require_once('../prepare.php');
//require_once('lib/function.php');
function siru_list( $p )
{
$show_line = 10;
$p['page'] = (!empty($p['page']) && '0' < $p['page']) ? $p['page'] : '1';
//- 汁物csv取得
$csv_siru = get_csvdata('siru');
//- 弁当csv取得
$csv_siru_top = get_csvdata('siru_top');
$this->db = cs4_open();
//- 写真付き日替わりレシピ取得
$siru_top = get_rcpList($this->db, $csv_siru_top);
//現在時刻を取得
$today = getdate();
$hours = $today[hours];
//22:00以降は翌日のレシピを表示するための処理
if($hours >= 22){
$siru_top['today'] = $siru_top['tomorrow'];
}
$img_filename = sprintf("%s_n-s.jpg",$siru_top['today'][0]['uniq_id']);
$img_path = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename);
//- 10件分を取得
$start = (($p['page'] - 1) * $show_line) + 1;
for($i=$start ; $i < count($csv_siru) && $i < ($p['page'] * $show_line) + 1 ;$i++){
$line_arr = explode(",",$csv_siru[$i]);
if(is_numeric(trim($line_arr[0]))){
$siru_list[] = get_rcpDetail($this->db, $line_arr[0]);
}
}
//- 検索結果ゼロ処理
$list_ct = count($csv_siru);//- 取得件数
if('0' == $list_ct){
print "Not Found your request Recipe !!";
exit;
}
// テンプレート読み込み
$template =& loadTemplate( $p );
if(!empty($siru_top['today'][0])){
$template->setCurrentBlock('__ShowImage__');
if(file_exists($img_path)){
$template->setVariable('recipe_image',sprintf("
",str_replace(KTY_SERVER_ROOT,"",$img_path)));
// $template->setVariable('img_id',$siru_top['today'][0]['uniq_id']);
}
$template->parseCurrentBlock();
$template->setCurrentBlock('__TopRecipe__');
$template->setVariable('rcp_no',$siru_top['today'][0]['uniq_id']);
$template->setVariable('title',$siru_top['today'][0]['rcp_nm']);
$template->parseCurrentBlock();
}
for($i=0;$isetCurrentBlock('__List__');
$template->setVariable('rcp_no',$siru_list[$i][0]['uniq_id']);
$template->setVariable('title',$siru_list[$i][0]['rcp_nm']);
$img_f = sprintf("%s_n-s.jpg",$siru_list[$i][0]['uniq_id']);
$img = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_f);
if(file_exists($img)){
$template->setVariable('img',sprintf("
",str_replace(KTY_SERVER_ROOT,"",$img)));
}
$template->parseCurrentBlock();
}
//- ページ送り処理 (Prev)
if('1' < $p['page']){
$template->setCurrentBlock('__PagePrev__');
$template->setVariable('prev_page',$p['page'] - 1);
$template->parseCurrentBlock();
}
//- ページ送り処理 (Next)
if(($p['page'] * $show_line) < $list_ct){
$template->setCurrentBlock('__PageNext__');
$template->setVariable('next_page', $p['page'] + 1);
$template->parseCurrentBlock();
}
$template->setVariable('site_top',SITE_NAME);
$template->show();
cs4_close($this->db);
}
siru_list( $p );
?>