From 500b95460ea781228f27aa2e329dbde6711a05a6 Mon Sep 17 00:00:00 2001 From: pate Date: Fri, 20 Sep 2002 12:49:47 +0000 Subject: [PATCH] adding POD from Andres Arensburger --- C4/Database.pm | 28 +- C4/Koha.pm | 93 +++-- C4/Output.pm | 158 ++++++++- C4/Search.pm | 907 +++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 1130 insertions(+), 56 deletions(-) diff --git a/C4/Database.pm b/C4/Database.pm index e10b456206..63d828dcd2 100755 --- a/C4/Database.pm +++ b/C4/Database.pm @@ -1,4 +1,4 @@ -package C4::Database; #asummes C4/Database +package C4::Database; #assumes C4/Database #requires DBI.pm to be installed @@ -60,12 +60,28 @@ sub C4Connect { return $dbh; } # sub C4Connect +=item requireDBI + + &requireDBI($dbh, $functionnname); + +Verifies that C<$dbh> is a valid DBI::db database handle (presumably +to the Koha database). If it isn't, the function dies. + +C<$functionname> is the name of the calling function, which will be +used in error messages. + +=cut +#' #------------------ # Helper subroutine to make sure database handle was passed properly sub requireDBI { my ( $dbh, $subrname, # name of calling subroutine + # FIXME - Ought to get this with 'caller', + # instead of requiring developers to always + # get it right. Plus, it'd give the line + # number. )=@_; unless ( ref($dbh) =~ /DBI::db/ ) { @@ -77,3 +93,13 @@ sub requireDBI { END { } + +1; +__END__ +=back + +=head1 SEE ALSO + +L + +=cut diff --git a/C4/Koha.pm b/C4/Koha.pm index a5abe88e8c..1503f48ce1 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -26,6 +26,30 @@ use vars qw($VERSION @ISA @EXPORT); $VERSION = 0.01; +=head1 NAME + +C4::Koha - Perl Module containing convenience functions for Koha scripts + +=head1 SYNOPSIS + + use C4::Koha; + + + $date = slashifyDate("01-01-2002") + $ethnicity = fixEthnicity('asian'); + ($categories, $labels) = borrowercategories(); + ($categories, $labels) = ethnicitycategories(); + +=head1 DESCRIPTION + +Koha.pm provides many functions for Koha scripts. + +=head1 FUNCTIONS + +=over 2 + +=cut + @ISA = qw(Exporter); @EXPORT = qw(&slashifyDate &fixEthnicity @@ -37,6 +61,15 @@ use vars qw(); my $DEBUG = 0; +=item slashifyDate + + $slash_date = &slashifyDate($dash_date); + +Takes a string of the form "DD-MM-YYYY" (or anything separated by +dashes), converts it to the form "YYYY/MM/DD", and returns the result. + +=cut + sub slashifyDate { # accepts a date of the form xx-xx-xx[xx] and returns it in the # form xx/xx/xx[xx] @@ -44,6 +77,17 @@ sub slashifyDate { return("$dateOut[2]/$dateOut[1]/$dateOut[0]") } +=item fixEthnicity + + $ethn_name = &fixEthnicity($ethn_code); + +Takes an ethnicity code (e.g., "european" or "pi") and returns the +corresponding descriptive name from the C table in the +Koha database ("European" or "Pacific Islander"). + +=cut +#' + sub fixEthnicity($) { my $ethnicity = shift; @@ -56,6 +100,18 @@ sub fixEthnicity($) { return $data->{'name'}; } +=item borrowercategories + + ($codes_arrayref, $labels_hashref) = &borrowercategories(); + +Looks up the different types of borrowers in the database. Returns two +elements: a reference-to-array, which lists the borrower category +codes, and a reference-to-hash, which maps the borrower category codes +to category descriptions. + +=cut +#' + sub borrowercategories { my $dbh=C4Connect; my $sth=$dbh->prepare("Select categorycode,description from categories order by description"); @@ -71,6 +127,18 @@ sub borrowercategories { return(\@codes,\%labels); } +=item ethnicitycategories + + ($codes_arrayref, $labels_hashref) = ðnicitycategories(); + +Looks up the different ethnic types in the database. Returns two +elements: a reference-to-array, which lists the ethnicity codes, and a +reference-to-hash, which maps the ethnicity codes to ethnicity +descriptions. + +=cut +#' + sub ethnicitycategories { my $dbh=C4Connect; my $sth=$dbh->prepare("Select code,name from ethnicity order by name"); @@ -89,25 +157,7 @@ sub ethnicitycategories { 1; __END__ -=head1 NAME - -Koha - Perl Module containing convenience functions for Koha scripts - -=head1 SYNOPSIS - - use Koha; - - - $date = slashifyDate("01-01-2002") - $ethnicity=fixEthnicity('asian'); - ($categories,$labels)=borrowercategories(); - -=head1 DESCRIPTION - -Koha.pm provides many functions for Koha scripts. - -slashifyDate() takes a dash separated date string and returns a slash -separated date string +=back =head1 AUTHOR @@ -118,8 +168,3 @@ Pat Eyler, pate@gnu.org perl(1). =cut - - - - - diff --git a/C4/Output.pm b/C4/Output.pm index 8c6b7d747d..6aa7df5944 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -33,6 +33,28 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); # set the version for version checking $VERSION = 0.01; +=head1 NAME + +C4::Output - Functions for generating HTML for the Koha web interface + +=head1 SYNOPSIS + + use C4::Output; + + $str = &mklink("http://www.koha.org/", "Koha web page"); + print $str; + +=head1 DESCRIPTION + +The functions in this module generate HTML, and return the result as a +printable string. + +=head1 FUNCTIONS + +=over 2 + +=cut + @ISA = qw(Exporter); @EXPORT = qw(&startpage &endpage &mktablehdr &mktableft &mktablerow &mklink @@ -48,19 +70,21 @@ $VERSION = 0.01; # your exported package globals go here, # as well as any optionally exported functions -@EXPORT_OK = qw($Var1 %Hashit); +@EXPORT_OK = qw($Var1 %Hashit); # FIXME - These are never used # non-exported package globals go here -use vars qw(@more $stuff); +use vars qw(@more $stuff); # FIXME - These are never used # initalize package globals, first exported ones +# FIXME - These are never used my $Var1 = ''; my %Hashit = (); # then the others (which are still accessible as $Some::Module::stuff) +# FIXME - These are never used my $stuff = ''; my @more = (); @@ -70,6 +94,9 @@ my @more = (); # # Change this value to reflect where you will store your includes # +# FIXME - Since this is used in several places, it ought to be put +# into a separate file. Better yet, put "use C4::Config;" inside the +# &import method of any package that requires the config file. my %configfile; open (KC, "/etc/koha.conf"); while () { @@ -93,10 +120,31 @@ my $path=$configfile{'includes'}; # make all your functions, whether exported or not; +=item picktemplate + + $template = &picktemplate($includes, $base); + +Returns the preferred template for a given page. C<$base> is the +basename of the script that will generate the page (with the C<.pl> +extension stripped off), and C<$includes> is the directory in which +HTML include files are located. + +The preferred template is given by the C