-=head2 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' => 'utf8',
- 'icon' => undef,
- 'id' => 'LIBRARY OF CONGRESS',
- 'label' => '',
- 'name' => 'server',
- 'opensearch' => '',
- 'value' => 'lx2.loc.gov:210/',
- 'zed' => 1,
- },
-
-=cut
-
-sub displayServers {
- my ( $position, $type ) = @_;
- my $dbh = C4::Context->dbh;
-
- my $strsth = 'SELECT * FROM z3950servers';
- my @where_clauses;
- my @bind_params;
-
- if ($position) {
- push @bind_params, $position;
- push @where_clauses, ' position = ? ';
- }
-
- if ($type) {
- push @bind_params, $type;
- push @where_clauses, ' type = ? ';
- }
-
- # reassemble where clause from where clause pieces
- if (@where_clauses) {
- $strsth .= ' WHERE ' . join( ' AND ', @where_clauses );
- }
-
- my $rq = $dbh->prepare($strsth);
- $rq->execute(@bind_params);
- my @primaryserverloop;
-
- while ( my $data = $rq->fetchrow_hashref ) {
- push @primaryserverloop,
- { label => $data->{description},
- id => $data->{name},
- name => "server",
- value => $data->{host} . ":" . $data->{port} . "/" . $data->{database},
- encoding => ( $data->{encoding} ? $data->{encoding} : "iso-5426" ),
- checked => "checked",
- icon => $data->{icon},
- zed => $data->{type} eq 'zed',
- opensearch => $data->{type} eq 'opensearch'
- };
- }
- return \@primaryserverloop;
-}
-
-
-=head2 GetKohaImageurlFromAuthorisedValues
-
-$authhorised_value = GetKohaImageurlFromAuthorisedValues( $category, $authvalcode );
-
-Return the first url of the authorised value image represented by $lib.
-
-=cut
-
-sub GetKohaImageurlFromAuthorisedValues {
- my ( $category, $lib ) = @_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("SELECT imageurl FROM authorised_values WHERE category=? AND lib =?");
- $sth->execute( $category, $lib );
- while ( my $data = $sth->fetchrow_hashref ) {
- return $data->{'imageurl'};
- }
-}
-