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 |
if ($flip_id) $dbh->dbh_do("UPDATE news SET prikazi = NOT prikazi WHERE (news_id = $flip_id)"); |
17 |
} |
18 |
$cat = "i"; $acat = "z"; |
19 |
if (!$offset) $offset = 0; |
20 |
$empty = array("category" => $cat, "limit" => 10, "offset" => $offset, "npar" => 0); |
21 |
if ($top_edit && $ed_id <= 0 && $isEdit) { |
22 |
include_once("inc/newsEdit.php"); |
23 |
$ed = newsEdit($empty, "top_edit"); |
24 |
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
25 |
else $top_edit = false; |
26 |
} |
27 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"] + 1, $empty["offset"], $empty["npar"]); |
28 |
$a2 = array(); |
29 |
$lm = count($arts); |
30 |
if ($lm > $empty["limit"]) $lm = $empty["limit"]; |
31 |
for ($i = 0; $i < $lm; $i++) { |
32 |
$art = $arts[$i]; |
33 |
$ed = ""; |
34 |
if ($top_edit && ($art["id"] == $ed_id)) { |
35 |
include_once("inc/newsEdit.php"); |
36 |
$ed = newsEdit($art, "top_edit"); |
37 |
} |
38 |
if ($ed && is_string($ed)) array_push($a2, array("EDIT" => $ed)); |
39 |
else { |
40 |
if ($ed && $ed["category"] == $cat) $art = $ed; |
41 |
for ($j = 0; $j < count($art["text"]); $j++) |
42 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
43 |
array_push($a2, array( |
44 |
"id" => $art["id"], |
45 |
"title" => MyEscape($art["title"]), |
46 |
"lead" => MyEscape($art["lead"]), |
47 |
"pgfs" => (count($art["text"]) > 0) ? true : false, |
48 |
"titlepic_url" => MyEscape($art["pic_url"]), |
49 |
"titlepic_alt" => MyEscape($art["pic_alt"]), |
50 |
"titlepic_type" => $art["pic_pos"], |
51 |
"titlepic_width" => $art["pic_w"], |
52 |
"titlepic_height" => $art["pic_h"], |
53 |
"text" => $art["text"], |
54 |
"links" => GetLinks((($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"] && (!$art["more"] || ($art["more"] && !strpos($art["more"], "?")))) ? $art["read"] : "", |
55 |
/* MyEscape($art["more"]) */ /* ((count($art["text"]) > 0 || strstr("?", $art["more"]) == 0) && $art["id"]) ? $art["more"] : "", */ "", |
56 |
MyEscape($art["more_title"]), $art["id"], $empty["category"], "top", |
57 |
true, ($i > 0), ($i < count($arts) - 1), $art["show"], $art["related"]), |
58 |
"read" => $art["read"] || ($art["more"] && !strstr($art["more"], "?")) ? $art["read"] : "" |
59 |
)); |
60 |
} |
61 |
} |
62 |
$tpl->assign("top", $a2); |
63 |
$tpl->assign("cat", $cat); |
64 |
$tpl->assign("next", (count($arts) > 10) ? ($offset + 10) : 0); |
65 |
$tpl->assign("prev", $offset ? ($offset - 10) : 0); |
66 |
$tpl->assign("offset", $offset); |
67 |
} |
68 |
$dbh->disconnect(); |
69 |
?> |