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

Contents of /inc/newsShow.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Wed Aug 8 12:58:08 2001 UTC (22 years, 8 months ago) by ravilov
Branch: MAIN
Changes since 1.3: +5 -2 lines
Conditions and Lifestyle news are now displayed in groups of 10.
mkdir.sh replaced with more general fix.sh.

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

  ViewVC Help
Powered by ViewVC 1.1.26