From f88a76525f0da08a957ae7db689ae80b088c6b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Mon, 1 May 2017 15:16:00 +0200 Subject: [PATCH] Bug 18516 - Add possibility to import text from file based help system as news based help system item Adds additional button to help page to import text from file based help to a new news based help item. First draft - proof of concept. Not yet ready to sign-off. --- help.pl | 23 +++++++++++++++++++--- .../intranet-tmpl/prog/en/includes/help-top.inc | 3 +++ .../prog/en/modules/tools/koha-news.tt | 8 ++++++-- tools/koha-news.pl | 4 +++- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/help.pl b/help.pl index 4d13684..29d6b76 100755 --- a/help.pl +++ b/help.pl @@ -38,7 +38,21 @@ sub _help_template_file_of_url { return "help/$file.tt"; } -my $query = new CGI; +our $query = new CGI; + +# CP code for proof of concept Bug 18516, will need rework +sub _get_filepath ($;$) { + my $referer = shift; + $referer =~ /koha\/(.*)\.pl/; + my $file = $1; + $file =~ s/[^0-9a-zA-Z_\-\/]*//g; + my $from = "help/$file.tt"; + my $htdocs = C4::Context->config('intrahtdocs'); + my ($theme, $lang, $availablethemes) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); + return "$htdocs/$theme/$lang/modules/$from"; +} + + # Init the interface to get the correct language. # This is usually set by get_template_and_user @@ -61,6 +75,10 @@ my $htdocs = C4::Context->config('intrahtdocs'); # checking that the help file exist, otherwise, display nohelp.tt page my ( $theme, $lang ) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); +#my $createfrom = $from; +my $createfrom = _get_filepath($refer, 1); # 2nd argument triggers themelanguage call + + unless ( -e "$htdocs/$theme/$lang/modules/$from" ) { $from = "help/nohelp.tt"; ( $theme, $lang ) = C4::Templates::themelanguage( $htdocs, $from, "intranet", $query ); @@ -85,14 +103,13 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( ); - - $template->param( referer => $refer, helpkey => $helpkey, intranetstylesheet => C4::Context->preference("intranetstylesheet"), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), helpsystem => $helpsys, + createfrom => $createfrom, ); if ( index($helpsys,'newsbased') != -1 || index ($helpsys,'filebased') != -1 ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc index b914d0e..96757a8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/help-top.inc @@ -34,6 +34,9 @@

Add help for all pages Key is: all

+

+ Add help for this page using built in text + Uses installed Koha help text as a base for new entry

Note: You can manage and / or delete help entries in More › Tools

[% END %] 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 9d73c22..4b0e5f3 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 @@ -193,8 +193,12 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] [% END %] -
  • - +
  • + [% IF createfrom %] + + [% ELSE %] + + [% END %]
  • diff --git a/tools/koha-news.pl b/tools/koha-news.pl index 5bf0859..9993b2a 100755 --- a/tools/koha-news.pl +++ b/tools/koha-news.pl @@ -46,6 +46,7 @@ if ( $cgi->param('expirationdate') ) { my $timestamp = output_pref({ dt => dt_from_string( scalar $cgi->param('timestamp') ), dateformat => 'iso', dateonly => 1 }); my $number = $cgi->param('number'); my $helpkey = $cgi->param('helpkey'); +my $createfrom = $cgi->param('createfrom'); my $lang = $cgi->param('lang'); my $branchcode = $cgi->param('branch'); my $error_message = $cgi->param('error_message'); @@ -119,7 +120,8 @@ if ( $op eq 'add_form' ) { else { $template->param( op => 'add', - helpkey => $helpkey + helpkey => $helpkey, + createfrom => $createfrom ); } -- 2.1.4