Ignore:
Timestamp:
2007/08/10 18:33:39 (17 years ago)
Author:
nanasess
Message:

リファクタリング

Location:
branches/feature-module-update/data/class
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/SC_View.php

    r15257 r15279  
    122122 
    123123        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl'; 
    124         $array['tpl_root_id'] = SC_Utils_Ex::sfGetRootId(); 
     124 
     125        $objDb = new SC_Helper_DB_Ex(); 
     126        $array['tpl_root_id'] = $objDb->sfGetRootId(); 
    125127        $this->assignarray($array); 
    126128    } 
  • branches/feature-module-update/data/class/helper/SC_Helper_DB.php

    r15237 r15279  
    1414 */ 
    1515class SC_Helper_DB { 
     16 
     17    // {{{ properties 
     18 
     19    /** ルートカテゴリ取得フラグ */ 
     20    var $g_root_on; 
     21 
     22    /** ルートカテゴリID */ 
     23    var $g_root_id; 
    1624 
    1725    // }}} 
     
    166174        } 
    167175        return $ret; 
     176    } 
     177 
     178    /** 
     179     * 店舗基本情報を取得する. 
     180     * 
     181     * @return array 店舗基本情報の配列 
     182     */ 
     183    function sf_getBasisData() { 
     184        //DBから設定情報を取得 
     185        $objConn = new SC_DbConn(); 
     186        $result = $objConn->getAll("SELECT * FROM dtb_baseinfo"); 
     187        if(is_array($result[0])) { 
     188            foreach ( $result[0] as $key=>$value ){ 
     189                $CONF["$key"] = $value; 
     190            } 
     191        } 
     192        return $CONF; 
     193    } 
     194 
     195    /* 選択中のアイテムのルートカテゴリIDを取得する */ 
     196    function sfGetRootId() { 
     197 
     198        if(!$this->g_root_on)   { 
     199            $this->g_root_on = true; 
     200            $objQuery = new SC_Query(); 
     201 
     202            if (!isset($_GET['product_id'])) $_GET['product_id'] = ""; 
     203            if (!isset($_GET['category_id'])) $_GET['category_id'] = ""; 
     204 
     205            if(!empty($_GET['product_id']) || !empty($_GET['category_id'])) { 
     206                // 選択中のカテゴリIDを判定する 
     207                $category_id = SC_Utils_Ex::sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 
     208                // ROOTカテゴリIDの取得 
     209                $arrRet = SC_Utils_Ex::sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); 
     210                $root_id = $arrRet[0]; 
     211            } else { 
     212                // ROOTカテゴリIDをなしに設定する 
     213                $root_id = ""; 
     214            } 
     215            $this->g_root_id = $root_id; 
     216        } 
     217        return $this->g_root_id; 
    168218    } 
    169219 
  • branches/feature-module-update/data/class/util/SC_Utils.php

    r15238 r15279  
    8888            require_once($extern_php); 
    8989        } 
    90     } 
    91  
    92     function sf_getBasisData() { 
    93         //DBから設定情報を取得 
    94         $objConn = new SC_DbConn(DEFAULT_DSN); 
    95         $result = $objConn->getAll("SELECT * FROM dtb_baseinfo"); 
    96         if(is_array($result[0])) { 
    97             foreach ( $result[0] as $key=>$value ){ 
    98                 $CONF["$key"] = $value; 
    99             } 
    100         } 
    101         return $CONF; 
    10290    } 
    10391 
     
    16281616    } 
    16291617 
    1630     // ROOTID取得判定用のグローバル変数(一度取得されていたら再取得しないようにする) 
    1631     //$g_root_on = false; 
    1632     //$g_root_id = ""; 
    1633  
    1634     /* 選択中のアイテムのルートカテゴリIDを取得する */ 
    1635     function sfGetRootId() { 
    1636         global $g_root_on; 
    1637         global $g_root_id; 
    1638         if(!$g_root_on) { 
    1639             $g_root_on = true; 
    1640             $objQuery = new SC_Query(); 
    1641             if($_GET['product_id'] != "" || $_GET['category_id'] != "") { 
    1642                 // 選択中のカテゴリIDを判定する 
    1643                 $category_id = SC_Utils::sfGetCategoryId($_GET['product_id'], $_GET['category_id']); 
    1644                 // ROOTカテゴリIDの取得 
    1645                  $arrRet = SC_Utils::sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); 
    1646                  $root_id = $arrRet[0]; 
    1647             } else { 
    1648                 // ROOTカテゴリIDをなしに設定する 
    1649                 $root_id = ""; 
    1650             } 
    1651             $g_root_id = $root_id; 
    1652         } 
    1653         return $g_root_id; 
    1654     } 
    1655  
    16561618    /* カテゴリから商品を検索する場合のWHERE文と値を返す */ 
    16571619    function sfGetCatWhere($category_id) { 
Note: See TracChangeset for help on using the changeset viewer.