1 |
ravilov |
1.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 |
ravilov |
1.2 |
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 |
ravilov |
1.1 |
$empty = array("category" => "t", "limit" => 1, "npar" => 1); |
16 |
|
|
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["npar"]); |
17 |
|
|
$art = array_shift($arts); |
18 |
|
|
$ed = ""; |
19 |
|
|
if ($top_edit && ($art["id"] == $ed_id || $ed_id <= 0)) { |
20 |
|
|
include_once("inc/newsEdit.php"); |
21 |
|
|
$ed = newsEdit(($ed_id > 0) ? $art : $empty, "top_edit"); |
22 |
|
|
} |
23 |
|
|
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
24 |
|
|
else { |
25 |
ravilov |
1.2 |
if ($ed && $ed["category"] == "t") $art = $ed; |
26 |
ravilov |
1.1 |
$tpl->assign("top_id", $art["id"]); |
27 |
|
|
$tpl->assign("top_title", MyEscape($art["title"])); |
28 |
|
|
$tpl->assign("top_lead", MyEscape($art["lead"])); |
29 |
|
|
$tpl->assign("top_titlepic_url", MyEscape($art["pic_url"])); |
30 |
|
|
$tpl->assign("top_titlepic_alt", MyEscape($art["pic_alt"])); |
31 |
|
|
$tpl->assign("top_titlepic_type", $art["pic_pos"]); |
32 |
|
|
$tpl->assign("top_titlepic_width", $art["pic_w"]); |
33 |
|
|
$tpl->assign("top_titlepic_height", $art["pic_h"]); |
34 |
|
|
for ($j = 0; $j < count($art["text"]); $j++) |
35 |
|
|
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"])); |
36 |
|
|
$tpl->assign("top_text", $art["text"]); |
37 |
|
|
include_once("inc/links.php"); |
38 |
|
|
$tpl->assign("top_links", GetLinks($art["read"] && $art["id"], |
39 |
ravilov |
1.2 |
MyEscape($art["more"]), $art["id"], $empty["category"], "top", |
40 |
|
|
false, false, false)); |
41 |
ravilov |
1.1 |
} |
42 |
|
|
$empty = array("category" => "w", "limit" => ($wn_edit ? 4 : 5), "npar" => 0); |
43 |
ravilov |
1.2 |
$ed = ""; |
44 |
ravilov |
1.1 |
if ($wn_edit && $ed_id <= 0) { |
45 |
|
|
include_once("inc/newsEdit.php"); |
46 |
|
|
$ed = newsEdit($empty, "wn_edit"); |
47 |
|
|
if ($ed && is_string($ed)) $tpl->assign("WN_EDIT", $ed); |
48 |
|
|
else $wn_edit = false; |
49 |
|
|
} |
50 |
|
|
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["npar"]); |
51 |
|
|
$wn = array(); |
52 |
|
|
for ($i = 0; $i < count($arts); $i++) { |
53 |
|
|
$art = $arts[$i]; |
54 |
|
|
$ed = ""; |
55 |
|
|
if ($wn_edit && $art["id"] == $ed_id) { |
56 |
|
|
include_once("inc/newsEdit.php"); |
57 |
ravilov |
1.2 |
$art["nlimit"] = count($arts); |
58 |
ravilov |
1.1 |
$ed = newsEdit($art, "wn_edit"); |
59 |
|
|
} |
60 |
|
|
if ($ed && is_string($ed)) array_push($wn, array("EDIT" => $ed)); |
61 |
|
|
else { |
62 |
ravilov |
1.2 |
if ($ed && $ed["category"] == "w") $art = $ed; |
63 |
ravilov |
1.1 |
for ($j = 0; $j < count($art["text"]); $j++) |
64 |
|
|
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"])); |
65 |
|
|
include_once("inc/links.php"); |
66 |
|
|
array_push($wn, array( |
67 |
|
|
"id" => $art["id"], |
68 |
|
|
"title" => MyEscape($art["title"]), |
69 |
|
|
"lead" => MyEscape($art["lead"]), |
70 |
|
|
"pic" => MyEscape($art["pic_url"]), |
71 |
|
|
"alt" => MyEscape($art["pic_alt"]), |
72 |
|
|
"pos" => MyEscape($art["pic_pos"]), |
73 |
|
|
"width" => MyEscape($art["pic_w"]), |
74 |
|
|
"height" => MyEscape($art["pic_h"]), |
75 |
|
|
"links" => GetLinks($art["read"] && $art["id"], |
76 |
|
|
MyEscape($art["more"]), $art["id"], |
77 |
ravilov |
1.2 |
$empty["category"], "wn", true, ($i > 0), |
78 |
|
|
($i < count($arts) - 1)), |
79 |
ravilov |
1.1 |
"text" => $art["text"] |
80 |
|
|
)); |
81 |
|
|
} |
82 |
|
|
} |
83 |
|
|
$empty = array("category" => "p", "limit" => ($pn_edit ? 4 : 5), "npar" => 0); |
84 |
ravilov |
1.2 |
$ed = ""; |
85 |
ravilov |
1.1 |
if ($pn_edit && $ed_id <= 0) { |
86 |
|
|
include_once("inc/newsEdit.php"); |
87 |
|
|
$ed = newsEdit($empty, "pn_edit"); |
88 |
|
|
if ($ed && is_string($ed)) $tpl->assign("PN_EDIT", $ed); |
89 |
|
|
else $pn_edit = false; |
90 |
|
|
} |
91 |
|
|
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["npar"]); |
92 |
|
|
$pn = array(); |
93 |
|
|
for ($i = 0; $i < count($arts); $i++) { |
94 |
|
|
$art = $arts[$i]; |
95 |
|
|
$ed = ""; |
96 |
|
|
if ($pn_edit && $art["id"] == $ed_id) { |
97 |
|
|
include_once("inc/newsEdit.php"); |
98 |
ravilov |
1.2 |
$art["nlimit"] = count($arts); |
99 |
ravilov |
1.1 |
$ed = newsEdit($art, "pn_edit"); |
100 |
|
|
} |
101 |
|
|
if ($ed && is_string($ed)) array_push($pn, array("EDIT" => $ed)); |
102 |
|
|
else { |
103 |
ravilov |
1.2 |
if ($ed && $ed["category"] == "p") $art = $ed; |
104 |
ravilov |
1.1 |
for ($j = 0; $j < count($art["text"]); $j++) |
105 |
|
|
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"])); |
106 |
|
|
include_once("inc/links.php"); |
107 |
|
|
array_push($pn, array( |
108 |
|
|
"id" => $art["id"], |
109 |
|
|
"title" => MyEscape($art["title"]), |
110 |
|
|
"lead" => MyEscape($art["lead"]), |
111 |
|
|
"pic" => MyEscape($art["pic_url"]), |
112 |
|
|
"alt" => MyEscape($art["pic_alt"]), |
113 |
|
|
"pos" => MyEscape($art["pic_pos"]), |
114 |
|
|
"width" => MyEscape($art["pic_w"]), |
115 |
|
|
"height" => MyEscape($art["pic_h"]), |
116 |
|
|
"links" => GetLinks($art["read"] && $art["id"], |
117 |
|
|
MyEscape($art["more"]), $art["id"], |
118 |
ravilov |
1.2 |
$empty["category"], "pn", true, ($i > 0), |
119 |
|
|
($i < count($arts) - 1)), |
120 |
ravilov |
1.1 |
"text" => MyEscape($art["text"]) |
121 |
|
|
)); |
122 |
|
|
} |
123 |
|
|
} |
124 |
|
|
$tpl->assign("wn", $wn); |
125 |
|
|
$tpl->assign("pn", $pn); |
126 |
|
|
$tpl->assign("top_edit", $top_edit); |
127 |
|
|
$tpl->assign("wn_edit", $wn_edit); |
128 |
|
|
$tpl->assign("pn_edit", $pn_edit); |
129 |
|
|
} |
130 |
|
|
$dbh->disconnect(); |
131 |
|
|
?> |