Skip to content

Commit

Permalink
Homepage|Build Repository: Sort platform versions by latest/best
Browse files Browse the repository at this point in the history
The latest/best version of each platform should be listed first.
Updated comment in source to reflect the impact of the platform ID
ordinal values.
  • Loading branch information
skyjake committed Mar 7, 2014
1 parent ec6ef2c commit 4c5963d
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions web/plugins/buildrepository/buildrepository.php
Expand Up @@ -29,13 +29,13 @@
* @ingroup builds
*/
///@{
define('PID_ANY', 0); ///< (Enumeration). Ordinals are meaningless (can change) however must be unique.
define('PID_ANY', 0); ///< (Enumeration). Ordinal value affects sort order and must be unique.
define('PID_WIN_X86', 1);
define('PID_MAC10_4_X86_PPC', 2);
define('PID_MAC10_8_X86_64', 2);
define('PID_MAC10_6_X86_X86_64', 3);
define('PID_MAC10_8_X86_64', 4);
define('PID_LINUX_X86', 5);
define('PID_LINUX_X86_64', 6);
define('PID_MAC10_4_X86_PPC', 4);
define('PID_LINUX_X86_64', 5);
define('PID_LINUX_X86', 6);
define('PID_SOURCE', 7);
///@}

Expand Down Expand Up @@ -73,11 +73,11 @@ class BuildRepositoryPlugin extends Plugin implements Actioner, RequestInterpret
*/
private static $platforms = array(
PID_WIN_X86 => array('id'=>PID_WIN_X86, 'name'=>'win-x86', 'nicename'=>'Windows'),
PID_MAC10_4_X86_PPC => array('id'=>PID_MAC10_4_X86_PPC, 'name'=>'mac10_4-x86-ppc', 'nicename'=>'OS X 10.4+'),
PID_MAC10_6_X86_X86_64 => array('id'=>PID_MAC10_6_X86_X86_64, 'name'=>'mac10_6-x86-x86_64', 'nicename'=>'OS X 10.6+'),
PID_MAC10_8_X86_64 => array('id'=>PID_MAC10_8_X86_64, 'name'=>'mac10_8-x86_64', 'nicename'=>'OS X 10.8+'),
PID_LINUX_X86 => array('id'=>PID_LINUX_X86, 'name'=>'linux-x86', 'nicename'=>'Ubuntu (32bit)'),
PID_LINUX_X86_64 => array('id'=>PID_LINUX_X86_64, 'name'=>'linux-x86_64', 'nicename'=>'Ubuntu (64bit)'),
PID_MAC10_6_X86_X86_64 => array('id'=>PID_MAC10_6_X86_X86_64, 'name'=>'mac10_6-x86-x86_64', 'nicename'=>'OS X 10.6+'),
PID_MAC10_4_X86_PPC => array('id'=>PID_MAC10_4_X86_PPC, 'name'=>'mac10_4-x86-ppc', 'nicename'=>'OS X 10.4+'),
PID_LINUX_X86_64 => array('id'=>PID_LINUX_X86_64, 'name'=>'linux-x86_64', 'nicename'=>'Ubuntu 12.04 (64bit)'),
PID_LINUX_X86 => array('id'=>PID_LINUX_X86, 'name'=>'linux-x86', 'nicename'=>'Ubuntu 12.04 (32bit)'),
PID_SOURCE => array('id'=>PID_SOURCE, 'name'=>'source', 'nicename'=>'Source code')
);
private static $unknownPlatform = array(
Expand Down Expand Up @@ -202,8 +202,11 @@ public static function packageWeight(&$pack)

public static function packageSorter($packA, $packB)
{
// Primarily by platform id.
if($packA->platformId() !== $packB->platformId()) return $packA->platformId() - $packB->platformId();
// Primarily by platform id (ordinal value).
if($packA->platformId() !== $packB->platformId())
{
return $packA->platformId() - $packB->platformId();
}

// Secondarily by package type.
if($packA === $packB) return 0;
Expand Down

0 comments on commit 4c5963d

Please sign in to comment.