Skip to content

Commit

Permalink
Homepage|Build Repository: Fixed order of packages on event detail pages
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Apr 20, 2012
1 parent d8f6d5e commit d11ef15
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions web/plugins/buildrepository/buildrepository.php
Expand Up @@ -106,10 +106,14 @@ class BuildRepositoryPlugin extends Plugin implements Actioner, RequestInterpret

/// Weight values for sorting of Packages.
private static $packageWeights = array(
'DistributionPackage' =>0,
'PluginPackage' =>1,
'UnstableDistributionPackage' =>2,
'UnstablePluginPackage' =>3
'DistributionPackage' =>0,
'DistributionBuilderPackage' =>0,
'PluginPackage' =>1,
'PluginBuilderPackage' =>1,
'DistributionUnstablePackage' =>2,
'DistributionUnstableBuilderPackage' =>2,
'PluginUnstablePackage' =>3,
'PluginUnstableBuilderPackage' =>3
);

/// @return Plugin name.
Expand Down Expand Up @@ -201,8 +205,10 @@ public static function packageSorter($packA, $packB)
if($packA === $packB) return 0;
$a = self::packageWeight($packA);
$b = self::packageWeight($packB);
if($a === $b) return 0;
return $a < $b? -1 : 1;
if($a !== $b) return $a < $b? -1 : 1;

// Lastly by package title.
return strcasecmp($packA->title(), $packB->title());
}

/**
Expand Down

0 comments on commit d11ef15

Please sign in to comment.