1 |
<?php |
2 |
require("Smarty.class.php"); |
3 |
require("conn.inc"); |
4 |
|
5 |
$smarty = new Smarty; |
6 |
|
7 |
$smarty->assign( array ( Title=>"Pliva d.d." ) ); |
8 |
|
9 |
if (isset($from)) { |
10 |
$section=$from; |
11 |
} else { |
12 |
$section="new"; |
13 |
} |
14 |
|
15 |
$sql_where="where $visible_is_true"; |
16 |
|
17 |
unset($menu_item); // don't modify title in section.inc |
18 |
include("section.inc"); |
19 |
|
20 |
if ($section == "investor") { |
21 |
$back_url="investor.php"; |
22 |
if (! isset($type)) { |
23 |
$sql_where .= " and type='i'"; |
24 |
} |
25 |
} else { |
26 |
$back_url="index.php"; |
27 |
$sql_where.=" and (type='a' or type='c' or type='e' or type='f' or type='i' or type='n' or type='p' or type='r')"; // don't show company profile |
28 |
} |
29 |
|
30 |
$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, ) ); |
31 |
|
32 |
include("find_html_file.inc"); |
33 |
include("news_type.inc"); |
34 |
|
35 |
if (file_exists(find_html_file("news",$more))) { |
36 |
|
37 |
$main=join('',file(find_html_file("news",$more))); |
38 |
$back_url=$GLOBALS[HTTP_REFERER]; |
39 |
|
40 |
} else { |
41 |
if (isset($id)) { |
42 |
$sql_where.=" and id=$id "; |
43 |
} |
44 |
|
45 |
if (isset($type)) { |
46 |
if ($type == "n") { |
47 |
$sql_where .= " and (type='n' or type='i')"; |
48 |
} elseif ($type == "e") { |
49 |
$sql_where .= " and (type='e' or type='f')"; |
50 |
} elseif ($type == "f") { |
51 |
$sql_where .= " and type='f'"; |
52 |
} elseif ($type == "c") { |
53 |
$sql_where .= " and type='c'"; |
54 |
} |
55 |
} |
56 |
|
57 |
if (! isset($show) && !isset($start)) { |
58 |
$sql_limit="limit 10"; |
59 |
} elseif (isset($start)) { |
60 |
$sql_limit="limit 10,$start"; |
61 |
} |
62 |
|
63 |
|
64 |
if (isset($days)) { |
65 |
if ($days != 0) { |
66 |
$sql_where.=" and date(now())-date(date) > 0 and date(now())-date(date) < $days"; |
67 |
$title.=" : News in last $days days"; |
68 |
} |
69 |
$smarty->assign("days",$days); |
70 |
$smarty->assign("last_days",array(14,30,160,240,365)); |
71 |
$smarty->assign("last_desc",array("two weeks","one month","four months","six months","one year")); |
72 |
} |
73 |
|
74 |
$num_selected=0; |
75 |
$sql="select |
76 |
id,upper(title) as title,town_date,body,more,pdf, |
77 |
(date-now()::date) as comming,type,title as title_lc |
78 |
from news $sql_where order by priority desc,date desc $sql_limit"; |
79 |
# print "$sql"; |
80 |
$sth = $dbh->prepare("$sql"); |
81 |
$sth->execute(); |
82 |
while ($row=$sth->fetchrow_hash()) { |
83 |
$data[]=$row; |
84 |
$num_selected++; |
85 |
} |
86 |
|
87 |
if ($num_selected == 10) { |
88 |
$tmp="$PHP_SELF?start=".($start+10); |
89 |
if ($days) $tmp.="&days=$days"; |
90 |
if ($from) $tmp.="&from=$from"; |
91 |
if ($type) $tmp.="&type=$type"; |
92 |
$smarty->assign(array( |
93 |
"multi_page_show" => 1, |
94 |
"multi_page_next" => $tmp |
95 |
)); |
96 |
} |
97 |
if ($start && $start >= 10) { |
98 |
$tmp="$PHP_SELF?start=".($start-10); |
99 |
if ($days) $tmp.="&days=$days"; |
100 |
if ($from) $tmp.="&from=$from"; |
101 |
if ($type) $tmp.="&type=$type"; |
102 |
$smarty->assign(array( |
103 |
"multi_page_show" => 1, |
104 |
"multi_page_prev" => $tmp |
105 |
)); |
106 |
} |
107 |
|
108 |
if (isset($id) && $num_selected == 1) { |
109 |
$title.=" : ".$news_type[ $data[0][type] ]." : ".$data[0][title_lc]; |
110 |
} else { |
111 |
$title.=" : ".$news_type[ $data[0][type] ]; |
112 |
} |
113 |
|
114 |
if (isset($days) && $num_selected == 0) { |
115 |
$warning = "There are no news for last $days days."; |
116 |
} elseif ($main == "" && $num_selected == 0) { |
117 |
$warning = "This news item is no longer available"; |
118 |
} |
119 |
|
120 |
$smarty->assign(array( |
121 |
data=>$data, |
122 |
warning=>$warning |
123 |
)); |
124 |
|
125 |
$main=$smarty->fetch("new.tpl"); |
126 |
|
127 |
if (isset($id) && find_html_file("news",$data[0][more])) { |
128 |
$main=join('',file(find_html_file("news",$data[0][more]))); |
129 |
} |
130 |
|
131 |
|
132 |
} |
133 |
|
134 |
include("common.inc"); |
135 |
$smarty->assign( array(back_url=>$back_url, MAIN=>$main, |
136 |
Section_title=>$title ) ); |
137 |
|
138 |
$smarty->display("index.tpl"); |
139 |
?> |