style and page template migrations complete
This commit is contained in:
parent
de758d8dfe
commit
5d0faf0e3f
12 changed files with 354 additions and 409 deletions
|
|
@ -33,9 +33,10 @@ This package contains utility methods for WebGUI's style system.
|
|||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Style;
|
||||
$style = WebGUI::Style::get();
|
||||
$template = WebGUI::Style::getTemplate();
|
||||
$html = WebGUI::Style::process($content);
|
||||
|
||||
=head1 METHODS
|
||||
=head1 SUBROUTINES
|
||||
|
||||
These subroutines are available from this package:
|
||||
|
||||
|
|
@ -44,56 +45,80 @@ These subroutines are available from this package:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 get ( )
|
||||
=head2 getTemplate ( [ templateId ] )
|
||||
|
||||
Returns a style based upon the current WebGUI session information.
|
||||
Retrieves the template for this style.
|
||||
|
||||
=over
|
||||
|
||||
=item templateId
|
||||
|
||||
The unique identifier for the template to retrieve. Defaults to the style template tied to the current page.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub get {
|
||||
my ($header, $footer, %style, $styleId, @body);
|
||||
tie %style, 'Tie::CPHash';
|
||||
if ($session{form}{makePrintable}) {
|
||||
$styleId = $session{form}{style} || 3;
|
||||
} else {
|
||||
$styleId = $session{page}{styleId} || 2;
|
||||
}
|
||||
%style = WebGUI::SQL->quickHash("select * from style where styleId=$styleId");
|
||||
@body = split(/\^\-\;/,$style{body});
|
||||
my $type = lc($session{setting}{siteicon});
|
||||
$type =~ s/.*\.(.*?)$/$1/;
|
||||
$header = $session{setting}{docTypeDec}.'
|
||||
<!-- WebGUI '.$WebGUI::VERSION.' -->
|
||||
<html> <head>
|
||||
<title>'.$session{page}{title}.' - '.$session{setting}{companyName}.'</title>
|
||||
';
|
||||
$header .= $style{styleSheet}.$session{page}{metaTags};
|
||||
if ($session{var}{adminOn}) {
|
||||
# This "triple incantation" panders to the delicate tastes of various browsers for reliable cache suppression.
|
||||
$header .= '<meta http-equiv="Pragma" content="no-cache" />';
|
||||
$header .= '<meta http-equiv="Cache-Control" content="no-cache, must-revalidate, max_age=0" />';
|
||||
$header .= '<meta http-equiv="Expires" content="0" />';
|
||||
}
|
||||
if ($session{page}{defaultMetaTags}) {
|
||||
$header .= '<meta http-equiv="Keywords" name="Keywords" content="'.$session{page}{title}
|
||||
.', '.$session{setting}{companyName}.'" />';
|
||||
if ($session{page}{synopsis}) {
|
||||
$header .= '<meta http-equiv="Description" name="Description" content="'.$session{page}{synopsis}.'" />';
|
||||
}
|
||||
}
|
||||
$header .= '
|
||||
<meta http-equiv="Content-Type"
|
||||
content="text/html; charset='.($session{header}{charset}||$session{language}{characterSet}||"ISO-8859-1").'" />
|
||||
<link rel="icon" href="'.$session{setting}{siteicon}.'" type="image/'.$type.'" />
|
||||
<link rel="SHORTCUT ICON" href="'.$session{setting}{favicon}.'" />
|
||||
</head>
|
||||
';
|
||||
$header .= $body[0];
|
||||
$footer = $body[1].' </html>';
|
||||
return $header.$_[0].$footer;
|
||||
sub getTemplate {
|
||||
my $templateId = shift || $session{page}{styleId};
|
||||
return WebGUI::Template::get($templateId,"style");
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 process ( content [ , templateId ] )
|
||||
|
||||
Returns a parsed style with content based upon the current WebGUI session information.
|
||||
|
||||
=over
|
||||
|
||||
=item content
|
||||
|
||||
The content to be parsed into the style. Usually generated by WebGUI::Page::generate().
|
||||
|
||||
=item templateId
|
||||
|
||||
The unique identifier for the template to retrieve. Defaults to the style template tied to the current page.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
sub process {
|
||||
my %var;
|
||||
$var{'body.content'} = shift;
|
||||
my $templateId = shift;
|
||||
my $type = lc($session{setting}{siteicon});
|
||||
$type =~ s/.*\.(.*?)$/$1/;
|
||||
$var{'head.tags'} = '
|
||||
<meta name="generator" content="WebGUI '.$WebGUI::VERSION.'" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset='.($session{header}{charset}||$session{language}{characterSet}||"ISO-8859-1").'" />
|
||||
<link rel="icon" href="'.$session{setting}{siteicon}.'" type="image/'.$type.'" />
|
||||
<link rel="SHORTCUT ICON" href="'.$session{setting}{favicon}.'" />
|
||||
';
|
||||
$var{'head.tags'} .= $session{page}{metaTags};
|
||||
if ($session{var}{adminOn}) {
|
||||
# This "triple incantation" panders to the delicate tastes of various browsers for reliable cache suppression.
|
||||
$var{'head.tags'} .= '
|
||||
<meta http-equiv="Pragma" content="no-cache" />
|
||||
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate, max_age=0" />
|
||||
<meta http-equiv="Expires" content="0" />
|
||||
';
|
||||
}
|
||||
if ($session{page}{defaultMetaTags}) {
|
||||
$var{'head.tags'} .= '
|
||||
<meta http-equiv="Keywords" name="Keywords" content="'.$session{page}{title}.', '.$session{setting}{companyName}.'" />
|
||||
';
|
||||
if ($session{page}{synopsis}) {
|
||||
$var{'head.tags'} .= '
|
||||
<meta http-equiv="Description" name="Description" content="'.$session{page}{synopsis}.'" />
|
||||
';
|
||||
}
|
||||
}
|
||||
return WebGUI::Template::process(getTemplate($templateId),\%var);
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue