__PACKAGE__->run_before('check_part_id', only => [ qw(edit delete) ]);
+__PACKAGE__->run_before('normalize_text_blocks');
+
# actions for editing parts
#
sub action_add_part {
die "invalid part_type" unless $_[0] =~ /^(part|service|assembly|assortment)$/;
}
+
+sub normalize_text_blocks {
+ my ($self) = @_;
+
+ # check if feature is enabled (select normalize_part_descriptions from defaults)
+ return unless ($::instance_conf->get_normalize_part_descriptions);
+
+ # text block
+ foreach (qw(description)) {
+ $self->part->{$_} =~ s/\s+$//s;
+ $self->part->{$_} =~ s/^\s+//s;
+ $self->part->{$_} =~ s/ {2,}/ /g;
+ }
+ # html block (caveat: can be circumvented by using bold or italics)
+ $self->part->{notes} =~ s/^<p>( )+\s+/<p>/s;
+ $self->part->{notes} =~ s/( )+<\/p>$/<\/p>/s;
+
+}
+
sub render_assortment_items_to_html {
my ($self, $assortment_items, $number_of_items) = @_;
return %template_arrays;
}
-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;