From 52131da17ff7e648b2fc2f2f853e6082dfe238e5 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 14 Jan 2014 16:04:43 +0100 Subject: [PATCH] Artikelstammdaten: HTML in Langtexten nutzen --- SL/DB/Part.pm | 3 + SL/DB/Translation.pm | 7 +- SL/IC.pm | 6 +- bin/mozilla/ic.pl | 4 ++ templates/webpages/ic/form_header.html | 6 +- .../webpages/ic/parts_language_selection.html | 69 +++++++++++++++++++ .../webpages/ic/tabs/_edit_translations.html | 2 +- 7 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 templates/webpages/ic/parts_language_selection.html diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm index ecdaeaabe..89630ec6d 100644 --- a/SL/DB/Part.pm +++ b/SL/DB/Part.pm @@ -9,6 +9,7 @@ use SL::DBUtils; use SL::DB::MetaSetup::Part; use SL::DB::Manager::Part; use SL::DB::Chart; +use SL::DB::Helper::AttrHTML; use SL::DB::Helper::TransNumberGenerator; use SL::DB::Helper::CustomVariables ( module => 'IC', @@ -40,6 +41,8 @@ __PACKAGE__->meta->add_relationships( __PACKAGE__->meta->initialize; +__PACKAGE__->attr_html('notes'); + __PACKAGE__->before_save('_before_save_set_partnumber'); sub _before_save_set_partnumber { diff --git a/SL/DB/Translation.pm b/SL/DB/Translation.pm index 82362d406..5087ccced 100644 --- a/SL/DB/Translation.pm +++ b/SL/DB/Translation.pm @@ -1,15 +1,14 @@ -# This file has been auto-generated only because it didn't exist. -# Feel free to modify it at will; it will not be overwritten automatically. - package SL::DB::Translation; use strict; use SL::DB::MetaSetup::Translation; +use SL::DB::Helper::AttrHTML; __PACKAGE__->meta->initialize; -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; +__PACKAGE__->attr_html('longdescription'); + 1; diff --git a/SL/IC.pm b/SL/IC.pm index 649ad2fd0..191a2d300 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -40,6 +40,7 @@ use YAML; use SL::CVar; use SL::DBUtils; +use SL::HTML::Restrict; use SL::TransNumber; use strict; @@ -227,6 +228,7 @@ sub save { my @values; # connect to database, turn off AutoCommit my $dbh = $form->get_standard_dbh; + my $restricter = SL::HTML::Restrict->create; # save the part # make up a unique handle and store in partnumber field @@ -371,7 +373,7 @@ sub save { $form->{lastcost}, $form->{weight}, $form->{unit}, - $form->{notes}, + $restricter->process($form->{notes}), $form->{formel}, $form->{rop}, conv_i($form->{warehouse_id}), @@ -405,7 +407,7 @@ sub save { $sth = $dbh->prepare($query); foreach my $translation (@translations) { - do_statement($form, $sth, $query, conv_i($form->{id}), conv_i($translation->{language_id}), $translation->{translation}, $translation->{longdescription}); + do_statement($form, $sth, $query, conv_i($form->{id}), conv_i($translation->{language_id}), $translation->{translation}, $restricter->process($translation->{longdescription})); } $sth->finish(); diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index 473467b4e..3a97c8ecf 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -39,6 +39,7 @@ use SL::AM; use SL::CVar; use SL::IC; use SL::Helper::Flash; +use SL::HTML::Util; use SL::ReportGenerator; #use SL::PE; @@ -1382,6 +1383,8 @@ sub generate_report { } map { $row->{$_}{link} = $ref->{$_} } qw(drawing microfiche); + $row->{notes}{data} = SL::HTML::Util->strip($ref->{notes}); + $report->add_data($row); my $next_ref = $form->{parts}[$idx + 1]; @@ -1628,6 +1631,7 @@ sub form_header { CVar->render_inputs('variables' => $form->{CUSTOM_VARIABLES}, show_disabled_message => 1) if (scalar @{ $form->{CUSTOM_VARIABLES} }); + $::request->layout->use_javascript("${_}.js") for qw(ckeditor/ckeditor ckeditor/adapters/jquery); $form->header; #print $form->parse_html_template('ic/form_header', { ALL_PRICE_FACTORS => $form->{ALL_PRICE_FACTORS}, # ALL_UNITS => $form->{ALL_UNITS}, diff --git a/templates/webpages/ic/form_header.html b/templates/webpages/ic/form_header.html index 296cd1601..20ff5a995 100644 --- a/templates/webpages/ic/form_header.html +++ b/templates/webpages/ic/form_header.html @@ -1,6 +1,6 @@ [%- USE T8 %] [%- USE HTML %] -[%- USE LxERP %][%- USE L -%] +[%- USE LxERP %][%- USE L -%][%- USE P -%] [% PROCESS 'common/select_warehouse_bin.html' %]

[% title %] [% HTML.escape(partnumber) %] [% HTML.escape(description) %]

@@ -133,9 +133,9 @@ [% 'Part Notes' | $T8 %] [% 'Formula' | $T8 %] - + - + [% L.textarea_tag("notes", P.restricted_html(notes), class="texteditor", style="width: 600px; height: 200px") %] diff --git a/templates/webpages/ic/parts_language_selection.html b/templates/webpages/ic/parts_language_selection.html new file mode 100644 index 000000000..58e183287 --- /dev/null +++ b/templates/webpages/ic/parts_language_selection.html @@ -0,0 +1,69 @@ +[%- USE T8 %] +[%- USE HTML %][%- USE L -%][%- USE P -%] +
+ + + +
[% title %]
+ +

[% 'Please insert your language values below' | $T8 %]

+ +

+ + + + [%- FOREACH col = HEADER %] + + [%- END %] + + + [%- FOREACH row = LANGUAGES %] + + + + + + + [%- IF loop.last %] + + [%- END %] + [%- END %] +
 [% col.column_title %]
[% L.hidden_tag("id_" _ loop.count, row.id) %][% HTML.escape(row.description) %] + [%- IF row.translation_area %] + [% L.textarea_tag("translation_" _ loop.count, row.translation, rows=row.translation_rows, cols="40", wrap="soft") %] + [%- ELSE %] + [% L.input_tag("translation_" _ loop.count, row.translation) %] + [%- END %] + + [% L.textarea_tag("longdescription_" _ loop.count, P.restricted_html(row.longdescription), class="texteditor", style="width: 500px; height: 100px") %] +
+

+ +

+ +

+ +
+ + diff --git a/templates/webpages/ic/tabs/_edit_translations.html b/templates/webpages/ic/tabs/_edit_translations.html index 61884bf2f..1d0d6c18d 100644 --- a/templates/webpages/ic/tabs/_edit_translations.html +++ b/templates/webpages/ic/tabs/_edit_translations.html @@ -15,7 +15,7 @@ [% HTML.escape(language.description) %] [% L.input_tag("translations[].translation", translation.translation) %] - [% L.textarea_tag("translations[].longdescription", translation.longdescription, id="translations_longdescription_" _ language_id, style="width: 500px; height: 100px") %] + [% L.textarea_tag("translations[].longdescription", P.restricted_html(translation.longdescription), id="translations_longdescription_" _ language_id, class="texteditor", style="width: 500px; height: 100px") %] [%- END %] -- 2.20.1