[oe-commits] org.oe.dev feed-browser: much better sectionlist (rewrite to be recursive anyone?)

hrw commit openembedded-commits at lists.openembedded.org
Fri Aug 25 15:33:48 UTC 2006


feed-browser: much better sectionlist (rewrite to be recursive anyone?)

Author: hrw at openembedded.org
Branch: org.openembedded.dev
Revision: 28a2710b7514996588df4fcf0ecdcc35eedc3cc8
ViewMTN: http://monotone.openembedded.org/revision.psp?id=28a2710b7514996588df4fcf0ecdcc35eedc3cc8
Files:
1
contrib/feed-browser/includes/functions.inc
Diffs:

#
# mt diff -r1af401bfaec8c7ab41dcbec9558745958b647ae8 -r28a2710b7514996588df4fcf0ecdcc35eedc3cc8
#
# 
# 
# patch "contrib/feed-browser/includes/functions.inc"
#  from [4d9b05fb27d91c1cc53f3eab07c2421a84b11069]
#    to [482988de50e062c8bce4ddab1590bf8466fa5d8b]
# 
============================================================
--- contrib/feed-browser/includes/functions.inc	4d9b05fb27d91c1cc53f3eab07c2421a84b11069
+++ contrib/feed-browser/includes/functions.inc	482988de50e062c8bce4ddab1590bf8466fa5d8b
@@ -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 = $section_split[0];
+			}
 
-				$section_up = 'opie';
-			}
-			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]);
+				}
 			}
+		}
 
-			if(
-				strpos($section_name, '/')		// subsection
-			)
+		$output = "<ul id='sections'>\n";
+
+		foreach($sections as $section_name1=>$item)
+		{
+			$output .= sprintf ("<li><a href='?action=section&amp;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&amp;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&amp;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>';
 				}
+
+				$output .= '</ul>';
 			}
-			elseif($section_level)
-			{
-				$section_up = $section_name;
-				$ipkgoutput .= '</ul></li>';
-				$section_level = FALSE;
-			}
-			else
-			{
-				$section_up = $section_name;
-			}
 
-			$ipkgoutput .= sprintf ("<li><a href='?action=section&amp;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()






More information about the Openembedded-commits mailing list