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/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>

Auch abrufbar als: Unified diff