diff --git a/lib/calcms/ListenerAccess.pm b/lib/calcms/ListenerAccess.pm index d109d8d..5951215 100644 --- a/lib/calcms/ListenerAccess.pm +++ b/lib/calcms/ListenerAccess.pm @@ -12,7 +12,7 @@ use Apache2::Connection (); use Apache2::Const -compile => qw(FORBIDDEN OK); sub handler { - my $r = shift; + my ($r) = @_; my $DAYS = 24 * 60 * 60; my $OK = Apache2::Const::OK; diff --git a/lib/calcms/aggregator.pm b/lib/calcms/aggregator.pm index 53acc65..20302d8 100644 --- a/lib/calcms/aggregator.pm +++ b/lib/calcms/aggregator.pm @@ -14,9 +14,7 @@ use Date::Calc; our @EXPORT_OK = qw(get_cache configure_cache put_cache get_list check_params); sub get_list($$) { - my $config = shift; - my $request = shift; - + my ($config, $request) = @_; my $params = $request->{params}->{checked}; #customize prefiltered request parameters @@ -63,10 +61,7 @@ sub get_list($$) { } sub get_menu($$$$) { - my $config = shift; - my $request = shift; - my $date = shift; - my $results = shift; + my ($config, $request, $date, $results) = @_; my $params = $request->{params}->{checked}; @@ -89,9 +84,7 @@ sub get_menu($$$$) { } sub get_calendar($$$) { - my $config = shift; - my $request = shift; - my $date = shift; + my ($config, $request, $date) = @_; my $params = $request->{params}->{checked}; @@ -114,8 +107,7 @@ sub get_calendar($$$) { } sub get_newest_comments($$) { - my $config = shift; - my $request = shift; + my ($config, $request) = @_; my $params = { template => 'comments_newest.html', diff --git a/lib/calcms/audio.pm b/lib/calcms/audio.pm index 3db95a9..7155f38 100644 --- a/lib/calcms/audio.pm +++ b/lib/calcms/audio.pm @@ -3,7 +3,7 @@ use warnings; use strict; sub durationToSeconds($) { - my $duration = shift; + my ($duration) = @_; if ( $duration =~ /(\d+):(\d\d):(\d\d).(\d\d)/ ) { return $1 * 3600 + $2 * 60 + $3 + $4 / 100; @@ -12,10 +12,7 @@ sub durationToSeconds($) { } sub formatDuration($$$;$) { - my $audioDuration = shift; - my $eventDuration = shift; - my $value = shift; - my $mouseOver = shift; + my ($audioDuration, $eventDuration, $value, $mouseOver) = @_; return '' unless $audioDuration; return '' unless $eventDuration; @@ -52,7 +49,8 @@ sub formatDuration($$$;$) { } sub formatChannels($) { - my $channels = shift; + my ($channels) = @_; + return '' unless $channels; my $class = "ok"; $class = "error" if $channels != 2; @@ -60,7 +58,8 @@ sub formatChannels($) { } sub formatSamplingRate($) { - my $samplingRate = shift; + my ($samplingRate) = @_; + return '' unless $samplingRate; my $class = "ok"; $class = "error" if $samplingRate != 44100; @@ -68,7 +67,8 @@ sub formatSamplingRate($) { } sub formatBitrate($) { - my $bitrate = shift; + my ($bitrate) = @_; + return '' unless $bitrate; my $class = 'ok'; $class = 'warn' if $bitrate >= 200; @@ -77,7 +77,8 @@ sub formatBitrate($) { } sub formatBitrateMode($) { - my $mode = shift; + my ($mode) = @_; + return '' unless $mode; my $class = 'ok'; $class = 'error' if $mode ne 'CBR'; @@ -85,9 +86,9 @@ sub formatBitrateMode($) { } sub formatLoudness { - my $value = shift; - my $prefix = shift || ''; - my $round = shift || ''; + my ($value, $prefix, $round) = @_; + $prefix ||= ''; + $round ||= ''; return '' unless $value; $value = sprintf( "%.1f", $value ); @@ -103,8 +104,7 @@ sub formatLoudness { } sub formatFile{ - my $file = shift; - my $event_id = shift; + my ($file, $event_id) = @_; return '' unless $file; diff --git a/lib/calcms/audio_recordings.pm b/lib/calcms/audio_recordings.pm index 58c4dcd..12328f2 100644 --- a/lib/calcms/audio_recordings.pm +++ b/lib/calcms/audio_recordings.pm @@ -24,8 +24,7 @@ sub get_columns($) { # get playout entries sub get($$) { - my $config = shift; - my $condition = shift; + my ($config, $condition) = @_; my $date_range_include = 0; $date_range_include = 1 diff --git a/lib/calcms/calendar.pm b/lib/calcms/calendar.pm index 73d84c6..0762fd1 100644 --- a/lib/calcms/calendar.pm +++ b/lib/calcms/calendar.pm @@ -27,8 +27,7 @@ sub get_cached_or_render($$$) { } sub get($$) { - my $config = shift; - my $request = shift; + my ($config, $request) = @_; my $params = $request->{params}->{checked}; my $language = $config->{date}->{language} || 'en'; @@ -315,8 +314,8 @@ sub get_calendar_weeks($$$) { } sub getWeeksOfMonth($$) { - my $thisYear = shift; - my $thisMonth = shift; + my ($thisYear, $thisMonth) = @_; + my $thisDay = 1; # get weekday of 1st of month diff --git a/lib/calcms/comments.pm b/lib/calcms/comments.pm index 5673604..915e56d 100644 --- a/lib/calcms/comments.pm +++ b/lib/calcms/comments.pm @@ -70,8 +70,7 @@ sub get_cached_or_render($$$;$) { } sub get($$) { - my $config = shift; - my $request = shift; + my ($config, $request) = @_; my $params = $request->{params}->{checked}; my $dbh = db::connect( $config, $request ); @@ -81,9 +80,7 @@ sub get($$) { } sub get_query($$$) { - my $dbh = shift; - my $config = shift; - my $request = shift; + my ($dbh, $config, $request) = @_; my $params = $request->{params}->{checked}; @@ -229,9 +226,7 @@ sub render($$$$) { #check if comment exists already sub check ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $query = qq{ select id @@ -259,9 +254,7 @@ sub check ($$$) { #used for insert sub get_level($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $parent_id = $comment->{parent_id}; return 0 unless defined $parent_id; @@ -294,9 +287,7 @@ sub get_level($$$) { } sub get_by_event($$$) { - my $dbh = shift; - my $config = shift; - my $request = $_[0]; + my ($dbh, $config, $request) = @_; my $params = $request->{params}->{checked}->{comment}; @@ -336,9 +327,7 @@ sub get_by_event($$$) { } sub get_by_time($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $where = ''; my $bind_values = []; @@ -375,10 +364,7 @@ sub get_by_time($$$) { } sub get_events($$$$) { - my $dbh = shift; - my $config = shift; - my $request = shift; - my $comments = shift; + my ($dbh, $config, $request, $comments) = @_; my $params = $request->{params}->{checked}->{comment}; @@ -438,9 +424,7 @@ sub get_events($$$$) { } sub insert ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; $comment->{level} = comments::get_level( $dbh, $config, $comment ); @@ -461,9 +445,7 @@ sub insert ($$$) { } sub set_lock_status ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $id = $comment->{id}; my $lock_status = $comment->{set_lock_status}; @@ -489,9 +471,7 @@ sub set_lock_status ($$$) { } sub set_news_status($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $id = $comment->{id}; my $news_status = $comment->{set_news_status}; @@ -505,9 +485,7 @@ sub set_news_status($$$) { } sub update_comment_count ($$$) { - my $dbh = shift; - my $config = shift; - my $comment = shift; + my ($dbh, $config, $comment) = @_; my $query = qq{ select count(id) count @@ -530,9 +508,7 @@ sub update_comment_count ($$$) { } sub sort_childs { - my $node = shift; - my $nodes = shift; - my $sorted_nodes = shift; + my ($node, $nodes, $sorted_nodes) = @_; #push node into list of sorted nodes push @{$sorted_nodes}, $node; @@ -549,8 +525,7 @@ sub sort_childs { #precondition: results are presorted by creation date (by sql) sub sort($$) { - my $config = shift; - my $results = shift; + my ($config, $results) = @_; #define parent nodes my $nodes = {}; @@ -578,8 +553,7 @@ sub sort($$) { } sub check_params ($$) { - my $config = shift; - my $params = shift; + my ($config, $params) = @_; my $comment = {}; $comment->{event_start} = ''; diff --git a/lib/calcms/config.pm b/lib/calcms/config.pm index 07ea1bf..a50b9be 100644 --- a/lib/calcms/config.pm +++ b/lib/calcms/config.pm @@ -14,7 +14,7 @@ my $config = undef; sub get($) { - my $filename = shift; + my ($filename) = @_; return read_config($filename); } @@ -25,7 +25,7 @@ sub getFromScriptLocation() { } sub read_config { - my $file = $_[0]; + my ($file) = @_; my $vars = {}; my @stack = (); diff --git a/lib/calcms/creole_wiki.pm b/lib/calcms/creole_wiki.pm index c5f35d7..71fe122 100644 --- a/lib/calcms/creole_wiki.pm +++ b/lib/calcms/creole_wiki.pm @@ -13,8 +13,7 @@ our @EXPORT_OK = #convert creole wiki text to event sub extractEventFromWikiText($;$) { - my $params = shift; - my $event = shift; + my ($params, $event) = @_; $event = {} unless defined $event; my $title = $params->{title} || ''; @@ -111,7 +110,7 @@ s/\{\{\s*thumbs\/+(.*?)\s*\|\s*(.*?)\s*\}\}/\[\[$local_media_url\/images\/$1\|\{ } sub eventToWikiText($$) { - my $event = shift; + my ($event) = @_; my $local_media_url = $event->{local_media_url} || ''; $event->{program} =~ s/^\s+|\s+$//g; @@ -163,8 +162,7 @@ s/\[\[.*?\/+media\/+images\/+(.*?)\s*\|.*?\{\{.*?\/+media\/+thumbs\/+(.*?)\s*\|\ #extrace meta tags from comment text sub extractMeta ($$) { - my $comments = shift; - my $meta = shift; + my ($comments, $meta) = @_; $meta = [] unless defined $meta; @@ -202,7 +200,8 @@ sub extractMeta ($$) { #remove meta tags from comment text sub removeMeta($) { - my $comments = shift || ''; + my ($comments) = @_; + $comments ||= ''; my $result = ''; for my $line ( split( /\n/, $comments ) ) { @@ -216,7 +215,7 @@ sub removeMeta($) { #add meta tags to comment text sub metaToWiki { - my $meta = shift; + my ($meta) = @_; my $result = ''; for my $pair (@$meta) { diff --git a/lib/calcms/db.pm b/lib/calcms/db.pm index f31965c..6d4ee4f 100644 --- a/lib/calcms/db.pm +++ b/lib/calcms/db.pm @@ -150,8 +150,7 @@ sub put($$$) { # deprecated sub quote($$) { - my $dbh = shift; - my $sql = shift; + my ($dbh, $sql) = @_; $sql =~ s/\_/\\\_/g; return $dbh->quote($sql); @@ -159,9 +158,7 @@ sub quote($$) { #subtract hours, deprecated(!) sub shift_date_by_hours($$$) { - my $dbh = shift; - my $date = shift; - my $offset = shift; + my ($dbh, $date, $offset) = @_; my $query = 'select date(? - INTERVAL ? HOUR) date'; my $bind_values = [ $date, $offset ]; @@ -171,9 +168,7 @@ sub shift_date_by_hours($$$) { #add minutes, deprecated(!) sub shift_datetime_by_minutes($$$) { - my $dbh = shift; - my $datetime = shift; - my $offset = shift; + my ($dbh, $datetime, $offset) = @_; my $query = "select ? + INTERVAL ? MINUTE date"; my $bind_values = [ $datetime, $offset ]; diff --git a/lib/calcms/event_history.pm b/lib/calcms/event_history.pm index fec59bb..48fafea 100644 --- a/lib/calcms/event_history.pm +++ b/lib/calcms/event_history.pm @@ -113,8 +113,7 @@ sub insert($$) { # insert event sub insert_by_event_id ($$){ - my $config = shift; - my $options = shift; + my ($config, $options) = @_; return undef unless defined $options->{project_id}; return undef unless defined $options->{studio_id}; diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index d5c0b77..27171c3 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -482,11 +482,10 @@ sub add_recurrence_dates { } sub calc_dates { - my $config = shift; - my $result = shift; - my $params = shift || {}; - my $previous_result = shift || {}; - my $time_diff = shift || ''; + my ($config, $result, $params, $previous_result, $time_diff) = @_; + $params ||= {}; + $previous_result ||= {}; + $time_diff ||= ''; $result->{utc_offset} = $time_diff; $result->{time_zone} = $config->{date}->{time_zone}; @@ -642,8 +641,7 @@ sub set_listen_key{ sub set_upload_status($$){ my ($config, $event) = @_; - - print STDERR "set upload_status=$event->{upload_status} for ".$event->{event_id}."\n"; + return undef unless defined $event->{event_id}; return undef unless defined $event->{upload_status}; my $bindValues = [ $event->{upload_status}, $event->{event_id}, $event->{upload_status} ]; @@ -1500,9 +1498,7 @@ sub get_by_image ($$$) { # deleting an event is currently disabled sub delete ($$$) { return; - my $request = shift; - my $config = shift; - my $event_id = shift; + my ($request, $config, $event_id) = @_; my $params = $request->{params}->{checked}; my $dbh = db::connect($config); @@ -1523,7 +1519,7 @@ sub delete ($$$) { sub get_duration ($$) { my ($config, $event) = @_; - + my $timezone = $config->{date}->{time_zone}; my $start = time::get_datetime( $event->{start}, $timezone ); my $end = time::get_datetime( $event->{end}, $timezone ); diff --git a/lib/calcms/images.pm b/lib/calcms/images.pm index bb46de1..4df699b 100644 --- a/lib/calcms/images.pm +++ b/lib/calcms/images.pm @@ -19,8 +19,7 @@ my $sql_columns = [ ]; sub get($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my @cond = (); my $bind_values = []; @@ -99,8 +98,7 @@ sub get($$) { } sub insert_or_update($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; $image->{name} = 'new' if $image->{name} eq ''; my $entry = get_by_filename( $dbh, $image->{filename} ); @@ -112,8 +110,7 @@ sub insert_or_update($$) { } sub insert ($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; my @sql_columns = @$sql_columns; @@ -154,8 +151,7 @@ sub insert ($$) { } sub update($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{studio_id} ) { print STDERR "missing studio_id at images::update\n"; @@ -213,8 +209,7 @@ sub update($$) { } sub delete($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{project_id} ) { print STDERR "missing project_id at images::delete\n"; @@ -252,11 +247,7 @@ sub delete($$) { # deactivated sub delete_files($$$$$) { - my $config = $_[0]; - my $local_media_dir = $_[1]; - my $filename = $_[2]; - my $action_result = $_[3]; - my $errors = $_[4]; + my ($config, $local_media_dir, $filename, $action_result, $errors) = @_; return undef; @@ -320,8 +311,7 @@ sub delete_file ($$$$) { } sub getPath { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $dir = $config->{locations}->{local_media_dir}; return undef unless defined $dir; @@ -340,8 +330,7 @@ sub getPath { } sub getInternalPath ($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; my $dir = $config->{locations}->{local_media_dir}; return undef unless defined $dir; @@ -360,14 +349,16 @@ sub getInternalPath ($$) { } sub normalizeName (;$) { - my $name = shift; + my ($name) = @_; + return undef unless defined $name; $name =~ s/.*\///g; return $name; } sub readFile($) { - my $path = shift; + my ($path) = @_; + my $content = ''; print STDERR "read '$path'\n"; @@ -382,8 +373,7 @@ sub readFile($) { } sub writeFile ($$) { - my $path = shift; - my $content = shift; + my ($path, $content) = @_; print STDERR "save '$path'\n"; open my $fh, '> :raw', $path or return { error => 'could not save image. ' . $! . " $path" }; @@ -394,7 +384,8 @@ sub writeFile ($$) { } sub deleteFile($) { - my $path = shift; + my ($path) = @_; + return { error => "source '$path' does not exist" } unless -e $path; #unlink $path; @@ -403,9 +394,7 @@ sub deleteFile($) { } sub copyFile ($$$) { - my $source = shift; - my $target = shift; - my $errors = shift; + my ($source, $target, $errors) = @_; my $read = images::readFile($source); return $read if defined $read->{error}; @@ -415,8 +404,7 @@ sub copyFile ($$$) { } sub publish($$) { - my $config = shift; - my $filename = shift; + my ($config, $filename) = @_; print STDERR "publish\n"; return undef unless defined $config; @@ -435,8 +423,7 @@ sub publish($$) { } sub depublish ($$) { - my $config = shift; - my $filename = shift; + my ($config, $filename) = @_; print STDERR "depublish\n"; return undef unless defined $config; @@ -468,8 +455,7 @@ sub checkLicence ($$) { } sub setEventLabels($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{project_id} ) { print STDERR "missing project_id at images::setEventLabels\n"; @@ -495,8 +481,7 @@ sub setEventLabels($$) { } sub setSeriesLabels($$) { - my $dbh = shift; - my $image = shift; + my ($dbh, $image) = @_; unless ( defined $image->{project_id} ) { print STDERR "missing project_id at images::setSeriesLabels\n"; diff --git a/lib/calcms/localization.pm b/lib/calcms/localization.pm index 74f277d..760cc5f 100644 --- a/lib/calcms/localization.pm +++ b/lib/calcms/localization.pm @@ -17,8 +17,7 @@ our @EXPORT_OK = qw(get getJavascript); # user : get from user settings # loc : add to existing localization, optional sub get($$) { - my $config = shift; - my $options = shift; + my ($config, $options) = @_; #get pot file unless ( defined $options->{file} ) { @@ -63,8 +62,7 @@ sub get($$) { } sub read_po_file($$) { - my $po_file = shift; - my $loc = shift; + my ($po_file, $loc) = @_; unless ( -e $po_file ) { print STDERR "po file $po_file does not exist\n"; @@ -99,7 +97,7 @@ sub read_po_file($$) { } sub getJavascript ($){ - my $loc = shift; + my ($loc) = @_; my $out = '