X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a1a9bb961ab49ee053cb208ea01e17430d0ca836..4a12c839937370488b8b8a40bef376e7cb0a2ce6:/SL/Form.pm diff --git a/SL/Form.pm b/SL/Form.pm index 2f4283359..b25fe6a2d 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -451,11 +451,15 @@ sub use_stylesheet { my $self = shift; $self->{stylesheet} = [ $self->{stylesheet} ] unless ref $self->{stylesheet} eq 'ARRAY'; - $self->{stylesheet} = [ grep { -f } - map { m:^css/: ? $_ : "css/$_" } - grep { $_ } - (@{ $self->{stylesheet} }, @_) - ]; + + if (@_) { + $self->{stylesheet} = + [ grep { -f } + map { m:^css/: ? $_ : "css/$_" } + grep { $_ } + (@{ $self->{stylesheet} }, @_) + ]; + } return @{ $self->{stylesheet} }; } @@ -492,7 +496,7 @@ sub header { my $css_path = $self->get_stylesheet_for_user; $self->{favicon} ||= "favicon.ico"; - $self->{titlebar} = "$self->{title} - $self->{titlebar}" if $self->{title}; + $self->{titlebar} = join ' - ', grep $_, $self->{title}, $self->{login}, $::myconfig{dbname}, $self->{version} if $self->{title}; # build includes if ($self->{refresh_url} || $self->{refresh_time}) { @@ -501,33 +505,18 @@ sub header { push @header, ""; } - push @header, map { qq|| } $self->use_stylesheet; + push @header, map { qq|| } $self->use_stylesheet, $::request->{layout}->stylesheets; push @header, "" if $self->{landscape}; push @header, "" if -f $self->{favicon}; push @header, map { qq|| } - qw(jquery common jscalendar/calendar jscalendar/lang/calendar-de jscalendar/calendar-setup part_selection jquery-ui jqModal switchmenuframe); + qw(jquery common jscalendar/calendar jscalendar/lang/calendar-de jscalendar/calendar-setup part_selection jquery-ui jquery.cookie jqModal switchmenuframe); push @header, $self->{javascript} if $self->{javascript}; push @header, map { qq|| } qw(main menu tabcontent list_accounts jquery.autocomplete jquery.multiselect2side frame_header/header ui-lightness/jquery-ui-1.8.12.custom); push @header, map { qq|| } push @header, map { $_->show_javascript } @{ $self->{AJAX} || [] }; push @header, "" if $self->{fokus}; - push @header, sprintf "", - join ' - ', grep $_, $self->{title}, $self->{login}, $::myconfig{dbname}, $self->{version} if $self->{title}; - - # if there is a title, we put some JavaScript in to the page, wich writes a - # meaningful title-tag for our frameset. - my $title_hack = ''; - if ($self->{title}) { - $title_hack = qq| - |; - } my %doctypes = ( strict => qq||, @@ -557,14 +546,31 @@ EOT $params{extra_code} - $title_hack + EOT + print $::request->{layout}->pre_content; + print $::request->{layout}->start_content; $::lxdebug->leave_sub; } +sub footer { + # TODO: fix abort conditions + + print $::request->{layout}->post_content; + print "\n" for $::request->{layout}->javascripts; + if (my @inline_scripts = $::request->{layout}->javascript_inline) { + print "\n" for @inline_scripts; + } + + print < + +EOL +} + sub ajax_response_header { $main::lxdebug->enter_sub(); @@ -695,6 +701,8 @@ sub init_template { return $self->template if $self->template; + # Force scripts/locales.pl to pick up the exception handling template. + # parse_html_template('generic/exception') return $self->template(Template->new({ 'INTERPOLATE' => 0, 'EVAL_PERL' => 0, @@ -704,6 +712,7 @@ sub init_template { 'INCLUDE_PATH' => '.:templates/webpages', 'COMPILE_EXT' => '.tcc', 'COMPILE_DIR' => $::lx_office_conf{paths}->{userspath} . '/templates-cache', + 'ERROR' => 'templates/webpages/generic/exception.html', })) || die; } @@ -788,10 +797,8 @@ sub write_trigger { # default my %dateformats = ( "dd.mm.yy" => "%d.%m.%Y", - "dd-mm-yy" => "%d-%m-%Y", "dd/mm/yy" => "%d/%m/%Y", "mm/dd/yy" => "%m/%d/%Y", - "mm-dd-yy" => "%m-%d-%Y", "yyyy-mm-dd" => "%Y-%m-%d", ); @@ -865,41 +872,30 @@ sub format_amount { $main::lxdebug->enter_sub(2); my ($self, $myconfig, $amount, $places, $dash) = @_; - $dash ||= ''; - - if ($amount eq "") { - $amount = 0; - } + $amount ||= 0; + $dash ||= ''; + my $neg = $amount < 0; + my $force_places = defined $places && $places >= 0; - $amount *= 1; + $amount = $self->round_amount($amount, abs $places) if $force_places; + $amount = sprintf "%.*f", ($force_places ? $places : 10), abs $amount; # 6 is default for %fa - # Hey watch out! The amount can be an exponential term like 1.13686837721616e-13 + # before the sprintf amount was a number, afterwards it's a string. because of the dynamic nature of perl + # this is easy to confuse, so keep in mind: before this comment no s///, m//, concat or other strong ops on + # $amount. after this comment no +,-,*,/,abs. it will only introduce subtle bugs. - my $neg = ($amount =~ s/^-//); - my $exp = ($amount =~ m/[e]/) ? 1 : 0; - - if (defined($places) && ($places ne '')) { - if (not $exp) { - if ($places < 0) { - $amount *= 1; - $places *= -1; - - if ($amount =~ /\.(\d+)/) { - my $actual_places = length $1; - $places = $actual_places if $actual_places > $places; - } - } - } - $amount = $self->round_amount($amount, $places); - } + $amount =~ s/0*$// unless defined $places && $places == 0; # cull trailing 0s my @d = map { s/\d//g; reverse split // } my $tmp = $myconfig->{numberformat}; # get delim chars - my @p = split(/\./, $amount); # split amount at decimal point - - $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters + my @p = split(/\./, $amount); # split amount at decimal point + $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters $amount = $p[0]; - $amount .= $d[0].($p[1]||'').(0 x ($places - length ($p[1]||''))) if ($places || $p[1] ne ''); + if ($places || $p[1]) { + $amount .= $d[0] + . ( $p[1] || '' ) + . (0 x (abs($places || 0) - length ($p[1]||''))); # pad the fraction + } $amount = do { ($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) : @@ -907,7 +903,6 @@ sub format_amount { ($neg ? "-$amount" : "$amount" ) ; }; - $main::lxdebug->leave_sub(2); return $amount; } @@ -3601,6 +3596,30 @@ sub reformat_numbers { $::myconfig{numberformat} = $saved_numberformat; } +sub layout { + my ($self) = @_; + $::lxdebug->enter_sub; + + my %style_to_script_map = ( + v3 => 'v3', + neu => 'new', + v4 => 'v4', + ); + + my $menu_script = $style_to_script_map{$::myconfig{menustyle}} || ''; + + package main; + require "bin/mozilla/menu$menu_script.pl"; + package Form; + require SL::Controller::FrameHeader; + + + my $layout = SL::Controller::FrameHeader->new->action_header . ::render(); + + $::lxdebug->leave_sub; + return $layout; +} + 1; __END__