Changeset 20222
- Timestamp:
- 2011/02/20 02:39:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
r20199 r20222 96 96 function action() { 97 97 $objQuery =& SC_Query::getSingletonInstance(); 98 $objDb = new SC_Helper_DB_Ex();//$this->helperDBにしたい99 98 $objProduct = new SC_Product(); 100 99 101 $this->arrForm = $_ GET;100 $this->arrForm = $_REQUEST; 102 101 //modeの取得 103 102 $this->mode = $this->getMode(); … … 105 104 //表示条件の取得 106 105 $this->arrSearchData = array( 107 'category_id' => $this->lfGetCategoryId( $this->arrForm['category_id']),108 'maker_id'=> $this->arrForm['maker_id'],106 'category_id' => $this->lfGetCategoryId(intval($this->arrForm['category_id'])), 107 'maker_id'=>intval($this->arrForm['maker_id']), 109 108 'name'=>$this->arrForm['name'] 110 109 ); … … 114 113 $this->tpl_pageno = $this->arrForm['pageno']; 115 114 $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); 116 $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#";117 $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $this->disp_number, "fnNaviPage", NAVI_PMAX, $urlParam);118 115 119 116 // 画面に表示するサブタイトルの設定 … … 122 119 // 画面に表示する検索条件を設定 123 120 $this->arrSearch = $this->lfGetSearchConditionDisp($this->arrSearchData); 124 //この辺まではinit()に書いちゃダメなのかな?125 121 126 122 // 商品一覧データの取得 127 $searchCondition = $this->lfGetSearchCondition($arrSearchData); 128 $this->tpl_linemax = $this->lfGetProductAllNum($searchCondition); 129 $this->arrProducts = $this->lfGetProductsList($searchCondition,$this->disp_number,$this->objNavi->start_row,$this->tpl_linemax,&$objProduct); 130 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($this->tpl_pageno, $this->tpl_linemax, $this->disp_number, "fnNaviPage", NAVI_PMAX, $urlParam,SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE); 127 $this->arrProducts = $this->lfGetProductsList($arrSearchCondition,$this->disp_number,$this->objNavi->start_row,$this->tpl_linemax,&$objProduct); 131 128 //商品一覧の表示処理 132 129 $strnavi = $this->objNavi->strnavi; … … 156 153 unset($this->arrProducts["productStatus"]); 157 154 158 $productsClassCategories = $objProduct->classCategories;159 160 155 $objJson = new Services_JSON(); 161 $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($productsClassCategories) . '; '; 162 156 $this->tpl_javascript .= 'var productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . ';\n'; 163 157 164 158 //onloadスクリプトを設定 165 159 foreach ($this->arrProducts as $arrProduct) { 166 160 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n"; 167 } 161 } 168 162 169 163 //カート処理 170 if (intval($this->arrForm['product_id']) > 0) { 164 $target_product_id = intval($this->arrForm['product_id']); 165 if ( $target_product_id > 0) { 171 166 // 商品IDの正当性チェック 172 167 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")) { 173 168 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 174 169 } 175 $product_id = $this->arrForm['product_id']; 170 176 171 // 入力内容のチェック 177 $arrErr = $this->lfCheckError($ product_id);172 $arrErr = $this->lfCheckError($target_product_id,&$this->arrForm,$this->tpl_classcat_find1,$this->tpl_classcat_find2); 178 173 if (count($arrErr) == 0) { 179 $classcategory_id1 = $this->arrForm['classcategory_id1']; 180 $classcategory_id2 = $this->arrForm['classcategory_id2']; 181 // 規格1が設定されていない場合 182 if (!$this->tpl_classcat_find1[$product_id]) { 183 $classcategory_id1 = '0'; 184 } 185 // 規格2が設定されていない場合 186 if (!$this->tpl_classcat_find2[$product_id]) { 187 $classcategory_id2 = '0'; 188 } 189 // 規格IDを取得 190 $objProduct = new SC_Product(); 191 $product_class_id = $this->arrForm['product_class_id']; 192 $product_type = $this->arrForm['product_type']; 193 $objCartSess = new SC_CartSession(); 194 $objCartSess->addProduct($product_class_id, $this->arrForm['quantity'], $product_type); 195 196 // カート「戻るボタン」用に保持 197 if (SC_Utils_Ex::sfIsInternalDomain($_SERVER['HTTP_REFERER'])) { 198 $_SESSION['cart_referer_url'] = $_SERVER['HTTP_REFERER']; 199 } 200 201 SC_Response_Ex::sendRedirect(CART_URLPATH); 174 $this->lfAddCart($this->arrForm,$this->tpl_classcat_find1,$this->tpl_classcat_find2,$target_product_id); 202 175 exit; 203 176 } 204 foreach (array_keys($this->arrProducts) as $key) { 205 $arrProduct =& $this->arrProducts[$key]; 206 if ($arrProduct['product_id'] == $product_id) { 207 $arrProduct['product_class_id'] = $this->arrForm['product_class_id']; 208 $arrProduct['classcategory_id1'] = $this->arrForm['classcategory_id1']; 209 $arrProduct['classcategory_id2'] = $this->arrForm['classcategory_id2']; 210 $arrProduct['quantity'] = $this->arrForm['quantity']; 211 $arrProduct['arrErr'] = $arrErr; 212 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']}, '{$this->arrForm['classcategory_id2']}');\n"; 213 } 214 } 177 $js_fnOnLoad .= $this->lfSetSelectedData(&$this->arrProducts,$this->arrForm,$arrErr,$target_product_id); 215 178 } 216 179 217 180 // ページャ用データ設定(モバイル) 218 181 if (Net_UserAgent_Mobile::isMobile() === true) { 219 $this->lfSetPagerMobile(); 220 } 221 222 $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; 182 $this->tpl_previous_page = $this->objNavi->arrPagenavi['before']; 183 $this->tpl_next_page = $this->objNavi->arrPagenavi['next']; 184 } 185 186 $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'."\n"; 223 187 $this->tpl_onload .= 'fnOnLoad(); '; 224 188 … … 318 282 ,product_id 319 283 __EOS__; 320 $objQuery->setOrder($order);284 //$objQuery->setOrder($order); 321 285 break; 322 286 } … … 328 292 $arrProduct_id = $objProduct->findProductIdsOrder($objQuery, array_merge($searchCondition["arrval"], $arrval_order)); 329 293 330 // 取得した表示すべきIDだけを指定して情報を取得。 < 謎の処理294 // 取得した表示すべきIDだけを指定して情報を取得。 331 295 $where = ""; 332 296 if (is_array($arrProduct_id) && !empty($arrProduct_id)) { … … 357 321 358 322 /* 入力内容のチェック */ 359 function lfCheckError($ id) {323 function lfCheckError($product_id,&$arrForm,$tpl_classcat_find1,$tpl_classcat_find2) { 360 324 361 325 // 入力データを渡す。 362 $objErr = new SC_CheckError($ this->arrForm);326 $objErr = new SC_CheckError($arrForm); 363 327 364 328 // 複数項目チェック 365 if ($t his->tpl_classcat_find1[$id]) {329 if ($tpl_classcat_find1[$product_id]) { 366 330 $objErr->doFunc(array("規格1", 'classcategory_id1', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 367 331 } 368 if ($t his->tpl_classcat_find2[$id]) {332 if ($tpl_classcat_find2[$product_id]) { 369 333 $objErr->doFunc(array("規格2", 'classcategory_id2', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 370 334 } … … 388 352 } 389 353 return $display_number; 390 }391 392 /**393 * ページャ用データ設定(モバイル)394 *395 * @return void396 */397 function lfSetPagerMobile() {398 // ページ送り機能用のURLを作成する。399 $objURL = new Net_URL($_SERVER['PHP_SELF']);400 foreach ($_REQUEST as $key => $value) {401 if ($key == session_name() || $key == 'pageno') {402 continue;403 }404 $objURL->addQueryString($key, mb_convert_encoding($value, 'SJIS', CHAR_CODE));405 }406 407 if ($this->objNavi->now_page > 1) {408 $objURL->addQueryString('pageno', $this->objNavi->now_page - 1);409 $this->tpl_previous_page = $objURL->path . '?' . $objURL->getQueryString();410 }411 if ($this->objNavi->now_page < $this->objNavi->max_page) {412 $objURL->addQueryString('pageno', $this->objNavi->now_page + 1);413 $this->tpl_next_page = $objURL->path . '?' . $objURL->getQueryString();414 }415 354 } 416 355 … … 524 463 return $searchCondition; 525 464 } 465 466 /** 467 * カートに入れる商品情報にエラーがあったら戻す 468 * 469 * @return str 470 */ 471 function lfSetSelectedData(&$arrProducts,$arrForm,$arrErr,$product_id){ 472 $js_fnOnLoad = ""; 473 foreach (array_keys($arrProducts) as $key) { 474 if ($arrProducts[$key]['product_id'] == $product_id) { 475 $arrProducts[$key]['product_class_id'] = $arrForm['product_class_id']; 476 $arrProducts[$key]['classcategory_id1'] = $arrForm['classcategory_id1']; 477 $arrProducts[$key]['classcategory_id2'] = $arrForm['classcategory_id2']; 478 $arrProducts[$key]['quantity'] = $arrForm['quantity']; 479 $arrProducts[$key]['arrErr'] = $arrErr; 480 $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProducts[$key]['product_id']}, '{$arrForm['classcategory_id2']}');\n"; 481 } 482 } 483 return $js_fnOnLoad; 484 } 485 486 /** 487 * カートに商品を追加 488 * 489 * @return void 490 */ 491 function lfAddCart($arrForm,$tpl_classcat_find1,$tpl_classcat_find2,$target_product_id){ 492 $classcategory_id1 = $arrForm['classcategory_id1']; 493 $classcategory_id2 = $arrForm['classcategory_id2']; 494 // 規格1が設定されていない場合 495 if (!$tpl_classcat_find1[$target_product_id]) { 496 $classcategory_id1 = '0'; 497 } 498 // 規格2が設定されていない場合 499 if (!$tpl_classcat_find2[$target_product_id]) { 500 $classcategory_id2 = '0'; 501 } 502 503 // 規格IDを取得 504 $product_class_id = $arrForm['product_class_id']; 505 $product_type = $arrForm['product_type']; 506 $objCartSess = new SC_CartSession(); 507 $objCartSess->addProduct($product_class_id, $arrForm['quantity'], $product_type); 508 509 // カート「戻るボタン」用に保持 510 if (SC_Utils_Ex::sfIsInternalDomain($_SERVER['HTTP_REFERER'])) { 511 $_SESSION['cart_referer_url'] = $_SERVER['HTTP_REFERER']; 512 } 513 514 SC_Response_Ex::sendRedirect(CART_URLPATH); 515 } 526 516 } 527 517 ?>
Note: See TracChangeset
for help on using the changeset viewer.