/*
*********************************************************************************
* システム:katsuyo.net *
*===============================================================================*
* クラス:diet_nifty_detail |モジュール:diet_nifty_detail.php *
* 概要 :ダイエット趣向レシピ芸能nifty用 ダイエットレシピ詳細表示画面 *
* パス :APP_HOME/diet/ *
* 作成 :2007/05/29 J.Nikaido *
*-------------------------------------------------------------------------------*
* 更新 : *
*********************************************************************************
*/
require_once('../prepare.php');
require_once('lib/diet_function.php');
function diet_nifty_detail( $p ){
//現在時刻を取得
$today = getdate();
$hours = $today[hours];
//明日日時を取得
$date_today = mktime (0, 0, 0, date("m"), date("d"), date("y"));
$date_tomorrow = $date_today + 86400;
//本日日付取得(22:00以降は翌日のレシピを表示)
if($hours >= 22){
$this->today = date('Y/m/d', $date_tomorrow);
}else{
$this->today = date("Y/m/d");
}
$this->db = cs4_open();
//レシピID取得
$where = sprintf("date <= '%s'",$this->today);
$ret = cs4_select($this->db,"kty_diet_set" , $where , 'date' ,'DESC',0,1);
while($row = cs4_fetch_row($ret)){
$main_id = $row['main_id'];
$day = substr(str_replace("-","",$row['date']),0,8);
}
if(strlen($main_id) <= 0){
$main_id = '9064';
$day = date(Ymd);
}
//- レシピ詳細情報取得
$detail = get_rcpDetail($this->db,$main_id);
//- レシピ写真サイズ判定
if("1" == $p['version']){
$photo_size = 1;
}else{
$photo_size = 0;
}
//- au Ver.2 対応
if("e" == $p['carrier'] && $p['version'] == "2"){
$photo_size = 1;
}
// テンプレート読み込み
$template =& loadTemplate( $p );
$template->setVariable('recipe_name',$detail[0]['rcp_nm']);
if(strlen($day) > 7){
$update_day = substr($day,4,2)."月".substr($day,6,2)."日";
}
$template->setVariable('update_day',$update_day);
$img_filename = array(sprintf("%s_n.jpg",$detail[0]['uniq_id']),sprintf("%s_n-s.jpg",$detail[0]['uniq_id']));
switch($photo_size){
case "0":
$img_path = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[0]);
$another_url = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[1]);
if(file_exists($img_path)){
$template->setVariable('recipe_image',sprintf("
",str_replace(KTY_SERVER_ROOT,"",$img_path)));
}
clearstatcache();
break;
case "1":
$img_path = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[1]);
$another_url = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[0]);
if(file_exists($img_path)){
$template->setVariable('recipe_image',sprintf("
",str_replace(KTY_SERVER_ROOT,"",$img_path)));
}
clearstatcache();
break;
default:
break;
}
if(!empty($detail[0]['rcp_crl'])){
$template->setCurrentBlock('__Calorie__');
$template->setVariable('calorie',sprintf("%skcal
",$detail[0]['rcp_crl']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_num'])){
$template->setVariable('number_of_persons',sprintf("(%s人分)",$detail[0]['rcp_num']));
}
//- 材料セット
$ing = array();
$detail[0]['rcp_cook_mtr'] = str_replace("、",",",$detail[0]['rcp_cook_mtr']);
$ing = explode(",",$detail[0]['rcp_cook_mtr']);
for($i=0;$isetCurrentBlock('__Ingedients__');
$template->setVariable('Ingredients',$ing_name);
if(!empty($ing_amount)){
$template->setVariable('amount',sprintf(":%s",$ing_amount));
}
$template->parseCurrentBlock();
}
//- 作り方セット
$howto = array();
$howto = explode(",",$detail[0]['mtr_cook_exp']);
for($i=0;$isetCurrentBlock('__HowtoCook__');
$template->setVariable('process',sprintf("%s.%s",$i + 1,$howto[$i]));
$template->parseCurrentBlock();
}
//- Memoセット
$template->setCurrentBlock('__Memo__');
$template->setVariable('memo',$detail[0]['rcp_comment']);
$template->parseCurrentBlock();
$template->setVariable('rcp_no',$detail[0]['uniq_id']);
$template->show();
cs4_close($this->db);
}
diet_nifty_detail( $p );
?>