# -- # Copyright (C) 2001-2019 OTRS AG, https://otrs.com/ # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see # the enclosed file COPYING for license information (GPL). If you # did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt. # -- package Kernel::Output::HTML::ITSMConfigItem::LayoutTextArea; use strict; use warnings; our @ObjectDependencies = ( 'Kernel::System::Log', 'Kernel::Output::HTML::Layout', 'Kernel::Config', 'Kernel::System::Web::Request' ); =head1 NAME Kernel::Output::HTML::ITSMConfigItem::LayoutTextArea - layout backend module =head1 DESCRIPTION All layout functions of textarea objects =head2 new() create an object $BackendObject = Kernel::Output::HTML::ITSMConfigItem::LayoutTextArea->new( %Param, ); =cut sub new { my ( $Type, %Param ) = @_; # allocate new hash for object my $Self = {}; bless( $Self, $Type ); return $Self; } =head2 OutputStringCreate() create output string my $Value = $BackendObject->OutputStringCreate( Value => 11, # (optional) Item => $ItemRef, ); =cut sub OutputStringCreate { my ( $Self, %Param ) = @_; # check needed stuff if ( !$Param{Item} ) { $Kernel::OM->Get('Kernel::System::Log')->Log( Priority => 'error', Message => 'Need Item!', ); return; } if ( !defined $Param{Value} ) { $Param{Value} = ''; } # get layout object my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout'); # translate if ( $Param{Item}->{Input}->{Translation} ) { $Param{Value} = $LayoutObject->{LanguageObject}->Translate( $Param{Value} ); } my $LinkFeature = 1; my $HTMLResultMode = 1; # do not transform links in print view if ( $Param{Print} ) { $LinkFeature = 0; $HTMLResultMode = 0; } # transform ascii to html $Param{Value} = $LayoutObject->Ascii2Html( Text => $Param{Value}, HTMLResultMode => $HTMLResultMode, LinkFeature => $LinkFeature, ); return $Param{Value}; } =head2 FormDataGet() get form data as hash reference my $FormDataRef = $BackendObject->FormDataGet( Key => 'Item::1::Node::3', Item => $ItemRef, ); =cut sub FormDataGet { my ( $Self, %Param ) = @_; # check needed stuff for my $Argument (qw(Key Item)) { if ( !$Param{$Argument} ) { $Kernel::OM->Get('Kernel::System::Log')->Log( Priority => 'error', Message => "Need $Argument!", ); return; } } my %FormData; # get form data $FormData{Value} = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} ); # set invalid param if ( $Param{Item}->{Input}->{Required} && !defined $FormData{Value} ) { $FormData{Invalid} = 1; $Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1; } # value was entered in the form, a regex is defined and the value does not match the regex if ( $FormData{Value} && $Param{Item}->{Input}->{RegEx} && $FormData{Value} !~ m{ $Param{Item}->{Input}->{RegEx} }xms ) { $FormData{Invalid} = 1; $Param{Item}->{Form}->{ $Param{Key} }->{Invalid} = 1; $Param{Item}->{Form}->{ $Param{Key} }->{RegExErrorMessage} = $Param{Item}->{Input}->{RegExErrorMessage}; } return \%FormData; } =head2 InputCreate() create a input string my $Value = $BackendObject->InputCreate( Key => 'Item::1::Node::3', Value => 11, # (optional) Item => $ItemRef, ); =cut sub InputCreate { my ( $Self, %Param ) = @_; # check needed stuff for my $Argument (qw(Key Item)) { if ( !$Param{$Argument} ) { $Kernel::OM->Get('Kernel::System::Log')->Log( Priority => 'error', Message => "Need $Argument!", ); return; } } my $Cols = $Param{Item}->{Input}->{Cols} || 58; my $Rows = $Param{Item}->{Input}->{Rows} || 10; my $Value = $Param{Value}; if ( !defined $Param{Value} ) { $Value = $Param{Item}->{Input}->{ValueDefault} || ''; } my $Class = 'W50pc'; my $Required = $Param{Required}; my $Invalid = $Param{Invalid}; my $ItemId = $Param{ItemId}; if ($Required) { $Class .= ' Validate_Required'; } if ($Invalid) { $Class .= ' ServerError'; } # translate if ( $Param{Item}->{Input}->{Translation} ) { $Value = $Kernel::OM->Get('Kernel::Output::HTML::Layout')->{LanguageObject}->Translate($Value); } my $String = ""; return $String; } =head2 SearchFormDataGet() get search form data my $Value = $BackendObject->SearchFormDataGet( Key => 'Item::1::Node::3', ); =cut sub SearchFormDataGet { my ( $Self, %Param ) = @_; # check needed stuff if ( !$Param{Key} ) { $Kernel::OM->Get('Kernel::System::Log')->Log( Priority => 'error', Message => 'Need Key!', ); return; } # get form data my $Value; if ( $Param{Value} ) { $Value = $Param{Value}; } else { $Value = $Kernel::OM->Get('Kernel::System::Web::Request')->GetParam( Param => $Param{Key} ); } return $Value; } =head2 SearchInputCreate() create a search input string my $Value = $BackendObject->SearchInputCreate( Key => 'Item::1::Node::3', Item => $ItemRef, ); =cut sub SearchInputCreate { my ( $Self, %Param ) = @_; # check needed stuff for my $Argument (qw(Key Item)) { if ( !$Param{$Argument} ) { $Kernel::OM->Get('Kernel::System::Log')->Log( Priority => 'error', Message => "Need $Argument!", ); return; } } my $Value = $Self->SearchFormDataGet(%Param); if ( !defined $Value ) { $Value = ''; } my $String = qq{}; return $String; } 1; =head1 TERMS AND CONDITIONS This software is part of the OTRS project (L). This software comes with ABSOLUTELY NO WARRANTY. For details, see the enclosed file COPYING for license information (GPL). If you did not receive this file, see L. =cut