From dbab69eb2f207566fc642c5e82a932fc113ebe83 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 21 Jun 2006 03:19:58 +0000 Subject: [PATCH] make the dynamic list of macros work again --- lib/WebGUI/Help/Macros.pm | 32 +++++++++++++-- lib/WebGUI/Operation/Help.pm | 7 +++- .../i18n/English/Automated_Information.pm | 41 ------------------- lib/WebGUI/i18n/English/Macros.pm | 1 - 4 files changed, 35 insertions(+), 46 deletions(-) delete mode 100644 lib/WebGUI/i18n/English/Automated_Information.pm diff --git a/lib/WebGUI/Help/Macros.pm b/lib/WebGUI/Help/Macros.pm index 9024ac5ca..096069a74 100644 --- a/lib/WebGUI/Help/Macros.pm +++ b/lib/WebGUI/Help/Macros.pm @@ -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 '', '', $_, '', + ($macros{$_} ? ('^', $macros{$_}, '();') : ' '), + '' } + @macros; + + my $i18n = WebGUI::International->new($session, 'Macros'); + $macro_table = + join("\n", + '', + '',$macro_table,'
',$i18n->get('macro name'), + '', + $i18n->get('macro shortcut'), + '
'); + }, + fields => [], related => sub { ##Hey, you gotta pass in the session var, right? my $session = shift; sort { $a->{tag} cmp $b->{tag} } diff --git a/lib/WebGUI/Operation/Help.pm b/lib/WebGUI/Operation/Help.pm index 55163eca0..245bbeea7 100644 --- a/lib/WebGUI/Operation/Help.pm +++ b/lib/WebGUI/Operation/Help.pm @@ -304,7 +304,12 @@ sub www_viewHelp { } my %vars; $vars{uiLevelLabel} = $i18n->get('739', 'WebGUI'); - $vars{body} = $i18n->get($help->{body}); + if (ref $help->{body} eq 'CODE') { + $vars{body} = $help->{body}->($session); + } + else { + $vars{body} = $i18n->get($help->{body}); + } my $userUiLevel = $session->user->profileField("uiLevel"); my $uiOverride = $session->form->process("uiOverride"); foreach my $row (@{ $help->{fields} }) { diff --git a/lib/WebGUI/i18n/English/Automated_Information.pm b/lib/WebGUI/i18n/English/Automated_Information.pm deleted file mode 100644 index 25760e00c..000000000 --- a/lib/WebGUI/i18n/English/Automated_Information.pm +++ /dev/null @@ -1,41 +0,0 @@ -package WebGUI::i18n::English::Automated_Information; - -##This module must not be preloaded, since it requires that $session -##be populated when the module is use'ed. - -use WebGUI::International; -my $i18n = WebGUI::International->new($session, 'Macros'); - -##Get list of all macros by namespace/module name -my $dir = join '/', $self->session->config->getWebguiRoot,"lib","WebGUI","Macro"; -opendir (DIR,$dir) or $self->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 %{ $self->session->config->get("macros") }; - -my $macro_table = - join "\n", - map { join '', '', $_, '', - ($macros{$_} ? ('^', $macros{$_}, '();') : ' '), - '' } - @macros; - -$macro_table = - join("\n", - '', - '',$macro_table,'
',$i18n->get('macro name'), - '', - $i18n->get('macro shortcut'), - '
'); - -our $I18N = { - 'macro table' => { - message => $macro_table, - lastUpdated => 1112466408, - } -}; -1; diff --git a/lib/WebGUI/i18n/English/Macros.pm b/lib/WebGUI/i18n/English/Macros.pm index 16d8bcc55..1f71bb902 100644 --- a/lib/WebGUI/i18n/English/Macros.pm +++ b/lib/WebGUI/i18n/English/Macros.pm @@ -19,7 +19,6 @@ our $I18N = { 'macros list body' => { message => q|

The set of available Macros is defined in the WebGUI configuration file. These Macros are available for use on your site:

-^International("macro table","Automated_Information"); |, context => 'Content for dynamically generated macro list', lastUpdated => 1114134745,