<?php

 
global $PHP_SELF$db$act$news_tpl$news_id$news_page;

 
$max_items 5;

 
$pages = array(
   
""         =>"news_index",
   
"index"    =>"news_index",
   
"news_list"=>"news_list",
   
"news_item"=>"news_item",
 );

 
// not current page attributes
 
$news_pages_attrs[] = array(
   
"NEWS_PU_A0"=>"",
   
"NEWS_PU_A1"=>"",
   
"NEWS_PD_A0"=>"",
   
"NEWS_PD_A1"=>"",
 );

 
// current page attributes
 
$news_pages_attrs[] = array(
   
"NEWS_PU_A0"=>"<font color=Red>",
   
"NEWS_PU_A1"=>"</font>",
   
"NEWS_PD_A0"=>"<font color=Red>",
   
"NEWS_PD_A1"=>"</font>",
 );

//echo( $pages[ $news_tpl] . "dd $news_tpl DDD");
 
$tpl = new dvTPL"./_tpl/" $pages"$news_tpl"] . ".tpl");
 
$tpl->tpl_read();
 
$tpl->tpl_split();
 
$vars = array();
 
$ret "";
 
$tpl->walk"""tpl_func"$varsTPLF_RST$ret);

 
$news_pic_0 = array(
   
"PicHeader0"=>"PIC0_DESC",
 );
 
$news_pic_1 = array(
   
"PicHeader1"=>"PIC1_DESC",
 );
 
$news_pic_2 = array(
   
"PicHeader2"=>"PIC2_DESC",
 );
 
$news_pic_3 = array(
   
"PicHeader3"=>"PIC3_DESC",
 );
 
$news_pic_4 = array(
   
"PicHeader4"=>"PIC4_DESC",
 );
 
$news_pic_5 = array(
   
"PicHeader5"=>"PIC5_DESC",
 );
 
$news_trs = array(
   
"Id"=>"ID",
   
"Data"=>"DATA",
   
"ShortForm"=>"SHORT_FORM",
   
"FullForm"=>"FULL_FORM",
   
"Subject"=>"SUBJECT",
   
"Picture"=>"PIC0",
   
"NEWS_PIC0"=>array( "Picture"$news_pic_0),
   
"NEWS_PIC1"=>array( "Picture1"$news_pic_1),
   
"NEWS_PIC2"=>array( "Picture2"$news_pic_2),
   
"NEWS_PIC3"=>array( "Picture3"$news_pic_3),
   
"NEWS_PIC4"=>array( "Picture4"$news_pic_4),
   
"NEWS_PIC5"=>array( "Picture5"$news_pic_5),
   );

 
$news_attrs = array(
   
"ACT"=>"0.1",
   
"NEWS_HREF"=>$PHP_SELF,
   );
 
 
////// NEWS START
 
$db->Push$tmpvd);
 
$db->Query"SELECT COUNT(Id) FROM news");
 
$db->Next();
 
$num $db->rec0];
 
$pnum intval$num $max_items);
 if ( 
$pnum != $num $max_items$pnum++;
//echo( "PAGES:" . $pnum);
 
$tmpq "";
 
$tmpq .= "SELECT * FROM news";
 if ( 
$news_id != ""$tmpq .= " WHERE Id=$news_id";
 
$tmpq .= " ORDER BY Data DESC, Id DESC LIMIT " . ( $news_page $max_items) . ",$max_items";
 
$db->Query$tmpq);
 
tpl_news$tpl$db"NEWS"$news_trs$news_attrs$pnum$news_page);
 
tpl_news_pages$tpl"NEWS_PU"$news_attrs$news_pages_attrs$pnum$news_page);
 
tpl_news_pages$tpl"NEWS_PD"$news_attrs$news_pages_attrs$pnum$news_page);
 
$db->Pop$tmpvd);
 
/////// NEWS END

 /////// PARSE & PRINT
 
$tpl->walk".""tpl_func"$varsTPLF_STRIP$ret);
 echo( 
$ret);
?>