From f25f0aa254a11b12493466e6c733d90df0df11a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Wed, 2 Dec 2015 09:49:02 +0100 Subject: [PATCH] Bug 15288: Error pages: Code duplication removal and better translatability This patch changes the 400, 401, 402, 403, 404, 500 error pages to be handled by only one template for staff and only one template for OPAC. Additionally it removes a translatability issues due to sentence splitings by html tags. To test: - Apply patch - Trigger 404 error for staff and for OPAC by calling a page that does not exist - Try to trigger other error pages and/or carefully review code changes in the *.pl files - Review koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/errorpage.tt and koha-tmpl/intranet-tmpl/prog/en/modules/errorpage.tt (Amended to fix a typo) (Amended for comment #6) (Amended to cover OPAC error pages as well) Signed-off-by: Hector Castro Works as advertised Signed-off-by: Marcel de Rooy Signed-off-by: Brendan A Gallagher --- errors/400.pl | 7 +- errors/401.pl | 7 +- errors/402.pl | 7 +- errors/403.pl | 7 +- errors/404.pl | 7 +- errors/500.pl | 7 +- .../prog/en/modules/errors/400.tt | 29 ------- .../prog/en/modules/errors/401.tt | 30 ------- .../prog/en/modules/errors/402.tt | 29 ------- .../prog/en/modules/errors/403.tt | 29 ------- .../prog/en/modules/errors/405.tt | 29 ------- .../prog/en/modules/errors/500.tt | 29 ------- .../modules/errors/{404.tt => errorpage.tt} | 16 ++-- .../bootstrap/en/modules/errors/404.tt | 54 ------------- .../bootstrap/en/modules/errors/errorpage.tt | 81 +++++++++++++++++++ opac/errors/400.pl | 7 +- opac/errors/401.pl | 7 +- opac/errors/402.pl | 7 +- opac/errors/403.pl | 7 +- opac/errors/404.pl | 7 +- opac/errors/500.pl | 7 +- 21 files changed, 149 insertions(+), 261 deletions(-) delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/errors/400.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/errors/401.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/errors/402.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/errors/403.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/errors/405.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/errors/500.tt rename koha-tmpl/intranet-tmpl/prog/en/modules/errors/{404.tt => errorpage.tt} (77%) delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/404.tt create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/errorpage.tt diff --git a/errors/400.pl b/errors/400.pl index 23dc5aeb85..7c947dbf29 100755 --- a/errors/400.pl +++ b/errors/400.pl @@ -27,12 +27,15 @@ my $query = CGI->new; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => 'errors/400.tt', + template_name => 'errors/errorpage.tt', query => $query, type => 'intranet', authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 400, +); output_with_http_headers $query, $cookie, $template->output, 'html', '400 Bad Request'; diff --git a/errors/401.pl b/errors/401.pl index 88c88d8e08..fcd2d88b16 100755 --- a/errors/401.pl +++ b/errors/401.pl @@ -26,12 +26,15 @@ my $query = CGI->new; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => 'errors/401.tt', + template_name => 'errors/errorpage.tt', query => $query, type => 'intranet', authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 401, +); output_with_http_headers $query, $cookie, $template->output, 'html', '401 Unauthorized'; diff --git a/errors/402.pl b/errors/402.pl index 552398b87f..1a9f3a6876 100755 --- a/errors/402.pl +++ b/errors/402.pl @@ -27,12 +27,15 @@ my $query = CGI->new; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => 'errors/402.tt', + template_name => 'errors/errorpage.tt', query => $query, type => 'intranet', authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 402, +); output_with_http_headers $query, $cookie, $template->output, 'html', '402 Payment Required'; diff --git a/errors/403.pl b/errors/403.pl index 11918c38a3..3a46f68a2f 100755 --- a/errors/403.pl +++ b/errors/403.pl @@ -27,12 +27,15 @@ my $query = CGI->new; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => 'errors/403.tt', + template_name => 'errors/errorpage.tt', query => $query, type => 'intranet', authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 403, +); output_with_http_headers $query, $cookie, $template->output, 'html', '403 Forbidden'; diff --git a/errors/404.pl b/errors/404.pl index e7e007141b..57191f1600 100755 --- a/errors/404.pl +++ b/errors/404.pl @@ -27,12 +27,15 @@ my $query = CGI->new; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => 'errors/404.tt', + template_name => 'errors/errorpage.tt', query => $query, type => 'intranet', authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 404, +); output_with_http_headers $query, $cookie, $template->output, 'html', '404 Not Found'; diff --git a/errors/500.pl b/errors/500.pl index 9fb6e0cc8e..0008faf5c5 100755 --- a/errors/500.pl +++ b/errors/500.pl @@ -27,12 +27,15 @@ my $query = CGI->new; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => 'errors/500.tt', + template_name => 'errors/errorpage.tt', query => $query, type => 'intranet', authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 500, +); output_with_http_headers $query, $cookie, $template->output, 'html', '500 Internal Server Error'; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/400.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/400.tt deleted file mode 100644 index 350f629dea..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/400.tt +++ /dev/null @@ -1,29 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Error -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'cat-search.inc' %] - - - -
- -
-
-
-

An error has occurred!

-

Error 400

-
    -
  • This error means that the link was broken and that the page doesn't exist
  • -
  • To report this error, you can email the Koha administrator.
  • -
  • Use top menu bar to navigate to another part of Koha.
  • -
-
- -
-
- -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/401.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/401.tt deleted file mode 100644 index 5c0d3cf686..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/401.tt +++ /dev/null @@ -1,30 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Error 401 -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'cat-search.inc' %] - - - -
- -
-
-
-

