Ignore:
Timestamp:
2007/08/24 13:08:14 (17 years ago)
Author:
nanasess
Message:

リファクタリングと Bugfix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/pages/products/LC_Page_Products_List.php

    r15154 r15344  
    2020    // {{{ properties 
    2121 
    22     // TODO 
    23     var $arrSTATUS = array(); 
    24     var $arrSTATUS_IMAGE = array(); 
    25     var $arrDELIVERYDATE = array(); 
    26     var $arrPRODUCTLISTMAX = array(); 
     22    /** テンプレートクラス名1 */ 
     23    var $tpl_class_name1; 
     24 
     25    /** テンプレートクラス名2 */ 
     26    var $tpl_class_name2; 
     27 
     28    /** JavaScript テンプレート */ 
     29    var $tpl_javascript; 
    2730 
    2831    // }}} 
     
    3639    function init() { 
    3740        parent::init(); 
    38         session_cache_limiter('private-no-expire'); 
    39         $this->arrPRODUCTLISTMAX = array(15 => '15件', 
    40                                          30 => '30件', 
    41                                          50 => '50件'); 
     41 
     42        $masterData = new SC_DB_MasterData_Ex(); 
     43        $this->arrSTATUS = $masterData->getMasterData("mtb_status"); 
     44        $this->arrSTATUS_IMAGE = $masterData->getMasterData("mtb_status_image"); 
     45        $this->arrDELIVERYDATE = $masterData->getMasterData("mtb_delivery_date"); 
     46        $this->arrPRODUCTLISTMAX = $masterData->getMasterData("mtb_product_list_max"); 
     47 
     48        $this->tpl_class_name1 = array(); 
     49        $this->tpl_class_name2 = array(); 
     50        $this->allowClientCache(); 
    4251    } 
    4352 
     
    5160 
    5261        //表示件数の選択 
    53         if(SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { 
     62        if(isset($_POST['disp_number']) 
     63           && SC_Utils_Ex::sfIsInt($_POST['disp_number'])) { 
    5464            $this->disp_number = $_POST['disp_number']; 
    5565        } else { 
     
    5969 
    6070        //表示順序の保存 
    61         $this->orderby = $_POST['orderby']; 
     71        $this->orderby = isset($_POST['orderby']) ? $_POST['orderby'] : ""; 
    6272 
    6373        // GETのカテゴリIDを元に正しいカテゴリIDを取得する。 
    6474        $category_id = SC_Utils_Ex::sfGetCategoryId("", $_GET['category_id']); 
    6575 
     76        if (!isset($_GET['mode'])) $_GET['mode'] = ""; 
     77        if (!isset($_GET['name'])) $_GET['name'] = ""; 
     78        if (!isset($_POST['orderby'])) $_POST['orderby'] = ""; 
     79 
    6680        // タイトル編集 
    6781        $tpl_subtitle = ""; 
    68         if($_GET['mode'] == 'search'){ 
     82        if ($_GET['mode'] == 'search') { 
    6983            $tpl_subtitle = "検索結果"; 
    70         }elseif ($category_id == "" ) { 
     84        } elseif ($category_id == "" ) { 
    7185            $tpl_subtitle = "全商品"; 
    72         }else{ 
     86        } else { 
    7387            $arrFirstCat = SC_Utils_Ex::sfGetFirstCat($category_id); 
    7488            $tpl_subtitle = $arrFirstCat['name']; 
     
    8296        // ・カテゴリIDがルートIDである。 
    8397        // ・検索モードでない。 
    84         if(($count >= BEST_MIN) && lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) { 
     98        if(($count >= BEST_MIN) && $this->lfIsRootCategory($category_id) && ($_GET['mode'] != 'search') ) { 
    8599            // 商品TOPの表示処理 
    86100            /** 必ず指定する **/ 
    87101            $this->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // メインテンプレート 
    88102 
    89             $this->arrBestItems = sfGetBestProducts($conn, $category_id); 
     103            $this->arrBestItems = SC_Utils_Ex::sfGetBestProducts($conn, $category_id); 
    90104            $this->BEST_ROOP_MAX = ceil((BEST_MAX-1)/2); 
    91105        } else { 
     
    119133        $this = $layout->sfGetPageLayout($this, false, "products/list.php"); 
    120134 
    121         if($_POST['mode'] == "cart" && $_POST['product_id'] != "") { 
     135        if(isset($_POST['mode']) && $_POST['mode'] == "cart"  
     136           && $_POST['product_id'] != "") { 
     137             
    122138            // 値の正当性チェック 
    123             if(!sfIsInt($_POST['product_id']) || !sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 
    124                 sfDispSiteError(PRODUCT_NOT_FOUND); 
     139            if(!SC_Utils_Ex::sfIsInt($_POST['product_id']) || !SC_Utils_Ex::sfIsRecord("dtb_products", "product_id", $_POST['product_id'], "del_flg = 0 AND status = 1")) { 
     140                SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND); 
    125141            } else { 
    126142                // 入力値の変換 
    127                 $this->arrErr = lfCheckError($_POST['product_id']); 
     143                $this->arrErr = $this->lfCheckError($_POST['product_id']); 
    128144                if(count($this->arrErr) == 0) { 
    129145                    $objCartSess = new SC_CartSession(); 
     
    185201    /* 商品一覧の表示 */ 
    186202    function lfDispProductsList($category_id, $name, $disp_num, $orderby) { 
    187         global $objPage; 
     203 
    188204        $objQuery = new SC_Query(); 
    189         $objPage->tpl_pageno = $_POST['pageno']; 
     205        $objDb = new SC_Helper_DB_Ex(); 
     206        $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : ""; 
    190207 
    191208        //表示件数でテンプレートを切り替える 
    192         $objPage->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // メインテンプレート 
     209        $this->tpl_mainpage = HTML_PATH . "user_data/templates/list.tpl";        // メインテンプレート 
    193210 
    194211        //表示順序 
     
    221238        if ( strlen($name) > 0 ){ 
    222239            $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 
    223             $ret = sfManualEscape($name); 
     240            $ret = SC_Utils_Ex::sfManualEscape($name); 
    224241            $arrval[] = "%$ret%"; 
    225242            $arrval[] = "%$ret%"; 
     
    228245        // 行数の取得 
    229246        $linemax = $objQuery->count("vw_products_allclass AS allcls", $where, $arrval); 
    230         $objPage->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
     247        $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用 
    231248 
    232249        // ページ送りの取得 
    233         $objNavi = new SC_PageNavi($_POST['pageno'], $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 
     250        $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $disp_num, "fnNaviPage", NAVI_PMAX); 
    234251 
    235252        $strnavi = $objNavi->strnavi; 
    236253        $strnavi = str_replace('onclick="fnNaviPage', 'onclick="form1.mode.value=\''.'\'; fnNaviPage', $strnavi); 
    237         $objPage->tpl_strnavi = $strnavi;       // 表示文字列 
     254        $this->tpl_strnavi = $strnavi;       // 表示文字列 
    238255        $startno = $objNavi->start_row;                 // 開始行 
    239256 
     
    243260        $objQuery->setorder($order); 
    244261 
    245  
    246  
    247  
    248  
    249  
    250  
    251  
    252262        // 検索結果の取得 
    253         $objPage->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval); 
     263        $this->arrProducts = $objQuery->select("*", "vw_products_allclass AS allcls", $where, $arrval); 
    254264 
    255265        // 規格名一覧 
    256         $arrClassName = SC_Utils_Ex::sfGetIDValueList("dtb_class", "class_id", "name"); 
     266        $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); 
    257267        // 規格分類名一覧 
    258         $arrClassCatName = SC_Utils_Ex::sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
     268        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); 
    259269        // 企画セレクトボックス設定 
    260270        if($disp_num == 15) { 
    261             for($i = 0; $i < count($objPage->arrProducts); $i++) { 
    262                 $objPage = $this->lfMakeSelect($objPage->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); 
     271            for($i = 0; $i < count($this->arrProducts); $i++) { 
     272                $this = $this->lfMakeSelect($this->arrProducts[$i]['product_id'], $arrClassName, $arrClassCatName); 
    263273                // 購入制限数を取得 
    264                 $objPage = $this->lfGetSaleLimit($objPage->arrProducts[$i]); 
    265             } 
    266         } 
    267  
    268         return $objPage; 
     274                $this = $this->lfGetSaleLimit($this->arrProducts[$i]); 
     275            } 
     276        } 
     277 
     278        return $this; 
    269279    } 
    270280 
    271281    /* 規格セレクトボックスの作成 */ 
    272282    function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) { 
    273         global $objPage; 
    274283 
    275284        $classcat_find1 = false; 
     
    282291 
    283292        // 規格1クラス名の取得 
    284         $objPage->tpl_class_name1[$product_id] = $arrClassName[$arrProductsClass[0]['class_id1']]; 
     293        $this->tpl_class_name1[$product_id] = 
     294            isset($arrClassName[$arrProductsClass[0]['class_id1']]) 
     295            ? $arrClassName[$arrProductsClass[0]['class_id1']] 
     296            : ""; 
     297 
    285298        // 規格2クラス名の取得 
    286         $objPage->tpl_class_name2[$product_id] = $arrClassName[$arrProductsClass[0]['class_id2']]; 
     299        $this->tpl_class_name2[$product_id] = 
     300            isset($arrClassName[$arrProductsClass[0]['class_id2']]) 
     301            ? $arrClassName[$arrProductsClass[0]['class_id2']] 
     302            : ""; 
    287303 
    288304        // すべての組み合わせ数 
     
    313329                $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1]; 
    314330                $list_id++; 
     331 
     332                $arrList[$list_id] = ""; 
     333                $arrVal[$list_id] = ""; 
    315334            } 
    316335 
     
    337356 
    338357        // 規格1 
    339         $objPage->arrClassCat1[$product_id] = $arrSele; 
     358        $this->arrClassCat1[$product_id] = $arrSele; 
    340359 
    341360        $lists = "\tlists".$product_id. " = new Array("; 
    342361        $no = 0; 
    343362        foreach($arrList as $val) { 
    344             $objPage->tpl_javascript.= $val; 
     363            $this->tpl_javascript.= $val; 
    345364            if ($no != 0) { 
    346365                $lists.= ",list". $product_id. "_". $no; 
     
    350369            $no++; 
    351370        } 
    352         $objPage->tpl_javascript.= $lists.");\n"; 
     371        $this->tpl_javascript.= $lists.");\n"; 
    353372 
    354373        $vals = "\tvals".$product_id. " = new Array("; 
    355374        $no = 0; 
    356375        foreach($arrVal as $val) { 
    357             $objPage->tpl_javascript.= $val; 
     376            $this->tpl_javascript.= $val; 
    358377            if ($no != 0) { 
    359378                $vals.= ",val". $product_id. "_". $no; 
     
    363382            $no++; 
    364383        } 
    365         $objPage->tpl_javascript.= $vals.");\n"; 
     384        $this->tpl_javascript.= $vals.");\n"; 
    366385 
    367386        // 選択されている規格2ID 
    368387        $classcategory_id = "classcategory_id". $product_id; 
    369         $objPage->tpl_onload .= "lnSetSelect('".$classcategory_id."_1','".$classcategory_id."_2','".$product_id."','".$_POST[$classcategory_id."_2"]."'); "; 
     388 
     389        $classcategory_id_2 = $classcategory_id . "_2"; 
     390        if (!isset($$classcategory_id_2)) $$classcategory_id_2 = ""; 
     391        if (!isset($_POST[$$classcategory_id_2])) $_POST[$$classcategory_id_2] = ""; 
     392 
     393        $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', " 
     394            . "'" . $$classcategory_id_2 . "'," 
     395            . "'" . $product_id . "'," 
     396            . "'" . $_POST[$$classcategory_id_2] ."'); "; 
    370397 
    371398        // 規格1が設定されている 
     
    379406        } 
    380407 
    381         $objPage->tpl_classcat_find1[$product_id] = $classcat_find1; 
    382         $objPage->tpl_classcat_find2[$product_id] = $classcat_find2; 
    383         $objPage->tpl_stock_find[$product_id] = $stock_find; 
    384  
    385         return $objPage; 
     408        $this->tpl_classcat_find1[$product_id] = $classcat_find1; 
     409        $this->tpl_classcat_find2[$product_id] = $classcat_find2; 
     410        $this->tpl_stock_find[$product_id] = $stock_find; 
     411 
     412        return $this; 
    386413    } 
    387414    /* 商品規格情報の取得 */ 
     
    402429    /* 入力内容のチェック */ 
    403430    function lfCheckError($id) { 
    404         global $objPage; 
    405431 
    406432        // 入力データを渡す。 
     
    411437        $quantity = "quantity". $id; 
    412438        // 複数項目チェック 
    413         if ($objPage->tpl_classcat_find1[$id]) { 
     439        if ($this->tpl_classcat_find1[$id]) { 
    414440            $objErr->doFunc(array("規格1", $classcategory_id1, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    415441        } 
    416         if ($objPage->tpl_classcat_find2[$id]) { 
     442        if ($this->tpl_classcat_find2[$id]) { 
    417443            $objErr->doFunc(array("規格2", $classcategory_id2, INT_LEN), array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    418444        } 
     
    424450    // 購入制限数の設定 
    425451    function lfGetSaleLimit($product) { 
    426         global $objPage; 
    427452        //在庫が無限または購入制限値が設定値より大きい場合 
    428453        if($product['sale_unlimited'] == 1 || $product['sale_limit'] > SALE_LIMIT_MAX) { 
    429             $objPage->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX; 
     454            $this->tpl_sale_limit[$product['product_id']] = SALE_LIMIT_MAX; 
    430455        } else { 
    431             $objPage->tpl_sale_limit[$product['product_id']] = $product['sale_limit']; 
    432         } 
    433  
    434         return $objPage; 
     456            $this->tpl_sale_limit[$product['product_id']] = $product['sale_limit']; 
     457        } 
     458 
     459        return $this; 
    435460    } 
    436461 
     
    449474 
    450475    function lfconvertParam () { 
    451         global $objPage; 
    452  
    453         foreach ($objPage->arrForm as $key => $value) { 
     476        foreach ($this->arrForm as $key => $value) { 
    454477            if (preg_match('/^quantity[0-9]+/', $key)) { 
    455                  $objPage->arrForm[$key] 
    456                     = htmlspecialchars($objPage->arrForm[$key], ENT_QUOTES, CHAR_CODE); 
     478                 $this->arrForm[$key] 
     479                    = htmlspecialchars($this->arrForm[$key], ENT_QUOTES, CHAR_CODE); 
    457480            } 
    458481        } 
Note: See TracChangeset for help on using the changeset viewer.