1 |
<?php |
2 |
|
3 |
$max_title_len=20; // max. length of titles in drop-down |
4 |
|
5 |
require("Smarty.class.php"); |
6 |
require("conn.inc"); |
7 |
|
8 |
$smarty = new Smarty; |
9 |
|
10 |
$smarty->assign( array ( Title=>"PLIVA Ljubljana" ) ); |
11 |
|
12 |
include("find_html_file.inc"); |
13 |
include("fix_msshit.inc"); |
14 |
|
15 |
if (! isset($p)) { |
16 |
$p=0; |
17 |
$section="domov"; |
18 |
} else { |
19 |
// fetch current page |
20 |
$sql="select id,menu_num,name,html,path,type from multi where $visible_is_true and id=$p"; |
21 |
$sth = $dbh->prepare("$sql"); |
22 |
$sth->execute(); |
23 |
if (! $row=$sth->fetchrow_hash()) { |
24 |
$sth = $dbh->prepare("select min(num) as menu_num from menu"); |
25 |
$sth->execute(); |
26 |
$row2=$sth->fetchrow_hash(); |
27 |
$row = array(id=>0,menu_num=>$row2[menu_num],name=>"Can't find page",html=>'',path=>'',type=>''); |
28 |
} |
29 |
|
30 |
$title.=" : $row[name]"; |
31 |
$smarty->assign("mtext",$row[name]); |
32 |
if ($row[type]=="h" && find_html_file("multi",$row[html])) { |
33 |
$main=join('',file(find_html_file("multi",$row[html]))); |
34 |
$main=fix_msshit($main); |
35 |
} elseif ($row[type]=="p") { |
36 |
if (find_html_file("",$row[path])) { |
37 |
$main=join('',file(find_html_file("",$row[path]))); |
38 |
// fix entities from MS programs |
39 |
$main=fix_msshit($main); |
40 |
} else { |
41 |
$main="<b>can't find $row[path] for id $p</b>"; |
42 |
} |
43 |
// try to load translation (html fix-up or something) |
44 |
$fix_up="./fix_up/".str_replace("/","_",dirname($row[path])).".inc"; |
45 |
|
46 |
# $main.="<!-- trying to use fixup $fix_up -->"; ## DEBUG |
47 |
if (file_exists($fix_up)) { |
48 |
include($fix_up); |
49 |
# $main.="<!-- fixup: $fix_up -->"; ## DEBUG |
50 |
} |
51 |
} else { |
52 |
$main="<b>can't find multi page for id $p</b>"; |
53 |
} |
54 |
|
55 |
// fetch section |
56 |
$sql="select section,item from menu where num=$row[menu_num]"; |
57 |
$sth = $dbh->prepare("$sql"); |
58 |
$sth->execute(); |
59 |
$menu_row=$sth->fetchrow_hash(); |
60 |
$section=$menu_row[section]; |
61 |
$title=" : $menu_row[item] $title"; |
62 |
$title=str_replace("\\n"," ",$title); // nuke nl chars |
63 |
|
64 |
// fetch all pages in this multi-page |
65 |
$sql="select id,name from multi where $visible_is_true and menu_num=$row[menu_num] order by menu_num,num"; |
66 |
$sth = $dbh->prepare("$sql"); |
67 |
$sth->execute(); |
68 |
|
69 |
$multi_page_url=array(); |
70 |
$multi_page_options=array(); |
71 |
$multi_page_id=array(); |
72 |
$max=0; |
73 |
while ($row=$sth->fetchrow_hash()) { |
74 |
array_push($multi_page_url,"$PHP_SELF?p=$row[id]"); |
75 |
array_push($multi_page_id,$row[id]); |
76 |
$drop_title=$row[name]; |
77 |
if (strlen($drop_title) > $max_title_len) $drop_title=substr($drop_title,0,$max_title_len)."..."; |
78 |
$multi_page_options[$row[id]]=$drop_title; |
79 |
if ($row[id] == $p) { |
80 |
$current=$max; |
81 |
$curr_id=$row[id]; |
82 |
} |
83 |
$max++; |
84 |
} |
85 |
$smarty->assign(array( |
86 |
"multi_page_show" => 1, |
87 |
"multi_page_current"=>($current+1), |
88 |
"multi_page_max"=>$max, |
89 |
"multi_page_prev"=>$multi_page_url[$current-1], |
90 |
"multi_page_next"=>$multi_page_url[$current+1], |
91 |
"multi_page_options"=>$multi_page_options, |
92 |
"multi_page_curr_id"=>$curr_id |
93 |
)); |
94 |
} |
95 |
|
96 |
require("inc/section.php"); |
97 |
include("common.inc"); |
98 |
|
99 |
$smarty->assign(array(section=>$section, |
100 |
mpic=>$mpic, |
101 |
Section_title=>$title, |
102 |
rnd=>$rnd, |
103 |
MAIN=>$main, |
104 |
)); |
105 |
|
106 |
$smarty->display("index.tpl"); |
107 |
?> |