/[health_html]/inc/newsShow.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/newsShow.php

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

revision 1.16 by ravilov, Tue Oct 16 13:07:03 2001 UTC revision 1.17 by ravilov, Tue Oct 23 16:13:59 2001 UTC
# Line 37  Line 37 
37                  $arts = array();                  $arts = array();
38                  if (!$offset) $offset = 0;                  if (!$offset) $offset = 0;
39                  if (!$spec && $isMed) $spec = 0;                  if (!$spec && $isMed) $spec = 0;
40                  $sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_orig, author_pic, author_alt, author_info, author_name, autor_cv, ord, prikazi FROM news".(isset($ct)?", cat_news":"").(isset($spec)?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)".($isEdit?"":" AND (prikazi)");                  $conds = array();
41                  if ($id > 0) $sql .= " AND (news.news_id = $id)";                  if (!$isEdit) array_push($conds, "(prikazi)");
42                  if ($ct) $sql .= " AND ((category = '$ct') OR ((cat_news.cat_id = '$ct') AND (cat_news.news_id = news.news_id)))";                  if (!$id || $id < 0) array_push($conds, $isMed ? "(plivamed)" : "(NOT plivamed)");
43                  if (isset($spec)) $sql .= " AND (spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec)";                  if ($id > 0) array_push($conds, "(news.news_id = $id)");
44                  if ($limit && $isEdit) $sql .= "";                  if ($ct) array_push($conds, "((category = '$ct') OR ((cat_news.cat_id = '$ct') AND (cat_news.news_id = news.news_id)))");
45                  $sql .= " ORDER BY d_orig DESC";                  if (isset($spec) && (!$id || $id < 0)) array_push($conds, "((spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec))");
46                    # if ($limit && $isEdit) array_push($conds, "");
47                    $sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_orig, author_pic, author_alt, author_info, author_name, autor_cv, ord, prikazi FROM news".(isset($ct)?", cat_news":"").((isset($spec)&&(!$id||$id<0))?", spec_news":"");
48                    $conds = implode(" AND ", $conds);
49                    if ($conds) $sql .= " WHERE ".$conds;
50                    $sql .= " ORDER BY d_orig DESC, title";
51                  if ($limit && !$isEdit) $sql .= " LIMIT $limit";                  if ($limit && !$isEdit) $sql .= " LIMIT $limit";
52                  if ($offset) $sql .= " OFFSET $offset";                  if ($offset) $sql .= " OFFSET $offset";
53                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
# Line 70  Line 75 
75                          $art["limit"] = $limit;                          $art["limit"] = $limit;
76                          $art["offset"] = $offset;                          $art["offset"] = $offset;
77                          $art["npar"] = $npar;                          $art["npar"] = $npar;
78                            $sql = "SELECT rel_id FROM related WHERE (news_id = ".$art["id"].") LIMIT 1";
79                            $sth2 = $dbh->prepare($sql);
80                            if (!$sth2) error("Cannot prepare query: \"$sql\"");
81                            if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
82                            $row = $sth2->fetchrow_array();
83                            $sth2->finish();
84                            $art["related"] = $row ? true : false;
85                          array_push($arts, $art);                          array_push($arts, $art);
86                  }                  }
87                  $sth->finish();                  $sth->finish();
# Line 93  Line 105 
105          }          }
106    
107          function newsShow($art) {          function newsShow($art) {
108                  global $fname, $tpl, $acat, $acat2;                  global $fname, $tpl, $acat, $acat2, $dbh;
109                  $fname = "show.tpl";                  $fname = "show.tpl";
110                  $tpl->assign("title", MyEscape(convert_html($art["title"])));                  $tpl->assign("title", MyEscape(convert_html($art["title"])));
111                  $tpl->assign("lead", ParseNewline(MyEscape(convert_html($art["lead"]), false), false));                  $tpl->assign("lead", ParseNewline(MyEscape(convert_html($art["lead"]), false), false));
# Line 106  Line 118 
118                  $tpl->assign("titlepic_width", $art["pic_w"]);                  $tpl->assign("titlepic_width", $art["pic_w"]);
119                  $tpl->assign("titlepic_height", $art["pic_h"]);                  $tpl->assign("titlepic_height", $art["pic_h"]);
120                  $tpl->assign("date", $art["date"] ? strftime("%d.%m.%Y.", strtotime($art["date"])) : "");                  $tpl->assign("date", $art["date"] ? strftime("%d.%m.%Y.", strtotime($art["date"])) : "");
121                  $tpl->assign("AUTHOR", GetAuthor($art["au_pic"],                  $tpl->assign("AUTHOR", GetAuthor($art["au_pic"], $art["au_alt"],
122                          $art["au_alt"], $art["au_info"],                          $art["au_info"], $art["au_w"], $art["au_h"], $art["au_cv"]));
                         $art["au_w"], $art["au_h"]));  
123                  for ($i = 0; $i < count($art["text"]); $i++) {                  for ($i = 0; $i < count($art["text"]); $i++) {
124                          $art["text"][$i]["text"] = ParseNewline(MyEscape(                          if ($art["text"][$i]["text"]) {
125                                  convert_html($art["text"][$i]["text"]), false), true);                                  $art["text"][$i]["text"] = ParseNewline(MyEscape(
126                          $art["text"][$i]["hl"] = ParseNewline(MyEscape(                                          convert_html($art["text"][$i]["text"]), false), true);
127                                  convert_html($art["text"][$i]["hl"]), false), true);                          }
128                          $art["text"][$i]["exp"] = ParseNewline(MyEscape(                          if ($art["text"][$i]["exp"]) {
129                                  convert_html($art["text"][$i]["exp"]), false), true);                                  $art["text"][$i]["exp"] = ParseNewline(MyEscape(
130                          if ($art["text"][$i]["hl"]) $art["text"][$i]["hl"] = GetHighlight($art["text"][$i]["hl"]);                                          convert_html($art["text"][$i]["exp"]), false), true);
131                            }
132                            if ($art["text"][$i]["hl"]) {
133                                    $art["text"][$i]["hl"] = GetHighlight(ParseNewline(
134                                            MyEscape($art["text"][$i]["hl"], false), false));
135                            }
136                          if ($art["text"][$i]["level"]) $art["text"][$i]["level2"] = (($art["text"][$i]["level"] - 1) * 15) + 2;                          if ($art["text"][$i]["level"]) $art["text"][$i]["level2"] = (($art["text"][$i]["level"] - 1) * 15) + 2;
137                  }                  }
138                  $tpl->assign("text", $art["text"]);                  $tpl->assign("text", $art["text"]);
# Line 124  Line 140 
140                  $tpl->assign("acat", $acat);                  $tpl->assign("acat", $acat);
141                  $tpl->assign("acat2", $acat2);                  $tpl->assign("acat2", $acat2);
142                  $tpl->assign("pgfs", count($art["text"]));                  $tpl->assign("pgfs", count($art["text"]));
143                    if ($art["id"]) {
144                            $sql = "SELECT news.news_id, news.category, news.title, news.lead, news.title_pic, news.title_alt FROM news, related WHERE (news.news_id = related.rel_id) AND (related.news_id = ".$art["id"].") AND (prikazi) ORDER BY d_orig DESC";
145                            $sth = $dbh->prepare($sql);
146                            if (!$sth) error("Cannot prepare query: \"$sql\"");
147                            if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
148                            $related = array();
149                            while ($row = $sth->fetchrow_array()) {
150                                    list($id, $cat, $title, $lead, $pic, $alt) = $row;
151                                    if ($pic) list($w, $h) = PicSize($pic);
152                                    array_push($related, array(
153                                            "id" => $id,
154                                            "title" => MyEscape($title),
155                                            "lead" => ParseNewline(MyEscape($lead), false),
156                                            "pic" => MyEscape($pic), "w" => $w, "h" => $h,
157                                            "alt" => MyEscape($alt),
158                                            "read" => GetRead($id, $cat)
159                                    ));
160                            }
161                            $sth->finish();
162                            $tpl->assign("related", $related);
163                    }
164                  global $PATH;                  global $PATH;
165                  if (is_array($PATH)) array_push($PATH,                  if (is_array($PATH)) array_push($PATH,
166                          MyUpper(MyEscape(convert_html($art["title"]))));                          MyUpper(MyEscape(convert_html($art["title"]))));

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

  ViewVC Help
Powered by ViewVC 1.1.26