diff --git a/website/page/code/desktop-download.php b/website/page/code/desktop-download.php index c91986c0..89f94cfc 100644 --- a/website/page/code/desktop-download.php +++ b/website/page/code/desktop-download.php @@ -13,6 +13,32 @@ function iitcDesktopDownload ( $build ) print "Download\n"; } +function loadPopularity() +{ + $popularity = Array(); + + $pop_file = getcwd() . "/popularity.txt"; + + if ( file_exists($pop_file) ) + { + foreach ( file($pop_file,FILE_IGNORE_NEW_LINES) as $line ) + { + $items = explode ( ' ', $line ); + $popularity[$items[0]] = (int)$items[1]; + } + } + + return $popularity; +} + +function popularity_cmp ( $a, $b ) +{ + if ( $a['popularity'] == $b['popularity'] ) + return 0; + // sort from highest to lowest + return ($a['popularity'] > $b['popularity']) ? -1 : 1; +} + function iitcDesktopPluginDownloadTable ( $build ) { @@ -28,6 +54,8 @@ function iitcDesktopPluginDownloadTable ( $build ) 'Misc' => "Unclassified plugins", ); + $popularity = loadPopularity(); + $plugins = Array(); foreach ( glob ( "$build/plugins/*.user.js" ) as $path ) @@ -35,6 +63,11 @@ function iitcDesktopPluginDownloadTable ( $build ) $basename = basename ( $path, ".user.js" ); $details = loadUserScriptHeader ( $path ); + if ( array_key_exists('total-conversion-build',$popularity) && array_key_exists('plugins/'.$basename, $popularity) ) + { + $details['popularity'] = $popularity['plugins/'.$basename] / $popularity['total-conversion-build']; + } + $plugins[$basename] = $details; $category = array_key_exists('@category',$details) ? $details['@category'] : 'Misc'; @@ -47,15 +80,19 @@ function iitcDesktopPluginDownloadTable ( $build ) } ksort ( $plugins ); - + uasort ( $plugins, 'popularity_cmp' ); ?> - + + + + @@ -64,7 +101,7 @@ function iitcDesktopPluginDownloadTable ( $build ) $category_desc ) { - print "\n"; + print "\n"; $empty = True; foreach ( $plugins as $basename => $details ) @@ -89,11 +126,22 @@ function iitcDesktopPluginDownloadTable ( $build ) # remove unneeded prefix from description $description = preg_replace ( '/^\[[^]]*\] */', '', $details['@description'] ); + $plugin_users = "-"; + if ( array_key_exists('popularity',$details) ) + { + $plugin_users = (int)($details['popularity']*1000)/10 . "%"; + + } + print ""; - print ""; - print ""; - print ""; + print ""; + print ""; + print ""; +// print ""; + print ""; print "\n"; + print "\n"; + } if ( $empty ) print "\n";
NameID / VersionPopularityIDVersion Download
Category: $category$category_desc
Category: $category$category_desc
$name$basename
$version
$descriptionDownload$plugin_users$basename$version$description
$description
(no plugins in this category)