/[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

Annotation of /inc/newsShow.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Fri Aug 3 09:12:42 2001 UTC (22 years, 8 months ago) by ravilov
Branch: MAIN
Branch point for: pliva
Initial revision

1 ravilov 1.1 <?php
2     function newsLoad($id, $cat, $limit = 1, $npar = 1) {
3     global $dbh;
4     $arts = array();
5     $sql = "SELECT news_id, title, lead, title_pic, title_alt, title_pos, url, date FROM news WHERE (category = '$cat')";
6     if ($id > 0) $sql .= " AND (news_id = $id)";
7     $sql .= " ORDER BY date DESC LIMIT $limit";
8     $sth = $dbh->prepare($sql);
9     if (!$sth) error("Cannot prepare query: \"$sql\"");
10     if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
11     while ($row = $sth->fetchrow_array()) {
12     $art = array();
13     list($art["id"], $art["title"], $art["lead"], $art["pic_url"],
14     $art["pic_alt"], $art["pic_pos"], $art["more"], $date) = $row;
15     list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);
16     $text = array();
17     if ($art["id"]) {
18     $sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos FROM paragraphs, par_levels WHERE (news_id = ".$art["id"].") AND (level = level_id)";
19     $sth2 = $dbh->prepare($sql);
20     if (!$sth2) error("Cannot prepare query: \"$sql\"");
21     if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
22     while ($row = $sth2->fetchrow_array()) {
23     list($w, $h) = PicSize($row[5]);
24     array_push($text, array(
25     "id" => $row[0],
26     "text" => $row[1],
27     "title" => $row[2],
28     "level" => $row[3],
29     "class" => $row[4],
30     "pic" => $row[5],
31     "alt" => $row[6],
32     "pos" => $row[7],
33     "w" => $w,
34     "h" => $h
35     ));
36     }
37     $sth2->finish();
38     }
39     $art["text"] = $text;
40     $art["read"] = (count($text) > $npar) ? true : false;
41     $art["category"] = $cat;
42     $art["limit"] = $limit;
43     $art["npar"] = $npar;
44     array_push($arts, $art);
45     }
46     $sth->finish();
47     return $arts;
48     }
49    
50     function newsShow($art) {
51     global $fname, $syspicdir, $tpl;
52     $fname = "show.tpl";
53     $tpl->assign("title", MyEscape($art["title"]));
54     $tpl->assign("lead", MyEscape($art["lead"]));
55     $tpl->assign("titlepic_url", MyEscape($art["pic_url"]));
56     $tpl->assign("titlepic_alt", MyEscape($art["pic_alt"]));
57     $tpl->assign("titlepic_type", $art["pic_pos"]);
58     $tpl->assign("title_url", MyEscape($art["more"]));
59     $tpl->assign("titlepic_width", $art["pic_w"]);
60     $tpl->assign("titlepic_height", $art["pic_h"]);
61     for ($i = 0; $i < count($art["text"]); $i++)
62     $art["text"][$i]["text"] = ParseNewline(MyEscape($art["text"][$i]["text"]));
63     $tpl->assign("text", $art["text"]);
64     $tpl->assign("cat", $art["category"]);
65     }
66     ?>

  ViewVC Help
Powered by ViewVC 1.1.26