Bug 22318: Example implementation: OpacNavRight system preference
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / koha-news.tt
index 074f875..3096ece 100644 (file)
@@ -1,76 +1,15 @@
+[% USE raw %]
+[% USE Asset %]
 [% USE KohaDates %]
 [% USE Branches %]
+[% SET footerjs = 1 %]
 [% 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 %]/css/datatables.css" />
-    [% INCLUDE 'datatables.inc' %]
-    <script type="text/javascript">//<![CDATA[
-    $(document).ready(function() {
-        $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
-            "aoColumnDefs": [
-                { "aTargets": [ 0,-1,-2 ], "bSortable": false },
-                { "aTargets": [ 0, -1 ], "bSearchable": false },
-                { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
-            ],
-            "sPaginationType": "full_numbers"
-        }));
-        $(".delete_news").on("click", function(){
-            return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
-        });
-
-        function Checkbox(){
-            var form = document.getElementById('del_form');
-            var inputs = form.getElementsByTagName('input');
-            var checked = false;
-            for (var i=0; i<inputs.length; i++) {
-                if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
-                    checked = inputs[i].checked;
-                    if (checked) return true;
-                }
-            }
-        }
-
-        $("#del_form").on("submit",function(){
-            if ( Checkbox() ) {
-                return confirmDelete( _("Are you sure you want to delete the selected news?") );
-            } else {
-                alert(_("Please select a news item to delete."));
-                return false;
-            }
-        });
-    });
-    //]]>
-    </script>
 [% END %]
-<script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
-<script type="text/javascript">//<![CDATA[
-tinyMCE.init({
-    mode : "textareas",
-    theme : "advanced",
-    convert_urls : false,
-    relative_urls : false,
-    content_css : "[% interface %]/[% theme %]/css/tinymce.css",
-    plugins : "table,save,advhr,advlink,searchreplace,print,contextmenu",
-    theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,search,replace,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,|,print",
-    theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
-    theme_advanced_buttons3 : "",
-    theme_advanced_toolbar_location : "top",
-    theme_advanced_toolbar_align : "left",
-    theme_advanced_path_location : "bottom",
-    theme_advanced_resizing : true,
-    plugin_insertdate_dateFormat : "%Y-%m-%d",
-    plugin_insertdate_timeFormat : "%H:%M:%S",
-    apply_source_formatting : true,
-    height : "300",
-    width : "700"
-//]]>
-});
-//]]>
-</script>
 </head>
