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/BackgroundJobHistory.pm
79 79
}
80 80

  
81 81
sub add_stylesheet {
82
  $::form->use_stylesheet('lx-office-erp/background_jobs.css');
82
  $::request->{layout}->use_stylesheet('lx-office-erp/background_jobs.css');
83 83
}
84 84

  
85 85
1;
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;
SL/Controller/Layout/Classic.pm
14 14
  $self->{top}  = SL::Controller::Layout::Top->new;
15 15
  $self->{left} = SL::Controller::Layout::MenuLeft->new;
16 16

  
17
  $self->use_stylesheet(
18
    $self->{top}->stylesheets,
19
    $self->{left}->stylesheets,
20
  );
21

  
22
  $self->use_javascript(
23
    $self->{top}->javascripts,
24
    $self->{left}->javascripts,
25
  );
26

  
17 27
  $self;
18 28
}
19 29

  
......
30 40
  "</div>\n";
31 41
}
32 42

  
33
sub stylesheets {
34
  $_[0]{top}->stylesheets,
35
  $_[0]{left}->stylesheets;
36
}
37

  
38
sub javascripts {
39
  $_[0]{top}->javascripts,
40
  $_[0]{left}->javascripts;
41
}
42

  
43 43
1;
SL/Controller/Layout/MenuLeft.pm
7 7

  
8 8
use List::MoreUtils qw(apply);
9 9

  
10
sub stylesheets {
11
  qw(css/icons16.css css/icons24.css);
10
sub new {
11
  my ($class, @slurp) = @_;
12

  
13
  my $self = $class->SUPER::new(@slurp);
14

  
15
  $self->use_stylesheet(qw(css/icons16.css css/icons24.css));
16

  
17
  $self;
12 18
}
13 19

  
14 20
sub render {
SL/Drafts.pm
36 36
  return ($module, $submodule);
37 37
}
38 38

  
39
my @dont_save = qw(login password stylesheet action);
39
my @dont_save = qw(login password action);
40 40

  
41 41
sub save {
42 42
  $main::lxdebug->enter_sub();
SL/Form.pm
447 447
  return $output;
448 448
}
449 449

  
450
sub use_stylesheet {
451
  my $self = shift;
452

  
453
  $self->{stylesheet} = [ $self->{stylesheet} ] unless ref $self->{stylesheet} eq 'ARRAY';
454

  
455
  if (@_) {
456
    $self->{stylesheet} =
457
      [ grep { -f                       }
458
        map  { m:^css/: ? $_ : "css/$_" }
459
        grep { $_                       }
460
             (@{ $self->{stylesheet} }, @_)
461
      ];
462
  }
463

  
464
  return @{ $self->{stylesheet} };
465
}
466

  
467
sub get_stylesheet_for_user {
468
  my $css_path = 'css';
469
  if (my $user_style = $::myconfig{stylesheet}) {
470
    $user_style =~ s/\.css$//; # nuke trailing .css, this is a remnand of pre 2.7.0 stylesheet handling
471
    if (-d "$css_path/$user_style" &&
472
        -f "$css_path/$user_style/main.css") {
473
      $css_path = "$css_path/$user_style";
474
    } else {
475
      $css_path = "$css_path/lx-office-erp";
476
    }
477
  } else {
478
    $css_path = "$css_path/lx-office-erp";
479
  }
480
  $::myconfig{css_path} = $css_path; # needed for menunew, FIXME: don't do this here
481

  
482
  return $css_path;
483
}
484

  
485 450
sub header {
486 451
  $::lxdebug->enter_sub;
487 452

  
488
  # extra code is currently only used by menuv3 and menuv4 to set their css.
489
  # it is strongly deprecated, and will be changed in a future version.
490 453
  my ($self, %params) = @_;
491 454
  my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET;
492 455
  my @header;
493 456

  
457
  my $layout = $::request->{layout};
458

  
494 459
  $::lxdebug->leave_sub and return if !$ENV{HTTP_USER_AGENT} || $self->{header}++;
495 460

  
496
  my $css_path = $self->get_stylesheet_for_user;
461
  # standard css for all
462
  $layout->use_stylesheet("$_.css") for qw(
463
    main menu tabcontent list_accounts jquery.autocomplete
464
    jquery.multiselect2side frame_header/header
465
    ui-lightness/jquery-ui-1.8.12.custom
466
    js/jscalendar/calendar-win2k-1
467
  );
468

  
469
  $layout->use_javascript("$_.js") for qw(
470
    jquery common jscalendar/calendar jscalendar/lang/calendar-de
471
    jscalendar/calendar-setup part_selection jquery-ui jquery.cookie jqModal
472
    switchmenuframe
473
  );
497 474

  
498 475
  $self->{favicon} ||= "favicon.ico";
499 476
  $self->{titlebar} = join ' - ', grep $_, $self->{title}, $self->{login}, $::myconfig{dbname}, $self->{version} if $self->{title};
......
505 482
    push @header, "<meta http-equiv='refresh' content='$refresh_time;$refresh_url'>";
506 483
  }
507 484

  
508
  push @header, map { qq|<link rel="stylesheet" href="$_" type="text/css" title="Stylesheet">| } $self->use_stylesheet, $::request->{layout}->stylesheets;
509

  
510
  push @header, "<style type='text/css'>\@page { size:landscape; }</style>" if $self->{landscape};
511
  push @header, "<link rel='shortcut icon' href='$self->{favicon}' type='image/x-icon'>" if -f $self->{favicon};
512
  push @header, map { qq|<script type="text/javascript" src="js/$_.js"></script>| }
513
       qw(jquery common jscalendar/calendar jscalendar/lang/calendar-de jscalendar/calendar-setup part_selection jquery-ui jquery.cookie jqModal switchmenuframe);
485
  push @header, map { qq|<link rel="stylesheet" href="$_" type="text/css" title="Stylesheet">| } $layout->stylesheets;
486
  push @header, "<style type='text/css'>\@page { size:landscape; }</style> "                     if $self->{landscape};
487
  push @header, "<link rel='shortcut icon' href='$self->{favicon}' type='image/x-icon'>"         if -f $self->{favicon};
488
  push @header, map { qq|<script type="text/javascript" src="$_"></script>| }                 $layout->javascripts;
514 489
  push @header, $self->{javascript} if $self->{javascript};
515
  push @header, map { qq|<link rel="stylesheet" type="text/css" href="$css_path/$_.css">| }
516
       qw(main menu tabcontent list_accounts jquery.autocomplete jquery.multiselect2side frame_header/header ui-lightness/jquery-ui-1.8.12.custom);
517
  push @header, map { qq|<link rel="stylesheet" type="text/css" href="js/jscalendar/calendar-win2k-1.css">| }
518 490
  push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] };
