add plugin category display support to the website
This commit is contained in:
parent
4073e56856
commit
362406f529
@ -3,3 +3,7 @@ body {
|
|||||||
background: url('../img/bg.jpg');
|
background: url('../img/bg.jpg');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table tr.category_header {
|
||||||
|
background: #ddd;
|
||||||
|
}
|
||||||
|
@ -16,8 +16,37 @@ function iitcDesktopDownload ( $build )
|
|||||||
|
|
||||||
function iitcDesktopPluginDownloadTable ( $build )
|
function iitcDesktopPluginDownloadTable ( $build )
|
||||||
{
|
{
|
||||||
|
$categories = Array (
|
||||||
|
'Info' => "",
|
||||||
|
'Keys' => "Key management",
|
||||||
|
'Controls' => "Map controls",
|
||||||
|
'Highlighter' => "Portal highliters",
|
||||||
|
'Layer' => "Additional map layers",
|
||||||
|
'Map Tiles' => "Alternative map layers",
|
||||||
|
'Tweaks' => "Adjust IITC settings",
|
||||||
|
'Misc' => "Unclassified plugins",
|
||||||
|
);
|
||||||
|
|
||||||
|
$plugins = Array();
|
||||||
|
|
||||||
|
foreach ( glob ( "$build/plugins/*.user.js" ) as $path )
|
||||||
|
{
|
||||||
|
$basename = basename ( $path, ".user.js" );
|
||||||
|
$details = loadUserScriptHeader ( $path );
|
||||||
|
|
||||||
|
$plugins[$basename] = $details;
|
||||||
|
|
||||||
|
$category = array_key_exists('@category',$details) ? $details['@category'] : 'Misc';
|
||||||
|
|
||||||
|
if ( !array_key_exists($category,$categories) )
|
||||||
|
{
|
||||||
|
# add missing categories
|
||||||
|
$categories[$category] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<table class="table table-condensed table-hover">
|
<table class="table table-condensed">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
@ -29,11 +58,19 @@ function iitcDesktopPluginDownloadTable ( $build )
|
|||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
foreach ( glob ( "$build/plugins/*.user.js" ) as $path )
|
foreach ( $categories as $category => $category_desc )
|
||||||
{
|
{
|
||||||
$basename = basename ( $path, ".user.js" );
|
print "<tr class=\"category_header\"><th colspan=\"2\">Category: $category</th><td colspan=\"2\">$category_desc</td></tr>\n";
|
||||||
|
|
||||||
$details = loadUserScriptHeader ( $path );
|
$empty = True;
|
||||||
|
foreach ( $plugins as $basename => $details )
|
||||||
|
{
|
||||||
|
$this_category = array_key_exists('@category',$details) ? $details['@category'] : 'Misc';
|
||||||
|
|
||||||
|
if ( $category != $this_category )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$empty = False;
|
||||||
|
|
||||||
print "<tr id=\"plugin-$basename\">\n";
|
print "<tr id=\"plugin-$basename\">\n";
|
||||||
|
|
||||||
@ -51,8 +88,11 @@ foreach ( glob ( "$build/plugins/*.user.js" ) as $path )
|
|||||||
print "<td>$description</td>";
|
print "<td>$description</td>";
|
||||||
print "<td><a onclick=\"if(track){track('desktop','iitc-plugin-$basename','$build');}\" href=\"$path\" class=\"btn btn-small btn-primary\">Download</a></td>";
|
print "<td><a onclick=\"if(track){track('desktop','iitc-plugin-$basename','$build');}\" href=\"$path\" class=\"btn btn-small btn-primary\">Download</a></td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
|
if ( $empty )
|
||||||
|
print "<tr><td colspan=\"4\">(no plugins in this category)</td></tr>\n";
|
||||||
|
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user