#-------------------------------------------------------
+sub add_autorlist_menu : Private {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ push @{ $c->stash->{'menu_path'} }, {
+ 'path' => $c->web_path("/autor/list"),
+ 'name' => "Liste"
+ };
+
+}
+
+#-------------------------------------------------------
+
=head2 list
Fetch all author objects and pass to autor/list.tt2 in stash to be displayed
my $K = ( caller(0) )[3] . "(): ";
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
- push @{ $c->stash->{'menu_path'} }, {
- 'path' => $c->web_path("/autor/list"),
- 'name' => "Liste"
- };
+ $self->add_autorlist_menu($c);
+
+ my $page = $c->session->{'autor_list_page'} || 1;
+ my $list_length = $c->stash->{'list_length'} || 10;
- my $liste = get_author_list( $c, 'get_books' => 1 );
+ if ( $c->request->params->{'page'} and to_int( $c->request->params->{'page'} ) ) {
+ $page = to_int( $c->request->params->{'page'} );
+ $c->session->{'autor_list_page'} = $page;
+ }
+
+ my ( $liste, $anzahl ) = get_author_list( $c, 'get_books' => 1, 'page' => $page );
$c->log->debug( get_output_string( $K, "Erhaltene Liste der Autoren: ", $liste ) ) if $c->stash->{'debug_level'} >= 2;
+ my $max_page = 1;
+ if ( $anzahl ) {
+ $max_page = int( $anzahl / $list_length ) + 1;
+ if ( ( $page - 1 ) * $list_length > $anzahl ) {
+ $page = $max_page;
+ $c->session->{'autor_list_page'} = $page;
+ }
+ }
+ else {
+ $page = 1;
+ $c->session->{'autor_list_page'} = 1;
+ }
+
+ my $nav = {
+ 'cur' => $page,
+ 'first' => 1,
+ 'last' => $max_page,
+ 'prev' => ( ( $page > 1 ) ? ( $page - 1 ) : 1 ),
+ 'next' => ( ( ( $page + 1 ) > $max_page ) ? $max_page : ( $page + 1 ) ),
+ 'autoren' => $anzahl,
+ 'autor_from' => ( $anzahl ? ( ( $page - 1 ) * $list_length ) + 1 : 0 ),
+ 'autor_to' => ( ( $page * $list_length ) > $anzahl ? $anzahl : ( $page * $list_length ) ),
+ };
+ $c->stash->{'autor_liste_page'} = $nav;
+ $c->log->debug( get_output_string( $K, "Seitennavigation: ", $nav ) ) if $c->stash->{'debug_level'} >= 2;
+
$c->stash->{'authors'} = $liste;
$c->session->{'return_target_view'} = $c->web_path("/autor/list");
__END__
-# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :
+# vim: noai : ts=4 fenc=utf-8 filetype=perl
__END__
-# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :
+# vim: noai : ts=4 fenc=utf-8 filetype=perl
=back
-Rueckgabe: Eine Array-Ref von Hash-Refs mit allen Autoren, die den uebergebenen Suchkriterien entsprechen:
+Rueckgabe: Eine Array-Ref von Hash-Refs mit allen Autoren, die den uebergebenen Suchkriterien entsprechen, sowie im Listenkontext die Anzahl der Autoren, die den uebergebenen Suchkriterien entsprechen.
+
+Die zurueckgegebene Array-Ref hat folgenden Aufbau:
$res = [
{
$c->log->debug( get_output_string( $K, "Uebergebene Parameter: ", $params ) ) if $c->stash->{'debug_level'} >= 2;
my $list = [];
+ my $anzahl_autoren = 0;
my $page = to_int( $params->{'page'} ) ? to_int( $params->{'page'} ) : undef;
my $rows = undef;
};
}
+ $anzahl_autoren = $c->model('Schema::Autoren')->count( $search_params );
+ $c->log->debug( get_output_string( $K, "Anzahl gefundene Autoren: ", $anzahl_autoren ) ) if $c->stash->{'debug_level'} >= 2;
+
my $other_params = {};
$other_params->{'order_by'} = [ 'nachname', 'vorname', 'mittelname', 'name_suffix' ];
$other_params->{'select'} = [
}
}
- return $list;
+ return ( wantarray ? ( $list, $anzahl_autoren ) : $list );
}
#-----------------------------------------------------------------------------------
-->
+[% tab_colspan = 4 %][% IF Catalyst.user_exists %][% tab_colspan = 6 %][% END -%]
+
[% META title = 'Autorenliste' -%]
+[% BLOCK navrow %]
+ <tr>
+ <td class="nav" colspan="[% tab_colspan %]"><table cellspacing="0" class="nav" width="100%">
+ <tr>
+ <td width="33%" style="text-align: left;"><b>[% IF autor_liste_page.cur != 1 %]<a href="[% self_url %]?page=1" title="Erste Seite"><<</a>[% ELSE %]<<[% END %] [% IF autor_liste_page.cur != autor_liste_page.prev %]<a href="[% self_url %]?page=[% autor_liste_page.prev %]" title="Vorherige Seite"><</a>[% ELSE %]<[% END %]</b></td>
+ <td width="33%" style="text-align: center;">Autor [% autor_liste_page.autor_from %] bis [% autor_liste_page.autor_to %] von [% autor_liste_page.autoren %]</td>
+ <td width="33%" style="text-align: right;"><b>[% IF autor_liste_page.cur != autor_liste_page.next %]<a href="[% self_url %]?page=[% autor_liste_page.next %]" title="Nächste Seite">></a>[% ELSE %]>[% END %] [% IF autor_liste_page.cur != autor_liste_page.last %]<a href="[% self_url %]?page=[% autor_liste_page.last %]" title="Letzte Seite">>></a>[% ELSE %]>>[% END %]</b></td>
+ </tr>
+ </table></td>
+ </tr>
+[% END -%]
+
<div class="center">
<table class="wrapper" cellspacing="0">
-<tr><th>Liste der Bücher</th> </tr>
+<tr><th>Liste der Autoren</th> </tr>
[% IF Catalyst.user_exists %]<tr><td class="action"><a href="[% path('/autor/new') %]">Neuer Autor ...</a></td></tr>[% END %]
<tr><td><table class="autorliste">
<tr>
<th></th>
[% IF Catalyst.user_exists %]<th></th>
<th></th>[% END %]
- </tr>
+ </tr>[% PROCESS navrow %]
[% rowstyle = 'even' %][%- FOREACH author IN authors -%][% author_id = author.id %]
<tr>
<td class="[% rowstyle %]">[% author.name %]</td>
<td class="button [% rowstyle %]">[% IF author.books and author.books.size > 0 %]Löschen[% ELSE %]<a href="[% path('/autor/delete') %]?delete_autor_id=[% author.id %]">Löschen</a>[% END %]</td>[% END %]
</tr>
[% IF rowstyle == 'even' %][% rowstyle = 'odd'%][% ELSE %][% rowstyle = 'even' %][% END %][% END -%]
-</table></td></tr></table>
+[% PROCESS navrow %]</table></td></tr></table>
</div>
<br />