Navigation Menu

Skip to content

Commit

Permalink
Homepage|Add-on Repository: Sort add-ons alphanumerically
Browse files Browse the repository at this point in the history
Plus some minor cleanup.
  • Loading branch information
danij-deng committed Feb 24, 2012
1 parent 36a2cfb commit 9e5c297
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions web/plugins/addonrepository/addonrepository.php
Expand Up @@ -34,6 +34,21 @@ class AddonRepositoryPlugin extends Plugin implements Actioner, RequestInterpret

private $_displayOptions = 0;

// Symbolic game mode names:
private static $doomGameModes = array(
'doom1', 'doom1-ultimate', 'doom1-share', 'doom2', 'doom2-plut', 'doom2-tnt'
);

private static $hereticGameModes = array(
'heretic', 'heretic-share', 'heretic-ext'
);

private static $hexenGameModes = array(
'hexen', 'hexen-dk', 'hexen-demo'
);

private $addons = NULL;

public function __construct() {}

public function title()
Expand Down Expand Up @@ -173,37 +188,38 @@ private function outputAddonList(&$addons, $filter_gameModes, $filter_featured=-

}

public function generateHTML()
public static function packageSorter($packA, $packB)
{
global $FrontController;
return strcmp($packA['title'], $packB['title']);
}

$addonListXml = file_get_contents(FrontController::nativePath("plugins/addonrepository/addons.xml"));
public function generateHTML()
{
includeHTML('overview', self::$name);

$addons = array();
AddonsParser::parse($addonListXml, $addons);
if(0){
?><h3>Featured Add-ons</h3><?php

includeHTML('overview', self::$name);
$this->outputAddonList($this->addons, NULL/*no game mode filter*/, TRUE/*only featured*/);
}

?><h3>DOOM</h3>
<p>The following add-ons are for use with <strong>DOOM</strong>, <strong>DOOM2</strong>, <strong>Ultimate DOOM</strong> and <strong>Final DOOM (TNT/Plutonia)</strong>. Some of which may even be used with the shareware version of DOOM (check the <em>Notes</em>).</p>
<?php

$doomGames = array('doom1', 'doom1-ultimate', 'doom1-share', 'doom2', 'doom2-plut', 'doom2-tnt');
$this->outputAddonList($addons, $doomGames);
$this->outputAddonList($this->addons, self::$doomGameModes);

?><h3>Heretic</h3>
<p>The following add-ons are for use with <strong>Heretic</strong> and <strong>Heretic: Shadow of the Serpent Riders </strong>. Some of which may even be used with the shareware version of Heretic (check the <em>Notes</em>).</p>
<?php

$hereticGames = array('heretic', 'heretic-share', 'heretic-ext');
$this->outputAddonList($addons, $hereticGames);
$this->outputAddonList($this->addons, self::$hereticGameModes);

?><h3>Hexen</h3>
<p>The following add-ons are for use with <strong>Hexen</strong> and <strong>Hexen:Deathkings of the Dark Citadel</strong>. Some of which may even be used with the shareware version of Hexen (check the <em>Notes</em>).</p>
<?php

$hexenGames = array('hexen', 'hexen-dk', 'hexen-demo');
$this->outputAddonList($addons, $hexenGames);
$this->outputAddonList($this->addons, self::$hexenGameModes);

includeHTML('instructions', self::$name);
}
Expand All @@ -215,6 +231,16 @@ public function execute($args=NULL)
{
global $FrontController;

// Build the add-ons collection.
$addonListXml = file_get_contents(FrontController::nativePath("plugins/addonrepository/addons.xml"));

$this->addons = array();
AddonsParser::parse($addonListXml, $this->addons);

// Sort the collection.
uasort($this->addons, array('self', 'packageSorter'));

// Output the page.
$FrontController->outputHeader($this->title());
$FrontController->beginPage($this->title());

Expand Down

0 comments on commit 9e5c297

Please sign in to comment.