Koha/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt
Lucas Gass 2544210395 Bug 24220: Move OpacMoreSearches to HTML customizations in additional-contents
To test:
1- Before applying the patch add some content to the system preference
   OpacMoreSearches
2- Apply patch
3- restart_all and updatedatabase
4. Go to additional-content.pl ( HTML customizations )
5. You should now see your content from the system preference under
   OpacMoreSearches in HTML customizations
6. Try searching for the system preference, OpacMoreSeaches. It has been
   removed and you should not be able to find it.
7. Try changing/removing/adding content from OpacMoreSearches in HTML
   customizations
8. Make sure your edits are reflected when you look at the
   OpacMoreSearch area in the OPAC.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2022-01-31 21:55:40 -10:00

626 lines
28 KiB
Text

[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
[% USE Branches %]
[% SET footerjs = 1 %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Additional contents &rsaquo; Tools &rsaquo; Koha</title>
[% INCLUDE 'doc-head-close.inc' %]
[% IF ( wysiwyg ) %]
[% SET editmode = "wysiwyg" %]
[% ELSE %]
[% SET editmode = "text" %]
[% Asset.css("lib/codemirror/codemirror.css") | $raw %]
[% Asset.css("lib/codemirror/lint.min.css") | $raw %]
<style>
.CodeMirror {
resize: vertical;
z-index: 0;
}
</style>
[% END %]
</head>
<body id="tools_additional-contents" class="tools">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'cat-search.inc' %]
<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
<ol>
<li>
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
</li>
<li>
<a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a>
</li>
[% IF op == 'add_form' %]
<li>
[% IF category == 'news' %]
<a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a>
[% ELSE %]
<a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a>
[% END %]
</li>
<li>
<a href="#" aria-current="page">
[% IF additional_content.idnew %]
<span>Modify additional content<span>
[% ELSE %]
<span>Add additional content<span>
[% END %]
([% IF category == 'news' %]<span>News</span>[% ELSE %]<span>HTML customizations</span>[% END %])
</a>
</li>
[% ELSE %]
<li>
<a href="#" aria-current="page">
[% IF category == 'news' %]
News
[% ELSE %]
HTML customizations
[% END %]
</a>
</li>
[% END %]
</ol>
</nav>
[% IF op == '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>
[% FOR m IN messages %]
<div class="dialog [% m.type | html %]">
[% SWITCH m.code %]
[% CASE 'error_on_update' %]
An error occurred when updating this content. Perhaps it already exists.
[% CASE 'error_on_insert' %]
An error occurred when adding this content. Check the logs
[% CASE 'error_on_delete' %]
An error occurred when deleting this content. Check the logs.
[% CASE 'success_on_update' %]
Content updated successfully.
[% CASE 'success_on_insert' %]
Content added successfully.
[% CASE 'success_on_delete' %]
Content deleted successfully.
[% CASE %]
[% m.code | html %]
[% END %]
</div>
[% END %]
[% IF op == 'add_form' %]
[% PROCESS add_form %]
[% ELSE %]
[% PROCESS list %]
[% END %]
</main>
[% IF op != 'add_form' %]
</div> <!-- /.col-sm-10.col-sm-push-2 -->
<div class="col-sm-2 col-sm-pull-10">
<aside>
<div id="news-filter">
<form action="/cgi-bin/koha/tools/additional-contents.pl" method="get">
<h4>Filter</h4>
<fieldset class="brief">
<ol>
<li>
<label for="news_keyword">Keyword:</label>
<input type="text" name="news_keyword" id="news_keyword" />
</li>
<li>
<label for="news_display_location">Display location:</label>
<select name="news_display_location" id="news_display_location">
<option value="">All</option>
[% PROCESS locations_options category => category %]
</select>
</li>
<li>
<label for="news_library">Library: </label>
<select id="news_library" name="news_library">
<option value=""></option>
<option value="">All libraries</option>
[% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %]
</select>
</li>
<li>
<label>
<input type="checkbox" name="show_expired" id="show_expired" /> Show expired
</label>
</li>
</ol>
</fieldset>
</form>
</div>
[% INCLUDE 'tools-menu.inc' %]
</aside>
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
[% END %]
</div> <!-- /.row -->
</div> <!-- /.main.container-fluid -->
[% BLOCK add_form %]
[% IF additional_content %]
<h1>Modify an additional content</h1>
[% ELSE %]
<h1>New additional content ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])</h1>
[% END %]
<div id="toolbar" class="btn-toolbar">
<div class="btn-group">
<button class="btn btn-default" id="submit_form"><i class="fa fa-save"></i> Save</button>
</div>
[% IF category == 'news' %]
<a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl"><i class="fa fa-remove"></i> Cancel</a>
[% ELSE %]
<a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations"><i class="fa fa-remove"></i> Cancel</a>
[% END %]
</div>
<form id="add_additional_content" method="post" action="/cgi-bin/koha/tools/additional-contents.pl" class="validate">
<input type="hidden" name="op" value="add_validate" />
<input type="hidden" name="category" value="[% category | html %]" />
<input type="hidden" name="code" value="[% additional_content.code | html %]" />
<fieldset class="rows">
<ol>
<li>
<label for="location">Display location:</label>
<select id="location" name="location">
[% PROCESS locations_options location => additional_content.location %]
</select>
</li>
<li>
<label for="branchcode">Library: </label>
<select id="branchcode" name="branchcode">
[% IF additional_content.branchcode == '' %]
<option value="" selected="selected">All libraries</option>
[% ELSE %]
<option value="">All libraries</option>
[% END %]
[% PROCESS options_for_libraries libraries => Branches.all( selected => additional_content.branchcode, unfiltered => 1, ) %]
</select>
</li>
[% UNLESS languages.size %]
<li>
<label for="title" class="required">Title: </label>
<input id="title" size="100" maxlength="250" type="text" name="title_default" value="[% additional_content.title | html %]" required="required" class="required" /> <span class="required">Required</span>
</li>
[% END %]
<li>
<label for="from">Publication date: </label>
<input id="from" type="text" name="published_on" size="15" value="[% additional_content.published_on | $KohaDates %]" class="flatpickr" data-date_to="to" />
<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="[% additional_content.expirationdate | $KohaDates %]" class="flatpickr" />
<div class="hint">
[% INCLUDE 'date-format.inc' %]
[% IF category == 'news' %]
<br>News will still be accessible by direct URL if expired.
[% END %]
</div>
</li>
<li>
<label for="number">Appear in position: </label>
[% IF ( additional_content.number ) %]
<input id="number" size="3" name="number" type="text" value="[% additional_content.number | html %]" />
[% ELSE %]
<input id="number" size="3" name="number" type="text" />
[% END %]
</li>
</ol>
</fieldset>
[% IF languages.size %]
<div style="clear:both"></div>
<div id="tabs">
<ul>
[% FOR language IN languages %]
[% IF language.lang == 'default' %]
<li><a href="#lang_default">Default</a></li>
[% ELSE %]
<li><a href="#lang_[% language.lang | uri %]">[% language.description | html %]</a></li>
[% END %]
[% END %]
</ul>
[% FOR language IN languages %]
<div id="lang_[% language.lang | uri %]" class="lang clearfix" data-lang="[% language.description | html %]">
<fieldset class="rows">
<ol>
<li style="list-style: none;">
<label for="title_[% language.lang | html %]">Title: </label>
<input id="title_[% language.lang| html %]" size="100" maxlength="250" type="text" name="title_[% language.lang | html %]" value="[% translated_contents.item(language.lang).title | html %]">
</li>
<li style="list-style: none;">
<label for="content_[% language.lang | html %]">Content: </label>
<textarea name="content_[% language.lang | html %]" id="content_[% language.lang | html %]" data-lang="[% language.lang | html%]" cols="75" rows="10">[% translated_contents.item(language.lang).content | html %]</textarea>
<input type="hidden" name="lang" value="[% language.lang | html %]" />
</li>
</ol>
</fieldset>
</div>
[% END %]
</div>
[% ELSE %]
<div id="lang_default">
<div class="clearfix">
<textarea name="content" id="content_default" data-lang="[% language.lang | html %]" cols="75" rows="10">[% additional_content.content | html %]</textarea>
</div>
</div>
[% END %]
</form>
[% END %]
[% BLOCK list %]
<div id="toolbar" class="btn-toolbar">
<div class="btn-group">
<a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | uri %]&editmode=[% editmode | uri %]" class="btn btn-default" id="newentry"> <i class="fa fa-plus"></i> New entry</a><button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
<li>
[% IF ( wysiwyg ) %]
<a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | uri %]&editmode=text">New entry using text editor</a>
[% ELSE %]
<a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | uri %]&editmode=wysiwyg">New entry using WYSIWYG editor</a>
[% END %]
</li>
</ul>
</div>
</div>
<h2>Additional contents ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])</h2>
[% IF category == 'news' %]
See <a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a>
[% ELSE %]
See <a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a>
[% END %]
[% IF additional_contents.count %]
<form id="del_form" method="post" action="/cgi-bin/koha/tools/additional-contents.pl">
<table id="table_additional_contents">
<thead>
<tr>
<th class="NoSort">&nbsp;</th>
<th>Location</th>
<th>Library</th>
<th>Number</th>
<th>Publication date</th>
<th>Expiration date</th>
<th class="anti-the">Title</th>
<th>Author</th>
<th class="anti-the">News</th>
<th class="NoSort noExport">Actions</th>
</tr>
</thead>
<tbody>
[% FOREACH c IN additional_contents%]
[% IF ( c.is_expired ) %]<tr class="expired">[% ELSE %]<tr>[% END %]
<td>
<input type="checkbox" name="ids" value="[% c.idnew | html %]" />
</td>
<td>
[% IF c.category == 'news' %]
[% IF c.location == 'staff_and_opac' %]All
[% ELSIF c.location == 'staff_only' %]Librarian interface
[% ELSIF c.location == 'opac_only' %]OPAC
[% ELSIF c.location == 'slip' %]Slip
[% ELSE %]Unknown ('[% location | html %]')
[% END %]
[% ELSE %]
[% c.location | html %]
[% END %]
</td>
<td>
[% IF ( c.branchcode == "" ) -%]
All libraries
[% ELSE %][% c.library.branchname | html %]
[% END %]
</td>
<td>[% c.number | html %]</td>
<td data-order="[% c.published_on | html %]">[% c.published_on | $KohaDates %]</td>
<td data-order="[% c.expirationdate | html %]">[% c.expirationdate | $KohaDates %] [% IF ( c.is_expired ) %](<span class="expired">expired</span>)[% END %]</td>
<td>[% c.title | html %]</td>
<td>[% IF ( c.author) %][% INCLUDE 'patron-title.inc' patron=c.author %][% END %]</td>
<td>
<div class="btn-group">
<a class="preview_news btn btn-default btn-xs" data-number="[% loop.count | html %]"><i class="fa fa-eye" aria-hidden="true"></i> Preview content</a>
</div>
<div id="contentModal[% loop.count | html %]" class="modal" tabindex="-1" role="dialog" data-number="[% loop.count | html %]">
<div class="modal-dialog" role="document">
<div class="modal-content modal-lg">
<div class="modal-header">
<h5 class="modal-title">Preview of: "[% c.title | html %]"</h5>
</div>
<div class="modal-body">
[% c.content | $raw %]
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</td>
<td class="actions">
<div class="btn-group dropup">
<a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.idnew | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
<li>
[% IF ( wysiwyg ) %]
<a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.idnew | uri %]&editmode=text"><i class="fa fa-pencil"></i> Edit with text editor</a>
[% ELSE %]
<a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.idnew | uri %]&editmode=wysiwyg"><i class="fa fa-pencil"></i> Edit with WYSIWYG editor</a>
[% END %]
</li>
</ul>
</div>
<div class="btn-group">
<a href="#" class="delete_news btn btn-default btn-xs" data-idnew="[% c.idnew | html %]"><i class="fa fa-trash"></i> Delete</a>
</div>
</td>
</tr>
[% END %]
</tbody>
</table>
<input type="hidden" name="op" value="delete_confirmed" />
<input type="hidden" name="category" value="[% category | html %]" />
<fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
</form>
<form action="/cgi-bin/koha/tools/additional-contents.pl" method="post" id="delete_single">
<input type="hidden" id="del_op" name="op" value="delete_confirmed" />
<input type="hidden" id="del_category" name="category" value="[% category | html %]" />
<input type="hidden" id="del_ids" name="ids" />
</form>
[% ELSE %]
<div class="dialog message">There are no additional contents.</div>
[% END %]
[% END %]
[% BLOCK locations_options %]
[% IF category == 'news' %]
[% IF location == "staff_and_opac" %]
<option value="staff_and_opac" selected="selected">Librarian and OPAC interfaces</option>
[% ELSE %]
<option value="staff_and_opac">Librarian and OPAC interfaces</option>
[% END %]
[% IF location == "staff_only" %]
<option value="staff_only" selected="selected">Librarian interface</option>
[% ELSE %]
<option value="staff_only">Librarian interface</option>
[% END %]
[% IF location == "opac_only" %]
<option value="opac_only" selected="selected">OPAC</option>
[% ELSE %]
<option value="opac_only">OPAC</option>
[% END %]
[% IF location == "slip" %]
<option value="slip" selected="selected">Slip</option>
[% ELSE %]
<option value="slip">Slip</option>
[% END %]
[% ELSE %]
[% FOREACH l IN [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches' ] %]
[% IF l == location %]
<option value="[% l | html %]" selected="selected">[% l | html %]</option>
[% ELSE %]
<option value="[% l | html %]">[% l | html %]</option>
[% END %]
[% END %]
[% END %]
[% END %]
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'calendar.inc' %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% Asset.js("lib/hc-sticky.js") | $raw %]
[% IF additional_contents.count %]
[% INCLUDE 'datatables.inc' %]
<script>
$('.preview_news').click( function() {
modalNumber = $(this).attr('data-number');
$('.modal[data-number="'+modalNumber+'"]').modal('show');
})
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;
}
}
}
function filterDataTable( table, column, term ){
if( column ){
table.column( column ).search( term ).draw();
} else {
table.search( term ).draw();
}
clearFilter( term );
}
function clearFilter( term ){
if( term == "" ){
$(".dt_button_clear_filter").addClass("disabled");
} else {
$(".dt_button_clear_filter").removeClass("disabled");
}
}
/* Custom table search configuration: If a table row
has an "expired" class, hide it UNLESS the
show_expired checkbox is checked */
$.fn.dataTable.ext.search.push(
function( settings, searchData, index, rowData, counter ) {
var row = $(settings.aoData[index].nTr);
if( row.hasClass("expired") && !$("#show_expired").prop("checked") ){
return false;
} else {
return true;
}
}
);
$(document).ready(function() {
var table = $("#table_additional_contents").DataTable($.extend(true, {}, dataTablesDefaults, {
"order": [[ 4, "desc" ]],
"aoColumnDefs": [
{ "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] },
{ "type": "anti-the", "targets": [ "anti-the" ] }
],
"sPaginationType": "full_numbers"
}));
$("#del_form").on("click", ".delete_news", function(e){
e.preventDefault();
if( confirmDelete( _("Are you sure you want to delete this content? This cannot be undone.") ) ){
$("#del_ids").val( $(this).data("idnew") );
$("#delete_single").submit();
}
});
$("#del_form").on("submit",function(){
if ( Checkbox() ) {
return confirmDelete( _("Are you sure you want to delete the selected content?") );
} else {
alert(_("Please select content to delete."));
return false;
}
});
$("#show_expired").on("change", function(){
/* redraw the DataTable according to the custom search function */
table.draw();
});
table.on( 'search.dt', function () {
var term = table.search();
$("#news_keyword").val( term );
});
$("#news_keyword").on("keyup", function(){
var term = $(this).val();
filterDataTable( table, null, term );
});
$("#news_display_location").on("change", function(){
var term = $(this).val();
filterDataTable( table, 1, term );
});
$("#news_library").on("change", function(){
// Table must be filtered by the <option>'s text, not its value
var opt = $(this).find("option:selected").text();
filterDataTable( table, 2, opt );
});
$(".dt_button_clear_filter").on("click", function(){
table.search('').columns().search('').draw();
$("#news-filter select").each(function(){
$(this).val("");
});
});
});
</script>
[% ELSE %]
<script>
$(document).ready(function() {
$("#tabs").tabs();
$("#add_additional_content").validate({
submitHandler: function(form){
if ( ! $("#title_default").val().length > 0 ) {
alert(__("Please specify a title for 'Default'"));
return false;
}
form.submit();
}
});
$("#submit_form").on("click",function(){
$("#add_additional_content").submit();
});
Sticky = $("#toolbar");
Sticky.hcSticky({
stickTo: ".main",
stickyClass: "floating"
});
});
</script>
[% END %]
[% UNLESS ( wysiwyg ) %]
[% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %]
[% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %]
[% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %]
[% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %]
[% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %]
<script>
$("textarea[name^='content_']").each( function(index) {
var this_lang = $(this).attr('data-lang');
var editor = CodeMirror.fromTextArea(document.getElementById('content_' + this_lang), {
lineNumbers: true,
lineWrapping: true,
lint: true,
mode: "text/html",
gutters: ["CodeMirror-lint-markers"],
viewportMargin: Infinity,
});
});
</script>
[% ELSE %]
[% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %]
[% INCLUDE 'str/tinymce_i18n.inc' %]
<script>
tinyMCE.init({
verify_html: false,
force_br_newlines : false,
force_p_newlines : false,
forced_root_block : '',
branding : false,
relative_urls : false,
content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css",
menubar : "file edit view insert format tools table",
mode : "specific_textareas",
plugins : "autoresize table hr link image charmap lists code emoticons",
extended_valid_elements:"style,link[href|rel]",
custom_elements:"style,link,~link",
toolbar : [
"formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr",
"table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code"
],
});
</script>
[% END # /UNLESS wysiwyg %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]