Module: appdb Branch: master Commit: a6a62a22994e644788f5a87030f8d737959b1d9c URL: http://source.winehq.org/git/appdb.git/?a=commit;h=a6a62a22994e644788f5a8703...
Author: Alexander Nicolaysen Sørnes alex@thehandofagony.com Date: Tue Sep 18 13:18:50 2007 +0200
Use objectManager to display versions
---
appview.php | 2 +- include/objectManager.php | 23 +++++++++++++++++++++++ include/version.php | 16 ++++++++++++++-- objectManager.php | 17 +++++++++++++---- 4 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/appview.php b/appview.php index 4ad6e8a..6b4e3b3 100644 --- a/appview.php +++ b/appview.php @@ -79,7 +79,7 @@ if( isset($aClean['iAppId']) ) } else if( isset($aClean['iVersionId']) ) // We want to see a particular version. { $oVersion = new Version($aClean['iVersionId']); - $iTestingId = isset($aClean['iTestingId']) ? $aClean['iTestingId'] : null; + // header apidb_header("Viewing App: ".version::fullName($oVersion->iVersionId)); $oVersion->display($aClean); diff --git a/include/objectManager.php b/include/objectManager.php index 1b2737a..7473998 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -700,6 +700,29 @@ class ObjectManager } }
+ /* Gets the title of the page to be displayed. Classes can set + the page title depending on the action, or return null to + let objectManager use one, normally the title specified in + the URL. Since this only affects the user interface and not + functionality, objectGetCustomTitle is not a required method. + Why do we need this method? Think of the versions, for instance. + If we were to fetch the name from the URL, that would mean + that changes to the version name would not be reflected in + static URLs, like external links to the AppDB. */ + function get_title($sAction) + { + $oObject = new $this->sClass($this->iId); + $sTitle = ""; + + if(method_exists($oObject, "objectGetCustomTitle")) + $sTitle = $oObject->objectGetCustomTitle($sAction); + + if(!$sTitle) + $sTitle = $this->sTitle; + + return $sTitle; + } + /* 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. diff --git a/include/version.php b/include/version.php index 1d14db2..85c723b 100644 --- a/include/version.php +++ b/include/version.php @@ -719,6 +719,18 @@ class version { $this->iObsoleteBy = 0; }
+ function objectGetCustomTitle($sAction) + { + switch($sAction) + { + case "display": + return "Viewing App: ".version::fullName($this->iVersionId); + + default: + return null; + } + } + function objectGetCustomVars($aClean, $sAction) { switch($sAction) @@ -986,7 +998,7 @@ class version { // show the test results table if($oTest->iTestingId) { - $oTest->ShowVersionsTestingTable($_SERVER['PHP_SELF']."?iVersionId=".$this->iVersionId."&iTestingId=", + $oTest->ShowVersionsTestingTable($this->objectMakeUrl()."&iTestingId=", 5); } if($_SESSION['current']->isLoggedIn()) @@ -1278,7 +1290,7 @@ class version {
function objectMakeUrl() { - return APPDB_ROOT."appview.php?iVersionId=$this->iVersionId"; + return APPDB_ROOT."objectManager.php?sClass=version&iId=$this->iVersionId"; }
function objectMakeLink() diff --git a/objectManager.php b/objectManager.php index 7052c62..e880a68 100644 --- a/objectManager.php +++ b/objectManager.php @@ -79,12 +79,21 @@ if(isset($aClean['sAction']) && $aClean['sAction'] == "add") if($oObject->iId && $aClean['sAction'] == "moveChildren" && $aClean['iNewId']) $oObject->move_children($aClean['iNewId']);
-apidb_header($oObject->sTitle); +$sAction = $aClean['sAction']; + +/* If no action is specified, use a default depending on other parameters */ +if(!$sAction) +{ + if($oObject->iId) + $sAction = "display"; +} + +apidb_header($oObject->get_title($sAction));
/* display a particular element */ if($oObject->iId) { - switch($aClean['sAction']) + switch($sAction) { case "cancel": $oObject->display_table($aClean); /* go back to the queue */ @@ -102,11 +111,11 @@ if($oObject->iId) $oObject->delete_prompt(); break;
- default: + case "display": $oObject->view($_SERVER['REQUEST_URI'], $aClean); break; } -} else if (isset($aClean['sAction']) && $aClean['sAction'] == "add") +} else if ($sAction == "add") { $oObject->add_entry($_SERVER['REQUEST_URI'], $sErrors); } else