make the dynamic list of macros work again

This commit is contained in:
Colin Kuskie 2006-06-21 03:19:58 +00:00
parent 5f93f2dc13
commit dbab69eb2f
4 changed files with 35 additions and 46 deletions

View file

@ -18,9 +18,35 @@ our $HELP = {
'macros list' => {
title => 'macros list title',
body => 'macros list body',
fields => [
],
body => sub {
my $session = shift;
my $dir = join '/', $session->config->getWebguiRoot,"lib","WebGUI","Macro";
opendir (DIR,$dir) or $session->errorHandler->fatal("Can't open Macro directory: $dir!");
my @macros = map { s/Macro_//; s/\.pm//; $_; }
grep { /\.pm$/ }
readdir(DIR); ##list of namespaces
closedir(DIR);
##Build list of enabled macros, by namespace, by reversing session hash:
my %macros = reverse %{ $session->config->get("macros") };
my $macro_table =
join "\n",
map { join '', '<tr><td>', $_, '</td><td>',
($macros{$_} ? ('&#94;', $macros{$_}, '();') : '&nbsp;'),
'</td></tr>' }
@macros;
my $i18n = WebGUI::International->new($session, 'Macros');
$macro_table =
join("\n",
'<table border="1" cellpadding="3">',
'<tr><th>',$i18n->get('macro name'),
'</th><th>',
$i18n->get('macro shortcut'),
'</th></tr>',$macro_table,'</table>');
},
fields => [],
related => sub { ##Hey, you gotta pass in the session var, right?
my $session = shift;
sort { $a->{tag} cmp $b->{tag} }