Changeset 20195
- Timestamp:
- 2011/02/18 16:53:46 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
r20187 r20195 95 95 */ 96 96 function action() { 97 $this->arrForm = $_GET; 98 //modeの取得 99 $this->mode = $this->getMode(); 100 101 //表示条件の取得 102 $this->arrSearchData = array( 103 'category_id' => $this->lfGetCategoryId($this->arrForm['category_id']), 104 'maker_id'=>$this->arrForm['maker_id'], 105 'name'=>$this->arrForm['name'] 106 ); 107 $this->orderby = $this->arrForm['orderby']; 108 109 //ページング設定 110 $this->tpl_pageno = $this->arrForm['pageno']; 111 $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); 112 113 $objQuery = new SC_Query();//$this->queryにしたい 114 $objDb = new SC_Helper_DB_Ex();//$this->helperDBにしたい 115 116 // 画面に表示するサブタイトルの設定 117 $this->tpl_subtitle = $this->lfGetPageTitle($this->mode,$this->arrSearchData['category_id'],$objDb); 118 119 // 画面に表示する検索条件を設定 120 $this->arrSearch = $this->lfGetSearchCondition($this->arrSearchData,$objQuery); 121 //この辺まではinit()に書いちゃダメなのかな? 122 //2011-02-17 ここまでやった 97 $this->lfLoadParam(); 98 $objQuery = new SC_Query(); 99 $objDb = new SC_Helper_DB_Ex(); 100 101 // タイトル編集 102 if ($this->mode == 'search') { 103 $this->tpl_subtitle = "検索結果"; 104 } elseif ($this->arrSearchData['category_id'] == 0) { 105 $this->tpl_subtitle = "全商品"; 106 } else { 107 $arrCat = $objDb->sfGetCat($this->arrSearchData['category_id']); 108 $this->tpl_subtitle = $arrCat['name']; 109 } 110 111 $count = $objQuery->count("dtb_best_products", "category_id = ?", array($this->arrSearchData['category_id'])); 123 112 124 113 // 商品一覧の表示処理 125 $this->arrProducts = $this->lfGetProductsList($objDb); 126 127 //onloadスクリプトを設定 114 $this->lfDispProductsList(); 115 116 // 検索条件を画面に表示 117 // カテゴリー検索条件 118 if ($this->arrSearchData['category_id'] == 0) { 119 $this->arrSearch['category'] = "指定なし"; 120 } else { 121 $arrCat = $objQuery->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($this->arrSearchData['category_id'])); 122 $this->arrSearch['category'] = $arrCat; 123 } 124 125 // メーカー検索条件 126 if (strlen($this->arrSearchData['maker_id']) == 0) { 127 $this->arrSearch['maker'] = "指定なし"; 128 } else { 129 $this->arrSearch['maker'] = $objQuery->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", $this->arrSearchData['maker_id']); 130 } 131 132 // 商品名検索条件 133 if (strlen($this->arrSearchData['name']) == 0) { 134 $this->arrSearch['name'] = "指定なし"; 135 } else { 136 $this->arrSearch['name'] = $this->arrSearchData['name']; 137 } 138 128 139 foreach ($this->arrProducts as $arrProduct) { 129 140 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n"; 130 } 131 132 //カート処理 133 if (intval($this->arrForm['product_id']) > 0) { 141 } 142 143 if ($this->inCart) { 134 144 // 商品IDの正当性チェック 135 145 if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) { … … 204 214 */ 205 215 function lfGetCategoryId($category_id) { 216 $objDb = new SC_Helper_DB_Ex(); 206 217 207 218 // 指定なしの場合、0 を返す … … 233 244 234 245 /* 商品一覧の表示 */ 235 function lfGetProductsList($objDb) { 246 function lfDispProductsList() { 247 $objDb = new SC_Helper_DB_Ex(); 236 248 $arrval = array(); 237 249 $arrval_order = array(); … … 425 437 * @return void 426 438 */ 427 function lfGetDisplayNum($display_number) { 439 function lfLoadParam() { 440 $this->arrForm = $_GET; 441 442 $this->mode = $this->getMode(); 443 $this->arrSearchData['category_id'] = $this->lfGetCategoryId($this->arrForm['category_id']); 444 $this->arrSearchData['maker_id'] = $this->arrForm['maker_id']; 445 $this->arrSearchData['name'] = $this->arrForm['name']; 446 $this->orderby = $this->arrForm['orderby']; 428 447 // 表示件数 429 if (!isset($display_number) 430 OR !SC_Utils_Ex::sfIsInt($display_number) 448 if ( 449 isset($this->arrForm['disp_number']) 450 && SC_Utils_Ex::sfIsInt($this->arrForm['disp_number']) 431 451 ) { 452 $this->disp_number = $this->arrForm['disp_number']; 453 } else { 432 454 //最小表示件数を選択 433 return current(array_keys($this->arrPRODUCTLISTMAX)); 434 } 435 return $display_number; 455 $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); 456 } 457 $this->tpl_pageno = $this->arrForm['pageno']; 458 $this->inCart = strlen($this->arrForm['product_id']) >= 1; 436 459 } 437 460 … … 460 483 } 461 484 } 462 463 /**464 * ページタイトルの設定465 *466 * @return str467 */468 function lfGetPageTitle($mode,$category_id = 0,$objDb){469 if ($mode == 'search') {470 return "検索結果";471 } elseif ($category_id == 0) {472 return "全商品";473 } else {474 $arrCat = $objDb->sfGetCat($category_id);475 return $arrCat['name'];476 }477 return "";478 }479 480 /**481 * 検索条件の設定482 *483 * @return array484 */485 function lfGetSearchCondition($arrSearchData,$objQuery){486 $arrSearch = array('category'=>"指定なし",'maker'=>"指定なし",'name'=>"指定なし");487 // カテゴリー検索条件488 if ($arrSearchData['category_id'] > 0) {489 $arrSearch['category'] = $objQuery->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($arrSearchData['category_id']));490 }491 492 // メーカー検索条件493 if (strlen($arrSearchData['maker_id']) > 0) {494 $arrSearch['maker'] = $objQuery->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", array($arrSearchData['maker_id']));495 }496 497 // 商品名検索条件498 if (strlen($arrSearchData['name']) > 0) {499 $arrSearch['name'] = $arrSearchData['name'];500 }501 return $arrSearch;502 }503 485 } 504 486 ?>
Note: See TracChangeset
for help on using the changeset viewer.