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:
parent
d3f8a075a7
commit
2b3b3fd458
7 changed files with 108 additions and 46 deletions
|
|
@ -371,7 +371,7 @@ sub definition {
|
|||
uiLevel=>3,
|
||||
fieldType=>'text',
|
||||
defaultValue=>'',
|
||||
filter=>'fixUrl'
|
||||
filter=>'fixUrl',
|
||||
},
|
||||
isHidden=>{
|
||||
tab=>"display",
|
||||
|
|
@ -387,7 +387,7 @@ sub definition {
|
|||
hoverHelp=>$i18n->get('940 description'),
|
||||
uiLevel=>9,
|
||||
fieldType=>'yesNo',
|
||||
defaultValue=>0
|
||||
defaultValue=>0,
|
||||
},
|
||||
encryptPage=>{
|
||||
fieldType => ($session->config->get("sslEnabled") ? 'yesNo' : 'hidden'),
|
||||
|
|
@ -404,7 +404,7 @@ sub definition {
|
|||
uiLevel=>6,
|
||||
fieldType=>'user',
|
||||
filter=>'fixId',
|
||||
defaultValue=>'3'
|
||||
defaultValue=>'3',
|
||||
},
|
||||
groupIdView=>{
|
||||
tab=>"security",
|
||||
|
|
@ -413,7 +413,7 @@ sub definition {
|
|||
uiLevel=>6,
|
||||
fieldType=>'group',
|
||||
filter=>'fixId',
|
||||
defaultValue=>'7'
|
||||
defaultValue=>'7',
|
||||
},
|
||||
groupIdEdit=>{
|
||||
tab=>"security",
|
||||
|
|
@ -423,7 +423,7 @@ sub definition {
|
|||
uiLevel=>6,
|
||||
fieldType=>'group',
|
||||
filter=>'fixId',
|
||||
defaultValue=>'4'
|
||||
defaultValue=>'4',
|
||||
},
|
||||
synopsis=>{
|
||||
tab=>"meta",
|
||||
|
|
@ -431,15 +431,16 @@ sub definition {
|
|||
hoverHelp=>$i18n->get('412 description'),
|
||||
uiLevel=>3,
|
||||
fieldType=>'textarea',
|
||||
defaultValue=>undef
|
||||
defaultValue=>undef,
|
||||
},
|
||||
extraHeadTags=>{
|
||||
tab=>"meta",
|
||||
label=>$i18n->get("extra head tags"),
|
||||
hoverHelp=>$i18n->get('extra head tags description'),
|
||||
uiLevel=>5,
|
||||
fieldType=>'textarea',
|
||||
defaultValue=>undef
|
||||
fieldType=>'codearea',
|
||||
defaultValue=>undef,
|
||||
customDrawMethod => 'drawExtraHeadTags',
|
||||
},
|
||||
isPackage=>{
|
||||
label=>$i18n->get("make package"),
|
||||
|
|
@ -447,7 +448,7 @@ sub definition {
|
|||
hoverHelp=>$i18n->get('make package description'),
|
||||
uiLevel=>7,
|
||||
fieldType=>'yesNo',
|
||||
defaultValue=>0
|
||||
defaultValue=>0,
|
||||
},
|
||||
isPrototype=>{
|
||||
tab=>"meta",
|
||||
|
|
@ -455,7 +456,7 @@ sub definition {
|
|||
hoverHelp=>$i18n->get('make prototype description'),
|
||||
uiLevel=>9,
|
||||
fieldType=>'yesNo',
|
||||
defaultValue=>0
|
||||
defaultValue=>0,
|
||||
},
|
||||
isExportable=>{
|
||||
tab=>'meta',
|
||||
|
|
@ -476,7 +477,7 @@ sub definition {
|
|||
status=>{
|
||||
noFormPost=>1,
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>'pending'
|
||||
defaultValue=>'pending',
|
||||
},
|
||||
lastModified=>{
|
||||
noFormPost=>1,
|
||||
|
|
@ -486,7 +487,7 @@ sub definition {
|
|||
assetSize=>{
|
||||
noFormPost=>1,
|
||||
fieldType=>'hidden',
|
||||
defaultValue=>0
|
||||
defaultValue=>0,
|
||||
},
|
||||
);
|
||||
push(@{$definition}, {
|
||||
|
|
@ -502,6 +503,25 @@ sub definition {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 drawExtraHeadTags ( )
|
||||
|
||||
Draw the Extra Head Tags. Done with a customDrawMethod because the Template
|
||||
will override this.
|
||||
|
||||
=cut
|
||||
|
||||
sub drawExtraHeadTags {
|
||||
my ($self, $params) = @_;
|
||||
return WebGUI::Form::codearea($self->session, {
|
||||
name => $params->{name},
|
||||
value => $self->get($params->{name}),
|
||||
defaultValue => undef,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 DESTROY ( )
|
||||
|
|
@ -1958,7 +1978,7 @@ OUTPUT
|
|||
|
||||
=head2 prepareView ( )
|
||||
|
||||
Executes what is necessary to make the view() method work with content chunking. This includes things like processing template head tags.
|
||||
Executes what is necessary to make the view() method work with content chunking.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -1970,12 +1990,11 @@ sub prepareView {
|
|||
my $style = $self->session->style;
|
||||
my @keywords = @{WebGUI::Keyword->new($self->session)->getKeywordsForAsset({asset=>$self, asArrayRef=>1})};
|
||||
if (scalar @keywords) {
|
||||
$style->setMeta( {
|
||||
$style->setMeta({
|
||||
name => 'keywords',
|
||||
content => join(',', @keywords),
|
||||
});
|
||||
});
|
||||
}
|
||||
$style->setRawHeadTags($self->getExtraHeadTags);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -2114,7 +2133,9 @@ sub processTemplate {
|
|||
|
||||
=head2 processStyle ( html )
|
||||
|
||||
Returns some HTML wrappered in a style. Should be overridden by subclasses, because this one actually doesn't do anything other than return the html back to you.
|
||||
Returns some HTML wrappered in a style. Should be overridden by subclasses, because
|
||||
this one actually doesn't do anything other than return the html back to you and
|
||||
adds the Asset's extraHeadTags into the raw head tags.
|
||||
|
||||
=head3 html
|
||||
|
||||
|
|
@ -2124,6 +2145,7 @@ The content to wrap up.
|
|||
|
||||
sub processStyle {
|
||||
my ($self, $output) = @_;
|
||||
$self->session->style->setRawHeadTags($self->getExtraHeadTags);
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,18 +2,6 @@ package WebGUI::i18n::English::Asset_Template;
|
|||
use strict;
|
||||
|
||||
our $I18N = {
|
||||
'head block' => {
|
||||
message => q|Head Block|,
|
||||
context => q|label for the get edit form where users should put things that go in the html head block|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'head block description' => {
|
||||
message => q|Put meta tags, script tags, link tables, style sheets, and anything else here that you want to appear in the head block of the HTML document.|,
|
||||
context => q|hover help for the head block field|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'style wizard' => {
|
||||
message => q|Style Wizard|,
|
||||
context => q|Label for link to engage the style wizard.|,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue