Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0f179c9a

Von Sven Schöling vor etwa 12 Jahren hinzugefügt

  • ID 0f179c9ab60ac22c697027cadc9f4bdb9c515ce5
  • Vorgänger 0164607c
  • Nachfolger 2219d158

stylesheet/javascript handling verbessert

Unterschiede anzeigen:

SL/Controller/Layout/Base.pm
21 21
  Menu->new('menu.ini');
22 22
}
23 23

  
24
##########################################
25
#  inheritable/overridable
26
##########################################
27

  
24 28
sub pre_content {
25 29
}
26 30

  
......
33 37
sub post_content {
34 38
}
35 39

  
40
sub stylesheets_inline {
41
}
42

  
43
sub javascript_inline {
44
}
45

  
46
#########################################
47
# Interface
48
########################################
49

  
50
sub use_stylesheet {
51
  my $self = shift;
52
  push @{ $self->{stylesheets} ||= [] }, @_ if @_;
53
  @{ $self->{stylesheets} ||= [] };
54
}
55

  
36 56
sub stylesheets {
57
  my ($self) = @_;
58
  my $css_path = $self->get_stylesheet_for_user;
59

  
60
  return grep { $_ } map { $self->_find_stylesheet($_, $css_path)  } $self->use_stylesheet;
37 61
}
38 62

  
39
sub stylesheets_inline {
63
sub _find_stylesheet {
64
  my ($self, $stylesheet, $css_path) = @_;
65

  
66
  return "$css_path/$stylesheet" if -f "$css_path/$stylesheet";
67
  return "css/$stylesheet"       if -f "css/$stylesheet";
68
  return $stylesheet             if -f $stylesheet;
40 69
}
41 70

  
42
sub javascript_inline {
71
sub get_stylesheet_for_user {
72
  my $css_path = 'css';
73
  if (my $user_style = $::myconfig{stylesheet}) {
74
    $user_style =~ s/\.css$//; # nuke trailing .css, this is a remnand of pre 2.7.0 stylesheet handling
75
    if (-d "$css_path/$user_style" &&
76
        -f "$css_path/$user_style/main.css") {
77
      $css_path = "$css_path/$user_style";
78
    } else {
79
      $css_path = "$css_path/lx-office-erp";
80
    }
81
  } else {
82
    $css_path = "$css_path/lx-office-erp";
83
  }
84
  $::myconfig{css_path} = $css_path; # needed for menunew, FIXME: don't do this here
85

  
86
  return $css_path;
87
}
88

  
89

  
90
sub use_javascript {
91
  my $self = shift;
92
  $::lxdebug->dump(0,  "class", \@_);
93
  push @{ $self->{javascripts} ||= [] }, @_ if @_;
94
  @{ $self->{javascripts} ||= [] };
95
}
96

  
97
sub javascripts {
98
  my ($self) = @_;
99

  
100
  $::lxdebug->dump(0,  "called", [ map { $self->find_javascript($_)  } $self->use_javascript ]);
101
  return map { $self->_find_javascript($_)  } $self->use_javascript;
102
}
103

  
104
sub _find_javascript {
105
  my ($self, $javascript) = @_;
106

  
107
  return "js/$javascript"        if -f "js/$javascript";
108
  return $javascript             if -f $javascript;
43 109
}
44 110

  
45 111
1;

Auch abrufbar als: Unified diff