--- new.php 2001/02/23 15:23:32 1.5 +++ new.php 2001/09/18 10:26:46 1.17 @@ -13,11 +13,21 @@ $section="new"; } +$sql_where="where $visible_is_true"; + if ($section == "investor") { $title="INVESTOR'S PAGE"; $lpic="investor"; $lext=".jpg"; $mpic="investors.gif"; $back_url="investor.php"; + if (! isset($type)) { + $sql_where .= " and type='i'"; + } + $title.=" : Investors News"; +} elseif ($section == "about") { + $title="ABOUT US"; + $lpic="about"; $lext=".gif"; + $mpic="about.gif"; } else { $title="What's New"; $lpic="new"; $lext=".jpg"; @@ -25,17 +35,9 @@ $back_url="index.php"; } -$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, Section_title=>$title ) ); +$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, ) ); -$sql_where="where visible is true"; - -function find_html_file($dir,$file) { - $file="./$dir/$file"; - if (is_file("$file") && file_exists("$file")) { return "$file"; } - if (is_file("$file.htm") && file_exists("$file.htm")) { return "$file.htm"; } - if (is_file("$file.html") && file_exists("$file.html")) { return "$file.html"; } - return 0; -} +include("find_html_file.inc"); if (file_exists(find_html_file("news",$more))) { @@ -49,7 +51,14 @@ if (isset($type)) { if ($type == "n") { - $sql_where .= " and type='n'"; + $sql_where .= " and (type='n' or type='i')"; + $title.=" : News"; + } elseif ($type == "e") { + $sql_where .= " and type='e'"; + $title.=" : Events"; + } elseif ($type == "c") { + $sql_where .= " and type='c'"; + $title.=" : Community"; } } @@ -60,11 +69,21 @@ } + if (isset($days)) { + if ($days != 0) { + $sql_where.=" and date(now())-date(date) > 0 and date(now())-date(date) < $days"; + $title.=" : News in last $days days"; + } + $smarty->assign("days",$days); + $smarty->assign("last_days",array(14,30,160,240,365)); + $smarty->assign("last_desc",array("two weeks","one month","four months","six months","one year")); + } + $num_selected=0; $sql="select id,upper(title) as title,town_date,body,more,pdf, - (date-now()::date) as comming - from news $sql_where order by date desc $sql_limit"; + (date-now()::date) as comming,type,title as title_lc + from news $sql_where order by priority desc,date desc $sql_limit"; # print "$sql"; $sth = $dbh->prepare("$sql"); $sth->execute(); @@ -74,19 +93,51 @@ } if ($num_selected == 10) { + $tmp="$PHP_SELF?start=".($start+10); + if ($days) $tmp.="&days=$days"; $smarty->assign(array( "multi_page_show" => 1, - "multi_page_next" => "$PHP_SELF?start=".($start+10), + "multi_page_next" => $tmp )); } if ($start && $start >= 10) { + $tmp="$PHP_SELF?start=".($start-10); + if ($days) $tmp.="&days=$days"; $smarty->assign(array( "multi_page_show" => 1, - "multi_page_prev" => "$PHP_SELF?start=".($start-10), + "multi_page_prev" => $tmp )); } - $smarty->assign("data",$data); + if (isset($id) && $num_selected == 1) { + if ($data[0][type] == "n") { + $title.=" : News : ".$data[0][title_lc]; + } elseif ($data[0][type] == "e") { + $title.=" : Event : ".$data[0][title_lc]; + } elseif ($data[0][type] == "c") { + $title.=" : Community : ".$data[0][title_lc]; + } elseif ($data[0][type] == "r") { + $title.=" : Result : ".$data[0][title_lc]; + } elseif ($data[0][type] == "i") { + $title.=" : Investors News : ".$data[0][title_lc]; + } elseif ($data[0][type] == "a") { + $title.=" : Annual Report : ".$data[0][title_lc]; + } elseif ($data[0][type] == "p") { + $title.=" : Presentations : ".$data[0][title_lc]; + } + } + + + if (isset($days) && $num_selected == 0) { + $warning = "There are no news for last $days days."; + } elseif ($main == "" && $num_selected == 0) { + $warning = "This news item is no longer available"; + } + + $smarty->assign(array( + data=>$data, + warning=>$warning + )); $main=$smarty->fetch("new.tpl"); @@ -94,14 +145,12 @@ $main=join('',file(find_html_file("news",$data[0][more]))); } - if ($main == "") { - $main = "This news item is no longer available"; - } } include("common.inc"); -$smarty->assign( array(back_url=>$back_url, MAIN=>$main)); +$smarty->assign( array(back_url=>$back_url, MAIN=>$main, + Section_title=>$title ) ); $smarty->display("index.tpl"); ?>