Jeremy Newman : move home page only funcs to home page
Jeremy Newman
jnewman at winehq.org
Tue Nov 22 10:24:27 CST 2016
Module: appdb
Branch: master
Commit: c5d6cf5c751fa7575c92eebf880c137e5e98bf1c
URL: http://source.winehq.org/git/appdb.git/?a=commit;h=c5d6cf5c751fa7575c92eebf880c137e5e98bf1c
Author: Jeremy Newman <jnewman at codeweavers.com>
Date: Tue Nov 22 10:21:46 2016 -0600
move home page only funcs to home page
* reducing global code in util.php
* add commas to app count
---
include/util.php | 83 ------------------------------------------------------
index.php | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 84 insertions(+), 84 deletions(-)
diff --git a/include/util.php b/include/util.php
index cdc8d96..367179d 100644
--- a/include/util.php
+++ b/include/util.php
@@ -266,89 +266,6 @@ function getNumberOfComments()
return $oRow->num_comments;
}
-/* used by outputTopXRowAppsFromRating() to reduce duplicated code */
-function outputTopXRow($oRow)
-{
- $oVersion = new Version($oRow->versionId);
- $oApp = new Application($oVersion->iAppId);
- $img = Screenshot::get_random_screenshot_img(null, $oRow->versionId, false); // image, disable extra formatting
-
- // create the table row
- $oTableRow = new TableRow();
- $oTableRow->SetClass("white");
-
- // create the cells that represent the row
- $oTableCell = new TableCell(version::fullNameLink($oVersion->iVersionId));
- $oTableCell->SetClass("app_name");
- $oTableRow->AddCell($oTableCell);
- $oTableRow->AddTextCell(util_trim_description($oApp->sDescription));
- $oTableCell = new TableCell($img);
- $oTableCell->SetStyle("text-align:center;");
- $oTableRow->AddCell($oTableCell);
-
- // create a new TableRowclick
- $oTableRowClick = new TableRowClick($oVersion->objectMakeUrl());
-
- // set the click property of the html table row
- $oTableRow->SetRowClick($oTableRowClick);
-
- // output the entire table row
- echo $oTableRow->GetString();
- echo "\n";
-}
-
-/* Output the rows for the Top-X tables on the main page */
-function outputTopXRowAppsFromRating($sRating, $iNumApps)
-{
- /* clean the input values so we can continue to use query_appdb() */
- $sRating = query_escape_string($sRating);
- $iNumApps = query_escape_string($iNumApps);
-
- /* list of versionIds we've already output, so we don't output */
- /* them again when filling in any empty spots in the list */
- $aVersionId = array();
-
- $sQuery = "SELECT appVotes.versionId, COUNT( appVotes.versionId ) AS c
- FROM appVotes, appVersion
- WHERE appVersion.rating = '?'
- AND appVersion.versionId = appVotes.versionId
- AND appVersion.state = 'accepted'
- GROUP BY appVotes.versionId
- ORDER BY c DESC
- LIMIT ?";
- $hResult = query_parameters($sQuery, $sRating, $iNumApps);
- $iNumApps -= query_num_rows($hResult); /* take away the rows we are outputting here */
- while($oRow = query_fetch_object($hResult))
- {
- /* keep track of the apps we've already output */
- $aVersionId[] = $oRow->versionId;
- outputTopXRow($oRow);
- }
-
- /* if we have no more app entries we should stop now and save ourselves a query */
- if(!$iNumApps) return;
-
- /* if we have any empty spots in the list, get these from applications with images */
- $sQuery = "SELECT DISTINCT appVersion.versionId
- FROM appVersion, appData
- WHERE appVersion.rating = '$sRating'
- AND appVersion.versionId = appData.versionId
- AND appVersion.state = 'accepted'
- AND appData.type = 'screenshot'
- AND appData.state = 'accepted'";
-
- /* make sure we exclude any apps we've already output */
- foreach($aVersionId as $key=>$value)
- $sQuery.="AND appVersion.versionId != '".$value."' ";
-
- $sQuery .= " LIMIT $iNumApps";
-
- /* get the list that will fill the empty spots */
- $hResult = query_appdb($sQuery);
- while($oRow = query_fetch_object($hResult))
- outputTopXRow($oRow);
-}
-
/* return true if this word is in the list of words to ignore */
function isIgnoredWord($sWord)
{
diff --git a/index.php b/index.php
index d7fa469..71e32b4 100644
--- a/index.php
+++ b/index.php
@@ -11,6 +11,89 @@
require("path.php");
require(BASE."include/incl.php");
+/* used by outputTopXRowAppsFromRating() to reduce duplicated code */
+function outputTopXRow($oRow)
+{
+ $oVersion = new Version($oRow->versionId);
+ $oApp = new Application($oVersion->iAppId);
+ $img = Screenshot::get_random_screenshot_img(null, $oRow->versionId, false); // image, disable extra formatting
+
+ // create the table row
+ $oTableRow = new TableRow();
+ $oTableRow->SetClass("white");
+
+ // create the cells that represent the row
+ $oTableCell = new TableCell(version::fullNameLink($oVersion->iVersionId));
+ $oTableCell->SetClass("app_name");
+ $oTableRow->AddCell($oTableCell);
+ $oTableRow->AddTextCell(util_trim_description($oApp->sDescription));
+ $oTableCell = new TableCell($img);
+ $oTableCell->SetClass("text-center padding-left-md padding-right-md");
+ $oTableRow->AddCell($oTableCell);
+
+ // create a new TableRowclick
+ $oTableRowClick = new TableRowClick($oVersion->objectMakeUrl());
+
+ // set the click property of the html table row
+ $oTableRow->SetRowClick($oTableRowClick);
+
+ // output the entire table row
+ echo $oTableRow->GetString();
+ echo "\n";
+}
+
+/* Output the rows for the Top-X tables on the main page */
+function outputTopXRowAppsFromRating($sRating, $iNumApps)
+{
+ /* clean the input values so we can continue to use query_appdb() */
+ $sRating = query_escape_string($sRating);
+ $iNumApps = query_escape_string($iNumApps);
+
+ /* list of versionIds we've already output, so we don't output */
+ /* them again when filling in any empty spots in the list */
+ $aVersionId = array();
+
+ $sQuery = "SELECT appVotes.versionId, COUNT( appVotes.versionId ) AS c
+ FROM appVotes, appVersion
+ WHERE appVersion.rating = '?'
+ AND appVersion.versionId = appVotes.versionId
+ AND appVersion.state = 'accepted'
+ GROUP BY appVotes.versionId
+ ORDER BY c DESC
+ LIMIT ?";
+ $hResult = query_parameters($sQuery, $sRating, $iNumApps);
+ $iNumApps -= query_num_rows($hResult); /* take away the rows we are outputting here */
+ while($oRow = query_fetch_object($hResult))
+ {
+ /* keep track of the apps we've already output */
+ $aVersionId[] = $oRow->versionId;
+ outputTopXRow($oRow);
+ }
+
+ /* if we have no more app entries we should stop now and save ourselves a query */
+ if(!$iNumApps) return;
+
+ /* if we have any empty spots in the list, get these from applications with images */
+ $sQuery = "SELECT DISTINCT appVersion.versionId
+ FROM appVersion, appData
+ WHERE appVersion.rating = '$sRating'
+ AND appVersion.versionId = appData.versionId
+ AND appVersion.state = 'accepted'
+ AND appData.type = 'screenshot'
+ AND appData.state = 'accepted'";
+
+ /* make sure we exclude any apps we've already output */
+ foreach($aVersionId as $key=>$value)
+ $sQuery.="AND appVersion.versionId != '".$value."' ";
+
+ $sQuery .= " LIMIT $iNumApps";
+
+ /* get the list that will fill the empty spots */
+ $hResult = query_appdb($sQuery);
+ while($oRow = query_fetch_object($hResult))
+ outputTopXRow($oRow);
+}
+
apidb_header("Wine Application Database");
?>
@@ -63,7 +146,7 @@ else
?>
<?php
- $iNumApps = version::objectGetEntriesCount('accepted');
+ $iNumApps = number_format(version::objectGetEntriesCount('accepted'));
$voteQuery = "SELECT appVotes.versionId, count(userId) as count ".
"FROM appVotes ".
More information about the wine-cvs
mailing list