Use objectManager to display main screenshot gallery

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-12-02 19:39:15 +01:00
committed by Chris Morgan
parent 6d9aa68e0e
commit e52f270498
4 changed files with 126 additions and 149 deletions

View File

@@ -168,6 +168,64 @@ class ObjectManager
exit;
}
public function drawTable($hResult)
{
/* output the header */
echo '<table width="100%" border="0" cellpadding="3" cellspacing="0">';
/* Output header cells */
$this->outputHeader("color4");
/* Preserve the page title */
$this->setReturnToTitle($this->sTitle);
/* output each entry */
for($iCount = 0; $oRow = query_fetch_object($hResult); $iCount++)
{
$oObject = new $this->sClass(null, $oRow);
$this->oTableRow = $oObject->objectGetTableRow();
$sColor = ($iCount % 2) ? "color0" : "color1";
// if there is no class set for a given row use the
// default one in $sColor
if(!$this->oTableRow->GetTableRow()->GetClass())
{
$this->oTableRow->GetTableRow()->SetClass($sColor);
}
// if this row is clickable, make it highlight appropirately
$oTableRowClick = $this->oTableRow->GetTableRow()->GetTableRowClick();
if($oTableRowClick)
{
$oTableRowHighlight = GetStandardRowHighlight($iCount);
$oTableRowClick->SetHighlight($oTableRowHighlight);
}
$sEditLinkLabel = $this->bIsQueue ? "process" : "edit";
/* We add some action links */
if($oObject->canEdit())
{
$shDeleteLink = "";
if($this->oTableRow->GetHasDeleteLink())
{
$shDeleteLink = ' [&nbsp;<a href="'.$this->makeUrl("delete", $oObject->objectGetId()).
'">delete</a>&nbsp;]';
}
$oTableCell = new TableCell('[&nbsp;<a href="'.$this->makeUrl("edit",
$oObject->objectGetId()).'">'.$sEditLinkLabel.'</a>&nbsp;]'.$shDeleteLink);
$this->oTableRow->AddCell($oTableCell);
}
echo $this->oTableRow->GetString();
}
echo "</table>";
}
/* displays the list of entries */
public function display_table($aClean)
{
@@ -267,60 +325,14 @@ class ObjectManager
echo '</div>';
}
/* output the header */
echo '<table width="100%" border="0" cellpadding="3" cellspacing="0">';
$sQueued = $this->getQueueString($this->bIsQueue, $this->bIsRejected);
/* Output header cells */
$this->outputHeader("color4");
/* Preserve the page title */
$this->setReturnToTitle($this->sTitle);
/* output each entry */
for($iCount = 0; $oRow = query_fetch_object($hResult); $iCount++)
{
$oObject = new $this->sClass(null, $oRow);
$this->oTableRow = $oObject->objectGetTableRow();
$sColor = ($iCount % 2) ? "color0" : "color1";
// if there is no class set for a given row use the
// default one in $sColor
if(!$this->oTableRow->GetTableRow()->GetClass())
{
$this->oTableRow->GetTableRow()->SetClass($sColor);
}
// if this row is clickable, make it highlight appropirately
$oTableRowClick = $this->oTableRow->GetTableRow()->GetTableRowClick();
if($oTableRowClick)
{
$oTableRowHighlight = GetStandardRowHighlight($iCount);
$oTableRowClick->SetHighlight($oTableRowHighlight);
}
$sEditLinkLabel = $this->bIsQueue ? "process" : "edit";
/* We add some action links */
if($oObject->canEdit())
{
$shDeleteLink = "";
if($this->oTableRow->GetHasDeleteLink())
{
$shDeleteLink = ' [&nbsp;<a href="'.$this->makeUrl("delete", $oObject->objectGetId()).
'">delete</a>&nbsp;]';
}
$oTableCell = new TableCell('[&nbsp;<a href="'.$this->makeUrl("edit",
$oObject->objectGetId()).'">'.$sEditLinkLabel.'</a>&nbsp;]'.$shDeleteLink);
$this->oTableRow->AddCell($oTableCell);
}
echo $this->oTableRow->GetString();
}
echo "</table>";
/* Should we let the class draw its own custom table? */
if(method_exists($this->sClass, 'objectWantCustomDraw') &&
$oObject->objectWantCustomDraw('table', $sQueued))
$oObject->objectDrawCustomTable($hResult, $sQueued);
else
$this->drawTable($hResult);
$oObject = new $this->sClass();
if($oObject->canEdit() && $this->GetOptionalSetting("objectShowAddEntry", FALSE))

View File

