require_once('../prepare.php');
require_once('lib/bbs_recipe_function.php');
//- メンバーチェック
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){
header("Location: " . MEMBER_REGIST_URL . "?p[contents]=" . substr(strrchr(dirname( __FILE__ ) , '/'), 1));
exit;
}
function bbs_list( $p )
{
$this->db = cs4_open();
$terms = $p;
$title_arr = array(
'1' => 'カンタンレシピ自慢BBS',
'2' => '一人暮らしレシピ自慢BBS',
'3' => '家庭料理レシピ自慢BBS',
'4' => 'ヘルシーレシピ自慢BBS',
'5' => 'お弁当レシピ自慢BBS'
);
//var_dump($terms);
//- mode毎にkeyphraseセット <--- 初期仕様では表示なし
/*
switch($terms['mode']){
case "words":
$title = "キーワードサーチ";
// $keyphrase[]['phrase'] = sprintf("・キーワード:%s",urldecode($terms['keywords']));
if(empty($terms['keywords'])){
if(!empty($terms['pre_terms']['keywords'])){
$tmp_key = array('name' => 'keywords','phrase' => sprintf("・主材料:%s",urldecode($terms['pre_terms']['keywords'])));
}
}else{
$tmp_key = array('name' => 'keywords','phrase' => sprintf("・主材料:%s",urldecode($terms['keywords'])));
}
$keyphrase[] = $tmp_key;
break;
case "quick":
$title = "クイックサーチ";
$main_arr = array(
'20' => '魚介類',
'31' => '牛肉',
'32' => '鶏肉',
'33' => '豚肉'
);
if(!empty($terms['main']) && '0' != $terms['main']){
// $main_arr = bsc_get_rcp_main_arr();
$main = $main_arr[$terms['main']];
$tmp_key = array('name' => 'main','phrase' => sprintf("・主材料:%s",$main));
$keyphrase[] = $tmp_key;
}
if(!empty($terms['cook']) && '0' != $terms['cook']){
$cook = bsc_get_rcp_howto_cook($this->db,$terms['cook']);
$tmp_key = array('name' => 'cook','phrase' => sprintf("・調理方法:%s",$cook));
$keyphrase[] = $tmp_key;
}
if(!empty($terms['kind']) && '0' != $terms['kind']){
$kind = bsc_get_rcp_kind($this->db,$terms['kind']);
$tmp_key = array('name' => 'kind','phrase' => sprintf("・種類:%s",$kind[0]['r_knd_nm']));
$keyphrase[] = $tmp_key;
}
if(!empty($terms['add_keywords'])){
$keyphrase[] = array('name' => 'add_keywords','phrase' => sprintf("・キーワード:%s",$terms['add_keywords'] ));
}
break;
case "style":
$style_arr = bsc_get_rcp_RcpStyle_arr($this->db);
$title = "スタイルレシピ";
$keyphrase[] = array('name' => 'style','phrase' => sprintf("・%s",$style_arr[$terms['style']]));
break;
}
*/
//- ページ番号セット
$terms['page'] = (empty($terms['page'])) ? "1" : $terms['page'] ;
//---- 該当条件レシピ一覧を取得
$rcp_list = rcp_getRcpList($this->db,$terms);
$count = ($rcp_list['list']) ? count($rcp_list['list']) : false ;
if(constant('BBS_DEBUG_MODE')){
print "
-------------------
bh_recipe_search.php L178 Count -> ";
var_dump($count);
}
// テンプレート読み込み
$template =& loadTemplate( $p );
/*
//- Keyphrase表示
for($i=0;$isetCurrentBlock('__SearchKey__');
$template->setVariable('keyphrase',$keyphrase[$i]['phrase']);
$template->parseCurrentBlock();
}
*/
//- ページタイトルセット
$template->setVariable('page_title',$title_arr[substr($p['gnr_no'],3,1)]);
$template->setVariable('title',$title_arr[substr($p['gnr_no'],3,1)]);
//- 検索エラーハンドリング
if($count){
$template->setCurrentBlock('__SerachResult__');
$template->setVariable('count',$count);
$template->parseCurrentBlock();
$template->hideBlock('__SearchError__');
}else{
$template->TouchBlock('__SearchError__');
$template->hideBlock('__SearchResult__');
}
//-- レシピ一覧作成
$start = ($terms['page'] - 1) * constant('RCP_LIST_COUNT');
$limit = (($start + constant('RCP_LIST_COUNT')) > $count) ? $count : $start + constant('RCP_LIST_COUNT');
//var_dump($rcp_list);
for($i = $start;$i < $limit;$i++){
//- ユーザ情報取得
$user_detail = rcp_get_UserDetail($db,$rcp_list['list'][$i]['mem_no']);
//- Detail url作成
//2006.06.22 J,Nikaido Add
// $detail_url = sprintf("bbs_detail.php?p[id]=%d",$rcp_list['list'][$i]['uniq_id']);
$detail_url = sprintf("%d",$rcp_list['list'][$i]['uniq_id']);
//- ユーザプロフィールリンクurl作成
//2006.06.22 J,Nikaido Add
// $user_prof_url = sprintf("bbs_userslist.php?p[id]=%s",$rcp_list['list'][$i]['mem_no']);
$user_prof_url = sprintf("userslist/%s",$rcp_list['list'][$i]['mem_no']);
$template->setCurrentBlock('__RecipeList__');
$template->setVariable('url',$detail_url);
$template->setVariable('rcp_name',$rcp_list['list'][$i]['rcp_nm']);
$template->setVariable('user_name',sprintf("勒%s",$user_prof_url,$user_detail['mem_nick_nm']));
// $template->setVariable('time',$rcp_list['list'][$i]['rcp_time']);
// if(!empty($rcp_list['list'][$i]['rcp_crl'])){
// $template->setVariable('calorie',sprintf("・%skcal",$rcp_list['list'][$i]['rcp_crl']));
// }
$template->parseCurrentBlock();
}
if(constant('BBS_DEBUG_MODE')){
print "
Page Now -> ".$terms['page']."
\n";
print "Total Count -> ".$count."
\n";
print "Show Limit -> ".$limit."
\n";
}
$key_str = "";
if($terms['page'] > '1'){
$template->setCurrentBlock('__PagePrev__');
$template->setVariable('prev_page',($terms['page'] - 1));
$template->setVariable('page_genre',$terms['gnr_no']);
/*
switch($terms['mode']){
case "words":
$template->setVariable('terms',sprintf("&p[keywords]=%s",urlencode($terms['keywords'])));
break;
case "quick":
for($i=0;$isetVariable('terms',$key_str);
break;
case "style":
// $template->setVariable('terms',sprintf("&p[%s]=%s",urlencode($terms['keywords'])));
for($i=0;$isetVariable('terms',$key_str);
break;
default:
break;
}
*/
$template->parseCurrentBlock();
}else{
$template->hideBlock('__PagePrev__');
}
if($count > $limit){
$template->setCurrentBlock('__PageNext__');
$template->setVariable('next_page',($terms['page'] + 1));
$template->setVariable('page_genre',$terms['gnr_no']);
/*
switch($terms['mode']){
case "words":
$template->setVariable('terms',sprintf("&p[keywords]=%s",urlencode($terms['keywords'])));
break;
case "quick":
for($i=0;$isetVariable('terms',$key_str);
break;
case "style":
for($i=0;$isetVariable('terms',$key_str);
break;
default:
break;
}
*/
$template->parseCurrentBlock();
}else{
$template->hideBlock('__PageNext__');
}
// $template->parseCurrentBlock();
$template->setVariable('contents_top',BBS_NAME);
$template->show();
cs4_close($this->db);
}
//var_dump($p);
bbs_list( $p );
?>