X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FPlugin%2FMultiColumnIterator.pm;h=7ce3aeb55174077e7c11df2cf381bfda52242579;hb=2b3391521b469f9f7b2928d104a9f620dddb25d2;hp=71fb565a7f71bd5407f276eaa69e1e605ae294fd;hpb=06fd85e8e7c7813fb15bdb9e8add12b6c78031ed;p=kivitendo-erp.git diff --git a/SL/Template/Plugin/MultiColumnIterator.pm b/SL/Template/Plugin/MultiColumnIterator.pm index 71fb565a7..7ce3aeb55 100644 --- a/SL/Template/Plugin/MultiColumnIterator.pm +++ b/SL/Template/Plugin/MultiColumnIterator.pm @@ -1,6 +1,5 @@ package SL::Template::Plugin::MultiColumnIterator; -use strict; use base 'Template::Plugin'; use Template::Constants; use Template::Exception; @@ -8,10 +7,12 @@ use Template::Iterator; use SL::LXDebug; use Data::Dumper; +use strict; + our $AUTOLOAD; sub new { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my $class = shift; my $context = shift; my $data = shift || [ ]; @@ -36,7 +37,7 @@ sub new { $data = [ $data ] ; } - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); bless { _DATA => $data, @@ -47,7 +48,7 @@ sub new { sub get_first { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my $self = shift; my $data = $self->{ _DATA }; my $dim = $self->{ _DIM }; @@ -55,7 +56,7 @@ sub get_first { $self->{ _DATASET } = $self->{ _DATA }; my $size = int ((scalar @$data - 1) / $dim) + 1; my $index = 0; - + return (undef, Template::Constants::STATUS_DONE) unless $size; # initialise various counters, flags, etc. @@ -63,12 +64,12 @@ sub get_first { @$self{ qw( PREV ) } = ( undef ); $$self{ qw( NEXT ) } = [ @{ $self->{ _DATASET } }[ map { $index + 1 + $_ * $size } 0 .. ($dim - 1) ] ]; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); return [ @{ $self->{ _DATASET } }[ map { $index + $_ * $size } 0 .. ($dim - 1) ] ]; } sub get_next { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my $self = shift; my ($max, $index) = @$self{ qw( MAX INDEX ) }; my $data = $self->{ _DATASET }; @@ -89,11 +90,11 @@ sub get_next { @$self{ qw( INDEX COUNT FIRST LAST ) } = ( $index, $index + 1, 0, $index == $max ? 1 : 0 ); $$self{ qw( PREV ) } = [ @{ $self->{ _DATASET } }[ map { $index - 1 + $_ * $size } 0 .. ($dim - 1) ] ]; $$self{ qw( NEXT ) } = [ @{ $self->{ _DATASET } }[ map { $index + 1 + $_ * $size } 0 .. ($dim - 1) ] ]; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); return [ @{ $self->{ _DATASET } }[ map { $index + $_ * $size } 0 .. ($dim - 1) ] ]; } else { - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); return (undef, Template::Constants::STATUS_DONE); ## RETURN ## } } @@ -110,7 +111,7 @@ sub get_all { # update counters and flags @$self{ qw( INDEX COUNT FIRST LAST ) } = ( $max, $max + 1, 0, 1 ); $main::lxdebug->leave_sub(); - return \@data; ## RETURN ## + return \@data; ## RETURN ## } else { $main::lxdebug->leave_sub(); @@ -131,9 +132,9 @@ sub AUTOLOAD { } sub dump { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my $self = shift; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); return join('', "
", " Data: ", Dumper($self->{ _DATA }), "\n", @@ -149,45 +150,51 @@ sub dump { } sub index { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($self) = @_; - $self->{ INDEX }; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); + return $self->{ INDEX }; } sub number { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($self) = @_; - $self->{ NUMBER }; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); + return $self->{ NUMBER }; } +sub count { + $main::lxdebug->enter_sub(); + my ($self) = @_; + $main::lxdebug->leave_sub(); + return $self->{ COUNT }; +} sub max { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($self) = @_; - $self->{ MAX }; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); + return $self->{ MAX }; } sub size { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($self) = @_; - $self->{ SIZE }; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); + return $self->{ SIZE }; } sub first { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($self) = @_; - $self->{ FIRST }; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); + return $self->{ FIRST }; } sub last { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(); my ($self) = @_; - $self->{ LAST}; - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(); + return $self->{ LAST}; } 1;