Jonathan Druart
89ade834d6
One big patch for one big move. The "News" feature (opac_news) has been hijacked to handle some system preferences (bug 26050). The goal was to take profit of the UI (editor) and the ability to translate the value. Disclaimer: This patch is NOT offering the best implementation but, as we still don't have bug 24975, it cannot be done now. And no, we don't want to wait for it to move forward here. This patch is going into the right direction anyway. This enhancement is going to rename the "News" with a more genertic "Additional contents". We have two different "categories" of content: "news" and "html customizations". What does it bring? - A split on the UI for disambigate the two types of content (news and syspref/html customizations) - A simplification of the edit form: all languages will be translatable on the same view (like the "notice templates") - Ground will be prepared for different types of content (if needed later) - Staff news can be translated How was the "News" area working before this patch? The opac_news DB table contained a (very inconsistent) 'lang' column. The different values were: - '' => news to display at the OPAC and staff interfaces - 'koha' => news for staff only - 'slip' => news for slip notices - $lang => news for OPAC only, translated in $lang ('en', 'es-ES', etc.) - "$location_$lang" => A syspref moved to this "news" area. The syspref is $location, and is translated in $lang. Eg. OpacLoginInstructions_en, OpacLoginInstructions_fr-FR, opacheader_es-ES This patch is improving the DB structure with the following changes: - renaming 'opac_news' with 'additional_contents' - new 'category' column => 'news' or 'html_customizations' - new 'location' column => For 'news': 'staff_and_opac', 'staff_only', 'slip' => For 'html_customizations': the old syspref name (eg. 'OpacLoginInstructions'). - new 'code' column (see later for more info) - the 'lang' column will only contain the language code ('en', 'es-ES', etc.). BUT a 'default' entry will ALWAYS exist for fallback behaviour. We are getting closer to the 'notice template' table structure because we want to match its UI. The 'code' column will bring us the ability to group the different 'additional_contents' rows. The code for a given news will be the same, but the (lang, title, content) will differ. Examples: News 1 will have, for each of the translated versions (category, code, location, branchcode) ('news', 'News1', $location, $branchcode||undef) And the 3 following columns will differ: (title, content, lang) ('title for news 1', 'content for news 1', 'default') ('titulo para 1', 'contenido para 1', 'es-ES') Note that the "category" is not strictely necessary, but it seems better to have the ability to split the different content by category/type easily. Additional changes: - Syspref 'NewsToolEditor' is renamed 'AdditionalContentsEditor' - Koha::NewItem => Koha::AdditionalContent - Koha::News => Koha::AdditionalContents - Script and template renamed from koha-news to additional-contents - Foreign keys have been renamed - Subpermission edit_news has been renamed edit_additional_contents - The UI can now be accessed via a "News" or "HTML customizations" link from the tools module. The related contents will then be displayed (both categories are now split) Changes not done here: - Primary key 'idnew' could be renamed 'id' Limitations of the upgrade: News cannot be grouped by a unique code for existing translations. => A given news will be now displayed several times on the translated interface Any ideas to improve the upgrade behaviour? We will have to add a warning in the release notes to tell libraries to review their news. Test plan: 0. Don't apply the patches 1. Translate the interfaces in some languages . Create some news for staff and OPAC . Create some content for different entry of HTML customizations Note that you are forced to define a 'default'. Also note that you are only forced to fill the title (not the content). This is certainly problematic (see FIXME in the code) as sometime only the content is displayed. . Play with the interface (edit, delete, filter) . Go to the different places the news are displayed, and confirm they are displayed correctly (staff home, opac home, opac rss) . Create 1+ news for 'slip', check an item out and 'print slip' (from the circulation page). You must see the news. . Go to the different places you are expecting the HTML customizations to be present and confirm that you see them. . Switch the lang of the interface and confirm that you now see the content in the translated version . Generate the templates in another language, don't translate the content . Use this language for the interface and confirm that the 'default' version is displauyed. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
56 lines
1.8 KiB
Perl
Executable file
56 lines
1.8 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# This file is part of Koha.
|
|
#
|
|
# Copyright (C) 2015 Viktor Sarge
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it
|
|
# under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
|
|
|
|
|
use Modern::Perl;
|
|
use CGI;
|
|
use C4::Auth qw( get_template_and_user );
|
|
use C4::Output qw( output_html_with_http_headers );
|
|
use Koha::AdditionalContents;
|
|
|
|
my $input = CGI->new;
|
|
my $dbh = C4::Context->dbh;
|
|
|
|
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|
{
|
|
template_name => "opac-news-rss.tt",
|
|
type => "opac",
|
|
query => $input,
|
|
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
|
|
}
|
|
);
|
|
|
|
# Get the news to display
|
|
# use cookie setting for language, bug default to syspref if it's not set
|
|
my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-main.tt','opac',$input);
|
|
|
|
my $branchcode = $input->param('branchcode');
|
|
|
|
my $koha_news = Koha::AdditionalContents->search_for_display(
|
|
{
|
|
category => 'news',
|
|
location => ['opac_only', 'staff_and_opac'],
|
|
lang => $news_lang,
|
|
library_id => $branchcode,
|
|
}
|
|
);
|
|
|
|
$template->param( koha_news => $koha_news );
|
|
|
|
output_html_with_http_headers $input, $cookie, $template->output;
|