Implement browsing of newest apps in the object manager infrastructure
This commit is contained in:
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Browse newest applications
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
require("path.php");
|
|
||||||
require(BASE."include/incl.php");
|
|
||||||
|
|
||||||
/* Set default value */
|
|
||||||
if(empty($aClean['iNumVersions']) || $aClean['iNumVersions'] > 200 || $aClean['iNumVersions'] < 0)
|
|
||||||
$aClean['iNumVersions'] = 25;
|
|
||||||
|
|
||||||
apidb_header("Browse Newest Applications");
|
|
||||||
|
|
||||||
/* Selector for how many versions to view */
|
|
||||||
echo "<form method=\"post\" name=\"sMessage\" action=\"".$_SERVER['PHP_SELF']."\">";
|
|
||||||
echo "<b>How many versions to display:</b>";
|
|
||||||
echo "<select name='iNumVersions'>";
|
|
||||||
|
|
||||||
$numVersionsArray = array(25, 50, 100, 200);
|
|
||||||
|
|
||||||
foreach($numVersionsArray as $i => $value)
|
|
||||||
{
|
|
||||||
if($numVersionsArray[$i] == $aClean['iNumVersions'])
|
|
||||||
echo "<option selected=\"selected\">$numVersionsArray[$i]</option>";
|
|
||||||
else
|
|
||||||
echo "<option>$numVersionsArray[$i]</option>";
|
|
||||||
}
|
|
||||||
echo "</select>";
|
|
||||||
|
|
||||||
echo ' <input type="submit" value="Refresh" />';
|
|
||||||
echo '</form>';
|
|
||||||
echo '<br />';
|
|
||||||
|
|
||||||
/* Query the database for the n newest versions */
|
|
||||||
$hResult = query_parameters("SELECT appId, appName, description, submitTime FROM appFamily WHERE
|
|
||||||
queued = 'false' ORDER BY appId DESC LIMIT ?",
|
|
||||||
$aClean['iNumVersions']);
|
|
||||||
|
|
||||||
if($hResult)
|
|
||||||
{
|
|
||||||
echo html_frame_start("", "90%", '', 0);
|
|
||||||
echo html_table_begin("width=\"100%\" align=\"center\"");
|
|
||||||
echo "<tr class=\"color4\">\n";
|
|
||||||
echo "<td><font color=\"white\">Submission Date</font></td>\n";
|
|
||||||
echo "<td><font color=\"white\">Application</font></td>\n";
|
|
||||||
echo "<td><font color=\"white\">Description</font></td></tr>\n";
|
|
||||||
|
|
||||||
$c = 1;
|
|
||||||
while($row = mysql_fetch_object($hResult))
|
|
||||||
{
|
|
||||||
$oApp = new application($row->appId);
|
|
||||||
$bgcolor = ($c % 2) ? "color0" : "color1";
|
|
||||||
$link = $oApp->objectMakeLink();
|
|
||||||
echo "<tr class=\"$bgcolor\">";
|
|
||||||
echo "<td width=\"20%\">".print_short_date(mysqltimestamp_to_unixtimestamp($row->submitTime))."</td>\n";
|
|
||||||
echo "<td>$link </td>\n";
|
|
||||||
echo "<td>$row->description </td></tr>\n";
|
|
||||||
$c++;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo html_table_end();
|
|
||||||
echo html_frame_end();
|
|
||||||
}
|
|
||||||
|
|
||||||
apidb_footer();
|
|
||||||
|
|
||||||
?>
|
|
||||||
140
include/browse_newest_apps.php
Normal file
140
include/browse_newest_apps.php
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// class lists the newest applications and versions in the database
|
||||||
|
|
||||||
|
class browse_newest_apps
|
||||||
|
{
|
||||||
|
var $iAppId;
|
||||||
|
|
||||||
|
// constructor doesn't need to perform any queries. we provide a constructor for
|
||||||
|
// browse_newest_apps because the objectManager requires an instance for some methods
|
||||||
|
function browse_newest_apps($iAppId = null, $oRow = null)
|
||||||
|
{
|
||||||
|
if(!$iAppId && !$oRow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!$oRow)
|
||||||
|
{
|
||||||
|
$this->iAppId = $iAppId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($oRow)
|
||||||
|
{
|
||||||
|
$this->iAppId = $oRow->appId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
|
||||||
|
{
|
||||||
|
// We don't implement queues or rejected applications
|
||||||
|
if($bQueued || $bRejected)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
// if row limit is 0 we want to fetch all rows
|
||||||
|
if(!$iRows)
|
||||||
|
{
|
||||||
|
$iRows = browse_newest_apps::objectGetEntriesCount($bQueued, $bRejected);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sQuery = "SELECT appId, appName, description, submitTime FROM appFamily WHERE".
|
||||||
|
" queued = '?' ORDER BY appId DESC LIMIT ?,?";
|
||||||
|
|
||||||
|
return query_parameters($sQuery, $bQueued ? "true" : "false",
|
||||||
|
$iStart, $iRows);
|
||||||
|
}
|
||||||
|
|
||||||
|
function objectGetEntriesCount($bQueued, $bRejected)
|
||||||
|
{
|
||||||
|
// We don't implement queues or rejected applications
|
||||||
|
if($bQueued || $bRejected)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return application::objectGetEntriesCount($bQueued, $bRejected);
|
||||||
|
}
|
||||||
|
|
||||||
|
function objectGetHeader()
|
||||||
|
{
|
||||||
|
$aCells = array(
|
||||||
|
array("Submission Date", "color=\"white\""),
|
||||||
|
array("Application", "color=\"white\""),
|
||||||
|
array("Description", "color=\"white\""));
|
||||||
|
|
||||||
|
return $aCells;
|
||||||
|
}
|
||||||
|
|
||||||
|
function objectGetTableRow()
|
||||||
|
{
|
||||||
|
$oApp = new application($this->iAppId);
|
||||||
|
$aCells = array(
|
||||||
|
array(print_short_date(mysqltimestamp_to_unixtimestamp($oApp->sSubmitTime)),
|
||||||
|
"width=\"20%\""),
|
||||||
|
$oApp->objectMakeLink(),
|
||||||
|
util_trim_description($oApp->sDescription));
|
||||||
|
|
||||||
|
|
||||||
|
$oTableRow = new TableRow($aCells);
|
||||||
|
return $oTableRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
function objectGetItemsPerPage($bQueued = false)
|
||||||
|
{
|
||||||
|
$aItemsPerPage = array(25, 50, 100, 200);
|
||||||
|
$iDefaultPerPage = 25;
|
||||||
|
return array($aItemsPerPage, $iDefaultPerPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
function objectGetId()
|
||||||
|
{
|
||||||
|
return $this->iAppId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub implementation
|
||||||
|
function allowAnonymousSubmissions()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub canEdit() out, no one can edit these entries
|
||||||
|
function canEdit()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub implementation
|
||||||
|
function display()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub implementation
|
||||||
|
function outputEditor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub implementation
|
||||||
|
function getOutputEditorValues($aValues)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub implementation
|
||||||
|
function objectMakeLink()
|
||||||
|
{
|
||||||
|
$oApp = new Application($this->iAppId);
|
||||||
|
return $oApp->objectMakeLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub implementation
|
||||||
|
function objectMakeUrl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// stub implementation
|
||||||
|
function mustBeQueued()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -20,7 +20,8 @@ function global_sidebar_menu()
|
|||||||
$g = new htmlmenu("AppDB");
|
$g = new htmlmenu("AppDB");
|
||||||
$g->add("Screenshots", BASE."viewScreenshots.php");
|
$g->add("Screenshots", BASE."viewScreenshots.php");
|
||||||
$g->add("Browse Apps", BASE."appbrowse.php");
|
$g->add("Browse Apps", BASE."appbrowse.php");
|
||||||
$g->add("Browse Newest Apps", BASE."browse_newest_apps.php");
|
$g->add("Browse Newest Apps", BASE."objectManager.php?sClass=browse_newest_apps&".
|
||||||
|
"bIsQueue=false&sTitle=Newest%20apps");
|
||||||
$g->add("Downloadable Apps", BASE."browse_downloadable.php");
|
$g->add("Downloadable Apps", BASE."browse_downloadable.php");
|
||||||
$g->add("Browse Apps by Rating", BASE."browse_by_rating.php");
|
$g->add("Browse Apps by Rating", BASE."browse_by_rating.php");
|
||||||
$g->add("Top 25", BASE."votestats.php");
|
$g->add("Top 25", BASE."votestats.php");
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ require_once(BASE.'include/objectManager.php');
|
|||||||
require_once(BASE.'include/application_queue.php');
|
require_once(BASE.'include/application_queue.php');
|
||||||
require_once(BASE.'include/version_queue.php');
|
require_once(BASE.'include/version_queue.php');
|
||||||
require_once(BASE.'include/testData_queue.php');
|
require_once(BASE.'include/testData_queue.php');
|
||||||
|
require_once(BASE.'include/browse_newest_apps.php');
|
||||||
|
|
||||||
/* if we have no valid class name we should abort */
|
/* if we have no valid class name we should abort */
|
||||||
if(!$aClean['sClass'])
|
if(!$aClean['sClass'])
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ require_once(BASE.'include/maintainer.php');
|
|||||||
require_once(BASE.'include/testData_queue.php');
|
require_once(BASE.'include/testData_queue.php');
|
||||||
require_once(BASE.'include/version_queue.php');
|
require_once(BASE.'include/version_queue.php');
|
||||||
require_once(BASE.'include/application_queue.php');
|
require_once(BASE.'include/application_queue.php');
|
||||||
|
require_once(BASE.'include/browse_newest_apps.php');
|
||||||
|
|
||||||
/* internal function */
|
/* internal function */
|
||||||
function test_class($sClassName, $aTestMethods)
|
function test_class($sClassName, $aTestMethods)
|
||||||
@@ -25,6 +26,11 @@ function test_class($sClassName, $aTestMethods)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: work around for 'browse_newest_apps' class
|
||||||
|
// since we can't create a new database object of browse_newest_apps
|
||||||
|
if($sClassName == "browse_newest_apps")
|
||||||
|
return true;
|
||||||
|
|
||||||
/* Set up test user */
|
/* Set up test user */
|
||||||
global $test_email, $test_password;
|
global $test_email, $test_password;
|
||||||
if(!$oUser = create_and_login_user())
|
if(!$oUser = create_and_login_user())
|
||||||
@@ -278,6 +284,7 @@ function test_object_methods()
|
|||||||
|
|
||||||
$aTestClasses = array("application",
|
$aTestClasses = array("application",
|
||||||
"application_queue",
|
"application_queue",
|
||||||
|
"browse_newest_apps",
|
||||||
"distribution",
|
"distribution",
|
||||||
"downloadurl",
|
"downloadurl",
|
||||||
"maintainer",
|
"maintainer",
|
||||||
|
|||||||
Reference in New Issue
Block a user