Changeset 22586 for branches/version-2_12-dev/data/class
- Timestamp:
- 2013/02/28 09:30:36 (13 years ago)
- Location:
- branches/version-2_12-dev/data/class
- Files:
-
- 2 edited
-
pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php (modified) (3 diffs)
-
util/SC_Utils.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Category.php
r22567 r22586 132 132 $objQuery =& SC_Query_Ex::getSingletonInstance(); 133 133 $objDb = new SC_Helper_DB_Ex(); 134 134 135 $col = '*'; 135 136 $from = 'dtb_category left join dtb_category_total_count ON dtb_category.category_id = dtb_category_total_count.category_id'; … … 142 143 $objQuery->setOption('ORDER BY rank DESC'); 143 144 $arrRet = $objQuery->select($col, $from, $where); 145 146 $arrTree = SC_Utils_Ex::buildTree('category_id', 'parent_category_id', 10, $arrRet); 147 144 148 foreach ($arrParentCategoryId as $category_id) { 145 149 $arrParentID = $objDb->sfGetParents( … … 162 166 ); 163 167 $this->root_parent_id[] = $arrParentID[0]; 164 $arrDispID = array_merge($arrBrothersID, $arrChildrenID); 165 foreach ($arrRet as &$arrCategory) { 166 if (in_array($arrCategory['category_id'], $arrDispID)) { 167 $arrCategory['display'] = 1; 168 } 169 } 170 } 171 return $arrRet; 168 $this->arrDispID = array_merge($arrBrothersID, $arrChildrenID); 169 } 170 171 return $arrTree; 172 172 } 173 173 -
branches/version-2_12-dev/data/class/util/SC_Utils.php
r22567 r22586 1922 1922 return $return; 1923 1923 } 1924 1925 /** 1926 * 1927 * @param string $primary_key 1928 * @param string $glue_key 1929 * @param integer $max_depth 1930 * @param array $correction 1931 * @param integer $base_id 1932 * @return array ツリーの配列 1933 */ 1934 public static function buildTree($primary_key, $glue_key, $max_depth, $correction = array(), $base_id = 0) 1935 { 1936 $children = array(); 1937 foreach ($correction as $child) { 1938 $children[$child[$glue_key]][] = $child; 1939 } 1940 $arrTree = $children[$base_id]; 1941 foreach ($arrTree as &$child) { 1942 SC_Utils_Ex::addChild($child, $primary_key, 1, $max_depth, $children); 1943 } 1944 return $arrTree; 1945 } 1946 1947 /** 1948 * ツリーの親子をつなげるルーチン. 1949 * 1950 * @param array $target 親 1951 * @param string $primary_key 主キーの識別子 1952 * @param integer $level 親の階層 1953 * @param integer $max_depth 階層の深さの最大値 1954 * @param array $children 子の配列(キーが親ID) 1955 * @return void 1956 */ 1957 public static function addChild(&$target, $primary_key, $level, $max_depth, &$children = array()) 1958 { 1959 if (isset($children[$target[$primary_key]])) { 1960 $target['children'] = $children[$target[$primary_key]]; 1961 if ($level + 1 < $max_depth) { 1962 foreach ($target['children'] as &$child) { 1963 SC_Utils_Ex::addChild($child, $primary_key, $level++, $max_depth, $children); 1964 } 1965 } 1966 } 1967 } 1924 1968 }
Note: See TracChangeset
for help on using the changeset viewer.
