- Timestamp:
- 2011/02/18 20:39:02 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
r20195 r20197 95 95 */ 96 96 function action() { 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'])); 97 $objQuery = new SC_Query();//$this->queryにしたい 98 $objDb = new SC_Helper_DB_Ex();//$this->helperDBにしたい 99 100 $this->arrForm = $_GET; 101 //modeの取得 102 $this->mode = $this->getMode(); 103 104 //表示条件の取得 105 $this->arrSearchData = array( 106 'category_id' => $this->lfGetCategoryId($this->arrForm['category_id'],&$objDb), 107 'maker_id'=>$this->arrForm['maker_id'], 108 'name'=>$this->arrForm['name'] 109 ); 110 $this->orderby = $this->arrForm['orderby']; 111 112 //ページング設定 113 $this->tpl_pageno = $this->arrForm['pageno']; 114 $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); 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 ここまでやった 112 123 113 124 // 商品一覧の表示処理 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 125 $this->arrProducts = $this->lfGetProductsList($objDb); 126 127 //onloadスクリプトを設定 139 128 foreach ($this->arrProducts as $arrProduct) { 140 129 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n"; 141 } 142 143 if ($this->inCart) { 130 } 131 132 //カート処理 133 if (intval($this->arrForm['product_id']) > 0) { 144 134 // 商品IDの正当性チェック 145 135 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")) { … … 213 203 * @return integer カテゴリID 214 204 */ 215 function lfGetCategoryId($category_id) { 216 $objDb = new SC_Helper_DB_Ex(); 217 205 function lfGetCategoryId($category_id,&$objDb) { 218 206 // 指定なしの場合、0 を返す 219 207 if ( … … 244 232 245 233 /* 商品一覧の表示 */ 246 function lfDispProductsList() { 247 $objDb = new SC_Helper_DB_Ex(); 234 function lfGetProductsList($objDb) { 248 235 $arrval = array(); 249 236 $arrval_order = array(); … … 379 366 $arrProducts2[ $item['product_id'] ] = $item; 380 367 } 381 $ this->arrProducts = array();368 $arrProducts = array(); 382 369 foreach($arrProduct_id as $product_id) { 383 $ this->arrProducts[] = $arrProducts2[$product_id];370 $arrProducts[] = $arrProducts2[$product_id]; 384 371 } 385 372 … … 412 399 $objJson = new Services_JSON(); 413 400 $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($productsClassCategories) . '; '; 401 return $arrProducts; 414 402 } 415 403 … … 437 425 * @return void 438 426 */ 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']; 427 function lfGetDisplayNum($display_number) { 447 428 // 表示件数 448 if ( 449 isset($this->arrForm['disp_number']) 450 && SC_Utils_Ex::sfIsInt($this->arrForm['disp_number']) 429 if (!isset($display_number) 430 OR !SC_Utils_Ex::sfIsInt($display_number) 451 431 ) { 452 $this->disp_number = $this->arrForm['disp_number'];453 } else {454 432 //最小表示件数を選択 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; 433 return current(array_keys($this->arrPRODUCTLISTMAX)); 434 } 435 return $display_number; 459 436 } 460 437 … … 483 460 } 484 461 } 462 463 /** 464 * ページタイトルの設定 465 * 466 * @return str 467 */ 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 array 484 */ 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 } 485 503 } 486 504 ?>
Note: See TracChangeset
for help on using the changeset viewer.