Remove the headblock property from the Template Asset, and merge

it into extra head tags.  Style templates are not allowed to
have extra head tags.
This commit is contained in:
Colin Kuskie 2008-11-26 21:24:44 +00:00
parent d3f8a075a7
commit 2b3b3fd458
7 changed files with 108 additions and 46 deletions

View file

@ -90,10 +90,6 @@ sub definition {
fieldType => 'selectList',
defaultValue => [$session->config->get("defaultTemplateParser")],
},
headBlock => {
fieldType => "codearea",
defaultValue => undef,
},
namespace => {
fieldType => 'combo',
defaultValue => undef,
@ -103,6 +99,25 @@ sub definition {
return $class->SUPER::definition($session,$definition);
}
#-------------------------------------------------------------------
=head2 drawExtraHeadTags ( )
Override the master drawExtraHeadTags to prevent Style template from having
Extra Head Tags.
=cut
sub drawExtraHeadTags {
my ($self, $params) = @_;
if ($self->get('namespace') eq 'style') {
my $i18n = WebGUI::International->new($self->session);
return $i18n->get(881);
}
return $self->SUPER::drawExtraHeadTags($params);
}
#-------------------------------------------------------------------
=head2 duplicate
@ -125,15 +140,20 @@ sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
# TODO: Perhaps add a way to check template syntax before it blows stuff up?
my %data;
my $needsUpdate = 0;
if ($self->getValue("parser") ne $self->session->form->process("parser","className") && ($self->session->form->process("parser","className") ne "")) {
my %data;
if (isIn($self->session->form->process("parser","className"),@{$self->session->config->get("templateParsers")})) {
%data = ( parser => $self->session->form->process("parser","className") );
} else {
%data = ( parser => $self->session->config->get("defaultTemplateParser") );
}
$self->update(\%data);
}
if ($self->session->form->process("namespace") eq 'style') {
$needsUpdate = 1;
$data{extraHeadTags} = '';
}
$self->update(\%data) if $needsUpdate;
}
#-------------------------------------------------------------------
@ -185,12 +205,6 @@ sub getEditForm {
-syntax => "html",
-value=>$self->getValue("template")
);
$tabform->getTab("properties")->codearea(
-name=>"headBlock",
-label=>$i18n->get('head block'),
-hoverHelp=>$i18n->get('head block description'),
-value=>$self->getValue("headBlock")
);
if($self->session->config->get("templateParsers")){
my @temparray = @{$self->session->config->get("templateParsers")};
tie my %parsers, 'Tie::IxHash';
@ -323,7 +337,7 @@ sub prepare {
my $templateHeadersSent = $self->session->stow->get("templateHeadersSent") || [];
my @sent = @{$templateHeadersSent};
unless (isIn($self->getId, @sent)) { # don't send head block if we've already sent it for this template
$self->session->style->setRawHeadTags($self->getParser($self->session, $self->get('parser'))->process($self->get('headBlock'), $vars));
$self->session->style->setRawHeadTags($self->getParser($self->session, $self->get('parser'))->process($self->getExtraHeadTags, $vars));
}
push(@sent, $self->getId);
$self->session->stow->set("templateHeadersSent", \@sent);

View file

@ -370,7 +370,8 @@ sub processPropertiesFromFormPost {
=head2 processStyle ( output )
Returns output parsed under the current style.
Returns output parsed under the current style. Sets the Asset's extra head tags
into the raw head tags, too.
=head3 output
@ -381,6 +382,7 @@ An HTML blob to be parsed into the current style.
sub processStyle {
my $self = shift;
my $output = shift;
$self->session->style->setRawHeadTags($self->getExtraHeadTags);
return $self->session->style->process($output,$self->get("styleTemplateId"));
}