--- new.php 2001/03/17 18:19:40 1.11 +++ new.php 2001/04/09 13:30:14 1.15 @@ -37,14 +37,7 @@ $smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, ) ); - -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))) { @@ -76,6 +69,16 @@ } + 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, @@ -90,15 +93,19 @@ } 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 )); } @@ -113,10 +120,22 @@ $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]; } } - $smarty->assign("data",$data); + + 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"); @@ -124,9 +143,6 @@ $main=join('',file(find_html_file("news",$data[0][more]))); } - if ($main == "") { - $main = "This news item is no longer available"; - } }