Changeset 15154 for branches


Ignore:
Timestamp:
2007/08/01 12:20:15 (17 years ago)
Author:
nanasess
Message:

LC_Page のクラス化対応

Location:
branches/feature-module-update
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/html/products/detail.php

    r15080 r15154  
    66 */ 
    77 
     8// {{{ requires 
    89require_once("../require.php"); 
    9 require_once(DATA_PATH . "include/page_layout.inc"); 
     10require_once(CLASS_PATH . "page_extends/products/LC_Page_Products_Detail_Ex.php"); 
    1011 
    11 class LC_Page { 
    12     function LC_Page() { 
    13         /** 必ず指定する **/ 
    14         global $arrSTATUS; 
    15         $this->arrSTATUS = $arrSTATUS; 
    16         global $arrSTATUS_IMAGE; 
    17         $this->arrSTATUS_IMAGE = $arrSTATUS_IMAGE; 
    18         global $arrDELIVERYDATE; 
    19         $this->arrDELIVERYDATE = $arrDELIVERYDATE; 
    20         global $arrRECOMMEND; 
    21         $this->arrRECOMMEND = $arrRECOMMEND; 
    22          
    23         //$this->tpl_mainpage="products/detail.tpl"; 
    24          
    25         /* 
    26          session_start時のno-cacheヘッダーを抑制することで 
    27          「戻る」ボタン使用時の有効期限切れ表示を抑制する。 
    28          private-no-expire:クライアントのキャッシュを許可する。 
    29         */ 
    30         session_cache_limiter('private-no-expire'); 
    31     } 
    32 } 
     12// }}} 
     13// {{{ generate page 
    3314 
    34 $objPage = new LC_Page(); 
    35 $objView = new SC_SiteView(); 
    36 $objCustomer = new SC_Customer(); 
    37 $objQuery = new SC_Query(); 
    38  
    39 // レイアウトデザインを取得 
    40 $objPage = sfGetPageLayout($objPage, false, "products/detail.php"); 
    41  
    42 // パラメータ管理クラス 
    43 $objFormParam = new SC_FormParam(); 
    44 // パラメータ情報の初期化 
    45 lfInitParam(); 
    46 // POST値の取得 
    47 $objFormParam->setParam($_POST); 
    48  
    49 // ファイル管理クラス 
    50 $objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); 
    51 // ファイル情報の初期化 
    52 lfInitFile(); 
    53  
    54 // 管理ページからの確認の場合は、非公開の商品も表示する。 
    55 if($_GET['admin'] == 'on') { 
    56     $where = "del_flg = 0"; 
    57 } else { 
    58     $where = "del_flg = 0 AND status = 1"; 
    59 } 
    60  
    61 if($_POST['mode'] != "") { 
    62     $tmp_id = $_POST['product_id']; 
    63 } else { 
    64     $tmp_id = $_GET['product_id']; 
    65 } 
    66  
    67 // 値の正当性チェック 
    68 if(!sfIsInt($_GET['product_id']) || !sfIsRecord("dtb_products", "product_id", $tmp_id, $where)) { 
    69     sfDispSiteError(PRODUCT_NOT_FOUND); 
    70 } 
    71 // ログイン判定 
    72 if($objCustomer->isLoginSuccess()) { 
    73     //お気に入りボタン表示 
    74     $objPage->tpl_login = true; 
    75  
    76 /* 閲覧ログ機能は現在未使用 
    77      
    78     $table = "dtb_customer_reading"; 
    79     $where = "customer_id = ? "; 
    80     $arrval[] = $objCustomer->getValue('customer_id'); 
    81     //顧客の閲覧商品数 
    82     $rpcnt = $objQuery->count($table, $where, $arrval); 
    83  
    84     //閲覧数が設定数以下 
    85     if ($rpcnt < CUSTOMER_READING_MAX){ 
    86         //閲覧履歴に新規追加 
    87         lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); 
    88     } else { 
    89         //閲覧履歴の中で一番古いものを削除して新規追加 
    90         $oldsql = "SELECT MIN(update_date) FROM ".$table." WHERE customer_id = ?"; 
    91         $old = $objQuery->getone($oldsql, array($objCustomer->getValue("customer_id"))); 
    92         $where = "customer_id = ? AND update_date = ? "; 
    93         $arrval = array($objCustomer->getValue("customer_id"), $old); 
    94         //削除 
    95         $objQuery->delete($table, $where, $arrval); 
    96         //追加 
    97         lfRegistReadingData($tmp_id, $objCustomer->getValue('customer_id')); 
    98     } 
    99 */ 
    100 } 
    101  
    102  
    103 // 規格選択セレクトボックスの作成 
    104 $objPage = lfMakeSelect($objPage, $tmp_id); 
    105  
    106 // 商品IDをFORM内に保持する。 
    107 $objPage->tpl_product_id = $tmp_id; 
    108  
    109 switch($_POST['mode']) { 
    110 case 'cart': 
    111     // 入力値の変換 
    112     $objFormParam->convParam(); 
    113     $objPage->arrErr = lfCheckError(); 
    114     if(count($objPage->arrErr) == 0) { 
    115         $objCartSess = new SC_CartSession(); 
    116         $classcategory_id1 = $_POST['classcategory_id1']; 
    117         $classcategory_id2 = $_POST['classcategory_id2']; 
    118                  
    119         // 規格1が設定されていない場合 
    120         if(!$objPage->tpl_classcat_find1) { 
    121             $classcategory_id1 = '0'; 
    122         } 
    123          
    124         // 規格2が設定されていない場合 
    125         if(!$objPage->tpl_classcat_find2) { 
    126             $classcategory_id2 = '0'; 
    127         } 
    128          
    129         $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); 
    130         $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $objFormParam->getValue('quantity')); 
    131         header("Location: " . URL_CART_TOP); 
    132  
    133         exit; 
    134     } 
    135     break; 
    136          
    137 default: 
    138     break; 
    139 } 
    140  
    141 $objQuery = new SC_Query(); 
    142 // DBから商品情報を取得する。 
    143 $arrRet = $objQuery->select("*", "vw_products_allclass_detail AS alldtl", "product_id = ?", array($tmp_id)); 
    144 $objPage->arrProduct = $arrRet[0]; 
    145  
    146 // 商品コードの取得 
    147 $code_sql = "SELECT product_code FROM dtb_products_class AS prdcls WHERE prdcls.product_id = ? GROUP BY product_code ORDER BY product_code"; 
    148 $arrProductCode = $objQuery->getall($code_sql, array($tmp_id)); 
    149 $arrProductCode = sfswaparray($arrProductCode); 
    150 $objPage->arrProductCode = $arrProductCode["product_code"]; 
    151  
    152 // 購入制限数を取得 
    153 if($objPage->arrProduct['sale_unlimited'] == 1 || $objPage->arrProduct['sale_limit'] > SALE_LIMIT_MAX) { 
    154   $objPage->tpl_sale_limit = SALE_LIMIT_MAX; 
    155 } else { 
    156   $objPage->tpl_sale_limit = $objPage->arrProduct['sale_limit']; 
    157 } 
    158  
    159 // サブタイトルを取得 
    160 $arrFirstCat = sfGetFirstCat($arrRet[0]['category_id']); 
    161 $tpl_subtitle = $arrFirstCat['name']; 
    162 $objPage->tpl_subtitle = $tpl_subtitle; 
    163  
    164 // DBからのデータを引き継ぐ 
    165 $objUpFile->setDBFileList($objPage->arrProduct); 
    166 // ファイル表示用配列を渡す 
    167 $objPage->arrFile = $objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL, true); 
    168 // 支払方法の取得 
    169 $objPage->arrPayment = lfGetPayment(); 
    170 // 入力情報を渡す 
    171 $objPage->arrForm = $objFormParam->getFormParamList(); 
    172 //レビュー情報の取得 
    173 $objPage->arrReview = lfGetReviewData($tmp_id); 
    174 // トラックバック情報の取得 
    175  
    176 // トラックバック機能の稼働状況チェック 
    177 if (sfGetSiteControlFlg(SITE_CONTROL_TRACKBACK) != 1) { 
    178     $objPage->arrTrackbackView = "OFF"; 
    179 } else { 
    180     $objPage->arrTrackbackView = "ON"; 
    181     $objPage->arrTrackback = lfGetTrackbackData($tmp_id); 
    182 } 
    183 $objPage->trackback_url = TRACKBACK_TO_URL . $tmp_id; 
    184 // タイトルに商品名を入れる 
    185 $objPage->tpl_title = "商品詳細 ". $objPage->arrProduct["name"]; 
    186 //オススメ商品情報表示 
    187 $objPage->arrRecommend = lfPreGetRecommendProducts($tmp_id); 
    188 //この商品を買った人はこんな商品も買っています 
    189 $objPage->arrRelateProducts = lfGetRelateProducts($tmp_id); 
    190  
    191 // 拡大画像のウィンドウサイズをセット 
    192 $image_path = IMAGE_SAVE_DIR . basename($objPage->arrFile["main_large_image"]["filepath"]); 
    193 list($large_width, $large_height) = getimagesize($image_path); 
    194 $objPage->tpl_large_width = $large_width + 60; 
    195 $objPage->tpl_large_height = $large_height + 80; 
    196  
    197 lfConvertParam(); 
    198  
    199 $objView->assignobj($objPage); 
    200 $objView->display(SITE_FRAME); 
    201 //----------------------------------------------------------------------------------------------------------------------------------- 
    202 /* ファイル情報の初期化 */ 
    203 function lfInitFile() { 
    204     global $objUpFile; 
    205     $objUpFile->addFile("一覧-メイン画像", 'main_list_image', array('jpg','gif'),IMAGE_SIZE, true, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); 
    206     $objUpFile->addFile("詳細-メイン画像", 'main_image', array('jpg'), IMAGE_SIZE, true, NORMAL_IMAGE_WIDTH, NORMAL_IMAGE_HEIGHT); 
    207     $objUpFile->addFile("詳細-メイン拡大画像", 'main_large_image', array('jpg'), IMAGE_SIZE, false, LARGE_IMAGE_HEIGHT, LARGE_IMAGE_HEIGHT); 
    208     for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { 
    209         $objUpFile->addFile("詳細-サブ画像$cnt", "sub_image$cnt", array('jpg'), IMAGE_SIZE, false, NORMAL_SUBIMAGE_HEIGHT, NORMAL_SUBIMAGE_HEIGHT);    
    210         $objUpFile->addFile("詳細-サブ拡大画像$cnt", "sub_large_image$cnt", array('jpg'), IMAGE_SIZE, false, LARGE_SUBIMAGE_HEIGHT, LARGE_SUBIMAGE_HEIGHT); 
    211     } 
    212     $objUpFile->addFile("商品比較画像", 'file1', array('jpg'), IMAGE_SIZE, false, NORMAL_IMAGE_HEIGHT, NORMAL_IMAGE_HEIGHT); 
    213     $objUpFile->addFile("商品詳細ファイル", 'file2', array('pdf'), PDF_SIZE, false, 0, 0, false); 
    214 } 
    215  
    216 /* 規格選択セレクトボックスの作成 */ 
    217 function lfMakeSelect($objPage, $product_id) { 
    218     global $objPage; 
    219     $classcat_find1 = false; 
    220     $classcat_find2 = false; 
    221     // 在庫ありの商品の有無 
    222     $stock_find = false; 
    223      
    224     // 規格名一覧 
    225     $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); 
    226     // 規格分類名一覧 
    227     $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
    228     // 商品規格情報の取得     
    229     $arrProductsClass = lfGetProductsClass($product_id); 
    230      
    231     // 規格1クラス名の取得 
    232     $objPage->tpl_class_name1 = $arrClassName[$arrProductsClass[0]['class_id1']]; 
    233     // 規格2クラス名の取得 
    234     $objPage->tpl_class_name2 = $arrClassName[$arrProductsClass[0]['class_id2']]; 
    235      
    236     // すべての組み合わせ数    
    237     $count = count($arrProductsClass); 
    238      
    239     $classcat_id1 = ""; 
    240      
    241     $arrSele = array(); 
    242     $arrList = array(); 
    243      
    244     $list_id = 0; 
    245     $arrList[0] = "\tlist0 = new Array('選択してください'"; 
    246     $arrVal[0] = "\tval0 = new Array(''"; 
    247      
    248     for ($i = 0; $i < $count; $i++) { 
    249         // 在庫のチェック 
    250         if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { 
    251             continue; 
    252         } 
    253          
    254         $stock_find = true; 
    255          
    256         // 規格1のセレクトボックス用 
    257         if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 
    258             $arrList[$list_id].=");\n"; 
    259             $arrVal[$list_id].=");\n"; 
    260             $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; 
    261             $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; 
    262             $list_id++; 
    263         } 
    264          
    265         // 規格2のセレクトボックス用 
    266         $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; 
    267          
    268         // セレクトボックス表示値 
    269         if($arrList[$list_id] == "") { 
    270             $arrList[$list_id] = "\tlist".$list_id." = new Array('選択してください', '".$arrClassCatName[$classcat_id2]."'"; 
    271         } else { 
    272             $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; 
    273         } 
    274          
    275         // セレクトボックスPOST値 
    276         if($arrVal[$list_id] == "") { 
    277             $arrVal[$list_id] = "\tval".$list_id." = new Array('', '".$classcat_id2."'"; 
    278         } else { 
    279             $arrVal[$list_id].= ", '".$classcat_id2."'"; 
    280         } 
    281     }    
    282      
    283     $arrList[$list_id].=");\n"; 
    284     $arrVal[$list_id].=");\n"; 
    285          
    286     // 規格1 
    287     $objPage->arrClassCat1 = $arrSele; 
    288      
    289     $lists = "\tlists = new Array("; 
    290     $no = 0; 
    291      
    292     foreach($arrList as $val) { 
    293         $objPage->tpl_javascript.= $val; 
    294         if ($no != 0) { 
    295             $lists.= ",list".$no; 
    296         } else { 
    297             $lists.= "list".$no; 
    298         } 
    299         $no++; 
    300     } 
    301     $objPage->tpl_javascript.=$lists.");\n"; 
    302      
    303     $vals = "\tvals = new Array("; 
    304     $no = 0; 
    305      
    306     foreach($arrVal as $val) { 
    307         $objPage->tpl_javascript.= $val; 
    308         if ($no != 0) { 
    309             $vals.= ",val".$no; 
    310         } else { 
    311             $vals.= "val".$no; 
    312         } 
    313         $no++; 
    314     } 
    315     $objPage->tpl_javascript.=$vals.");\n"; 
    316      
    317     // 選択されている規格2ID 
    318     $objPage->tpl_onload = "lnSetSelect('form1', 'classcategory_id1', 'classcategory_id2', '" . $_POST['classcategory_id2'] . "');"; 
    319  
    320     // 規格1が設定されている 
    321     if($arrProductsClass[0]['classcategory_id1'] != '0') { 
    322         $classcat_find1 = true; 
    323     } 
    324      
    325     // 規格2が設定されている 
    326     if($arrProductsClass[0]['classcategory_id2'] != '0') { 
    327         $classcat_find2 = true; 
    328     } 
    329          
    330     $objPage->tpl_classcat_find1 = $classcat_find1; 
    331     $objPage->tpl_classcat_find2 = $classcat_find2; 
    332     $objPage->tpl_stock_find = $stock_find; 
    333          
    334     return $objPage; 
    335 } 
    336  
    337 /* パラメータ情報の初期化 */ 
    338 function lfInitParam() { 
    339     global $objFormParam; 
    340  
    341     $objFormParam->addParam("規格1", "classcategory_id1", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 
    342     $objFormParam->addParam("規格2", "classcategory_id2", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); 
    343     $objFormParam->addParam("個数", "quantity", INT_LEN, "n", array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    344 } 
    345  
    346 /* 商品規格情報の取得 */ 
    347 function lfGetProductsClass($product_id) { 
    348     $arrRet = array(); 
    349     if(sfIsInt($product_id)) { 
    350         // 商品規格取得 
    351         $objQuery = new SC_Query(); 
    352         $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; 
    353         $table = "vw_product_class AS prdcls"; 
    354         $where = "product_id = ?"; 
    355         $objQuery->setorder("rank1 DESC, rank2 DESC"); 
    356         $arrRet = $objQuery->select($col, $table, $where, array($product_id)); 
    357     } 
    358     return $arrRet; 
    359 } 
    360  
    361 /* 登録済みオススメ商品の読み込み */ 
    362 function lfPreGetRecommendProducts($product_id) { 
    363     $objQuery = new SC_Query(); 
    364     $objQuery->setorder("rank DESC"); 
    365     $arrRet = $objQuery->select("recommend_product_id, comment", "dtb_recommend_products", "product_id = ?", array($product_id)); 
    366     $max = count($arrRet); 
    367     $no = 0; 
    368     for($i = 0; $i < $max; $i++) { 
    369         $where = "del_flg = 0 AND product_id = ? AND status = 1"; 
    370         $arrProductInfo = $objQuery->select("main_list_image, price02_min, price02_max, price01_min, price01_max, name, point_rate", "vw_products_allclass  AS allcls", $where, array($arrRet[$i]['recommend_product_id']));  
    371                  
    372         if(count($arrProductInfo) > 0) { 
    373             $arrRecommend[$no] = $arrProductInfo[0]; 
    374             $arrRecommend[$no]['product_id'] = $arrRet[$i]['recommend_product_id']; 
    375             $arrRecommend[$no]['comment'] = $arrRet[$i]['comment']; 
    376             $no++; 
    377         }    
    378     } 
    379     return $arrRecommend; 
    380 } 
    381  
    382 /* 入力内容のチェック */ 
    383 function lfCheckError() { 
    384     global $objFormParam; 
    385     global $objPage; 
    386     // 入力データを渡す。 
    387     $arrRet =  $objFormParam->getHashArray(); 
    388     $objErr = new SC_CheckError($arrRet); 
    389     $objErr->arrErr = $objFormParam->checkError(); 
    390          
    391     // 複数項目チェック 
    392     if ($objPage->tpl_classcat_find1) { 
    393         $objErr->doFunc(array("規格1", "classcategory_id1"), array("EXIST_CHECK")); 
    394     } 
    395     if ($objPage->tpl_classcat_find2) { 
    396         $objErr->doFunc(array("規格2", "classcategory_id2"), array("EXIST_CHECK")); 
    397     } 
    398              
    399     return $objErr->arrErr; 
    400 } 
    401  
    402 //閲覧履歴新規登録 
    403 function lfRegistReadingData($tmp_id, $customer_id){ 
    404     $objQuery = new SC_Query; 
    405     $sqlval['customer_id'] = $customer_id; 
    406     $sqlval['reading_product_id'] = $tmp_id; 
    407     $sqlval['create_date'] = 'NOW()'; 
    408     $sqlval['update_date'] = 'NOW()'; 
    409     $objQuery->insert("dtb_customer_reading", $sqlval); 
    410 } 
    411  
    412 //この商品を買った人はこんな商品も買っています 
    413 function lfGetRelateProducts($tmp_id) { 
    414     $objQuery = new SC_Query; 
    415     //自動抽出 
    416     $objQuery->setorder("random()"); 
    417     //表示件数の制限 
    418     $objQuery->setlimit(RELATED_PRODUCTS_MAX); 
    419     //検索条件 
    420     $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate"; 
    421     $from = "vw_products_allclass AS allcls "; 
    422     $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? "; 
    423     $arrval[] = $tmp_id; 
    424     //結果の取得 
    425     $arrProducts = $objQuery->select($col, $from, $where, $arrval); 
    426      
    427     return $arrProducts; 
    428 } 
    429  
    430 //商品ごとのレビュー情報を取得する 
    431 function lfGetReviewData($id) { 
    432     $objQuery = new SC_Query; 
    433     //商品ごとのレビュー情報を取得する 
    434     $col = "create_date, reviewer_url, reviewer_name, recommend_level, title, comment"; 
    435     $from = "dtb_review"; 
    436     $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . REVIEW_REGIST_MAX; 
    437     $arrval[] = $id; 
    438     $arrReview = $objQuery->select($col, $from, $where, $arrval); 
    439     return $arrReview;  
    440 } 
    441  
    442 /* 
    443  * 商品ごとのトラックバック情報を取得する 
    444  *  
    445  * @param $product_id 
    446  * @return $arrTrackback 
    447  */ 
    448 function lfGetTrackbackData($product_id) { 
    449  
    450     $arrTrackback = array(); 
    451  
    452     $objQuery = new SC_Query; 
    453     //商品ごとのトラックバック情報を取得する 
    454     $col = "blog_name, url, title, excerpt, title, create_date"; 
    455     $from = "dtb_trackback"; 
    456     $where = "del_flg = 0 AND status = 1 AND product_id = ? ORDER BY create_date DESC LIMIT " . TRACKBACK_VIEW_MAX; 
    457     $arrval[] = $product_id; 
    458     $arrTrackback = $objQuery->select($col, $from, $where, $arrval); 
    459     return $arrTrackback;  
    460 } 
    461  
    462 //支払方法の取得 
    463 //payment_id    1:クレジット 2:ショッピングローン  
    464 function lfGetPayment() { 
    465     $objQuery = new SC_Query; 
    466     $col = "payment_id, rule, payment_method"; 
    467     $from = "dtb_payment"; 
    468     $where = "del_flg = 0"; 
    469     $order = "payment_id"; 
    470     $objQuery->setorder($order); 
    471     $arrRet = $objQuery->select($col, $from, $where); 
    472     return $arrRet; 
    473 } 
    474  
    475 function lfConvertParam() { 
    476     global $objPage; 
    477      
    478     $value = $objPage->arrForm['quantity']['value']; 
    479     $objPage->arrForm['quantity']['value'] = htmlspecialchars($value, ENT_QUOTES, CHAR_CODE); 
    480 } 
     15$objPage = new LC_Page_Products_Detail_Ex(); 
     16$objPage->init(); 
     17$objPage->process(); 
     18register_shutdown_function(array($objPage, "destroy")); 
    48119?> 
  • branches/feature-module-update/html/products/detail_image.php

    r15080 r15154  
    66 */ 
    77 
     8// {{{ requires 
    89require_once("../require.php"); 
     10require_once(CLASS_PATH . "page_extends/products/LC_Page_Products_DetailImage_Ex.php"); 
    911 
    10 class LC_Page { 
    11     function LC_Page() { 
    12         /** 必ず指定する **/ 
    13         $this->tpl_mainpage = 'products/detail_image.tpl';          // メインテンプレート 
    14     } 
    15 } 
     12// }}} 
     13// {{{ generate page 
    1614 
    17 $objPage = new LC_Page(); 
    18 $objView = new SC_SiteView(); 
    19 $objCartSess = new SC_CartSession("", false); 
    20  
    21 // 管理ページからの確認の場合は、非公開の商品も表示する。 
    22 if($_GET['admin'] == 'on') { 
    23     $where = "del_flg = 0"; 
    24 } else { 
    25     $where = "del_flg = 0 AND status = 1"; 
    26 } 
    27  
    28 // 値の正当性チェック 
    29 if(!sfIsInt($_GET['product_id']) || !sfIsRecord("dtb_products", "product_id", $_GET['product_id'], $where)) { 
    30     sfDispSiteError(PRODUCT_NOT_FOUND); 
    31 } 
    32  
    33  
    34 $image_key = $_GET['image']; 
    35  
    36 $objQuery = new SC_Query(); 
    37 $col = "name, $image_key"; 
    38 $arrRet = $objQuery->select($col, "dtb_products", "product_id = ?", array($_GET['product_id'])); 
    39  
    40 list($width, $height) = getimagesize(IMAGE_SAVE_DIR . $arrRet[0][$image_key]); 
    41 $objPage->tpl_width = $width; 
    42 $objPage->tpl_height = $height; 
    43  
    44 $objPage->tpl_table_width = $objPage->tpl_width + 20; 
    45 $objPage->tpl_table_height = $objPage->tpl_height + 20; 
    46  
    47 $objPage->tpl_image = $arrRet[0][$image_key]; 
    48 $objPage->tpl_name = $arrRet[0]['name']; 
    49  
    50 $objView->assignobj($objPage); 
    51 $objView->display($objPage->tpl_mainpage); 
    52 //----------------------------------------------------------------------------------------------------------------------------------- 
     15$objPage = new LC_Page_Products_DetailImage_Ex(); 
     16$objPage->init(); 
     17$objPage->process(); 
     18register_shutdown_function(array($objPage, "destroy")); 
    5319?> 
  • branches/feature-module-update/html/products/list.php

    r15080 r15154  
    66 */ 
    77 
     8// {{{ requires 
    89require_once("../require.php"); 
    9 require_once(DATA_PATH . "include/page_layout.inc"); 
     10require_once(CLASS_PATH . "page_extends/products/LC_Page_Products_List_Ex.php"); 
    1011 
    11 class LC_Page { 
    12     function LC_Page() { 
    13         global $arrSTATUS; 
    14         $this->arrSTATUS = $arrSTATUS; 
    15         global $arrSTATUS_IMAGE; 
    16         $this->arrSTATUS_IMAGE = $arrSTATUS_IMAGE; 
    17         global $arrDELIVERYDATE; 
    18         $this->arrDELIVERYDATE = $arrDELIVERYDATE; 
    19         global $arrPRODUCTLISTMAX; 
    20         $this->arrPRODUCTLISTMAX = $arrPRODUCTLISTMAX;       
    21         /* 
    22          session_start時のno-cacheヘッダーを抑制することで 
    23          「戻る」ボタン使用時の有効期限切れ表示を抑制する。 
    24          private-no-expire:クライアントのキャッシュを許可する。 
    25         */ 
    26         session_cache_limiter('private-no-expire'); 
    27     } 
    28 } 
     12// }}} 
     13// {{{ generate page 
    2914 
    30 $objPage = new LC_Page(); 
    31 $conn = new SC_DBConn(); 
    32  
    33 //表示件数の選択 
    34 if(sfIsInt($_POST['disp_number'])) { 
    35     $objPage->disp_number = $_POST['disp_number']; 
    36 } else { 
    37     //最小表示件数を選択 
    38     $objPage->disp_number = current(array_keys($arrPRODUCTLISTMAX)); 
    39 } 
    40  
    41 //表示順序の保存 
    42 $objPage->orderby = $_POST['orderby']; 
    43  
    44 // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 
    45 $category_id = sfGetCategoryId("", $_GET['category_id']); 
    46  
    47 // タイトル編集 
    48 $tpl_subtitle = ""; 
    49 if($_GET['mode'] == 'search'){ 
    50     $tpl_subtitle = "検索結果"; 
    51 }elseif ($category_id == "" ) { 
    52     $tpl_subtitle = "全商品"; 
    53 }else{ 
    54     $arrFirstCat = sfGetFirstCat($category_id); 
    55     $tpl_subtitle = $arrFirstCat['name']; 
    56 } 
    57  
    58 $objQuery = new SC_Query(); 
    59 $count = $objQuery->count("dtb_best_products", "category_id = ?", array($category_id)); 
    60  
    61 // 以下の条件でBEST商品を表示する 
    62 // ・BEST最大数の商品が登録されている。 
    63 // ・カテゴリIDがルートIDである。 
    64 // ・検索モードでない。 
    65 if(($count >= BEST_MIN) && lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) { 
    66     // 商品TOPの表示処理 
    67     /** 必ず指定する **/ 
    68     $objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // メインテンプレート     
    69      
    70     $objPage->arrBestItems = sfGetBestProducts($conn, $category_id); 
    71     $objPage->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 
    72 } else { 
    73     if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 
    74         // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 
    75         $category_id = '';   
    76     } 
    77      
    78     // 商品一覧の表示処理 
    79     $objPage = lfDispProductsList($category_id, $_GET['name'], $objPage->disp_number, $_POST['orderby']); 
    80      
    81     // 検索条件を画面に表示 
    82     // カテゴリー検索条件 
    83     if (strlen($_GET['category_id']) == 0) { 
    84         $arrSearch['category'] = "指定なし"; 
    85     }else{ 
    86         $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id)); 
    87         $arrSearch['category'] = $arrCat; 
    88     } 
    89      
    90     // 商品名検索条件 
    91     if ($_GET['name'] === "") { 
    92         $arrSearch['name'] = "指定なし"; 
    93     }else{ 
    94         $arrSearch['name'] = $_GET['name']; 
    95     } 
    96 } 
    97  
    98 // レイアウトデザインを取得 
    99 $objPage = sfGetPageLayout($objPage, false, "products/list.php"); 
    100  
    101 if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { 
    102     // 値の正当性チェック 
    103     if(!sfIsInt($_POST['product_id']) || !sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 
    104         sfDispSiteError(PRODUCT_NOT_FOUND); 
    105     } else { 
    106         // 入力値の変換 
    107         $objPage->arrErr = lfCheckError($_POST['product_id']); 
    108         if(count($objPage->arrErr) == 0) { 
    109             $objCartSess = new SC_CartSession(); 
    110             $classcategory_id = "classcategory_id". $_POST['product_id']; 
    111             $classcategory_id1 = $_POST[$classcategory_id. '_1']; 
    112             $classcategory_id2 = $_POST[$classcategory_id. '_2']; 
    113             $quantity = "quantity". $_POST['product_id']; 
    114             // 規格1が設定されていない場合 
    115             if(!$objPage->tpl_classcat_find1[$_POST['product_id']]) { 
    116                 $classcategory_id1 = '0'; 
    117             } 
    118             // 規格2が設定されていない場合 
    119             if(!$objPage->tpl_classcat_find2[$_POST['product_id']]) { 
    120                 $classcategory_id2 = '0'; 
    121             } 
    122             $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); 
    123             $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); 
    124             header("Location: " . URL_CART_TOP); 
    125             exit; 
    126         } 
    127     } 
    128 } 
    129  
    130  
    131 $objPage->tpl_subtitle = $tpl_subtitle; 
    132  
    133 // 支払方法の取得 
    134 $objPage->arrPayment = lfGetPayment(); 
    135 // 入力情報を渡す 
    136 $objPage->arrForm = $_POST; 
    137  
    138 lfConvertParam(); 
    139  
    140 $objPage->category_id = $category_id; 
    141 $objPage->arrSearch = $arrSearch; 
    142  
    143 sfCustomDisplay($objPage); 
    144  
    145 //----------------------------------------------------------------------------------------------------------------------------------- 
    146 /* カテゴリIDがルートかどうかの判定 */ 
    147 function lfIsRootCategory($category_id) { 
    148     $objQuery = new SC_Query(); 
    149     $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id)); 
    150     if($level == 1) { 
    151         return true; 
    152     } 
    153     return false; 
    154 } 
    155  
    156 /* 商品一覧の表示 */ 
    157 function lfDispProductsList($category_id, $name, $disp_num, $orderby) { 
    158     global $objPage; 
    159     $objQuery = new SC_Query();  
    160     $objPage->tpl_pageno = $_POST['pageno']; 
    161  
    162     //表示件数でテンプレートを切り替える 
    163     $objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // メインテンプレート         
    164  
    165     //表示順序 
    166     switch($orderby) { 
    167     //価格順 
    168     case 'price': 
    169         $order = "price02_min ASC"; 
    170         break; 
    171     //新着順 
    172     case 'date': 
    173         $order = "create_date DESC"; 
    174         break; 
    175     default: 
    176         $order = "category_rank DESC, rank DESC"; 
    177         break; 
    178     } 
    179      
    180     // 商品検索条件の作成(未削除、表示) 
    181     $where = "del_flg = 0 AND status = 1 "; 
    182     // カテゴリからのWHERE文字列取得 
    183     if ( $category_id ) { 
    184         list($tmp_where, $arrval) = sfGetCatWhere($category_id); 
    185         if($tmp_where != "") { 
    186             $where.= " AND $tmp_where"; 
    187         } 
    188     } 
    189          
    190     // 商品名をwhere文に 
    191     $name = ereg_replace(",", "", $name); 
    192     if ( strlen($name) > 0 ){ 
    193         $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 
    194         $ret = sfManualEscape($name);        
    195         $arrval[] = "%$ret%"; 
    196         $arrval[] = "%$ret%"; 
    197     } 
    198              
    199     // 行数の取得 
    200     $linemax = $objQuery->count("vw_products_allclass AS allcls", $where, $arrval); 
    201     $objPage->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
    202      
    203     // ページ送りの取得 
    204     $objNavi = new SC_PageNavi($_POST['pageno'], $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 
    205      
    206     $strnavi = $objNavi->strnavi; 
    207     $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 
    208     $objPage->tpl_strnavi = $strnavi;       // 表示文字列 
    209     $startno = $objNavi->start_row;                 // 開始行 
    210      
    211     // 取得範囲の指定(開始行番号、行数のセット) 
    212     $objQuery->setlimitoffset($disp_num, $startno); 
    213     // 表示順序 
    214     $objQuery->setorder($order); 
    215      
    216      
    217      
    218      
    219      
    220      
    221      
    222      
    223     // 検索結果の取得 
    224     $objPage->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval); 
    225      
    226     // 規格名一覧 
    227     $arrClassName = sfGetIDValueList("dtb_class", "class_id", "name"); 
    228     // 規格分類名一覧 
    229     $arrClassCatName = sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
    230     // 企画セレクトボックス設定 
    231     if($disp_num == 15) { 
    232         for($i = 0; $i < count($objPage->arrProducts); $i++) { 
    233             $objPage = lfMakeSelect($objPage->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); 
    234             // 購入制限数を取得 
    235             $objPage = lfGetSaleLimit($objPage->arrProducts[$i]); 
    236         } 
    237     } 
    238  
    239     return $objPage; 
    240 } 
    241  
    242 /* 規格セレクトボックスの作成 */ 
    243 function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) { 
    244     global $objPage; 
    245      
    246     $classcat_find1 = false; 
    247     $classcat_find2 = false; 
    248     // 在庫ありの商品の有無 
    249     $stock_find = false; 
    250      
    251     // 商品規格情報の取得     
    252     $arrProductsClass = lfGetProductsClass($product_id); 
    253      
    254     // 規格1クラス名の取得 
    255     $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']]; 
    256     // 規格2クラス名の取得 
    257     $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']]; 
    258      
    259     // すべての組み合わせ数    
    260     $count = count($arrProductsClass); 
    261      
    262     $classcat_id1 = ""; 
    263      
    264     $arrSele = array(); 
    265     $arrList = array(); 
    266      
    267     $list_id = 0; 
    268     $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'"; 
    269     $arrVal[0] = "\tval". $product_id. "_0 = new Array(''"; 
    270      
    271     for ($i = 0; $i < $count; $i++) { 
    272         // 在庫のチェック 
    273         if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { 
    274             continue; 
    275         } 
    276          
    277         $stock_find = true; 
    278          
    279         // 規格1のセレクトボックス用 
    280         if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 
    281             $arrList[$list_id].=");\n"; 
    282             $arrVal[$list_id].=");\n"; 
    283             $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; 
    284             $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; 
    285             $list_id++; 
    286         } 
    287          
    288         // 規格2のセレクトボックス用 
    289         $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; 
    290          
    291         // セレクトボックス表示値 
    292         if($arrList[$list_id] == "") { 
    293             $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'"; 
    294         } else { 
    295             $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; 
    296         } 
    297          
    298         // セレクトボックスPOST値 
    299         if($arrVal[$list_id] == "") { 
    300             $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'"; 
    301         } else { 
    302             $arrVal[$list_id].= ", '".$classcat_id2."'"; 
    303         } 
    304     }    
    305      
    306     $arrList[$list_id].=");\n"; 
    307     $arrVal[$list_id].=");\n"; 
    308          
    309     // 規格1 
    310     $objPage->arrClassCat1[$product_id] = $arrSele; 
    311      
    312     $lists = "\tlists".$product_id. " = new Array("; 
    313     $no = 0; 
    314     foreach($arrList as $val) { 
    315         $objPage->tpl_javascript.= $val; 
    316         if ($no != 0) { 
    317             $lists.= ",list". $product_id. "_". $no; 
    318         } else { 
    319             $lists.= "list". $product_id. "_". $no; 
    320         } 
    321         $no++; 
    322     } 
    323     $objPage->tpl_javascript.= $lists.");\n"; 
    324      
    325     $vals = "\tvals".$product_id. " = new Array("; 
    326     $no = 0; 
    327     foreach($arrVal as $val) { 
    328         $objPage->tpl_javascript.= $val; 
    329         if ($no != 0) { 
    330             $vals.= ",val". $product_id. "_". $no; 
    331         } else { 
    332             $vals.= "val". $product_id. "_". $no; 
    333         } 
    334         $no++; 
    335     } 
    336     $objPage->tpl_javascript.= $vals.");\n"; 
    337      
    338     // 選択されている規格2ID 
    339     $classcategory_id = "classcategory_id". $product_id; 
    340     $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); "; 
    341  
    342     // 規格1が設定されている 
    343     if($arrProductsClass[0]['classcategory_id1'] != '0') { 
    344         $classcat_find1 = true; 
    345     } 
    346      
    347     // 規格2が設定されている 
    348     if($arrProductsClass[0]['classcategory_id2'] != '0') { 
    349         $classcat_find2 = true; 
    350     } 
    351          
    352     $objPage->tpl_classcat_find1[$product_id] = $classcat_find1; 
    353     $objPage->tpl_classcat_find2[$product_id] = $classcat_find2; 
    354     $objPage->tpl_stock_find[$product_id] = $stock_find; 
    355          
    356     return $objPage; 
    357 } 
    358 /* 商品規格情報の取得 */ 
    359 function lfGetProductsClass($product_id) { 
    360     $arrRet = array(); 
    361     if(sfIsInt($product_id)) { 
    362         // 商品規格取得 
    363         $objQuery = new SC_Query(); 
    364         $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; 
    365         $table = "vw_product_class AS prdcls"; 
    366         $where = "product_id = ?"; 
    367         $objQuery->setorder("rank1 DESC, rank2 DESC"); 
    368         $arrRet = $objQuery->select($col, $table, $where, array($product_id)); 
    369     } 
    370     return $arrRet; 
    371 } 
    372  
    373 /* 入力内容のチェック */ 
    374 function lfCheckError($id) { 
    375     global $objPage; 
    376      
    377     // 入力データを渡す。 
    378     $objErr = new SC_CheckError(); 
    379      
    380     $classcategory_id1 = "classcategory_id". $id. "_1"; 
    381     $classcategory_id2 = "classcategory_id". $id. "_2"; 
    382     $quantity = "quantity". $id; 
    383     // 複数項目チェック 
    384     if ($objPage->tpl_classcat_find1[$id]) { 
    385         $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    386     } 
    387     if ($objPage->tpl_classcat_find2[$id]) { 
    388         $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    389     } 
    390     $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    391              
    392     return $objErr->arrErr; 
    393 } 
    394  
    395 // 購入制限数の設定 
    396 function lfGetSaleLimit($product) { 
    397     global $objPage; 
    398     //在庫が無限または購入制限値が設定値より大きい場合 
    399     if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) { 
    400         $objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX; 
    401     } else { 
    402         $objPage->tpl_sale_limit[$product['product_id']] = $product['sale_limit']; 
    403     } 
    404      
    405     return $objPage; 
    406 } 
    407  
    408 //支払方法の取得 
    409 //payment_id    1:代金引換 2:銀行振り込み 3:現金書留 
    410 function lfGetPayment() { 
    411     $objQuery = new SC_Query; 
    412     $col = "payment_id, rule, payment_method"; 
    413     $from = "dtb_payment"; 
    414     $where = "del_flg = 0"; 
    415     $order = "payment_id"; 
    416     $objQuery->setorder($order); 
    417     $arrRet = $objQuery->select($col, $from, $where); 
    418     return $arrRet; 
    419 } 
    420  
    421 function lfconvertParam () { 
    422     global $objPage; 
    423      
    424     foreach ($objPage->arrForm as $key => $value) { 
    425         if (preg_match('/^quantity[0-9]+/', $key)) { 
    426              $objPage->arrForm[$key] 
    427                 = htmlspecialchars($objPage->arrForm[$key], ENT_QUOTES, CHAR_CODE); 
    428         } 
    429     } 
    430 } 
     15$objPage = new LC_Page_Products_List_Ex(); 
     16$objPage->init(); 
     17$objPage->process(); 
     18register_shutdown_function(array($objPage, "destroy")); 
    43119?> 
Note: See TracChangeset for help on using the changeset viewer.