--- new.php 2001/02/20 12:53:02 1.1 +++ new.php 2002/04/29 13:11:39 1.24 @@ -6,57 +6,133 @@ $smarty->assign( array ( Title=>"Pliva d.d." ) ); - if (isset($from)) { $section=$from; } else { $section="new"; } +$sql_where="where $visible_is_true"; + +include("section.inc"); + 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"; } else { $title="What's New"; $lpic="new"; $lext=".jpg"; $mpic="new.gif"; $back_url="index.php"; + $sql_where.=" and (type='a' or type='c' or type='e' or type='f' or type='i' or type='n' or type='p' or type='r')"; // don't show company profile } -$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, Section_title=>$title ) ); +$smarty->assign( array ( lpic=>$lpic, lext=>$lext, mpic=>$mpic, ) ); -$sql_where=""; +include("find_html_file.inc"); +include("news_type.inc"); -if (isset($id)) { - $sql_where.=" where id=$id "; -} +if (file_exists(find_html_file("news",$more))) { -if (! isset($more) || !file_exists("./news/$more")) { + $main=join('',file(find_html_file("news",$more))); + $back_url=$GLOBALS[HTTP_REFERER]; -$sth = $dbh->prepare("select id,title,date,body,more,pdf from news $sql_where order by id desc"); -$sth->execute(); -while ($row=$sth->fetchrow_hash()) { - $data[]=$row; -} +} else { + if (isset($id)) { + $sql_where.=" and id=$id "; + } -$smarty->assign("data",$data); + if (isset($type)) { + if ($type == "n") { + $sql_where .= " and (type='n' or type='i')"; + } elseif ($type == "e" || $type == "f" || $type == "c") { + $sql_where .= " and type='".$type."'"; + } + $title.=" : ".$news_type[$type]; + } -$main=$smarty->fetch("new.tpl"); + if (! isset($show) && !isset($start)) { + $sql_limit="limit 10"; + } elseif (isset($start)) { + $sql_limit="limit 10,$start"; + } - if (isset($id) && $data[0][more]) { - $main=join('',file("./news/".$data[0][more])); + 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")); } -} else { // display details - $main=join('',file("./news/$more")); - $back_url=$GLOBALS[HTTP_REFERER]; + $num_selected=0; + $sql="select + id,upper(title) as title,town_date,body,more,pdf, + (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(); + while ($row=$sth->fetchrow_hash()) { + $data[]=$row; + $num_selected++; + } + + if ($num_selected == 10) { + $tmp="$PHP_SELF?start=".($start+10); + if ($days) $tmp.="&days=$days"; + if ($from) $tmp.="&from=$from"; + $smarty->assign(array( + "multi_page_show" => 1, + "multi_page_next" => $tmp + )); + } + if ($start && $start >= 10) { + $tmp="$PHP_SELF?start=".($start-10); + if ($days) $tmp.="&days=$days"; + if ($from) $tmp.="&from=$from"; + $smarty->assign(array( + "multi_page_show" => 1, + "multi_page_prev" => $tmp + )); + } + + if (isset($id) && $num_selected == 1) { + $title.=" : ".$news_type[ $data[0][type] ]." : ".$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"); + + if (isset($id) && find_html_file("news",$data[0][more])) { + $main=join('',file(find_html_file("news",$data[0][more]))); + } + + } include("common.inc"); -$smarty->assign( array(back_url=>$back_url, MAIN=>$main)); +$smarty->assign( array(back_url=>$back_url, MAIN=>$main, + Section_title=>$title ) ); + +include("inc/newsletter.php"); $smarty->display("index.tpl"); ?>