Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2e97532c

Von Jan Büren vor etwa 6 Jahren hinzugefügt

  • ID 2e97532c88dacf9523576df4028b6f7df5967ea8
  • Vorgänger c20a734c
  • Nachfolger 94a5c241

Fixt #349 (Normalisierung Artikel) - normalize_text_blocks nach Part-Controller migriert

Unterschiede anzeigen:

SL/Controller/Part.pm
42 42

  
43 43
__PACKAGE__->run_before('check_part_id', only   => [ qw(edit delete) ]);
44 44

  
45
__PACKAGE__->run_before('normalize_text_blocks');
46

  
45 47
# actions for editing parts
46 48
#
47 49
sub action_add_part {
......
1193 1195
  die "invalid part_type" unless $_[0] =~ /^(part|service|assembly|assortment)$/;
1194 1196
}
1195 1197

  
1198

  
1199
sub normalize_text_blocks {
1200
  my ($self) = @_;
1201

  
1202
  # check if feature is enabled (select normalize_part_descriptions from defaults)
1203
  return unless ($::instance_conf->get_normalize_part_descriptions);
1204

  
1205
  # text block
1206
  foreach (qw(description)) {
1207
    $self->part->{$_} =~ s/\s+$//s;
1208
    $self->part->{$_} =~ s/^\s+//s;
1209
    $self->part->{$_} =~ s/ {2,}/ /g;
1210
  }
1211
  # html block (caveat: can be circumvented by using bold or italics)
1212
  $self->part->{notes} =~ s/^<p>(&nbsp;)+\s+/<p>/s;
1213
  $self->part->{notes} =~ s/(&nbsp;)+<\/p>$/<\/p>/s;
1214

  
1215
}
1216

  
1196 1217
sub render_assortment_items_to_html {
1197 1218
  my ($self, $assortment_items, $number_of_items) = @_;
1198 1219

  
SL/IC.pm
954 954
  return %template_arrays;
955 955
}
956 956

  
957
sub normalize_text_blocks {
958
  $main::lxdebug->enter_sub();
959

  
960
  my $self     = shift;
961
  my %params   = @_;
962

  
963
  my $form     = $params{form}     || $main::form;
964

  
965
  # check if feature is enabled (select normalize_part_descriptions from defaults)
966
  return unless ($::instance_conf->get_normalize_part_descriptions);
967

  
968
  foreach (qw(description notes)) {
969
    $form->{$_} =~ s/\s+$//s;
970
    $form->{$_} =~ s/^\s+//s;
971
    $form->{$_} =~ s/ {2,}/ /g;
972
  }
973
   $main::lxdebug->leave_sub();
974
}
975

  
976

  
977 957
1;

Auch abrufbar als: Unified diff