]> Frank Brehm's Git Trees - books.git/commitdiff
Betrachter für Kategorie dazu
authorFrank Brehm <frank@brehm-online.com>
Thu, 15 Oct 2009 21:08:37 +0000 (21:08 +0000)
committerFrank Brehm <frank@brehm-online.com>
Thu, 15 Oct 2009 21:08:37 +0000 (21:08 +0000)
lib/FrBr/Books/Controller/Kategorie.pm
lib/FrBr/Books/Util/Category.pm
root/src/category/view.css [new file with mode: 0644]
root/src/category/view.tt2 [new file with mode: 0644]

index bfb90014490432ae72226ccc6dfe30b2c169cd7e..240689d483404aecd5936da65693e8d1109aa40e 100644 (file)
@@ -61,6 +61,7 @@ sub index : Private {
     $c->stash->{'template'} = 'category/index.tt2';
        $c->session->{'return_target_category_save'} = $c->web_path("/kategorie");
 
+    delete $c->session->{'from_category_list'} if exists $c->session->{'from_category_list'};
 }
 
 #-------------------------------------------------------
@@ -161,6 +162,56 @@ sub list : Local {
 
 #-------------------------------------------------------
 
+=head2 form_view( )
+
+Ansehen einer vorhandenen Kategorie.
+
+=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'};
+       $self->add_kategorielist_menu($c) if $c->session->{'from_category_list'};
+       push @{ $c->stash->{'menu_path'} }, {
+               'path' => $c->web_path("/kategorie/view"),
+               'name' => "Betrachten"
+       };
+
+       $c->stash->{'error_message'} = '';
+
+       my $category_id = to_int( $c->request->params->{'view_category_id'} || 0 );
+       unless ( $category_id ) {
+               $c->stash->{'template'} = 'error.tt2';
+               $c->stash->{'error'}    = 'Keine oder ung&uuml;ltige Kategorie-Id &uuml;bergeben.';
+               return 1;
+       }
+
+
+       my $category_list = get_category_list( $c, 'category_id' => $category_id, 'get_books' => 1, );
+       $c->log->debug( get_output_string( $K, "Erhaltene Kategorieliste: ", $category_list ) ) if $c->stash->{'debug_level'} >= 2;
+
+       unless ( $category_list and scalar( @$category_list ) ) {
+               $c->stash->{'template'} = 'error.tt2';
+               $c->stash->{'error'}    = 'Zur &uuml;bergebenen Kategorie-Id wurde keine Kategorie gefunden.';
+               return 1;
+       }
+
+       $c->stash->{'return_target'} = $c->session->{'return_target_view'} or $c->web_path("/kategorie/list");
+
+       $c->stash->{'kategorie'}     = $category_list->[0];
+       $category_list = undef;
+       $c->stash->{'template'} = 'category/view.tt2';
+       push @{$c->stash->{'cssfiles'}}, 'category/view.css';
+
+}
+
+#-------------------------------------------------------
+
 =head2 form_new( )
 
 Erstellen eines neuen Verlages.
