appdb/ include/appData.php include/distributio ...

WineHQ wineowner at wine.codeweavers.com
Sat Mar 17 16:04:43 CDT 2007


ChangeSet ID:	30982
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/03/17 16:04:43

Modified files:
	include        : appData.php distribution.php maintainer.php 
	                 objectManager.php screenshot.php vendor.php 
	unit_test      : test_om_objects.php 

Log message:
	Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
	Let objectManager output table headers. A class returns an array of header cells and then
	the objectManager adds an edit column if appropriate.

Patch: http://cvs.winehq.org/patch.py?id=30982

Old revision  New revision  Changes     Path
 1.10          1.11          +2 -5       appdb/include/appData.php
 1.17          1.18          +2 -5       appdb/include/distribution.php
 1.32          1.33          +2 -5       appdb/include/maintainer.php
 1.5           1.6           +17 -4      appdb/include/objectManager.php
 1.59          1.60          +2 -2       appdb/include/screenshot.php
 1.16          1.17          +3 -6       appdb/include/vendor.php
 1.3           1.4           +1 -1       appdb/unit_test/test_om_objects.php

Index: appdb/include/appData.php
diff -u -p appdb/include/appData.php:1.10 appdb/include/appData.php:1.11
--- appdb/include/appData.php:1.10	17 Mar 2007 21: 4:43 -0000
+++ appdb/include/appData.php	17 Mar 2007 21: 4:43 -0000
@@ -199,7 +199,7 @@ class appData
 
     }
 
-    function objectOutputHeader($sClass, $sType)
+    function objectGetHeader($sType)
     {
         $aCells = array(
             "Submission Date",
@@ -207,10 +207,7 @@ class appData
             "Application",
             "Version");
 
-        if(appData::canEdit($sType))
-            $aCells[] = "Action";
-
-        echo html_tr($aCells, $sClass);
+        return $aCells;
     }
 
     function objectGetEntries($bQueued, $iRows = 0, $iStart = 0, $sType)
Index: appdb/include/distribution.php
diff -u -p appdb/include/distribution.php:1.17 appdb/include/distribution.php:1.18
--- appdb/include/distribution.php:1.17	17 Mar 2007 21: 4:43 -0000
+++ appdb/include/distribution.php	17 Mar 2007 21: 4:43 -0000
@@ -400,17 +400,14 @@ class distribution {
         echo "</select>\n";
     }
 
-    function objectOutputHeader($sClass = "")
+    function objectGetHeader()
     {
         $aCells = array(
             "Distribution name",
             "Distribution url",
             array("Linked Tests", "align=\"right\""));
 
-        if(distribution::canEdit())
-            $aCells[3] = array("Action", "align=\"center\"");
-
-        echo html_tr($aCells, $sClass);
+        return $aCells;
     }
 
     function objectGetEntries($bQueued, $iRows = 0, $iStart = 0)
Index: appdb/include/maintainer.php
diff -u -p appdb/include/maintainer.php:1.32 appdb/include/maintainer.php:1.33
--- appdb/include/maintainer.php:1.32	17 Mar 2007 21: 4:43 -0000
+++ appdb/include/maintainer.php	17 Mar 2007 21: 4:43 -0000
@@ -409,7 +409,7 @@ class maintainer
         return $aUserIds;
     }
 
-    function ObjectOutputHeader($sClass)
+    function ObjectGetHeader()
     {
         $aCells = array(
             "Submission Date",
@@ -418,10 +418,7 @@ class maintainer
             "Super maintainer?",
             "Submitter");
 
-        if(maintainer::canEdit())
-            $aCells[sizeof($aCells)] = "Action";
-
-        echo html_tr($aCells, $sClass);
+        return $aCells;
     }
 
     /* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */
