/*
*********************************************************************************
* システム:katsuyo.net *
*===============================================================================*
* クラス:search_list |モジュール:search_list.php *
* 概要 :新・あしたのお弁当 あしたのお弁当TOP画面 *
* パス :APP_HOME/bentou/ *
* 作成 :2006/07/21 J.Nikaido *
*-------------------------------------------------------------------------------*
* 更新 : *
*********************************************************************************
*/
require_once('../prepare.php');
require_once('lib/bentou_function.php');
function search_list( $p ){
$r_id = $p['r_id'];
$r_id1 = $p['r_id1'];
$r_id2 = $p['r_id2'];
$r_id3 = $p['r_id3'];
/*
print "メイン:".$r_id1."
";
print "脇役:".$r_id2."
";
print "主食:".$r_id3."
";
print $r_id."
";
*/
//DB接続
$this->db = cs4_open();
// テンプレート読み込み
$template =& loadTemplate( $p );
//-- 追加絞り込み検索対応
if(!empty($p['pre_terms'])){
//- 前回検索条件を unserialize() してセット
$tmp_pre_terms = unserialize(base64_decode($p['pre_terms']));
$p['pre_terms'] = $tmp_pre_terms;
//- mode を保持する
$p['mode'] = ($p['mode'] != $p['pre_terms']['mode']) ? $p['pre_terms']['mode'] : $p['mode'];
if($p['mode'] == "mix_search"){
$p['ing_genre'] = $p['pre_terms']['ing_genre'];
$p['cook'] = $p['pre_terms']['cook'];
}
}
$terms = $p;
//---- 該当条件レシピ一覧を取得
$rcp_list = search_getRcpList($this->db,$terms);
//- mode毎にkeyphraseセット
if($p['mode'] == "mix_search"){
$title = "組み合わせから探す";
$ing_genre_arr = array(
'200' => '肉類',
'300' => '魚介類',
'401' => '海藻類',
'100' => '野菜類',
'402' => '乾物・加工品',
'403' => '卵・乳製品',
'404' => '豆・豆加工品'
);
if(!empty($terms['ing_genre']) && '0' != $terms['ing_genre']){
$tmp_key = array('name' => 'ing_genre','phrase' => sprintf("・素材:%s",$ing_genre_arr[$terms['ing_genre']]));
$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;
}
}
//- ページ番号セット
$terms['page'] = (empty($terms['page'])) ? "1" : $terms['page'] ;
$count = ($rcp_list['list']) ? count($rcp_list['list']) : false ;
//デバッグ処理
if(constant('RECIPE_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();
}
//- 検索エラーハンドリング
if($count){
$template->setCurrentBlock('__SerachResult__');
$template->setVariable('count',$count);
$template->parseCurrentBlock();
$template->hideBlock('__SearchError__');
}else{
$template->TouchBlock('__SearchError__');
}
//-- レシピ一覧作成
$start = ($terms['page'] - 1) * constant('RCP_LIST_COUNT');
$limit = (($start + constant('RCP_LIST_COUNT')) > $count) ? $count : $start + constant('RCP_LIST_COUNT');
$add_param = "";
for($i=0;$isetCurrentBlock('__RecipeList__');
$template->setVariable('url',$rcp);
$template->setVariable('rcp_no',$rcp_list['list'][$i]['uniq_id']);
$template->setVariable('rcp_name',$rcp_list['list'][$i]['rcp_nm']);
$template->setVariable('r_id',$r_id);
//print $r_id."
";
if($r_id == 1){
$template->setVariable('r_id1',$rcp_list['list'][$i]['uniq_id']);
$template->setVariable('r_id2',$r_id2);
$template->setVariable('r_id3',$r_id3);
}else if($r_id == 2){
$template->setVariable('r_id1',$r_id1);
$template->setVariable('r_id2',$rcp_list['list'][$i]['uniq_id']);
$template->setVariable('r_id3',$r_id3);
}else if($r_id == 3){
$template->setVariable('r_id1',$r_id1);
$template->setVariable('r_id2',$r_id2);
$template->setVariable('r_id3',$rcp_list['list'][$i]['uniq_id']);
}
$template->parseCurrentBlock();
}
//- 新規検索フォーム表示(全mode共通)
$template->touchBlock('__SearchForm__');
//デバッグ処理
if(constant('RECIPE_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_mode_pre',$terms['mode']);
$template->setVariable('r_id',$r_id);
$template->setVariable('r_id1',$r_id1);
$template->setVariable('r_id2',$r_id2);
$template->setVariable('r_id3',$r_id3);
if($p['mode'] == "mix_search"){
for($i=0;$isetVariable('terms',$key_str);
}
$template->parseCurrentBlock();
}else{
$template->hideBlock('__PagePrev__');
}
if($count > $limit){
$template->setCurrentBlock('__PageNext__');
$template->setVariable('next_page',($terms['page'] + 1));
$template->setVariable('page_mode_next',$terms['mode']);
$template->setVariable('r_id',$r_id);
$template->setVariable('r_id1',$r_id1);
$template->setVariable('r_id2',$r_id2);
$template->setVariable('r_id3',$r_id3);
if($p['mode'] == "mix_search"){
for($i=0;$isetVariable('terms',$key_str);
}
$template->parseCurrentBlock();
}else{
$template->hideBlock('__PageNext__');
}
//- pre_terms を一旦消去
$terms['pre_terms'] = "";
if(!$count || '0' == $count){
$terms = "";
}
$template->parseCurrentBlock();
$template->show();
//DB開放
cs4_close($this->db);
}
search_list( $p );
?>