Alexander Nicolaysen Sørnes : Prepare for viewing versions using objectManager

Chris Morgan cmorgan at winehq.org
Tue Sep 18 19:51:53 CDT 2007


Module: appdb
Branch: master
Commit: 93d71f630a49fc57938470c114e545367fefcb4c
URL:    http://source.winehq.org/git/appdb.git/?a=commit;h=93d71f630a49fc57938470c114e545367fefcb4c

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Tue Sep 18 12:28:37 2007 +0200

Prepare for viewing versions using objectManager

---

 appview.php               |    4 +++-
 include/objectManager.php |   32 ++++++++++++++++++++++++++++++--
 include/version.php       |   23 ++++++++++++++++++-----
 objectManager.php         |    2 +-
 4 files changed, 52 insertions(+), 9 deletions(-)

diff --git a/appview.php b/appview.php
index b0731d0..4ad6e8a 100644
--- a/appview.php
+++ b/appview.php
@@ -80,7 +80,9 @@ if( isset($aClean['iAppId']) )
 {
     $oVersion = new Version($aClean['iVersionId']);
     $iTestingId = isset($aClean['iTestingId']) ? $aClean['iTestingId'] : null;
-    $oVersion->display($iTestingId);
+    // header
+    apidb_header("Viewing App: ".version::fullName($oVersion->iVersionId));
+    $oVersion->display($aClean);
 } else
 {
     // Oops! Called with no params, bad llamah!
diff --git a/include/objectManager.php b/include/objectManager.php
index c0b61d3..0c1a3ea 100644
--- a/include/objectManager.php
+++ b/include/objectManager.php
@@ -699,14 +699,42 @@ class ObjectManager
         }
     }
 
+    /* Gets the custom variables, if any, from a class depending on
+       the action which is being taken, such as viewing an entry,
+       editing one etc.
+       Returns null if there are no custom vars, or a labelled array
+       with the variable contents otherwise */
+    function get_custom_vars($aClean, $sAction)
+    {
+        $oObject = new $this->sClass($this->iId);
+
+        if(!method_exists($oObject, "objectGetCustomVars"))
+            return null; /* No vars */
+
+        $aVars = array();
+
+        foreach($oObject->objectGetCustomVars($aClean, $sAction) as $sVar)
+            $aVars[$sVar] = $aClean[$sVar];
+
+        if(!sizeof($aVars))
+           return null; /* No vars */
+        else
+            return $aVars;
+    }
+
     /* View an entry */
-    function view($sBackLink)
+    function view($sBackLink, $aClean)
     {
         $this->checkMethods(array("display"));
 
         $oObject = new $this->sClass($this->iId);
 
-        $oObject->display();
+        $aVars = $this->get_custom_vars($aClean, "display");
+
+        if(!$aVars)
+            $oObject->display();
+        else
+            $oObject->display($aVars);
 
         // display the move children entry
         $this->displayMoveChildren($oObject);
diff --git a/include/version.php b/include/version.php
index 157c9c2..bba4efc 100644
--- a/include/version.php
+++ b/include/version.php
@@ -12,6 +12,7 @@ require_once(BASE."include/util.php");
 require_once(BASE."include/testData.php");
 require_once(BASE."include/downloadurl.php");
 require_once(BASE."include/monitor.php");
+require_once(BASE."include/vote.php");
 
 define("LICENSE_OPENSOURCE", "Open Source");
 define("LICENSE_FREEWARE", "Freeware");
@@ -718,12 +719,28 @@ class version {
             $this->iObsoleteBy = 0;
     }
 
-    function display($iTestingId)
+    function objectGetCustomVars($aClean, $sAction)
+    {
+        switch($sAction)
+        {
+            case "display":
+                /* Allow the user to select which test report is
+                   shown in the version view */
+                return array("iTestingId");
+
+            default:
+                return null;
+        }
+    }
+
+    function display($aVars)
     {
         /* is this user supposed to view this version? */
         if(!$_SESSION['current']->canViewVersion($this))
             util_show_error_page_and_exit("Something went wrong with the application or version id");
 
+        $iTestingId = $aVars['iTestingId'];
+
         $oApp = new Application($this->iAppId);
 
         // Oops! application not found or other error. do something
@@ -738,10 +755,6 @@ class version {
         if($_SESSION['current']->isLoggedIn())
             apidb_sidebar_add("vote_menu");
 
-
-        // header
-        apidb_header("Viewing App- ".$oApp->sName." Version - ".$this->sName);
-
         // cat
         $oCategory = new Category($oApp->iCatId);
         $oCategory->display($oApp->iAppId, $this->iVersionId);
diff --git a/objectManager.php b/objectManager.php
index 1bfc96e..7052c62 100644
--- a/objectManager.php
+++ b/objectManager.php
@@ -103,7 +103,7 @@ if($oObject->iId)
         break;
 
         default:
-        $oObject->view($_SERVER['REQUEST_URI']);
+        $oObject->view($_SERVER['REQUEST_URI'], $aClean);
         break;
     }
 } else if (isset($aClean['sAction']) && $aClean['sAction'] == "add")




More information about the wine-cvs mailing list