Changeset 15344 for branches/feature-module-update/data/class/pages/products/LC_Page_Products_List.php
- Timestamp:
- 2007/08/24 13:08:14 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/data/class/pages/products/LC_Page_Products_List.php
r15154 r15344 20 20 // {{{ properties 21 21 22 // TODO 23 var $arrSTATUS = array(); 24 var $arrSTATUS_IMAGE = array(); 25 var $arrDELIVERYDATE = array(); 26 var $arrPRODUCTLISTMAX = array(); 22 /** テンプレートクラス名1 */ 23 var $tpl_class_name1; 24 25 /** テンプレートクラス名2 */ 26 var $tpl_class_name2; 27 28 /** JavaScript テンプレート */ 29 var $tpl_javascript; 27 30 28 31 // }}} … … 36 39 function init() { 37 40 parent::init(); 38 session_cache_limiter('private-no-expire'); 39 $this->arrPRODUCTLISTMAX = array(15 => '15件', 40 30 => '30件', 41 50 => '50件'); 41 42 $masterData = new SC_DB_MasterData_Ex(); 43 $this->arrSTATUS = $masterData->getMasterData("mtb_status"); 44 $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); 45 $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); 46 $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max"); 47 48 $this->tpl_class_name1 = array(); 49 $this->tpl_class_name2 = array(); 50 $this->allowClientCache(); 42 51 } 43 52 … … 51 60 52 61 //表示件数の選択 53 if(SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { 62 if(isset($_POST['disp_number']) 63 && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { 54 64 $this->disp_number = $_POST['disp_number']; 55 65 } else { … … 59 69 60 70 //表示順序の保存 61 $this->orderby = $_POST['orderby'];71 $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : ""; 62 72 63 73 // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 64 74 $category_id = SC_Utils_Ex::sfGetCategoryId("", $_GET['category_id']); 65 75 76 if (!isset($_GET['mode'])) $_GET['mode'] = ""; 77 if (!isset($_GET['name'])) $_GET['name'] = ""; 78 if (!isset($_POST['orderby'])) $_POST['orderby'] = ""; 79 66 80 // タイトル編集 67 81 $tpl_subtitle = ""; 68 if ($_GET['mode'] == 'search'){82 if ($_GET['mode'] == 'search') { 69 83 $tpl_subtitle = "検索結果"; 70 } elseif ($category_id == "" ) {84 } elseif ($category_id == "" ) { 71 85 $tpl_subtitle = "全商品"; 72 } else{86 } else { 73 87 $arrFirstCat = SC_Utils_Ex::sfGetFirstCat($category_id); 74 88 $tpl_subtitle = $arrFirstCat['name']; … … 82 96 // ・カテゴリIDがルートIDである。 83 97 // ・検索モードでない。 84 if(($count >= BEST_MIN) && lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) {98 if(($count >= BEST_MIN) && $this->lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) { 85 99 // 商品TOPの表示処理 86 100 /** 必ず指定する **/ 87 101 $this->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl"; // メインテンプレート 88 102 89 $this->arrBestItems = sfGetBestProducts($conn, $category_id);103 $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $category_id); 90 104 $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 91 105 } else { … … 119 133 $this = $layout->sfGetPageLayout($this, false, "products/list.php"); 120 134 121 if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { 135 if(isset($_POST['mode']) && $_POST['mode'] == "cart" 136 && $_POST['product_id'] != "") { 137 122 138 // 値の正当性チェック 123 if(! sfIsInt($_POST['product_id']) || !sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) {124 sfDispSiteError(PRODUCT_NOT_FOUND);139 if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 140 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 125 141 } else { 126 142 // 入力値の変換 127 $this->arrErr = lfCheckError($_POST['product_id']);143 $this->arrErr = $this->lfCheckError($_POST['product_id']); 128 144 if(count($this->arrErr) == 0) { 129 145 $objCartSess = new SC_CartSession(); … … 185 201 /* 商品一覧の表示 */ 186 202 function lfDispProductsList($category_id, $name, $disp_num, $orderby) { 187 global $objPage; 203 188 204 $objQuery = new SC_Query(); 189 $objPage->tpl_pageno = $_POST['pageno']; 205 $objDb = new SC_Helper_DB_Ex(); 206 $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : ""; 190 207 191 208 //表示件数でテンプレートを切り替える 192 $ objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl"; // メインテンプレート209 $this->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl"; // メインテンプレート 193 210 194 211 //表示順序 … … 221 238 if ( strlen($name) > 0 ){ 222 239 $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 223 $ret = sfManualEscape($name);240 $ret = SC_Utils_Ex::sfManualEscape($name); 224 241 $arrval[] = "%$ret%"; 225 242 $arrval[] = "%$ret%"; … … 228 245 // 行数の取得 229 246 $linemax = $objQuery->count("vw_products_allclass AS allcls", $where, $arrval); 230 $ objPage->tpl_linemax = $linemax; // 何件が該当しました。表示用247 $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 231 248 232 249 // ページ送りの取得 233 $objNavi = new SC_PageNavi($ _POST['pageno'], $linemax, $disp_num, "fnNaviPage", NAVI_PMAX);250 $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 234 251 235 252 $strnavi = $objNavi->strnavi; 236 253 $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 237 $ objPage->tpl_strnavi = $strnavi; // 表示文字列254 $this->tpl_strnavi = $strnavi; // 表示文字列 238 255 $startno = $objNavi->start_row; // 開始行 239 256 … … 243 260 $objQuery->setorder($order); 244 261 245 246 247 248 249 250 251 252 262 // 検索結果の取得 253 $ objPage->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval);263 $this->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval); 254 264 255 265 // 規格名一覧 256 $arrClassName = SC_Utils_Ex::sfGetIDValueList("dtb_class", "class_id", "name");266 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); 257 267 // 規格分類名一覧 258 $arrClassCatName = SC_Utils_Ex::sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");268 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 259 269 // 企画セレクトボックス設定 260 270 if($disp_num == 15) { 261 for($i = 0; $i < count($ objPage->arrProducts); $i++) {262 $ objPage = $this->lfMakeSelect($objPage->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName);271 for($i = 0; $i < count($this->arrProducts); $i++) { 272 $this = $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); 263 273 // 購入制限数を取得 264 $ objPage = $this->lfGetSaleLimit($objPage->arrProducts[$i]);265 } 266 } 267 268 return $ objPage;274 $this = $this->lfGetSaleLimit($this->arrProducts[$i]); 275 } 276 } 277 278 return $this; 269 279 } 270 280 271 281 /* 規格セレクトボックスの作成 */ 272 282 function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) { 273 global $objPage;274 283 275 284 $classcat_find1 = false; … … 282 291 283 292 // 規格1クラス名の取得 284 $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']]; 293 $this->tpl_class_name1[$product_id] = 294 isset($arrClassName[$arrProductsClass[0]['class_id1']]) 295 ? $arrClassName[$arrProductsClass[0]['class_id1']] 296 : ""; 297 285 298 // 規格2クラス名の取得 286 $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']]; 299 $this->tpl_class_name2[$product_id] = 300 isset($arrClassName[$arrProductsClass[0]['class_id2']]) 301 ? $arrClassName[$arrProductsClass[0]['class_id2']] 302 : ""; 287 303 288 304 // すべての組み合わせ数 … … 313 329 $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; 314 330 $list_id++; 331 332 $arrList[$list_id] = ""; 333 $arrVal[$list_id] = ""; 315 334 } 316 335 … … 337 356 338 357 // 規格1 339 $ objPage->arrClassCat1[$product_id] = $arrSele;358 $this->arrClassCat1[$product_id] = $arrSele; 340 359 341 360 $lists = "\tlists".$product_id. " = new Array("; 342 361 $no = 0; 343 362 foreach($arrList as $val) { 344 $ objPage->tpl_javascript.= $val;363 $this->tpl_javascript.= $val; 345 364 if ($no != 0) { 346 365 $lists.= ",list". $product_id. "_". $no; … … 350 369 $no++; 351 370 } 352 $ objPage->tpl_javascript.= $lists.");\n";371 $this->tpl_javascript.= $lists.");\n"; 353 372 354 373 $vals = "\tvals".$product_id. " = new Array("; 355 374 $no = 0; 356 375 foreach($arrVal as $val) { 357 $ objPage->tpl_javascript.= $val;376 $this->tpl_javascript.= $val; 358 377 if ($no != 0) { 359 378 $vals.= ",val". $product_id. "_". $no; … … 363 382 $no++; 364 383 } 365 $ objPage->tpl_javascript.= $vals.");\n";384 $this->tpl_javascript.= $vals.");\n"; 366 385 367 386 // 選択されている規格2ID 368 387 $classcategory_id = "classcategory_id". $product_id; 369 $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); "; 388 389 $classcategory_id_2 = $classcategory_id . "_2"; 390 if (!isset($$classcategory_id_2)) $$classcategory_id_2 = ""; 391 if (!isset($_POST[$$classcategory_id_2])) $_POST[$$classcategory_id_2] = ""; 392 393 $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', " 394 . "'" . $$classcategory_id_2 . "'," 395 . "'" . $product_id . "'," 396 . "'" . $_POST[$$classcategory_id_2] ."'); "; 370 397 371 398 // 規格1が設定されている … … 379 406 } 380 407 381 $ objPage->tpl_classcat_find1[$product_id] = $classcat_find1;382 $ objPage->tpl_classcat_find2[$product_id] = $classcat_find2;383 $ objPage->tpl_stock_find[$product_id] = $stock_find;384 385 return $ objPage;408 $this->tpl_classcat_find1[$product_id] = $classcat_find1; 409 $this->tpl_classcat_find2[$product_id] = $classcat_find2; 410 $this->tpl_stock_find[$product_id] = $stock_find; 411 412 return $this; 386 413 } 387 414 /* 商品規格情報の取得 */ … … 402 429 /* 入力内容のチェック */ 403 430 function lfCheckError($id) { 404 global $objPage;405 431 406 432 // 入力データを渡す。 … … 411 437 $quantity = "quantity". $id; 412 438 // 複数項目チェック 413 if ($ objPage->tpl_classcat_find1[$id]) {439 if ($this->tpl_classcat_find1[$id]) { 414 440 $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 415 441 } 416 if ($ objPage->tpl_classcat_find2[$id]) {442 if ($this->tpl_classcat_find2[$id]) { 417 443 $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 418 444 } … … 424 450 // 購入制限数の設定 425 451 function lfGetSaleLimit($product) { 426 global $objPage;427 452 //在庫が無限または購入制限値が設定値より大きい場合 428 453 if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) { 429 $ objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX;454 $this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX; 430 455 } else { 431 $ objPage->tpl_sale_limit[$product['product_id']] = $product['sale_limit'];432 } 433 434 return $ objPage;456 $this->tpl_sale_limit[$product['product_id']] = $product['sale_limit']; 457 } 458 459 return $this; 435 460 } 436 461 … … 449 474 450 475 function lfconvertParam () { 451 global $objPage; 452 453 foreach ($objPage->arrForm as $key => $value) { 476 foreach ($this->arrForm as $key => $value) { 454 477 if (preg_match('/^quantity[0-9]+/', $key)) { 455 $ objPage->arrForm[$key]456 = htmlspecialchars($ objPage->arrForm[$key], ENT_QUOTES, CHAR_CODE);478 $this->arrForm[$key] 479 = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE); 457 480 } 458 481 }
Note: See TracChangeset
for help on using the changeset viewer.