Ignore:
Timestamp:
2013/03/05 09:21:53 (11 years ago)
Author:
pineray
Message:

#2166 同じ処理を繰り返さないようにスタティック変数を使用.

File:
1 edited

Legend:

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

    r22597 r22603  
    7171    public function getList($cid_to_key = FALSE) 
    7272    { 
    73         static $arrCategory = array(); 
     73        static $arrCategory = array(), $cidIsKey = array(); 
    7474 
    7575        if (!isset($arrCategory[$this->count_check])) { 
     
    9090 
    9191        if ($cid_to_key) { 
    92             // 配列のキーをカテゴリーIDに 
    93             return SC_Utils_Ex::makeArrayIDToKey('category_id', $arrCategory[$this->count_check]); 
     92            if (!isset($cidIsKey[$this->count_check])) { 
     93                // 配列のキーをカテゴリーIDに 
     94                $cidIsKey[$this->count_check] = SC_Utils_Ex::makeArrayIDToKey('category_id', $arrCategory[$this->count_check]); 
     95            } 
     96            return $cidIsKey[$this->count_check]; 
    9497        } 
    9598 
     
    104107    public function getTree() 
    105108    { 
    106         $arrList = $this->getList(); 
    107         $arrTree = SC_Utils_Ex::buildTree('category_id', 'parent_category_id', LEVEL_MAX, $arrList); 
    108         return $arrTree; 
     109        static $arrTree = array(); 
     110        if (!isset($arrTree[$this->count_check])) { 
     111            $arrList = $this->getList(); 
     112            $arrTree[$this->count_check] = SC_Utils_Ex::buildTree('category_id', 'parent_category_id', LEVEL_MAX, $arrList); 
     113        } 
     114        return $arrTree[$this->count_check]; 
    109115    } 
    110116 
     
    118124    public function getTreeTrail($category_id, $id_only = TRUE) 
    119125    { 
    120         $arrCategory = $this->getList(); 
    121         $arrTrailID = SC_Utils_Ex::getTreeTrail($category_id, 'category_id', 'parent_category_id', $arrCategory, 0, $id_only); 
     126        $arrCategory = $this->getList(TRUE); 
     127        $arrTrailID = SC_Utils_Ex::getTreeTrail($category_id, 'category_id', 'parent_category_id', $arrCategory, TRUE, 0, $id_only); 
    122128        return $arrTrailID; 
    123129    } 
Note: See TracChangeset for help on using the changeset viewer.