519 491
  push @header, "<script type='text/javascript'>function fokus(){ document.$self->{fokus}.focus(); }</script>" if $self->{fokus};
520 492

  
......
522 494
    strict       => qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">|,
523 495
    transitional => qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">|,
524 496
    frameset     => qq|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">|,
497
    html5        => qq|<!DOCTYPE html>|,
525 498
  );
526 499

  
527 500
  # output
......
545 518
   ***********************************************/
546 519

  
547 520
  </script>
548
  $params{extra_code}
549 521
 </head>
550 522
 <body>
551 523

  
......
559 531
sub footer {
560 532
  # TODO: fix abort conditions
561 533

  
534
  print $::request->{layout}->end_content;
562 535
  print $::request->{layout}->post_content;
563
  print "<script type='text/javascript' src='$_'></script>\n" for $::request->{layout}->javascripts;
564
  if (my @inline_scripts = $::request->{layout}->javascript_inline) {
565
    print "<script type='text/javascript'>$_</script>\n" for @inline_scripts;
566
  }
536
#  print "<script type='text/javascript' src='$_'></script>\n" for $::request->{layout}->javascripts;
537
#  if (my @inline_scripts = $::request->{layout}->javascript_inline) {
538
#    print "<script type='text/javascript'>$_</script>\n" for @inline_scripts;
539
#  }
567 540

  
568 541
  print <<EOL
569 542
 </body>
SL/User.pm
136 136
    $dbh->disconnect;
137 137

  
138 138
    if ($update_available) {
139
      $form->{"stylesheet"} = "lx-office-erp.css";
140 139
      $form->{"title"} = $main::locale->text("Dataset upgrade");
141 140
      $form->header();
142 141
      print $form->parse_html_template("dbupgrade/header");
bin/mozilla/admin.pl
91 91
  $locale = $::locale;
92 92
  $auth   = $::auth;
93 93

  
94
  $form->{stylesheet} = "lx-office-erp.css";
94
  $request->{layout}->use_stylesheet("lx-office-erp.css");
95 95
  $form->{favicon}    = "favicon.ico";
96 96

  
97 97
  if ($form->{action}) {
......
703 703
  my $form            = $main::form;
704 704
  my $locale          = $main::locale;
705 705

  
706
  $form->{stylesheet} = "lx-office-erp.css";
706
  $::request->{layout}->use_stylesheet("lx-office-erp.css");
707 707
  $form->{title}      = $locale->text("Dataset upgrade");
708 708
  $form->header();
709 709

  
bin/mozilla/am.pl
466 466
    $ca->{link_edit_account} = $link_edit_account . '&id=' . E($ca->{id});
467 467
  }
468 468

  
469
  $form->use_stylesheet("list_accounts.css");
469
  $::request->{layout}->use_stylesheet("list_accounts.css");
470 470
  $form->{title}       = $locale->text('Chart of Accounts');
471 471

  
472 472
  $form->header;
bin/mozilla/drafts.pl
26 26
    restore_form($form->{SAVED_FORM}, 1) if ($form->{SAVED_FORM});
27 27
    delete $form->{SAVED_FORM};
28 28

  
29
    $form->{SAVED_FORM}   = save_form(qw(stylesheet login password));
29
    $form->{SAVED_FORM}   = save_form(qw(login password));
30 30
    $form->{remove_draft} = 1;
31 31

  
32 32
    $form->header();
......
79 79
  $draft_nextsub = "add" unless ($draft_nextsub);
80 80

  
81 81
  delete $form->{action};
82
  my $saved_form = save_form(qw(stylesheet login password));
82
  my $saved_form = save_form(qw(login password));
83 83

  
84 84
  $form->header();
85 85
  print($form->parse_html_template("drafts/load",
......
129 129
    $form->{draft_description}     = $description;
130 130
    $form->{remove_draft}          = 'checked';
131 131
  }
132
  # Ich vergesse bei Rechnungsentwürfe das Rechnungsdatum zu ändern. Dadurch entstehen 
132
  # Ich vergesse bei Rechnungsentwürfe das Rechnungsdatum zu ändern. Dadurch entstehen
133 133
  # ungültige Belege. Vielleicht geht es anderen ähnlich jan 19.2.2011
134 134
  $form->{invdate} = $form->current_date(\%myconfig); # Aktuelles Rechnungsdatum  ...
135 135
  $form->{duedate} = $form->current_date(\%myconfig); # Aktuelles Fälligkeitsdatum  ...
bin/mozilla/is.pl
835 835
    $form->error($locale->text("Invoice has already been storno'd!"));
836 836
  }
837 837

  
838
  map({ my $key = $_; delete($form->{$key}) unless (grep({ $key eq $_ } qw(id login password stylesheet type))); } keys(%{ $form }));
838
  map({ my $key = $_; delete($form->{$key}) unless (grep({ $key eq $_ } qw(id login password type))); } keys(%{ $form }));
839 839

  
840 840
  invoice_links();
841 841
  prepare_invoice();
bin/mozilla/oe.pl
1225 1225

  
1226 1226
  $form->{simple_save} = 1;
1227 1227
  if(!$form->{print_and_save}) {
1228
    delete @{$form}{ary_diff([keys %{ $form }], [qw(login stylesheet id script type cursor_fokus)])};
1228
    delete @{$form}{ary_diff([keys %{ $form }], [qw(login id script type cursor_fokus)])};
1229 1229
    edit();
1230 1230
    ::end_of_request();
1231 1231
  }

Auch abrufbar als: Unified diff