/[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.1.1.1 by ravilov, Fri Aug 3 09:12:42 2001 UTC revision 1.16 by ravilov, Tue Oct 16 13:07:03 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          function newsLoad($id, $cat, $limit = 1, $npar = 1) {          function get_sections($nid, &$text, $par = 0) {
3                  global $dbh;                  global $dbh;
4                    if (!isset($nid)) return array();
5                    if (!$par) $par = "NULL";
6                    $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);
8                    if (!$sth) error("Cannot prepare query: \"$sql\"");
9                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
10                    while ($row = $sth->fetchrow_array()) {
11                            $subs = get_sections($nid, $text, $row[0]);
12                            list($w, $h) = PicSize($row[5]);
13                            list($w2, $h2) = PicSize($row[10]);
14                            array_push($text, array(
15                                    "id" => $row[0],
16                                    "text" => $row[1],
17                                    "title" => $row[2],
18                                    "level" => $row[3],
19                                    "class" => $row[4],
20                                    "pic" => str_replace("+", "%20", urlencode($row[5])),
21                                    "alt" => $row[6],
22                                    "pos" => $row[7],
23                                    "hl" => $row[8],
24                                    "exp" => $row[9],
25                                    "full" => $row[10],
26                                    "fw" => $w2,
27                                    "fh" => $h2,
28                                    "subs" => $subs,
29                                    "w" => $w,
30                                    "h" => $h
31                            ));
32                    }
33                    $sth->finish();
34            }
35            function newsLoad($id, $ct = "", $limit = 0, $offset = 0, $npar = 1) {
36                    global $dbh, $spec, $isMed, $isEdit;
37                  $arts = array();                  $arts = array();
38                  $sql = "SELECT news_id, title, lead, title_pic, title_alt, title_pos, url, date FROM news WHERE (category = '$cat')";                  if (!$offset) $offset = 0;
39                  if ($id > 0) $sql .= " AND (news_id = $id)";                  if (!$spec && $isMed) $spec = 0;
40                  $sql .= " ORDER BY date DESC LIMIT $limit";                  $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)");
41                    if ($id > 0) $sql .= " AND (news.news_id = $id)";
42                    if ($ct) $sql .= " AND ((category = '$ct') OR ((cat_news.cat_id = '$ct') AND (cat_news.news_id = news.news_id)))";
43                    if (isset($spec)) $sql .= " AND (spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec)";
44                    if ($limit && $isEdit) $sql .= "";
45                    $sql .= " ORDER BY d_orig DESC";
46                    if ($limit && !$isEdit) $sql .= " LIMIT $limit";
47                    if ($offset) $sql .= " OFFSET $offset";
48                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
49                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
50                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
51                  while ($row = $sth->fetchrow_array()) {                  while ($row = $sth->fetchrow_array()) {
52                          $art = array();                          $art = array();
53                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],
54                                  $art["pic_alt"], $art["pic_pos"], $art["more"], $date) = $row;                                  $art["pic_alt"], $art["pic_pos"], $art["more"],
55                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);                                  $art["more_title"], $art["date"], $art["au_pic"],
56                          $text = array();                                  $art["au_alt"], $art["au_info"], $art["au_name"],
57                          if ($art["id"]) {                                  $art["au_cv"], $ord, $art["show"]) = $row;
58                                  $sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos FROM paragraphs, par_levels WHERE (news_id = ".$art["id"].") AND (level = level_id)";                          $art["show"] = ($art["show"][0] == "f" || $art["show"][0] == "F") ? false : true;
59                                  $sth2 = $dbh->prepare($sql);                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic_url"]);
60                                  if (!$sth2) error("Cannot prepare query: \"$sql\"");                          $art["more_new"] = strstr($art["more"], "://") ? true : false;
61                                  if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");                          global $sysaupicdir;
62                                  while ($row = $sth2->fetchrow_array()) {                          list($art["au_w"], $art["au_h"]) = PicSize($art["au_pic"], $sysaupicdir);
63                                          list($w, $h) = PicSize($row[5]);                          $art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"]));
64                                          array_push($text, array(                          $art["au_pic"] = str_replace("+", "%20", urlencode($art["au_pic"]));
65                                                  "id" => $row[0],                          $art["text"] = array();
66                                                  "text" => $row[1],                          if ($art["id"]) get_sections($art["id"], $art["text"]);
67                                                  "title" => $row[2],                          $art["order"] = $ord;
68                                                  "level" => $row[3],                          $art["read"] = (count($art["text"]) > $npar || $art["more"]) ? GetRead($art["id"], $ct) : "";
69                                                  "class" => $row[4],                          $art["category"] = $ct;
                                                 "pic" => $row[5],  
                                                 "alt" => $row[6],  
                                                 "pos" => $row[7],  
                                                 "w" => $w,  
                                                 "h" => $h  
                                         ));  
                                 }  
                                 $sth2->finish();  
                         }  
                         $art["text"] = $text;  
                         $art["read"] = (count($text) > $npar) ? true : false;  
                         $art["category"] = $cat;  
70                          $art["limit"] = $limit;                          $art["limit"] = $limit;
71                            $art["offset"] = $offset;
72                          $art["npar"] = $npar;                          $art["npar"] = $npar;
73                          array_push($arts, $art);                          array_push($arts, $art);
74                  }                  }
75                  $sth->finish();                  $sth->finish();
76                    $foo = true;
77                    while ($foo) {
78                            $foo = false;
79                            for ($i = 0; $i < count($arts); $i++) {
80                                    if ($arts[$i]["order"] == 0) continue;
81                                    $j = ($i + $arts[$i]["order"]);
82                                    $j %= count($arts);
83                                    if ($j < 0) $j += count($arts);
84                                    if ($i == $j) continue;
85                                    $foo = true;
86                                    $tmp = $arts[$j];
87                                    $arts[$j] = $arts[$i];
88                                    $arts[$i] = $tmp;
89                                    $arts[$j]["order"] = 0;
90                            }
91                    }
92                  return $arts;                  return $arts;
93          }          }
94    
95          function newsShow($art) {          function newsShow($art) {
96                  global $fname, $syspicdir, $tpl;                  global $fname, $tpl, $acat, $acat2;
97                  $fname = "show.tpl";                  $fname = "show.tpl";
98                  $tpl->assign("title", MyEscape($art["title"]));                  $tpl->assign("title", MyEscape(convert_html($art["title"])));
99                  $tpl->assign("lead", MyEscape($art["lead"]));                  $tpl->assign("lead", ParseNewline(MyEscape(convert_html($art["lead"]), false), false));
100                  $tpl->assign("titlepic_url", MyEscape($art["pic_url"]));                  $tpl->assign("titlepic_url", MyEscape(convert_html($art["pic_url"])));
101                  $tpl->assign("titlepic_alt", MyEscape($art["pic_alt"]));                  $tpl->assign("titlepic_alt", MyEscape(convert_html($art["pic_alt"])));
102                  $tpl->assign("titlepic_type", $art["pic_pos"]);                  $tpl->assign("titlepic_type", $art["pic_pos"]);
103                  $tpl->assign("title_url", MyEscape($art["more"]));                  $tpl->assign("title_url", MyEscape(convert_html($art["more"])));
104                    $tpl->assign("title_url_new", $art["more_new"]);
105                    $tpl->assign("title_url_title", MyEscape(convert_html($art["more_title"])));
106                  $tpl->assign("titlepic_width", $art["pic_w"]);                  $tpl->assign("titlepic_width", $art["pic_w"]);
107                  $tpl->assign("titlepic_height", $art["pic_h"]);                  $tpl->assign("titlepic_height", $art["pic_h"]);
108                  for ($i = 0; $i < count($art["text"]); $i++)                  $tpl->assign("date", $art["date"] ? strftime("%d.%m.%Y.", strtotime($art["date"])) : "");
109                          $art["text"][$i]["text"] = ParseNewline(MyEscape($art["text"][$i]["text"]));                  $tpl->assign("AUTHOR", GetAuthor($art["au_pic"],
110                            $art["au_alt"], $art["au_info"],
111                            $art["au_w"], $art["au_h"]));
112                    for ($i = 0; $i < count($art["text"]); $i++) {
113                            $art["text"][$i]["text"] = ParseNewline(MyEscape(
114                                    convert_html($art["text"][$i]["text"]), false), true);
115                            $art["text"][$i]["hl"] = ParseNewline(MyEscape(
116                                    convert_html($art["text"][$i]["hl"]), false), true);
117                            $art["text"][$i]["exp"] = ParseNewline(MyEscape(
118                                    convert_html($art["text"][$i]["exp"]), false), true);
119                            if ($art["text"][$i]["hl"]) $art["text"][$i]["hl"] = GetHighlight($art["text"][$i]["hl"]);
120                            if ($art["text"][$i]["level"]) $art["text"][$i]["level2"] = (($art["text"][$i]["level"] - 1) * 15) + 2;
121                    }
122                  $tpl->assign("text", $art["text"]);                  $tpl->assign("text", $art["text"]);
123                  $tpl->assign("cat", $art["category"]);                  $tpl->assign("cat", $art["category"]);
124                    $tpl->assign("acat", $acat);
125                    $tpl->assign("acat2", $acat2);
126                    $tpl->assign("pgfs", count($art["text"]));
127                    global $PATH;
128                    if (is_array($PATH)) array_push($PATH,
129                            MyUpper(MyEscape(convert_html($art["title"]))));
130          }          }
131  ?>  ?>

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

  ViewVC Help
Powered by ViewVC 1.1.26