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