<<

NAME

    C4::Koha - Perl Module containing convenience functions for Koha scripts

SYNOPSIS

  use C4::Koha;

DESCRIPTION

    Koha.pm provides many functions for Koha scripts.

FUNCTIONS

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.

DisplayISBN

    my $string = DisplayISBN( $isbn );

GetSupportName

  $itemtypename = &GetSupportName($codestring);

Returns a string with the name of the itemtype.

GetSupportList

  $itemtypes = &GetSupportList();

Returns an array ref containing informations about Support (since itemtype is rather a circulation code when item-level-itypes is used).

build a HTML select with the following code :

in PERL SCRIPT

    my $itemtypes = GetSupportList();
    $template->param(itemtypeloop => $itemtypes);

in TEMPLATE

    <form action='<!-- TMPL_VAR name="script_name" -->' method=post>
        <select name="itemtype">
            <option value="">Default</option>
        <!-- TMPL_LOOP name="itemtypeloop" -->
            <option value="<!-- TMPL_VAR name="itemtype" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->> <!--TMPL_IF Name="imageurl"--><img alt="<!-- TMPL_VAR name="description" -->" src="<!--TMPL_VAR Name="imageurl"-->><!--TMPL_ELSE-->"<!-- TMPL_VAR name="description" --><!--/TMPL_IF--></option>
        <!-- /TMPL_LOOP -->
        </select>
        <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
        <input type="submit" value="OK" class="button">
    </form>

GetItemTypes

  $itemtypes = &GetItemTypes();

Returns information about existing itemtypes.

build a HTML select with the following code :

in PERL SCRIPT

    my $itemtypes = GetItemTypes;
    my @itemtypesloop;
    foreach my $thisitemtype (sort keys %$itemtypes) {
        my $selected = 1 if $thisitemtype eq $itemtype;
        my %row =(value => $thisitemtype,
                    selected => $selected,
                    description => $itemtypes->{$thisitemtype}->{'description'},
                );
        push @itemtypesloop, \%row;
    }
    $template->param(itemtypeloop => \@itemtypesloop);

in TEMPLATE

    <form action='<!-- TMPL_VAR name="script_name" -->' method=post>
        <select name="itemtype">
            <option value="">Default</option>
        <!-- TMPL_LOOP name="itemtypeloop" -->
            <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="description" --></option>
        <!-- /TMPL_LOOP -->
        </select>
        <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->">
        <input type="submit" value="OK" class="button">
    </form>

getauthtypes

  $authtypes = &getauthtypes();

Returns information about existing authtypes.

build a HTML select with the following code :

in PERL SCRIPT

my $authtypes = getauthtypes; my @authtypesloop; foreach my $thisauthtype (keys %$authtypes) { my $selected = 1 if $thisauthtype eq $authtype; my %row =(value => $thisauthtype, selected => $selected, authtypetext => $authtypes->{$thisauthtype}->{'authtypetext'}, ); push @authtypesloop, \%row; } $template->param(itemtypeloop => \@itemtypesloop);

in TEMPLATE

<form action='<!-- TMPL_VAR name="script_name" -->' method=post> <select name="authtype"> <!-- TMPL_LOOP name="authtypeloop" --> <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="authtypetext" --></option> <!-- /TMPL_LOOP --> </select> <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->"> <input type="submit" value="OK" class="button"> </form>

getframework

  $frameworks = &getframework();

Returns information about existing frameworks

build a HTML select with the following code :

in PERL SCRIPT

my $frameworks = frameworks(); my @frameworkloop; foreach my $thisframework (keys %$frameworks) { my $selected = 1 if $thisframework eq $frameworkcode; my %row =(value => $thisframework, selected => $selected, description => $frameworks->{$thisframework}->{'frameworktext'}, ); push @frameworksloop, \%row; } $template->param(frameworkloop => \@frameworksloop);

in TEMPLATE

<form action='<!-- TMPL_VAR name="script_name" -->' method=post> <select name="frameworkcode"> <option value="">Default</option> <!-- TMPL_LOOP name="frameworkloop" --> <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="frameworktext" --></option> <!-- /TMPL_LOOP --> </select> <input type=text name=searchfield value="<!-- TMPL_VAR name="searchfield" -->"> <input type="submit" value="OK" class="button"> </form>

getframeworkinfo

  $frameworkinfo = &getframeworkinfo($frameworkcode);

Returns information about an frameworkcode.

getitemtypeinfo

  $itemtype = &getitemtype($itemtype);

Returns information about an itemtype.

getitemtypeimagedir

4
  my $directory = getitemtypeimagedir( 'opac' );

pass in 'opac' or 'intranet'. Defaults to 'opac'.

returns the full path to the appropriate directory containing images.

_getImagesFromDirectory

  Find all of the image files in a directory in the filesystem

  parameters:
    a directory name

  returns: a list of images in that directory.

  Notes: this does not traverse into subdirectories. See
      _getSubdirectoryNames for help with that.
    Images are assumed to be files with .gif or .png file extensions.
    The image names returned do not have the directory name on them.

_getSubdirectoryNames

  Find all of the directories in a directory in the filesystem

  parameters:
    a directory name

  returns: a list of subdirectories in that directory.

  Notes: this does not traverse into subdirectories. Only the first
      level of subdirectories are returned.
    The directory names returned don't have the parent directory name
      on them.

