200 || $aClean['iTopNumber'] < 0) $aClean['iTopNumber'] = 25; if(empty($aClean['iCategoryId'])) $aClean['iCategoryId'] = 0; apidb_header("Vote Stats - Top ".$aClean['iTopNumber']." Applications"); echo "
\n"; /* display the selection for the top number of apps to view */ echo "
"; echo "Number of top apps to display:"; echo ""; /** * build an array of categories from the current category back up * the tree to the main category */ $cat_array = Array(); $cat_name_array = Array(); if(!empty($aClean['iCategoryId'])) { $currentCatId = $aClean['iCategoryId']; do { $sCatQuery = "SELECT appCategory.catName, appCategory.catParent ". "FROM appCategory WHERE appCategory.catId = '?'"; $hResult = query_parameters($sCatQuery, $currentCatId); if($hResult) { $oRow = query_fetch_object($hResult); $catParent = $oRow->catParent; array_push($cat_array, "$currentCatId"); array_push($cat_name_array, "$oRow->catName"); } $currentCatId = $catParent; } while($currentCatId != 0); } /*******************************************************************/ /* add options for all of the categories that we are recursed into */ echo "Section:"; echo ''; echo ''; echo '
'; echo '
'; echo '
'; /***************************************************/ /* build a list of the apps in the chosen category */ if(empty($aClean['iCategoryId'])) { /* leave out the appFamily.catId = '$aClean['iCategoryId']' */ $hResult = query_parameters("SELECT appVotes.versionId, versionName, appName, count(userId) as count FROM appVotes, appFamily, appVersion WHERE appVotes.versionId = appVersion.versionId AND appFamily.appId = appVersion.appId AND appVersion.state = 'accepted' GROUP BY appVotes.versionId ORDER BY count DESC LIMIT ?", $aClean['iTopNumber']); } else { /* Display all application for a given category (including sub categories) SELECT f.appId, f.appName FROM appFamily AS f, appCategory AS c WHERE f.catId = c.catId AND ( c.catId =29 OR c.catParent =29)*/ $hResult = query_parameters("SELECT v.versionId, appVersion.versionName, f.appName, count( v.versionId ) AS count FROM appFamily AS f, appCategory AS c, appVotes AS v, appVersion WHERE appVersion.appId = f.appId AND appVersion.versionId = v.versionId AND appVersion.state = 'accepted' AND f.catId = c.catId AND ( c.catId = '?' OR c.catParent = '?' ) GROUP BY v.versionId ORDER BY count DESC LIMIT ?", $aClean['iCategoryId'], $aClean['iCategoryId'], $aClean['iTopNumber']); } if($hResult) { echo html_frame_start("", "90%", '', 0); $oTable = new Table(); $oTable->SetWidth("100%"); $oTable->SetAlign("center"); $oTableRow = new TableRow(); $oTableRow->SetClass("color4"); $oTableRow->AddTextCell("Application Name"); $oTableRow->AddTextCell("Votes"); $oTable->AddRow($oTableRow); $c = 1; while($oRow = query_fetch_object($hResult)) { $sColor = ($c % 2) ? "color0" : "color1"; $oTableRowHighlight = GetStandardRowHighlight($c); $shLink = version::fullNameLink($oRow->versionId); $oVersion = new Version($oRow->versionId); $oTableRowClick = new TableRowClick($oVersion->objectMakeUrl()); $oTableRowClick->SetHighlight($oTableRowHighlight); $oTableRow = new TableRow(); $oTableRow->SetRowClick($oTableRowClick); $oTableRow->SetClass($sColor); $oTableCell = new TableCell("$c.".$shLink); $oTableCell->SetWidth("90%"); $oTableRow->AddCell($oTableCell); $oTableRow->AddTextCell($oRow->count); $oTable->AddRow($oTableRow); $c++; } // output the table echo $oTable->GetString(); echo html_frame_end(); /* Make sure we tell the user here are no apps, otherwise they might */ /* think that something went wrong with the server */ if($c == 1) { echo '

No apps found in this category, please vote for your favorite apps!

'; } echo '

What does this screen mean?

'; } echo "
\n"; apidb_footer(); ?>