diff options
author | Marcin Juszkiewicz <hrw@openembedded.org> | 2006-08-25 15:29:19 +0000 |
---|---|---|
committer | Marcin Juszkiewicz <hrw@openembedded.org> | 2006-08-25 15:29:19 +0000 |
commit | 4b0d1a5487be990fcb99badadb8068283b9e1a06 (patch) | |
tree | f3951bf3045d36ac3e5263b637786e0e201e1271 /contrib/feed-browser/includes | |
parent | b6a4f08a7344338cb487e74f398f22587ae01894 (diff) |
feed-browser: much better sectionlist (rewrite to be recursive anyone?)
Diffstat (limited to 'contrib/feed-browser/includes')
-rw-r--r-- | contrib/feed-browser/includes/functions.inc | 94 |
1 files changed, 53 insertions, 41 deletions
diff --git a/contrib/feed-browser/includes/functions.inc b/contrib/feed-browser/includes/functions.inc index 4b0b898118..4745c75910 100644 --- a/contrib/feed-browser/includes/functions.inc +++ b/contrib/feed-browser/includes/functions.inc @@ -332,68 +332,80 @@ function sectionslist() if($result = db_query ("SELECT DISTINCT p_section FROM packages ORDER BY p_section")) { - $ipkgoutput = "<ul id='sections'>\n"; + $section_up = ''; - $section_up = $result[0]['p_section']; - $section_level = FALSE; - $opie_top = FALSE; + $sections = array(); - foreach($result as $item) + foreach($result as $package) { - $section_name = $item['p_section']; + $section_split = explode('/', $package['p_section']); - if(0 === strpos($section_name, 'opie') AND !$opie_top) + if($section_up != $section_split[0]) { - $opie_top = TRUE; - - $section_up = 'opie'; + $section_up = $section_split[0]; } - elseif($opie_top AND 0 !== strpos($section_name, 'opie')) + + if(isset($section_split[1])) // x11/gnome/libs { - $opie_top = FALSE; + $sections[$section_up][$section_split[1]] = $section_split[1]; + + if(isset($section_split[2])) // x11/gnome/libs + { + $sections[ $section_up ][ $section_split[1] ] = array($section_split[2]=>$section_split[2]); + } } + } + + $output = "<ul id='sections'>\n"; - if( - strpos($section_name, '/') // subsection - ) + foreach($sections as $section_name1=>$item) + { + $output .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a>", + urlencode($section_name1), + urlencode($section_name1), + $section_name1); + + if(is_array($item)) { - if(0 === strpos($section_name, $section_up . '/')) // console/network are not part of console/net + $output .= '<ul class="subsections">'; + + foreach($item as $section_name2=>$subitem) { - if(!$section_level) + $section_name = "{$section_name1}/{$section_name2}"; + $output .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a>", + urlencode($section_name), + urlencode($section_name), + $section_name2); + + if(is_array($subitem)) { - $ipkgoutput .= '<li><ul class="subsections">'; + $output .= '<ul class="subsections">'; + + foreach($subitem as $section_name3=>$subitem2) + { + $section_name = "{$section_name1}/{$section_name2}/{$section_name3}"; + $output .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a></li>", + urlencode($section_name), + urlencode($section_name), + $section_name3); + } + + $output .= '</ul>'; } - $section_name = str_replace($section_up . '/', '', $item['p_section']); - $section_level = TRUE; + $output .= '</li>'; } - } - elseif($section_level) - { - $section_up = $section_name; - $ipkgoutput .= '</ul></li>'; - $section_level = FALSE; - } - else - { - $section_up = $section_name; + + $output .= '</ul>'; } - $ipkgoutput .= sprintf ("<li><a href='?action=section&section=%s' title='%s'>%s</a></li>", - urlencode($item['p_section']), - urlencode($item['p_section']), - $section_name); + $output .= '</li>'; } - if($section_level) - { - $ipkgoutput .= '</ul></li>'; - } - - $ipkgoutput .= "</ul>\n"; + $output .= "</ul>\n"; } - return $ipkgoutput; + return $output; } function check_database() |