@@ -591,12 +591,72 @@ class screenshot
return $shImg;
}
public static function objectGetItemsPerPage($bQueued = false)
{
if($bQueued)
{
$aItemsPerPage = array(25, 50, 100, 200);
$iDefaultPerPage = 25;
} else
{
$aItemsPerPage = array(6, 9, 12, 15, 18, 21, 24);
$iDefaultPerPage = 6;
}
return array($aItemsPerPage, $iDefaultPerPage);
}
function objectWantCustomDraw($sWhat, $sQueued)
{
switch($sWhat)
{
case 'table':
if($sQueued == 'false')
return true;
break;
}
return false;
}
function objectDrawCustomTable($hResult, $sQueued)
{
echo "<div align=center><table><tr>\n";
for($i = 1; $oRow = query_fetch_object($hResult); $i++)
{
// display thumbnail
$oVersion = new version($oRow->versionId);
$oApp = new Application($oVersion->iAppId);
$oScreenshot = new Screenshot($oRow->id);
$shImg = $oScreenshot->get_thumbnail_img();
echo "<td align=center>\n";
echo $shImg;
echo "<div align=center>". substr($oRow->description,0,20). "\n";
echo "<br />[".$oApp->objectMakeLink()."]";
echo "<br />[".$oVersion->objectMakeLink()."]";
echo "</div></td>\n";
// end row if counter of 3
if($i % 3 == 0)
echo "</tr><tr>\n";
}
echo "</tr></table></div><br />\n";
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
{
return appData::objectGetEntries($bQueued, $bRejected, $iRows, $iStart,
"screenshot");
}
function objectGetEntriesCount($bQueued, $bRejected, $iRows = 0, $iStart = 0)
{
return appData::objectGetEntriesCount($bQueued, $bRejected,
'screenshot');
}
function objectGetHeader()
{
return appData::objectGetHeader("screenshot");

View File

@@ -18,7 +18,7 @@ function global_sidebar_menu()
$g->done();
$g = new htmlmenu("AppDB");
$g->add("Screenshots", BASE."viewScreenshots.php");
$g->add("Screenshots", BASE."objectManager.php?sClass=screenshot&sTitle=View+Screenshots");
$g->add("Browse Apps", BASE."appbrowse.php");
$g->add("Browse Newest Apps", BASE."objectManager.php?sClass=application&".
"bIsQueue=false&sTitle=Newest%20apps&sOrderBy=appId&bAscending=false");

View File

@@ -1,95 +0,0 @@
<?php
/************************************************************/
/* Page for managing all of the screenshots in the AppDB */
/* Without having go into each application version to do so */
/************************************************************/
require("path.php");
require(BASE."include/incl.php");
require_once(BASE."include/screenshot.php");
require_once(BASE."include/application.php");
apidb_header("View Screenshots");
echo "<div class='default_container'>\n";
/* display a range of 10 pages */
$pageRange = 10;
$ItemsPerPage = isset($aClean['iItemsPerPage']) ? $aClean['iItemsPerPage'] : 6;
$currentPage = isset($aClean['iPage']) ? $aClean['iPage'] : 1;
$ItemsPerPage = min($ItemsPerPage,100);
$totalPages = ceil(appData::objectGetEntriesCount("false", false,
"screenshot")/$ItemsPerPage);
$currentPage = min($currentPage,$totalPages);
$offset = (($currentPage-1) * $ItemsPerPage);
/* display page selection links */
echo "<center>";
echo "<b>Page $currentPage of $totalPages</b><br />";
display_page_range($currentPage, $pageRange, $totalPages,
$_SERVER['PHP_SELF']."?iItemsPerPage=".$ItemsPerPage);
echo "<br />";
echo "<br />";
/* display the option to choose how many screenshots per-page to display */
echo '<form method="get" name="message" action="'.$_SERVER['PHP_SELF'].'">';
echo '<b>Number of Screenshots per page:</b>';
echo "&nbsp<select name='iItemsPerPage'>";
$ItemsPerPageArray = array(6, 9, 12, 15, 18, 21, 24);
foreach($ItemsPerPageArray as $i => $value)
{
if($ItemsPerPageArray[$i] == $ItemsPerPage)
echo "<option value='$ItemsPerPageArray[$i]' SELECTED>$ItemsPerPageArray[$i]";
else
echo "<option value='$ItemsPerPageArray[$i]'>$ItemsPerPageArray[$i]";
}
echo "</select>";
echo "<input type=hidden name=iPage value=$currentPage>";
echo "&nbsp<input type=submit value='Refresh'>";
echo "</form>";
echo "</center>";
/* query for all of the Screenshots in assending order */
$Ids = appData::objectGetEntries(false, false, $ItemsPerPage, $offset, "screenshot");
$c = 1;
echo "<div align=center><table><tr>\n";
while ($oRow = query_fetch_object($Ids))
{
// display thumbnail
$oVersion = new version($oRow->versionId);
$oApp = new Application($oVersion->iAppId);
$oScreenshot = new Screenshot($oRow->id);
$img = $oScreenshot->get_thumbnail_img();
echo "<td align=center>\n";
echo $img;
echo "<div align=center>". substr($oRow->description,0,20). "\n";
echo "<br />[".$oApp->objectMakeLink()."]";
echo "<br />[".$oVersion->objectMakeLink()."]";
echo "</div></td>\n";
// end row if counter of 3
if ($c % 3 == 0) echo "</tr><tr>\n";
$c++;
}
echo "</tr></table></div><br />\n";
/* display page selection links */
echo "<center>";
display_page_range($currentPage, $pageRange, $totalPages,
$_SERVER['PHP_SELF']."?iItemsPerPage=".$ItemsPerPage);
echo "</center>";
echo "</div>\n";
apidb_footer();
?>