getImageSets

  returns: a listref of hashrefs. Each hash represents another collection of images.
           { imagesetname => 'npl', # the name of the image set (npl is the original one)
             images => listref of image hashrefs
           }

    each image is represented by a hashref like this:
      { KohaImage     => 'npl/image.gif',
        StaffImageUrl => '/intranet-tmpl/prog/img/itemtypeimg/npl/image.gif',
        OpacImageURL  => '/opac-tmpl/prog/itemtypeimg/npl/image.gif'
        checked       => 0 or 1: was this the image passed to this method?
                         Note: I'd like to remove this somehow.
      }

GetPrinters

  $printers = &GetPrinters();
  @queues = keys %$printers;

Returns information about existing printer queues.

$printers is a reference-to-hash whose keys are the print queues defined in the printers table of the Koha database. The values are references-to-hash, whose keys are the fields in the printers table.

GetPrinter

$printer = GetPrinter( $query, $printers );

getnbpages

Returns the number of pages to display in a pagination bar, given the number of items and the number of items per page.

getallthemes

  (@themes) = &getallthemes('opac');
  (@themes) = &getallthemes('intranet');

Returns an array of all available themes.

get_infos_of

Return a href where a key is associated to a href. You give a query, the name of the key among the fields returned by the query. If you also give as third argument the name of the value, the function returns a href of scalar. The optional 4th argument is an arrayref of items passed to the execute() call. It is designed to bind parameters to any placeholders in your SQL.

  my $query = '
SELECT itemnumber,
       notforloan,
       barcode
  FROM items
';

  # generic href of any information on the item, href of href.
  my $iteminfos_of = get_infos_of($query, 'itemnumber');
  print $iteminfos_of->{$itemnumber}{barcode};

  # specific information, href of scalar
  my $barcode_of_item = get_infos_of($query, 'itemnumber', 'barcode');
  print $barcode_of_item->{$itemnumber};

get_notforloan_label_of

  my $notforloan_label_of = get_notforloan_label_of();

Each authorised value of notforloan (information available in items and itemtypes) is link to a single label.

Returns a href where keys are authorised values and values are corresponding labels.

  foreach my $authorised_value (keys %{$notforloan_label_of}) {
    printf(
        "authorised_value: %s => %s\n",
        $authorised_value,
        $notforloan_label_of->{$authorised_value}
    );
  }

displayServers

my $servers = displayServers();

my $servers = displayServers( $position );

my $servers = displayServers( $position, $type );

displayServers returns a listref of hashrefs, each containing information about available z3950 servers. Each hashref has a format like:

    {
      'checked'    => 'checked',
      'encoding'   => 'MARC-8'
      'icon'       => undef,
      'id'         => 'LIBRARY OF CONGRESS',
      'label'      => '',
      'name'       => 'server',
      'opensearch' => '',
      'value'      => 'z3950.loc.gov:7090/',
      'zed'        => 1,
    },

GetAuthValCode

$authvalcode = GetAuthValCode($kohafield,$frameworkcode);

GetAuthValCodeFromField

$authvalcode = GetAuthValCodeFromField($field,$subfield,$frameworkcode);

$subfield can be undefined

GetAuthorisedValues

$authvalues = GetAuthorisedValues([$category], [$selected]);

This function returns all authorised values from the'authorised_value' table in a reference to array of hashrefs.

$category returns authorised values for just one category (optional).

$opac If set to a true value, displays OPAC descriptions rather than normal ones when they exist.

GetAuthorisedValueCategories

$auth_categories = GetAuthorisedValueCategories();

Return an arrayref of all of the available authorised value categories.

GetKohaAuthorisedValues

        Takes $kohafield, $fwcode as parameters.
        If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
        Returns hashref of Code => description
        Returns undef 
          if no authorised value category is defined for the kohafield.

GetKohaAuthorisedValuesFromField

        Takes $field, $subfield $fwcode as parameters.
        If $opac parameter is set to a true value, displays OPAC descriptions rather than normal ones when they exist.
        $subfield can be undefined
        Returns hashref of Code => description
        Returns undef 
          if no authorised value category is defined for the given field and subfield 

display_marc_indicators

# field is a MARC::Field object my $display_form = C4::Koha::display_marc_indicators($field);

Generate a display form of the indicators of a variable MARC field, replacing any blanks with '#'.

AUTHOR

Koha Team

<<
https://perldoc.koha-community.org/v3.02.00-alpha/C4/Koha.html
perldoc.koha-community.org
crawl=CC-MAIN-2020-40
22611
application/http; msgtype=response
sha1:GK44NC55J2Z7KE564CXWABFTTQHNS3H2
<urn:uuid:94b71ccc-09c9-4157-8ab4-463694d3bca8>
2020-09-30T18:20:38Z
67.220.127.145
text/html
sha1:CNYKDJNGIUHD5FA6MJJUR26P3KCPIVM2
<urn:uuid:c5d95056-bac3-4469-8895-d99e294b62d2>
https://perldoc.koha-community.org/v3.02.00-alpha/C4/Koha.html
response
<urn:uuid:9278a321-a44f-446f-937e-f8e3f668ccf7>
isPartOf: CC-MAIN-2020-40
publisher: Common Crawl
description: Wide crawl of the web for September 2020
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-89.ec2.internal
software: Apache Nutch 1.17 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/