require_once('../prepare.php');
//require_once('lib/function.php');
function sweets_top( $p )
{
//- スウィーツcsv取得
$csv_sweets_top = get_csvdata('sweets_top');
$this->db = cs4_open();
//- 写真付き日替わりレシピ取得
$sweets_top = get_rcpList($this->db, $csv_sweets_top);
//現在時刻を取得
$today = getdate();
$hours = $today[hours];
//22:00以降は翌日のレシピを表示するための処理
if($hours >= 22){
$sweets_top['today'] = $sweets_top['tomorrow'];
}
$img_filename = sprintf("%s_n-s.jpg",$sweets_top['today'][0]['uniq_id']);
$img_path = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename);
$sweets_genre = get_SweetsGenre($this->db);
// テンプレート読み込み
$template =& loadTemplate( $p );
if(!empty($sweets_top['today'][0]) && (("2" == $p['version'] && "i" == $p['carrier']) || ("2" == $p['version'] && "e" == $p['carrier']) || "3" == $p['version'] || "w" == $p['carrier'] || "g" == $p['carrier'])){
$template->setCurrentBlock('__ShowImage__');
if(file_exists($img_path)){
$template->setVariable('recipe_image',sprintf("
",str_replace(KTY_SERVER_ROOT,"",$img_path)));
// $template->setVariable('img_id',$sweets_top['today'][0]['uniq_id']);
}
$template->parseCurrentBlock();
$template->setCurrentBlock('__TopRecipe__');
$template->setVariable('rcp_no',$sweets_top['today'][0]['uniq_id']);
$template->setVariable('title',$sweets_top['today'][0]['rcp_nm']);
$template->parseCurrentBlock();
}
for($i=0;$isetCurrentBlock('__GenreList__');
$template->setVariable('gnr_id',substr($sweets_genre[$i]['r_gnr_no'],1,1));
$template->setVariable('title',$sweets_genre[$i]['r_gnr_nm']);
$template->parseCurrentBlock();
}
$template->setVariable('site_top',SITE_NAME);
$template->show();
cs4_close($this->db);
}
sweets_top( $p );
?>