Index: appdb/include/objectManager.php
diff -u -p appdb/include/objectManager.php:1.5 appdb/include/objectManager.php:1.6
--- appdb/include/objectManager.php:1.5	17 Mar 2007 21: 4:43 -0000
+++ appdb/include/objectManager.php	17 Mar 2007 21: 4:43 -0000
@@ -55,7 +55,7 @@ class ObjectManager
     /* displays the list of entries */
     function display_table()
     {
-        $this->checkMethods(array("ObjectGetEntries", "ObjectOutputHeader",
+        $this->checkMethods(array("ObjectGetEntries", "ObjectGetHeader",
              "ObjectGetInstanceFromRow", "ObjectOutputTableRow", "canEdit"));
 
 
@@ -85,9 +85,8 @@ class ObjectManager
         /* output the header */
         echo '<table width="100%" border="0" cellpadding="3" cellspacing="0">';
 
-        call_user_func(array($this->sClass,
-                             "objectOutputHeader"), "color4");
-
+        /* Output header cells */
+        $this->outputHeader("color4");
 
         /* output each entry */
         for($iCount = 0; $oRow = mysql_fetch_object($hResult); $iCount++)
@@ -324,6 +323,20 @@ class ObjectManager
         $sId = "i".ucfirst($this->sClass)."Id";
         return $aClean[$sId];
     }
+
+    /* Output headers for a table */
+    function outputHeader($sClass)
+    {
+        $oObject = new $this->sClass();
+        $aCells = $oObject->objectGetHeader();
+
+        /* Add an action column if the user can edit this class, or if it is a queue.
+           Even though a user annot process items, he can edit his queued submissions */
+        if($oObject->canEdit() || $this->bIsQueue)
+            $aCells[] = "Action";
+
+        echo html_tr($aCells, $sClass);
+    }
 }
 
 ?>
Index: appdb/include/screenshot.php
diff -u -p appdb/include/screenshot.php:1.59 appdb/include/screenshot.php:1.60
--- appdb/include/screenshot.php:1.59	17 Mar 2007 21: 4:43 -0000
+++ appdb/include/screenshot.php	17 Mar 2007 21: 4:43 -0000
@@ -518,9 +518,9 @@ class Screenshot {
         return appData::objectGetEntries($bQueued, $iRows, $iStart, "screenshot");
     }
 
-    function objectOutputHeader($sClass)
+    function objectGetHeader()
     {
-        return appData::objectOutputHeader($sClass, "screenshot");
+        return appData::objectGetHeader("screenshot");
     }
 
     function canEdit()
Index: appdb/include/vendor.php
diff -u -p appdb/include/vendor.php:1.16 appdb/include/vendor.php:1.17
--- appdb/include/vendor.php:1.16	17 Mar 2007 21: 4:43 -0000
+++ appdb/include/vendor.php	17 Mar 2007 21: 4:43 -0000
@@ -167,17 +167,14 @@ class Vendor {
         return $hResult;
     }
 
-    function objectOutputHeader($sClass = "")
+    function objectGetHeader()
     {
-        $sCells = array(
+        $aCells = array(
             "Name",
             "Website",
             array("Linked apps", "align=\"right\""));
 
-        if(vendor::canEdit())
-            $sCells[sizeof($sCells)] = "Action";
-
-        echo html_tr($sCells, $sClass);
+        return $aCells;
     }
 
     function objectGetInstanceFromRow($oRow)
Index: appdb/unit_test/test_om_objects.php
diff -u -p appdb/unit_test/test_om_objects.php:1.3 appdb/unit_test/test_om_objects.php:1.4
--- appdb/unit_test/test_om_objects.php:1.3	17 Mar 2007 21: 4:43 -0000
+++ appdb/unit_test/test_om_objects.php	17 Mar 2007 21: 4:43 -0000
@@ -143,7 +143,7 @@ function test_object_methods()
         echo "PASSED:\t\t".$sClassName."\n";
     }*/
 
-    $aTestMethods = array("objectOutputHeader", "objectOutputTableRow",
+    $aTestMethods = array("objectGetHeader", "objectOutputTableRow",
                           "objectGetEntries", "display",
                           "objectGetInstanceFromRow", "outputEditor", "canEdit",
                           "getOutputEditorValues", "objectMakeUrl", "objectMakeLink");



More information about the wine-cvs mailing list