Refactor processStyle so there's no duplicated code. Make Wobject call
SUPER. Add an option to skip adding getExtraHeadTags, so that Shortcut doesn't add them an extra time. Remove the subclassed getExtraHeadTags, since prepareView will add them, which prevents adding them a 3rd time.
This commit is contained in:
parent
66843db604
commit
b0a1e20053
4 changed files with 50 additions and 43 deletions
|
|
@ -1,6 +1,7 @@
|
|||
7.7.9
|
||||
- fixed: Reverted bugfix for 10409 and changed the hover help to reflect the correct way to build list-type form controls in the MetaData.
|
||||
- fixed: Template parser cannot be set
|
||||
- fixed #10361: Shortcuts duplicate extra header tags
|
||||
|
||||
7.7.8
|
||||
- fixed: Basic Auth doesn't work if password contains colon (Arjan Widlak,
|
||||
|
|
|
|||
|
|
@ -2196,23 +2196,30 @@ sub processTemplate {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processStyle ( html )
|
||||
=head2 processStyle ( $output, $noHeadTags )
|
||||
|
||||
Returns some HTML wrappered in a style. Should be overridden by subclasses, because
|
||||
Returns the output 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
|
||||
=head3 $output
|
||||
|
||||
The content to wrap up.
|
||||
|
||||
=head3 $options
|
||||
|
||||
Options that alter how the method behaves.
|
||||
|
||||
=head4 noHeadTags
|
||||
|
||||
If this options is true, then this method will not set the extraHeadTags
|
||||
|
||||
=cut
|
||||
|
||||
sub processStyle {
|
||||
my ($self, $output) = @_;
|
||||
my $session = $self->session;
|
||||
my $style = $session->style;
|
||||
$style->setRawHeadTags($self->getExtraHeadTags);
|
||||
my ($self, $output, $options) = @_;
|
||||
my $style = $self->session->style;
|
||||
$style->setRawHeadTags($self->getExtraHeadTags) unless $options->{noHeadTags};
|
||||
if ($self->get('synopsis')) {
|
||||
$style->setMeta({
|
||||
name => 'Description',
|
||||
|
|
|
|||
|
|
@ -212,6 +212,15 @@ sub discernUserId {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 duplicate
|
||||
|
||||
Extend the base method to duplicate shortcut overrides.
|
||||
|
||||
See also Asset::duplicate.
|
||||
|
||||
=cut
|
||||
|
||||
sub duplicate {
|
||||
my $self = shift;
|
||||
my $newAsset = $self->SUPER::duplicate(@_);
|
||||
|
|
@ -313,22 +322,6 @@ sub getEditForm {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getExtraHeadTags ( )
|
||||
|
||||
Returns the extraHeadTags stored in the asset. Called in $self->session->style->generateAdditionalHeadTags if this asset is the $self->session->asset. Also called in WebGUI::Asset::Wobject::Layout for its child assets. Overriden to also add tags from shortcutted asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub getExtraHeadTags {
|
||||
my $self = shift;
|
||||
my $output = $self->get("extraHeadTags")."\n";
|
||||
my $shortcut = $self->getShortcut;
|
||||
$output .= $self->getShortcut->get("extraHeadTags") if defined $shortcut;
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getFieldsList {
|
||||
my $self = shift;
|
||||
|
|
@ -667,7 +660,8 @@ sub notLinked {
|
|||
|
||||
=head2 prepareView ( )
|
||||
|
||||
See WebGUI::Asset::prepareView() for details.
|
||||
See WebGUI::Asset::prepareView() for details. Extends the base class to call prepareView
|
||||
on the Asset that is shortcutted.
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -683,6 +677,14 @@ sub prepareView {
|
|||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processPropertiesFromFormPost ( )
|
||||
|
||||
See WebGUI::Asset::processPropertiesFromFormPost () for details. Extends the base class to delete
|
||||
the scratch variables, and to uncache the overrides.
|
||||
|
||||
=cut
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
|
|
@ -720,6 +722,14 @@ sub setOverride {
|
|||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge ( )
|
||||
|
||||
See Asset::purge for details. Extends the base method to delete this Shortcut's
|
||||
overrides.
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my $self = shift;
|
||||
$self->session->db->write(<<'END_SQL', [$self->getId]);
|
||||
|
|
@ -985,8 +995,9 @@ sub www_view {
|
|||
if ($shortcut->isa('WebGUI::Asset::Wobject')) {
|
||||
$self->session->http->setLastModified($self->getContentLastModified);
|
||||
$self->session->http->sendHeader;
|
||||
my $style = $shortcut->processStyle($self->getSeparator);
|
||||
my ($head, $foot) = split($self->getSeparator,$style);
|
||||
##Tell processStyle not to set the h
|
||||
my $style = $shortcut->processStyle($shortcut->getSeparator, { noHeadTags => 1 });
|
||||
my ($head, $foot) = split($shortcut->getSeparator,$style);
|
||||
$self->session->output->print($head, 1);
|
||||
$self->session->output->print($self->view);
|
||||
$self->session->output->print($foot, 1);
|
||||
|
|
|
|||
|
|
@ -377,28 +377,16 @@ sub processPropertiesFromFormPost {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 processStyle ( output )
|
||||
=head2 processStyle ( )
|
||||
|
||||
Returns output parsed under the current style. Sets the Asset's extra head tags
|
||||
into the raw head tags, too.
|
||||
|
||||
=head3 output
|
||||
|
||||
An HTML blob to be parsed into the current style.
|
||||
Returns output parsed under the current style. See also Asset::processStyle.
|
||||
|
||||
=cut
|
||||
|
||||
sub processStyle {
|
||||
my ($self, $output) = @_;
|
||||
my $session = $self->session;
|
||||
my $style = $session->style;
|
||||
$style->setRawHeadTags($self->getExtraHeadTags);
|
||||
if ($self->get('synopsis')) {
|
||||
$style->setMeta({
|
||||
name => 'Description',
|
||||
content => $self->get('synopsis'),
|
||||
});
|
||||
}
|
||||
my ($self, $output, $options) = @_;
|
||||
$output = $self->SUPER::processStyle($output, $options);
|
||||
my $style = $self->session->style;
|
||||
if ($style->useMobileStyle) {
|
||||
return $style->process($output,$self->get("mobileStyleTemplateId"));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue