Changeset 22589


Ignore:
Timestamp:
2013/03/01 10:01:07 (11 years ago)
Author:
pineray
Message:

#2166 再利用性を高めた形へ変更

Location:
branches/version-2_12-dev/data/class
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/helper/SC_Helper_Category.php

    r22588 r22589  
    3131class SC_Helper_Category 
    3232{ 
     33    private $count_check; 
     34 
     35    /** 
     36     * コンストラクター 
     37     *  
     38     * @param boolean $count_check 登録商品数をチェックする場合はtrue 
     39     */ 
     40    function __construct($count_check = FALSE) 
     41    { 
     42        $this->count_check = $count_check; 
     43    } 
     44 
    3345    /** 
    3446     * カテゴリー一覧の取得. 
    3547     *  
    36      * @param boolean $count_check 登録商品数をチェックする場合はtrue 
    3748     * @param boolean $cid_to_key 配列のキーをカテゴリーIDにする場合はtrue 
    3849     * @return array カテゴリー一覧の配列 
    3950     */ 
    40     public function getList($count_check = FALSE, $cid_to_key = FALSE) 
     51    public function getList($cid_to_key = FALSE) 
    4152    { 
    4253        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     
    4455        $from = 'dtb_category left join dtb_category_total_count ON dtb_category.category_id = dtb_category_total_count.category_id'; 
    4556        // 登録商品数のチェック 
    46         if ($count_check) { 
     57        if ($this->count_check) { 
    4758            $where = 'del_flg = 0 AND product_count > 0'; 
    4859        } else { 
     
    5465        if ($cid_to_key) { 
    5566            // 配列のキーをカテゴリーIDに 
    56             $arrTmp = array(); 
    57             foreach ($arrCategory as $category) { 
    58                 $arrTmp[$category['category_id']] = $category; 
    59             } 
    60             $arrCategory =& $arrTmp; 
    61             unset($arrTmp); 
     67            $arrCategory = SC_Utils_Ex::makeArrayIDToKey('category_id', $arrCategory); 
    6268        } 
    6369         
     
    6874     * カテゴリーツリーの取得. 
    6975     *  
    70      * @param boolean $count_check 登録商品数をチェックする場合はtrue 
    7176     * @return type 
    7277     */ 
    73     public function getTree($count_check = FALSE) 
     78    public function getTree() 
    7479    { 
    75         $arrList = $this->getList($count_check); 
     80        $arrList = $this->getList(); 
    7681        $arrTree = SC_Utils_Ex::buildTree('category_id', 'parent_category_id', LEVEL_MAX, $arrList); 
    7782        return $arrTree; 
  • branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php

    r22588 r22589  
    131131    { 
    132132        $objDb = new SC_Helper_DB_Ex(); 
    133         $objCategory = new SC_Helper_Category_Ex(); 
    134         $arrTree = $objCategory->getTree($count_check); 
    135  
    136         $arrCategory = $objCategory->getList($count_check); 
     133        $objCategory = new SC_Helper_Category_Ex($count_check); 
     134        $arrTree = $objCategory->getTree(); 
     135 
     136        $arrCategory = $objCategory->getList(); 
    137137        foreach ($arrParentCategoryId as $category_id) { 
    138138            $arrParentID = $objDb->sfGetParents( 
  • branches/version-2_12-dev/data/class/util/SC_Utils.php

    r22586 r22589  
    19241924 
    19251925    /** 
     1926     * カテゴリーツリー状の配列を作成. 
    19261927     *  
    19271928     * @param string $primary_key 
     
    19661967        } 
    19671968    } 
     1969 
     1970    /** 
     1971     * 配列のキーをIDにした配列を作成. 
     1972     *  
     1973     * @param string $ID_name IDが格納されているキー名 
     1974     * @param array $correction 元の配列 
     1975     * @return array 
     1976     */ 
     1977    public static function makeArrayIDToKey($ID_name, $correction = array()) 
     1978    { 
     1979        $arrTmp = array(); 
     1980        foreach ($correction as $item) { 
     1981            $arrTmp[$item[$ID_name]] = $item; 
     1982        } 
     1983        $return =& $arrTmp; 
     1984        unset($arrTmp); 
     1985        return $return; 
     1986    } 
    19681987} 
Note: See TracChangeset for help on using the changeset viewer.