Use objectManager to display versions

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-09-18 13:18:50 +02:00
committed by Chris Morgan
parent 69b14f58c7
commit a6a62a2299
4 changed files with 51 additions and 7 deletions

View File

@@ -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);

View File

@@ -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.

View File

@@ -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()

View File

@@ -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