From: Jan Büren Date: Wed, 15 Jan 2014 13:57:16 +0000 (+0100) Subject: Zeilenumbrüche als letztes Zeichen bei part.description, part.notes beim Speichern... X-Git-Tag: release-3.1.0beta1~22^2~3 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=53fcb212544cf90957c5e6a3b3a1a36af395b273;p=kivitendo-erp.git Zeilenumbrüche als letztes Zeichen bei part.description, part.notes beim Speichern in DB verhindern closes #2011 Wie Wulf vorgeschlagen hat, werden alle whitespaces beim Beginn eines Textblocks und beim Ende eines Textblocks entfernt. Ferner werden mehrfach Wiederholungen von Leerzeichen innerhalb eines Blocks auf nur ein Leerzeichen reduziert. Konfigurierbar (Standard an). OFFEN: Bei CSV-Import wird dies noch nicht berücksichtigt --- diff --git a/SL/DB/MetaSetup/Default.pm b/SL/DB/MetaSetup/Default.pm index 0efdbe20e..48551285c 100644 --- a/SL/DB/MetaSetup/Default.pm +++ b/SL/DB/MetaSetup/Default.pm @@ -55,7 +55,7 @@ __PACKAGE__->meta->columns( language_id => { type => 'integer' }, max_future_booking_interval => { type => 'integer', default => 360 }, mtime => { type => 'timestamp' }, - # normalize_part_descriptions => { type => 'boolean', default => 'true' }, + normalize_part_descriptions => { type => 'boolean', default => 'true' }, normalize_vc_names => { type => 'boolean', default => 'true' }, parts_image_css => { type => 'text', default => 'border:0;float:left;max-width:250px;margin-top:20px:margin-right:10px;margin-left:10px;' }, parts_listing_image => { type => 'boolean', default => 'true' }, diff --git a/SL/IC.pm b/SL/IC.pm index d37f66f90..649ad2fd0 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -324,6 +324,8 @@ sub save { $subq_expense = "NULL"; } + normalize_text_blocks(); + $query = qq|UPDATE parts SET partnumber = ?, @@ -1697,5 +1699,24 @@ sub prepare_parts_for_printing { $main::lxdebug->leave_sub(); } +sub normalize_text_blocks { + $main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + my $form = $params{form} || $main::form; + + # check if feature is enabled (select normalize_part_descriptions from defaults) + return unless ($::instance_conf->get_normalize_part_descriptions); + + foreach (qw(description notes)) { + $form->{$_} =~ s/\s+$//s; + $form->{$_} =~ s/^\s+//s; + $form->{$_} =~ s/ {2,}/ /g; + } + $main::lxdebug->leave_sub(); +} + 1; diff --git a/templates/webpages/client_config/_features.html b/templates/webpages/client_config/_features.html index 3d3b21678..28a00ec24 100644 --- a/templates/webpages/client_config/_features.html +++ b/templates/webpages/client_config/_features.html @@ -44,11 +44,11 @@ [% L.input_tag('defaults.parts_image_css', SELF.defaults.parts_image_css, style=style) %] [% LxERP.t8('Style the picture with the following CSS code') %] - +