Leser: 1
|< 1 2 >| | 11 Einträge, 2 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<table>
<tr>
<td>Mo</td>
<td>Di</td>
<td>Mi</td>
<td>Do</td>
<td>Fr</td>
<td>Sa</td>
<td>So</td>
</tr>
<!-- TMPL_LOOP ALLE_WOCHEN -->
<tr>
<!-- TMPL_LOOP EINE_WOCHE -->
<td><!-- TMPL_VAR TAGESZAHL --></td>
<!-- /TMPL_LOOP EINE_WOCHE -->
</tr>
<!-- /TMPL_LOOP ALLE_WOCHEN -->
</table>
1
2
3
4
5
6
7
for my $d ( 1 .. Days_in_Month($year, $month) ) {
# ????
}
$template->param(
ALLE_WOCHEN => \@AlleWochen
);
1
2
3
4
my @AlleWochen = (
{ EINE_WOCHE => [{ TAGESZAHL => 1 }, ..., { TAGESZAHL => 7 }] },
...
);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
my @AlleWochen;
my @EineWoche;
my %EineWoche;
for my $d ( 1 .. Days_in_Month($year, $month) ) {
my $dow = Day_of_Week($year, $month, $d);
# Am Monatsersten wenn kein Montag Leerzellen einfügen
if ( $d == 1 && $dow > 1 ) {
for my $i ( 1 .. $dow - 1 ) {
my %EinTagDummy = (
TAG => 'xx',
);
push (@EineWoche, \%EinTagDummy);
}
my %EinTag = (
TAG => $d,
);
push (@EineWoche, \%EinTag);
}
else {
my %EinTag = (
TAG => $d,
);
push (@EineWoche, \%EinTag);
}
# am letzten Tag der Woche Zeile übergeben
if ( $dow == 7 ) {
$EineWoche{EINE_WOCHE} = \@EineWoche;
push (@AlleWochen, \%EineWoche);
@EineWoche = ();
}
}
$template->param(
ALLE_WOCHEN => \@AlleWochen
);
1 2 3 4 5 6 7 8 9 10 11
use Data::Tabulate; my $tab = Data::Tabulate->new(); $tab->min_columns( 7 ); $tab->max_columns( 7 ); my @array = map{ {TAGESZAHL => $_} }( 1 .. Days_in_Month($month,$year) ); @array = map{ {WOCHE => $_} } $tab->tabulate(@array); $tmpl->param( ALLE_WOCHEN => \@array );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#!/usr/bin/perl use strict; use warnings; use Data::Tabulate; use Data::Dumper; use Date::Calc qw(Day_of_Week Days_in_Month); use HTML::Template::Compiled; my $month = 2; my $year = 2007; # nicht jeder monat faengt mit Montag an my $dow = Day_of_Week( $year, $month, 1 ); $dow = 7 if $dow == 1; $dow--; my @array = (' ') x $dow; # bearbeite die tage my @tage; for( @array, 1 .. Days_in_Month($year,$month) ){ push @tage, { TAGESZAHL => $_, CSS => 'irgendein_css', #... }; } # teile in wochen auf my $tab = Data::Tabulate->new(); $tab->min_columns(7); $tab->max_columns(7); my @wochen = map{ {WOCHE => $_} }$tab->tabulate(@tage); # template processing my $template = HTML::Template::Compiled->new( filehandle => *DATA ); $template->param( ALLEWOCHEN => \@wochen ); print $template->output; __DATA__ <table> <TMPL_LOOP NAME=ALLEWOCHEN> <tr> <TMPL_LOOP NAME=WOCHE> <td class="<TMPL_VAR NAME=CSS ESCAPE=HTML>"><TMPL_VAR NAME=TAGESZAHL></td> </TMPL_LOOP> </tr> </TMPL_LOOP> </table>
1
2
[Mon Jul 23 14:10:17 2007] [error] [client 164.30.144.153] Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/site_perl/5.8.6/Data/Tabulate.pm line 217., referer: ...
[Mon Jul 23 14:10:17 2007] [error] [client 164.30.144.153] Use of uninitialized value in pattern match (m//) at /usr/lib/perl5/site_perl/5.8.6/Data/Tabulate.pm line 195., referer: ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
sub max_columns{ my ($self,$value) = @_; $self->{max_cols} = $value if defined $value and $value =~ /^[1-9]\d*$/; my $caller = (caller(1))[3]; unless( ($caller and $caller =~ /min_columns/) or not defined $self->min_columns){ $self->min_columns($self->{max_cols}) if $self->{max_cols} < $self->min_columns; } return $self->{max_cols}; } =head2 min_columns set how many columns the table can have (at least). $tabulator->min_columns(3); the table has at least three columns =cut sub min_columns{ my ($self,$value) = @_; $self->{min_cols} = $value if defined $value and $value =~ /^[1-9]\d*$/; my $caller = (caller(1))[3]; unless( $caller and $caller =~ /max_columns/){ $self->max_columns($self->{min_cols}) if $self->{min_cols} > $self->max_columns; } return $self->{min_cols}; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#!/usr/bin/perl use strict; use warnings; use Date::Calc qw(Day_of_Week Days_in_Month); use HTML::Template::Compiled; my $month = 2; my $year = 2007; # nicht jeder monat faengt mit Montag an my $dow = Day_of_Week( $year, $month, 1 ); $dow = 7 if $dow == 1; $dow--; my @array = (' ') x $dow; # bearbeite die tage my @tage; for( @array, 1 .. Days_in_Month($year,$month) ){ push @tage, { TAGESZAHL => $_, CSS => 'irgendein_css', #... }; } # teile in wochen auf my @wochen; my $counter = 0; my @subtage; for my $tag( @tage ){ push @subtage, $tag; if( ++$counter == 7 ){ $counter = 0; push @woche, { WOCHE => [@subtage] }; undef @subtage; } } # template processing my $template = HTML::Template::Compiled->new( filehandle => *DATA ); $template->param( ALLEWOCHEN => \@wochen ); print $template->output; __DATA__ <table> <TMPL_LOOP NAME=ALLEWOCHEN> <tr> <TMPL_LOOP NAME=WOCHE> <td class="<TMPL_VAR NAME=CSS ESCAPE=HTML>"><TMPL_VAR NAME=TAGESZAHL></td> </TMPL_LOOP> </tr> </TMPL_LOOP> </table>
|< 1 2 >| | 11 Einträge, 2 Seiten |