An error has occurred!

-

Error 401

-
    -
  • This error means that you aren't authorized to view this page.
  • -
  • Please log in and try again. -
  • To report this error, you can email the Koha administrator.
  • -
  • Use top menu bar to navigate to another part of Koha.
  • -
-
- -
-
- -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/402.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/402.tt deleted file mode 100644 index 865649984a..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/402.tt +++ /dev/null @@ -1,29 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Error 402 -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'cat-search.inc' %] - - - -
- -
-
-
-

An error has occurred!

-

Error 402

-
    -
  • This error means that the link was broken and that the page doesn't exist
  • -
  • To report this error, you can email the Koha administrator.
  • -
  • Use top menu bar to navigate to another part of Koha.
  • -
-
- -
-
- -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/403.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/403.tt deleted file mode 100644 index 6ed5c3a19a..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/403.tt +++ /dev/null @@ -1,29 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Error 403 -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'cat-search.inc' %] - - - -
- -
-
-
-

An error has occurred!

-

Error 403

-
    -
  • This error means that you are forbidden to view this page.
  • -
  • To report this error, you can email the Koha administrator.
  • -
  • Use top menu bar to navigate to another part of Koha.
  • -
-
- -
-
- -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/405.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/405.tt deleted file mode 100644 index f4948d05d0..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/405.tt +++ /dev/null @@ -1,29 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Error 405 -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'cat-search.inc' %] - - - -
- -
-
-
-

An error has occurred!

-

Error 405

-
    -
  • This error means that the link was broken and that the page doesn't exist
  • -
  • To report this error, you can email the Koha administrator.
  • -
  • Use top menu bar to navigate to another part of Koha.
  • -
-
- -
-
- -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/500.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/500.tt deleted file mode 100644 index bab01b6bb6..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/500.tt +++ /dev/null @@ -1,29 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -Koha › Error 500 -[% INCLUDE 'doc-head-close.inc' %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'cat-search.inc' %] - - - -
- -
-
-
-

An error has occurred!

-

Error 500

-
    -
  • In Koha this typically means that the Koha team is working on new features
  • -
  • Wait while system maintenance is being done or email the Koha administrator.
  • -
  • Use top menu bar to navigate to another part of Koha.
  • -
-
- -
-
- -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/404.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt similarity index 77% rename from koha-tmpl/intranet-tmpl/prog/en/modules/errors/404.tt rename to koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt index 422aba3aa7..837ebffa00 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/errors/404.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/errors/errorpage.tt @@ -1,21 +1,21 @@ [% INCLUDE 'doc-head-open.inc' %] -Koha › Error 404 +Koha › Error [% errno %] [% INCLUDE 'doc-head-close.inc' %] - + [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] - +
- +
-
-
+
+

An error has occurred!

-

Error 404

+

Error [% errno %]

