1 package SL::Controller::Layout::Base;
4 use parent qw(SL::Controller::Base);
6 use Rose::Object::MakeMethods::Generic (
7 'scalar --get_set_init' => qw(menu),
9 'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' },
10 'add_javascripts_inline' => { interface => 'add', hash_key => 'javascripts_inline' },
12 'add_sub_layouts' => { interface => 'add', hash_key => 'sub_layouts' },
21 my ($class, @slurp) = @_;
23 my $self = $class->SUPER::new(@slurp);
27 Menu->new('menu.ini');
30 ##########################################
31 # inheritable/overridable
32 ##########################################
35 join '', map { $_->pre_content } $_[0]->sub_layouts;
39 join '', map { $_->start_content } $_[0]->sub_layouts;
43 join '', map { $_->end_content } $_[0]->sub_layouts;
47 join '', map { $_->post_content } $_[0]->sub_layouts;
50 sub stylesheets_inline {
51 ( map { $_->stylesheets_inline } $_[0]->sub_layouts ),
52 @{ $_[0]->{stylesheets_inline} || [] };
55 sub javascripts_inline {
56 ( map { $_->javascripts_inline } $_[0]->sub_layouts ),
57 @{ $_[0]->{javascripts_inline} || [] };
61 #########################################
63 ########################################
67 push @{ $self->{stylesheets} ||= [] }, @_ if @_;
68 @{ $self->{stylesheets} ||= [] };
73 my $css_path = $self->get_stylesheet_for_user;
75 return grep { $_ } map { $self->_find_stylesheet($_, $css_path) }
76 $self->use_stylesheet, map { $_->stylesheets } $self->sub_layouts;
79 sub _find_stylesheet {
80 my ($self, $stylesheet, $css_path) = @_;
82 return "$css_path/$stylesheet" if -f "$css_path/$stylesheet";
83 return "css/$stylesheet" if -f "css/$stylesheet";
84 return $stylesheet if -f $stylesheet;
87 sub get_stylesheet_for_user {
89 if (my $user_style = $::myconfig{stylesheet}) {
90 $user_style =~ s/\.css$//; # nuke trailing .css, this is a remnand of pre 2.7.0 stylesheet handling
91 if (-d "$css_path/$user_style" &&
92 -f "$css_path/$user_style/main.css") {
93 $css_path = "$css_path/$user_style";
95 $css_path = "$css_path/lx-office-erp";
98 $css_path = "$css_path/lx-office-erp";
100 $::myconfig{css_path} = $css_path; # needed for menunew, FIXME: don't do this here
108 push @{ $self->{javascripts} ||= [] }, @_ if @_;
109 @{ $self->{javascripts} ||= [] };
115 return map { $self->_find_javascript($_) }
116 $self->use_javascript, map { $_->javascripts } $self->sub_layouts;
119 sub _find_javascript {
120 my ($self, $javascript) = @_;
122 return "js/$javascript" if -f "js/$javascript";
123 return $javascript if -f $javascript;
127 ############################################
128 # track state of form header
129 ############################################
132 $_[0]{_header_done} = 1;