Replace objectOutputTableRow() with objectGetTableRow(). Redesign the table output mechanism so

that we fetch a table row from a class instead of letting the class display it. Move adding of
edit/delete links from the classes to the objectManager. Fix a hole in the distribution class
where an uninitialized variable could have been used in the constructor.
This commit is contained in:
Alexander Nicolaysen Sørnes
2007-06-14 00:50:35 +00:00
committed by WineHQ
parent 46f4f20ce6
commit cd198f44d7
14 changed files with 134 additions and 108 deletions

View File

@@ -11,6 +11,7 @@ class ObjectManager
var $iId;
var $bIsRejected;
var $oMultiPage;
var $oTableRow;
function ObjectManager($sClass, $sTitle = "list", $iId = false)
{
@@ -18,6 +19,7 @@ class ObjectManager
$this->sTitle = $sTitle;
$this->iId = $iId;
$this->oMultiPage = new MultiPage(FALSE);
$this->oTableRow = new TableRow(null);
}
/* Check whether the associated class has the given method */
@@ -59,7 +61,7 @@ class ObjectManager
function display_table($aClean)
{
$this->checkMethods(array("ObjectGetEntries", "ObjectGetHeader",
"ObjectOutputTableRow", "canEdit"));
"objectGetTableRow", "objectGetId", "canEdit"));
$oObject = new $this->sClass();
@@ -110,9 +112,28 @@ class ObjectManager
{
$oObject = new $this->sClass(null, $oRow);
/* arg1 = OM object, arg2 = CSS style, arg3 = text for edit link */
$oObject->objectOutputTableRow($this, ($iCount % 2) ? "color0" : "color1",
$this->bIsQueue ? "process" : "edit");
$this->oTableRow->TableRow($oObject->objectGetTableRow());
if(!$this->oTableRow->sStyle)
$this->oTableRow->sStyle = ($iCount % 2) ? "color0" : "color1";
$sEditLinkLabel = $this->bIsQueue ? "process" : "edit";
/* We add some action links */
if($oObject->canEdit())
{
$shDeleteLink = "";
if($this->oTableRow->bDeleteLink)
{
$shDeleteLink = ' [ <a href="'.$this->makeUrl("delete", $oObject->objectGetid()).
'">delete</a> ]';
}
$this->oTableRow->aCells[] = '[ <a href="'.$this->makeUrl("edit",
$oObject->objectGetId()).'">'.$sEditLinkLabel.'</a> ]'.$shDeleteLink;
}
echo html_tr($this->oTableRow->aCells, $this->oTableRow->sStyle);
}
echo "</table>";
@@ -640,4 +661,33 @@ class MultiPage
}
}
class TableRow
{
var $aCells;
var $sStyle;
var $sEditLinkLabel;
var $bDeleteLink;
var $aRowClickable;
var $bCanEdit;
var $iId;
function TableRow($aInput)
{
if(!$aInput)
return;
/* aInput is returned from objectGetTableRow(); an array with the following members
0: an array with the contents of the table row
1: CSS style to be used. If it is null we use the default
2: Is TRUE if we should display a delete link with the edit link
3: Contains an array with info if we should make the entrie table row clickable,
null otherwise */
$this->aCells = $aInput[0];
$this->sStyle = $aInput[1];
$this->bDeleteLink = $aInput[2];
$this->aRowClickable = $aInput[3];
}
}
?>