From 299995af1406dcdbe3a5688b23df57febc15fb65 Mon Sep 17 00:00:00 2001
From: JT Smith ';
$output .= ''.WebGUI::International::get(150).'
';
- $output .= formHeader();
- $output .= WebGUI::Form::hidden("op","addStyleSave");
- $output .= '';
- $output .= tableFormRow(WebGUI::International::get(151),WebGUI::Form::text("name",20,30));
- $output .= tableFormRow(WebGUI::International::get(152),WebGUI::Form::textArea("header",'',50,10));
- $output .= tableFormRow(WebGUI::International::get(153),WebGUI::Form::textArea("footer",'',50,10));
- $output .= tableFormRow(WebGUI::International::get(154),WebGUI::Form::textArea("styleSheet","",50,10));
- $output .= formSave();
- $output .= '
';
- $output .= ' ';
- } else {
- $output = WebGUI::Privilege::adminOnly();
- }
- return $output;
-}
-
-#-------------------------------------------------------------------
-sub www_addStyleSave {
- my ($output);
- if (WebGUI::Privilege::isInGroup(5)) {
- WebGUI::SQL->write("insert into style values (".getNextId("styleId").", ".quote($session{form}{name}).", ".quote($session{form}{header}).", ".quote($session{form}{footer}).", ".quote($session{form}{styleSheet}).")");
- $output = www_listStyles();
- } else {
- $output = WebGUI::Privilege::adminOnly();
- }
- return $output;
-}
+our @EXPORT = qw(&www_copyStyle &www_deleteStyle &www_deleteStyleConfirm &www_editStyle &www_editStyleSave &www_listStyles);
#-------------------------------------------------------------------
sub www_copyStyle {
my (%style);
if (WebGUI::Privilege::isInGroup(5)) {
%style = WebGUI::SQL->quickHash("select * from style where styleId=$session{form}{sid}");
- WebGUI::SQL->write("insert into style values (".getNextId("styleId").", ".quote('Copy of '.$style{name}).", ".quote($style{header}).", ".quote($style{footer}).", ".quote($style{styleSheet}).")");
+ WebGUI::SQL->write("insert into style (styleId,name,body,styleSheet) values (".getNextId("styleId").",
+ ".quote('Copy of '.$style{name}).", ".quote($style{body}).", ".quote($style{styleSheet}).")");
return www_listStyles();
} else {
return WebGUI::Privilege::adminOnly();
@@ -78,7 +45,7 @@ sub www_deleteStyle {
if ($session{form}{sid} < 26 && $session{form}{sid} > 0) {
return WebGUI::Privilege::vitalComponent();
} elsif (WebGUI::Privilege::isInGroup(5)) {
- $output .= helpLink(4);
+ $output .= helpIcon(4);
$output .= ''.WebGUI::International::get(42).'
';
$output .= WebGUI::International::get(155).'
"; + $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}.'