/[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.7 - (hide annotations)
Wed Sep 19 12:23:57 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.6: +40 -16 lines
Added thefilez/med/ (PLIVAmed site). Other major changes...

1 ravilov 1.1 <?php
2 ravilov 1.7 function newsLoad($id, $cat = "", $limit = 0, $offset = 0, $npar = 1) {
3     global $dbh, $spec, $isMed;
4 ravilov 1.1 $arts = array();
5 ravilov 1.4 if (!$offset) $offset = 0;
6 ravilov 1.7 $sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_change, author_pic, author_alt, author_info, ord FROM news".($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)";
7     if ($cat) $sql .= " AND (category = '$cat')";
8     /*
9     $sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_change, author_pic, author_alt, author_info, ord FROM news".($cat?", cat_news":"").($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)";
10     if ($cat) $sql .= " AND ((category = '$cat') OR ((cat_news.cat_id = '$cat') AND (cat_news.news_id = news.news_id)))";
11     */
12     if ($spec) $sql .= " AND (spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec)";
13 ravilov 1.1 if ($id > 0) $sql .= " AND (news_id = $id)";
14 ravilov 1.7 $sql .= " ORDER BY d_change DESC";
15 ravilov 1.4 if ($limit) $sql .= " LIMIT $limit OFFSET $offset";
16 ravilov 1.7 #echo "[$sql]<BR>\n";
17 ravilov 1.1 $sth = $dbh->prepare($sql);
18     if (!$sth) error("Cannot prepare query: \"$sql\"");
19     if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
20     while ($row = $sth->fetchrow_array()) {
21     $art = array();
22     list($art["id"], $art["title"], $art["lead"], $art["pic_url"],
23 ravilov 1.3 $art["pic_alt"], $art["pic_pos"], $art["more"],
24 ravilov 1.7 $art["more_title"], $date, $art["au_pic"],
25     $art["au_alt"], $art["au_info"], $ord) = $row;
26     list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]);
27     $art["more_new"] = strstr($art["more"], "://") ? true : false;
28     global $sysaupicdir;
29     list($art["au_w"], $art["au_h"]) = PicSize($art["au_pic"], $sysaupicdir);
30 ravilov 1.5 $art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"]));
31 ravilov 1.7 $art["au_pic"] = str_replace("+", "%20", urlencode($art["au_pic"]));
32 ravilov 1.1 $text = array();
33 ravilov 1.2 if (isset($art["id"])) {
34 ravilov 1.7 $sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos, hl FROM paragraphs, par_levels WHERE (news_id = ".$art["id"].") AND (level = level_id)";
35 ravilov 1.1 $sth2 = $dbh->prepare($sql);
36     if (!$sth2) error("Cannot prepare query: \"$sql\"");
37     if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
38     while ($row = $sth2->fetchrow_array()) {
39     list($w, $h) = PicSize($row[5]);
40     array_push($text, array(
41     "id" => $row[0],
42     "text" => $row[1],
43     "title" => $row[2],
44     "level" => $row[3],
45     "class" => $row[4],
46 ravilov 1.5 "pic" => str_replace("+", "%20", urlencode($row[5])),
47 ravilov 1.1 "alt" => $row[6],
48     "pos" => $row[7],
49 ravilov 1.7 "hl" => $row[8],
50 ravilov 1.1 "w" => $w,
51     "h" => $h
52     ));
53     }
54     $sth2->finish();
55     }
56     $art["text"] = $text;
57 ravilov 1.3 $art["order"] = $ord;
58 ravilov 1.2 $art["read"] = (count($art["text"]) > $npar) ? true : false;
59 ravilov 1.1 $art["category"] = $cat;
60     $art["limit"] = $limit;
61 ravilov 1.4 $art["offset"] = $offset;
62 ravilov 1.1 $art["npar"] = $npar;
63     array_push($arts, $art);
64     }
65     $sth->finish();
66 ravilov 1.3 $foo = true;
67     while ($foo) {
68     $foo = false;
69     for ($i = 0; $i < count($arts); $i++) {
70     if ($arts[$i]["order"] == 0) continue;
71     $j = ($i + $arts[$i]["order"]);
72     $j %= count($arts);
73 ravilov 1.7 if ($j < 0) $j += count($arts);
74     if ($i == $j) continue;
75 ravilov 1.3 $foo = true;
76     $tmp = $arts[$j];
77     $arts[$j] = $arts[$i];
78     $arts[$i] = $tmp;
79     $arts[$j]["order"] = 0;
80     }
81     }
82 ravilov 1.1 return $arts;
83     }
84    
85     function newsShow($art) {
86 ravilov 1.7 global $fname, $tpl;
87 ravilov 1.1 $fname = "show.tpl";
88 ravilov 1.7 $tpl->assign("title", MyEscape(convert_html($art["title"])));
89     $tpl->assign("lead", MyEscape(convert_html($art["lead"]), false));
90     $tpl->assign("titlepic_url", MyEscape(convert_html($art["pic_url"])));
91     $tpl->assign("titlepic_alt", MyEscape(convert_html($art["pic_alt"])));
92 ravilov 1.1 $tpl->assign("titlepic_type", $art["pic_pos"]);
93 ravilov 1.7 $tpl->assign("title_url", MyEscape(convert_html($art["more"])));
94     $tpl->assign("title_url_new", $art["more_new"]);
95     $tpl->assign("title_url_title", MyEscape(convert_html($art["more_title"])));
96 ravilov 1.1 $tpl->assign("titlepic_width", $art["pic_w"]);
97     $tpl->assign("titlepic_height", $art["pic_h"]);
98 ravilov 1.7 include_once("author.php");
99     $tpl->assign("AUTHOR", GetAuthor($art["au_pic"],
100     $art["au_alt"], $art["au_info"],
101     $art["au_w"], $art["au_h"]));
102     for ($i = 0; $i < count($art["text"]); $i++) {
103     $art["text"][$i]["text"] = ParseNewline(convert_html(
104     MyEscape($art["text"][$i]["text"]), false), true);
105     $art["text"][$i]["hl"] = ParseNewline(convert_html(
106     MyEscape($art["text"][$i]["hl"]), false), true);
107     }
108 ravilov 1.1 $tpl->assign("text", $art["text"]);
109     $tpl->assign("cat", $art["category"]);
110     }
111     ?>

  ViewVC Help
Powered by ViewVC 1.1.26