Macros have been converted to be configured from the config file rather than the filesystem.
This commit is contained in:
parent
3d50eeb7db
commit
7bca02db6d
3 changed files with 57 additions and 19 deletions
|
|
@ -14,3 +14,54 @@ wobjects = Article, EventsCalendar, ExtraColumn, FAQ, FileManager, HttpProxy, \
|
||||||
Item, LinkList, MailForm, MessageBoard, Poll, Product, SiteMap, \
|
Item, LinkList, MailForm, MessageBoard, Poll, Product, SiteMap, \
|
||||||
SQLReport, Survey, SyndicatedContent, USS, WobjectProxy
|
SQLReport, Survey, SyndicatedContent, USS, WobjectProxy
|
||||||
|
|
||||||
|
macros = a => a_account, \
|
||||||
|
AdminBar => AdminBar, \
|
||||||
|
AdminText => AdminText, \
|
||||||
|
AdminToggle => AdminToggle, \
|
||||||
|
@ => At_username, \
|
||||||
|
\ => Backslash_pageUrl, \
|
||||||
|
c => c_companyName, \
|
||||||
|
C => C_crumbTrail, \
|
||||||
|
D => D_date, \
|
||||||
|
e => e_companyEmail, \
|
||||||
|
Env => Env, \
|
||||||
|
Execute => Execute, \
|
||||||
|
Extras => Extras, \
|
||||||
|
File => File, \
|
||||||
|
FlexMenu => FlexMenu, \
|
||||||
|
FormParam => FormParam, \
|
||||||
|
GroupText => GroupText, \
|
||||||
|
# => Hash_userId, \
|
||||||
|
H => H_homeLink, \
|
||||||
|
i => i_imageNoTags, \
|
||||||
|
I => I_imageWithTags, \
|
||||||
|
Include => Include, \
|
||||||
|
International => International, \
|
||||||
|
L => L_loginBox, \
|
||||||
|
LoginToggle => LoginToggle, \
|
||||||
|
m => m_currentMenuHorizontal, \
|
||||||
|
M => M_currentMenuVertical, \
|
||||||
|
Page => Page, \
|
||||||
|
PageTitle => PageTitle, \
|
||||||
|
p => p_previousMenuHorizontal, \
|
||||||
|
P => P_previousMenuVertical, \
|
||||||
|
? => Question_search, \
|
||||||
|
rootmenu => rootmenuHorizontal, \
|
||||||
|
RootTitle => RootTitle, \
|
||||||
|
r => r_printable, \
|
||||||
|
/ => Slash_gatewayUrl, \
|
||||||
|
Snippet => Snippet, \
|
||||||
|
* => Splat_random, \
|
||||||
|
SQL => SQL, \
|
||||||
|
s => s_specificMenuHorizontal, \
|
||||||
|
S => S_specificMenuVertical, \
|
||||||
|
Synopsis => Synopsis, \
|
||||||
|
ThumbnailLinker => ThumbnailLinker, \
|
||||||
|
Thumbnail => Thumbnail, \
|
||||||
|
t => t_topMenuHorizontal, \
|
||||||
|
T => T_topMenuVertical, \
|
||||||
|
u => u_companyUrl, \
|
||||||
|
URLEncode => URLEncode, \
|
||||||
|
User => User
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ A string of HTML to be processed.
|
||||||
sub process {
|
sub process {
|
||||||
my ($macro, $cmd, $output, $temp);
|
my ($macro, $cmd, $output, $temp);
|
||||||
$output = $_[0];
|
$output = $_[0];
|
||||||
foreach $macro (keys %{$session{macro}}) {
|
foreach $macro (keys %{$session{config}{macros}}) {
|
||||||
$cmd = "WebGUI::Macro::".$macro."::process";
|
$cmd = "WebGUI::Macro::".$session{config}{macros}{$macro}."::process";
|
||||||
$temp = eval{&$cmd($output)};
|
$temp = eval{&$cmd($output)};
|
||||||
if ($@) {
|
if ($@) {
|
||||||
WebGUI::ErrorHandler::warn("Processing failed on macro: $macro: ".$@);
|
WebGUI::ErrorHandler::warn("Processing failed on macro: $macro: ".$@);
|
||||||
|
|
|
||||||
|
|
@ -191,24 +191,11 @@ sub _loadAuthentication {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
sub _loadMacros {
|
sub _loadMacros {
|
||||||
my ($namespace, $cmd, @files, $file, $dir, $exclude);
|
foreach my $key (keys %{$session{config}{macros}}) {
|
||||||
$dir = $session{config}{webguiRoot}.$session{os}{slash}."lib".$session{os}{slash}."WebGUI".$session{os}{slash}."Macro";
|
my $cmd = "use WebGUI::Macro::".$session{config}{macros}{$key};
|
||||||
opendir (DIR,$dir) or WebGUI::ErrorHandler::fatalError("Can't open macro directory!");
|
eval($cmd);
|
||||||
@files = readdir(DIR);
|
WebGUI::ErrorHandler::fatalError("Macro failed to compile: $key.".$@) if($@);
|
||||||
foreach $file (@files) {
|
|
||||||
if ($file =~ /(.*?)\.pm$/) {
|
|
||||||
$namespace = $1;
|
|
||||||
$cmd = "use WebGUI::Macro::".$1;
|
|
||||||
eval($cmd);
|
|
||||||
WebGUI::ErrorHandler::fatalError("Macro failed to compile: $namespace.".$@) if($@);
|
|
||||||
$exclude = $session{config}{excludeMacro};
|
|
||||||
$exclude =~ s/ //g;
|
|
||||||
unless (isIn($namespace, split(/,/,$exclude))) {
|
|
||||||
$session{macro}{$namespace} = $namespace;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
closedir(DIR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue