/[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.3 by ravilov, Tue Aug 7 13:55:51 2001 UTC revision 1.6 by ravilov, Mon Sep 3 15:52:15 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          function newsLoad($id, $cat, $limit = 1, $npar = 1) {          function newsLoad($id, $cat, $limit = 1, $offset = 0, $npar = 1) {
3                  global $dbh;                  global $dbh;
4                  $arts = array();                  $arts = array();
5                  $sql = "SELECT news_id, title, lead, title_pic, title_alt, title_pos, url, date, ord FROM news WHERE (category = '$cat')";                  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')";
7                  if ($id > 0) $sql .= " AND (news_id = $id)";                  if ($id > 0) $sql .= " AND (news_id = $id)";
8                  $sql .= " ORDER BY date DESC LIMIT $limit";                  $sql .= " ORDER BY date DESC";
9                    if ($limit) $sql .= " LIMIT $limit OFFSET $offset";
10                  $sth = $dbh->prepare($sql);                  $sth = $dbh->prepare($sql);
11                  if (!$sth) error("Cannot prepare query: \"$sql\"");                  if (!$sth) error("Cannot prepare query: \"$sql\"");
12                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
# Line 12  Line 14 
14                          $art = array();                          $art = array();
15                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],                          list($art["id"], $art["title"], $art["lead"], $art["pic_url"],
16                                  $art["pic_alt"], $art["pic_pos"], $art["more"],                                  $art["pic_alt"], $art["pic_pos"], $art["more"],
17                                  $date, $ord) = $row;                                  $art["more_title"], $date, $ord) = $row;
18                            $art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"]));
19                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);                          list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);
20                          $text = array();                          $text = array();
21                          if (isset($art["id"])) {                          if (isset($art["id"])) {
# Line 28  Line 31 
31                                                  "title" => $row[2],                                                  "title" => $row[2],
32                                                  "level" => $row[3],                                                  "level" => $row[3],
33                                                  "class" => $row[4],                                                  "class" => $row[4],
34                                                  "pic" => $row[5],                                                  "pic" => str_replace("+", "%20", urlencode($row[5])),
35                                                  "alt" => $row[6],                                                  "alt" => $row[6],
36                                                  "pos" => $row[7],                                                  "pos" => $row[7],
37                                                  "w" => $w,                                                  "w" => $w,
# Line 42  Line 45 
45                          $art["read"] = (count($art["text"]) > $npar) ? true : false;                          $art["read"] = (count($art["text"]) > $npar) ? true : false;
46                          $art["category"] = $cat;                          $art["category"] = $cat;
47                          $art["limit"] = $limit;                          $art["limit"] = $limit;
48                            $art["offset"] = $offset;
49                          $art["npar"] = $npar;                          $art["npar"] = $npar;
50                          array_push($arts, $art);                          array_push($arts, $art);
51                  }                  }
# Line 72  Line 76 
76                  $tpl->assign("titlepic_alt", MyEscape($art["pic_alt"]));                  $tpl->assign("titlepic_alt", MyEscape($art["pic_alt"]));
77                  $tpl->assign("titlepic_type", $art["pic_pos"]);                  $tpl->assign("titlepic_type", $art["pic_pos"]);
78                  $tpl->assign("title_url", MyEscape($art["more"]));                  $tpl->assign("title_url", MyEscape($art["more"]));
79                    $tpl->assign("title_url_title", MyEscape($art["more_title"]));
80                  $tpl->assign("titlepic_width", $art["pic_w"]);                  $tpl->assign("titlepic_width", $art["pic_w"]);
81                  $tpl->assign("titlepic_height", $art["pic_h"]);                  $tpl->assign("titlepic_height", $art["pic_h"]);
82                  for ($i = 0; $i < count($art["text"]); $i++)                  for ($i = 0; $i < count($art["text"]); $i++)
83                          $art["text"][$i]["text"] = ParseNewline(MyEscape($art["text"][$i]["text"]));                          $art["text"][$i]["text"] = ParseNewline(MyEscape($art["text"][$i]["text"]), true);
84                  $tpl->assign("text", $art["text"]);                  $tpl->assign("text", $art["text"]);
85                  $tpl->assign("cat", $art["category"]);                  $tpl->assign("cat", $art["category"]);
86          }          }

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

  ViewVC Help
Powered by ViewVC 1.1.26