/[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.6 by ravilov, Mon Sep 3 15:52:15 2001 UTC revision 1.7 by ravilov, Wed Sep 19 12:23:57 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          function newsLoad($id, $cat, $limit = 1, $offset = 0, $npar = 1) {          function newsLoad($id, $cat = "", $limit = 0, $offset = 0, $npar = 1) {
3                  global $dbh;                  global $dbh, $spec, $isMed;
4                  $arts = array();                  $arts = array();
5                  if (!$offset) $offset = 0;                  if (!$offset) $offset = 0;
6                  $sql = "SELECT news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, date, ord FROM news WHERE (category = '$cat')";                  $sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_change, author_pic, author_alt, author_info, ord FROM news".($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)";
7                    if ($cat) $sql .= " AND (category = '$cat')";
8    /*
9                    $sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_change, author_pic, author_alt, author_info, ord FROM news".($cat?", cat_news":"").($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)";
10                    if ($cat) $sql .= " AND ((category = '$cat') OR ((cat_news.cat_id = '$cat') AND (cat_news.news_id = news.news_id)))";
11    */
12                    if ($spec) $sql .= " AND (spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec)";
13                  if ($id > 0) $sql .= " AND (news_id = $id)";                  if ($id > 0) $sql .= " AND (news_id = $id)";
14                  $sql .= " ORDER BY date DESC";                  $sql .= " ORDER BY d_change DESC";
15                  if ($limit) $sql .= " LIMIT $limit OFFSET $offset";                  if ($limit) $sql .= " LIMIT $limit OFFSET $offset";
16    #echo "[$sql]<BR>\n";
17                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
18                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
19                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
# Line 14  Line 21 
21                          $art = array();                          $art = array();
22                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],
23                                  $art["pic_alt"], $art["pic_pos"], $art["more"],                                  $art["pic_alt"], $art["pic_pos"], $art["more"],
24                                  $art["more_title"], $date, $ord) = $row;                                  $art["more_title"], $date, $art["au_pic"],
25                          $art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"]));                                  $art["au_alt"], $art["au_info"], $ord) = $row;
26                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);
27                            $art["more_new"] = strstr($art["more"], "://") ? true : false;
28                            global $sysaupicdir;
29                            list($art["au_w"], $art["au_h"]) = PicSize($art["au_pic"], $sysaupicdir);
30                            $art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"]));
31                            $art["au_pic"] = str_replace("+", "%20", urlencode($art["au_pic"]));
32                          $text = array();                          $text = array();
33                          if (isset($art["id"])) {                          if (isset($art["id"])) {
34                                  $sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos FROM paragraphs, par_levels WHERE (news_id = ".$art["id"].") AND (level = level_id)";                                  $sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos, hl FROM paragraphs, par_levels WHERE (news_id = ".$art["id"].") AND (level = level_id)";
35                                  $sth2 = $dbh->prepare($sql);                                  $sth2 = $dbh->prepare($sql);
36                                  if (!$sth2) error("Cannot prepare query: \"$sql\"");                                  if (!$sth2) error("Cannot prepare query: \"$sql\"");
37                                  if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");                                  if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
# Line 34  Line 46 
46                                                  "pic" => str_replace("+", "%20", urlencode($row[5])),                                                  "pic" => str_replace("+", "%20", urlencode($row[5])),
47                                                  "alt" => $row[6],                                                  "alt" => $row[6],
48                                                  "pos" => $row[7],                                                  "pos" => $row[7],
49                                                    "hl" => $row[8],
50                                                  "w" => $w,                                                  "w" => $w,
51                                                  "h" => $h                                                  "h" => $h
52                                          ));                                          ));
# Line 57  Line 70 
70                                  if ($arts[$i]["order"] == 0) continue;                                  if ($arts[$i]["order"] == 0) continue;
71                                  $j = ($i + $arts[$i]["order"]);                                  $j = ($i + $arts[$i]["order"]);
72                                  $j %= count($arts);                                  $j %= count($arts);
73                                    if ($j < 0) $j += count($arts);
74                                    if ($i == $j) continue;
75                                  $foo = true;                                  $foo = true;
76                                  $tmp = $arts[$j];                                  $tmp = $arts[$j];
77                                  $arts[$j] = $arts[$i];                                  $arts[$j] = $arts[$i];
# Line 68  Line 83 
83          }          }
84    
85          function newsShow($art) {          function newsShow($art) {
86                  global $fname, $syspicdir, $tpl;                  global $fname, $tpl;
87                  $fname = "show.tpl";                  $fname = "show.tpl";
88                  $tpl->assign("title", MyEscape($art["title"]));                  $tpl->assign("title", MyEscape(convert_html($art["title"])));
89                  $tpl->assign("lead", MyEscape($art["lead"]));                  $tpl->assign("lead", MyEscape(convert_html($art["lead"]), false));
90                  $tpl->assign("titlepic_url", MyEscape($art["pic_url"]));                  $tpl->assign("titlepic_url", MyEscape(convert_html($art["pic_url"])));
91                  $tpl->assign("titlepic_alt", MyEscape($art["pic_alt"]));                  $tpl->assign("titlepic_alt", MyEscape(convert_html($art["pic_alt"])));
92                  $tpl->assign("titlepic_type", $art["pic_pos"]);                  $tpl->assign("titlepic_type", $art["pic_pos"]);
93                  $tpl->assign("title_url", MyEscape($art["more"]));                  $tpl->assign("title_url", MyEscape(convert_html($art["more"])));
94                  $tpl->assign("title_url_title", MyEscape($art["more_title"]));                  $tpl->assign("title_url_new", $art["more_new"]);
95                    $tpl->assign("title_url_title", MyEscape(convert_html($art["more_title"])));
96                  $tpl->assign("titlepic_width", $art["pic_w"]);                  $tpl->assign("titlepic_width", $art["pic_w"]);
97                  $tpl->assign("titlepic_height", $art["pic_h"]);                  $tpl->assign("titlepic_height", $art["pic_h"]);
98                  for ($i = 0; $i < count($art["text"]); $i++)                  include_once("author.php");
99                          $art["text"][$i]["text"] = ParseNewline(MyEscape($art["text"][$i]["text"]), true);                  $tpl->assign("AUTHOR", GetAuthor($art["au_pic"],
100                            $art["au_alt"], $art["au_info"],
101                            $art["au_w"], $art["au_h"]));
102                    for ($i = 0; $i < count($art["text"]); $i++) {
103                            $art["text"][$i]["text"] = ParseNewline(convert_html(
104                                    MyEscape($art["text"][$i]["text"]), false), true);
105                            $art["text"][$i]["hl"] = ParseNewline(convert_html(
106                                    MyEscape($art["text"][$i]["hl"]), false), true);
107                    }
108                  $tpl->assign("text", $art["text"]);                  $tpl->assign("text", $art["text"]);
109                  $tpl->assign("cat", $art["category"]);                  $tpl->assign("cat", $art["category"]);
110          }          }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26