Ignore:
Timestamp:
2010/03/11 10:35:11 (14 years ago)
Author:
kajiwara
Message:

正式版にナイトリービルド版をマージしてみるテスト

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tmp/version-2_5-test/data/class/pages/products/LC_Page_Products_List.php

    r18562 r18609  
    3737 
    3838    /** テンプレートクラス名1 */ 
    39     var $tpl_class_name1; 
     39    var $tpl_class_name1 = array(); 
    4040 
    4141    /** テンプレートクラス名2 */ 
    42     var $tpl_class_name2; 
     42    var $tpl_class_name2 = array(); 
    4343 
    4444    /** JavaScript テンプレート */ 
    4545    var $tpl_javascript; 
     46 
     47    var $orderby; 
     48 
     49    var $mode; 
     50 
     51    /** 検索条件(内部データ) */ 
     52    var $arrSearchData = array(); 
     53 
     54    /** 検索条件(表示用) */ 
     55    var $arrSearch = array(); 
     56 
     57    var $tpl_subtitle = ''; 
     58 
     59    /** ランダム文字列 **/ 
     60    var $tpl_rnd = ''; 
    4661 
    4762    // }}} 
     
    6176        $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); 
    6277        $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max"); 
    63  
    64         $this->tpl_class_name1 = array(); 
    65         $this->tpl_class_name2 = array(); 
    66         $this->allowClientCache(); 
    6778    } 
    6879 
     
    7384     */ 
    7485    function process() { 
    75         $objView = new SC_SiteView(); 
     86        $this->lfLoadParam(); 
     87 
     88        $objView = new SC_SiteView(!$this->inCart); 
    7689        $conn = new SC_DBConn(); 
    7790        $objDb = new SC_Helper_DB_Ex(); 
    7891 
    79         //表示件数の選択 
    80         if(isset($_POST['disp_number']) 
    81            && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { 
    82             $this->disp_number = $_POST['disp_number']; 
    83         } else { 
    84             //最小表示件数を選択 
    85             $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); 
    86         } 
    87  
    88         //表示順序の保存 
    89         $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : ""; 
    90  
    91         // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 
    92         $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); 
    93  
    94         if (!isset($_GET['mode'])) $_GET['mode'] = ""; 
    95         if (!isset($_GET['name'])) $_GET['name'] = ""; 
    96         if (!isset($_POST['orderby'])) $_POST['orderby'] = ""; 
    97         if (empty($arrCategory_id)) $arrCategory_id = array("0"); 
    98  
    9992        // タイトル編集 
    100         $tpl_subtitle = ""; 
    101         if ($_GET['mode'] == 'search') { 
    102             $tpl_subtitle = "検索結果"; 
    103         } elseif (empty($arrCategory_id[0])) { 
    104             $tpl_subtitle = "全商品"; 
    105         } else { 
    106             $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); 
    107             $tpl_subtitle = $arrFirstCat['name']; 
     93        if ($this->mode == 'search') { 
     94            $this->tpl_subtitle = "検索結果"; 
     95        } elseif ($this->arrSearchData['category_id'] == 0) { 
     96            $this->tpl_subtitle = "全商品"; 
     97        } else { 
     98            $arrCat = $objDb->sfGetCat($this->arrSearchData['category_id']); 
     99            $this->tpl_subtitle = $arrCat['name']; 
    108100        } 
    109101 
    110102        $objQuery = new SC_Query(); 
    111         $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); 
    112  
    113         // 以下の条件でBEST商品を表示する 
    114         // ・BEST最大数の商品が登録されている。 
    115         // ・カテゴリIDがルートIDである。 
    116         // ・検索モードでない。 
    117         if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { 
    118             // 商品TOPの表示処理 
    119             $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); 
    120             $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 
    121         } else { 
    122             if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 
    123                 // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 
    124                 $arrCategory_id = array(0); 
    125             } 
    126  
    127             // 商品一覧の表示処理 
    128             $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_POST['orderby']); 
    129  
    130             // 検索条件を画面に表示 
    131             // カテゴリー検索条件 
    132             if (strlen($_GET['category_id']) == 0) { 
    133                 $arrSearch['category'] = "指定なし"; 
    134             }else{ 
    135                 $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", $arrCategory_id); 
    136                 $arrSearch['category'] = $arrCat; 
    137             } 
    138  
    139             // 商品名検索条件 
    140             if ($_GET['name'] === "") { 
    141                 $arrSearch['name'] = "指定なし"; 
    142             }else{ 
    143                 $arrSearch['name'] = $_GET['name']; 
    144             } 
     103        $count = $objQuery->count("dtb_best_products", "category_id = ?", array($this->arrSearchData['category_id'])); 
     104 
     105        // 商品一覧の表示処理 
     106        $this->lfDispProductsList(); 
     107 
     108        // 検索条件を画面に表示 
     109        // カテゴリー検索条件 
     110        if ($this->arrSearchData['category_id'] == 0) { 
     111            $this->arrSearch['category'] = "指定なし"; 
     112        } else { 
     113            $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($this->arrSearchData['category_id'])); 
     114            $this->arrSearch['category'] = $arrCat; 
     115        } 
     116 
     117        // メーカー検索条件 
     118        if (strlen($this->arrSearchData['maker_id']) == 0) { 
     119            $this->arrSearch['maker'] = "指定なし"; 
     120        } else { 
     121            $this->arrSearch['maker'] = $conn->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", $this->arrSearchData['maker_id']); 
     122        } 
     123 
     124        // 商品名検索条件 
     125        if (strlen($this->arrSearchData['name']) == 0) { 
     126            $this->arrSearch['name'] = "指定なし"; 
     127        } else { 
     128            $this->arrSearch['name'] = $this->arrSearchData['name']; 
    145129        } 
    146130 
     
    149133        $layout->sfGetPageLayout($this, false, "products/list.php"); 
    150134 
    151         if(isset($_POST['mode']) && $_POST['mode'] == "cart" 
    152            && $_POST['product_id'] != "") { 
    153  
    154             // 値の正当性チェック 
    155             if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 
     135        foreach ($this->arrProducts as $arrProduct) { 
     136            $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n"; 
     137        } 
     138         
     139        if ($this->inCart) { 
     140            // 商品IDの正当性チェック 
     141            if (!SC_Utils_Ex::sfIsInt($this->arrForm['product_id']) || !$objDb->sfIsRecord("dtb_products", "product_id", $this->arrForm['product_id'], "del_flg = 0 AND status = 1")) { 
    156142                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 
    157             } else { 
    158                 // 入力値の変換 
    159                 $this->arrErr = $this->lfCheckError($_POST['product_id']); 
    160                 if(count($this->arrErr) == 0) { 
    161                     $objCartSess = new SC_CartSession(); 
    162                     $classcategory_id = "classcategory_id". $_POST['product_id']; 
    163                     $classcategory_id1 = $_POST[$classcategory_id. '_1']; 
    164                     $classcategory_id2 = $_POST[$classcategory_id. '_2']; 
    165                     $quantity = "quantity". $_POST['product_id']; 
     143            } 
     144            $product_id = $this->arrForm['product_id']; 
     145            // 入力内容のチェック 
     146            $arrErr = $this->lfCheckError($product_id); 
     147            if (count($arrErr) == 0) { 
     148                $classcategory_id1 = $this->arrForm['classcategory_id1']; 
     149                $classcategory_id2 = $this->arrForm['classcategory_id2']; 
    166150                    // 規格1が設定されていない場合 
    167                     if(!$this->tpl_classcat_find1[$_POST['product_id']]) { 
     151                if (!$this->tpl_classcat_find1[$product_id]) { 
    168152                        $classcategory_id1 = '0'; 
    169153                    } 
    170154                    // 規格2が設定されていない場合 
    171                     if(!$this->tpl_classcat_find2[$_POST['product_id']]) { 
     155                if (!$this->tpl_classcat_find2[$product_id]) { 
    172156                        $classcategory_id2 = '0'; 
    173157                    } 
    174                     $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); 
    175                     $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); 
     158                $objCartSess = new SC_CartSession(); 
     159                $objCartSess->addProduct(array($product_id, $classcategory_id1, $classcategory_id2), $this->arrForm['quantity']); 
    176160                    $this->sendRedirect($this->getLocation(URL_CART_TOP)); 
    177161                    exit; 
     162            } 
     163            foreach (array_keys($this->arrProducts) as $key) { 
     164                $arrProduct =& $this->arrProducts[$key]; 
     165                if ($arrProduct['product_id'] == $product_id) { 
     166                    $arrProduct['classcategory_id1'] = $this->arrForm['classcategory_id1']; 
     167                    $arrProduct['classcategory_id2'] = $this->arrForm['classcategory_id2']; 
     168                    $arrProduct['quantity'] = $this->arrForm['quantity']; 
     169                    $arrProduct['arrErr'] = $arrErr; 
     170                    $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']}, '{$this->arrForm['classcategory_id2']}');\n"; 
    178171                } 
    179172            } 
    180173        } 
    181  
    182         $this->tpl_subtitle = $tpl_subtitle; 
    183  
    184         // 支払方法の取得 
    185         $this->arrPayment = $this->lfGetPayment(); 
    186         // 入力情報を渡す 
    187         $this->arrForm = $_POST; 
    188  
    189         $this->lfConvertParam(); 
    190  
    191         $this->category_id = $arrCategory_id[0]; 
    192         $this->arrSearch = $arrSearch; 
     174        $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}'; 
     175        $this->tpl_onload .= 'fnOnLoad(); '; 
     176 
     177        $this->tpl_rnd = SC_Utils_Ex::sfGetRandomString(3); 
    193178 
    194179        $objView->assignobj($this); 
     
    213198     */ 
    214199    function mobileProcess() { 
     200        $this->lfLoadParam(); 
     201 
    215202        $objView = new SC_MobileView(); 
    216203        $conn = new SC_DBConn(); 
    217204        $objDb = new SC_Helper_DB_Ex(); 
    218205 
    219         //表示件数の選択 
    220         if(isset($_REQUEST['disp_number']) 
    221            && SC_Utils_Ex::sfIsInt($_REQUEST['disp_number'])) { 
    222             $this->disp_number = $_REQUEST['disp_number']; 
    223         } else { 
    224             //最小表示件数を選択 
    225             $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); 
    226         } 
    227  
    228         //表示順序の保存 
    229         $this->orderby = isset($_REQUEST['orderby']) ? $_REQUEST['orderby'] : ""; 
    230  
    231         // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 
    232         $arrCategory_id = $objDb->sfGetCategoryId("", $_GET['category_id']); 
    233  
    234  
    235206        // タイトル編集 
    236         $tpl_subtitle = ""; 
    237207        $tpl_search_mode = false; 
    238208 
    239         if (!isset($_GET['mode'])) $_GET['mode'] = ""; 
    240         if (!isset($_POST['mode'])) $_POST['mode'] = ""; 
    241         if (!isset($_GET['name'])) $_GET['name'] = ""; 
    242         if (!isset($_REQUEST['orderby'])) $_REQUEST['orderby'] = ""; 
    243         if (empty($arrCategory_id)) $arrCategory_id = array("0"); 
    244  
    245         if($_GET['mode'] == 'search'){ 
    246             $tpl_subtitle = "検索結果"; 
     209        if ($this->mode == 'search') { 
     210            $this->tpl_subtitle = "検索結果"; 
    247211            $tpl_search_mode = true; 
    248         }elseif (empty($arrCategory_id[0])) { 
    249             $tpl_subtitle = "全商品"; 
    250         }else{ 
    251             $arrFirstCat = $objDb->sfGetFirstCat($arrCategory_id[0]); 
    252             $tpl_subtitle = $arrFirstCat['name']; 
     212        } elseif ($this->arrSearchData['category_id'] == 0) { 
     213            $this->tpl_subtitle = "全商品"; 
     214        } else { 
     215            $arrCat = $objDb->sfGetCat($this->arrSearchData['category_id']); 
     216            $this->tpl_subtitle = $arrCat['name']; 
    253217        } 
    254218 
    255219        $objQuery = new SC_Query(); 
    256         $count = $objQuery->count("dtb_best_products", "category_id = ?", $arrCategory_id); 
    257  
    258         // 以下の条件でBEST商品を表示する 
    259         // ・BEST最大数の商品が登録されている。 
    260         // ・カテゴリIDがルートIDである。 
    261         // ・検索モードでない。 
    262         if(($count >= BEST_MIN) && $this->lfIsRootCategory($arrCategory_id[0]) && ($_GET['mode'] != 'search') ) { 
    263             // 商品TOPの表示処理 
    264  
    265             $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $arrCategory_id[0]); 
    266             $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 
    267         } else { 
    268             if ($_GET['mode'] == 'search' && strlen($_GET['category_id']) == 0 ){ 
    269                 // 検索時にcategory_idがGETに存在しない場合は、仮に埋めたIDを空白に戻す 
    270                 $arrCategory_id = array(""); 
    271             } 
     220        $count = $objQuery->count("dtb_best_products", "category_id = ?", array($this->arrSearchData['category_id'])); 
    272221 
    273222            // 商品一覧の表示処理 
    274             $this->lfDispProductsList($arrCategory_id[0], $_GET['name'], $this->disp_number, $_REQUEST['orderby']); 
     223        $this->lfDispProductsList(); 
    275224 
    276225            // 検索条件を画面に表示 
    277226            // カテゴリー検索条件 
    278             if (strlen($_GET['category_id']) == 0) { 
    279                 $arrSearch['category'] = "指定なし"; 
    280             }else{ 
     227        if ($this->arrSearchData['category_id'] == 0) { 
     228            $this->arrSearch['category'] = "指定なし"; 
     229        } else { 
    281230                $arrCat = $conn->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?",array($category_id)); 
    282                 $arrSearch['category'] = $arrCat; 
     231            $this->arrSearch['category'] = $arrCat; 
    283232            } 
    284233 
    285234            // 商品名検索条件 
    286             if ($_GET['name'] === "") { 
    287                 $arrSearch['name'] = "指定なし"; 
    288             }else{ 
    289                 $arrSearch['name'] = $_GET['name']; 
    290             } 
    291         } 
    292  
    293         if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { 
    294             // 値の正当性チェック 
    295             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")) { 
    296                 SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND, "", false, "", true); 
     235        if ($this->arrForm['name'] === "") { 
     236            $this->arrSearch['name'] = "指定なし"; 
    297237            } else { 
    298                 // 入力値の変換 
    299                 $this->arrErr = $this->lfCheckError($_POST['product_id']); 
    300                 if(count($this->arrErr) == 0) { 
    301                     $objCartSess = new SC_CartSession(); 
    302                     $classcategory_id = "classcategory_id". $_POST['product_id']; 
    303                     $classcategory_id1 = $_POST[$classcategory_id. '_1']; 
    304                     $classcategory_id2 = $_POST[$classcategory_id. '_2']; 
    305                     $quantity = "quantity". $_POST['product_id']; 
    306                     // 規格1が設定されていない場合 
    307                     if(!$this->tpl_classcat_find1[$_POST['product_id']]) { 
    308                         $classcategory_id1 = '0'; 
     238            $this->arrSearch['name'] = $this->arrForm['name']; 
    309239                    } 
    310                     // 規格2が設定されていない場合 
    311                     if(!$this->tpl_classcat_find2[$_POST['product_id']]) { 
    312                         $classcategory_id2 = '0'; 
    313                     } 
    314                     $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); 
    315                     $objCartSess->addProduct(array($_POST['product_id'], $classcategory_id1, $classcategory_id2), $_POST[$quantity]); 
    316                     $this->sendRedirect(MOBILE_URL_CART_TOP, array(session_name() => session_id())); 
    317                     exit; 
    318                 } 
    319             } 
    320         } 
    321  
    322240 
    323241        // ページ送り機能用のURLを作成する。 
     
    339257        } 
    340258 
    341         $this->tpl_subtitle = $tpl_subtitle; 
    342259        $this->tpl_search_mode = $tpl_search_mode; 
    343260 
    344         // 支払方法の取得 
    345         $this->arrPayment = $this->lfGetPayment(); 
    346         // 入力情報を渡す 
    347         $this->arrForm = $_POST; 
    348  
    349         $this->category_id = $arrCategory_id[0]; 
    350         $this->arrSearch = $arrSearch; 
    351261        $this->tpl_mainpage = MOBILE_TEMPLATE_DIR . "products/list.tpl"; 
    352262 
     
    364274    } 
    365275 
    366     /* カテゴリIDがルートかどうかの判定 */ 
    367     function lfIsRootCategory($category_id) { 
    368         $objQuery = new SC_Query(); 
    369         $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($category_id)); 
    370         if($level == 1) { 
    371             return true; 
    372         } 
    373         return false; 
     276    /** 
     277     * カテゴリIDの取得 
     278     * 
     279     * @return integer カテゴリID 
     280     */ 
     281    function lfGetCategoryId($category_id) { 
     282        $objDb = new SC_Helper_DB_Ex(); 
     283         
     284        // 指定なしの場合、0 を返す 
     285        if ( 
     286            strlen($category_id) == 0 
     287            || (String) $category_id == '0' 
     288        ) { 
     289            return 0; 
     290        } 
     291         
     292        // 正当性チェック 
     293        if ( 
     294            !SC_Utils_Ex::sfIsInt($category_id) 
     295                || SC_Utils_Ex::sfIsZeroFilling($category_id) 
     296            || !$objDb->sfIsRecord('dtb_category', 'category_id', (array)$category_id, 'del_flg = 0') 
     297        ) { 
     298            SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); 
     299    } 
     300         
     301        // 指定されたカテゴリIDを元に正しいカテゴリIDを取得する。 
     302        $arrCategory_id = $objDb->sfGetCategoryId('', $category_id); 
     303         
     304        if (empty($arrCategory_id)) { 
     305            SC_Utils_Ex::sfDispSiteError(CATEGORY_NOT_FOUND); 
     306        } 
     307         
     308        return $arrCategory_id[0]; 
    374309    } 
    375310 
    376311    /* 商品一覧の表示 */ 
    377     function lfDispProductsList($category_id, $name, $disp_num, $orderby) { 
     312    function lfDispProductsList() { 
    378313 
    379314        $objQuery = new SC_Query(); 
    380315        $objDb = new SC_Helper_DB_Ex(); 
    381         $this->tpl_pageno = defined("MOBILE_SITE") ? @$_GET['pageno'] : @$_POST['pageno']; 
    382316        $arrval = array(); 
    383317        $arrval_order = array(); 
    384318        $arrval_category = array(); 
    385  
     319         
    386320        // カテゴリからのWHERE文字列取得 
    387  
    388         if ( $category_id ) { 
    389             list($tmp_where, $arrval_category) = $objDb->sfGetCatWhere($category_id); 
    390             if (strlen($tmp_where) >= 1) { 
    391                 $where_category = "AND $tmp_where"; 
    392                 //並び替え用(MySQL4.1対応) 
    393                 $where_category_order = "AND " ."T2.".trim($tmp_where); 
    394             } 
    395         } 
    396  
     321        if ($this->arrSearchData['category_id'] != 0) { 
     322            list($where_category, $arrval_category) = $objDb->sfGetCatWhere($this->arrSearchData['category_id']); 
     323        } 
     324         
    397325        // ▼対象商品IDの抽出 
    398326        // 商品検索条件の作成(未削除、表示) 
    399327        $where = "del_flg = 0 AND status = 1 "; 
    400  
     328         
    401329        // 在庫無し商品の非表示 
    402330        if (NOSTOCK_HIDDEN === true) { 
    403331            $where .= ' AND (stock_max >= 1 OR stock_unlimited_max = 1)'; 
    404332        } 
    405  
     333         
    406334        if (strlen($where_category) >= 1) { 
    407             $where.= " $where_category"; 
     335            $where.= " AND $where_category"; 
    408336            $arrval = array_merge($arrval, $arrval_category); 
    409337        } 
    410338 
    411339        // 商品名をwhere文に 
     340        $name = $this->arrSearchData['name']; 
    412341        $name = ereg_replace(",", "", $name);// XXX 
    413342        // 全角スペースを半角スペースに変換 
     
    417346        // 分割したキーワードを一つずつwhere文に追加 
    418347        foreach ($names as $val) { 
    419             if ( strlen($val) > 0 ){ 
     348            if ( strlen($val) > 0 ) { 
    420349                $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 
    421350                $ret = SC_Utils_Ex::sfManualEscape($val); 
     
    425354        } 
    426355 
     356        // メーカーらのWHERE文字列取得 
     357        if ($this->arrSearchData['maker_id']) { 
     358            $where .= " AND maker_id = ? "; 
     359            $arrval[] = $this->arrSearchData['maker_id']; 
     360        } 
     361         
     362        // 対象商品IDの抽出 
    427363        $arrProduct_id = $objQuery->getCol('vw_products_allclass AS allcls', 'DISTINCT product_id', $where, $arrval); 
    428         // ▲対象商品IDの抽出 
    429  
     364         
    430365        // 行数の取得 
    431366        $linemax = count($arrProduct_id); 
     
    434369 
    435370        // ページ送りの取得 
    436         $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 
    437  
     371        $urlParam = "category_id={$this->arrSearchData['category_id']}&pageno=#page#"; 
     372        $this->objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $this->disp_number, "fnNaviPage", NAVI_PMAX, $urlParam); 
    438373        $strnavi = $this->objNavi->strnavi; 
    439         $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 
     374 
    440375        // 表示文字列 
    441376        $this->tpl_strnavi = empty($strnavi) ? " " : $strnavi; 
    442377        $startno = $this->objNavi->start_row;                 // 開始行 
    443  
     378         
    444379        // ▼商品詳細取得 
    445380        $col = <<< __EOS__ 
     
    464399            ,point_rate 
    465400            ,sale_limit 
    466             ,sale_unlimited 
    467401            ,deliv_date_id 
    468402            ,deliv_fee 
     
    471405            ,del_flg 
    472406__EOS__; 
    473  
     407         
    474408        $from = "vw_products_allclass_detail AS alldtl"; 
    475  
     409         
    476410        // WHERE 句 
    477411        $where = '0=0'; 
     
    482416            $where .= ' AND 0<>0'; 
    483417        } 
    484  
    485         //表示順序 
    486         switch($orderby) { 
    487  
    488             //販売価格順 
     418         
     419        // 表示順序 
     420        switch ($this->orderby) { 
     421 
     422            // 販売価格順 
    489423            case 'price': 
    490424                $order = "price02_min, product_id"; 
    491425                break; 
    492426 
    493             //新着順 
     427            // 新着順 
    494428            case 'date': 
    495429                $order = "create_date DESC, product_id"; 
     
    497431 
    498432            default: 
     433                if (strlen($where_category) >= 1) { 
     434                    $dtb_product_categories = "(SELECT * FROM dtb_product_categories WHERE $where_category)"; 
     435                    $arrval_order = array_merge($arrval_category, $arrval_category); 
     436                } else { 
     437                    $dtb_product_categories = 'dtb_product_categories'; 
     438                } 
    499439                $order = <<< __EOS__ 
    500440                    ( 
     
    502442                             T3.rank 
    503443                        FROM 
    504                             dtb_product_categories T2 
     444                            $dtb_product_categories T2 
    505445                            JOIN dtb_category T3 
    506446                                USING (category_id) 
    507447                        WHERE T2.product_id = alldtl.product_id 
    508                             $where_category_order 
    509448                        ORDER BY T3.rank DESC, T2.rank DESC 
    510449                        LIMIT 1 
     
    514453                            T2.rank 
    515454                        FROM 
    516                             dtb_product_categories T2 
     455                            $dtb_product_categories T2 
    517456                            JOIN dtb_category T3 
    518457                                USING (category_id) 
    519458                        WHERE T2.product_id = alldtl.product_id 
    520                             $where_category_order 
    521459                        ORDER BY T3.rank DESC, T2.rank DESC 
    522460                        LIMIT 1 
     
    524462                    ,product_id 
    525463__EOS__; 
    526                 $arrval_order = array_merge($arrval_category, $arrval_category); 
    527464                break; 
    528465        } 
    529  
     466         
    530467        // 取得範囲の指定(開始行番号、行数のセット) 
    531         $objQuery->setlimitoffset($disp_num, $startno); 
     468        $objQuery->setlimitoffset($this->disp_number, $startno); 
    532469        // 表示順序 
    533470        $objQuery->setorder($order); 
    534  
     471         
    535472        // 検索結果の取得 
    536473        $this->arrProducts = $objQuery->select($col, $from, $where, $arrval_order); 
    537474        // ▲商品詳細取得 
    538  
    539         // 規格名一覧 
    540         $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); 
    541         // 規格分類名一覧 
    542         $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
     475         
     476        $arrProductId = array(); 
    543477        // 規格セレクトボックス設定 
    544         if($disp_num == 15) { 
    545             for($i = 0; $i < count($this->arrProducts); $i++) { 
    546                 $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); 
    547             } 
    548         } 
    549     } 
    550  
    551     /* 規格セレクトボックスの作成 */ 
    552     function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) { 
    553  
    554         $classcat_find1 = false; 
    555         $classcat_find2 = false; 
    556         // 在庫ありの商品の有無 
    557         $stock_find = false; 
    558  
    559         // 商品規格情報の取得 
    560         $arrProductsClass = $this->lfGetProductsClass($product_id); 
    561  
    562         // 規格1クラス名の取得 
    563         $this->tpl_class_name1[$product_id] = 
    564             isset($arrClassName[$arrProductsClass[0]['class_id1']]) 
    565             ? $arrClassName[$arrProductsClass[0]['class_id1']] 
    566             : ""; 
    567  
    568         // 規格2クラス名の取得 
    569         $this->tpl_class_name2[$product_id] = 
    570             isset($arrClassName[$arrProductsClass[0]['class_id2']]) 
    571             ? $arrClassName[$arrProductsClass[0]['class_id2']] 
    572             : ""; 
    573  
    574         // すべての組み合わせ数 
    575         $count = count($arrProductsClass); 
    576  
    577         $classcat_id1 = ""; 
    578  
    579         $arrSele = array(); 
    580         $arrList = array(); 
    581  
    582         $list_id = 0; 
    583         $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'"; 
    584         $arrVal[0] = "\tval". $product_id. "_0 = new Array(''"; 
    585  
    586         for ($i = 0; $i < $count; $i++) { 
    587             // 在庫のチェック 
    588             if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') { 
    589                 continue; 
    590             } 
    591  
    592             $stock_find = true; 
    593  
    594             // 規格1のセレクトボックス用 
    595             if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){ 
    596                 $arrList[$list_id].=");\n"; 
    597                 $arrVal[$list_id].=");\n"; 
    598                 $classcat_id1 = $arrProductsClass[$i]['classcategory_id1']; 
    599                 $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; 
    600                 $list_id++; 
    601  
    602                 $arrList[$list_id] = ""; 
    603                 $arrVal[$list_id] = ""; 
    604             } 
    605  
    606             // 規格2のセレクトボックス用 
    607             $classcat_id2 = $arrProductsClass[$i]['classcategory_id2']; 
    608  
    609             // セレクトボックス表示値 
    610             if($arrList[$list_id] == "") { 
    611                 $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'"; 
    612             } else { 
    613                 $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'"; 
    614             } 
    615  
    616             // セレクトボックスPOST値 
    617             if($arrVal[$list_id] == "") { 
    618                 $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'"; 
    619             } else { 
    620                 $arrVal[$list_id].= ", '".$classcat_id2."'"; 
    621             } 
    622         } 
    623  
    624         $arrList[$list_id].=");\n"; 
    625         $arrVal[$list_id].=");\n"; 
    626  
     478        foreach ($this->arrProducts as $product) { 
     479            $arrProductId[] = $product['product_id']; 
     480            // 購入制限数を取得 
     481            $this->lfGetSaleLimit($product); 
     482        } 
     483         
     484        require_once CLASS_PATH . 'SC_Product.php'; 
     485        $objProduct = new SC_Product($arrProductId); 
     486         
     487        // 規格1クラス名 
     488        $this->tpl_class_name1 = $objProduct->className1; 
     489 
     490        // 規格2クラス名 
     491        $this->tpl_class_name2 = $objProduct->className2; 
     492         
    627493        // 規格1 
    628         $this->arrClassCat1[$product_id] = $arrSele; 
    629  
    630         $lists = "\tlists".$product_id. " = new Array("; 
    631         $no = 0; 
    632         foreach($arrList as $val) { 
    633             $this->tpl_javascript.= $val; 
    634             if ($no != 0) { 
    635                 $lists.= ",list". $product_id. "_". $no; 
    636             } else { 
    637                 $lists.= "list". $product_id. "_". $no; 
    638             } 
    639             $no++; 
    640         } 
    641         $this->tpl_javascript.= $lists.");\n"; 
    642  
    643         $vals = "\tvals".$product_id. " = new Array("; 
    644         $no = 0; 
    645         foreach($arrVal as $val) { 
    646             $this->tpl_javascript.= $val; 
    647             if ($no != 0) { 
    648                 $vals.= ",val". $product_id. "_". $no; 
    649             } else { 
    650                 $vals.= "val". $product_id. "_". $no; 
    651             } 
    652             $no++; 
    653         } 
    654         $this->tpl_javascript.= $vals.");\n"; 
    655  
    656         // 選択されている規格2ID 
    657         $classcategory_id = "classcategory_id". $product_id; 
    658  
    659         $classcategory_id_2 = $classcategory_id . "_2"; 
    660         if (!isset($classcategory_id_2)) $classcategory_id_2 = ""; 
    661         if (!isset($_POST[$classcategory_id_2]) || !is_numeric($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = ""; 
    662  
    663         $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', " 
    664             . "'" . $classcategory_id_2 . "'," 
    665             . "'" . $product_id . "'," 
    666             . "'" . $_POST[$classcategory_id_2] ."'); "; 
     494        $this->arrClassCat1 = $objProduct->classCats1; 
    667495 
    668496        // 規格1が設定されている 
    669         if($arrProductsClass[0]['classcategory_id1'] != '0') { 
    670             $classcat_find1 = true; 
    671         } 
    672  
     497        $this->tpl_classcat_find1 = $objProduct->classCat1_find; 
    673498        // 規格2が設定されている 
    674         if($arrProductsClass[0]['classcategory_id2'] != '0') { 
    675             $classcat_find2 = true; 
    676         } 
    677  
    678         $this->tpl_classcat_find1[$product_id] = $classcat_find1; 
    679         $this->tpl_classcat_find2[$product_id] = $classcat_find2; 
    680         $this->tpl_stock_find[$product_id] = $stock_find; 
    681     } 
    682  
    683     /* 商品規格情報の取得 */ 
    684     function lfGetProductsClass($product_id) { 
    685         $arrRet = array(); 
    686         if(SC_Utils_Ex::sfIsInt($product_id)) { 
    687             // 商品規格取得 
    688             $objQuery = new SC_Query(); 
    689             $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited"; 
    690             $table = "vw_product_class AS prdcls"; 
    691             $where = "product_id = ?"; 
    692             $objQuery->setorder("rank1 DESC, rank2 DESC"); 
    693             $arrRet = $objQuery->select($col, $table, $where, array($product_id)); 
    694         } 
    695         return $arrRet; 
     499        $this->tpl_classcat_find2 = $objProduct->classCat2_find; 
     500 
     501        $this->tpl_stock_find = $objProduct->stock_find; 
     502 
     503        $productsClassCategories = $objProduct->classCategories; 
     504         
     505        require_once DATA_PATH . 'module/Services/JSON.php'; 
     506        $objJson = new Services_JSON(); 
     507        $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($productsClassCategories) . '; '; 
    696508    } 
    697509 
     
    700512 
    701513        // 入力データを渡す。 
    702         $objErr = new SC_CheckError(); 
    703  
    704         $classcategory_id1 = "classcategory_id". $id. "_1"; 
    705         $classcategory_id2 = "classcategory_id". $id. "_2"; 
    706         $quantity = "quantity". $id; 
     514        $objErr = new SC_CheckError($this->arrForm); 
     515 
    707516        // 複数項目チェック 
    708517        if ($this->tpl_classcat_find1[$id]) { 
    709             $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     518            $objErr->doFunc(array("規格1", 'classcategory_id1', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    710519        } 
    711520        if ($this->tpl_classcat_find2[$id]) { 
    712             $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    713         } 
    714         $objErr->doFunc(array("個数", $quantity, INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     521            $objErr->doFunc(array("規格2", 'classcategory_id2', INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     522        } 
     523        $objErr->doFunc(array("数量", 'quantity', INT_LEN), array("EXIST_CHECK", "ZERO_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    715524 
    716525        return $objErr->arrErr; 
    717526    } 
    718527 
    719     //支払方法の取得 
    720     //payment_id    1:代金引換 2:銀行振り込み 3:現金書留 
    721     function lfGetPayment() { 
    722         $objQuery = new SC_Query; 
    723         $col = "payment_id, rule, payment_method"; 
    724         $from = "dtb_payment"; 
    725         $where = "del_flg = 0"; 
    726         $order = "payment_id"; 
    727         $objQuery->setorder($order); 
    728         $arrRet = $objQuery->select($col, $from, $where); 
    729         return $arrRet; 
    730     } 
    731  
    732     function lfconvertParam () { 
    733         foreach ($this->arrForm as $key => $value) { 
    734             if (preg_match('/^quantity[0-9]+/', $key)) { 
    735                  $this->arrForm[$key] 
    736                     = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE); 
    737             } 
    738         } 
     528    // 購入制限数の設定 
     529    // XXX 標準実装では「tpl_sale_limit」は利用されていないようである。カスタマイズ用? 
     530    function lfGetSaleLimit($arrProduct) { 
     531        //在庫が無限または購入制限値が設定値より大きい場合 
     532        if (!SC_Utils_Ex::sfIsInt($arrProduct['sale_limit']) || $arrProduct['sale_limit'] > SALE_LIMIT_MAX) { 
     533            $this->tpl_sale_limit[$arrProduct['product_id']] = SALE_LIMIT_MAX; 
     534        } else { 
     535            $this->tpl_sale_limit[$arrProduct['product_id']] = $arrProduct['sale_limit']; 
     536        } 
     537    } 
     538 
     539    /** 
     540     * パラメータの読み込み 
     541     * 
     542     * @return void 
     543     */ 
     544    function lfLoadParam() { 
     545        $this->arrForm = $_GET; 
     546         
     547        $this->mode = $this->arrForm['mode']; 
     548        $this->arrSearchData['category_id'] = $this->lfGetCategoryId($this->arrForm['category_id']); 
     549        $this->arrSearchData['maker_id'] = $this->arrForm['maker_id']; 
     550        $this->arrSearchData['name'] = $this->arrForm['name']; 
     551        $this->orderby = $this->arrForm['orderby']; 
     552        // 表示件数 
     553        if ( 
     554            isset($this->arrForm['disp_number']) 
     555            && SC_Utils_Ex::sfIsInt($this->arrForm['disp_number']) 
     556        ) { 
     557            $this->disp_number = $this->arrForm['disp_number']; 
     558        } else { 
     559            //最小表示件数を選択 
     560            $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); 
     561        } 
     562        $this->tpl_pageno = $this->arrForm['pageno']; 
     563        $this->inCart = strlen($this->arrForm['product_id']) >= 1; 
    739564    } 
    740565} 
Note: See TracChangeset for help on using the changeset viewer.