require_once('../prepare.php');
require_once('lib/search_function.php');
function search_detail( $p ){
$this->db = cs4_open();
//- レシピ詳細情報取得
$detail = get_rcpDetail($this->db,$p['id']);
//- 2007.07.06 J.Nikaido Add 有料レシピの場合には無料会員はマイメニュー登録ページへ遷移
if($detail[0][toll_flg] >= 1){
//- メンバーチェック
if("e" == $p['carrier']){
chdir(dirname(__FILE__) . "/authcheck");
require_once("../authcheck/authcheck.php");
chdir(dirname(__FILE__));
}
$db = u4user_open();
if(!get_UserDetail_uid($db, $p['uid'], '0', '1') && MEMBER_CHECK && "w" != $p['carrier']){
$p['template'] = preg_replace('/.php$/','_free.html', basename( $_SERVER['SCRIPT_NAME'] ) );
$p['template_x'] = preg_replace('/.php$/','_free.xhtml', basename( $_SERVER['SCRIPT_NAME'] ) );
$free_flg = true;
}
u4user_close($db);
}
//- レシピ写真サイズ判定
if("1" == $p['version']){
$photo_size = 1;
}else{
$photo_size = 0;
}
//- au Ver.2 対応
if("e" == $p['carrier'] && $p['version'] == "2"){
$photo_size = 1;
}
$dir_name = substr(strrchr(dirname( __FILE__ ) , '/'), 1);
// テンプレート読み込み
$template =& loadTemplate( $p );
if($free_flg){
if($p['carrier'] == 'i'){
$template->setVariable('regist_url', MEMBER_REGIST_URL . "?uid=NULLGWDOCOMO&p[contents]=" . $dir_name."_".$p['id']);
}else{
$template->setVariable('regist_url', MEMBER_REGIST_URL . "?p[contents]=" . $dir_name."_".$p['id']);
}
}
$template->setVariable('recipe_name',$detail[0]['rcp_nm']);
$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_salt']) && "1" == $detail[0]['rcp_salt_flg']){
$template->setCurrentBlock('__Salt__');
$template->setVariable('salt',sprintf("%sg
",$detail[0]['rcp_salt']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_menu'])){
$template->setCurrentBlock('__Genre__');
$template->setVariable('genre',sprintf("%s
",$detail[0]['rcp_menu']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_time'])){
$template->setCurrentBlock('__Time__');
$template->setVariable('time',sprintf("%s
",$detail[0]['rcp_time']."分"));
$template->parseCurrentBlock();
}
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_style'])){
$template->setCurrentBlock('__Style__');
$template->setVariable('style',sprintf("%s
",$detail[0]['rcp_style']));
$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);
$template->setVariable('amount',sprintf(":%s",$ing_amount));
$template->parseCurrentBlock();
}
if(!$free_flg){
//- 作り方セット
$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']);
//- お気に入り セット
if( is_favorite($this->db,$detail[0]['uniq_id'],$p['uid']) ){
$template->setCurrentBlock('__FavoriteOff__');
$template->setVariable('rcp_no',$detail[0]['uniq_id']);
$template->setVariable('contents','search');
$template->parseCurrentBlock();
$template->hideBlock('__FavoriteOn__');
}else{
$template->setCurrentBlock('__FavoriteOn__');
$template->setVariable('rcp_no',$detail[0]['uniq_id']);
$template->setVariable('contents','search');
$template->parseCurrentBlock();
$template->hideBlock('__FavoriteOff__');
}
//- 検索条件
$p['pre_terms'] = serialize($p);
}
//- access_log 記録
//$ret = bsc_insert_acslog($this->db,$detail[0],"r",$p['uid']);
//- 戻りURLセット
$add_param = "";
if(!empty($p['vegetable'])){
$add_param .= sprintf("&p[vegetable]=%s",$p['vegetable']);
}
if(!empty($p['meat'])){
$add_param .= sprintf("&p[meat]=%s",$p['meat']);
}
if(!empty($p['fish'])){
$add_param .= sprintf("&p[fish]=%s",$p['fish']);
}
if(!empty($p['other'])){
$add_param .= sprintf("&p[other]=%s",$p['other']);
}
if(!empty($p['genre'])){
$add_param .= sprintf("&p[genre]=%s",$p['genre']);
}
if(!empty($p['ing_genre'])){
$add_param .= sprintf("&p[ing_genre]=%s",$p['ing_genre']);
}
if(!empty($p['cook'])){
$add_param .= sprintf("&p[cook]=%s",$p['cook']);
}
if(!empty($p['kind'])){
$add_param .= sprintf("&p[kind]=%s",$p['kind']);
}
if(!empty($p['theme'])){
$add_param .= sprintf("&p[theme]=%s",$p['theme']);
}
if(!empty($p['keywords'])){
$add_param .= sprintf("&p[keywords]=%s",$p['keywords']);
}
if(!empty($p['mode'])){
$add_param .= sprintf("&p[mode]=%s",$p['mode']);
}
$add_param = sprintf("?p[page]=%d%s",$p['page'],$add_param);
$template->setVariable('add_param',$add_param);
$template->show();
cs4_close($this->db);
}
search_detail( $p );
?>