/[health_html]/inc/newsEdit.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /inc/newsEdit.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by ravilov, Fri Oct 12 13:13:38 2001 UTC revision 1.16 by ravilov, Tue Oct 16 13:07:03 2001 UTC
# Line 15  Line 15 
15                  #echo "<TT><B>[SQL]</B> $sql<BR>\n";                  #echo "<TT><B>[SQL]</B> $sql<BR>\n";
16          }          }
17          function my_cmp($a, $b) { return MyCompare($a["txt"], $b["txt"]); }          function my_cmp($a, $b) { return MyCompare($a["txt"], $b["txt"]); }
18            function my_cmp_2($a, $b) { return MyCompare($a["ime"], $b["ime"]); }
19          function newsEdit($art, $trigger = "", $isVijest = false) {          function newsEdit($art, $trigger = "", $isVijest = false) {
20                  global $phptmp, $picdir, $syspicdir, $aupicdir, $sysaupicdir, $dbh, $tpl;                  global $phptmp, $picdir, $syspicdir, $aupicdir, $sysaupicdir, $dbh;
21                  global $section, $section_menu, $section_menu2, $spec;                  global $section, $section_menu, $section_menu2, $spec;
22                  global $ed_id, $ed_cat, $isMed;                  global $ed_id, $ed_cat, $isMed;
23                  $i = 1;                  $i = 1;
# Line 79  sql($sql); Line 80  sql($sql);
80                  $sth->finish();                  $sth->finish();
81                  usort($categories, "my_cmp");                  usort($categories, "my_cmp");
82                  // -----                  // -----
83                    $autori = array();
84                    $sql = "SELECT autor_id, ime FROM autori";
85    sql($sql);
86                    $sth = $dbh->prepare($sql);
87                    if (!$sth) error("Cannot prepare query: \"$sql\"");
88                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
89                    while ($row = $sth->fetchrow_array()) array_push($autori, array("id" => $row[0], "ime" => MyEscape($row[1], false)));
90                    $sth->finish();
91                    usort($autori, "my_cmp_2");
92                    // -----
93                  $specs = array();                  $specs = array();
94                  $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (spec_id != 0) AND (NOT link)";                  $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (spec_id != 0) AND (NOT link)";
95  sql($sql);  sql($sql);
# Line 88  sql($sql); Line 99  sql($sql);
99                  while ($row = $sth->fetchrow_array()) array_push($specs, array("id" => $row[0], "txt" => $row[1]));                  while ($row = $sth->fetchrow_array()) array_push($specs, array("id" => $row[0], "txt" => $row[1]));
100                  $sth->finish();                  $sth->finish();
101                  usort($specs, "my_cmp");                  usort($specs, "my_cmp");
102                    array_unshift($specs, array("id" => 0, "txt" => "HOME"));
103                  // -----                  // -----
104                  $levels = array();                  $levels = array();
105                  $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name";                  $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name";
# Line 127  sql($sql); Line 139  sql($sql);
139                                  global $ed_title, $ed_lead, $ed_titlepic_alt,                                  global $ed_title, $ed_lead, $ed_titlepic_alt,
140                                          $ed_titlepic_pos, $ed_more, $ed_more_title,                                          $ed_titlepic_pos, $ed_more, $ed_more_title,
141                                          $ed_cat, $ed_author_alt, $ed_author_info,                                          $ed_cat, $ed_author_alt, $ed_author_info,
142                                          $ed_author_ime, $ed_prikazi;                                          $ed_author_ime, $ed_author_cv, $ed_prikazi;
143                                  $ed_title = MyQuote($ed_title);                                  $ed_title = MyQuote($ed_title);
144                                  $ed_lead = MyQuote($ed_lead);                                  $ed_lead = MyQuote($ed_lead);
145                                  $ed_author_nm = urldecode(MyQuote(basename($author_name)));                                  $ed_author_nm = urldecode(MyQuote(basename($author_name)));
# Line 139  sql($sql); Line 151  sql($sql);
151                                  $ed_more = MyQuote($ed_more);                                  $ed_more = MyQuote($ed_more);
152                                  $ed_more_title = MyQuote($ed_more_title);                                  $ed_more_title = MyQuote($ed_more_title);
153                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;                                  if (!$ed_titlepic_pos) $ed_titlepic_pos = 0;
154                                    if (!$ed_author_cv) $ed_author_cv = 0;
155                                  if ($ed_id > 0) {                                  if ($ed_id > 0) {
156                                          $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, author_name = $ed_author_ime, url = $ed_more, url_title = $ed_more_title, plivamed = ".($isMed?"true":"false").", prikazi = ".($ed_prikazi?"true":"false").", ord = 0, 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, author_name = $ed_author_ime, autor_cv = $ed_author_cv, url = $ed_more, url_title = $ed_more_title, plivamed = ".($isMed?"true":"false").", prikazi = ".($ed_prikazi?"true":"false").", ord = 0, d_change = NOW() WHERE (news_id = $ed_id)";
157  sql($sql);  sql($sql);
158                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
159                                  } else {                                  } else {
160                                          $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, author_pic, author_alt, author_info, author_name, url, url_title, plivamed, prikazi, d_orig, d_change) VALUES ('$ed_cat', $ed_title, $ed_lead, $ed_titlepic_nm, $ed_titlepic_alt, $ed_titlepic_pos, $ed_author_nm, $ed_author_alt, $ed_author_info, $ed_author_ime, $ed_more, $ed_more_title, ".($isMed?"true":"false").", ".($ed_prikazi?"true":"false").", NOW(), NOW())";                                          $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, author_pic, author_alt, author_info, author_name, autor_cv, url, url_title, plivamed, prikazi, d_orig, d_change) VALUES ('$ed_cat', $ed_title, $ed_lead, $ed_titlepic_nm, $ed_titlepic_alt, $ed_titlepic_pos, $ed_author_nm, $ed_author_alt, $ed_author_info, $ed_author_ime, $ed_author_cv, $ed_more, $ed_more_title, ".($isMed?"true":"false").", ".($ed_prikazi?"true":"false").", NOW(), NOW())";
161  sql($sql);  sql($sql);
162                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
163                                          $sql = "SELECT currval('news_news_id_seq')::text";                                          $sql = "SELECT currval('news_news_id_seq')::text";
# Line 170  sql($sql); Line 183  sql($sql);
183                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},                                                  ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i},
184                                                  ${"ed_text_level_".$i}, ${"ed_hl_".$i},                                                  ${"ed_text_level_".$i}, ${"ed_hl_".$i},
185                                                  ${"ed_textpic_exp_".$i};                                                  ${"ed_textpic_exp_".$i};
186                                          list($id, $tit, $txt, $pic, $full, $orig, $alt, $pos, $del, $lev, $hl, $exp) = array(                                          list($id, $tit, $txt, $pic, $orig,$full, $forig, $alt, $pos, $del, $lev, $hl, $exp) = array(
187                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i},                                                  ${"ed_text_id_".$i}, ${"ed_text_title_".$i}, ${"ed_text_".$i},
188                                                  ${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_full2_".$i},                                                  ${"textpic_url2_".$i}, ${"textpic_name_".$i}, ${"textpic_full2_".$i},
189                                                  ${"textpic_name_".$i}, ${"ed_textpic_alt_".$i},                                                  ${"textpic_fname_".$i}, ${"ed_textpic_alt_".$i},
190                                                  ${"ed_textpic_pos_".$i}, ${"del_".$i}, ${"ed_text_level_".$i},                                                  ${"ed_textpic_pos_".$i}, ${"del_".$i}, ${"ed_text_level_".$i},
191                                                  ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i});                                                  ${"ed_hl_".$i}, ${"ed_textpic_exp_".$i});
192                                          if ($lev != $last_level) {                                          if ($lev != $last_level) {
# Line 191  sql($sql); Line 204  sql($sql);
204                                          $hl = MyQuote($hl);                                          $hl = MyQuote($hl);
205                                          $orig = basename($orig);                                          $orig = basename($orig);
206                                          $org = MyQuote($orig);                                          $org = MyQuote($orig);
207                                            $forig = basename($forig);
208                                            $forg = MyQuote($forig);
209                                          $alt = MyQuote($alt);                                          $alt = MyQuote($alt);
210                                          if (!$pos) $pos = 0;                                          if (!$pos) $pos = 0;
211                                          if ($id && $id > 0) {                                          if ($id && $id > 0) {
# Line 206  sql($sql); Line 221  sql($sql);
221                                                          }                                                          }
222                                                          $sth->finish();                                                          $sth->finish();
223                                                  }                                                  }
224                                                    if ($del || !$forig) {
225                                                            $sql = "SELECT full_pic FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
226    sql($sql);
227                                                            $sth = $dbh->prepare($sql);
228                                                            if (!$sth) error("Cannot prepare query: \"$sql\"");
229                                                            if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
230                                                            while ($row = $sth->fetchrow_array()) {
231                                                                    list($pic) = $row;
232                                                                    MyDelete($syspicdir."/".$pic);
233                                                            }
234                                                            $sth->finish();
235                                                    }
236                                                  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)";
237                                                          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)";                                                          else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, hl = $hl, pic = $org, full_pic = $forg, alt = $alt, pos = $pos, pic_title = $exp WHERE (news_id = $ed_id) AND (paragraph_id = $id)";
238  sql($sql);  sql($sql);
239                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
240                                          } else if (!$del) {                                          } else if (!$del) {
241                                                  $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)";                                                  $sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, full_pic, alt, pos, hl, pic_title) VALUES ($ed_id, $tit, $lev, $txt, $org, $forg, $alt, $pos, $hl, $exp)";
242  sql($sql);  sql($sql);
243                                                  $dbh->dbh_do($sql);                                                  $dbh->dbh_do($sql);
244                                                  $sql = "SELECT currval('paragraphs_paragraph_id_seq')::text";                                                  $sql = "SELECT currval('paragraphs_paragraph_id_seq')::text";
# Line 225  sql($sql); Line 252  sql($sql);
252                                                  $last_id = $id = $row;                                                  $last_id = $id = $row;
253                                          }                                          }
254                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");                                          if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig");
255                                            if ($full) MyMove("$syspicdir/$full", "$syspicdir/$forig");
256                                          $i++;                                          $i++;
257                                  }                                  }
258                                  if ($ed_id) {                                  if ($ed_id) {
# Line 232  sql($sql); Line 260  sql($sql);
260  sql($sql);  sql($sql);
261                                          $dbh->dbh_do($sql);                                          $dbh->dbh_do($sql);
262                                          for ($k = 0; $k < count($specs); $k++) {                                          for ($k = 0; $k < count($specs); $k++) {
263                                                  $var = "ed_spec_".$specs[$k]["id"]; global $$var;                                                  $var = "ed_spec_".$specs[$k]["id"];
264                                                    global $$var;
265                                                  if (!$$var) continue;                                                  if (!$$var) continue;
266                                                  $sql = "INSERT INTO spec_news (news_id, spec_id) VALUES ($ed_id, ".$specs[$k]["id"].")";                                                  $sql = "INSERT INTO spec_news (news_id, spec_id) VALUES ($ed_id, ".$specs[$k]["id"].")";
267  sql($sql);  sql($sql);
# Line 317  sql($sql); Line 346  sql($sql);
346                  // -----                  // -----
347                  $tp = new Smarty();                  $tp = new Smarty();
348                  $tp->assign("levels", $levels);                  $tp->assign("levels", $levels);
349                    $tp->assign("autori", $autori);
350                  // -----                  // -----
351                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,                  global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos,
352                          $ed_titlepic_alt, $ed_cat, $ed_more,                          $ed_titlepic_alt, $ed_cat, $ed_more,
# Line 342  sql($sql); Line 372  sql($sql);
372                          for ($i = 0; $i < count($specs); $i++) {                          for ($i = 0; $i < count($specs); $i++) {
373                                  $var = "ed_spec_".$specs[$i]["id"];                                  $var = "ed_spec_".$specs[$i]["id"];
374                                  global $$var;                                  global $$var;
375                                  $nspecs[$specs[$i]["id"]] = $$var ? true : false;                                  $foo = isset($$var) ? $$var : ($spec && $spec == $specs[$i]["id"]);
376                                    $nspecs[$specs[$i]["id"]] = $foo ? true : false;
377                          }                          }
378                          for ($i = 0; $i < count($categories); $i++) {                          for ($i = 0; $i < count($categories); $i++) {
379                                  $var = "ed_cat_".$categories[$i]["id"];                                  $var = "ed_cat_".$categories[$i]["id"];
# Line 353  sql($sql); Line 384  sql($sql);
384                                  $ed_titlepic_alt, $ed_cat, $ed_more,                                  $ed_titlepic_alt, $ed_cat, $ed_more,
385                                  $ed_more_title, $ed_author_url,                                  $ed_more_title, $ed_author_url,
386                                  $ed_author_alt, $ed_author_info,                                  $ed_author_alt, $ed_author_info,
387                                  $ed_author_ime, $ed_prikazi;                                  $ed_author_ime, $ed_author_cv,
388                                    $ed_prikazi;
389                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";                          if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = "";
390                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;                          if (!$titlepic_url) $titlepic_url = $titlepic_url2;
391                          if (!$titlepic_url && !($clear_main || $clr_main)) $titlepic_url = $art["pic_url"];                          if (!$titlepic_url && !($clear_main || $clr_main)) $titlepic_url = $art["pic_url"];
# Line 410  sql($sql); Line 442  sql($sql);
442                                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
443                                  while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true;                                  while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true;
444                                  $sth->finish();                                  $sth->finish();
445                          } else $art["show"] = true;                          } else {
446                                    $art["show"] = true;
447                                    for ($j = 0; $j < count($specs); $j++)
448                                            $nspecs[$specs[$j]["id"]] = ($specs[$j]["id"] == $spec) ? true : false;
449                            }
450                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,                          list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url,
451                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,                                  $titlepic_url2, $titlepic_name, $ed_titlepic_alt,
452                                  $ed_cat, $ed_more, $ed_more_title, $width, $height,                                  $ed_cat, $ed_more, $ed_more_title, $width, $height,
453                                  $author_url, $author_url2, $author_name,                                  $author_url, $author_url2, $author_name,
454                                  $ed_author_alt, $ed_author_info, $width2, $height2,                                  $ed_author_alt, $ed_author_info, $width2, $height2,
455                                  $ed_author_ime, $ed_prikazi) = array($art["title"], $art["lead"],                                  $ed_author_ime, $ed_author_cv, $ed_prikazi) = array($art["title"],
456                                  $art["pic_pos"], $art["pic_url"], $art["pic_url"],                                  $art["lead"], $art["pic_pos"], $art["pic_url"], $art["pic_url"],
457                                  urldecode($art["pic_url"]), $art["pic_alt"], $art["category"],                                  urldecode($art["pic_url"]), $art["pic_alt"], $art["category"],
458                                  $art["more"], $art["more_title"], $art["pic_w"], $art["pic_h"],                                  $art["more"], $art["more_title"], $art["pic_w"], $art["pic_h"],
459                                  $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]),                                  $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]),
460                                  $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"],                                  $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"],
461                                  $art["au_name"], $art["show"]);                                  $art["au_name"], $art["au_cv"], $art["show"]);
462                          if ($art["text"]) reset($art["text"]);                          if ($art["text"]) reset($art["text"]);
463                          while ($art["text"] && list($id, $val) = each($art["text"])) {                          while ($art["text"] && list($id, $val) = each($art["text"])) {
464                                  array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],                                  array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"],
# Line 554  sql($sql); Line 590  sql($sql);
590                  $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);                  $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false);
591                  $tp->assign("ed_more_title", MyEscape($ed_more_title));                  $tp->assign("ed_more_title", MyEscape($ed_more_title));
592                  $tp->assign("ed_prikazi", $ed_prikazi);                  $tp->assign("ed_prikazi", $ed_prikazi);
593                    $tp->assign("ed_author_cv", $ed_author_cv);
594                  $tp->assign("ed_clr_main", ($clear_main || $clr_main || !$titlepic_url) ? true : false);                  $tp->assign("ed_clr_main", ($clear_main || $clr_main || !$titlepic_url) ? true : false);
595                  $tp->assign("ed_clr_author", ($clear_author || $clr_author || !$author_url) ? true : false);                  $tp->assign("ed_clr_author", ($clear_author || $clr_author || !$author_url) ? true : false);
596                  $tp->assign("ed_text", $ed_text);                  $tp->assign("ed_text", $ed_text);

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.26