Changeset 20597
- Timestamp:
- 2011/03/11 10:38:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
r20595 r20597 71 71 parent::init(); 72 72 73 $masterData = new SC_DB_MasterData_Ex();74 $this->arrSTATUS = $masterData->getMasterData("mtb_status");75 $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image");76 $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date");77 $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max");73 $masterData = new SC_DB_MasterData_Ex(); 74 $this->arrSTATUS = $masterData->getMasterData("mtb_status"); 75 $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); 76 $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); 77 $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max"); 78 78 } 79 79 … … 95 95 */ 96 96 function action() { 97 $objQuery =& SC_Query_Ex::getSingletonInstance();97 $objQuery =& SC_Query_Ex::getSingletonInstance(); 98 98 $objProduct = new SC_Product_Ex(); 99 99 … … 104 104 //表示条件の取得 105 105 $this->arrSearchData = array( 106 'category_id' => $this->lfGetCategoryId(intval($this->arrForm['category_id'])),107 'maker_id' =>intval($this->arrForm['maker_id']),108 'name' =>$this->arrForm['name']106 'category_id' => $this->lfGetCategoryId(intval($this->arrForm['category_id'])), 107 'maker_id' => intval($this->arrForm['maker_id']), 108 'name' => $this->arrForm['name'] 109 109 ); 110 110 $this->orderby = $this->arrForm['orderby']; 111 111 112 112 //ページング設定 113 $this->tpl_pageno = $this->arrForm['pageno'];114 $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']);113 $this->tpl_pageno = $this->arrForm['pageno']; 114 $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); 115 115 116 116 // 画面に表示するサブタイトルの設定 117 $this->tpl_subtitle = $this->lfGetPageTitle($this->mode, $this->arrSearchData['category_id']);117 $this->tpl_subtitle = $this->lfGetPageTitle($this->mode, $this->arrSearchData['category_id']); 118 118 119 119 // 画面に表示する検索条件を設定 120 $this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData);120 $this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData); 121 121 122 122 // 商品一覧データの取得 123 123 $arrSearchCondition = $this->lfGetSearchCondition($this->arrSearchData); 124 $this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition);125 $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#";126 $this->objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $this->tpl_linemax, $this->disp_number, 'fnNaviPage', NAVI_PMAX, $urlParam, SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE);127 $this->arrProducts = $this->lfGetProductsList($arrSearchCondition, $this->disp_number, $this->objNavi->start_row, $this->tpl_linemax, $objProduct);124 $this->tpl_linemax = $this->lfGetProductAllNum($arrSearchCondition); 125 $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#"; 126 $this->objNavi = new SC_PageNavi_Ex($this->tpl_pageno, $this->tpl_linemax, $this->disp_number, 'fnNaviPage', NAVI_PMAX, $urlParam, SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE); 127 $this->arrProducts = $this->lfGetProductsList($arrSearchCondition, $this->disp_number, $this->objNavi->start_row, $this->tpl_linemax, $objProduct); 128 128 //商品一覧の表示処理 129 $strnavi = $this->objNavi->strnavi;129 $strnavi = $this->objNavi->strnavi; 130 130 // 表示文字列 131 $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi;131 $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; 132 132 133 133 // 規格1クラス名 134 $this->tpl_class_name1 = $objProduct->className1;134 $this->tpl_class_name1 = $objProduct->className1; 135 135 136 136 // 規格2クラス名 137 $this->tpl_class_name2 = $objProduct->className2;137 $this->tpl_class_name2 = $objProduct->className2; 138 138 139 139 // 規格1 140 $this->arrClassCat1 = $objProduct->classCats1;140 $this->arrClassCat1 = $objProduct->classCats1; 141 141 142 142 // 規格1が設定されている … … 145 145 $this->tpl_classcat_find2 = $objProduct->classCat2_find; 146 146 147 $this->tpl_stock_find = $objProduct->stock_find;147 $this->tpl_stock_find = $objProduct->stock_find; 148 148 $this->tpl_product_class_id = $objProduct->product_class_id; 149 $this->tpl_product_type = $objProduct->product_type;149 $this->tpl_product_type = $objProduct->product_type; 150 150 151 151 // 商品ステータスを取得 … … 162 162 if ( $target_product_id > 0) { 163 163 // 商品IDの正当性チェック 164 if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) || !SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) { 164 if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) 165 || !SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) { 165 166 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 166 167 } 167 168 168 169 // 入力内容のチェック 169 $arrErr = $this->lfCheckError($target_product_id, $this->arrForm,$this->tpl_classcat_find1,$this->tpl_classcat_find2);170 if ( count($arrErr) == 0) {170 $arrErr = $this->lfCheckError($target_product_id, $this->arrForm, $this->tpl_classcat_find1, $this->tpl_classcat_find2); 171 if (empty($arrErr)) { 171 172 $this->lfAddCart($this->arrForm, $_SERVER['HTTP_REFERER']); 172 173 SC_Response_Ex::sendRedirect(CART_URLPATH); 173 174 exit; 174 175 } 175 $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts,$this->arrForm,$arrErr,$target_product_id); 176 } 177 178 // ページャ用データ設定(モバイル) 179 if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { 180 $this->tpl_previous_page = $this->objNavi->arrPagenavi['before']; 181 $this->tpl_next_page = $this->objNavi->arrPagenavi['next']; 182 } 183 184 $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; 185 $this->tpl_onload .= 'fnOnLoad(); '; 186 187 $this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3); 176 $js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id); 177 } 178 179 $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; 180 $this->tpl_onload .= 'fnOnLoad(); '; 181 182 $this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3); 188 183 } 189 184 … … 203 198 */ 204 199 function lfGetCategoryId($category_id) { 200 205 201 // 指定なしの場合、0 を返す 206 if ( 207 strlen($category_id) == 0 208 || (String) $category_id == '0' 209 ) { 210 return 0; 211 } 202 if (empty($category_id)) return 0; 212 203 213 204 // 正当性チェック 214 if ( 215 !SC_Utils_Ex::sfIsInt($category_id) 216 || SC_Utils_Ex::sfIsZeroFilling($category_id) 205 if (!SC_Utils_Ex::sfIsInt($category_id) 206 || SC_Utils_Ex::sfIsZeroFilling($category_id) 217 207 || !SC_Helper_DB_Ex::sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0') 218 ) {208 ) { 219 209 SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); 220 }210 } 221 211 222 212 // 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。 … … 231 221 232 222 /* 商品一覧の表示 */ 233 function lfGetProductsList($searchCondition, $disp_number,$startno,$linemax,&$objProduct) {223 function lfGetProductsList($searchCondition, $disp_number, $startno, $linemax, &$objProduct) { 234 224 235 225 $arrval_order = array(); … … 251 241 if (strlen($searchCondition["where_category"]) >= 1) { 252 242 $dtb_product_categories = "(SELECT * FROM dtb_product_categories WHERE ".$searchCondition["where_category"].")"; 253 $arrval_order = array_merge($searchCondition['arrvalCategory'], $searchCondition['arrvalCategory']);243 $arrval_order = array_merge($searchCondition['arrvalCategory'], $searchCondition['arrvalCategory']); 254 244 } else { 255 245 $dtb_product_categories = 'dtb_product_categories'; … … 316 306 // 規格を設定 317 307 $objProduct->setProductsClassByProductIds($arrProduct_id); 318 $arrProducts += array('productStatus' =>$objProduct->getProductStatus($arrProduct_id));308 $arrProducts += array('productStatus' => $objProduct->getProductStatus($arrProduct_id)); 319 309 return $arrProducts; 320 310 } 321 311 322 312 /* 入力内容のチェック */ 323 function lfCheckError($product_id, &$arrForm,$tpl_classcat_find1,$tpl_classcat_find2) {313 function lfCheckError($product_id, &$arrForm, $tpl_classcat_find1, $tpl_classcat_find2) { 324 314 325 315 // 入力データを渡す。 … … 347 337 function lfGetDisplayNum($display_number) { 348 338 // 表示件数 349 if (!isset($display_number) 350 OR !SC_Utils_Ex::sfIsInt($display_number) 351 ) { 352 //最小表示件数を選択 353 return current(array_keys($this->arrPRODUCTLISTMAX)); 354 } 355 return $display_number; 339 return (SC_Utils_Ex::sfIsInt($display_number)) 340 ? $display_number 341 : current(array_keys($this->arrPRODUCTLISTMAX)); 356 342 } 357 343 … … 361 347 * @return str 362 348 */ 363 function lfGetPageTitle($mode, $category_id = 0){349 function lfGetPageTitle($mode, $category_id = 0){ 364 350 if ($mode == 'search') { 365 351 return "検索結果"; … … 370 356 return $arrCat['name']; 371 357 } 372 return "";373 358 } 374 359 … … 379 364 */ 380 365 function lfGetSearchConditionDisp($arrSearchData){ 381 $objQuery =& SC_Query_Ex::getSingletonInstance();382 $arrSearch = array('category'=>"指定なし",'maker'=>"指定なし",'name'=>"指定なし");366 $objQuery =& SC_Query_Ex::getSingletonInstance(); 367 $arrSearch = array('category' => '指定なし', 'maker' => '指定なし', 'name' => '指定なし'); 383 368 // カテゴリー検索条件 384 369 if ($arrSearchData['category_id'] > 0) { 385 $arrSearch['category'] = $objQuery->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($arrSearchData['category_id']));370 $arrSearch['category'] = $objQuery->get('category_name', 'dtb_category', 'category_id = ?', array($arrSearchData['category_id'])); 386 371 } 387 372 388 373 // メーカー検索条件 389 374 if (strlen($arrSearchData['maker_id']) > 0) { 390 $arrSearch['maker'] = $objQuery->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", array($arrSearchData['maker_id']));375 $arrSearch['maker'] = $objQuery->get('name', 'dtb_maker', 'maker_id = ?', array($arrSearchData['maker_id'])); 391 376 } 392 377 393 378 // 商品名検索条件 394 379 if (strlen($arrSearchData['name']) > 0) { 395 $arrSearch['name'] = $arrSearchData['name'];380 $arrSearch['name'] = $arrSearchData['name']; 396 381 } 397 382 return $arrSearch; … … 405 390 function lfGetProductAllNum($searchCondition){ 406 391 // 検索結果対象となる商品の数を取得 407 $objQuery =& SC_Query_Ex::getSingletonInstance();392 $objQuery =& SC_Query_Ex::getSingletonInstance(); 408 393 $objQuery->setWhere($searchCondition['where']); 409 394 $objProduct = new SC_Product_Ex(); … … 418 403 function lfGetSearchCondition($arrSearchData){ 419 404 $searchCondition = array( 420 'where' =>"",421 'arrval' =>array(),422 "where_category" =>"",423 'arrvalCategory' =>array()405 'where' => "", 406 'arrval' => array(), 407 "where_category" => "", 408 'arrvalCategory' => array() 424 409 ); 425 410 … … 452 437 foreach ($names as $val) { 453 438 if ( strlen($val) > 0 ) { 454 $searchCondition['where'] .= " AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) ";455 $searchCondition['arrval'][] = "%$val%";456 $searchCondition['arrval'][] = "%$val%";439 $searchCondition['where'] .= " AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) "; 440 $searchCondition['arrval'][] = "%$val%"; 441 $searchCondition['arrval'][] = "%$val%"; 457 442 } 458 443 } … … 460 445 // メーカーらのWHERE文字列取得 461 446 if ($arrSearchData['maker_id']) { 462 $searchCondition['where'] .= " AND alldtl.maker_id = ? ";447 $searchCondition['where'] .= " AND alldtl.maker_id = ? "; 463 448 $searchCondition['arrval'][] = $arrSearchData['maker_id']; 464 449 } … … 471 456 * @return str 472 457 */ 473 function lfSetSelectedData(&$arrProducts, $arrForm,$arrErr,$product_id){458 function lfSetSelectedData(&$arrProducts, $arrForm, $arrErr, $product_id){ 474 459 $js_fnOnLoad = ""; 475 460 foreach (array_keys($arrProducts) as $key) { 476 461 if ($arrProducts[$key]['product_id'] == $product_id) { 477 $arrProducts[$key]['product_class_id'] = $arrForm['product_class_id']; 462 463 $arrProducts[$key]['product_class_id'] = $arrForm['product_class_id']; 478 464 $arrProducts[$key]['classcategory_id1'] = $arrForm['classcategory_id1']; 479 465 $arrProducts[$key]['classcategory_id2'] = $arrForm['classcategory_id2']; 480 $arrProducts[$key]['quantity'] = $arrForm['quantity'];481 $arrProducts[$key]['arrErr'] = $arrErr;466 $arrProducts[$key]['quantity'] = $arrForm['quantity']; 467 $arrProducts[$key]['arrErr'] = $arrErr; 482 468 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProducts[$key]['product_id']}, '{$arrForm['classcategory_id2']}');"; 483 469 }
Note: See TracChangeset
for help on using the changeset viewer.