index 8701929437e770877b92535a92ed73e9c686af1f..fdca38a39abb61ea9cfa8c0ec95f882b6ac5974c 100644 (file)
@@ -149,6 +149,137 @@ sub get_category_list {
     return ( wantarray ? ( $list, 0 ) : $list ) unless scalar @$list;
     return ( wantarray ? ( $list, $anzahl_kategorien ) : $list ) unless $params->{'get_books'};
 
+       for my $cat ( @$list ) {
+
+               $cat->{'books'} = [];
+
+               $search_params = {
+                       "buch_kategorie.kategorie_id" => $cat->{'id'},
+               };
+               $other_params = {};
+               $other_params->{'join'}     = [ 'waehrung', 'ort', 'bindungsart', 'buch_kategorie', 'verlag', ];
+
+               $other_params->{'select'} = [
+                       'me.id',
+                       'me.title',
+                       'me.title_original',
+                       'me.untertitel',
+                       'me.bindungsart_id',
+                       'bindungsart.art_name',
+                       'me.orts_id',
+                       'me.isbn',
+                       'me.buch_nr',
+                       'me.ausgabejahr',
+                       'me.druckjahr',
+                       'me.seiten',
+                       'me.preis',
+                       'me.waehrungs_id',
+                       'waehrung.waehrungs_kuerzel',
+                       'waehrung.waehrungs_name',
+                       'waehrung.umrechnung_in_euro',
+                       'ort.name',
+                       'ort.descr',
+                       'ort.statisch',
+            'buch_kategorie.kategorie_id',
+            'verlag.name_short',
+            'verlag.name_long',
+               ];
+               $other_params->{'as'} = [
+                       'id',
+                       'title',
+                       'title_original',
+                       'untertitel',
+                       'bindungsart_id',
+                       'bindungsart',
+                       'orts_id',
+                       'isbn',
+                       'buch_nr',
+                       'ausgabejahr',
+                       'druckjahr',
+                       'seiten',
+                       'preis',
+                       'waehrungs_id',
+                       'waehrungs_kuerzel',
+                       'waehrungs_name',
+                       'umrechnung_in_euro',
+                       'ortsname',
+                       'ort_beschreibung',
+                       'ort_ist_statisch',
+            'kategorie_id',
+            'verlags_name_short',
+            'verlags_name_long',
+               ];
+
+               for my $book ( $c->model('Schema::Buecher')->search( $search_params, $other_params )->all() ) {
+                       my $buch = {};
+                       $buch->{'id'}                 = $book->id();
+                       $buch->{'title'}              = $book->title();
+                       $buch->{'title_original'}     = $book->title_original();
+                       $buch->{'untertitel'}         = $book->untertitel();
+                       $buch->{'bindungsart_id'}     = $book->bindungsart_id();
+                       $buch->{'bindungsart'}        = $book->get_column('bindungsart');
+                       $buch->{'orts_id'}            = $book->orts_id();
+                       $buch->{'isbn'}               = $book->isbn();
+                       $buch->{'buch_nr'}            = $book->buch_nr();
+                       $buch->{'ausgabejahr'}        = $book->ausgabejahr();
+                       $buch->{'druckjahr'}          = $book->druckjahr();
+                       $buch->{'seiten'}             = $book->seiten();
+                       $buch->{'preis'}              = $book->preis();
+                       $buch->{'waehrungs_id'}       = $book->waehrungs_id();
+                       $buch->{'waehrungs_kuerzel'}  = $book->get_column('waehrungs_kuerzel');
+                       $buch->{'waehrungs_name'}     = $book->get_column('waehrungs_name');
+                       $buch->{'umrechnung_in_euro'} = $book->get_column('umrechnung_in_euro');
+                       $buch->{'ortsname'}           = $book->get_column('ortsname');
+                       $buch->{'ort_beschreibung'}   = $book->get_column('ort_beschreibung');
+                       $buch->{'ort_ist_statisch'}   = $book->get_column('ort_ist_statisch');
+                       $buch->{'kategorie_id'}       = $book->get_column('kategorie_id');
+                       $buch->{'verlags_name_short'} = $book->get_column('verlags_name_short');
+                       $buch->{'verlags_name_long'}  = $book->get_column('verlags_name_long');
+                       $buch->{'autoren'}            = [];
+                       $buch->{'autor_ids'}          = [];
+
+                       my $a_search_params = {};
+                       $a_search_params->{'buch_id'} = $buch->{'id'};
+                       $other_params = {};
+                       $other_params->{'order_by'} = [ 'ord_num' ];
+                       $other_params->{'join'}     = [ 'autor' ];
+                       $other_params->{'select'} = [
+                               'me.buch_id',
+                               'autor.id',
+                               'autor.titel',
+                               'autor.vorname',
+                               'autor.mittelname',
+                               'autor.nachname',
+                               'autor.name_suffix',
+                       ];
+                       $other_params->{'as'} = [
+                               'buch_id',
+                               'autor_id',
+                               'titel',
+                               'vorname',
+                               'mittelname',
+                               'nachname',
+                               'name_suffix',
+                       ];
+                       for my $ref ( $c->model('Schema::Autor2buch')->search( $a_search_params, $other_params )->all() ) {
+                               my $aid = $ref->get_column('autor_id');
+                               my @N;
+                               push @N, $ref->get_column('titel') if $ref->get_column('titel');
+                               push @N, $ref->get_column('vorname') if $ref->get_column('vorname');
+                               push @N, $ref->get_column('mittelname') if $ref->get_column('mittelname');
+                               push @N, $ref->get_column('nachname');
+                               push @N, $ref->get_column('name_suffix') if $ref->get_column('name_suffix');
+                               my $autor = join( " ", @N );
+                               push @{ $buch->{'autoren'} },   $autor;
+                               push @{ $buch->{'autor_ids'} }, $aid;
+                       }
+
+                       push @{ $cat->{'books'} }, $buch;
+
+        }
+
+    }
+
     return ( wantarray ? ( $list, $anzahl_kategorien ) : $list );
 
 }
