1 |
<?php |
2 |
include("inc/conn.php"); |
3 |
include_once("inc/newsShow.php"); |
4 |
if ($show) { |
5 |
$section_menu = "main"; |
6 |
$arts = newsLoad($id, $cat); |
7 |
newsShow(array_shift($arts)); |
8 |
} else { |
9 |
if ($isEdit) { |
10 |
if ($del_id) { |
11 |
include_once("inc/newsDelete.php"); |
12 |
newsDelete($del_id); |
13 |
unset($top_edit, $wn_edit, $pn_edit); |
14 |
} |
15 |
if ($down_id) $dbh->dbh_do("UPDATE news SET ord = ord + 1 WHERE (news_id = $down_id)"); |
16 |
if ($up_id) $dbh->dbh_do("UPDATE news SET ord = ord - 1 WHERE (news_id = $up_id)"); |
17 |
} |
18 |
$cat = "c"; |
19 |
if ($section_menu == "zensko") $cat = "z"; |
20 |
if ($section_menu == "musko") $cat = "m"; |
21 |
if ($section_menu == "majkadijete") $cat = "d"; |
22 |
if ($section_menu == "treca") $cat = "r"; |
23 |
if ($section_menu == "mladi") $cat = "e"; |
24 |
if ($section_menu == "ovisnosti") $cat = "o"; |
25 |
if (!$offset) $offset = 0; |
26 |
$empty = array("category" => $cat, "limit" => 11, "offset" => $offset, "npar" => 0); |
27 |
if ($top_edit && $ed_id <= 0 && $isEdit) { |
28 |
include_once("inc/newsEdit.php"); |
29 |
$ed = newsEdit($empty, "top_edit"); |
30 |
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
31 |
else $top_edit = false; |
32 |
} |
33 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
34 |
$a2 = array(); |
35 |
$lm = count($arts); |
36 |
if ($lm > $empty["limit"]) $lm = $empty["limit"]; |
37 |
for ($i = 0; $i < $lm; $i++) { |
38 |
$art = $arts[$i]; |
39 |
$ed = ""; |
40 |
if ($top_edit && ($art["id"] == $ed_id)) { |
41 |
include_once("inc/newsEdit.php"); |
42 |
$ed = newsEdit($art, "top_edit"); |
43 |
} |
44 |
if ($ed && is_string($ed)) array_push($a2, array("EDIT" => $ed)); |
45 |
else { |
46 |
if ($ed && $ed["category"] == $cat) $art = $ed; |
47 |
for ($j = 0; $j < count($art["text"]); $j++) |
48 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
49 |
array_push($a2, array( |
50 |
"id" => $art["id"], |
51 |
"title" => MyEscape($art["title"]), |
52 |
"lead" => MyEscape($art["lead"]), |
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 |
)); |
64 |
} |
65 |
} |
66 |
$tpl->assign("top", $a2); |
67 |
$tpl->assign("cat", $cat); |
68 |
$tpl->assign("next", (count($arts) > 10) ? ($offset + 10) : 0); |
69 |
$tpl->assign("prev", ($offset > 0) ? ($offset - 10) : false); |
70 |
} |
71 |
$dbh->disconnect(); |
72 |
?> |