[Koha-patches] [PATCH] Bug 11736 - Use new DataTables include in Koha news templates

Owen Leonard oleonard at myacpl.org
Mon Feb 10 20:21:10 CET 2014


Bug 10649 introduced a new include file for adding DataTables-related
JavaScript assets. This patch adds use of this include file to the Koha
news page.

To test you should have existing news items with varying creation and
expiration dates. Apply the patch and confirm that table sorting works
correctly for all settings of the dateformat system preference.

C4::NewsChannels.pm has been modified so that it now passes an
unformatted date to the template, where the KohaDates plugin is used to
apply the correct formatting. Sorting is based on the unformatted date.

Also corrected: Capitalization errors.
---
 C4/NewsChannels.pm                                 |    2 --
 .../prog/en/modules/tools/koha-news.tt             |   17 +++++++++--------
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm
index 0201729..7c34239 100644
--- a/C4/NewsChannels.pm
+++ b/C4/NewsChannels.pm
@@ -116,8 +116,6 @@ sub get_opac_news {
     my $count = 0;
     while (my $row = $sth->fetchrow_hashref) {
         if ((($limit) && ($count < $limit)) || (!$limit)) {
-            $row->{'newdate'} = format_date($row->{'newdate'});
-            $row->{'expirationdate'} = format_date($row->{'expirationdate'});
             push @opac_news, $row;
         }
         $count++;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
index b92f63a..411ab1f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt
@@ -1,20 +1,21 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha › Tools › News</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
 [% IF ( opac_news_count ) %]
-    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/en/css/datatables.css" />
-    <script type="text/javascript" src="[% interface %]/[% theme %]/en/lib/jquery/plugins/jquery.dataTables.min.js"></script>
-    [% INCLUDE 'datatables-strings.inc' %]
-    <script type="text/javascript" src="[% interface %]/[% theme %]/en/js/datatables.js"></script>
+    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+    [% INCLUDE 'datatables.inc' %]
     <script type="text/javascript">//<![CDATA[
-    [% IF (dateformat == 'metric') %]dt_add_type_uk_date();[% END %]
     $(document).ready(function() {
         $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
             "sDom": 't',
             "aoColumnDefs": [
                 { "aTargets": [ 0,-1,-2 ], "bSortable": false, "bSearchable": false }
             ],
+            "aoColumns": [
+                null,null,null,{ "sType": "title-string" },{ "sType": "title-string" },null,null,null
+            ],
             "bPaginate": false
         }));
     });
@@ -52,7 +53,7 @@ tinyMCE.init({
 [% INCLUDE 'cat-search.inc' %]
 
 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › [% IF ( add_form ) %]<a href="/cgi-bin/koha/tools/koha-news.pl">News</a> › [% IF ( id ) %]
-Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
+Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
 
 [% IF ( add_form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
    <div id="bd">
@@ -165,8 +166,8 @@ Edit News Item[% ELSE %]Add News Item[% END %][% ELSE %]News[% END %]</div>
                              </td>
 
                             <td>[% opac_new.number %]</td>
-                            <td>[% opac_new.newdate %]</td>
-                            <td>[% opac_new.expirationdate %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</td>
+                            <td><span title="[% opac_new.newdate %]">[% opac_new.newdate | $KohaDates %]</span></td>
+                            <td><span title="[% opac_new.expirationdate %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</span></td>
                             <td>[% opac_new.title %]</td>
                            <td>
                                 [% opac_new.new %]
-- 
1.7.9.5


More information about the Koha-patches mailing list