Build top-X lists from a function call that will use the highest

voted apps for the list and fill the rest of the list in with applications
that have screenshots.  Don't mention a blank top application if there are no
votes recorded and no top application.CVS:
----------------------------------------------------------------------
This commit is contained in:
Chris Morgan
2005-05-12 23:49:30 +00:00
committed by WineHQ
parent a88e2d16da
commit 012fbdf264
2 changed files with 62 additions and 45 deletions

View File

@@ -253,4 +253,52 @@ function lookupVendorName($vendorId)
return $vendor->vendorName; return $vendor->vendorName;
} }
/* Output the rows for the Top-X tables on the main page */
function outputTopXRowAppsFromRating($rating, $num_apps)
{
$sQuery = "SELECT appVotes.appId AS appId, COUNT( appVotes.appId ) AS c
FROM appVotes, appVersion
WHERE appVersion.maintainer_rating = '$rating'
AND appVersion.appId = appVotes.appId
GROUP BY appVotes.appId
ORDER BY c DESC
LIMIT $num_apps";
$hResult = query_appdb($sQuery);
$num_apps-=mysql_num_rows($hResult); /* take away the rows we are outputting here */
while($oRow = mysql_fetch_object($hResult))
{
$oApp = new Application($oRow->appId);
// image
$img = get_screenshot_img($oRow->appId);
echo '
<tr class="white">
<td><a href="appview.php?appId='.$oRow->appId.'">'.$oApp->sName.'</a></td>
<td>'.trim_description($oApp->sDescription).'</td>
<td>'.$img.'</td>
</tr>';
}
/* if we have any empty spots in the list, get these from applications with images */
$sQuery = "SELECT DISTINCT appVersion.appId as appId
FROM appVersion, appData
WHERE appVersion.maintainer_rating = '$rating'
AND appVersion.versionId = appData.versionId
AND appData.type = 'image'
AND appData.queued = 'false'
LIMIT $num_apps";
$hResult = query_appdb($sQuery);
while($oRow = mysql_fetch_object($hResult))
{
$oApp = new Application($oRow->appId);
// image
$img = get_screenshot_img($oRow->appId);
echo '
<tr class="white">
<td><a href="appview.php?appId='.$oRow->appId.'">'.$oApp->sName.'</a></td>
<td>'.trim_description($oApp->sDescription).'</td>
<td>'.$img.'</td>
</tr>';
}
}
?> ?>

View File

@@ -70,10 +70,17 @@ If you have screenshots or links to contribute, please browse the database and u
$voteAppId = $ob->appId; $voteAppId = $ob->appId;
$voteAppName = $ob->appName; $voteAppName = $ob->appName;
/* don't mention the top application if there are no votes yet */
echo "There are <b>$numApps</b> applications currently in the database with\n"; if($voteAppId != "")
echo "<a href='appview.php?appId=$voteAppId'>$voteAppName</a> being the\n"; {
echo "top <a href='votestats.php'>voted</a> application.\n"; echo "There are <b>$numApps</b> applications currently in the database with\n";
echo "<a href='appview.php?appId=$voteAppId'>$voteAppName</a> being the\n";
echo "top <a href='votestats.php'>voted</a> application.\n";
} else
{
echo "There are <b>$numApps</b> applications currently in the database, please\n";
echo "<a href=\"".BASE."help/?topic=voting\" title=\"help on voting\" style=\"cursor: help\">vote</a> for your favorite application.\n";
}
?> ?>
<br /><br /> <br /><br />
@@ -89,26 +96,7 @@ If you have screenshots or links to contribute, please browse the database and u
<th>Application</th><th>Description</th><th>Screenshot</th> <th>Application</th><th>Description</th><th>Screenshot</th>
</tr> </tr>
<?php <?php
$sQuery = "SELECT appVotes.appId AS appId, COUNT( appVotes.appId ) AS c outputTopXRowAppsFromRating('Gold', 10);
FROM appVotes, appVersion
WHERE appVersion.maintainer_rating = 'Gold'
AND appVersion.appId = appVotes.appId
GROUP BY appVotes.appId
ORDER BY c DESC
LIMIT 10";
$hResult = query_appdb($sQuery);
while($oRow = mysql_fetch_object($hResult))
{
$oApp = new Application($oRow->appId);
// image
$img = get_screenshot_img($oRow->appId);
echo '
<tr class="white">
<td><a href="appview.php?appId='.$oRow->appId.'">'.$oApp->sName.'</a></td>
<td>'.trim_description($oApp->sDescription).'</td>
<td>'.$img.'</td>
</tr>';
}
?> ?>
</table> </table>
<br /> <br />
@@ -119,26 +107,7 @@ while($oRow = mysql_fetch_object($hResult))
<th>Application</th><th>Description</th><th>Screenshot</th> <th>Application</th><th>Description</th><th>Screenshot</th>
</tr> </tr>
<?php <?php
$sQuery = "SELECT appVotes.appId AS appId, COUNT( appVotes.appId ) AS c outputTopXRowAppsFromRating('Silver', 10);
FROM appVotes, appVersion
WHERE appVersion.maintainer_rating = 'Silver'
AND appVersion.appId = appVotes.appId
GROUP BY appVotes.appId
ORDER BY c DESC
LIMIT 10";
$hResult = query_appdb($sQuery);
while($oRow = mysql_fetch_object($hResult))
{
$oApp = new Application($oRow->appId);
// image
$img = get_screenshot_img($oRow->appId);
echo '
<tr class="white">
<td><a href="appview.php?appId='.$oRow->appId.'">'.$oApp->sName.'</a></td>
<td>'.trim_description($oApp->sDescription).'</td>
<td>'.$img.'</td>
</tr>';
}
?> ?>
</table> </table>