]> Frank Brehm's Git Trees - books.git/commitdiff
Aus Util::Waehrung mach Plugin::Waehrung
authorFrank Brehm <frank@brehm-online.com>
Tue, 16 Feb 2010 14:09:10 +0000 (14:09 +0000)
committerFrank Brehm <frank@brehm-online.com>
Tue, 16 Feb 2010 14:09:10 +0000 (14:09 +0000)
lib/FrBr/Books.pm
lib/FrBr/Books/Controller/Books.pm
lib/FrBr/Books/Plugin/Waehrung.pm [new file with mode: 0644]
lib/FrBr/Books/Util/Waehrung.pm [deleted file]

index 27a350d477100db26fcf856a1397bea806a62783..483e04c570eb9e5b9ffb325dda4c7077ac7c1a62 100644 (file)
@@ -39,6 +39,7 @@ use Catalyst qw/
     Session::State::Cookie
 
     +FrBr::Books::Plugin::Ort
+    +FrBr::Books::Plugin::Waehrung
 
 /;
 
index e9b50ccfb0e723dd3900503f295b94b614fc61da..9bcd1f61a89ec27d1212d55980a73fe07e776b8a 100644 (file)
@@ -15,7 +15,7 @@ use FrBr::Books::Util::Category;
 use FrBr::Books::Util::Serie;
 #use FrBr::Books::Util::Ort;
 use FrBr::Books::Util::Verlag;
-use FrBr::Books::Util::Waehrung;
+#use FrBr::Books::Util::Waehrung;
 use FrBr::Books::Util::User;
 
 =head1 NAME
@@ -1339,7 +1339,7 @@ sub prepare_data_structures : Private {
     $c->log->debug( get_output_string( $K . "Serien: ", $c->stash->{'serienliste'} ) );
 
     # Waehrungen zusammensammeln
-    my $waehrungsliste = get_waehrungsliste($c);
+    my $waehrungsliste = $c->b_get_waehrungsliste();
     $c->log->debug( get_output_string( $K . "Waehrungen gesamt: ", $waehrungsliste ) );
     $c->stash->{'waehrungsliste'} = {};
     $c->stash->{'waehrungs_ids'}  = [];
diff --git a/lib/FrBr/Books/Plugin/Waehrung.pm b/lib/FrBr/Books/Plugin/Waehrung.pm
new file mode 100644 (file)
index 0000000..d146637
--- /dev/null
@@ -0,0 +1,115 @@
+package FrBr::Books::Plugin::Waehrung;
+
+# $Id$
+# $URL$
+
+use strict;
+use warnings;
+
+use FrBr::Common;
+
+our $VERSION = '0.02';
+{
+    my ($rev) = '$Revision$' =~ /(\d+)/;
+    $VERSION = sprintf( $VERSION . ".%d", $rev );
+}
+
+=head1 NAME
+
+FrBr::Books::Plugin::Waehrung - Modul fuer Funktionen rund um Waehrungen
+
+=head1 METHODS
+
+=cut
+
+#-----------------------------------------------------------------------------------
+
+=head2 $c->b_get_waehrungsliste( $params )
+
+Sammelt alle Waehrungen zusammen.
+
+Folgende benannte Parameter koennen ueber $params uebergeben werden:
+
+Rueckgabe: Eine Array-Ref von Hash-Refs mit allen Waehrungen, die den uebergebenen Suchkriterien entsprechen:
+
+  $res = [
+    { 'id'     => 1,
+      'kuerzel'        => '$',
+      'name'   => 'US-Dollar',
+      'in_euro'        => 0.66225,
+    },
+    { 'id'     => 2,
+      ...
+    },
+    ...
+  ];
+
+Die Liste ist nach den Waehrungs-Namen alphabetisch sortiert.
+
+=cut
+
+sub b_get_waehrungsliste {
+
+    my $c = shift;
+    my $K = ( caller(0) )[3] . "(): ";
+
+    $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+
+    my $params = {};
+    if ( ref($_[0]) and ref($_[0]) eq 'HASH' ) {
+        $params = $_[0];
+    }
+    else {
+        %$params = @_;
+    }
+    $c->log->debug(  get_output_string( $K, "Uebergebene Parameter: ", $params ) ) if $c->stash->{'debug_level'} >= 2;
+
+    my $list = [];
+
+    my $search_params = undef;
+
+    my $other_params = {};
+    $other_params->{'order_by'} = [ 'waehrungs_name' ];
+    $other_params->{'select'} = [
+        'id',
+        'waehrungs_kuerzel',
+        'waehrungs_name',
+        'umrechnung_in_euro',
+    ];
+    $other_params->{'as'} = [
+        'id',
+        'waehrungs_kuerzel',
+        'waehrungs_name',
+        'umrechnung_in_euro',
+    ];
+    for my $waehrung_rs ( $c->model('Schema::Waehrungen')->search( $search_params, $other_params )->all() ) {
+        my $waehrung = {};
+        $waehrung->{'id'}      = $waehrung_rs->id();
+        $waehrung->{'kuerzel'} = $waehrung_rs->waehrungs_kuerzel();
+        $waehrung->{'name'}    = $waehrung_rs->waehrungs_name();
+        $waehrung->{'in_euro'} = $waehrung_rs->umrechnung_in_euro();
+        push @$list, $waehrung;
+    }
+
+    return $list;
+}
+
+#-----------------------------------------------------------------------------------
+
+=head1 AUTHOR
+
+Frank Brehm
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+
+__END__
+
+# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :
diff --git a/lib/FrBr/Books/Util/Waehrung.pm b/lib/FrBr/Books/Util/Waehrung.pm
deleted file mode 100644 (file)
index 34ede56..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-package FrBr::Books::Util::Waehrung;
-
-# $Id$
-# $URL$
-
-use strict;
-use warnings;
-
-use FrBr::Common;
-
-# Export-Deklarationen
-
-BEGIN {
-
-    use Exporter();
-    our ( $VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS );
-
-    # set the version for version checking
-    $VERSION = 0.1;
-    my ($rev) = '$Revision$' =~ /(\d+)/;
-    $VERSION = sprintf( $VERSION . ".%d", $rev );
-
-    @ISA    = qw(Exporter);
-    @EXPORT = qw(
-        &get_waehrungsliste
-    );
-
-    #%EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
-
-    # your exported package globals go here,
-    # as well as any optionally exported functions
-    #@EXPORT_OK   = qw($Var1 %Hashit &func3);
-} ## end BEGIN
-
-our @EXPORT_OK;
-
-=head1 NAME
-
-FrBr::Books::Util::Waehrung - Modul fuer Funktionen rund um Waehrungen
-
-=head1 METHODS
-
-=cut
-
-#-----------------------------------------------------------------------------------
-
-=head2 get_waehrungsliste( $c, $params )
-
-Sammelt alle Waehrungen zusammen.
-
-Folgende benannte Parameter koennen ueber $params uebergeben werden:
-
-Rueckgabe: Eine Array-Ref von Hash-Refs mit allen Waehrungen, die den uebergebenen Suchkriterien entsprechen:
-
-  $res = [
-    { 'id'     => 1,
-      'kuerzel'        => '$',
-      'name'   => 'US-Dollar',
-      'in_euro'        => 0.66225,
-    },
-    { 'id'     => 2,
-      ...
-    },
-    ...
-  ];
-
-Die Liste ist nach den Waehrungs-Namen alphabetisch sortiert.
-
-=cut
-
-sub get_waehrungsliste {
-
-    my $c = shift;
-    my $K = __PACKAGE__ . "::get_waehrungsliste(): ";
-
-    $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
-
-    my $params = {};
-    if ( ref($_[0]) and ref($_[0]) eq 'HASH' ) {
-        $params = $_[0];
-    }
-    else {
-        %$params = @_;
-    }
-    $c->log->debug(  get_output_string( $K, "Uebergebene Parameter: ", $params ) ) if $c->stash->{'debug_level'} >= 2;
-
-    my $list = [];
-
-    my $search_params = undef;
-
-    my $other_params = {};
-    $other_params->{'order_by'} = [ 'waehrungs_name' ];
-    $other_params->{'select'} = [
-        'id',
-        'waehrungs_kuerzel',
-        'waehrungs_name',
-        'umrechnung_in_euro',
-    ];
-    $other_params->{'as'} = [
-        'id',
-        'waehrungs_kuerzel',
-        'waehrungs_name',
-        'umrechnung_in_euro',
-    ];
-    for my $waehrung_rs ( $c->model('Schema::Waehrungen')->search( $search_params, $other_params )->all() ) {
-        my $waehrung = {};
-        $waehrung->{'id'}      = $waehrung_rs->id();
-        $waehrung->{'kuerzel'} = $waehrung_rs->waehrungs_kuerzel();
-        $waehrung->{'name'}    = $waehrung_rs->waehrungs_name();
-        $waehrung->{'in_euro'} = $waehrung_rs->umrechnung_in_euro();
-        push @$list, $waehrung;
-    }
-
-    return $list;
-}
-
-#-----------------------------------------------------------------------------------
-
-=head1 AUTHOR
-
-Frank Brehm
-
-=head1 LICENSE
-
-This library is free software, you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-
-1;
-
-__END__
-
-# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :