.\2', $iitc_details['@version'] ); print "
IITC version $iitc_version
\n"; 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 ) { $categories = Array ( 'Portal Info' => "Enhanced information on the selected portal", 'Info' => "Display additional information", 'Keys' => "Manual key management", 'Controls' => "Map controls/widgets", 'Highlighter' => "Portal highlighters", 'Layer' => "Additional map layers", 'Map Tiles' => "Alternative map layers", 'Tweaks' => "Adjust IITC settings", 'Misc' => "Unclassified plugins", 'Obsolete' => "Plugins that are no longer recommended, due to being superceded by others or similar", 'Deleted' => "Deleted plugins - listed here for reference only. No download available" ); $popularity = loadPopularity(); $plugins = Array(); foreach ( glob ( "$build/plugins/*.user.js" ) as $path ) { $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'; if ( !array_key_exists($category,$categories) ) { # add missing categories $categories[$category] = ''; } } ksort ( $plugins ); uasort ( $plugins, 'popularity_cmp' ); ?>