[Koha-bugs] [Bug 17385] Add custom export formats for bibliographic records

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jan 9 14:46:29 CET 2020


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17385

--- Comment #45 from Gabriel DeCarufel <gabriel.decarufel at inlibro.com> ---
Comment on attachment 97076
  --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=97076
Bug 17385: QA ctrics fixed

>From 95634bc8acc5fac9fcb44dca40d0c458aec2ae26 Mon Sep 17 00:00:00 2001
>From: Gabriel DeCarufel <gabriel at inlibro.com>
>Date: Wed, 8 Jan 2020 16:23:14 -0500
>Subject: [PATCH] Bug 17385: QA critics fixed
>
>---
> C4/XSLT.pm                                    | 12 +++++++++---
> .../prog/en/includes/cat-toolbar.inc          |  2 +-
> .../en/includes/virtualshelves-toolbar.inc    |  2 +-
> .../prog/en/modules/basket/basket.tt          |  2 +-
> .../prog/en/modules/catalogue/detail.tt       |  2 +-
> .../modules/virtualshelves/downloadshelf.tt   |  2 +-
> .../en/includes/opac-detail-sidebar.inc       |  2 +-
> .../bootstrap/en/modules/opac-downloadcart.tt |  2 +-
> .../en/modules/opac-downloadshelf.tt          |  2 +-
> t/db_dependent/XSLT.t                         | 19 ++-----------------
> 10 files changed, 19 insertions(+), 28 deletions(-)
>
>diff --git a/C4/XSLT.pm b/C4/XSLT.pm
>index 798c66e6ee..d74b3404c8 100644
>--- a/C4/XSLT.pm
>+++ b/C4/XSLT.pm
>@@ -163,6 +163,11 @@ sub _get_best_default_xslt_filename {
>     }
>     return $xslfilename;
> }
>+=head2 get_xslt_sysprefs
>+
>+    returns XML xslt sysprefs
>+
>+=cut
> 
> sub get_xslt_sysprefs {
>     my $sysxml = "<sysprefs>\n";
>@@ -263,7 +268,7 @@ sub XSLTParse4Display {
>     my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
>     my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
> 
>-    $variables ||= {};
>+    my $variables ||= {};
>     if (C4::Context->preference('OPACShowOpenURL')) {
>         my @biblio_itemtypes;
>         my $biblio = Koha::Biblios->find($biblionumber);
>@@ -416,7 +421,7 @@ sub CustomXSLTExportList {
>                       '/' . C4::Context->preference( $opac ? "opacthemes" : "template") .
>                       '/' . C4::Languages::getlanguage() .
>                       '/xslt/biblioexport';
>-    my @files = <$dir/*.xsl>;
>+    my @files = glob qq("$dir/*.xsl");
>     foreach my $file (@files) {
>         if ( -f "$file" ) {
>             (my $text = $file) =~ s/.*\///g;
>@@ -433,7 +438,8 @@ sub CustomXSLTExportList {
>             # Get output format
>             # There should only be one xsl:output node, so taking the first one only is OK
>             $node = @{$node->findnodes("xsl:output")}[0];
>-            my $outputformat = $node->{"method"} if $node;
>+            my $outputformat= "";
>+            $outputformat = $node->{"method"} if $node;
>             $outputformat = "txt" if ($outputformat eq "" || $outputformat eq "text");
> 
>             my %row = (
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
>index 39bd7c95e5..ce0a0da854 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
>+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
>@@ -97,7 +97,7 @@ CAN_user_serials_create_subscription ) %]
>         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=mods&op=export&bib=[% biblionumber | uri %]">MODS (XML)</a></li>
>         <li><a href="/cgi-bin/koha/catalogue/export.pl?format=ris&op=export&bib=[% biblionumber | uri %]">RIS</a></li>
>         [% FOREACH filesOption IN filesOptions %]
>-            <li><a href="/cgi-bin/koha/catalogue/export.pl?format=[% filesOption.format %]&op=exportxsl&file=[% filesOption.value %]&bib=[% biblionumber | html %]">[% filesOption.filename %]</a></li>
>+            <li><a href="/cgi-bin/koha/catalogue/export.pl?format=[% filesOption.format | uri %]&op=exportxsl&file=[% filesOption.value | uri %]&bib=[% biblionumber | uri %]">[% filesOption.filename | html %]</a></li>
>         [% END %]
>     </ul>
>     </div>
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc
>index 6c5bd3db77..c241f343f3 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc
>+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc
>@@ -32,7 +32,7 @@
>                         <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=[% csv_profile.export_format_id | uri %]&shelfid=[% shelf.shelfnumber | uri %]">CSV - [% csv_profile.profile | html %]</a></li>
>                     [% END %]
>                     [% FOREACH xsl_export IN xsl_exports %]
>-                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value %]&shelfid=[% shelf.shelfnumber %]">XSL - [% xsl_export.filename %]</a></li>
>+                        <li><a href="/cgi-bin/koha/virtualshelves/downloadshelf.pl?format=xsl.[% xsl_export.value | uri %]&shelfid=[% shelf.shelfnumber | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
>                     [% END %]
>                 </ul>
>         </div>
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt
>index 9c388ba1bc..ce428c396e 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/basket/basket.tt
>@@ -57,7 +57,7 @@
>                                 <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=[% csv_profile.export_format_id | uri %]&bib_list=[% bib_list | uri %]">CSV - [% csv_profile.profile | html %]</a></li>
>                             [% END %]
>                             [% FOREACH xsl_export IN xsl_exports %]
>-                                <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value %]&bib_list=[% bib_list %]">XSL - [% xsl_export.filename %]</a></li>
>+                                <li><a href="/cgi-bin/koha/basket/downloadcart.pl?format=xsl.[% xsl_export.value | uri %]&bib_list=[% bib_list | uri %]">XSL - [% xsl_export.filename | html %]</a></li>
>                             [% END %]
>                             </ul>
>                         </div>
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
>index 53bcf6c872..b04aa504e1 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
>@@ -754,7 +754,7 @@
> 
>         <option value="utf8">MARC (Unicode/UTF-8)</option>
>         [% FOREACH filesOption IN filesOptions %]
>-            <option value="[% filesOption.value %]">[% filesOption.filename %]</option>
>+            <option value="[% filesOption.value | html %]">[% filesOption.filename | html %]</option>
>         [% END %]</select>
>         <input type="submit" name="save" value="Download Record" /></td>
>   </tr>
>diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt
>index 740fe5d1f0..772ac50ab8 100644
>--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt
>+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/downloadshelf.tt
>@@ -37,7 +37,7 @@
> 	    <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
> 	    [% END %]
>         [% FOREACH xsl_export IN xsl_exports %]
>-            <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</option>
>+            <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
>         [% END %]
> 	</select>
> 	</li></ol>
>diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
>index 4e1ae642c1..7d07e07ed8 100644
>--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
>+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc
>@@ -80,7 +80,7 @@
>                                 </li>
>                                 [% ELSE %]
>                                     [% FOREACH filesOption IN filesOptions %]
>-                                        <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format %]&op=exportxsl&file=[% filesOption.value %]&bib=[% biblionumber %]">[% filesOption.filename %]</a></li>
>+                                        <li><a role="menuitem" href="/cgi-bin/koha/opac-export.pl?format=[% filesOption.format | html %]&op=exportxsl&file=[% filesOption.value | html %]&bib=[% biblionumber | html %]">[% filesOption.filename | html %]</a></li>
>                                     [% END %]
>                                 [% END %]
>                             [% END %]
>diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt
>index 70c3beb1a3..2bd1215ebc 100644
>--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt
>+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadcart.tt
>@@ -21,7 +21,7 @@
>                                     <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
>                                 [% END %]
>                                 [% FOREACH xsl_export IN xsl_exports %]
>-                                    <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</option>
>+                                    <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
>                                 [% END %]
>                             </select>
>                             <fieldset class="action">
>diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt
>index 4881ea7aa9..411168ea29 100644
>--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt
>+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-downloadshelf.tt
>@@ -60,7 +60,7 @@
>                                             <option value="[% csv_profile.export_format_id | html %]">CSV - [% csv_profile.profile | html %]</option>
>                                             [% END %]
>                                             [% FOREACH xsl_export IN xsl_exports %]
>-                                                <option value="xsl.[% xsl_export.value %]">XSL - [% xsl_export.filename %]</option>
>+                                                <option value="xsl.[% xsl_export.value | html %]">XSL - [% xsl_export.filename | html %]</option>
>                                             [% END %]
>                                         </select>
>                                         <span class="required">Required</span>
>diff --git a/t/db_dependent/XSLT.t b/t/db_dependent/XSLT.t
>index 968f7db8ad..3a69b66aab 100644
>--- a/t/db_dependent/XSLT.t
>+++ b/t/db_dependent/XSLT.t
>@@ -1,13 +1,11 @@
> use Modern::Perl;
>-use Test::More tests => 2;
>+use Test::More tests => 1;
> 
> use t::lib::Mocks;
> use C4::XSLT;
>-use Koha::Caches;
> use Koha::Database;
> 
> our $schema = Koha::Database->new->schema;
>-our $cache = Koha::Caches->get_instance;
> 
> # Here we go
> $schema->storage->txn_begin;
>@@ -22,17 +20,4 @@ subtest 'CustomXSLTExportList: Check export options' => sub {
>     $list = C4::XSLT::CustomXSLTExportList(1);
>     is( @$list, 0, 'We expect an empty list now' );
> };
>-
>-subtest  'CustomXSLTExportList: Caching' => sub {
>-    plan tests => 1;
>-    t::lib::Mocks::mock_preference('OpacExportOptions', 'custom');
>-    $cache->clear_from_cache('CustomXSLTExportListOPAC');
>-    my $list = C4::XSLT::CustomXSLTExportList(1);
>-    push @$list, { nonsense => 1 };
>-    $cache->set_in_cache( 'CustomXSLTExportListOPAC', $list );
>-    my $n = @$list;
>-    $list = C4::XSLT::CustomXSLTExportList(1);
>-    is( @$list, $n, 'This list comes from the cache and that is fine' );
>-    $cache->clear_from_cache('CustomXSLTExportListOPAC');
>-};
>-$schema->storage->txn_rollback;
>+$schema->storage->txn_rollback;
>\ No newline at end of file
>-- 
>2.17.1

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list