diff --git a/root/src/category/view.css b/root/src/category/view.css
new file mode 100644 (file)
index 0000000..167392b
--- /dev/null
@@ -0,0 +1,13 @@
+/* [%#
+   # Template fuer Stylesheets Buchanzeige
+   #
+   # vim: noai : ts=4 fenc=utf-8 filetype=css 
+   #
+   # $Id$
+   # $URL$
+   #
+-%]
+  Stylesheets Verlagsanzeige */
+
+[% PROCESS ftable.css %]
+
diff --git a/root/src/category/view.tt2 b/root/src/category/view.tt2
new file mode 100644 (file)
index 0000000..04f50ff
--- /dev/null
@@ -0,0 +1,82 @@
+<!-- [%#
+
+    Template fuer Kategorieanzeige
+
+    vim: noai : ts=4 fenc=utf-8 filetype=html
+
+    $Id$
+    $URL$
+
+    Übergebene Struktur in [kategorie]:
+
+       $kategorie = {
+    'books' => [
+      {
+        'ausgabejahr' => '1982',
+        'autor_ids' => [
+          '22',
+          '20',
+          '21'
+        ],
+        'autoren' => [
+          'Henry Lincoln',
+          'Michael Baigent',
+          'Richard Leigh'
+        ],
+        'bindungsart' => 'Softcover (Taschenbuch)',
+        'bindungsart_id' => '4',
+        'buch_nr' => undef,
+        'druckjahr' => '2005',
+        'id' => '34',
+        'isbn' => '3-404-77002-1',
+        'kategorie_id' => '6',
+        'ort_beschreibung' => '',
+        'ort_ist_statisch' => 'n',
+        'orts_id' => '2',
+        'ortsname' => 'Flur - Glasvitrine',
+        'preis' => '5',
+        'seiten' => '472',
+        'title' => 'Der Heilige Gral und seine Erben',
+        'title_original' => 'The Holy Blood and the Holy Gral',
+        'umrechnung_in_euro' => '1',
+        'untertitel' => 'Ursprung und Gegewart eines geheimen Ordens. Sein Wissen und seine Macht.',
+        'verlags_name_long' => 'Bastei Lübbe Taschenbuchverlag (Imprint der Verlagsgruppe Lübbe)',
+        'verlags_name_short' => 'Bastei Lübbe',
+        'waehrungs_id' => '1',
+        'waehrungs_kuerzel' => '€',
+        'waehrungs_name' => 'Euro',
+      }
+    ],
+    'count_books' => '1',
+    'id' => '6',
+    'name' => 'Dokumentation',
+       };
+
+-%]
+[%- BLOCK book_entry -%]
+[% book.title | html %][% IF book.autoren.size %] ([% book.autoren.join( ', ' ) | html %])[% END %]
+[%- END -%]
+
+
+Verlagsanzeige -->
+
+<table class="ftable" cellspacing="0">
+  <tr>
+    <th colspan="2" class="title">Kategorieangaben '[%- kategorie.name | html -%]'</th>
+  </tr><tr>
+    <td colspan="2" class="empty"></td>
+  </tr><tr>
+    <th>Kategorie:</th>
+    <td>[%- kategorie.name | html -%]</td>
+  </tr><tr>
+    <th>Anzahl Bücher:</th>
+    <td>[%- kategorie.count_books | html -%]</td>
+  </tr><tr>
+    <th>Bücher:</th>
+    <td>[% IF kategorie.count_books > 1 %]<ul>[% FOR buch IN kategorie.books %]<li>[% PROCESS book_entry book=buch %]</li>[% END %]</ul>[% ELSE %][% PROCESS book_entry book=kategorie.books.0 %][% END %]</td>
+</table>
+
+<div class="back">
+<h2><a href="[% return_target %]">[% 'Zurück' %]</a></h2>
+</div>
+