Changeset 20187


Ignore:
Timestamp:
2011/02/18 07:55:52 (13 years ago)
Author:
tao
Message:

refs #982 疑問だらけだけどとりあえずコミット

File:
1 edited

Legend:

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

    r20116 r20187  
    9595     */ 
    9696    function action() { 
    97         $this->lfLoadParam(); 
    98         $objQuery = new SC_Query(); 
    99         $objDb = new SC_Helper_DB_Ex(); 
    100  
    101         // タイトル編集 
    102         if ($this->mode == 'search') { 
    103             $this->tpl_subtitle = "検索結果"; 
    104         } elseif ($this->arrSearchData['category_id'] == 0) { 
    105             $this->tpl_subtitle = "全商品"; 
    106         } else { 
    107             $arrCat = $objDb->sfGetCat($this->arrSearchData['category_id']); 
    108             $this->tpl_subtitle = $arrCat['name']; 
    109         } 
    110  
    111         $count = $objQuery->count("dtb_best_products", "category_id = ?", array($this->arrSearchData['category_id'])); 
     97        $this->arrForm = $_GET; 
     98        //modeの取得 
     99        $this->mode = $this->getMode(); 
     100         
     101        //表示条件の取得 
     102        $this->arrSearchData = array( 
     103            'category_id' => $this->lfGetCategoryId($this->arrForm['category_id']), 
     104            'maker_id'=>$this->arrForm['maker_id'], 
     105            'name'=>$this->arrForm['name'] 
     106        ); 
     107        $this->orderby = $this->arrForm['orderby']; 
     108         
     109        //ページング設定 
     110        $this->tpl_pageno = $this->arrForm['pageno']; 
     111        $this->disp_number = $this->lfGetDisplayNum($this->arrForm['disp_number']); 
     112         
     113        $objQuery = new SC_Query();//$this->queryにしたい 
     114        $objDb = new SC_Helper_DB_Ex();//$this->helperDBにしたい 
     115 
     116        // 画面に表示するサブタイトルの設定 
     117        $this->tpl_subtitle = $this->lfGetPageTitle($this->mode,$this->arrSearchData['category_id'],$objDb); 
     118 
     119        // 画面に表示する検索条件を設定 
     120        $this->arrSearch = $this->lfGetSearchCondition($this->arrSearchData,$objQuery); 
     121        //この辺まではinit()に書いちゃダメなのかな? 
     122//2011-02-17 ここまでやった 
    112123 
    113124        // 商品一覧の表示処理 
    114         $this->lfDispProductsList(); 
    115  
    116         // 検索条件を画面に表示 
    117         // カテゴリー検索条件 
    118         if ($this->arrSearchData['category_id'] == 0) { 
    119             $this->arrSearch['category'] = "指定なし"; 
    120         } else { 
    121             $arrCat = $objQuery->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($this->arrSearchData['category_id'])); 
    122             $this->arrSearch['category'] = $arrCat; 
    123         } 
    124  
    125         // メーカー検索条件 
    126         if (strlen($this->arrSearchData['maker_id']) == 0) { 
    127             $this->arrSearch['maker'] = "指定なし"; 
    128         } else { 
    129             $this->arrSearch['maker'] = $objQuery->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", $this->arrSearchData['maker_id']); 
    130         } 
    131  
    132         // 商品名検索条件 
    133         if (strlen($this->arrSearchData['name']) == 0) { 
    134             $this->arrSearch['name'] = "指定なし"; 
    135         } else { 
    136             $this->arrSearch['name'] = $this->arrSearchData['name']; 
    137         } 
    138  
     125        $this->arrProducts = $this->lfGetProductsList($objDb); 
     126 
     127        //onloadスクリプトを設定 
    139128        foreach ($this->arrProducts as $arrProduct) { 
    140129            $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n"; 
    141         } 
    142  
    143         if ($this->inCart) { 
     130        }     
     131 
     132        //カート処理 
     133        if (intval($this->arrForm['product_id']) > 0) { 
    144134            // 商品IDの正当性チェック 
    145135            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")) { 
     
    214204     */ 
    215205    function lfGetCategoryId($category_id) { 
    216         $objDb = new SC_Helper_DB_Ex(); 
    217206 
    218207        // 指定なしの場合、0 を返す 
     
    244233 
    245234    /* 商品一覧の表示 */ 
    246     function lfDispProductsList() { 
    247         $objDb = new SC_Helper_DB_Ex(); 
     235    function lfGetProductsList($objDb) { 
    248236        $arrval = array(); 
    249237        $arrval_order = array(); 
     
    437425     * @return void 
    438426     */ 
    439     function lfLoadParam() { 
    440         $this->arrForm = $_GET; 
    441  
    442         $this->mode = $this->getMode(); 
    443         $this->arrSearchData['category_id'] = $this->lfGetCategoryId($this->arrForm['category_id']); 
    444         $this->arrSearchData['maker_id'] = $this->arrForm['maker_id']; 
    445         $this->arrSearchData['name'] = $this->arrForm['name']; 
    446         $this->orderby = $this->arrForm['orderby']; 
     427    function lfGetDisplayNum($display_number) { 
    447428        // 表示件数 
    448         if ( 
    449             isset($this->arrForm['disp_number']) 
    450             && SC_Utils_Ex::sfIsInt($this->arrForm['disp_number']) 
     429        if (!isset($display_number) 
     430            OR !SC_Utils_Ex::sfIsInt($display_number) 
    451431        ) { 
    452             $this->disp_number = $this->arrForm['disp_number']; 
    453         } else { 
    454432            //最小表示件数を選択 
    455             $this->disp_number = current(array_keys($this->arrPRODUCTLISTMAX)); 
    456         } 
    457         $this->tpl_pageno = $this->arrForm['pageno']; 
    458         $this->inCart = strlen($this->arrForm['product_id']) >= 1; 
     433            return current(array_keys($this->arrPRODUCTLISTMAX)); 
     434        } 
     435        return $display_number; 
    459436    } 
    460437 
     
    483460        } 
    484461    } 
     462 
     463    /** 
     464     * ページタイトルの設定 
     465     * 
     466     * @return str 
     467     */     
     468    function lfGetPageTitle($mode,$category_id = 0,$objDb){ 
     469        if ($mode == 'search') { 
     470            return "検索結果"; 
     471        } elseif ($category_id == 0) { 
     472            return "全商品"; 
     473        } else { 
     474            $arrCat = $objDb->sfGetCat($category_id); 
     475            return $arrCat['name']; 
     476        } 
     477        return "";        
     478    } 
     479 
     480    /** 
     481     * 検索条件の設定 
     482     * 
     483     * @return array 
     484     */     
     485    function lfGetSearchCondition($arrSearchData,$objQuery){ 
     486        $arrSearch = array('category'=>"指定なし",'maker'=>"指定なし",'name'=>"指定なし"); 
     487        // カテゴリー検索条件 
     488        if ($arrSearchData['category_id'] > 0) { 
     489            $arrSearch['category'] = $objQuery->getOne("SELECT category_name FROM dtb_category WHERE category_id = ?", array($arrSearchData['category_id'])); 
     490        } 
     491 
     492        // メーカー検索条件 
     493        if (strlen($arrSearchData['maker_id']) > 0) { 
     494            $arrSearch['maker'] = $objQuery->getOne("SELECT name FROM dtb_maker WHERE maker_id = ?", array($arrSearchData['maker_id'])); 
     495        } 
     496 
     497        // 商品名検索条件 
     498        if (strlen($arrSearchData['name']) > 0) { 
     499            $arrSearch['name'] = $arrSearchData['name']; 
     500        } 
     501        return $arrSearch; 
     502    } 
    485503} 
    486504?> 
Note: See TracChangeset for help on using the changeset viewer.