GIT.Harvie.CZ
/
mirrors
/
SokoMan.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2871360
)
Do stromu kategorii pridana IDcka
author
Thomas Mudrunka
<tomas@mudrunka.cz>
Fri, 9 Dec 2011 20:40:51 +0000
(21:40 +0100)
committer
Thomas Mudrunka
<tomas@mudrunka.cz>
Fri, 9 Dec 2011 20:40:51 +0000
(21:40 +0100)
assistants/category-tree.inc.php
patch
|
blob
|
blame
|
history
diff --git
a/assistants/category-tree.inc.php
b/assistants/category-tree.inc.php
index ce6c4c38043d004ef766263dded0b510e8c1905c..b41b5471ac2d658d670021431eb278f09fd171b5 100644
(file)
--- a/
assistants/category-tree.inc.php
+++ b/
assistants/category-tree.inc.php
@@
-1,26
+1,31
@@
<pre><?php
$result = $this->db->safe_query_fetch('SELECT * FROM category');
<pre><?php
$result = $this->db->safe_query_fetch('SELECT * FROM category');
-function addleaf(&$tree, $levels, $category='') {
- if(!count($levels)) return;
- $current = array_shift($levels);
+function addleaf(&$tree, $levels, $id, $category='') {
+ if(!count($levels)) {
+ $tree['__ID__'] = $id;
+ return;
+ }
+ $current = array_shift($levels); //echo("$current ".count($levels)."");
$category .= '/'.$current;
if(!isset($tree[$current])) $tree[$current] = array();
$tree[$current]['__PATH__'] = $category;
$category .= '/'.$current;
if(!isset($tree[$current])) $tree[$current] = array();
$tree[$current]['__PATH__'] = $category;
- addleaf($tree[$current], $levels, $category);
+ //if(!count($levels)) $tree[$current]['__ID__'] = $id; //echo "($current $id)\n";
+ addleaf($tree[$current], $levels, $id, $category);
}
$tree = array();
foreach($result as $row) {
$row_parts = preg_split('/\//', $row['category_name']);
}
$tree = array();
foreach($result as $row) {
$row_parts = preg_split('/\//', $row['category_name']);
- addleaf($tree, $row_parts);
+ //echo($row['category_name'].$row['category_id']."\n");
+ addleaf($tree, $row_parts, $row['category_id']);
}
}
-function render_tree($tree, $
pathindex='__PATH
__') {
+function render_tree($tree, $
index_path='__PATH__', $index_id='__ID
__') {
if(!is_array($tree)) return '';
$html='<menu>';
if(!is_array($tree)) return '';
$html='<menu>';
- foreach($tree as $name => $subtree) if($name != $
pathindex
) {
-
$html.='<li><b>'.$name.'</b> <small>('.$subtree[$pathindex
].')</small>'.render_tree($subtree).'</li>';
+ foreach($tree as $name => $subtree) if($name != $
index_path && $name != $index_id
) {
+
@$html.='<li><b>'.$name.'</b> <small>('.$subtree[$index_id].' => '.$subtree[$index_path
].')</small>'.render_tree($subtree).'</li>';
}
$html.='</menu>';
return $html;
}
$html.='</menu>';
return $html;
This page took
0.156888 seconds
and
4
git commands to generate.