X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/b6fd15a8dc44f9b09d5a2bce766cda14b87c6e13..c4ee17ee3ad87b04d524c1ee6f44b32412c71ee6:/SL/Layout/Base.pm diff --git a/SL/Layout/Base.pm b/SL/Layout/Base.pm index 56d5b8e2f..0c209e2af 100644 --- a/SL/Layout/Base.pm +++ b/SL/Layout/Base.pm @@ -3,14 +3,16 @@ package SL::Layout::Base; use strict; use parent qw(SL::Controller::Base); +use List::MoreUtils qw(uniq); + use Rose::Object::MakeMethods::Generic ( 'scalar --get_set_init' => qw(menu), 'scalar' => qw(focus), 'array' => [ 'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' }, 'add_javascripts_inline' => { interface => 'add', hash_key => 'javascripts_inline' }, - 'sub_layouts', - 'add_sub_layouts' => { interface => 'add', hash_key => 'sub_layouts' }, + 'sub_layouts', => { interface => 'get_set_init' }, + 'add_sub_layouts' => { interface => 'add', hash_key => 'sub_layouts' }, ], ); @@ -49,20 +51,26 @@ sub post_content { } sub stylesheets_inline { - ( map { $_->stylesheets_inline } $_[0]->sub_layouts ), + uniq ( map { $_->stylesheets_inline } $_[0]->sub_layouts ), @{ $_[0]->{stylesheets_inline} || [] }; } sub javascripts_inline { - ( map { $_->javascripts_inline } $_[0]->sub_layouts ), + uniq ( map { $_->javascripts_inline } $_[0]->sub_layouts ), @{ $_[0]->{javascripts_inline} || [] }; } +sub init_sub_layouts { [] } + ######################################### # Interface ######################################## +sub add_stylesheets { + &use_stylesheet; +} + sub use_stylesheet { my $self = shift; push @{ $self->{stylesheets} ||= [] }, @_ if @_; @@ -73,7 +81,7 @@ sub stylesheets { my ($self) = @_; my $css_path = $self->get_stylesheet_for_user; - return grep { $_ } map { $self->_find_stylesheet($_, $css_path) } + return uniq grep { $_ } map { $self->_find_stylesheet($_, $css_path) } $self->use_stylesheet, map { $_->stylesheets } $self->sub_layouts; } @@ -103,6 +111,9 @@ sub get_stylesheet_for_user { return $css_path; } +sub add_javascripts { + &use_javascript +} sub use_javascript { my $self = shift; @@ -113,7 +124,7 @@ sub use_javascript { sub javascripts { my ($self) = @_; - return map { $self->_find_javascript($_) } + return uniq map { $self->_find_javascript($_) } $self->use_javascript, map { $_->javascripts } $self->sub_layouts; }