my $liste = get_author_list( $c, 'get_books' => 1 );
$c->log->debug( get_output_string( $K, "Erhaltene Liste der Autoren: ", $liste ) ) if $c->stash->{'debug_level'} >= 2;
$c->stash->{'authors'} = $liste;
+ $c->session->{'return_target_view'} = $c->web_path("/autor/list");
$c->stash->{'template'} = 'autor/list.tt2';
#-------------------------------------------------------
+=head2 form_view( )
+
+Ansehen eines vorhandenen Autors.
+
+=cut
+
+sub form_view : Path('view') {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+
+ $c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
+ push @{ $c->stash->{'menu_path'} }, {
+ 'path' => $c->web_path("/autor/view"),
+ 'name' => "Betrachten"
+ };
+
+ $c->stash->{'error_message'} = '';
+
+ my $aid = to_int( $c->request->params->{'view_autor_id'} || 0 );
+ unless ( $aid ) {
+ $c->stash->{'template'} = 'error.tt2';
+ $c->stash->{'error'} = 'Keine oder ungültige Autoren-Id übergeben.';
+ return 1;
+ }
+
+ my $aliste = get_author_list( $c, 'autor_id' => $aid, 'get_books' => 1, );
+ $c->log->debug( get_output_string( $K, "Erhaltene Autorenliste: ", $aliste ) ) if $c->stash->{'debug_level'} >= 2;
+
+ unless ( $aliste and scalar( @$aliste ) ) {
+ $c->stash->{'template'} = 'error.tt2';
+ $c->stash->{'error'} = 'Zur übergebenen Autoren-Id wurde kein Autor gefunden.';
+ return 1;
+ }
+
+ $c->stash->{'return_target'} = $c->session->{'return_target_view'} or $c->web_path("/autor/list");
+
+ $c->stash->{'autor'} = $aliste->[0];
+ $aliste = undef;
+ $c->stash->{'template'} = 'autor/view.tt2';
+ push @{$c->stash->{'cssfiles'}}, 'autor/view.css';
+
+}
+
+#-------------------------------------------------------
+
sub save_author : Private {
my ( $self, $c ) = @_;
Boolscher Parameter, der aussagt, dass auch die Buecher des Autors / der Autoren
mit zuammengesammelt werden sollen.
+=item B<autor_id>: Die ID eines konkreten Autors
+
+=item B<page>
+
+Integer: Zeigt an, welche Seite von Verlagen dargestellt werden soll.
+
+Wenn nicht angegeben, werden alle Verlage zurückgegeben.
+
=back
Rueckgabe: Eine Array-Ref von Hash-Refs mit allen Autoren, die den uebergebenen Suchkriterien entsprechen:
- $res = [
- { 'id' => 1,
- 'name' => 'J.R.R. Tolkien',
- 'titel' => undef,
- 'vorname' => 'J.R.R.',
- 'mittelname' => undef,
- 'nachname' => 'Tolkien',
- 'name_suffix' => undef,
- 'descr' => 'Bla Blub',
- 'books' => [ 'Der Herr der Ringe',
- 'Silmarillion',
- ...
- ],
- },
- { 'id' => 2,
- ...
- },
- ...
- ];
+ $res = [
+ {
+ 'id' => 1,
+ 'name' => 'J.R.R. Tolkien',
+ 'titel' => undef,
+ 'vorname' => 'J.R.R.',
+ 'mittelname' => undef,
+ 'nachname' => 'Tolkien',
+ 'name_suffix' => undef,
+ 'descr' => 'Bla Blub',
+ 'books' => [
+ {
+ 'id' => 22,
+ 'title' => 'Der Herr der Ringe',
+ 'title_original' => 'The Lord Of The Rings',
+ 'untertitel' => 'Triligie',
+ 'isbn' => '123-45-678-908',
+ },
+ {
+ 'id' => 34,
+ 'title' => 'Silmarillion',
+ ...
+ },
+ ...
+ ],
+ },
+ {
+ 'id' => 2,
+ ...
+ },
+ ...
+ ];
Die Liste ist nach den Nachnamen, Vornamen, Mittelnamen und Namens-Suffixen alphabetisch sortiert.
my $list = [];
+ my $page = to_int( $params->{'page'} ) ? to_int( $params->{'page'} ) : undef;
+ my $rows = undef;
+ $rows = $c->stash->{'list_length'} || 20 if defined $page;
+
my $search_params = undef;
+ if ( $params->{'autor_id'} ) {
+ $search_params = {
+ 'me.id' => $params->{'autor_id'},
+ };
+ }
my $other_params = {};
$other_params->{'order_by'} = [ 'nachname', 'vorname', 'mittelname', 'name_suffix' ];
'autor_descr',
];
- for my $autor_rs ( $c->model('Schema::Autoren')->search( $search_params, $other_params )->all() ) {
- my $autor = {};
- $autor->{'id'} = $autor_rs->id();
- $autor->{'titel'} = $autor_rs->titel();
- $autor->{'vorname'} = $autor_rs->vorname();
- $autor->{'mittelname'} = $autor_rs->mittelname();
- $autor->{'nachname'} = $autor_rs->nachname();
- $autor->{'name_suffix'} = $autor_rs->name_suffix();
- $autor->{'descr'} = $autor_rs->autor_descr();
- $autor->{'books'} = [];
- my @N;
- push @N, $autor->{'titel'} if $autor->{'titel'};
- push @N, $autor->{'vorname'} if $autor->{'vorname'};
- push @N, $autor->{'mittelname'} if $autor->{'mittelname'};
- push @N, $autor->{'nachname'};
- push @N, $autor->{'name_suffix'} if $autor->{'name_suffix'};
- $autor->{'name'} = join( " ", @N );
- push @$list, $autor;
- }
+ if ( $page ) {
+ $other_params->{'rows'} = $rows;
+ $other_params->{'page'} = $page;
+ }
+
+ for my $autor_rs ( $c->model('Schema::Autoren')->search( $search_params, $other_params )->all() ) {
+ my $autor = {};
+ $autor->{'id'} = $autor_rs->id();
+ $autor->{'titel'} = $autor_rs->titel();
+ $autor->{'vorname'} = $autor_rs->vorname();
+ $autor->{'mittelname'} = $autor_rs->mittelname();
+ $autor->{'nachname'} = $autor_rs->nachname();
+ $autor->{'name_suffix'} = $autor_rs->name_suffix();
+ $autor->{'descr'} = $autor_rs->autor_descr();
+ $autor->{'books'} = [];
+ my @N;
+ push @N, $autor->{'titel'} if $autor->{'titel'};
+ push @N, $autor->{'vorname'} if $autor->{'vorname'};
+ push @N, $autor->{'mittelname'} if $autor->{'mittelname'};
+ push @N, $autor->{'nachname'};
+ push @N, $autor->{'name_suffix'} if $autor->{'name_suffix'};
+ $autor->{'name'} = join( " ", @N );
+ push @$list, $autor;
+ }
if ( $params->{'get_books'} ) {
for my $autor ( @$list ) {
** $Id$
** $URL$
** -%]
+[%- BLOCK book_entry -%]
+<a href="[% Catalyst.web_path( '/books/view', { 'return_target_form' => self_url, view_book_id => b.id, } ) %]">[% b.title | html %]</a>[% IF b.untertitel %] ([% b.untertitel | html %])[% END %]
+[%- END -%]
Autorenliste
<td class="[% rowstyle %]">[% author.descr %]</td>
<td class="[% rowstyle %]"><ul class="buchliste">
[% IF author.books and author.books.size > 0 %][% FOREACH book IN author.books -%]
- <li>[% book.title %][% IF book.untertitel %] ([% book.untertitel %])[% END %]</li>[% END %][% ELSE %]<li><i>keine</i></li>[% END %]
+ <li>[% PROCESS book_entry b=book %]</li>[% END %][% ELSE %]<li><i>keine</i></li>[% END %]
</ul></td>
<td class="button [% rowstyle %]"><a href="[% path('/autor/view') %]?view_autor_id=[% author.id %]">Ansehen</a></td>
[% IF Catalyst.user_exists %]<td class="button [% rowstyle %]"><a href="[% path('/autor/edit') %]?edit_autor_id=[% author.id %]">Ändern</a></td>
--- /dev/null
+/* [%#
+ # Template fuer Stylesheets Autorenazeige
+ #
+ # vim: noai : ts=4 fenc=utf-8 filetype=css
+ #
+ # $Id$
+ # $URL$
+ #
+-%]
+ Stylesheets Autorenazeige */
+
+TABLE.ftable {
+ border-width: 2px;
+ border-style: solid;
+ border-top-color: [% site.col.tab_rahmen_hell %];
+ border-left-color: [% site.col.tab_rahmen_hell %];
+ border-right-color: [% site.col.tab_rahmen_dkl %];
+ border-bottom-color: [% site.col.tab_rahmen_dkl %];
+ border-collapse: separate;
+ border-spacing: 0;
+ margin: auto;
+}
+
+TABLE.ftable UL {
+ margin: 0;
+}
+
+TABLE.ftable TH {
+ vertical-align: top;
+ text-align: left;
+ padding: 2px;
+ border-width: 1px;
+ border-style: solid;
+ font-size: 1em;
+ border-top-color: [% site.col.tab_rahmen_dkl %];
+ border-left-color: [% site.col.tab_rahmen_dkl %];
+ border-right-color: [% site.col.tab_rahmen_hell %];
+ border-bottom-color: [% site.col.tab_rahmen_hell %];
+ background-color: [% site.col.list_head %];
+}
+
+TABLE.ftable TD {
+ vertical-align: top;
+ padding: 2px;
+ border-width: 1px;
+ border-style: solid;
+ border-top-color: [% site.col.tab_rahmen_dkl %];
+ border-left-color: [% site.col.tab_rahmen_dkl %];
+ border-right-color: [% site.col.tab_rahmen_hell %];
+ border-bottom-color: [% site.col.tab_rahmen_hell %];
+ background-color: [% site.col.list_row_bold %];
+}
+
+TABLE.ftable TD.empty {
+ height: 0.5em;
+}
+
+TABLE.ftable TH.button {
+ font-weight: bolder;
+ text-align: center;
+ font-size: 1.2em;
+ padding-left: 1em;
+ padding-right: 1em;
+}
+
+TABLE.ftable TH.button INPUT {
+ font-weight: bolder;
+ text-align: center;
+ font-size: 1em;
+ padding-left: 1em;
+ padding-right: 1em;
+}
+
+
--- /dev/null
+<!-- [%#
+
+ Template fuer Autorenanzeige
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+ Übergebene Struktur in [autor]:
+
+ $autor = {
+ 'id' => 1,
+ 'name' => 'J.R.R. Tolkien',
+ 'titel' => undef,
+ 'vorname' => 'J.R.R.',
+ 'mittelname' => undef,
+ 'nachname' => 'Tolkien',
+ 'name_suffix' => undef,
+ 'descr' => 'Bla Blub',
+ 'books' => [
+ {
+ 'id' => 22,
+ 'title' => 'Der Herr der Ringe',
+ 'title_original' => 'The Lord Of The Rings',
+ 'untertitel' => 'Triligie',
+ 'isbn' => '123-45-678-908',
+ },
+ {
+ 'id' => 34,
+ 'title' => 'Silmarillion',
+ ...
+ };
+ ],
+ };
+
+-%]
+[%- BLOCK book_entry -%]
+<a href="[% Catalyst.web_path( '/books/view', { 'return_target_form' => self_url, view_book_id => b.id, } ) %]">[% b.title | html %]</a>[% IF b.untertitel %]<br />
+ <i>([% b.untertitel | html %])</i>[% END %]
+[%- END -%]
+
+Autorenanzeige -->
+
+<table class="ftable" cellspacing="0">
+ <tr>
+ <th colspan="2" class="title">Autor '[%- autor.name | html -%]'</th>
+ </tr><tr>
+ <td colspan="2" class="empty"></td>
+ </tr><tr>
+ <th>Titel des Autors :</th>
+ <td>[% autor.title | html %]</td>
+ </tr><tr>
+ <th>Vorname:</th>
+ <td>[% autor.vorname | html %]</td>
+ </tr><tr>
+ <th>Zweiter Vorname (oder Vatersname o.ä.):</th>
+ <td>[% autor.mittelname | html %]</td>
+ </tr><tr>
+ <th>Nachname:</th>
+ <td>[% autor.nachname | html %]</td>
+ </tr><tr>
+ <th>Namenssuffix (Jr. o.ä.):</th>
+ <td>[% autor.name_suffix | html %]</td>
+ </tr><tr>
+ <th>Zusätzliche Angaben:</th>
+ <td>[% autor.descr | html %]</td>
+ </tr><tr>
+ <th>Bücher:</th>
+ <td>[% IF autor.books.size > 0 %][% IF autor.books.size > 1 %]<ul>[% FOR buch IN autor.books %]<li>[% PROCESS book_entry b=buch %]</li>
+ [% END %]</ul>[% ELSE %][% PROCESS book_entry b=autor.books.0 %][% END %][% ELSE %]<i>keine</i>[% END %]</td>
+</table>
+
+<div class="back">
+<h2><a href="[% return_target %]">[% 'Zurück' %]</a></h2>
+</div>
+