Changeset 20234
- Timestamp:
- 2011/02/20 06:09:06 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php
r20116 r20234 54 54 /** アップロードファイル */ 55 55 var $objUpFile; 56 57 /** モード */ 58 var $mode; 56 59 57 60 // }}} … … 89 92 */ 90 93 function action() { 91 // プロダクトIDの正当性チェック92 $product_id = $this->lfCheckProductId();93 $mode = $this->getMode();94 // XXX 削除可能か、SC_SiteViewクラスコンストラクタ内の処理を要確認95 $objView = new SC_SiteView(strlen($mode) == 0);96 97 $objCustomer = new SC_Customer();98 $objDb = new SC_Helper_DB_Ex();99 100 // ログイン中のユーザが商品をお気に入りにいれる処理101 if ($objCustomer->isLoginSuccess() === true && strlen($mode) > 0 && $mode == "add_favorite" && strlen($_POST['favorite_product_id']) > 0 ) {102 // 値の正当性チェック103 if(!SC_Utils_Ex::sfIsInt($_POST['favorite_product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['favorite_product_id'], "del_flg = 0 AND status = 1")) {104 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);105 exit;106 } else {107 $this->arrErr = $this->lfCheckError();108 if(count($this->arrErr) == 0) {109 $customer_id = $objCustomer->getValue('customer_id');110 $this->lfRegistFavoriteProduct($customer_id, $_POST['favorite_product_id']);111 }112 }113 }114 115 94 // パラメータ管理クラス 116 95 $this->objFormParam = new SC_FormParam(); 117 96 // パラメータ情報の初期化 118 $this->lfInitParam(); 119 // POST値の取得 120 $this->objFormParam->setParam($_POST); 121 97 $this->arrForm = $this->lfInitParam(&$this->objFormParam); 122 98 // ファイル管理クラス 123 99 $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); 124 100 // ファイル情報の初期化 125 $this->lfInitFile(); 101 $this->objUpFile = $this->lfInitFile($this->objUpFile); 102 103 // プロダクトIDの正当性チェック 104 $product_id = $this->lfCheckProductId($this->objFormParam->getValue('admin'),$this->objFormParam->getValue('product_id')); 105 $this->mode = $this->getMode(); 106 107 $objCustomer = new SC_Customer(); 126 108 127 109 // ログイン判定 … … 132 114 133 115 // 規格選択セレクトボックスの作成 134 $this-> lfMakeSelect($product_id);116 $this->js_lnOnload .= $this->lfMakeSelect(); 135 117 136 118 $objProduct = new SC_Product(); … … 161 143 162 144 // モバイル用 規格選択セレクトボックスの作成 163 if( Net_UserAgent_Mobile::isMobile() === true) {164 $this->lfMakeSelectMobile($this, $product_id );145 if(SC_Display::detectDevice() == DEVICE_TYPE_MOBILE) { 146 $this->lfMakeSelectMobile($this, $product_id,$this->objFormParam->getValue('classcategory_id1')); 165 147 } 166 148 … … 168 150 $this->tpl_product_id = $product_id; 169 151 170 switch($ mode) {152 switch($this->mode) { 171 153 case 'cart': 172 // 入力値の変換 173 $this->objFormParam->convParam(); 174 $this->arrErr = $this->lfCheckError(); 154 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); 175 155 if (count($this->arrErr) == 0) { 176 156 $objCartSess = new SC_CartSession(); 177 $classcategory_id1 = $_POST['classcategory_id1']; 178 $classcategory_id2 = $_POST['classcategory_id2']; 179 $product_class_id = $_POST['product_class_id']; 180 $product_type = $_POST['product_type']; 181 182 if (!empty($_POST['gmo_oneclick'])) { 183 $objCartSess->delAllProducts(); 184 } 157 $classcategory_id1 = $this->objFormParam->getValue('classcategory_id1'); 158 $classcategory_id2 = $this->objFormParam->getValue('classcategory_id2'); 159 $product_class_id = $this->objFormParam->getValue('product_class_id'); 160 $product_type = $this->objFormParam->getValue('product_type'); 185 161 186 162 // 規格1が設定されていない場合 … … 198 174 if (SC_Utils_Ex::sfIsInternalDomain($_SERVER['HTTP_REFERER'])) { 199 175 $_SESSION['cart_referer_url'] = $_SERVER['HTTP_REFERER']; 200 }201 202 if (!empty($_POST['gmo_oneclick'])) {203 $objSiteSess = new SC_SiteSession;204 $objSiteSess->setRegistFlag();205 $objCartSess->saveCurrentCart($objSiteSess->getUniqId());206 207 SC_Response_Ex::sendRedirect(ROOT_URLPATH . USER_DIR . 'gmopg_oneclick_confirm.php', array(), false, true);208 exit;209 176 } 210 177 … … 213 180 } 214 181 break; 182 case "add_favorite": 183 // ログイン中のユーザが商品をお気に入りにいれる処理 184 if ($objCustomer->isLoginSuccess() === true && $this->objFormParam->getValue('favorite_product_id') > 0 ) { 185 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam); 186 if(count($this->arrErr) == 0){ 187 if(!$this->lfRegistFavoriteProduct($this->objFormParam->getValue('favorite_product_id'),$objCustomer->getValue('customer_id'))){ 188 exit; 189 } 190 } 191 } 215 192 216 193 default: … … 219 196 220 197 // モバイル用 ポストバック処理 221 if( Net_UserAgent_Mobile::isMobile() === true) {222 switch($ mode) {198 if(SC_Display::detectDevice() == DEVICE_TYPE_MOBILE) { 199 switch($this->mode) { 223 200 case 'select': 224 201 // 規格1が設定されている場合 … … 230 207 231 208 case 'select2': 232 $this->arrErr = $this->lfCheckError( );209 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); 233 210 234 211 // 規格1が設定されている場合 … … 248 225 249 226 case 'selectItem': 250 $this->arrErr = $this->lfCheckError( );227 $this->arrErr = $this->lfCheckError($this->mode,$this->objFormParam,$this->tpl_classcat_find1,$this->tpl_classcat_find2); 251 228 252 229 // 規格1が設定されている場合 … … 257 234 } 258 235 259 $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$ _POST['classcategory_id1']][$_POST['classcategory_id2']]['product_class_id'];236 $this->tpl_product_class_id = $objProduct->classCategories[$product_id][$this->objFormParam->getValue('classcategory_id1')][$this->objFormParam->getValue('classcategory_id2')]['product_class_id']; 260 237 261 238 // 商品数の選択を行う … … 276 253 277 254 // 関連カテゴリを取得 278 $this->arrRelativeCat = $objDb->sfGetMultiCatTree($product_id);255 $this->arrRelativeCat = SC_Helper_DB_Ex::sfGetMultiCatTree($product_id); 279 256 280 257 // 商品ステータスを取得 … … 285 262 = SC_Utils_Ex::sfNoImageMain($this->arrProduct['main_image']); 286 263 287 $this-> lfSetFile();264 $this->subImageFlag = $this->lfSetFile($this->objUpFile,$this->arrProduct,$this->arrFile); 288 265 // 支払方法の取得 289 266 $this->arrPayment = $this->lfGetPayment(); 290 // 入力情報を渡す291 $this->arrForm = $this->objFormParam->getFormParamList();292 267 //レビュー情報の取得 293 268 $this->arrReview = $this->lfGetReviewData($product_id); … … 304 279 //関連商品情報表示 305 280 $this->arrRecommend = $this->lfPreGetRecommendProducts($product_id); 306 307 $this->lfConvertParam();308 281 } 309 282 … … 318 291 319 292 /* プロダクトIDの正当性チェック */ 320 function lfCheckProductId( ) {293 function lfCheckProductId($admin_mode,$product_id) { 321 294 // 管理機能からの確認の場合は、非公開の商品も表示する。 322 if (isset($ _GET['admin']) && $_GET['admin']== 'on') {295 if (isset($admin_mode) && $admin_mode == 'on') { 323 296 SC_Utils_Ex::sfIsSuccess(new SC_Session()); 324 297 $status = true; … … 329 302 } 330 303 331 if (defined('MOBILE_SITE')) {332 if ($_SERVER['REQUEST_METHOD'] == 'POST') {333 $product_id = $_POST['product_id'];334 } else {335 $product_id = $_GET['product_id'];336 }337 } else {338 if ($_SERVER['REQUEST_METHOD'] == 'POST') {339 $product_id = $_POST['product_id'];340 } else {341 $product_id = $_GET['product_id'];342 }343 }344 345 $objDb = new SC_Helper_DB_Ex();346 304 if(!SC_Utils_Ex::sfIsInt($product_id) 347 305 || SC_Utils_Ex::sfIsZeroFilling($product_id) 348 || ! $objDb->sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where))306 || !SC_Helper_DB_Ex::sfIsRecord('dtb_products', 'product_id', (array)$product_id, $where)) 349 307 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 350 308 return $product_id; … … 352 310 353 311 /* ファイル情報の初期化 */ 354 function lfInitFile( ) {355 $ this->objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT);312 function lfInitFile($objUpFile) { 313 $objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); 356 314 for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { 357 $this->objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT); 358 } 315 $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT); 316 } 317 return $objUpFile; 359 318 } 360 319 361 320 /* 規格選択セレクトボックスの作成 */ 362 321 function lfMakeSelect() { 363 364 // 選択されている規格 365 $classcategory_id1 366 = isset($_POST['classcategory_id1']) && is_numeric($_POST['classcategory_id1']) 367 ? $_POST['classcategory_id1'] 368 : ''; 369 370 $classcategory_id2 371 = isset($_POST['classcategory_id2']) && is_numeric($_POST['classcategory_id2']) 372 ? $_POST['classcategory_id2'] 373 : ''; 374 375 $this->js_lnOnload .= 'fnSetClassCategories(' 322 return 'fnSetClassCategories(' 376 323 . 'document.form1, ' 377 . Services_JSON::encode($ classcategory_id2)324 . Services_JSON::encode($this->objFormParam->getValue('classcategory_id2')) 378 325 . '); '; 379 326 } 380 327 381 328 /* 規格選択セレクトボックスの作成(モバイル) */ 382 function lfMakeSelectMobile(&$objPage, $product_id) { 383 384 $objDb = new SC_Helper_DB_Ex(); 329 function lfMakeSelectMobile(&$objPage, $product_id,$request_classcategory_id1) { 330 385 331 $classcat_find1 = false; 386 332 $classcat_find2 = false; … … 389 335 390 336 // 規格名一覧 391 $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name");337 $arrClassName = SC_Helper_DB_Ex::sfGetIDValueList("dtb_class", "class_id", "name"); 392 338 // 規格分類名一覧 393 $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");339 $arrClassCatName = SC_Helper_DB_Ex::sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 394 340 /* 395 341 * FIXME … … 428 374 429 375 // 規格2のセレクトボックス用 430 if($arrProductsClass[$i]['classcategory_id1'] == $ _POST['classcategory_id1']and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) {376 if($arrProductsClass[$i]['classcategory_id1'] == $request_classcategory_id1 and $classcat_id2 != $arrProductsClass[$i]['classcategory_id2']) { 431 377 $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; 432 378 $arrSele2[$classcat_id2] = $arrClassCatName[$classcat_id2]; … … 454 400 455 401 /* パラメータ情報の初期化 */ 456 function lfInitParam() { 457 $this->objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 458 $this->objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 459 $this->objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 402 function lfInitParam(&$objFormParam) { 403 $objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 404 $objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 405 $objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 406 $objFormParam->addParam("管理者ログイン", "admin", INT_LEN, "a", array('ALNUM_CHECK',"MAX_LENGTH_CHECK")); 407 $objFormParam->addParam("商品ID", "product_id", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 408 $objFormParam->addParam("お気に入り商品ID", "favorite_product_id", INT_LEN, "n", array("ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 409 $objFormParam->addParam("商品規格ID", "product_class_id", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 410 $objFormParam->addParam("商品種別", "product_type", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 411 // 値の取得 412 $objFormParam->setParam($_REQUEST); 413 // 入力値の変換 414 $objFormParam->convParam(); 415 // 入力情報を渡す 416 return $objFormParam->getFormParamList(); 460 417 } 461 418 … … 469 426 function lfPreGetRecommendProducts($product_id) { 470 427 $arrRecommend = array(); 471 $objQuery = new SC_Query();428 $objQuery =& SC_Query::getSingletonInstance(); 472 429 $objQuery->setOrder("rank DESC"); 473 $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); 474 $max = count($arrRet); 475 $no = 0; 476 // FIXME SC_Product クラスを使用した実装 477 $from = "vw_products_allclass AS T1 " 478 . " JOIN (" 479 . " SELECT max(T2.rank) AS product_rank, " 480 . " T2.product_id" 481 . " FROM dtb_product_categories T2 " 482 . " GROUP BY product_id) AS T3 USING (product_id)"; 483 $objQuery->setOrder("T3.product_rank DESC"); 484 for($i = 0; $i < $max; $i++) { 485 $where = "del_flg = 0 AND T3.product_id = ? AND status = 1"; 486 $arrProductInfo = $objQuery->select("DISTINCT main_list_image, price02_min, price02_max, price01_min, price01_max, name, T3.product_rank", $from, $where, array($arrRet[$i]['recommend_product_id'])); 487 488 if(count($arrProductInfo) > 0) { 489 $arrRecommend[$no] = $arrProductInfo[0]; 490 $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id']; 491 $arrRecommend[$no]['comment'] = $arrRet[$i]['comment']; 492 $no++; 493 } 494 } 495 return $arrRecommend; 430 $arrRecommendData = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); 431 432 $objProduct = new SC_Product(); 433 434 $where = ""; 435 if (is_array($arrRecommendData["recommend_product_id"]) && !empty($arrRecommendData["recommend_product_id"])) { 436 $where = 'product_id IN (' . implode(',', $arrRecommendData["recommend_product_id"]) . ')'; 437 } else { 438 return $arrRecommend; 439 } 440 $objQuery =& SC_Query::getSingletonInstance(); 441 $objQuery->setWhere($where); 442 $arrProducts = $objProduct->lists($objQuery,$arrRecommendData["recommend_product_id"]); 443 foreach($arrProducts as $key=>$product){ 444 $arrProducts[$key] += array("comment"=>$arrRecommendData[$key]["comment"]); 445 } 446 return $arrProducts; 496 447 } 497 448 498 449 /* 入力内容のチェック */ 499 function lfCheckError( ) {500 501 switch ($ this->getMode()) {450 function lfCheckError($mode,&$objFormParam,$tpl_classcat_find1 = null ,$tpl_classcat_find2 = null) { 451 452 switch ($mode) { 502 453 case 'add_favorite': 503 454 $objCustomer = new SC_Customer(); … … 510 461 default: 511 462 // 入力データを渡す。 512 $arrRet = $ this->objFormParam->getHashArray();463 $arrRet = $objFormParam->getHashArray(); 513 464 $objErr = new SC_CheckError($arrRet); 514 $objErr->arrErr = $ this->objFormParam->checkError();465 $objErr->arrErr = $objFormParam->checkError(); 515 466 516 467 // 複数項目チェック 517 if ($t his->tpl_classcat_find1) {468 if ($tpl_classcat_find1) { 518 469 $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 519 470 } 520 if ($t his->tpl_classcat_find2) {471 if ($tpl_classcat_find2) { 521 472 $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 522 473 } … … 529 480 //閲覧履歴新規登録 530 481 function lfRegistReadingData($product_id, $customer_id){ 531 $objQuery = new SC_Query;482 $objQuery =& SC_Query::getSingletonInstance(); 532 483 $sqlval['customer_id'] = $customer_id; 533 484 $sqlval['reading_product_id'] = $product_id; … … 539 490 //商品ごとのレビュー情報を取得する 540 491 function lfGetReviewData($id) { 541 $objQuery = new SC_Query;492 $objQuery =& SC_Query::getSingletonInstance(); 542 493 //商品ごとのレビュー情報を取得する 543 494 $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment"; … … 559 510 $arrTrackback = array(); 560 511 561 $objQuery = new SC_Query;512 $objQuery =& SC_Query::getSingletonInstance(); 562 513 //商品ごとのトラックバック情報を取得する 563 514 $col = "blog_name, url, title, excerpt, title, create_date"; 564 515 $from = "dtb_trackback"; 565 516 $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX; 566 $arrval[] = $product_id; 567 $arrTrackback = $objQuery->select($col, $from, $where, $arrval); 517 $arrTrackback = $objQuery->select($col, $from, $where, array($product_id)); 568 518 return $arrTrackback; 569 519 } … … 572 522 //payment_id 1:クレジット 2:ショッピングローン 573 523 function lfGetPayment() { 574 $objQuery = new SC_Query;524 $objQuery =& SC_Query::getSingletonInstance(); 575 525 $col = "payment_id, rule, payment_method"; 576 526 $from = "dtb_payment"; … … 578 528 $order = "payment_id"; 579 529 $objQuery->setOrder($order); 580 $arrRet = $objQuery->select($col, $from, $where); 581 return $arrRet; 582 } 583 584 function lfConvertParam() { 585 if (!isset($this->arrForm['quantity']['value'])) $this->arrForm['quantity']['value'] = ""; 586 $value = $this->arrForm['quantity']['value']; 587 $this->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE); 530 $arrPaymentId = $objQuery->select($col, $from, $where); 531 return $arrPaymentId; 588 532 } 589 533 590 534 /* 591 535 * ファイルの情報をセットする 592 * 593 */ 594 function lfSetFile( ) {536 * @return $subImageFlag 537 */ 538 function lfSetFile($objUpFile,$arrProduct,&$arrFile) { 595 539 // DBからのデータを引き継ぐ 596 $ this->objUpFile->setDBFileList($this->arrProduct);540 $objUpFile->setDBFileList($arrProduct); 597 541 // ファイル表示用配列を渡す 598 $ this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true);542 $arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH, true); 599 543 600 544 // サブ画像の有無を判定 601 $ this->subImageFlag = false;545 $subImageFlag = false; 602 546 for ($i = 1; $i <= PRODUCTSUB_MAX; $i++) { 603 if ($this->arrFile["sub_image" . $i]["filepath"] != "") { 604 $this->subImageFlag = true; 605 } 606 } 547 if ($arrFile["sub_image" . $i]["filepath"] != "") { 548 $subImageFlag = true; 549 } 550 } 551 return $subImageFlag; 607 552 } 608 553 609 554 /* 610 555 * お気に入り商品登録 611 */ 612 function lfRegistFavoriteProduct($customer_id, $product_id) { 613 $objQuery = new SC_Query(); 614 $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $product_id)); 615 616 if ($count == 0) { 617 $sqlval['customer_id'] = $customer_id; 618 $sqlval['product_id'] = $product_id; 619 $sqlval['update_date'] = "now()"; 620 $sqlval['create_date'] = "now()"; 621 622 $objQuery->begin(); 623 $objQuery->insert('dtb_customer_favorite_products', $sqlval); 624 $objQuery->commit(); 625 } 626 } 627 556 * @return void 557 */ 558 function lfRegistFavoriteProduct($favorite_product_id,$customer_id) { 559 // ログイン中のユーザが商品をお気に入りにいれる処理 560 if(!SC_Helper_DB_Ex::sfIsRecord("dtb_products", "product_id", $favorite_product_id, "del_flg = 0 AND status = 1")) { 561 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 562 return false; 563 } else { 564 $objQuery =& SC_Query::getSingletonInstance(); 565 $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $favorite_product_id)); 566 567 if ($count == 0) { 568 $sqlval['customer_id'] = $customer_id; 569 $sqlval['product_id'] = $favorite_product_id; 570 $sqlval['update_date'] = "now()"; 571 $sqlval['create_date'] = "now()"; 572 573 $objQuery->begin(); 574 $objQuery->insert('dtb_customer_favorite_products', $sqlval); 575 $objQuery->commit(); 576 } 577 return true; 578 } 579 } 628 580 } 629 581 ?>
Note: See TracChangeset
for help on using the changeset viewer.