From 4050a5a0fc6b1eeb6ea281b69d854033b66c9856 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Mon, 10 Feb 2014 14:13:11 -0500
Subject: [PATCH] [PASSED QA] Bug 11736 - Use new DataTables include in Koha
 news templates

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.

Signed-off-by: wajasu <matted-34813@mypacks.net>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, no problems found.
Also passes tests and QA script.
---
 C4/NewsChannels.pm                                      |  2 --
 .../intranet-tmpl/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 &rsaquo; Tools &rsaquo; 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> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( add_form ) %]<a href="/cgi-bin/koha/tools/koha-news.pl">News</a> &rsaquo; [% 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.8.3.2