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); |
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 |
$cat = "c"; $acat = "s"; |
18 |
if ($section_menu == "zensko") { $cat = "z"; $acat2 = "z"; } |
19 |
if ($section_menu == "musko") { $cat = "m"; $acat2 = "m"; } |
20 |
if ($section_menu == "mid") { $cat = "d"; $acat2 = "d"; } |
21 |
if ($section_menu == "treca") { $cat = "r"; $acat2 = "t"; } |
22 |
if ($section_menu == "mladi") { $cat = "e"; $acat2 = "l"; } |
23 |
if ($section_menu == "ovisnosti") { $cat = "o"; $acat2 = "o"; } |
24 |
if (!$offset) $offset = 0; |
25 |
$empty = array("category" => $cat, "limit" => 10, "offset" => $offset, "npar" => 0); |
26 |
if ($top_edit && $ed_id <= 0 && $isEdit) { |
27 |
include_once("inc/newsEdit.php"); |
28 |
$ed = newsEdit($empty, "top_edit"); |
29 |
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
30 |
else $top_edit = false; |
31 |
} |
32 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"] + 1, $empty["offset"], $empty["npar"]); |
33 |
$a2 = array(); |
34 |
$lm = count($arts); |
35 |
if ($lm > $empty["limit"]) $lm = $empty["limit"]; |
36 |
for ($i = 0; $i < $lm; $i++) { |
37 |
$art = $arts[$i]; |
38 |
$ed = ""; |
39 |
if ($top_edit && ($art["id"] == $ed_id)) { |
40 |
include_once("inc/newsEdit.php"); |
41 |
$ed = newsEdit($art, "top_edit"); |
42 |
} |
43 |
if ($ed && is_string($ed)) array_push($a2, array("EDIT" => $ed)); |
44 |
else { |
45 |
if ($ed && $ed["category"] == $cat) $art = $ed; |
46 |
for ($j = 0; $j < count($art["text"]); $j++) |
47 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
48 |
array_push($a2, array( |
49 |
"id" => $art["id"], |
50 |
"title" => MyEscape($art["title"]), |
51 |
"lead" => MyEscape($art["lead"]), |
52 |
"pgfs" => (count($art["text"]) > 0) ? true : false, |
53 |
"titlepic_url" => MyEscape($art["pic_url"]), |
54 |
"titlepic_alt" => MyEscape($art["pic_alt"]), |
55 |
"titlepic_type" => $art["pic_pos"], |
56 |
"titlepic_width" => $art["pic_w"], |
57 |
"titlepic_height" => $art["pic_h"], |
58 |
"text" => $art["text"], |
59 |
"links" => GetLinks($art["read"] && $art["id"], |
60 |
/* MyEscape($art["more"]) */ ((count($art["text"]) > 0 || strstr("?", $art["more"]) == 0) && $art["id"]) ? $art["more"] : "", |
61 |
MyEscape($art["more_title"]), $art["id"], $empty["category"], "top", |
62 |
$isEdit, true, ($i > 0), ($i < count($arts) - 1)), |
63 |
"read" => $art["read"] || ($art["more"] && !strstr($art["more"], "?")) ? $art["read"] : "" |
64 |
)); |
65 |
} |
66 |
} |
67 |
$tpl->assign("top", $a2); |
68 |
$tpl->assign("cat", $cat); |
69 |
$tpl->assign("next", (count($arts) > 10) ? ($offset + 10) : 0); |
70 |
$tpl->assign("prev", $offset ? ($offset - 10) : 0); |
71 |
$tpl->assign("offset", $offset); |
72 |
} |
73 |
$dbh->disconnect(); |
74 |
?> |