Changed style system to a "body" configuration rather than header/footer.
This commit is contained in:
parent
3f2abb21e5
commit
299995af14
4 changed files with 70 additions and 87 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 .= '<h1>'.WebGUI::International::get(150).'</h1>';
|
||||
$output .= formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","addStyleSave");
|
||||
$output .= '<table>';
|
||||
$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","<style>\n\n</style>",50,10));
|
||||
$output .= formSave();
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
} 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 .= '<h1>'.WebGUI::International::get(42).'</h1>';
|
||||
$output .= WebGUI::International::get(155).'<p>';
|
||||
$output .= '<div align="center"><a href="'.
|
||||
|
|
@ -107,24 +74,26 @@ sub www_deleteStyleConfirm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editStyle {
|
||||
my ($output, %style);
|
||||
my ($output, %style, $f);
|
||||
tie %style, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(5)) {
|
||||
%style = WebGUI::SQL->quickHash("select * from style where styleId=$session{form}{sid}");
|
||||
$output .= helpLink(16);
|
||||
if ($session{form}{sid} eq "new") {
|
||||
$style{body} = "<body>\n\n^-;\n\n</body>";
|
||||
$style{styleSheet} = "<style>\n\n</style>";
|
||||
} else {
|
||||
%style = WebGUI::SQL->quickHash("select * from style where styleId=$session{form}{sid}");
|
||||
}
|
||||
$output .= helpIcon(16);
|
||||
$output .= '<h1>'.WebGUI::International::get(156).'</h1>';
|
||||
$output .= formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","editStyleSave");
|
||||
$output .= WebGUI::Form::hidden("sid",$session{form}{sid});
|
||||
$output .= '<table>';
|
||||
$output .= tableFormRow(WebGUI::International::get(380),$session{form}{sid});
|
||||
$output .= tableFormRow(WebGUI::International::get(151),WebGUI::Form::text("name",20,30,$style{name}));
|
||||
$output .= tableFormRow(WebGUI::International::get(152),WebGUI::Form::textArea("header",$style{header},50,10));
|
||||
$output .= tableFormRow(WebGUI::International::get(153),WebGUI::Form::textArea("footer",$style{footer},50,10));
|
||||
$output .= tableFormRow(WebGUI::International::get(154),WebGUI::Form::textArea("styleSheet",$style{styleSheet},50,10));
|
||||
$output .= formSave();
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
$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 .= '<h1>'.WebGUI::International::get(157).'</h1>';
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=addStyle').
|
||||
$output .= '<div align="center"><a href="'.WebGUI::URL::page('op=editStyle&sid=new').
|
||||
'">'.WebGUI::International::get(158).'</a></div>';
|
||||
$sth = WebGUI::SQL->read("select styleId,name from style where name<>'Reserved' order by name");
|
||||
while (@data = $sth->array) {
|
||||
$row[$i] = '<tr><td valign="top" class="tableData"><a href="'.
|
||||
WebGUI::URL::page('op=deleteStyle&sid='.$data[0]).
|
||||
'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a><a href="'.
|
||||
WebGUI::URL::page('op=editStyle&sid='.$data[0]).
|
||||
'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a><a href="'.
|
||||
WebGUI::URL::page('op=copyStyle&sid='.$data[0]).
|
||||
'"><img src="'.$session{setting}{lib}.'/copy.gif" border=0></a></td>';
|
||||
$row[$i] = '<tr><td valign="top" class="tableData">'
|
||||
.deleteIcon('op=deleteStyle&sid='.$data[0])
|
||||
.editIcon('op=editStyle&sid='.$data[0])
|
||||
.copyIcon('op=copyStyle&sid='.$data[0])
|
||||
.'</td>';
|
||||
$row[$i] .= '<td valign="top" class="tableData">'.$data[1].'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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 = '<html><!-- WebGUI '.$session{wg}{version}.' -->'."\n";
|
||||
$header .= '<head><title>'.$session{page}{title}.' - '.$session{setting}{companyName}.'</title>';
|
||||
$header .= $style{styleSheet}.'</head>'.$style{header};
|
||||
$footer = $style{footer}.'</html>';
|
||||
} else {
|
||||
tie %style, 'Tie::CPHash';
|
||||
%style = WebGUI::SQL->quickHash("select header,footer,styleSheet from style where styleId=$session{page}{styleId}");
|
||||
%style = WebGUI::SQL->quickHash("select * from style where styleId=$session{page}{styleId}");
|
||||
@body = split(/\^\-\;/,$style{body});
|
||||
$header = $session{setting}{docTypeDec}."\n".'<!-- WebGUI '.$WebGUI::VERSION.' -->
|
||||
<html>
|
||||
<head>
|
||||
|
|
@ -51,9 +51,9 @@ sub getStyle {
|
|||
$session{page}{synopsis}.'">';
|
||||
|
||||
}
|
||||
$header .= '</head>'.$style{header};
|
||||
$footer = $style{footer}.' </html>';
|
||||
$header .= '</head>'.$body[0];
|
||||
}
|
||||
$footer = $body[1].' </html>';
|
||||
$header = WebGUI::Macro::process($header);
|
||||
$footer = WebGUI::Macro::process($footer);
|
||||
return ($header, $footer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue