/[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.3 - (show annotations)
Tue Aug 7 13:55:51 2001 UTC (22 years, 8 months ago) by ravilov
Branch: MAIN
Changes since 1.2: +18 -2 lines
Articles can now be moves up/down. Started the 'library' section.

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

  ViewVC Help
Powered by ViewVC 1.1.26