+
 <body id="tools_koha-news" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -78,27 +17,36 @@ tinyMCE.init({
 <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>
 
-[% IF ( add_form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
-   <div id="bd">
-       <div id="yui-main">
-       <div class="yui-b">
+[% IF ( add_form ) %]
+    <div class="main container-fluid">
+        <div class="row">
+            <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
+[% ELSE %]
+    <div class="main container-fluid">
+        <div class="row">
+            <div class="col-sm-10 col-sm-push-2">
+[% END %]
+                <main>
 
 [% UNLESS ( add_form ) %]
     [% IF error_message == 'title_missing' %]
         <div class="dialog alert">Error: Required news title missing!</div>
     [% END %]
+<h2>News</h2>
 <div id="toolbar" class="btn-toolbar">
-    <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;lang=[% lang %]"><i class="fa fa-plus"></i> New entry</a>
+    <a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;lang=[% lang | html %]"><i class="fa fa-plus"></i> New entry</a>
 </div>
 [% END %]
 
 [% IF ( add_form ) %]
-    [% IF ( op == 'add' ) %][% default_lang = lang %]
-    [% ELSE %][% default_lang = new_detail.lang %]
+    [% IF ( op == 'add' ) %]
+        [% default_lang = lang %]
+    [% ELSE %]
+        [% default_lang = new_detail.lang %]
     [% END %]
         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
-            <input type="hidden" name="op" value="[% op %]" />
-            <input type="hidden" name="id" value="[% id %]" />
+            <input type="hidden" name="op" value="[% op | html %]" />
+            <input type="hidden" name="id" value="[% id | html %]" />
                        <fieldset class="rows">
             <legend>OPAC and Koha news</legend>
            <ol> <li>
@@ -120,11 +68,21 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
                 <option value="slip"                    >Slip</option>
                 [% END %]
                 [% FOREACH lang_lis IN lang_list %]
-                [% IF ( lang_lis.language == default_lang ) %]
-                    <option value="[% lang_lis.language %]" selected="selected">OPAC ([% lang_lis.language %])</option>
-                [% ELSE %]
-                    <option value="[% lang_lis.language %]"                    >OPAC ([% lang_lis.language %])</option>
-                [% END %]
+                    <optgroup label="[% lang_lis.language | html %]">
+                        [% FOREACH location IN [ '', 'OpacNavRight' ] %]
+                            [% IF ( location == '' ) %]
+                                [% SET location_lang = lang_lis.language %]
+                                [% SET location = "OPAC news" %]
+                            [% ELSE %]
+                                [% SET location_lang = location _ "_" _ lang_lis.language %]
+                            [% END %]
+                            [% IF ( location_lang == default_lang ) %]
+                                <option value="[% location_lang | html %]" selected="selected">[% location | html %] ([% lang_lis.language | html %])</option>
+                            [% ELSE %]
+                                <option value="[% location_lang | html %]">[% location | html %] ([% lang_lis.language | html %])</option>
+                            [% END %]
+                        [% END %]
+                    </optgroup>
                 [% END %]
             </select>
             </li>
@@ -141,28 +99,31 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
             </li>
             <li>
                 <label for="title" class="required">Title: </label>
-                <input id="title" size="30" type="text" name="title" value="[% new_detail.title %]" required="required" class="required" /> <span class="required">Required</span>
+                <input id="title" size="30" type="text" name="title" value="[% new_detail.title | html %]" required="required" class="required" /> <span class="required">Required</span>
             </li>
             <li>
                 <label for="from">Publication date: </label>
-                <input id="from" type="text" name="timestamp" size="15" value="[% new_detail.timestamp %]" class="datepickerfrom" />
+                <input id="from" type="text" name="timestamp" size="15" value="[% new_detail.timestamp | html %]" class="datepickerfrom" />
                                <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
             </li>
             <li>
                 <label for="to">Expiration date: </label>
-                <input id="to" type="text" name="expirationdate" size="15" value="[% new_detail.expirationdate %]" class="datepickerto" />
-                               <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+                <input id="to" type="text" name="expirationdate" size="15" value="[% new_detail.expirationdate | html %]" class="datepickerto" />
+                <div class="hint">
+                    [% INCLUDE 'date-format.inc' %]
+                    <br>News will still be accessible by direct URL if expired.
+                </div>
             </li>
             <li>
                 <label for="number">Appear in position: </label>
                 [% IF ( new_detail.number ) %]
-                    <input id="number" size="3" name="number" type="text" value="[% new_detail.number %]" />
+                    <input id="number" size="3" name="number" type="text" value="[% new_detail.number | html %]" />
                 [% ELSE %]
                     <input id="number" size="3" name="number" type="text" />
                 [% END %]
             </li>
-            <li><label for="new">News: </label>
-            <textarea name="new" id="new"  cols="75" rows="10">[% new_detail.new %]</textarea>
+            <li><label for="content">News: </label>
+            <textarea name="content" id="content"  cols="75" rows="10">[% new_detail.content | $raw %]</textarea>
             </li>
             </ol>
                        </fieldset>
@@ -191,9 +152,9 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
             [% END %]
                 [% FOREACH lang_lis IN lang_list %]
                 [% IF ( lang_lis.language == lang ) %]
-                    <option value="[% lang_lis.language %]" selected="selected">OPAC ([% lang_lis.language %])</option>
+                    <option value="[% lang_lis.language | html %]" selected="selected">OPAC ([% lang_lis.language | html %])</option>
                 [% ELSE %]
-                    <option value="[% lang_lis.language %]"         >OPAC ([% lang_lis.language %])</option>
+                    <option value="[% lang_lis.language | html %]"         >OPAC ([% lang_lis.language | html %])</option>
                 [% END %]
                 [% END %]
             </select>
@@ -231,7 +192,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
                             <tr>
                             [% END %]
                             <td>
-                                <input type="checkbox" name="ids" value="[% opac_new.idnew %]" />
+                                <input type="checkbox" name="ids" value="[% opac_new.idnew | html %]" />
                             </td>
                             <td>[% SWITCH opac_new.lang %]
                                 [%   CASE "koha" %]
@@ -241,24 +202,24 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
                                 [%   CASE "" %]
                                     All
                                 [%   CASE %]
-                                    OPAC ([% opac_new.lang %])
+                                    OPAC ([% opac_new.lang | html %])
                                 [% END %]
                              </td>
                             <td>[% IF ( opac_new.branchcode == "" ) -%]
                                 All libraries
-                                [% ELSE %][% opac_new.branchname %]
+                                [% ELSE %][% opac_new.branchname | html %]
                                 [% END %]</td>
-                            <td>[% opac_new.number %]</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.author_title %] [% opac_new.author_firstname %] [% opac_new.author_surname %]</td>
+                            <td>[% opac_new.number | html %]</td>
+                            <td><span title="[% opac_new.newdate | html %]">[% opac_new.newdate | $KohaDates %]</span></td>
+                            <td><span title="[% opac_new.expirationdate | html %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</span></td>
+                            <td>[% opac_new.title | html %]</td>
+                            <td>[% opac_new.author_title | html %] [% opac_new.author_firstname | html %] [% opac_new.author_surname | html %]</td>
                            <td>
-                                [% opac_new.new %]
+                                [% opac_new.content | $raw %]
                             </td>
                             <td class="actions">
-                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew %]" class="btn btn-mini"><i class="fa fa-pencil"></i> Edit</a>
-                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% opac_new.idnew %]" class="delete_news btn btn-mini"><i class="fa fa-trash"></i> Delete</a>
+                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&amp;id=[% opac_new.idnew | uri %]" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
+                                <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&amp;ids=[% opac_new.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
                             </td>
                         </tr>
                     [% END %]</tbody>
@@ -270,12 +231,85 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
             <div class="dialog message">There are no news items.</div>
         [% END %]
     [% END %]
-</div>
-</div>
-[% UNLESS ( add_form ) %]
-    <div class="yui-b noprint">
-        [% INCLUDE 'tools-menu.inc' %]
-    </div>
+
+                </main>
+            [% UNLESS ( add_form ) %]
+                </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+                <div class="col-sm-2 col-sm-pull-10">
+                    <aside>
+                        [% INCLUDE 'tools-menu.inc' %]
+                    </aside>
+                </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+            [% END %]
+        </div> <!-- /.row -->
+
+[% MACRO jsinclude BLOCK %]
+    [% INCLUDE 'calendar.inc' %]
+    [% Asset.js("js/tools-menu.js") | $raw %]
+    [% IF ( opac_news_count ) %]
+        [% INCLUDE 'datatables.inc' %]
+        <script>
+            $(document).ready(function() {
+                $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
+                    "aoColumnDefs": [
+                        { "aTargets": [ 0,-1,-2 ], "bSortable": false },
+                        { "aTargets": [ 0, -1 ], "bSearchable": false },
+                        { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
+                    ],
+                    "sPaginationType": "full_numbers"
+                }));
+                $(".delete_news").on("click", function(){
+                    return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
+                });
+
+                function Checkbox(){
+                    var form = document.getElementById('del_form');
+                    var inputs = form.getElementsByTagName('input');
+                    var checked = false;
+                    for (var i=0; i<inputs.length; i++) {
+                        if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
+                            checked = inputs[i].checked;
+                            if (checked) return true;
+                        }
+                    }
+                }
+
+                $("#del_form").on("submit",function(){
+                    if ( Checkbox() ) {
+                        return confirmDelete( _("Are you sure you want to delete the selected news?") );
+                    } else {
+                        alert(_("Please select a news item to delete."));
+                        return false;
+                    }
+                });
+            });
+        </script>
+    [% END %]
+    [% Asset.js("lib/tiny_mce/tiny_mce.js") | $raw %]
+    <script>
+        tinyMCE.baseURL = "[% interface | html %]/lib/tiny_mce";
+        tinyMCE.init({
+            mode : "textareas",
+            theme : "advanced",
+            convert_urls : false,
+            relative_urls : false,
+            content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
+            plugins : "table,save,advhr,advlink,searchreplace,print,contextmenu",
+            theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,search,replace,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,|,print",
+            theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
+            theme_advanced_buttons3 : "",
+            theme_advanced_toolbar_location : "top",
+            theme_advanced_toolbar_align : "left",
+            theme_advanced_path_location : "bottom",
+            theme_advanced_resizing : true,
+            plugin_insertdate_dateFormat : "%Y-%m-%d",
+            plugin_insertdate_timeFormat : "%H:%M:%S",
+            apply_source_formatting : true,
+            height : "300",
+            width : "700"
+        });
+    </script>
 [% END %]
-</div>
+
 [% INCLUDE 'intranet-bottom.inc' %]