[oe-commits] org.oe.dev feed-browser: no need to keep two copies of package listing generation code

hrw commit openembedded-commits at lists.openembedded.org
Thu Aug 24 15:33:09 UTC 2006


feed-browser: no need to keep two copies of package listing generation code

Author: hrw at openembedded.org
Branch: org.openembedded.dev
Revision: 2b7f351a95d9eba7246ddd2b5a89c7992888948a
ViewMTN: http://monotone.openembedded.org/revision.psp?id=2b7f351a95d9eba7246ddd2b5a89c7992888948a
Files:
1
contrib/feed-browser/index.php
Diffs:

#
# mt diff -re3e21d5a0b08f5ab995fedbe3643fa95f91c9918 -r2b7f351a95d9eba7246ddd2b5a89c7992888948a
#
# 
# 
# patch "contrib/feed-browser/index.php"
#  from [61a84b4762a8da7e6be41189d72424662d835914]
#    to [9ae74d70b4ae7a43dc4da9e6cc2ad5035e25b05b]
# 
============================================================
--- contrib/feed-browser/index.php	61a84b4762a8da7e6be41189d72424662d835914
+++ contrib/feed-browser/index.php	9ae74d70b4ae7a43dc4da9e6cc2ad5035e25b05b
@@ -239,12 +239,18 @@ function searchpkg ($searchword)
 
 function searchpkg ($searchword)
 {
-	$result = db_query("SELECT DISTINCT p_name,p_desc,p_section  FROM packages WHERE p_name LIKE '$searchword' ORDER BY p_name ASC;");    
+	if($result = db_query("SELECT DISTINCT p_name,p_desc,p_section  FROM packages WHERE p_name LIKE '$searchword' ORDER BY p_name ASC"))
+	{
+	    return generate_list_of_packages($result);
+	}
+}
 
+function generate_list_of_packages($query_result)
+{
 	$ipkgoutput = "<table>\n";
 	$ipkgoutput .="<tr><th>Package</th><th>Section</th><th>Description</th></tr>\n";
 
-	foreach($result as $package)
+	foreach($query_result as $package)
 	{
 		if (!strstr ($package['p_name'], 'locale'))
 		{
@@ -272,36 +278,10 @@ function searchsection($section)
 
 function searchsection($section)
 {
-	$result= db_query("SELECT DISTINCT p_name,p_desc,p_section FROM packages WHERE p_section like '$section%' order by p_section asc, p_name asc;");
-
-	$ipkgoutput = "<table>\n";
-	$ipkgoutput .="<tr><th>Package</th><th>Section</th><th>Description</th></tr>\n";
-
-	foreach($result as $package)
-	{
-		if (!strstr ($package['p_name'], 'locale'))
-		{
-			if(strlen($package['p_desc'])> 40)
-			{
-				$pos = strpos($package['p_desc'],' ',  40);
-
-				if($pos)
-				{
-					$package['p_desc'] = substr($package['p_desc'], 0, $pos) . '...';
-				}
-			}
-
-			$ipkgoutput .= sprintf ("<tr><td><a href='?action=details&amp;pnm=%s'>%s</a></td><td><a href=\"?action=section&amp;section=%s\">%s</a></td><td>%s</td></tr>",
-				urlencode($package['p_name']),
-				$package['p_name'],
-				$package['p_section'], $package['p_section'],
-				htmlentities($package['p_desc']));
-		}//if strstr
+	if($result = db_query("SELECT DISTINCT p_name,p_desc,p_section FROM packages WHERE p_section LIKE '$section%' ORDER BY p_section ASC, p_name ASC"))
+	{	
+	    return generate_list_of_packages($result);
 	}
-
-	$ipkgoutput .= "</table>\n";
-
-	return $ipkgoutput;
 }
 
 function pkgdetails ($package)






More information about the Openembedded-commits mailing list