added autocomplete="off"
[koha.git] / C4 / Koha.pm
index 2f94aa0..789f674 100644 (file)
@@ -2,6 +2,7 @@ package C4::Koha;
 
 # Copyright 2000-2002 Katipo Communications
 # Parts Copyright 2010 Nelsonville Public Library
+# Parts copyright 2010 BibLibre
 #
 # This file is part of Koha.
 #
@@ -57,8 +58,8 @@ BEGIN {
                &GetKohaAuthorisedValues
                &GetKohaAuthorisedValuesFromField
     &GetKohaAuthorisedValueLib
-      &GetAuthorisedValueByCode
-      &GetKohaImageurlFromAuthorisedValues
+    &GetAuthorisedValueByCode
+    &GetKohaImageurlFromAuthorisedValues
                &GetAuthValCode
                &GetNormalizedUPC
                &GetNormalizedISBN
@@ -572,9 +573,8 @@ sub getImageSets {
 
     my @imagesets = (); # list of hasrefs of image set data to pass to template
     my @subdirectories = _getSubdirectoryNames( $paths->{'staff'}{'filesystem'} );
-warn $paths->{'staff'}{'filesystem'};
     foreach my $imagesubdir ( @subdirectories ) {
-       warn $imagesubdir;
+    warn $imagesubdir if $DEBUG;
         my @imagelist     = (); # hashrefs of image info
         my @imagenames = _getImagesFromDirectory( File::Spec->catfile( $paths->{'staff'}{'filesystem'}, $imagesubdir ) );
         my $imagesetactive = 0;
@@ -957,9 +957,9 @@ sub GetKohaImageurlFromAuthorisedValues {
     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'};
-     }
+    while ( my $data = $sth->fetchrow_hashref ) {
+        return $data->{'imageurl'};
+    }
 }
 
 =head2 GetAuthValCode
@@ -1050,7 +1050,7 @@ sub GetAuthorisedValueCategories {
     my $sth = $dbh->prepare("SELECT DISTINCT category FROM authorised_values ORDER BY category");
     $sth->execute;
     my @results;
-    while (my $category = $sth->fetchrow_array) {
+    while (defined (my $category  = $sth->fetchrow_array) ) {
         push @results, $category;
     }
     return \@results;
@@ -1060,19 +1060,20 @@ sub GetAuthorisedValueCategories {
 
 $authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode );
 
-Return an hashref of the authorised value represented by $authvalcode.
+Return the lib attribute from authorised_values from the row identified
+by the passed category and code
 
 =cut
 
 sub GetAuthorisedValueByCode {
-       my ( $category, $authvalcode ) = @_;
-       
+    my ( $category, $authvalcode ) = @_;
+
     my $dbh = C4::Context->dbh;
     my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?");
     $sth->execute( $category, $authvalcode );
-     while ( my $data = $sth->fetchrow_hashref ) {
-       return $data->{'lib'};
-     }
+    while ( my $data = $sth->fetchrow_hashref ) {
+        return $data->{'lib'};
+    }
 }
 
 =head2 GetKohaAuthorisedValues
@@ -1201,21 +1202,22 @@ sub GetNormalizedUPC {
  my ($record,$marcflavour) = @_;
     my (@fields,$upc);
 
-    if ($marcflavour eq 'MARC21') {
-        @fields = $record->field('024');
+    if ($marcflavour eq 'UNIMARC') {
+        @fields = $record->field('072');
         foreach my $field (@fields) {
-            my $indicator = $field->indicator(1);
             my $upc = _normalize_match_point($field->subfield('a'));
-            if ($indicator == 1 and $upc ne '') {
+            if ($upc ne '') {
                 return $upc;
             }
         }
+
     }
-    else { # assume unimarc if not marc21
-        @fields = $record->field('072');
+    else { # assume marc21 if not unimarc
+        @fields = $record->field('024');
         foreach my $field (@fields) {
+            my $indicator = $field->indicator(1);
             my $upc = _normalize_match_point($field->subfield('a'));
-            if ($upc ne '') {
+            if ($indicator == 1 and $upc ne '') {
                 return $upc;
             }
         }
@@ -1235,10 +1237,10 @@ sub GetNormalizedISBN {
     }
     return undef unless $record;
 
-    if ($marcflavour eq 'MARC21') {
-        @fields = $record->field('020');
+    if ($marcflavour eq 'UNIMARC') {
+        @fields = $record->field('010');
         foreach my $field (@fields) {
-            $isbn = $field->subfield('a');
+            my $isbn = $field->subfield('a');
             if ($isbn) {
                 return _isbn_cleanup($isbn);
             } else {
@@ -1246,10 +1248,10 @@ sub GetNormalizedISBN {
             }
         }
     }
-    else { # assume unimarc if not marc21
-        @fields = $record->field('010');
+    else { # assume marc21 if not unimarc
+        @fields = $record->field('020');
         foreach my $field (@fields) {
-            my $isbn = $field->subfield('a');
+            $isbn = $field->subfield('a');
             if ($isbn) {
                 return _isbn_cleanup($isbn);
             } else {
@@ -1257,28 +1259,27 @@ sub GetNormalizedISBN {
             }
         }
     }
-
 }
 
 sub GetNormalizedEAN {
     my ($record,$marcflavour) = @_;
     my (@fields,$ean);
 
-    if ($marcflavour eq 'MARC21') {
-        @fields = $record->field('024');
+    if ($marcflavour eq 'UNIMARC') {
+        @fields = $record->field('073');
         foreach my $field (@fields) {
-            my $indicator = $field->indicator(1);
             $ean = _normalize_match_point($field->subfield('a'));
-            if ($indicator == 3 and $ean ne '') {
+            if ($ean ne '') {
                 return $ean;
             }
         }
     }
-    else { # assume unimarc if not marc21
-        @fields = $record->field('073');
+    else { # assume marc21 if not unimarc
+        @fields = $record->field('024');
         foreach my $field (@fields) {
+            my $indicator = $field->indicator(1);
             $ean = _normalize_match_point($field->subfield('a'));
-            if ($ean ne '') {
+            if ($indicator == 3 and $ean ne '') {
                 return $ean;
             }
         }
@@ -1288,7 +1289,10 @@ sub GetNormalizedOCLCNumber {
     my ($record,$marcflavour) = @_;
     my (@fields,$oclc);
 
-    if ($marcflavour eq 'MARC21') {
+    if ($marcflavour eq 'UNIMARC') {
+        # TODO: add UNIMARC fields
+    }
+    else { # assume marc21 if not unimarc
         @fields = $record->field('035');
         foreach my $field (@fields) {
             $oclc = $field->subfield('a');
@@ -1300,8 +1304,6 @@ sub GetNormalizedOCLCNumber {
             }
         }
     }
-    else { # TODO: add UNIMARC fields
-    }
 }
 
 sub _normalize_match_point {