/[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.12 by ravilov, Fri Oct 5 15:10:53 2001 UTC revision 1.18 by ravilov, Tue Oct 23 16:20:37 2001 UTC
# Line 3  Line 3 
3                  global $dbh;                  global $dbh;
4                  if (!isset($nid)) return array();                  if (!isset($nid)) return array();
5                  if (!$par) $par = "NULL";                  if (!$par) $par = "NULL";
6                  $sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos, hl, pic_title FROM paragraphs, par_levels WHERE (news_id = $nid) AND (level = level_id) AND (parent = $par)";                  $sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos, hl, pic_title, full_pic FROM paragraphs, par_levels WHERE (news_id = $nid) AND (level = level_id) AND (parent = $par)";
7                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
8                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
9                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
10                  while ($row = $sth->fetchrow_array()) {                  while ($row = $sth->fetchrow_array()) {
11                          $subs = get_sections($nid, $text, $row[0]);                          $subs = get_sections($nid, $text, $row[0]);
12                          list($w, $h) = PicSize($row[5]);                          list($w, $h) = PicSize($row[5]);
13                            list($w2, $h2) = PicSize($row[10]);
14                          array_push($text, array(                          array_push($text, array(
15                                  "id" => $row[0],                                  "id" => $row[0],
16                                  "text" => $row[1],                                  "text" => $row[1],
# Line 21  Line 22 
22                                  "pos" => $row[7],                                  "pos" => $row[7],
23                                  "hl" => $row[8],                                  "hl" => $row[8],
24                                  "exp" => $row[9],                                  "exp" => $row[9],
25                                    "full" => $row[10],
26                                    "fw" => $w2,
27                                    "fh" => $h2,
28                                  "subs" => $subs,                                  "subs" => $subs,
29                                  "w" => $w,                                  "w" => $w,
30                                  "h" => $h                                  "h" => $h
# Line 32  Line 36 
36                  global $dbh, $spec, $isMed, $isEdit;                  global $dbh, $spec, $isMed, $isEdit;
37                  $arts = array();                  $arts = array();
38                  if (!$offset) $offset = 0;                  if (!$offset) $offset = 0;
39                  $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, ord, prikazi FROM news".(isset($ct)?", cat_news":"").($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)".($isEdit?"":" AND (prikazi)");                  if (!$spec && $isMed) $spec = 0;
40                  if ($id > 0) $sql .= " AND (news.news_id = $id)";                  $conds = array();
41                  if ($ct) $sql .= " AND ((category = '$ct') OR ((cat_news.cat_id = '$ct') AND (cat_news.news_id = news.news_id)))";                  if (!$isEdit) array_push($conds, "(prikazi)");
42                  if ($spec) $sql .= " AND (spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec)";                  if (!$id || $id < 0) array_push($conds, $isMed ? "(plivamed)" : "(NOT plivamed)");
43                  $sql .= " ORDER BY d_orig DESC";                  if ($id > 0) array_push($conds, "(news.news_id = $id)");
44                  if ($limit) $sql .= " LIMIT $limit OFFSET $offset";                  if ($ct) array_push($conds, "((category = '$ct') OR ((cat_news.cat_id = '$ct') AND (cat_news.news_id = news.news_id)))");
45                    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";
52                    if ($offset) $sql .= " OFFSET $offset";
53                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
54                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
55                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
# Line 47  Line 59 
59                                  $art["pic_alt"], $art["pic_pos"], $art["more"],                                  $art["pic_alt"], $art["pic_pos"], $art["more"],
60                                  $art["more_title"], $art["date"], $art["au_pic"],                                  $art["more_title"], $art["date"], $art["au_pic"],
61                                  $art["au_alt"], $art["au_info"], $art["au_name"],                                  $art["au_alt"], $art["au_info"], $art["au_name"],
62                                  $ord, $art["show"]) = $row;                                  $art["au_cv"], $ord, $art["show"]) = $row;
63                          $art["show"] = ($art["show"][0] == "f" || $art["show"][0] == "F") ? false : true;                          $art["show"] = ($art["show"][0] == "f" || $art["show"][0] == "F") ? false : true;
64                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic_url"]);                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic_url"]);
65                          $art["more_new"] = strstr($art["more"], "://") ? true : false;                          $art["more_new"] = strstr($art["more"], "://") ? true : false;
# Line 58  Line 70 
70                          $art["text"] = array();                          $art["text"] = array();
71                          if ($art["id"]) get_sections($art["id"], $art["text"]);                          if ($art["id"]) get_sections($art["id"], $art["text"]);
72                          $art["order"] = $ord;                          $art["order"] = $ord;
73                          $art["read"] = (count($art["text"]) > $npar) ? GetRead($art["id"], $ct) : "";                          $art["read"] = (count($art["text"]) > $npar || $art["more"]) ? GetRead($art["id"], $ct) : "";
74                          $art["category"] = $ct;                          $art["category"] = $ct;
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 86  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", MyEscape(convert_html($art["lead"]), false));                  $tpl->assign("lead", ParseNewline(MyEscape(convert_html($art["lead"]), false), false));
112                  $tpl->assign("titlepic_url", MyEscape(convert_html($art["pic_url"])));                  $tpl->assign("titlepic_url", MyEscape(convert_html($art["pic_url"])));
113                  $tpl->assign("titlepic_alt", MyEscape(convert_html($art["pic_alt"])));                  $tpl->assign("titlepic_alt", MyEscape(convert_html($art["pic_alt"])));
114                  $tpl->assign("titlepic_type", $art["pic_pos"]);                  $tpl->assign("titlepic_type", $art["pic_pos"]);
# Line 99  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                  include_once("author.php");                  $tpl->assign("AUTHOR", GetAuthor($art["au_pic"], $art["au_alt"],
122                  $tpl->assign("AUTHOR", GetAuthor($art["au_pic"],                          $art["au_info"], $art["au_w"], $art["au_h"], $art["au_cv"]));
123                          $art["au_alt"], $art["au_info"],                  $some_title = false;
                         $art["au_w"], $art["au_h"]));  
124                  for ($i = 0; $i < count($art["text"]); $i++) {                  for ($i = 0; $i < count($art["text"]); $i++) {
125                          $art["text"][$i]["text"] = ParseNewline(convert_html(                          if ($art["text"][$i]["title"]) $some_title = true;
126                                  MyEscape($art["text"][$i]["text"]), false), true);                          if ($art["text"][$i]["text"]) {
127                          $art["text"][$i]["hl"] = ParseNewline(convert_html(                                  $art["text"][$i]["text"] = ParseNewline(MyEscape(
128                                  MyEscape($art["text"][$i]["hl"]), false), true);                                          convert_html($art["text"][$i]["text"]), false), true);
129                          $art["text"][$i]["exp"] = ParseNewline(convert_html(                          }
130                                  MyEscape($art["text"][$i]["exp"]), false), true);                          if ($art["text"][$i]["exp"]) {
131                          if ($art["text"][$i]["hl"]) $art["text"][$i]["hl"] = GetHighlight($art["text"][$i]["hl"]);                                  $art["text"][$i]["exp"] = ParseNewline(MyEscape(
132                                            convert_html($art["text"][$i]["exp"]), false), true);
133                            }
134                            if ($art["text"][$i]["hl"]) {
135                                    $art["text"][$i]["hl"] = GetHighlight(ParseNewline(
136                                            MyEscape($art["text"][$i]["hl"], false), false));
137                            }
138                          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;
139                  }                  }
140                  $tpl->assign("text", $art["text"]);                  $tpl->assign("text", $art["text"]);
141                  $tpl->assign("cat", $art["category"]);                  $tpl->assign("cat", $art["category"]);
142                  $tpl->assign("acat", $acat);                  $tpl->assign("acat", $acat);
143                  $tpl->assign("acat2", $acat2);                  $tpl->assign("acat2", $acat2);
144                    $tpl->assign("pgfs", count($art["text"]));
145                    $tpl->assign("some_title", $some_title);
146                    if ($art["id"]) {
147                            $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";
148                            $sth = $dbh->prepare($sql);
149                            if (!$sth) error("Cannot prepare query: \"$sql\"");
150                            if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
151                            $related = array();
152                            while ($row = $sth->fetchrow_array()) {
153                                    list($id, $cat, $title, $lead, $pic, $alt) = $row;
154                                    if ($pic) list($w, $h) = PicSize($pic);
155                                    array_push($related, array(
156                                            "id" => $id,
157                                            "title" => MyEscape($title),
158                                            "lead" => ParseNewline(MyEscape($lead), false),
159                                            "pic" => MyEscape($pic), "w" => $w, "h" => $h,
160                                            "alt" => MyEscape($alt),
161                                            "read" => GetRead($id, $cat)
162                                    ));
163                            }
164                            $sth->finish();
165                            $tpl->assign("related", $related);
166                    }
167                  global $PATH;                  global $PATH;
168                  if (is_array($PATH)) array_push($PATH,                  if (is_array($PATH)) array_push($PATH,
169                          MyUpper(MyEscape(convert_html($art["title"]))));                          MyUpper(MyEscape(convert_html($art["title"]))));

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.18

  ViewVC Help
Powered by ViewVC 1.1.26