Koha/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt
David Cook acc8de8214 Bug 11584: Introduce UseWYSIWYGinSystemPreferences syspref
This patch adds a system preference "UseWYSIWYGinSystemPreferences" to the Staff Client tab.

By default, it is off, which means that the TinyMCE WYSIWYG editor won't be shown for system
preferences with a type of "htmlarea".

However, when it's on, it will show the editor for "Local Use" preferences with a "htmlarea"
type, and for other system preferences in the "Opac", "Circulation", and "Staff Client" tabs,
which I have re-assigned. (Basically, I grepped for HTML and changed the type for all
the system preferences I found except for "IntranetNav", "OpacCustomSearch", and "OPACSearchForTitleIn",
as a WYSIWYG editor would potentially break the output for these system preferences or
add no value to them...)

_TEST PLAN_

0) Run `perl installer/data/mysql/updatedatabase.pl` after setting your environmental variables
1) Check the Opac tab to make sure that the WYSIWYG is nowhere to be seen
2) Change the "UseWYSIWYGinSystemPreferences" preference in "Staff Client" to "Show"
3) Refresh the Opac tab and notice that many system preferences now have a WYSIWYG editor

4) Try typing some text into these fields
5) Note that it gets marked as "modified"
6) Save the preference, and refresh the page
7) Note that the content has been saved
8) Take a look at how it's rendered on the actual webpage!

Signed-off-by: Martin Persson <xarragon@gmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2015-08-28 10:29:39 -03:00

191 lines
11 KiB
Text

