1 |
<?php |
2 |
include("inc/conn.php"); |
3 |
include_once("inc/newsShow.php"); |
4 |
if ($show) { |
5 |
$arts = newsLoad($id, $cat); |
6 |
newsShow(array_shift($arts)); |
7 |
} else { |
8 |
if ($isEdit) { |
9 |
if ($del_id) { |
10 |
include_once("inc/newsDelete.php"); |
11 |
newsDelete($del_id); |
12 |
unset($top_edit, $wn_edit, $pn_edit); |
13 |
} |
14 |
if ($down_id) $dbh->dbh_do("UPDATE news SET ord = ord + 1 WHERE (news_id = $down_id)"); |
15 |
if ($up_id) $dbh->dbh_do("UPDATE news SET ord = ord - 1 WHERE (news_id = $up_id)"); |
16 |
} |
17 |
$empty = array("category" => "t", "limit" => 1, "offset" => 0, "npar" => 0); |
18 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
19 |
$art = array_shift($arts); |
20 |
$ed = ""; |
21 |
if ($top_edit && ($art["id"] == $ed_id || $ed_id <= 0) && $isEdit) { |
22 |
include_once("inc/newsEdit.php"); |
23 |
$ed = newsEdit(($ed_id > 0) ? $art : $empty, "top_edit"); |
24 |
} |
25 |
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
26 |
else { |
27 |
if ($ed && $ed["category"] == "t") $art = $ed; |
28 |
$tpl->assign("top_id", $art["id"]); |
29 |
$tpl->assign("top_title", MyEscape($art["title"])); |
30 |
$tpl->assign("top_lead", MyEscape($art["lead"])); |
31 |
$tpl->assign("top_pgfs", (count($art["text"]) > 0) ? true : false); |
32 |
$tpl->assign("top_titlepic_url", MyEscape($art["pic_url"])); |
33 |
$tpl->assign("top_titlepic_alt", MyEscape($art["pic_alt"])); |
34 |
$tpl->assign("top_titlepic_type", $art["pic_pos"]); |
35 |
$tpl->assign("top_titlepic_width", $art["pic_w"]); |
36 |
$tpl->assign("top_titlepic_height", $art["pic_h"]); |
37 |
for ($j = 0; $j < count($art["text"]); $j++) |
38 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
39 |
$tpl->assign("top_text", $art["text"]); |
40 |
include_once("inc/author.php"); |
41 |
$tpl->assign("AUTHOR", GetAuthor($art["au_pic"], |
42 |
$art["au_alt"], $art["au_info"], |
43 |
$art["au_w"], $art["au_h"])); |
44 |
$tpl->assign("top_links", GetLinks($art["read"] && $art["id"], |
45 |
/* MyEscape($art["more"]) */ (count($art["text"]) > 0 && $art["id"]) ? $art["more"] : "", |
46 |
MyEscape($art["more_title"]), $art["id"], $empty["category"], |
47 |
"top", $isEdit, false, false, false)); |
48 |
} |
49 |
$menu2 = array(); |
50 |
$empty = array("category" => "w", "limit" => $isEdit ? 0 : ($wn_edit && !$ed_id ? 9 : 10), "offset" => 0, "npar" => 0); |
51 |
$ed = ""; |
52 |
if ($wn_edit && $ed_id <= 0 && $isEdit) { |
53 |
include_once("inc/newsEdit.php"); |
54 |
$ed = newsEdit($empty, "wn_edit", true); |
55 |
if ($ed && is_string($ed)) $tpl->assign("WN_EDIT", $ed); |
56 |
else $wn_edit = false; |
57 |
} |
58 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
59 |
$wn = array(); |
60 |
$tmp2 = array(); |
61 |
for ($i = 0; $i < count($arts); $i++) { |
62 |
$art = $arts[$i]; |
63 |
$ed = ""; |
64 |
if ($wn_edit && $art["id"] == $ed_id && $isEdit) { |
65 |
include_once("inc/newsEdit.php"); |
66 |
$art["nlimit"] = count($arts); |
67 |
$ed = newsEdit($art, "wn_edit", true); |
68 |
} |
69 |
if ($ed && is_string($ed)) array_push($wn, array("EDIT" => $ed)); |
70 |
else { |
71 |
if ($ed && $ed["category"] == "w") $art = $ed; |
72 |
for ($j = 0; $j < count($art["text"]); $j++) |
73 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
74 |
list($art["pic_w"], $art["pic_h"]) = PicResize($art["pic_w"], $art["pic_h"]); |
75 |
array_push($wn, array( |
76 |
"id" => $art["id"], |
77 |
"title" => MyEscape($art["title"]), |
78 |
"lead" => MyEscape($art["lead"]), |
79 |
"pgfs" => (count($art["text"]) > 0) ? true : false, |
80 |
"pic" => MyEscape($art["pic_url"]), |
81 |
"alt" => MyEscape($art["pic_alt"]), |
82 |
"pos" => MyEscape($art["pic_pos"]), |
83 |
"width" => $art["pic_w"], |
84 |
"height" => $art["pic_h"], |
85 |
"links" => GetLinks(($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"], |
86 |
MyEscape($art["more"]), MyEscape($art["more_title"]), |
87 |
$art["id"], $empty["category"], "wn", $isEdit, true, |
88 |
($i > 0), ($i < count($arts) - 1)), |
89 |
"text" => $art["text"] |
90 |
)); |
91 |
array_push($tmp2, array( |
92 |
"cat" => $empty["category"], |
93 |
"id" => $art["id"], |
94 |
"title" => MyEscape($art["title"]), |
95 |
"url" => MyEscape($art["more"]), |
96 |
"more" => ($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"] |
97 |
)); |
98 |
} |
99 |
} |
100 |
array_push($menu2, array( |
101 |
"title" => "Vijesti", |
102 |
"class" => "wnhead", |
103 |
"pre" => "wn-", |
104 |
"items" => $tmp2 |
105 |
)); |
106 |
$empty = array("category" => "p", $isEdit ? 0 : "limit" => ($pn_edit && !$ed_id ? 9 : 10), "offset" => 0, "npar" => 0); |
107 |
$ed = ""; |
108 |
if ($pn_edit && $ed_id <= 0 && $isEdit) { |
109 |
include_once("inc/newsEdit.php"); |
110 |
$ed = newsEdit($empty, "pn_edit", true); |
111 |
if ($ed && is_string($ed)) $tpl->assign("PN_EDIT", $ed); |
112 |
else $pn_edit = false; |
113 |
} |
114 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
115 |
$pn = array(); |
116 |
$tmp2 = array(); |
117 |
for ($i = 0; $i < count($arts); $i++) { |
118 |
$art = $arts[$i]; |
119 |
$ed = ""; |
120 |
if ($pn_edit && $art["id"] == $ed_id && $isEdit) { |
121 |
include_once("inc/newsEdit.php"); |
122 |
$art["nlimit"] = count($arts); |
123 |
$ed = newsEdit($art, "pn_edit", true); |
124 |
} |
125 |
if ($ed && is_string($ed)) array_push($pn, array("EDIT" => $ed)); |
126 |
else { |
127 |
if ($ed && $ed["category"] == "p") $art = $ed; |
128 |
for ($j = 0; $j < count($art["text"]); $j++) |
129 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
130 |
list($art["pic_w"], $art["pic_h"]) = PicResize($art["pic_w"], $art["pic_h"]); |
131 |
array_push($pn, array( |
132 |
"id" => $art["id"], |
133 |
"title" => MyEscape($art["title"]), |
134 |
"lead" => MyEscape($art["lead"]), |
135 |
"pgfs" => (count($art["text"]) > 0) ? true : false, |
136 |
"pic" => MyEscape($art["pic_url"]), |
137 |
"alt" => MyEscape($art["pic_alt"]), |
138 |
"pos" => MyEscape($art["pic_pos"]), |
139 |
"width" => MyEscape($art["pic_w"]), |
140 |
"height" => MyEscape($art["pic_h"]), |
141 |
"links" => GetLinks(($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"], |
142 |
MyEscape($art["more"]), MyEscape($art["more_title"]), |
143 |
$art["id"], $empty["category"], "pn", $isEdit, true, |
144 |
($i > 0), ($i < count($arts) - 1)), |
145 |
"text" => MyEscape($art["text"]) |
146 |
)); |
147 |
array_push($tmp2, array( |
148 |
"cat" => $empty["category"], |
149 |
"id" => $art["id"], |
150 |
"title" => MyEscape($art["title"]), |
151 |
"url" => MyEscape($art["more"]), |
152 |
"more" => ($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"] |
153 |
)); |
154 |
} |
155 |
} |
156 |
array_push($menu2, array( |
157 |
"title" => "Novo na PLIVA".($isMed ? "med.net" : "zdravlju"), |
158 |
"class" => "pnhead", |
159 |
"pre" => "pn-", |
160 |
"items" => $tmp2 |
161 |
)); |
162 |
$tpl->assign("wn", $wn); |
163 |
$tpl->assign("pn", $pn); |
164 |
$tpl->assign("top_edit", $top_edit); |
165 |
$tpl->assign("wn_edit", $wn_edit); |
166 |
$tpl->assign("pn_edit", $pn_edit); |
167 |
if (!$isMed) $tpl->assign("MENU2", $menu2); |
168 |
} |
169 |
$dbh->disconnect(); |
170 |
?> |