70 |
usort($categories, "my_cmp"); |
usort($categories, "my_cmp"); |
71 |
// ----- |
// ----- |
72 |
$specs = array(); |
$specs = array(); |
73 |
$sql = "SELECT spec_id, opis FROM specijalizacije WHERE (NOT link)"; |
$sql = "SELECT spec_id, opis FROM specijalizacije WHERE (spec_id != 0) AND (NOT link)"; |
74 |
sql($sql); |
sql($sql); |
75 |
$sth = $dbh->prepare($sql); |
$sth = $dbh->prepare($sql); |
76 |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
79 |
$sth->finish(); |
$sth->finish(); |
80 |
usort($specs, "my_cmp"); |
usort($specs, "my_cmp"); |
81 |
// ----- |
// ----- |
82 |
|
$levels = array(); |
83 |
|
$sql = "SELECT level_id, class, name FROM par_levels ORDER BY name"; |
84 |
|
sql($sql); |
85 |
|
$sth = $dbh->prepare($sql); |
86 |
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
87 |
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
88 |
|
while ($row = $sth->fetchrow_array()) array_push($levels, array("id" => $row[0], "class" => $row[1], "name" => $row[2])); |
89 |
|
$sth->finish(); |
90 |
|
// ----- |
91 |
global $cancel, $save; |
global $cancel, $save; |
92 |
if ($cancel || $save) { |
if ($cancel || $save) { |
93 |
if ($save) { |
if ($save) { |
94 |
// Move temp pics & save article. |
// Move temp pics & save article. |
95 |
if (ereg("$phptmp", $titlepic_url2) && $ed_id > 0) { |
if (ereg("$phptmp", $titlepic_url2) && $ed_id > 0 && file_exists("$syspicdir/$titlepic_url2")) { |
96 |
$sql = "SELECT title_pic FROM news WHERE (news_id = $ed_id)"; |
$sql = "SELECT title_pic FROM news WHERE (news_id = $ed_id)"; |
97 |
sql($sql); |
sql($sql); |
98 |
$sth = $dbh->prepare($sql); |
$sth = $dbh->prepare($sql); |
103 |
$row = array_shift($row); |
$row = array_shift($row); |
104 |
if ($row) MyDelete($syspicdir."/".$row); |
if ($row) MyDelete($syspicdir."/".$row); |
105 |
} |
} |
106 |
if (ereg("$phptmp", $author_url2) && $ed_id > 0) { |
if (ereg("$phptmp", $author_url2) && $ed_id > 0 && file_exists("$sysaupicdir/$author_url2")) { |
107 |
$sql = "SELECT author_pic FROM news WHERE (news_id = $ed_id)"; |
$sql = "SELECT author_pic FROM news WHERE (news_id = $ed_id)"; |
108 |
sql($sql); |
sql($sql); |
109 |
$sth = $dbh->prepare($sql); |
$sth = $dbh->prepare($sql); |
128 |
$ed_more_title = MyQuote($ed_more_title); |
$ed_more_title = MyQuote($ed_more_title); |
129 |
if (!$ed_titlepic_pos) $ed_titlepic_pos = 0; |
if (!$ed_titlepic_pos) $ed_titlepic_pos = 0; |
130 |
if ($ed_id > 0) { |
if ($ed_id > 0) { |
131 |
$sql = "UPDATE news SET category = '$ed_cat', title = $ed_title, lead = $ed_lead, title_pic = $ed_titlepic_nm, title_alt = $ed_titlepic_alt, title_pos = $ed_titlepic_pos, author_pic = $ed_author_nm, author_alt = $ed_author_alt, author_info = $ed_author_info, url = $ed_more, url_title = $ed_more_title, plivamed = ".($isMed?"true":"false").", d_change = NOW() WHERE (news_id = $ed_id)"; |
$sql = "UPDATE news SET category = '$ed_cat', title = $ed_title, lead = $ed_lead, title_pic = $ed_titlepic_nm, title_alt = $ed_titlepic_alt, title_pos = $ed_titlepic_pos, author_pic = $ed_author_nm, author_alt = $ed_author_alt, author_info = $ed_author_info, url = $ed_more, url_title = $ed_more_title, plivamed = ".($isMed?"true":"false").", ord = 0, d_change = NOW() WHERE (news_id = $ed_id)"; |
132 |
sql($sql); |
sql($sql); |
133 |
$dbh->dbh_do($sql); |
$dbh->dbh_do($sql); |
134 |
} else { |
} else { |
150 |
if ($titlepic_url2) MyMove("$syspicdir/$titlepic_url2", urldecode("$syspicdir/$titlepic_name")); |
if ($titlepic_url2) MyMove("$syspicdir/$titlepic_url2", urldecode("$syspicdir/$titlepic_name")); |
151 |
if ($author_url2) MyMove("$sysaupicdir/$author_url2", urldecode("$sysaupicdir/$author_name")); |
if ($author_url2) MyMove("$sysaupicdir/$author_url2", urldecode("$sysaupicdir/$author_name")); |
152 |
$i = 1; |
$i = 1; |
153 |
|
$parents = array(); |
154 |
|
$last_level = 0; |
155 |
|
$last_id = 0; |
156 |
while ($ed_id > 0 && isset(${"ed_text_id_".$i})) { |
while ($ed_id > 0 && isset(${"ed_text_id_".$i})) { |
157 |
global ${"ed_text_title_".$i}, ${"ed_text_".$i}, |
global ${"ed_text_title_".$i}, ${"ed_text_".$i}, |
158 |
${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, |
${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, |
159 |
${"ed_text_level_".$i}, ${"ed_hl_".$i}; |
${"ed_text_level_".$i}, ${"ed_hl_".$i}, |
160 |
list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev, $hl) = array( |
${"ed_textpic_exp_".$i}; |
161 |
|
list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev, $hl, $exp) = array( |
162 |
${"ed_text_id_".$i}, ${"ed_text_title_".$i}, |
${"ed_text_id_".$i}, ${"ed_text_title_".$i}, |
163 |
${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i}, |
${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i}, |
164 |
${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, |
${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, |
165 |
${"del_".$i}, ${"ed_text_level_".$i}, ${"ed_hl_".$i}); |
${"del_".$i}, ${"ed_text_level_".$i}, ${"ed_hl_".$i}, |
166 |
|
${"ed_textpic_exp_".$i}); |
167 |
|
if ($lev != $last_level) { |
168 |
|
if ($last_level) { |
169 |
|
if ($last_level < $lev) array_push($parents, $id); |
170 |
|
if ($last_level > $lev && count($parents) > 0) array_pop($parents); |
171 |
|
} |
172 |
|
$last_level = $lev; |
173 |
|
$parent = $parents[0]; |
174 |
|
if ($parent < 0) $parent = $last_id; |
175 |
|
} |
176 |
$tit = MyQuote($tit); |
$tit = MyQuote($tit); |
177 |
$txt = MyQuote($txt); |
$txt = MyQuote($txt); |
178 |
|
$exp = MyQuote($exp); |
179 |
$hl = MyQuote($hl); |
$hl = MyQuote($hl); |
180 |
$orig = basename($orig); |
$orig = basename($orig); |
181 |
$org = MyQuote($orig); |
$org = MyQuote($orig); |
195 |
$sth->finish(); |
$sth->finish(); |
196 |
} |
} |
197 |
if ($del) $sql = "DELETE FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)"; |
if ($del) $sql = "DELETE FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)"; |
198 |
else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, hl = $hl, pic = $org, alt = $alt, pos = $pos WHERE (news_id = $ed_id) AND (paragraph_id = $id)"; |
else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, hl = $hl, pic = $org, alt = $alt, pos = $pos, pic_title = $exp WHERE (news_id = $ed_id) AND (paragraph_id = $id)"; |
199 |
sql($sql); |
sql($sql); |
200 |
$dbh->dbh_do($sql); |
$dbh->dbh_do($sql); |
201 |
} else if (!$del) { |
} else if (!$del) { |
202 |
$sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, alt, pos, hl) VALUES ($ed_id, $tit, $lev, $txt, $org, $alt, $pos, $hl)"; |
$sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, alt, pos, hl, pic_title) VALUES ($ed_id, $tit, $lev, $txt, $org, $alt, $pos, $hl, $exp)"; |
203 |
sql($sql); |
sql($sql); |
204 |
$dbh->dbh_do($sql); |
$dbh->dbh_do($sql); |
205 |
$sql = "SELECT paragraph_id FROM paragraphs WHERE (text = $txt)"; |
$sql = "SELECT currval('paragraphs_paragraph_id_seq')::text"; |
206 |
sql($sql); |
sql($sql); |
207 |
$sth = $dbh->prepare($sql); |
$sth = $dbh->prepare($sql); |
208 |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
209 |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
210 |
$rows = array(); |
$row = $sth->fetchrow_array(); |
|
while ($row = $sth->fetchrow_array()) array_push($rows, $row); |
|
211 |
$sth->finish(); |
$sth->finish(); |
212 |
$row = array_pop($rows); |
$row = array_shift($row); |
213 |
if (is_array($row)) $row = array_shift($row); |
$last_id = $id = $row; |
|
$id = $row; |
|
214 |
} |
} |
215 |
if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig"); |
if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig"); |
216 |
$i++; |
$i++; |
232 |
for ($k = 0; $k < count($categories); $k++) { |
for ($k = 0; $k < count($categories); $k++) { |
233 |
$var = "ed_cat_".$categories[$k]["id"]; |
$var = "ed_cat_".$categories[$k]["id"]; |
234 |
global $$var; |
global $$var; |
235 |
if (!$$var) continue; |
if ($categories[$k]["id"] != $ed_cat && !$$var) continue; |
236 |
$sql = "INSERT INTO cat_news (news_id, cat_id) VALUES ($ed_id, '".$categories[$k]["id"]."')"; |
$sql = "INSERT INTO cat_news (news_id, cat_id) VALUES ($ed_id, '".$categories[$k]["id"]."')"; |
237 |
sql($sql); |
sql($sql); |
238 |
$dbh->dbh_do($sql); |
$dbh->dbh_do($sql); |
263 |
if ($size <= 0) continue; |
if ($size <= 0) continue; |
264 |
if (!$name) continue; |
if (!$name) continue; |
265 |
if ($tname == "none") continue; |
if ($tname == "none") continue; |
266 |
|
$name = strtr($name, "¹šðè澞©ŠÐÈÆ®Ž ", "ssdcczzSSDCCZZ_"); |
267 |
$nm = basename($tname); |
$nm = basename($tname); |
268 |
$ext = ereg_replace('^.*(\..+)$', '\1', $name); |
$ext = ereg_replace('^.*(\..+)$', '\1', $name); |
269 |
if ($key == "ed_titlepic_url") { |
if ($key == "ed_titlepic_url") { |
295 |
// ----- |
// ----- |
296 |
$tp = new Smarty(); |
$tp = new Smarty(); |
297 |
// ----- |
// ----- |
|
$levels = array(); |
|
|
$sql = "SELECT level_id, class, name FROM par_levels ORDER BY name"; |
|
|
sql($sql); |
|
|
$sth = $dbh->prepare($sql); |
|
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
|
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
|
|
while ($row = $sth->fetchrow_array()) array_push($levels, array("id" => $row[0], "class" => $row[1], "name" => $row[2])); |
|
|
$sth->finish(); |
|
298 |
$tp->assign("levels", $levels); |
$tp->assign("levels", $levels); |
299 |
// ----- |
// ----- |
300 |
global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos, |
global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos, |
345 |
$id = ${"ed_text_id_".$i}; |
$id = ${"ed_text_id_".$i}; |
346 |
global ${"ed_text_".$i}, ${"ed_text_title_".$i}, |
global ${"ed_text_".$i}, ${"ed_text_title_".$i}, |
347 |
${"ed_text_level_".$i}, ${"ed_textpic_alt_".$i}, |
${"ed_text_level_".$i}, ${"ed_textpic_alt_".$i}, |
348 |
${"ed_textpic_pos_".$i}, ${"ed_hl_".$i}; |
${"ed_textpic_pos_".$i}, ${"ed_hl_".$i}, |
349 |
|
${"ed_textpic_exp_".$i}; |
350 |
$pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ? |
$pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ? |
351 |
${"textpic_url_".$i} : ""; |
${"textpic_url_".$i} : ""; |
352 |
if (!$pic_url) $pic_url = ${"textpic_url2_".$i}; |
if (!$pic_url) $pic_url = ${"textpic_url2_".$i}; |
355 |
if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["pic"]; |
if ($art["text"][$j]["id"] == $id) $tmp = $art["text"][$j]["pic"]; |
356 |
if (!$pic_url && $tmp && !(${"clear_".$i} || ${"clr_".$i})) $pic_url = $tmp; |
if (!$pic_url && $tmp && !(${"clear_".$i} || ${"clr_".$i})) $pic_url = $tmp; |
357 |
$level = ${"ed_text_level_".$i}; |
$level = ${"ed_text_level_".$i}; |
358 |
$class = ""; |
list($w, $h) = PicSize($pic_url); |
|
while (list($key, $val) = each($levels)) |
|
|
if ($val["id"] == $level) $class = $val["class"]; |
|
359 |
array_push($ed_pgfs, array($id, |
array_push($ed_pgfs, array($id, |
360 |
${"ed_text_".$i}, ${"ed_text_title_".$i}, |
${"ed_text_".$i}, ${"ed_text_title_".$i}, |
361 |
$level, $class, $pic_url, ${"textpic_name_".$i}, |
$level, $pic_url, ${"textpic_name_".$i}, |
362 |
${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, |
${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, |
363 |
0, 0, ${"ed_hl_".$i}, false)); |
$w, $h, ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i}, false)); |
364 |
$i++; |
$i++; |
365 |
} |
} |
366 |
} else { |
} else { |
392 |
$art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]), |
$art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]), |
393 |
$art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"]); |
$art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"]); |
394 |
while ($art["text"] && list($id, $val) = each($art["text"])) { |
while ($art["text"] && list($id, $val) = each($art["text"])) { |
|
list($id, $txt, $title, $lev, $cls, $pic, $alt, $pos, $w, $h) = array( |
|
|
$val["id"], $val["text"], $val["title"], $val["level"], |
|
|
$val["class"], urldecode($val["pic"]), $val["alt"], $val["pos"], |
|
|
$val["w"], $val["h"]); |
|
395 |
array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"], |
array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"], |
396 |
$val["level"], $val["class"], urldecode($val["pic"]), |
$val["level"], urldecode($val["pic"]), |
397 |
urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"], |
urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"], |
398 |
$val["h"], $val["hl"], false)); |
$val["h"], $val["hl"], $val["exp"], false)); |
399 |
} |
} |
400 |
$ed_id = $art["id"]; |
$ed_id = $art["id"]; |
401 |
if (!$ed_id) $ed_id = -1; |
if (!$ed_id) $ed_id = -1; |
412 |
if ($add) { |
if ($add) { |
413 |
global $add_num; |
global $add_num; |
414 |
for ($i = 0; $i < intval($add_num); $i++) |
for ($i = 0; $i < intval($add_num); $i++) |
415 |
array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", "", 0, 0, 0, "", true)); |
array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", 0, 0, 0, "", "", true)); |
416 |
} |
} |
417 |
$ed_empty = ($ed_title || $ed_lead || $ed_titlepic_pos || $ed_more) ? false : true; |
$ed_empty = ($ed_title || $ed_lead || $ed_titlepic_pos || $ed_more) ? false : true; |
418 |
$ed_text = array(); |
$ed_text = array(); |
420 |
$ed_warnings = ($ed_warning ? true : false); |
$ed_warnings = ($ed_warning ? true : false); |
421 |
$i = 1; |
$i = 1; |
422 |
while (list($key, $val) = each($ed_pgfs)) { |
while (list($key, $val) = each($ed_pgfs)) { |
423 |
list($id, $txt, $tit, $lev, $cls, $pic, $name, $alt, $pos, $w, $h, $hl, $new) = $val; |
list($id, $txt, $tit, $lev, $pic, $name, $alt, $pos, $w, $h, $hl, $exp, $new) = $val; |
424 |
$del = ((${"delete_".$i} || ${"del_".$i}) ? true : false); |
$del = ((${"delete_".$i} || ${"del_".$i}) ? true : false); |
425 |
array_push($ed_records, array("val" => $del, "id" => $id)); |
array_push($ed_records, array("val" => $del, "id" => $id)); |
426 |
if ($del) { $i++; continue; } |
if ($del) { $i++; continue; } |
427 |
$picurl = ${"textpic_url_".$id}; |
$picurl = ${"textpic_url_".$id}; |
428 |
if (!$picurl) $picurl = $pic; |
if (!$picurl) $picurl = $pic; |
429 |
$class = ""; |
$class = ""; |
430 |
while (list($key, $val) = each($levels)) if ($val["id"] == $lev) $class = $val["class"]; |
reset($levels); |
431 |
|
while (list($k, $v) = each($levels)) if ($v["id"] == $lev) $class = $v["class"]; |
432 |
if ((${"clear_".$i} || ${"clr_".$i}) && $ed_preview && (${"textpic_name_".$i} != ${"textpic_url2_".$i})) { |
if ((${"clear_".$i} || ${"clr_".$i}) && $ed_preview && (${"textpic_name_".$i} != ${"textpic_url2_".$i})) { |
433 |
$tmp = ${"textpic_url2_".$i}; |
$tmp = ${"textpic_url2_".$i}; |
434 |
if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp); |
if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp); |
443 |
$txt3 = str_replace(">", ">", $txt3); |
$txt3 = str_replace(">", ">", $txt3); |
444 |
$hl = MyEscape(convert_html($hl), false); |
$hl = MyEscape(convert_html($hl), false); |
445 |
$hl2 = ParseNewline($hl, true); |
$hl2 = ParseNewline($hl, true); |
446 |
|
if ($hl2) $hl2 = GetHighlight($hl2); |
447 |
$hl3 = str_replace("&", "&", $hl); |
$hl3 = str_replace("&", "&", $hl); |
448 |
$hl3 = str_replace("\"", """, $hl3); |
$hl3 = str_replace("\"", """, $hl3); |
449 |
$hl3 = str_replace("<", "<", $hl3); |
$hl3 = str_replace("<", "<", $hl3); |
471 |
"url" => MyEscape(convert_html($picurl)), |
"url" => MyEscape(convert_html($picurl)), |
472 |
"name" => MyEscape(convert_html($name)), |
"name" => MyEscape(convert_html($name)), |
473 |
"alt" => MyEscape(convert_html($alt)), |
"alt" => MyEscape(convert_html($alt)), |
474 |
"width" => $w, |
"w" => $w, |
475 |
"height" => $h, |
"h" => $h, |
476 |
"pos" => $pos, |
"pos" => $pos, |
477 |
|
"exp" => MyEscape(convert_html($exp)), |
478 |
"warning" => $warning, |
"warning" => $warning, |
479 |
"clr" => (${"clear_".$i} || ${"clr_".$i} || !$picurl) ? true : false |
"clr" => (${"clear_".$i} || ${"clr_".$i} || !$picurl) ? true : false |
480 |
)); |
)); |
532 |
$tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?".implode("&", $params))); |
$tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?".implode("&", $params))); |
533 |
if (!$ed_preview) { |
if (!$ed_preview) { |
534 |
global $onload; |
global $onload; |
535 |
$onload .= "document.forms[0].elements[0].focus();"; |
$onload .= "document.forms[1].elements[0].focus();"; |
536 |
} |
} |
537 |
return $tp->fetch("edit.tpl"); |
return $tp->fetch("edit.tpl"); |
538 |
} |
} |