[% USE Koha %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Administration &rsaquo; System preferences</title>
[% INCLUDE 'doc-head-close.inc' %]
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
[% INCLUDE 'datatables.inc' %]
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/preferences.css" />
[% IF ( bidi ) %]
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/right-to-left.css" />
[% END %]
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/multiple-select/jquery.multiple.select.js"></script>
<link rel="stylesheet" type="text/css" href="[% interface %]/lib/jquery/plugins/multiple-select/multiple-select.css" />
<script type="text/javascript">
//<![CDATA[
[% UNLESS ( searchfield ) %]$(document).ready(function(){
$('#toolbar').fixFloat();
});[% END %]
$(document).ready(function(){
$("select[multiple='multiple']").multipleSelect( {
placeholder: _("Please select ..."),
selectAllText: _("Select all"),
allSelected: _("All selected"),
countSelected: _("# of % selected"),
noMatchesFound: _("No matches found")
} );
});
// This is here because of its dependence on template variables, everything else should go in js/pages/preferences.js - jpw
var to_highlight = "[% searchfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
var search_jumped = [% IF ( search_jumped ) %]true[% ELSE %]false[% END %];
var MSG_NOTHING_TO_SAVE = _("Nothing to save");
var MSG_SAVING = _("Saving...");
var MSG_SAVED_PREFERENCE = _("Saved preference %s");
var MSG_MODIFIED = _("modified");
var MSG_MADE_CHANGES = _("You have made changes to system preferences.");
var MSG_CLICK_TO_EXPAND = _("Click to expand this section");
var MSG_CLICK_TO_COLLAPSE = _("Click to collapse this section");
var MSG_INTERNAL_SERVER_ERROR = _( "Internal Server Error, please reload the page" );
var MSG_SESSION_TIMED_OUT = _( "You need to log in again, your session has timed out" );
var MSG_DATA_NOT_SAVED = _( "Error; your data might not have been saved" );
var MSG_LOADING = _( "Loading..." );
//]]>
</script>
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/humanmsg.css" />
<script src="[% interface %]/lib/jquery/plugins/humanmsg.js" type="text/javascript"></script>
<script src="[% themelang %]/js/ajax.js" type="text/javascript"></script>
<script src="[% themelang %]/js/pages/preferences.js" type="text/javascript"></script>
[%# Add WYSIWYG editor for htmlarea system preferences %]
[% INCLUDE 'wysiwyg-systempreferences.inc' %]
</head>
<body id="admin_preferences" class="admin">
[% INCLUDE 'header.inc' %]
[% INCLUDE 'prefs-admin-search.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; System preferences</div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
[% IF ( jump_not_found ) %]
<h2>System preferences</h2>
<div class="dialog alert">
Could not find a system preference named <code>[% jumpfield %]</code>.
</div>
[% END %]
[% IF ( search_not_found ) %]
<div class="dialog alert">
No system preferences matched your search for <strong>[% searchfield |html %]</strong>. You can try a different search or <a href="/cgi-bin/koha/admin/preferences.pl?tab=[% last_tab %]">return to where you were before.</a>
</div>
[% END %]
[% FOREACH TAB IN TABS %]
<div class="prefs-tab">
<h2>[% TAB.tab_title %] preferences</h2>
<form action="/cgi-bin/koha/admin/preferences.pl" method="post">
[% UNLESS ( searchfield ) %]<div id="toolbar"><button class="save-all submit" type="submit">Save all [% TAB.tab_title %] preferences</button></div>[% END %]
<input type="hidden" name="op" value="save" />
<input type="hidden" name="tab" value="[% TAB.tab_id %]" />
[% FOREACH LINE IN TAB.LINES %]
[% IF ( LINE.is_group_title ) %]
[% UNLESS ( loop.first ) %]</tbody></table>[% END %]
<h3>[% LINE.title %]</h3>
<table class="preferences">
<thead><tr><th>Preference</th><th>Value</th></tr></thead>
[% UNLESS ( loop.last ) %]<tbody>[% END %]
[% ELSE %]
[% IF ( loop.first ) %]<table class="preferences"><thead><tr><th>Preference</th><th>Value</th></tr></thead><tbody>[% END %]
<tr class="name-row">
<td class="name-cell">
<code>
[% FOREACH NAME IN LINE.NAMES %]
<label for="pref_[% NAME.name %]">
[% IF ( NAME.jumped ) %]
<span class="term" id="jumped">[% NAME.name %]</span>
[% ELSIF ( NAME.highlighted ) %]
<span class="term">[% NAME.name %]</span>
[% ELSE %]
[% NAME.name %]
[% END %]
[% IF NAME.overridden %]
<span class="overridden" title="The system preference [% NAME.name %] may have been overridden from this value by one or more virtual hosts.">
[Overridden]
</span>
[% END %]
</label>
[% UNLESS ( loop.last ) %]<br />[% END %]
[% END %]
</code>
</td>
<td><div>
[% FOREACH CHUNK IN LINE.CHUNKS %]
[% IF ( CHUNK.type_text ) %]
[% CHUNK.contents %]
[% ELSIF ( CHUNK.type_input ) %]
<input type="[%IF CHUNK.input_type %][% CHUNK.input_type %][% ELSE %]text[% END %]" name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "short" %]" value="[% CHUNK.value %]" autocomplete="off" /> [% IF ( CHUNK.dateinput ) %]<span class="hint">[% INCLUDE 'date-format.inc' %]</span>[% END %]
[% ELSIF ( CHUNK.type_select ) %]
<select name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "choice" %]">
[% FOREACH CHOICE IN CHUNK.CHOICES.sort('value') %]
[% IF ( CHOICE.selected ) %]
<option value="[% CHOICE.value %]" selected="selected">
[% ELSE %]
<option value="[% CHOICE.value %]">
[% END %]
[% CHOICE.text %]
</option>
[% END %]
</select>
[% ELSIF ( CHUNK.type_multiple ) %]
<select name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "choice" %]" multiple="multiple">
[% FOREACH CHOICE IN CHUNK.CHOICES %][% IF ( CHOICE.selected ) %]<option value="[% CHOICE.value %]" selected="selected">[% ELSE %]<option value="[% CHOICE.value %]">[% END %][% CHOICE.text %]</option>[% END %]
</select>
[% ELSIF ( CHUNK.type_textarea ) || ( CHUNK.type_htmlarea )%]
[% IF ( CHUNK.type_htmlarea ) && ( Koha.Preference('UseWYSIWYGinSystemPreferences') ) %]
<textarea name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "short" %] mce" rows="20" cols="60">[% CHUNK.value %]</textarea>
[% ELSE %]
<a class="expand-textarea" style="display: none" href="#">Click to Edit</a>
<textarea name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]" class="preference preference-[% CHUNK.class or "short" %]" rows="10" cols="40">[% CHUNK.value %]</textarea>
[% END %]
[% ELSIF ( CHUNK.type_languages ) %]
<dl>
[% FOREACH language IN CHUNK.languages %]
[% IF ( language.plural ) %]
<dt>
[% IF ( language.native_description ) %][% language.native_description %][% ELSE %][% language.rfc4646_subtag %][% END %]
</dt>
[% FOREACH sublanguages_loo IN language.sublanguages_loop %]
<dd>
<label for="pref_[% CHUNK.name %]_[% sublanguages_loo.rfc4646_subtag %]">[% sublanguages_loo.native_description %] [% sublanguages_loo.script_description %] [% sublanguages_loo.region_description %] [% sublanguages_loo.variant_description %]([% sublanguages_loo.rfc4646_subtag %])</label>
[% IF ( sublanguages_loo.enabled ) %]
<input value="[% sublanguages_loo.rfc4646_subtag %]" name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]_[% sublanguages_loo.rfc4646_subtag %]" type="checkbox" checked="checked" class="preference preference-checkbox"/>
[% ELSE %]
<input value="[% sublanguages_loo.rfc4646_subtag %]" name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]_[% sublanguages_loo.rfc4646_subtag %]" type="checkbox" class="preference preference-checkbox"/>
[% END %]
</dd>
[% END %]
[% ELSE %]
<dt>
<label for="pref_[% CHUNK.name %]_[% language.rfc4646_subtag %]">[% language.native_description %]([% language.rfc4646_subtag %])</label>
[% IF ( language.group_enabled ) %]
<input value="[% language.rfc4646_subtag %]" name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]_[% language.rfc4646_subtag %]" type="checkbox" checked="checked" class="preference preference-checkbox"/>
[% ELSE %]
<input value="[% language.rfc4646_subtag %]" name="pref_[% CHUNK.name %]" id="pref_[% CHUNK.name %]_[% language.rfc4646_subtag %]" type="checkbox" class="preference preference-checkbox"/>
[% END %]
</dt>
[% END %]
[% END %]
</dl>
[% END %]
[% END %]
</div></td>
</tr>
[% IF ( loop.last ) %]</tbody></table>[% END %]
[% END %]
[% END %]
<fieldset class="action"><button class="save-all submit" type="submit">Save all [% TAB.tab_title %] preferences</button> <a href="#" onclick="window.location.reload(true);" class="cancel">Cancel</a></fieldset>
</form>
</div>
[% END %]
</div>
</div>
<div class="yui-b">
[% INCLUDE 'prefs-menu.inc' %]
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]