Ignore:
Timestamp:
2007/08/27 16:31:19 (17 years ago)
Author:
nanasess
Message:

リファクタリング(関数移動)

File:
1 edited

Legend:

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

    r15351 r15364  
    13461346    } 
    13471347 
    1348     // カテゴリID取得判定用のグローバル変数(一度取得されていたら再取得しないようにする) 
    1349     //$g_category_on = false; 
    1350     //$g_category_id = ""; 
    1351  
    1352     /* 選択中のカテゴリを取得する */ 
    1353     function sfGetCategoryId($product_id, $category_id) { 
    1354         global $g_category_on; 
    1355         global $g_category_id; 
    1356         if(!$g_category_on) { 
    1357             $g_category_on = true; 
    1358             $category_id = (int) $category_id; 
    1359             $product_id = (int) $product_id; 
    1360             $objDb = new SC_Helper_DB_Ex(); 
    1361             if(SC_Utils_Ex::sfIsInt($category_id) && $objDb->sfIsRecord("dtb_category","category_id", $category_id)) { 
    1362                 $g_category_id = $category_id; 
    1363             } else if (SC_Utils_Ex::sfIsInt($product_id) && $objDb->sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { 
    1364                 $objQuery = new SC_Query(); 
    1365                 $where = "product_id = ?"; 
    1366                 $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id)); 
    1367                 $g_category_id = $category_id; 
    1368             } else { 
    1369                 // 不正な場合は、0を返す。 
    1370                 $g_category_id = 0; 
    1371             } 
    1372         } 
    1373         return $g_category_id; 
    1374     } 
    1375  
    13761348    /* 加算ポイントの計算式 */ 
    13771349    function sfGetAddPoint($totalpoint, $use_point, $arrInfo) { 
     
    18791851        } 
    18801852        return $arrChildren; 
    1881     } 
    1882  
    1883  
    1884     // カテゴリツリーの取得 
    1885     function sfGetCatTree($parent_category_id, $count_check = false) { 
    1886         $objQuery = new SC_Query(); 
    1887         $col = ""; 
    1888         $col .= " cat.category_id,"; 
    1889         $col .= " cat.category_name,"; 
    1890         $col .= " cat.parent_category_id,"; 
    1891         $col .= " cat.level,"; 
    1892         $col .= " cat.rank,"; 
    1893         $col .= " cat.creator_id,"; 
    1894         $col .= " cat.create_date,"; 
    1895         $col .= " cat.update_date,"; 
    1896         $col .= " cat.del_flg, "; 
    1897         $col .= " ttl.product_count"; 
    1898         $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; 
    1899         // 登録商品数のチェック 
    1900         if($count_check) { 
    1901             $where = "del_flg = 0 AND product_count > 0"; 
    1902         } else { 
    1903             $where = "del_flg = 0"; 
    1904         } 
    1905         $objQuery->setoption("ORDER BY rank DESC"); 
    1906         $arrRet = $objQuery->select($col, $from, $where); 
    1907  
    1908         $arrParentID = sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 
    1909  
    1910         foreach($arrRet as $key => $array) { 
    1911             foreach($arrParentID as $val) { 
    1912                 if($array['category_id'] == $val) { 
    1913                     $arrRet[$key]['display'] = 1; 
    1914                     break; 
    1915                 } 
    1916             } 
    1917         } 
    1918  
    1919         return $arrRet; 
    1920     } 
    1921  
    1922     // 親カテゴリーを連結した文字列を取得する 
    1923     function sfGetCatCombName($category_id){ 
    1924         // 商品が属するカテゴリIDを縦に取得 
    1925         $objQuery = new SC_Query(); 
    1926         $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); 
    1927         $ConbName = ""; 
    1928  
    1929         // カテゴリー名称を取得する 
    1930         foreach($arrCatID as $key => $val){ 
    1931             $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; 
    1932             $arrVal = array($val); 
    1933             $CatName = $objQuery->getOne($sql,$arrVal); 
    1934             $ConbName .= $CatName . ' | '; 
    1935         } 
    1936         // 最後の | をカットする 
    1937         $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); 
    1938  
    1939         return $ConbName; 
    1940     } 
    1941  
    1942     // 指定したカテゴリーIDの大カテゴリーを取得する 
    1943     function sfGetFirstCat($category_id){ 
    1944         // 商品が属するカテゴリIDを縦に取得 
    1945         $objQuery = new SC_Query(); 
    1946         $arrRet = array(); 
    1947         $arrCatID = SC_Utils_Ex::sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); 
    1948         $arrRet['id'] = $arrCatID[0]; 
    1949  
    1950         // カテゴリー名称を取得する 
    1951         $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; 
    1952         $arrVal = array($arrRet['id']); 
    1953         $arrRet['name'] = $objQuery->getOne($sql,$arrVal); 
    1954  
    1955         return $arrRet; 
    19561853    } 
    19571854 
Note: See TracChangeset for help on using the changeset viewer.