1 package SL::Layout::Base;
 
   4 use parent qw(SL::Controller::Base);
 
   6 use Rose::Object::MakeMethods::Generic (
 
   7   'scalar --get_set_init' => qw(menu),
 
  10     'add_stylesheets_inline' => { interface => 'add', hash_key => 'stylesheets_inline' },
 
  11     'add_javascripts_inline' => { interface => 'add', hash_key => 'javascripts_inline' },
 
  13     'add_sub_layouts'         => { interface => 'add', hash_key => 'sub_layouts' },
 
  22   my ($class, @slurp) = @_;
 
  24   my $self = $class->SUPER::new(@slurp);
 
  28   Menu->new('menu.ini');
 
  31 ##########################################
 
  32 #  inheritable/overridable
 
  33 ##########################################
 
  36   join '', map { $_->pre_content } $_[0]->sub_layouts;
 
  40   join '', map { $_->start_content } $_[0]->sub_layouts;
 
  44   join '', map { $_->end_content } $_[0]->sub_layouts;
 
  48   join '', map { $_->post_content } $_[0]->sub_layouts;
 
  51 sub stylesheets_inline {
 
  52   ( map { $_->stylesheets_inline } $_[0]->sub_layouts ),
 
  53   @{ $_[0]->{stylesheets_inline} || [] };
 
  56 sub javascripts_inline {
 
  57   ( map { $_->javascripts_inline } $_[0]->sub_layouts ),
 
  58   @{ $_[0]->{javascripts_inline} || [] };
 
  62 #########################################
 
  64 ########################################
 
  68   push @{ $self->{stylesheets} ||= [] }, @_ if @_;
 
  69   @{ $self->{stylesheets} ||= [] };
 
  74   my $css_path = $self->get_stylesheet_for_user;
 
  76   return grep { $_ } map { $self->_find_stylesheet($_, $css_path)  }
 
  77     $self->use_stylesheet, map { $_->stylesheets } $self->sub_layouts;
 
  80 sub _find_stylesheet {
 
  81   my ($self, $stylesheet, $css_path) = @_;
 
  83   return "$css_path/$stylesheet" if -f "$css_path/$stylesheet";
 
  84   return "css/$stylesheet"       if -f "css/$stylesheet";
 
  85   return $stylesheet             if -f $stylesheet;
 
  88 sub get_stylesheet_for_user {
 
  90   if (my $user_style = $::myconfig{stylesheet}) {
 
  91     $user_style =~ s/\.css$//; # nuke trailing .css, this is a remnand of pre 2.7.0 stylesheet handling
 
  92     if (-d "$css_path/$user_style" &&
 
  93         -f "$css_path/$user_style/main.css") {
 
  94       $css_path = "$css_path/$user_style";
 
  96       $css_path = "$css_path/lx-office-erp";
 
  99     $css_path = "$css_path/lx-office-erp";
 
 101   $::myconfig{css_path} = $css_path; # needed for menunew, FIXME: don't do this here
 
 109   push @{ $self->{javascripts} ||= [] }, @_ if @_;
 
 110   @{ $self->{javascripts} ||= [] };
 
 116   return map { $self->_find_javascript($_)  }
 
 117     $self->use_javascript, map { $_->javascripts } $self->sub_layouts;
 
 120 sub _find_javascript {
 
 121   my ($self, $javascript) = @_;
 
 123   return "js/$javascript"        if -f "js/$javascript";
 
 124   return $javascript             if -f $javascript;
 
 128 ############################################
 
 129 # track state of form header
 
 130 ############################################
 
 133   $_[0]{_header_done} = 1;