/[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.6 - (hide annotations)
Mon Sep 3 15:52:15 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.5: +3 -2 lines
Made the menu on the left into images. More bugfixes.

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

  ViewVC Help
Powered by ViewVC 1.1.26