set parameter strings with entry::set_strings

This commit is contained in:
Milan
2020-03-08 14:16:58 +01:00
parent 94d4ca59d8
commit 07219ad3ee
4 changed files with 19 additions and 65 deletions

View File

@@ -392,22 +392,12 @@ sub check_params {
$checked->{create_events} = 0; $checked->{create_events} = 0;
$checked->{publish_events} = 0; $checked->{publish_events} = 0;
} }
for my $param ( 'frequency', 'duration', 'default_duration', 'create_events', 'publish_events', 'live', entry::set_numbers( $checked, $params, [
'count_episodes' ) 'frequency', 'duration', 'default_duration', 'create_events', 'publish_events', 'live']);
{
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
$checked->{$param} = $1;
}
}
#scalars #scalars
for my $param ( 'search', 'from', 'till' ) { entry::set_strings( $checked, $params,
if ( defined $params->{$param} ) { [ 'search', 'from', 'till' ]);
$checked->{$param} = $params->{$param};
$checked->{$param} =~ s/^\s+//g;
$checked->{$param} =~ s/\s+$//g;
}
}
return $checked; return $checked;
} }

View File

@@ -821,13 +821,9 @@ sub check_params {
} }
#scalars #scalars
for my $param ( 'studio', 'search', 'from', 'till', 'hide_series' ) { entry::set_strings( $checked, $params, [
if ( defined $params->{$param} ) { 'studio', 'search', 'from', 'till', 'hide_series'
$checked->{$param} = $params->{$param}; ]);
$checked->{$param} =~ s/^\s+//g;
$checked->{$param} =~ s/\s+$//g;
}
}
#numbers #numbers
for my $param ( 'duration', 'recurrence' ) { for my $param ( 'duration', 'recurrence' ) {
@@ -847,23 +843,13 @@ sub check_params {
} }
} }
#strings entry::set_strings( $checked, $params, [
for my $param (
'series_name', 'title', 'excerpt', 'content', 'series_name', 'title', 'excerpt', 'content',
'topic', 'program', 'category', 'image', 'topic', 'program', 'category', 'image',
'series_image', 'user_content', 'user_title', 'user_excerpt', 'series_image', 'user_content', 'user_title', 'user_excerpt',
'podcast_url', 'archive_url', 'setImage', 'content_format' 'podcast_url', 'archive_url', 'setImage', 'content_format'
) ]);
{
if ( defined $params->{$param} ) {
#$checked->{$param}=uri_unescape();
$checked->{$param} = $params->{$param};
$checked->{$param} =~ s/^\s+//g;
$checked->{$param} =~ s/\s+$//g;
}
}
#dates #dates
for my $param ( 'start_date', 'end_date' ) { for my $param ( 'start_date', 'end_date' ) {
if ( ( defined $params->{$param} ) if ( ( defined $params->{$param} )

View File

@@ -1469,15 +1469,11 @@ sub check_params {
]); ]);
#scalars #scalars
for my $param ( 'search', 'from', 'till', 'period_type' ) { entry::set_strings( $checked, $params,
if ( defined $params->{$param} ) { [ 'search', 'from', 'till', 'period_type' ]
$checked->{$param} = $params->{$param}; );
$checked->{$param} =~ s/^\s+//g;
$checked->{$param} =~ s/\s+$//g;
}
}
for my $param ( entry::set_strings( $checked, $params, [
'series_name', 'title', 'series_name', 'title',
'excerpt', 'content', 'excerpt', 'content',
'topic', 'image', 'topic', 'image',
@@ -1485,16 +1481,7 @@ sub check_params {
'assign_event_title', 'comment', 'assign_event_title', 'comment',
'podcast_url', 'archive_url', 'podcast_url', 'archive_url',
'setImage', 'content_format' 'setImage', 'content_format'
) ]);
{
if ( defined $params->{$param} ) {
#$checked->{$param}=uri_unescape();
$checked->{$param} = $params->{$param};
$checked->{$param} =~ s/^\s+//g;
$checked->{$param} =~ s/\s+$//g;
}
}
for my $attr ('start') { for my $attr ('start') {
if ( ( defined $params->{$attr} ) if ( ( defined $params->{$attr} )

View File

@@ -299,20 +299,11 @@ sub check_params {
$checked->{create_events} = 0; $checked->{create_events} = 0;
$checked->{publish_events} = 0; $checked->{publish_events} = 0;
} }
for my $param ( 'frequency', 'duration', 'default_duration' ) { entry::set_numbers( $checked, $params, [ 'frequency', 'duration', 'default_duration' ]);
if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /(\d+)/ ) ) {
$checked->{$param} = $1;
}
}
#scalars entry::set_strings( $checked, $params,
for my $param ( 'from', 'till', 'period_type', 'type', 'title' ) { [ 'from', 'till', 'period_type', 'type', 'title' ]
if ( defined $params->{$param} ) { );
$checked->{$param} = $params->{$param};
$checked->{$param} =~ s/^\s+//g;
$checked->{$param} =~ s/\s+$//g;
}
}
for my $attr ('start') { for my $attr ('start') {
if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/ ) ) { if ( ( defined $params->{$attr} ) && ( $params->{$attr} =~ /(\d\d\d\d\-\d\d\-\d\d[ T]\d\d\:\d\d)/ ) ) {