Better, Fully tested bugs.php page for AppDB

Tony Lambregts tony_lambregts at telusplanet.net
Fri Apr 16 22:02:23 CDT 2004


Change log: Add a Bug search page for the AppDB.

Files Changed: appveiw.php
Files Added:   bugs.php


-- 
Tony Lambregts

Index: appview.php
===================================================================
RCS file: /home/wine/appdb/appview.php,v
retrieving revision 1.4
diff -u -r1.4 appview.php
--- appview.php	6 Apr 2004 21:21:20 -0000	1.4
+++ appview.php	17 Apr 2004 02:41:30 -0000
@@ -284,8 +284,7 @@
 	echo "<tr class=color0 valign=top><td align=right> <b>Vendor</b></td><td> ".
 	     "   <a href='vendorview.php?vendorId=$vendor->vendorId'> ".stripslashes($vendor->vendorName)." </a> &nbsp;\n";
         echo "<tr class=color0 valign=top><td align=right> <b>BUGS</b></td><td> ".
-	     "   <a href='http://bugs.winehq.org/buglist.cgi?product=Wine&bug_file_loc_type=allwords&bug_file_loc=appdb ".$data->appId."'>
-             Check for bugs in bugzilla </a> &nbsp;\n";        
+	     "   <a href='bugs.php?appId=$data->appId.'> Check for bugs in bugzilla </a> &nbsp;\n";        
 	echo "</td></tr>\n";
 	
 	//display notes
