/[pliva-si]/sections/novosti.inc
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 /sections/novosti.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Fri Jun 29 12:57:06 2001 UTC (22 years, 9 months ago) by dpavlin
Branch: MAIN
news

1 dpavlin 1.1 <?
2    
3     include("news_sif.inc");
4    
5     $sql_where="where visible is true";
6    
7     if (file_exists(find_html_file("more",$more))) {
8    
9     $main=join('',file(find_html_file("more",$more)));
10     $back_url=$GLOBALS[HTTP_REFERER];
11    
12     } else {
13     if (isset($id)) {
14     $sql_where.=" and id=$id ";
15     }
16    
17     if (isset($type)) {
18     if ($type == "n") {
19     $sql_where .= " and substr(type,1,1)='n'";
20     $title.=" : Novosti";
21     } elseif ($type == "e") {
22     $sql_where .= " and substr(type,1,1)='e'";
23     $title.=" : Dogotki";
24     }
25     }
26    
27     if (! isset($show) && !isset($start)) {
28     $sql_limit="limit 10";
29     } elseif (isset($start)) {
30     $sql_limit="limit 10,$start";
31     }
32    
33    
34     if (isset($days)) {
35     if ($days != 0) {
36     $sql_where.=" and date(now())-date(date) > 0 and date(now())-date(date) < $days";
37     $title.=" : News in last $days days";
38     }
39     $smarty->assign("days",$days);
40     $smarty->assign("last_days",array(14,30,160,240,365));
41     $smarty->assign("last_desc",array("two weeks","one month","four months","six months","one year"));
42     }
43    
44     $num_selected=0;
45     $sql="select
46     id,upper(title) as title,town_date,body,more,pdf,
47     (date-now()::date) as comming,type,title as title_lc
48     from news $sql_where order by priority desc,date desc $sql_limit";
49     # print "$sql";
50     $sth = $dbh->prepare("$sql");
51     $sth->execute();
52     while ($row=$sth->fetchrow_hash()) {
53     $data[]=$row;
54     $num_selected++;
55     }
56    
57     if ($num_selected == 10) {
58     $tmp="$PHP_SELF?start=".($start+10);
59     if ($days) $tmp.="&days=$days";
60     $smarty->assign(array(
61     "multi_page_show" => 1,
62     "multi_page_next" => $tmp
63     ));
64     }
65     if ($start && $start >= 10) {
66     $tmp="$PHP_SELF?start=".($start-10);
67     if ($days) $tmp.="&days=$days";
68     $smarty->assign(array(
69     "multi_page_show" => 1,
70     "multi_page_prev" => $tmp
71     ));
72     }
73    
74     if (isset($id) && $num_selected == 1) {
75     $title.=" : ".$news_sif[$data[0][type]];
76     $title.=" : ".$data[0][title_lc];
77     }
78    
79    
80     if (isset($days) && $num_selected == 0) {
81     $warning = "There are no news for last $days days.";
82     } elseif ($main == "" && $num_selected == 0) {
83     $warning = "This news item is no longer available";
84     }
85    
86     $smarty->assign(array(
87     data=>$data,
88     warning=>$warning
89     ));
90    
91     $main=$smarty->fetch("novosti.tpl");
92    
93     if (isset($id) && find_html_file("more",$data[0][more])) {
94     $main=join('',file(find_html_file("more",$data[0][more])));
95     }
96    
97    
98     }
99    
100     $smarty->assign( array(back_url=>$back_url) );
101    
102     ?>

  ViewVC Help
Powered by ViewVC 1.1.26