Fix screenshot counting and browsing. Make sure to specify the 'screenshot' tpe and use

appData functions for both counting and listing on the screenshots page, ensuring consistent
results.
This commit is contained in:
Alexander Nicolaysen Sørnes
2007-03-13 00:13:51 +00:00
committed by WineHQ
parent 695e8c32a1
commit 3c3e3a7ca4
4 changed files with 34 additions and 17 deletions

View File

@@ -74,7 +74,7 @@ echo "</tr>\n\n";
/* Display the number of images */ /* Display the number of images */
echo "<tr class=color4>\n"; echo "<tr class=color4>\n";
echo " <td>Screenshots:</td>\n"; echo " <td>Screenshots:</td>\n";
echo " <td>".appData::objectGetEntriesCount(false)."</td>\n"; echo " <td>".appData::objectGetEntriesCount("false", "screenshot")."</td>\n";
echo "</tr>\n\n"; echo "</tr>\n\n";
echo "</table>\n\n"; echo "</table>\n\n";

View File

@@ -108,8 +108,8 @@ class appData
if(($sQueued == "true" || $sQueued == "all") && if(($sQueued == "true" || $sQueued == "all") &&
!$_SESSION['current']->hasPriv("admin")) !$_SESSION['current']->hasPriv("admin"))
{ {
$sQuery = "SELECT COUNT(DISTINCT id) as count FROM appData, appMaintainers, $sQuery = "SELECT COUNT(DISTINCT appData.id) as count FROM appData,
appVersion, appFamily WHERE appMaintainers, appVersion, appFamily WHERE
appFamily.appId = appVersion.appId appFamily.appId = appVersion.appId
AND AND
appMaintainers.userId = '?' appMaintainers.userId = '?'
@@ -159,7 +159,7 @@ class appData
} }
} else } else
{ {
$sQuery = "SELECT COUNT(DISTINCT id) as count FROM appData, $sQuery = "SELECT COUNT(DISTINCT appData.id) as count FROM appData,
appFamily, appVersion WHERE appFamily, appVersion WHERE
appFamily.appId = appVersion.appId appFamily.appId = appVersion.appId
AND AND
@@ -209,7 +209,7 @@ class appData
echo html_tr($aCells, $sClass); echo html_tr($aCells, $sClass);
} }
function objectGetEntries($bQueued, $sType) function objectGetEntries($bQueued, $iRows = 0, $iStart = 0, $sType)
{ {
if($bQueued && !appData::canEdit($sType)) if($bQueued && !appData::canEdit($sType))
return FALSE; return FALSE;
@@ -259,9 +259,21 @@ class appData
appData.queued = '?' appData.queued = '?'
AND AND
appData.type = '?'"; appData.type = '?'";
if(!$iRows && !$iStarts)
{
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$bQueued ? "true" : "false", $sType); $bQueued ? "true" : "false", $sType);
} else } else
{
if(!$iRows)
$iRows = appData::objectGetEntriesCount($bQueued ? "true" : "false",
$sType);
$sQuery .= " LIMIT ?,?";
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$bQueued ? "true" : "false", $sType,
$iStart, $iRows);
}
} else
{ {
$sQuery = "SELECT DISTINCT appData.* FROM appData, appFamily, appVersion $sQuery = "SELECT DISTINCT appData.* FROM appData, appFamily, appVersion
WHERE WHERE
@@ -280,7 +292,18 @@ class appData
appData.queued = '?' appData.queued = '?'
AND AND
appData.type = '?'"; appData.type = '?'";
if(!$iRows && !$iStart)
{
$hResult = query_parameters($sQuery, $bQueued ? "true" : "false", $sType); $hResult = query_parameters($sQuery, $bQueued ? "true" : "false", $sType);
} else
{
if(!$iRows)
$iRows = appData::objectGetEntriesCount($bQueued ? "true" : "false",
$sType);
$sQuery .= " LIMIT ?,?";
$hResult = query_parameters($sQuery, $bQueued ? "true" : "false", $sType,
$iStart, $iRows);
}
} }
if(!$hResult) if(!$hResult)

View File

@@ -509,9 +509,9 @@ class Screenshot {
return $shImg; return $shImg;
} }
function objectGetEntries($bQueued) function objectGetEntries($bQueued, $iRows = 0, $iStart = 0)
{ {
return appData::objectGetEntries($bQueued, "screenshot"); return appData::objectGetEntries($bQueued, $iRows, $iStart, "screenshot");
} }
function objectOutputHeader($sClass) function objectOutputHeader($sClass)

View File

@@ -22,7 +22,7 @@ if($aClean['iPage'])
$currentPage = $aClean['iPage']; $currentPage = $aClean['iPage'];
$ItemsPerPage = min($ItemsPerPage,100); $ItemsPerPage = min($ItemsPerPage,100);
$totalPages = ceil(appData::objectGetEntriesCount(false)/$ItemsPerPage); $totalPages = ceil(appData::objectGetEntriesCount("false", "screenshot")/$ItemsPerPage);
$currentPage = min($currentPage,$totalPages); $currentPage = min($currentPage,$totalPages);
$offset = (($currentPage-1) * $ItemsPerPage); $offset = (($currentPage-1) * $ItemsPerPage);
@@ -57,13 +57,7 @@ echo "</form>";
echo "</center>"; echo "</center>";
/* query for all of the Screenshots in assending order */ /* query for all of the Screenshots in assending order */
$Ids = query_parameters("SELECT * from appData $Ids = appData::objectGetEntries(false, $ItemsPerPage, $offset, "screenshot");
WHERE
type = 'screenshot'
AND
queued = 'false'
ORDER BY id ASC LIMIT ?, ?",
$offset, $ItemsPerPage);
$c = 1; $c = 1;
echo "<div align=center><table><tr>\n"; echo "<div align=center><table><tr>\n";
while ($oRow = mysql_fetch_object($Ids)) while ($oRow = mysql_fetch_object($Ids))