From 980dd605031e616f1d481852dffe9cc6779eb3e3 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 8 May 2020 22:57:40 +0000 Subject: [PATCH] Bug 22660: Add system pref to allow switching of editors in News Tool This patch adds a system preference called 'NewsToolEditor' which allows for the choice between TinyMCE and CodeMirror in the News Feature. TEST PLAN: 1. Apply patch and run updatedatabase 2. Go to Tools > News and make a new entry or edit an existing News item. 3. When you initially load you should gte the TinyMCE editor (WYSIWYG) 4. Search for the NewsToolEditor system preference and switch to CodeMirror. 5. Reload your News item and now you should see the CodeMirror editor. 6. Try saving content with both and maki sure it works. 7. Try adding some different HTML tags in CodeMirror mode, saving, and making sure it looks right when you switch back to TinyMCE Signed-off-by: Owen Leonard Signed-off-by: Lisette Scheer Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- ...60_add_NewsToolEditor_system_preference.perl | 6 ++++++ installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/tools.pref | 8 +++++++- .../prog/en/modules/tools/koha-news.tt | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_22660_add_NewsToolEditor_system_preference.perl diff --git a/installer/data/mysql/atomicupdate/bug_22660_add_NewsToolEditor_system_preference.perl b/installer/data/mysql/atomicupdate/bug_22660_add_NewsToolEditor_system_preference.perl new file mode 100644 index 0000000000..88e141612d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22660_add_NewsToolEditor_system_preference.perl @@ -0,0 +1,6 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( "INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('NewsToolEditor','tinymce', 'Choose tool for editing News','tinymce|codemirror','Choice')" ); + + NewVersion( $DBversion, 22660, "Adds NewsToolEditor system preference"); +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 758a5916ac..5fcb9b13d1 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -330,6 +330,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'), ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'), +('NewsToolEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'), ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), ('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before check outs are blocked','Integer'), ('noItemTypeImages','0',NULL,'If ON, disables itemtype images in the staff interface','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref index 1d4f2965ef..77a40f1529 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref @@ -36,7 +36,13 @@ Tools: opac: "OPAC only" staff: "Staff client only" both: "Both OPAC and staff client" - - + - + - Use + - pref: NewsToolEditor + choices: + tinymce: "TinyMCE (WYSIWYG)" + codemirror: "CodeMirror" + - when editing News. Upload: - - Automatically delete temporary uploads older than 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 a42aea511e..80d6d68dff 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 @@ -4,6 +4,12 @@ [% USE Branches %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] +[% Asset.css("lib/codemirror/codemirror.css") | $raw %] + Koha › Tools › News [% INCLUDE 'doc-head-close.inc' %] [% IF ( opac_news_count ) %] @@ -206,6 +212,8 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] [% Asset.js("js/tools-menu.js") | $raw %] + [% Asset.js("lib/d3c3/d3.min.js") | $raw %] + [% Asset.js("lib/d3c3/c3.min.js") | $raw %] [% IF ( opac_news_count ) %] [% INCLUDE 'datatables.inc' %] [% END %] + [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %] [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] [% INCLUDE 'str/tinymce_i18n.inc' %] [% END %] -- 2.39.5