Bug 25626: Fix untranslatable strings on the 'OPAC problem reports' admin
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / koha-news.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Branches %]
6 [% SET footerjs = 1 %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Tools &rsaquo; News</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% IF ( opac_news_count ) %]
11 [% END %]
12 [% IF Koha.Preference('NewsToolEditor') == 'codemirror' %]
13     [% Asset.css("lib/codemirror/codemirror.css") | $raw %]
14     [% Asset.css("lib/codemirror/lint.min.css") | $raw %]
15     <style>
16         .CodeMirror {
17             resize: vertical;
18             z-index: 0;
19         }
20     </style>
21 [% END %]
22 </head>
23
24 <body id="tools_koha-news" class="tools">
25 [% INCLUDE 'header.inc' %]
26 [% INCLUDE 'cat-search.inc' %]
27
28 <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 ) %]
29 Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div>
30
31 [% IF ( add_form ) %]
32     <div class="main container-fluid">
33         <div class="row">
34             <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
35 [% ELSE %]
36     <div class="main container-fluid">
37         <div class="row">
38             <div class="col-sm-10 col-sm-push-2">
39 [% END %]
40                 <main>
41
42 [% UNLESS ( add_form ) %]
43     [% IF error_message == 'title_missing' %]
44         <div class="dialog alert">Error: Required news title missing!</div>
45     [% END %]
46 <h2>News</h2>
47 <div id="toolbar" class="btn-toolbar">
48     <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>
49 </div>
50 [% END %]
51
52 [% IF ( add_form ) %]
53     [% IF ( op == 'add' ) %]
54         [% default_lang = lang %]
55     [% ELSE %]
56         [% default_lang = new_detail.lang %]
57     [% END %]
58         <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" >
59             <input type="hidden" name="op" value="[% op | html %]" />
60             <input type="hidden" name="id" value="[% id | html %]" />
61                         <fieldset class="rows">
62             <legend>OPAC and Koha news</legend>
63            <ol> <li>
64             <label for="lang">Display location:</label>
65             <select id="lang" name="lang">
66                 [% PROCESS lang_locations language => default_lang %]
67             </select>
68             </li>
69             <li>
70                 <label for="branch">Library: </label>
71                 <select id="branch" name="branch">
72                     [% IF ( new_detail.branchcode == '' ) %]
73                         <option value="" selected="selected">All libraries</option>
74                     [% ELSE %]
75                         <option value=""         >All libraries</option>
76                     [% END %]
77                     [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %]
78                 </select>
79             </li>
80             <li>
81                 <label for="title" class="required">Title: </label>
82                 <input id="title" size="30" type="text" name="title" value="[% new_detail.title | html %]" required="required" class="required" /> <span class="required">Required</span>
83             </li>
84             <li>
85                 <label for="from">Publication date: </label>
86                 <input id="from" type="text" name="timestamp" size="15" value="[% new_detail.timestamp | html %]" class="datepickerfrom" />
87                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
88             </li>
89             <li>
90                 <label for="to">Expiration date: </label>
91                 <input id="to" type="text" name="expirationdate" size="15" value="[% new_detail.expirationdate | html %]" class="datepickerto" />
92                 <div class="hint">
93                     [% INCLUDE 'date-format.inc' %]
94                     <br>News will still be accessible by direct URL if expired.
95                 </div>
96             </li>
97             <li>
98                 <label for="number">Appear in position: </label>
99                 [% IF ( new_detail.number ) %]
100                     <input id="number" size="3" name="number" type="text" value="[% new_detail.number | html %]" />
101                 [% ELSE %]
102                     <input id="number" size="3" name="number" type="text" />
103                 [% END %]
104             </li>
105             <li><label for="content">News: </label>
106             <textarea name="content" id="content"  cols="75" rows="10">[% new_detail.content | $raw %]</textarea>
107             </li>
108             </ol>
109                         </fieldset>
110   
111                 <fieldset class="action"><input class="button" type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/tools/koha-news.pl">Cancel</a></fieldset>
112         </form>
113     [% ELSE %]
114         [% IF ( opac_news_count ) %]
115         <form id="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl">
116                 <table id="newst">
117                    <thead> <tr>
118                         <th class="NoSort">&nbsp;</th>
119                         <th>Location</th>
120                         <th>Library</th>
121                         <th>Number</th>
122                         <th class="title-string">Publication date</th>
123                         <th class="title-string">Expiration date</th>
124                         <th class="anti-the">Title</th>
125                         <th>Author</th>
126                         <th class="anti-the">News</th>
127                         <th class="NoSort">Actions</th>
128                     </tr></thead>
129                     <tbody>[% FOREACH opac_new IN opac_news %]
130                          [% IF ( opac_new.expired ) %]
131                             <tr class="expired">
132                             [% ELSE %]
133                             <tr>
134                             [% END %]
135                             <td>
136                                 <input type="checkbox" name="ids" value="[% opac_new.idnew | html %]" />
137                             </td>
138                             <td>[% SWITCH opac_new.lang %]
139                                 [%   CASE "koha" %]
140                                     Librarian interface
141                                 [%   CASE "slip" %]
142                                     Slip
143                                 [%   CASE "" %]
144                                     All
145                                 [%   CASE %]
146                                     OPAC ([% opac_new.lang | html %])
147                                 [% END %]
148                              </td>
149                             <td>[% IF ( opac_new.branchcode == "" ) -%]
150                                 All libraries
151                                 [% ELSE %][% opac_new.branchname | html %]
152                                 [% END %]</td>
153                             <td>[% opac_new.number | html %]</td>
154                             <td><span title="[% opac_new.newdate | html %]">[% opac_new.newdate | $KohaDates %]</span></td>
155                             <td><span title="[% opac_new.expirationdate | html %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</span></td>
156                             <td>[% opac_new.title | html %]</td>
157                             <td>[% opac_new.author_title | html %] [% opac_new.author_firstname | html %] [% opac_new.author_surname | html %]</td>
158                            <td>
159                                 [% opac_new.content | $raw %]
160                             </td>
161                             <td class="actions">
162                                 <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>
163                                 <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>
164                             </td>
165                         </tr>
166                     [% END %]</tbody>
167                 </table>
168                 <input type="hidden" name="op" value="del" />
169                 <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
170             </form>
171         [% ELSE %]
172             <div class="dialog message">There are no news items.</div>
173         [% END %]
174     [% END %]
175
176                 </main>
177             [% UNLESS ( add_form ) %]
178                 </div> <!-- /.col-sm-10.col-sm-push-2 -->
179
180                 <div class="col-sm-2 col-sm-pull-10">
181                     <aside>
182
183                         <div id="news-filter">
184                             <form action="/cgi-bin/koha/tools/koha-news.pl" method="get">
185                                 <h4>Filter</h4>
186                                 <fieldset class="brief">
187                                     <ol>
188                                         <li>
189                                             <label for="news_keyword">Keyword:</label>
190                                             <input type="text" name="news_keyword" id="news_keyword" />
191                                         </li>
192                                         <li>
193                                             <label for="news_display_location">Display location:</label>
194                                             <select name="news_display_location" id="news_display_location">
195                                                 [% PROCESS lang_locations %]
196                                             </select>
197                                         </li>
198                                         <li>
199                                             <label for="news_library">Library: </label>
200                                             <select id="news_library" name="news_library">
201                                                 <option value=""></option>
202                                                 <option value="">All libraries</option>
203                                                 [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
204                                             </select>
205                                         </li>
206                                     </ol>
207                                 </fieldset>
208                             </form>
209                         </div>
210
211                         [% INCLUDE 'tools-menu.inc' %]
212                     </aside>
213                 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
214             [% END %]
215         </div> <!-- /.row -->
216     </div> <!-- /.main.container-fluid -->
217
218
219 [% MACRO jsinclude BLOCK %]
220     [% INCLUDE 'calendar.inc' %]
221     [% Asset.js("js/tools-menu.js") | $raw %]
222     [% IF ( opac_news_count ) %]
223         [% INCLUDE 'datatables.inc' %]
224         <script>
225             function Checkbox(){
226                 var form = document.getElementById('del_form');
227                 var inputs = form.getElementsByTagName('input');
228                 var checked = false;
229                 for (var i=0; i<inputs.length; i++) {
230                     if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') {
231                         checked = inputs[i].checked;
232                         if (checked) return true;
233                     }
234                 }
235             }
236
237             function filterDataTable( table, column, term ){
238                 if( column ){
239                     table.column( column ).search( term ).draw();
240                 } else {
241                     table.search( term ).draw();
242                 }
243                 clearFilter( term );
244             }
245
246             function clearFilter( term ){
247                 if( term == "" ){
248                     $(".dt_button_clear_filter").addClass("disabled");
249                 } else {
250                     $(".dt_button_clear_filter").removeClass("disabled");
251                 }
252             }
253
254             $(document).ready(function() {
255                 var newst = $("#newst").DataTable($.extend(true, {}, dataTablesDefaults, {
256                     "order": [[ 4, "desc" ]],
257                     "aoColumnDefs": [
258                         { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] },
259                         { "type": "anti-the", "targets": [ "anti-the" ] },
260                         { "type": "title-string", "targets" : [ "title-string"] }
261                     ],
262                     "sPaginationType": "full_numbers"
263                 }));
264
265                 $(".delete_news").on("click", function(){
266                     return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") );
267                 });
268
269                 $("#del_form").on("submit",function(){
270                     if ( Checkbox() ) {
271                         return confirmDelete( _("Are you sure you want to delete the selected news?") );
272                     } else {
273                         alert(_("Please select a news item to delete."));
274                         return false;
275                     }
276                 });
277
278                 newst.on( 'search.dt', function () {
279                     var term = newst.search();
280                     $("#news_keyword").val( term );
281                 });
282
283                 $("#news_keyword").on("keyup", function(){
284                     var term = $(this).val();
285                     filterDataTable( newst, null, term );
286                 });
287
288                 $("#news_display_location").on("change", function(){
289                     var term = $(this).val();
290                     filterDataTable( newst, 1, term );
291                 });
292
293                 $("#news_library").on("change", function(){
294                     // Table must be filtered by the <option>'s text, not its value
295                     var opt = $(this).find("option:selected").text();
296                     filterDataTable( newst, 2, opt );
297                 });
298
299                 $(".dt_button_clear_filter").on("click", function(){
300                     newst.search('').columns().search('').draw();
301                     $("#news-filter select").each(function(){
302                         $(this).val("");
303                     });
304                 });
305             });
306         </script>
307     [% END %]
308     [% IF Koha.Preference('NewsToolEditor') == 'codemirror' %]
309         [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
310         [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
311         [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
312         [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
313         [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
314         <script>
315             var editor = CodeMirror.fromTextArea(document.getElementById('content'), {
316                 lineNumbers: true,
317                 lineWrapping: true,
318                 lint: true,
319                 mode: "text/html",
320                 gutters: ["CodeMirror-lint-markers"],
321                 viewportMargin: Infinity,
322             });
323         </script>
324     [% ELSE %]
325         [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
326         [% INCLUDE 'str/tinymce_i18n.inc' %]
327         <script>
328             tinyMCE.init({
329                 verify_html: false,
330                 force_br_newlines : false,
331                 force_p_newlines : false,
332                 forced_root_block : '',
333                 branding : false,
334                 relative_urls : false,
335                 content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
336                 menubar : "file edit view insert format tools table",
337                 mode : "specific_textareas",
338                 plugins : "autoresize table hr link image charmap lists code emoticons",
339                 toolbar : [
340                     "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
341                     "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code visualaid help"
342                 ],
343             });
344         </script>
345     [% END # /IF NewsToolEditor %]
346 [% END %]
347
348 [% BLOCK lang_locations %]
349     [% IF ( language == "" ) %]
350         <option value="" selected="selected"></option>
351     [% ELSE %]
352         <option value="">All</option>
353     [% END %]
354     [% IF ( language == "koha" ) %]
355         <option value="koha" selected="selected">Librarian interface</option>
356     [% ELSE %]
357         <option value="koha">Librarian interface</option>
358     [% END %]
359     [% IF ( language == "slip" ) %]
360         <option value="slip" selected="selected">Slip</option>
361     [% ELSE %]
362         <option value="slip">Slip</option>
363     [% END %]
364     [% FOREACH lang_lis IN lang_list %]
365         <optgroup label="[% lang_lis.language | html %]">
366             [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions'] %]
367                 [% IF ( location == '' ) %]
368                     [% SET location_lang = lang_lis.language %]
369                     [% location = BLOCK %]OPAC news[% END %]
370                 [% ELSE %]
371                     [% SET location_lang = location _ "_" _ lang_lis.language %]
372                 [% END %]
373                 [% IF ( location_lang == language ) %]
374                     <option value="[% location_lang | html %]" selected="selected">[% location | html %] ([% lang_lis.language | html %])</option>
375                 [% ELSE %]
376                     <option value="[% location_lang | html %]">[% location | html %] ([% lang_lis.language | html %])</option>
377                 [% END %]
378             [% END %]
379         </optgroup>
380     [% END %]
381 [% END %]
382
383 [% INCLUDE 'intranet-bottom.inc' %]