This message may have been caused by any of the following reasons:

  • You made use of an external link to an item that is no longer available
  • @@ -26,7 +26,7 @@

    What's next?

    • Use top menu bar to navigate to another part of Koha.
    • -
    • To report a broken link or any other issue, please send an email to the Koha Administrator
    • +
    • To report a broken link or any other issue, please contact the Koha Administrator. Send email
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/404.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/404.tt deleted file mode 100644 index 232ecd1ddd..0000000000 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/404.tt +++ /dev/null @@ -1,54 +0,0 @@ -[% INCLUDE 'doc-head-open.inc' %] -[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › An error has occurred -[% INCLUDE 'doc-head-close.inc' %] -[% BLOCK cssinclude %][% END %] - - -[% INCLUDE 'masthead.inc' %] - -
- - -
-
- [% IF ( OpacNav || OpacNavBottom ) %] -
- -
-
- [% ELSE %] -
- [% END %] -
-

Sorry, the requested page is not available

-

Error 404

-

This message can have following reasons

-
    -
  • You made use of an external link to a catalog item that is no longer available
  • -
  • You followed an outdated link e.g. from a search engine or a bookmark
  • -
  • You tried to access a page that needs authentification
  • -
  • An internal link in our catalog home page is broken and the page does not exist
  • -
-

What's next?

-
    -
  • You can search our catalog using the search form at the top of this page
  • -
  • You can navigate to the catalog main page
  • -
-

Report broken links

- -
-
-
-
-
- -[% INCLUDE 'opac-bottom.inc' %] -[% BLOCK jsinclude %] -[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/errorpage.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/errorpage.tt new file mode 100644 index 0000000000..63ede2d97d --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/errors/errorpage.tt @@ -0,0 +1,81 @@ +NCLUDE 'doc-head-open.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › An error has occurred +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + + +[% INCLUDE 'masthead.inc' %] + +
+ + +
+
+ [% IF ( OpacNav || OpacNavBottom ) %] +
+ +
+
+ [% ELSE %] +
+ [% END %] +
+

Sorry, the requested page is not available

+

Error [% errno %]

+

This message can have following reason(s)

+
    + [% IF ( errno == 400 ) %] +
  • Koha is pointed an invalid link.
  • + [% END %] + + [% IF ( errno == 401 ) %] +
  • You are trying to access a link that you're not authorized to see.
  • +
  • Try logging in to the catalog.
  • + [% END %] + + [% IF ( errno == 402 ) %] +
  • Koha is pointed an invalid link.
  • + [% END %] + + [% IF ( errno == 403 ) %] +
  • You are forbidden for some reason to see this page.
  • + [% END %] + + [% IF ( errno == 404 ) %] +
  • You made use of an external link to a catalog item that is no longer available.
  • +
  • You followed an outdated link e.g. from a search engine or a bookmark.
  • +
  • You tried to access a page that needs authentification.
  • +
  • An internal link in our catalog home page is broken and the page does not exist.
  • + [% END %] + [% IF ( errno == 500 ) %] +
  • An error occurred while try to process your request.
  • + [% END %] +
+

What's next?

+
    + [% IF ( errno == 401 ) %] +
  • Try logging in to the catalog.
  • + [% END %] +
  • You can use the menu and links at the top of the page
  • +
  • You can search our catalog using the search form at the top of this page.
  • +
  • Return to the catalog home page.
  • +
+

Report issues and broken links

+
    +
  • To report this error, please contact the Koha Administrator. + Send email.
  • +
+
+
+
+
+
+ +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] +[% END %] diff --git a/opac/errors/400.pl b/opac/errors/400.pl index 9fcdcb58e2..d2009c5b08 100755 --- a/opac/errors/400.pl +++ b/opac/errors/400.pl @@ -28,12 +28,15 @@ my $query = new CGI; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "errors/400.tt", + template_name => "errors/errorpage.tt", query => $query, type => "opac", authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 400, +); output_with_http_headers $query, $cookie, $template->output, 'html', '400 Bad Request'; diff --git a/opac/errors/401.pl b/opac/errors/401.pl index 395d47fdb0..2c1d60e06e 100755 --- a/opac/errors/401.pl +++ b/opac/errors/401.pl @@ -28,12 +28,15 @@ my $query = new CGI; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "errors/401.tt", + template_name => "errors/errorpage.tt", query => $query, type => "opac", authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 401, +); output_with_http_headers $query, $cookie, $template->output, 'html', '401 Unauthorized'; diff --git a/opac/errors/402.pl b/opac/errors/402.pl index 5d084b4ac3..492495ea40 100755 --- a/opac/errors/402.pl +++ b/opac/errors/402.pl @@ -28,12 +28,15 @@ my $query = new CGI; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "errors/402.tt", + template_name => "errors/errorpage.tt", query => $query, type => "opac", authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 402, +); output_with_http_headers $query, $cookie, $template->output, 'html', '402 Payment Required'; diff --git a/opac/errors/403.pl b/opac/errors/403.pl index 753dd370dc..8e502bbd33 100755 --- a/opac/errors/403.pl +++ b/opac/errors/403.pl @@ -28,12 +28,15 @@ my $query = new CGI; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "errors/403.tt", + template_name => "errors/errorpage.tt", query => $query, type => "opac", authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 403, +); output_with_http_headers $query, $cookie, $template->output, 'html', '403 Forbidden'; diff --git a/opac/errors/404.pl b/opac/errors/404.pl index 3ce91059c9..3a4e0443a5 100755 --- a/opac/errors/404.pl +++ b/opac/errors/404.pl @@ -28,12 +28,15 @@ my $query = new CGI; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "errors/404.tt", + template_name => "errors/errorpage.tt", query => $query, type => "opac", authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 404, +); output_html_with_http_headers $query, $cookie, $template->output, '404 Not Found'; diff --git a/opac/errors/500.pl b/opac/errors/500.pl index 1459752239..50fa33e1da 100755 --- a/opac/errors/500.pl +++ b/opac/errors/500.pl @@ -28,12 +28,15 @@ my $query = new CGI; my $admin = C4::Context->preference('KohaAdminEmailAddress'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "errors/500.tt", + template_name => "errors/errorpage.tt", query => $query, type => "opac", authnotrequired => 1, debug => 1, } ); -$template->param( admin => $admin ); +$template->param ( + admin => $admin, + errno => 500, +); output_with_http_headers $query, $cookie, $template->output, 'html', '500 Internal Server Error'; -- 2.39.5