--- /dev/null	2003-01-30 03:24:37.000000000 -0700
+++ bugs.php	2004-04-16 20:36:00.000000000 -0600
@@ -0,0 +1,253 @@
+<?
+
+
+/*
+ * Application Database - appview.php
+ *
+ */
+
+include("path.php");
+require(BASE."include/"."incl.php");
+require(BASE."include/"."application.php");
+require(BASE."include/"."comments.php");
+require(BASE."include/"."appdb.php");
+
+require(BASE."include/"."rating.php");
+require(BASE."include/"."category.php");
+
+global $apidb_root;
+
+
+
+
+function get_screenshot_img($appId, $versionId)
+{
+    global $apidb_root;
+
+    if(!$versionId)
+	$versionId = 0;
+
+    $result = mysql_query("SELECT * FROM appData WHERE appId = $appId AND versionId = $versionId AND type = 'image'");
+    
+    if(!$result || !mysql_num_rows($result))
+    {
+	$imgFile = "<img src='".$apidb_root."images/no_screenshot.gif' border=0 alt='No Screenshot'>";
+    }
+    else
+    {
+        $ob = mysql_fetch_object($result);
+	$imgFile = "<img src='appimage.php?appId=$appId&versionId=$versionId&width=128&height=128' ".
+	           "border=0 alt='$ob->description'>";
+    }
+    
+    $img = html_frame_start("",'128','',2);
+    $img .= "<a href='screenshots.php?appId=$appId&versionId=$versionId'>$imgFile</a>";
+    $img .= html_frame_end()."<br>";
+    
+    return $img;
+}
+
+
+function display_catpath($catId)
+{
+    $cat = new Category($catId);
+
+    $catFullPath = make_cat_path($cat->getCategoryPath());
+    echo html_frame_start("",'98%','',2);
+    echo "<p><b>Category: ". $catFullPath ."</b><br>\n";
+    echo html_frame_end();
+}
+
+/* display the SUB apps that belong to this app */
+function display_bundle($appId)
+{
+    $result = mysql_query("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ".
+			  "WHERE bundleId = $appId AND appBundle.appId = appFamily.appId");
+    if(!$result || mysql_num_rows($result) == 0)
+	{
+	    // do nothing
+	    return;
+	}
+
+    echo html_frame_start("","98%","",0);
+    echo "<table width='100%' border=0 cellpadding=3 cellspacing=1>\n\n";
+
+    echo "<tr class=color4>\n";
+    echo "    <td><font color=white>Application Name</font></td>\n";
+    echo "    <td><font color=white>Description</font></td>\n";
+    echo "</tr>\n\n";
+
+    $c = 0;
+    while($ob = mysql_fetch_object($result))
+	{
+	    //set row color
+	    $bgcolor = ($c % 2 == 0) ? "color0" : "color1";
+
+	    //format desc
+	    $desc = substr(stripslashes($ob->description),0,50);
+	    if(strlen($desc) == 50)
+		$desc .= " ...";
+
+	    //display row
+	    echo "<tr class=$bgcolor>\n";
+	    echo "    <td><a href='appview.php?appId=$ob->appId'>".stripslashes($ob->appName)."</a></td>\n";
+	    echo "    <td>$desc &nbsp;</td>\n";
+	    echo "</tr>\n\n";
+
+	    $c++;
+	}
+
+    echo "</table>\n\n";
+    echo html_frame_end();
+}
+
+
+
+/* display the versions */
+function display_versions($appId, $versions)
+{
+	if ($versions)
+	{
+	
+		 echo html_frame_start("","98%","",0);
+		 echo "<table width='100%' border=0 cellpadding=3 cellspacing=1>\n\n";
+
+		 echo "<tr class=color4>\n";
+		 echo "    <td width=80><font color=white>Version</font></td>\n";
+		 echo "    <td><font color=white>Description</font></td>\n";
+		 echo "    <td width=80><font color=white class=small>Rating With Windows</font></td>\n";
+		 echo "    <td width=80><font color=white class=small>Rating Without Windows</font></td>\n";
+		 echo "    <td width=40><font color=white class=small>Comments</font></td>\n";
+		 echo "</tr>\n\n";
+    	
+	        $c = 0;
+		while(list($idx, $ver) = each($versions))
+		{
+	             //set row color
+	            $bgcolor = ($c % 2 == 0) ? "color0" : "color1";
+
+	            //format desc
+	            $desc = substr(stripslashes($ver->description),0,75);
+	            if(strlen($desc) == 75)
+		    $desc .= " ...";		
+		
+		   //get ratings
+	           $r_win = rating_stars_for_version($ver->versionId, "windows");
+	           $r_fake = rating_stars_for_version($ver->versionId, "fake");
+		   
+		   //count comments
+		   $r_count = count_comments($appId,$ver->versionId);
+		
+	           //display row
+	           echo "<tr class=$bgcolor>\n";
+	           echo "    <td><a href='appview.php?appId=$appId&versionId=$ver->versionId'>".$ver->versionName."</a></td>\n";
+	           echo "    <td>$desc &nbsp;</td>\n";
+		   echo "    <td align=center>$r_win</td>\n";
+		   echo "    <td align=center>$r_fake</td>\n";
+		   echo "    <td align=center>$r_count</td>\n";
+	           echo "</tr>\n\n";
+
+	           $c++;		
+		}
+		
+		echo "</table>\n";
+		echo html_frame_end("Click the Version Name to view the details of that Version");
+	}
+}
+
+/* code to View an application's Bugs */
+
+$appId = $_REQUEST['appId'];
+
+if(!is_numeric($appId))
+{
+	errorpage("Something went wrong with the IDs");
+	exit;
+}
+
+if($appId)
+{
+	$app = new Application($appId);
+	$data = $app->data;
+	if(!$data) {
+		// Oops! application not found or other error. do something
+		errorpage('Internal Database Access Error');
+		exit;
+	}
+
+	// header
+	apidb_header("Search for bugs in Bugzila for - ".$data->appName);
+
+	//cat display
+	display_catpath($app->data->catId);
+
+	//set Vendor
+	$vendor = $app->getVendor();
+
+	//set URL
+	$appLinkURL = ($data->webPage) ? "<a href='$data->webPage'>".substr(stripslashes($data->webPage),0,30)."</a>": "&nbsp;";
+	
+	//set Image
+	$img = get_screenshot_img($appId, $versionId);
+	
+	//start display application
+	echo html_frame_start("","98%","",0);
+	
+	echo '<tr><td class=color4 valign=top>',"\n";	
+	echo '<table width="300" border=0 cellpadding=3 cellspacing=1">',"\n";
+	echo "<tr class=color0 valign=top><td width='250' align=right> <b>Name</b></td><td width='75%'> ".stripslashes($data->appName)." </td>\n";
+	echo "<tr class=color1 valign=top><td width='250' align=right> <b>App Id</b></td><td width='75%'> ".$data->appId." </td>\n";
+	echo "<tr class=color0 valign=top><td width='250' align=right> <b>Vendor</b></td><td width='75%'> ".
+	     "   <a href='vendorview.php?vendorId=$vendor->vendorId'> ".stripslashes($vendor->vendorName)." </a> &nbsp;\n";
+        echo "<tr class=color1 valign=top><td width='250' align=right> <b>All Bugs</b></td><td width='75%'> ".
+             "   <a href='http://bugs.winehq.org/buglist.cgi?product=Wine&bug_file_loc_type=allwords&bug_file_loc=appdb ".$data->appId."'>
+             Look for All bugs in bugzilla </a> &nbsp;\n";
+        echo "<tr class=color0 valign=top><td width=250 align=right> <b>Open Bugs</b></td><td width='75%'> ".
+             "   <a href='http://bugs.winehq.org/buglist.cgi?product=Wine".
+             "&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_file_loc_type=allwords&bug_file_loc=appdb ".$data->appId."'>
+             Look for Open bugs in bugzilla </a> &nbsp;\n";        
+        echo "<tr class=color1 valign=top><td width='250' align=right> <b>Submit a New Bug</b></td><td width='75%'> ".
+             "   <a href='http://bugs.winehq.org/enter_bug.cgi?product=wine&bug_file_loc=http://appdb.winehq.org/appview.php?appid=".$data->appId."'>
+             Submit a new bug in bugzilla </a> &nbsp;\n";
+    	echo "</td></tr>\n";
+	   
+	echo "</table></td><td class=color2 valign=top width='100%'>\n";
+
+	//Notes
+	echo "<table width='100%' border=0><tr><td width='100%' valign=top><big><b>Welcome</b></big><br>\n";
+?>      
+        <p>This is the link between the Wine Application Database and Wine's Buzilla. From here you 
+        get search for bugs entered against this application. You can also enter new bugs if you log
+        into Wine's Bugzilla.</p>
+	
+        <p>The link between the Application Database and Bugzilla is based on the bug having the following URL
+<?      
+        echo "<a href='http://appdb.winehq.org/appview.php?appId=".$data->appId."'>
+        http://appdb.winehq.org/appview.php?appId=".$data->appId."</a> &nbsp;\n";    
+?>
+        in the bug's "URL" Field. If it is not entered, this search page can not find it.
+<?       
+	echo "</td></tr></table>\n";
+		
+	echo html_frame_end("For more details and user comments, view the versions of this application.");
+
+        //display versions
+	display_versions($appId,$app->getAppVersionList());
+
+	//display bundle
+	display_bundle($appId);
+
+}
+else
+{
+	// Oops! Called with no params, bad llamah!
+	errorpage('Page Called with No Params!');
+	exit;
+}
+
+echo p();
+
+apidb_footer();
+
+?>
+





More information about the wine-patches mailing list