diff --git a/lib/WebGUI/Macro.pm b/lib/WebGUI/Macro.pm index d8623ccd0..ca154060a 100644 --- a/lib/WebGUI/Macro.pm +++ b/lib/WebGUI/Macro.pm @@ -29,24 +29,12 @@ sub getParams { #------------------------------------------------------------------- sub process { - my (@files, $file, $cmd, $output, $macroDir); + my ($macro, $cmd, $output); $output = $_[0]; - if ($^O =~ /Win/i) { - $macroDir = "\\lib\\WebGUI\\Macro"; - } else { - $macroDir = "/lib/WebGUI/Macro"; - } - opendir (DIR,$session{config}{webguiRoot}.$macroDir) or WebGUI::ErrorHandler::fatalError("Can't open macro directory!"); - @files = readdir(DIR); - foreach $file (@files) { - if ($file =~ /(.*?)\.pm$/) { - $cmd = "use WebGUI::Macro::".$1; - eval($cmd); - $cmd = "WebGUI::Macro::".$1."::process"; - $output = &$cmd($output); - } + foreach $macro (keys %{$session{macro}}) { + $cmd = "WebGUI::Macro::".$macro."::process"; + $output = &$cmd($output); } - closedir(DIR); return $output; } diff --git a/lib/WebGUI/Operation/Style.pm b/lib/WebGUI/Operation/Style.pm index 718cde3be..654c522ff 100644 --- a/lib/WebGUI/Operation/Style.pm +++ b/lib/WebGUI/Operation/Style.pm @@ -13,59 +13,26 @@ package WebGUI::Operation::Style; use Exporter; use strict; use Tie::CPHash; -use WebGUI::Form; +use WebGUI::HTMLForm; +use WebGUI::Icon; use WebGUI::International; use WebGUI::Paginator; use WebGUI::Privilege; use WebGUI::Session; -use WebGUI::Shortcut; use WebGUI::SQL; use WebGUI::URL; use WebGUI::Utility; our @ISA = qw(Exporter); -our @EXPORT = qw(&www_copyStyle &www_addStyle &www_addStyleSave &www_deleteStyle &www_deleteStyleConfirm &www_editStyle &www_editStyleSave &www_listStyles); - -#------------------------------------------------------------------- -sub www_addStyle { - my ($output); - if (WebGUI::Privilege::isInGroup(5)) { - $output .= helpLink(16); - $output .= '
'; $output .= '
"; + $style{styleSheet} = ""; + } else { + %style = WebGUI::SQL->quickHash("select * from style where styleId=$session{form}{sid}"); + } + $output .= helpIcon(16); $output .= '
'; - $output .= formHeader(); - $output .= WebGUI::Form::hidden("op","editStyleSave"); - $output .= WebGUI::Form::hidden("sid",$session{form}{sid}); - $output .= '
'; - $output .= ' '; + $f = WebGUI::HTMLForm->new; + $f->hidden("op","editStyleSave"); + $f->hidden("sid",$session{form}{sid}); + $f->readOnly($session{form}{sid},WebGUI::International::get(380)); + $f->text("name",WebGUI::International::get(151),$style{name}); + $f->HTMLArea("body",WebGUI::International::get(501),$style{body},'','','',(5+$session{setting}{textAreaRows})); + $f->textarea("styleSheet",WebGUI::International::get(154),$style{styleSheet},'','','',(5+$session{setting}{textAreaRows})); + $f->submit; + $output .= $f->print; } else { $output = WebGUI::Privilege::adminOnly(); } @@ -134,7 +103,13 @@ sub www_editStyle { #------------------------------------------------------------------- sub www_editStyleSave { if (WebGUI::Privilege::isInGroup(5)) { - WebGUI::SQL->write("update style set name=".quote($session{form}{name}).", header=".quote($session{form}{header}).", footer=".quote($session{form}{footer}).", styleSheet=".quote($session{form}{styleSheet})." where styleId=".$session{form}{sid}); + if ($session{form}{sid} eq "new") { + $session{form}{sid} = getNextId("styleId"); + WebGUI::SQL->write("insert into style (styleId) values ($session{form}{sid})"); + } + $session{form}{body} = "^-;" if ($session{form}{body} eq ""); + WebGUI::SQL->write("update style set name=".quote($session{form}{name}).", body=".quote($session{form}{body}).", + styleSheet=".quote($session{form}{styleSheet})." where styleId=".$session{form}{sid}); return www_listStyles(); } else { return WebGUI::Privilege::adminOnly(); @@ -145,19 +120,17 @@ sub www_editStyleSave { sub www_listStyles { my ($output, $sth, @data, @row, $i, $p); if (WebGUI::Privilege::isInGroup(5)) { - $output = helpLink(9); + $output = helpIcon(9); $output .= '
'; - $output .= '
'; $sth = WebGUI::SQL->read("select styleId,name from style where name<>'Reserved' order by name"); while (@data = $sth->array) { - $row[$i] = '



'; $i++; } diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index d13be1c54..1e9553230 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -93,6 +93,27 @@ sub _getUserInfo { return \%user; } +#------------------------------------------------------------------- +sub _loadMacros { + my ($namespace, $cmd, @files, $file, $dir); + if ($^O =~ /Win/i) { + $dir = "\\lib\\WebGUI\\Macro"; + } else { + $dir = "/lib/WebGUI/Macro"; + } + opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open macro directory!"); + @files = readdir(DIR); + foreach $file (@files) { + if ($file =~ /(.*?)\.pm$/) { + $namespace = $1; + $cmd = "use WebGUI::Macro::".$1; + eval($cmd); + $session{macro}{$namespace} = $namespace; + } + } + closedir(DIR); +} + #------------------------------------------------------------------- sub _loadWobjects { my ($dir, @files, $file, $cmd, $namespace); @@ -199,6 +220,7 @@ sub open { ###---------------------------- ### loading plugins _loadWobjects(); + _loadMacros(); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Style.pm b/lib/WebGUI/Style.pm index a8fec778a..e7a5aa9c6 100644 --- a/lib/WebGUI/Style.pm +++ b/lib/WebGUI/Style.pm @@ -18,18 +18,18 @@ use WebGUI::SQL; #------------------------------------------------------------------- sub getStyle { - my ($header, $footer, @style, %style, $styleId); + my ($header, $footer, %style, $styleId, @body); tie %style, 'Tie::CPHash'; if ($session{form}{makePrintable}) { $styleId = $session{form}{style} || 3; - %style = WebGUI::SQL->quickHash("select header,footer,styleSheet from style where styleId=$styleId"); + %style = WebGUI::SQL->quickHash("select * from style where styleId=$styleId"); + @body = split(/\^\-\;/,$style{body}); $header = ''."\n"; $header .= '
'; $header .= $style{styleSheet}.''.$style{header}; - $footer = $style{footer}.'