1 |
<?php |
2 |
include_once("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 ($del_id) { |
9 |
include_once("inc/newsDelete.php"); |
10 |
newsDelete($del_id); |
11 |
unset($top_edit, $wn_edit, $pn_edit); |
12 |
} |
13 |
if ($down_id) $dbh->dbh_do("UPDATE news SET ord = ord + 1 WHERE (news_id = $down_id)"); |
14 |
if ($up_id) $dbh->dbh_do("UPDATE news SET ord = ord - 1 WHERE (news_id = $up_id)"); |
15 |
$cat = "c"; |
16 |
if ($section_menu == "zensko") $cat = "z"; |
17 |
if ($section_menu == "musko") $cat = "m"; |
18 |
if ($section_menu == "majkadijete") $cat = "d"; |
19 |
if ($section_menu == "treca") $cat = "r"; |
20 |
if ($section_menu == "teen") $cat = "e"; |
21 |
if (!$offset) $offset = 0; |
22 |
$empty = array("category" => $cat, "limit" => 11, "offset" => $offset, "npar" => 1); |
23 |
if ($top_edit && $ed_id <= 0 && $isEdit) { |
24 |
include_once("inc/newsEdit.php"); |
25 |
$ed = newsEdit($empty, "top_edit"); |
26 |
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
27 |
else $top_edit = false; |
28 |
} |
29 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
30 |
$a2 = array(); |
31 |
$lm = count($arts); |
32 |
if ($lm > $empty["limit"]) $lm = $empty["limit"]; |
33 |
for ($i = 0; $i < $lm; $i++) { |
34 |
$art = $arts[$i]; |
35 |
$ed = ""; |
36 |
if ($top_edit && ($art["id"] == $ed_id)) { |
37 |
include_once("inc/newsEdit.php"); |
38 |
$ed = newsEdit($art, "top_edit"); |
39 |
} |
40 |
if ($ed && is_string($ed)) array_push($a2, array("EDIT" => $ed)); |
41 |
else { |
42 |
if ($ed && $ed["category"] == $cat) $art = $ed; |
43 |
for ($j = 0; $j < count($art["text"]); $j++) |
44 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
45 |
include_once("inc/links.php"); |
46 |
array_push($a2, array( |
47 |
"id" => $art["id"], |
48 |
"title" => MyEscape($art["title"]), |
49 |
"lead" => MyEscape($art["lead"]), |
50 |
"titlepic_url" => MyEscape($art["pic_url"]), |
51 |
"titlepic_alt" => MyEscape($art["pic_alt"]), |
52 |
"titlepic_type" => $art["pic_pos"], |
53 |
"titlepic_width" => $art["pic_w"], |
54 |
"titlepic_height" => $art["pic_h"], |
55 |
"text" => $art["text"], |
56 |
"links" => GetLinks($art["read"] && $art["id"], |
57 |
MyEscape($art["more"]), MyEscape($art["more_title"]), |
58 |
$art["id"], $empty["category"], "top", $isEdit, true, |
59 |
($i > 0), ($i < count($arts) - 1)) |
60 |
)); |
61 |
} |
62 |
} |
63 |
$tpl->assign("top", $a2); |
64 |
$tpl->assign("cat", $cat); |
65 |
$tpl->assign("next", (count($arts) > 10) ? ($offset + 10) : 0); |
66 |
$tpl->assign("prev", ($offset > 0) ? ($offset - 10) : false); |
67 |
} |
68 |
$dbh->disconnect(); |
69 |
?> |