.\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' ); ?> $category_desc ) { print "\n"; $empty = True; foreach ( $plugins as $basename => $details ) { $path = "$build/plugins/$basename.user.js"; $this_category = array_key_exists('@category',$details) ? $details['@category'] : 'Misc'; if ( $category != $this_category ) continue; $empty = False; print "\n"; # remove 'IITC Plugin: ' prefix if it's there, for neatness $name = preg_replace ( '/^IITC plugin: /i', '', $details['@name'] ); # format extended version info in less prominent font $version = preg_replace ( '/^(\d+\.\d+\.\d+)\.(\d{8}\.\d{1,6})/', '\1
.\2', $details['@version'] ); # 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 ""; if ( $category != "Deleted" ) { print ""; } print "\n"; print "\n"; } if ( $empty ) print "\n"; } ?>
Name Popularity ID Version Download
Category: $category$category_desc
$name$plugin_users$basename$version
$description
(no plugins in this category)