Bug 14544: Get rid of C4::VirtualShelves and C4::VirtualShelves::Page
[koha.git] / virtualshelves / downloadshelf.pl
index 156e261..5a00694 100755 (executable)
@@ -27,7 +27,6 @@ use C4::Auth;
 use C4::Biblio;
 use C4::Items;
 use C4::Output;
-use C4::VirtualShelves;
 use C4::Record;
 use C4::Ris;
 use C4::Csv;
@@ -54,7 +53,6 @@ my @messages;
 
 if ($shelfid && $format) {
 
-    my ($items, $totitems)  = GetShelfContents($shelfid);
     my $marcflavour         = C4::Context->preference('marcflavour');
     my $output='';
 
@@ -62,17 +60,18 @@ if ($shelfid && $format) {
     if ( $shelf ) {
         if ( $shelf->can_be_viewed( $loggedinuser ) ) {
 
+            my $contents = $shelf->get_contents;
             # CSV
             if ($format =~ /^\d+$/) {
                 my @biblios;
-                foreach (@$items) {
-                    push @biblios, $_->{biblionumber};
+                while ( my $content = $contents->next ) {
+                    push @biblios, $content->biblionumber->biblionumber;
                 }
                 $output = marc2csv(\@biblios, $format);
             }
             else { #Other formats
-                foreach my $biblio (@$items) {
-                    my $biblionumber = $biblio->{biblionumber};
+                while ( my $content = $contents->next ) {
+                    my $biblionumber = $content->biblionumber->biblionumber;
                     my $record = GetMarcBiblio($biblionumber, 1);
                     if ($format eq 'iso2709') {
                         $output .= $record->as_usmarc();