diff --git a/legacy/application/common/WidgetHelper.php b/legacy/application/common/WidgetHelper.php index 72334d4a0..721640174 100644 --- a/legacy/application/common/WidgetHelper.php +++ b/legacy/application/common/WidgetHelper.php @@ -164,8 +164,9 @@ class WidgetHelper foreach ($arr as &$a) { if (is_array($a)) { if (array_key_exists('image_path', $a)) { - $a['image_path'] = $a['image_path'] && $a['image_path'] !== '' ? - Config::getPublicUrl() . 'api/show-logo?id=' . $a['id'] : ''; + $a['image_path'] = $a['image_path'] && $a['image_path'] !== '' + ? Config::getPublicUrl() . 'api/show-logo?id=' . $a['id'] + : ''; } else { self::findAndConvertPaths($a); } diff --git a/legacy/application/controllers/ApiController.php b/legacy/application/controllers/ApiController.php index a48d68915..2435929ea 100644 --- a/legacy/application/controllers/ApiController.php +++ b/legacy/application/controllers/ApiController.php @@ -824,12 +824,11 @@ class ApiController extends Zend_Controller_Action $endDateTime = clone $nowDateTime; $endDateTime = $endDateTime->add(new DateInterval('PT2H')); - $this->view->shows = - Application_Model_Show::getShows( - $nowDateTime, - $endDateTime, - $onlyRecord = true - ); + $this->view->shows = Application_Model_Show::getShows( + $nowDateTime, + $endDateTime, + $onlyRecord = true + ); $this->view->is_recording = false; $this->view->server_timezone = Application_Model_Preference::GetDefaultTimezone(); @@ -1048,8 +1047,7 @@ class ApiController extends Zend_Controller_Action $dir_id = $request->getParam('dir_id'); $all = $request->getParam('all'); - $this->view->files = - Application_Model_StoredFile::listAllFiles($dir_id, $all); + $this->view->files = Application_Model_StoredFile::listAllFiles($dir_id, $all); } public function getStreamSettingAction() @@ -1349,8 +1347,7 @@ class ApiController extends Zend_Controller_Action $streams = ['s1', 's2', 's3', 's4']; $stream_params = []; foreach ($streams as $s) { - $stream_params[$s] = - Application_Model_StreamSetting::getStreamDataNormalized($s); + $stream_params[$s] = Application_Model_StreamSetting::getStreamDataNormalized($s); } $this->view->stream_params = $stream_params; } diff --git a/legacy/application/controllers/LocaleController.php b/legacy/application/controllers/LocaleController.php index 4f91d3f4d..d5eb76f04 100644 --- a/legacy/application/controllers/LocaleController.php +++ b/legacy/application/controllers/LocaleController.php @@ -9,8 +9,8 @@ final class LocaleController extends Zend_Controller_Action header('Content-type: text/javascript'); $locale = Application_Model_Preference::GetLocale(); - echo 'var datatables_dict =' . - file_get_contents( + echo 'var datatables_dict =' + . file_get_contents( Application_Common_OsPath::join( // $_SERVER["DOCUMENT_ROOT"], dirname(__FILE__) . '/../../public/', // Fixing this... -- Albert diff --git a/legacy/application/controllers/PreferenceController.php b/legacy/application/controllers/PreferenceController.php index d31141bfb..fa2d8aadd 100644 --- a/legacy/application/controllers/PreferenceController.php +++ b/legacy/application/controllers/PreferenceController.php @@ -97,8 +97,9 @@ class PreferenceController extends Zend_Controller_Action // Append sharing token (download key) to Station podcast URL $stationPodcast = PodcastQuery::create()->findOneByDbId(Application_Model_Preference::getStationPodcastId()); $key = Application_Model_Preference::getStationPodcastDownloadKey(); - $url = Config::getPublicUrl() . - (((int) $values->stationPodcastPrivacy) ? "feeds/station-rss?sharing_token={$key}" : 'feeds/station-rss'); + $url = Config::getPublicUrl() . (((int) $values->stationPodcastPrivacy) + ? "feeds/station-rss?sharing_token={$key}" + : 'feeds/station-rss'); $stationPodcast->setDbUrl($url)->save(); Application_Model_Preference::setStationPodcastPrivacy($values->stationPodcastPrivacy); diff --git a/legacy/application/controllers/ScheduleController.php b/legacy/application/controllers/ScheduleController.php index 0816b06d3..c3092bf17 100644 --- a/legacy/application/controllers/ScheduleController.php +++ b/legacy/application/controllers/ScheduleController.php @@ -48,14 +48,14 @@ class ScheduleController extends Zend_Controller_Action $events = json_encode($scheduleController->view->events); $this->view->headScript()->appendScript( - "var calendarPref = {};\n" . - 'calendarPref.weekStart = ' . Application_Model_Preference::GetWeekStartDay() . ";\n" . - 'calendarPref.timestamp = ' . time() . ";\n" . - 'calendarPref.timezoneOffset = ' . Application_Common_DateHelper::getUserTimezoneOffset() . ";\n" . - "calendarPref.timeScale = '" . Application_Model_Preference::GetCalendarTimeScale() . "';\n" . - 'calendarPref.timeInterval = ' . Application_Model_Preference::GetCalendarTimeInterval() . ";\n" . - 'calendarPref.weekStartDay = ' . Application_Model_Preference::GetWeekStartDay() . ";\n" . - "var calendarEvents = {$events};" + "var calendarPref = {};\n" + . 'calendarPref.weekStart = ' . Application_Model_Preference::GetWeekStartDay() . ";\n" + . 'calendarPref.timestamp = ' . time() . ";\n" + . 'calendarPref.timezoneOffset = ' . Application_Common_DateHelper::getUserTimezoneOffset() . ";\n" + . "calendarPref.timeScale = '" . Application_Model_Preference::GetCalendarTimeScale() . "';\n" + . 'calendarPref.timeInterval = ' . Application_Model_Preference::GetCalendarTimeInterval() . ";\n" + . 'calendarPref.weekStartDay = ' . Application_Model_Preference::GetWeekStartDay() . ";\n" + . "var calendarEvents = {$events};" ); $this->view->headScript()->appendFile(Assets::url('js/contextmenu/jquery.contextMenu.js'), 'text/javascript'); @@ -385,13 +385,12 @@ class ScheduleController extends Zend_Controller_Action $originalDateTime = new DateTime($originalShowStart, new DateTimeZone('UTC')); $originalDateTime->setTimezone($displayTimeZone); - $this->view->additionalShowInfo = - sprintf( - _('Rebroadcast of show %s from %s at %s'), - $originalShowName, - $originalDateTime->format('l, F jS'), - $originalDateTime->format('G:i') - ); + $this->view->additionalShowInfo = sprintf( + _('Rebroadcast of show %s from %s at %s'), + $originalShowName, + $originalDateTime->format('l, F jS'), + $originalDateTime->format('G:i') + ); } $this->view->showLength = $show->getShowLength(); $this->view->timeFilled = $show->getTimeScheduled(); @@ -482,8 +481,7 @@ class ScheduleController extends Zend_Controller_Action $forms = $this->createShowFormAction(); - [$data, $validateStartDate, $validateStartTime, $originalShowStartDateTime] = - $service_showForm->preEditShowValidationCheck($data); + [$data, $validateStartDate, $validateStartTime, $originalShowStartDateTime] = $service_showForm->preEditShowValidationCheck($data); if ($service_showForm->validateShowForms( $forms, @@ -543,8 +541,7 @@ class ScheduleController extends Zend_Controller_Action $forms = $this->createShowFormAction(); - [$data, $validateStartDate, $validateStartTime, $originalShowStartDateTime] = - $service_showForm->preEditShowValidationCheck($data); + [$data, $validateStartDate, $validateStartTime, $originalShowStartDateTime] = $service_showForm->preEditShowValidationCheck($data); if ($service_showForm->validateShowForms( $forms, diff --git a/legacy/application/forms/AddShowWhen.php b/legacy/application/forms/AddShowWhen.php index 9aeb43e7f..c522eb8fa 100644 --- a/legacy/application/forms/AddShowWhen.php +++ b/legacy/application/forms/AddShowWhen.php @@ -234,10 +234,9 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } elseif ($formData['add_show_repeat_type'] == 2 && $formData['add_show_monthly_repeat_type'] == 2) { $interval = 'P1M'; } elseif ($formData['add_show_repeat_type'] == 2 && $formData['add_show_monthly_repeat_type'] == 3) { - [$weekNumberOfMonth, $dayOfWeek] = - Application_Service_ShowService::getMonthlyWeeklyRepeatInterval( - new DateTime($start_time, $showTimezone) - ); + [$weekNumberOfMonth, $dayOfWeek] = Application_Service_ShowService::getMonthlyWeeklyRepeatInterval( + new DateTime($start_time, $showTimezone) + ); } /* Check first show diff --git a/legacy/application/forms/SmartBlockCriteria.php b/legacy/application/forms/SmartBlockCriteria.php index c1d0f3df6..e353c53ad 100644 --- a/legacy/application/forms/SmartBlockCriteria.php +++ b/legacy/application/forms/SmartBlockCriteria.php @@ -78,11 +78,9 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm foreach ($criteria[$column] as &$constraint) { // convert to appropriate timezone timestamps only if the modifier is not a relative time if (!in_array($constraint['modifier'], ['before', 'after', 'between'])) { - $constraint['value'] = - Application_Common_DateHelper::UTCStringToUserTimezoneString($constraint['value']); + $constraint['value'] = Application_Common_DateHelper::UTCStringToUserTimezoneString($constraint['value']); if (isset($constraint['extra'])) { - $constraint['extra'] = - Application_Common_DateHelper::UTCStringToUserTimezoneString($constraint['extra']); + $constraint['extra'] = Application_Common_DateHelper::UTCStringToUserTimezoneString($constraint['extra']); } } } diff --git a/legacy/application/models/Block.php b/legacy/application/models/Block.php index 859f52546..2f3bee675 100644 --- a/legacy/application/models/Block.php +++ b/legacy/application/models/Block.php @@ -1661,9 +1661,9 @@ SQL; $limits['items'] = null; } } else { - $limits['time'] = $storedCrit['limit']['modifier'] == 'hours' ? - intval(floatval($storedCrit['limit']['value']) * 60 * 60) : - intval($storedCrit['limit']['value'] * 60); + $limits['time'] = $storedCrit['limit']['modifier'] == 'hours' + ? intval(floatval($storedCrit['limit']['value']) * 60 * 60) + : intval($storedCrit['limit']['value'] * 60); $limits['items'] = null; } } diff --git a/legacy/application/models/Playlist.php b/legacy/application/models/Playlist.php index 354270304..9416e12b0 100644 --- a/legacy/application/models/Playlist.php +++ b/legacy/application/models/Playlist.php @@ -410,31 +410,31 @@ SQL; $entry['cliplength'] = $obj->getDbLength(); if ($obj instanceof CcFiles && $obj) { - $entry['cuein'] = isset($p_item['cuein']) ? - $p_item['cuein'] : $obj->getDbCuein(); + $entry['cuein'] = isset($p_item['cuein']) + ? $p_item['cuein'] : $obj->getDbCuein(); - $entry['cueout'] = isset($p_item['cueout']) ? - $p_item['cueout'] : $obj->getDbCueout(); + $entry['cueout'] = isset($p_item['cueout']) + ? $p_item['cueout'] : $obj->getDbCueout(); - $cue_in = isset($p_item['cueInSec']) ? - $p_item['cueInSec'] : Application_Common_DateHelper::calculateLengthInSeconds($entry['cuein']); + $cue_in = isset($p_item['cueInSec']) + ? $p_item['cueInSec'] : Application_Common_DateHelper::calculateLengthInSeconds($entry['cuein']); - $cue_out = isset($p_item['cueOutSec']) ? - $p_item['cueOutSec'] : Application_Common_DateHelper::calculateLengthInSeconds($entry['cueout']); + $cue_out = isset($p_item['cueOutSec']) + ? $p_item['cueOutSec'] : Application_Common_DateHelper::calculateLengthInSeconds($entry['cueout']); - $entry['cliplength'] = isset($p_item['length']) ? - $p_item['length'] : Application_Common_DateHelper::secondsToPlaylistTime($cue_out - $cue_in); + $entry['cliplength'] = isset($p_item['length']) + ? $p_item['length'] : Application_Common_DateHelper::secondsToPlaylistTime($cue_out - $cue_in); } elseif ($obj instanceof CcWebstream && $obj) { $entry['cuein'] = '00:00:00'; $entry['cueout'] = $entry['cliplength']; } $entry['ftype'] = $objType; - $entry['fadein'] = isset($p_item['fadein']) ? - $p_item['fadein'] : $entry['fadein']; + $entry['fadein'] = isset($p_item['fadein']) + ? $p_item['fadein'] : $entry['fadein']; - $entry['fadeout'] = isset($p_item['fadeout']) ? - $p_item['fadeout'] : $entry['fadeout']; + $entry['fadeout'] = isset($p_item['fadeout']) + ? $p_item['fadeout'] : $entry['fadeout']; } return $entry; diff --git a/legacy/application/models/Preference.php b/legacy/application/models/Preference.php index 6f4f52e6b..6b0debcd9 100644 --- a/legacy/application/models/Preference.php +++ b/legacy/application/models/Preference.php @@ -65,8 +65,8 @@ class Application_Model_Preference // this case should not happen. $caller = debug_backtrace()[1]['function']; - throw new Exception('Invalid number of results returned. Should be ' . - "0 or 1, but is '{$result}' instead, caller={$caller}"); + throw new Exception('Invalid number of results returned. Should be ' + . "0 or 1, but is '{$result}' instead, caller={$caller}"); } if ($result == 1) { // result found @@ -896,9 +896,9 @@ class Application_Model_Preference public static function SetLatestLink($link) { - $pattern = '#^(http|https|ftp)://' . - '([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+' . - '(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#'; + $pattern = '#^(http|https|ftp)://' + . '([a-zA-Z0-9]+\.)*[a-zA-Z0-9]+' + . '(/[a-zA-Z0-9\-\.\_\~\:\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+)*/?$#'; if (preg_match($pattern, $link)) { self::setValue('latest_link', $link); } diff --git a/legacy/application/models/Scheduler.php b/legacy/application/models/Scheduler.php index 9c0b80d21..373024e31 100644 --- a/legacy/application/models/Scheduler.php +++ b/legacy/application/models/Scheduler.php @@ -667,8 +667,8 @@ final class Application_Model_Scheduler Application_Common_Database::SINGLE ); - $show_sql = 'SELECT * FROM cc_show WHERE id IN (' . - 'SELECT show_id FROM cc_show_instances WHERE id = ' . $ccSchedule['instance_id'] . ')'; + $show_sql = 'SELECT * FROM cc_show WHERE id IN (' + . 'SELECT show_id FROM cc_show_instances WHERE id = ' . $ccSchedule['instance_id'] . ')'; $ccShow = Application_Common_Database::prepareAndExecute( $show_sql, [], @@ -685,8 +685,8 @@ final class Application_Model_Scheduler } } } else { - $show_sql = 'SELECT * FROM cc_show WHERE id IN (' . - 'SELECT show_id FROM cc_show_instances WHERE id = ' . $schedule['instance'] . ')'; + $show_sql = 'SELECT * FROM cc_show WHERE id IN (' + . 'SELECT show_id FROM cc_show_instances WHERE id = ' . $schedule['instance'] . ')'; $ccShow = Application_Common_Database::prepareAndExecute( $show_sql, [], @@ -732,10 +732,10 @@ final class Application_Model_Scheduler */ $pos = $ccSchedule['position']; - $linkedItem_sql = 'SELECT ends FROM cc_schedule ' . - "WHERE instance_id = {$instanceId} " . - "AND position = {$pos} " . - 'AND playout_status != -1'; + $linkedItem_sql = 'SELECT ends FROM cc_schedule ' + . "WHERE instance_id = {$instanceId} " + . "AND position = {$pos} " + . 'AND playout_status != -1'; $linkedItemEnds = Application_Common_Database::prepareAndExecute( $linkedItem_sql, [], @@ -746,8 +746,8 @@ final class Application_Model_Scheduler // With dynamic smart blocks there may be different number of items in // each show. In case the position does not exist we need to select // the end time of the last position - $maxPos_sql = 'SELECT max(position) from cc_schedule ' . - "WHERE instance_id = {$instanceId}"; + $maxPos_sql = 'SELECT max(position) from cc_schedule ' + . "WHERE instance_id = {$instanceId}"; $pos = Application_Common_Database::prepareAndExecute( $maxPos_sql, [], @@ -759,10 +759,10 @@ final class Application_Model_Scheduler $pos = 0; $nextStartDT = new DateTime($instance->getDbStarts(), new DateTimeZone('UTC')); } else { - $linkedItem_sql = 'SELECT ends FROM cc_schedule ' . - "WHERE instance_id = {$instanceId} " . - "AND position = {$pos} " . - 'AND playout_status != -1'; + $linkedItem_sql = 'SELECT ends FROM cc_schedule ' + . "WHERE instance_id = {$instanceId} " + . "AND position = {$pos} " + . 'AND playout_status != -1'; $linkedItemEnds = Application_Common_Database::prepareAndExecute( $linkedItem_sql, [], @@ -849,8 +849,8 @@ final class Application_Model_Scheduler $adjustFromDT = clone $nextStartDT; $doUpdate = true; - $movedItem_sql = 'SELECT * FROM cc_schedule ' . - 'WHERE id = ' . $file['sched_id']; + $movedItem_sql = 'SELECT * FROM cc_schedule ' + . 'WHERE id = ' . $file['sched_id']; $sched = Application_Common_Database::prepareAndExecute( $movedItem_sql, [], @@ -870,9 +870,9 @@ final class Application_Model_Scheduler * relative item is by its position */ if ($linked) { - $movedItem_sql = 'SELECT * FROM cc_schedule ' . - "WHERE position = {$originalPosition} " . - "AND instance_id = {$instanceId}"; + $movedItem_sql = 'SELECT * FROM cc_schedule ' + . "WHERE position = {$originalPosition} " + . "AND instance_id = {$instanceId}"; $sched = Application_Common_Database::prepareAndExecute( $movedItem_sql, @@ -942,30 +942,30 @@ final class Application_Model_Scheduler $endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']); if ($doInsert) { - $values[] = '(' . - "'{$nextStartDT->format(DEFAULT_MICROTIME_FORMAT)}', " . - "'{$endTimeDT->format(DEFAULT_MICROTIME_FORMAT)}', " . - "'{$file['cuein']}', " . - "'{$file['cueout']}', " . - "'{$file['fadein']}', " . - "'{$file['fadeout']}', " . - "'{$file['cliplength']}', " . - "{$pos}, " . - "{$instanceId}, " . - "{$fileId}, " . - "{$streamId})"; + $values[] = '(' + . "'{$nextStartDT->format(DEFAULT_MICROTIME_FORMAT)}', " + . "'{$endTimeDT->format(DEFAULT_MICROTIME_FORMAT)}', " + . "'{$file['cuein']}', " + . "'{$file['cueout']}', " + . "'{$file['fadein']}', " + . "'{$file['fadeout']}', " + . "'{$file['cliplength']}', " + . "{$pos}, " + . "{$instanceId}, " + . "{$fileId}, " + . "{$streamId})"; } elseif ($doUpdate) { - $update_sql = 'UPDATE cc_schedule SET ' . - "starts = '{$nextStartDT->format(DEFAULT_MICROTIME_FORMAT)}', " . - "ends = '{$endTimeDT->format(DEFAULT_MICROTIME_FORMAT)}', " . - "cue_in = '{$file['cuein']}', " . - "cue_out = '{$file['cueout']}', " . - "fade_in = '{$file['fadein']}', " . - "fade_out = '{$file['fadeout']}', " . - "clip_length = '{$file['cliplength']}', " . - "position = {$pos}, " . - "instance_id = {$instanceId} " . - "WHERE id = {$sched['id']}"; + $update_sql = 'UPDATE cc_schedule SET ' + . "starts = '{$nextStartDT->format(DEFAULT_MICROTIME_FORMAT)}', " + . "ends = '{$endTimeDT->format(DEFAULT_MICROTIME_FORMAT)}', " + . "cue_in = '{$file['cuein']}', " + . "cue_out = '{$file['cueout']}', " + . "fade_in = '{$file['fadein']}', " + . "fade_out = '{$file['fadeout']}', " + . "clip_length = '{$file['cliplength']}', " + . "position = {$pos}, " + . "instance_id = {$instanceId} " + . "WHERE id = {$sched['id']}"; Application_Common_Database::prepareAndExecute( $update_sql, @@ -978,10 +978,10 @@ final class Application_Model_Scheduler ++$pos; } // all files have been inserted/moved if ($doInsert) { - $insert_sql = 'INSERT INTO cc_schedule ' . - '(starts, ends, cue_in, cue_out, fade_in, fade_out, ' . - 'clip_length, position, instance_id, file_id, stream_id) VALUES ' . - implode(',', $values) . ' RETURNING id'; + $insert_sql = 'INSERT INTO cc_schedule ' + . '(starts, ends, cue_in, cue_out, fade_in, fade_out, ' + . 'clip_length, position, instance_id, file_id, stream_id) VALUES ' + . implode(',', $values) . ' RETURNING id'; $stmt = $this->con->prepare($insert_sql); if ($stmt->execute()) { @@ -1006,9 +1006,9 @@ final class Application_Model_Scheduler } if ($adjustSched === true) { - $followingItems_sql = 'SELECT * FROM cc_schedule ' . - "WHERE starts >= '{$initalStartDT->format(DEFAULT_MICROTIME_FORMAT)}' " . - "AND instance_id = {$instanceId} "; + $followingItems_sql = 'SELECT * FROM cc_schedule ' + . "WHERE starts >= '{$initalStartDT->format(DEFAULT_MICROTIME_FORMAT)}' " + . "AND instance_id = {$instanceId} "; if (count($excludeIds) > 0) { $followingItems_sql .= 'AND id NOT IN (' . implode(',', $excludeIds) . ') '; } @@ -1023,11 +1023,11 @@ final class Application_Model_Scheduler foreach ($followingSchedItems as $item) { $endTimeDT = $this->findEndTime($nextStartDT, $item['clip_length']); $endTimeDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration); - $update_sql = 'UPDATE cc_schedule SET ' . - "starts = '{$nextStartDT->format(DEFAULT_MICROTIME_FORMAT)}', " . - "ends = '{$endTimeDT->format(DEFAULT_MICROTIME_FORMAT)}', " . - "position = {$pos} " . - "WHERE id = {$item['id']}"; + $update_sql = 'UPDATE cc_schedule SET ' + . "starts = '{$nextStartDT->format(DEFAULT_MICROTIME_FORMAT)}', " + . "ends = '{$endTimeDT->format(DEFAULT_MICROTIME_FORMAT)}', " + . "position = {$pos} " + . "WHERE id = {$item['id']}"; Application_Common_Database::prepareAndExecute( $update_sql, [], diff --git a/legacy/application/models/Show.php b/legacy/application/models/Show.php index 890e403a0..c4647d208 100644 --- a/legacy/application/models/Show.php +++ b/legacy/application/models/Show.php @@ -390,8 +390,8 @@ SQL; ); if ($overlapping) { - return _("Cannot schedule overlapping shows.\nNote: Resizing a repeating show " . - 'affects all of its repeats.'); + return _("Cannot schedule overlapping shows.\nNote: Resizing a repeating show " + . 'affects all of its repeats.'); } } @@ -399,11 +399,11 @@ SQL; $hours = ($hours > 0) ? floor($hours) : ceil($hours); $mins = abs($deltaMin % 60); - $sql_gen = 'UPDATE cc_show_instances ' . - 'SET ends = (ends + :deltaDay1::INTERVAL + :interval1::INTERVAL) ' . - 'WHERE (id IN (' . implode(',', $instanceIds) . ') ' . - 'AND ends > :current_timestamp1) ' . - "AND ((ends + :deltaDay2::INTERVAL + :interval2::INTERVAL - starts) <= interval '24:00')"; + $sql_gen = 'UPDATE cc_show_instances ' + . 'SET ends = (ends + :deltaDay1::INTERVAL + :interval1::INTERVAL) ' + . 'WHERE (id IN (' . implode(',', $instanceIds) . ') ' + . 'AND ends > :current_timestamp1) ' + . "AND ((ends + :deltaDay2::INTERVAL + :interval2::INTERVAL - starts) <= interval '24:00')"; Application_Common_Database::prepareAndExecute( $sql_gen, @@ -417,10 +417,10 @@ SQL; 'execute' ); - $sql_gen = 'UPDATE cc_show_days ' . - 'SET duration = (CAST(duration AS interval) + :deltaDay3::INTERVAL + :interval3::INTERVAL) ' . - 'WHERE id IN (' . implode(',', $showDayIds) . ') ' . - "AND ((CAST(duration AS interval) + :deltaDay4::INTERVAL + :interval4::INTERVAL) <= interval '24:00')"; + $sql_gen = 'UPDATE cc_show_days ' + . 'SET duration = (CAST(duration AS interval) + :deltaDay3::INTERVAL + :interval3::INTERVAL) ' + . 'WHERE id IN (' . implode(',', $showDayIds) . ') ' + . "AND ((CAST(duration AS interval) + :deltaDay4::INTERVAL + :interval4::INTERVAL) <= interval '24:00')"; Application_Common_Database::prepareAndExecute( $sql_gen, diff --git a/legacy/application/models/airtime/CcFiles.php b/legacy/application/models/airtime/CcFiles.php index 1e11572d3..337a0c9cf 100644 --- a/legacy/application/models/airtime/CcFiles.php +++ b/legacy/application/models/airtime/CcFiles.php @@ -464,18 +464,18 @@ class CcFiles extends BaseCcFiles // Remove invalid UTF-8 characters // reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ? $string = preg_replace( - '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' . - '|[\x00-\x7F][\x80-\xBF]+' . - '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' . - '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' . - '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', + '/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]' + . '|[\x00-\x7F][\x80-\xBF]+' + . '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*' + . '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})' + . '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', '?', $string ); // reject overly long 3 byte sequences and UTF-16 surrogates and replace with ? - $string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' . - '|\xED[\xA0-\xBF][\x80-\xBF]/S', '?', $string); + $string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]' + . '|\xED[\xA0-\xBF][\x80-\xBF]/S', '?', $string); // Do a final encoding conversion to return mb_convert_encoding($string, 'UTF-8', 'UTF-8'); diff --git a/legacy/application/services/HistoryService.php b/legacy/application/services/HistoryService.php index 813e93369..75d6f8aad 100644 --- a/legacy/application/services/HistoryService.php +++ b/legacy/application/services/HistoryService.php @@ -55,9 +55,9 @@ class Application_Service_HistoryService // ----------------------------------------------------------------------- // Using the instance_id to filter the data. - $historyRange = '(' . - 'SELECT history.starts, history.ends, history.id AS history_id, history.instance_id' . - ' FROM cc_playout_history as history'; + $historyRange = '(' + . 'SELECT history.starts, history.ends, history.id AS history_id, history.instance_id' + . ' FROM cc_playout_history as history'; if (isset($instanceId)) { $historyRange .= ' WHERE history.instance_id = :instance'; @@ -70,12 +70,12 @@ class Application_Service_HistoryService $historyRange .= ') AS history_range'; - $manualMeta = '(' . - 'SELECT %KEY%.value AS %KEY%, %KEY%.history_id' . - ' FROM (' . - ' SELECT * from cc_playout_history_metadata AS phm WHERE phm.key = :meta_%KEY%' . - ' ) AS %KEY%' . - ' ) AS %KEY%_filter'; + $manualMeta = '(' + . 'SELECT %KEY%.value AS %KEY%, %KEY%.history_id' + . ' FROM (' + . ' SELECT * from cc_playout_history_metadata AS phm WHERE phm.key = :meta_%KEY%' + . ' ) AS %KEY%' + . ' ) AS %KEY%_filter'; $mainSelect = [ 'history_range.starts', @@ -111,40 +111,39 @@ class Application_Service_HistoryService } // the files associated with scheduled playback in Airtime. - $historyFile = '(' . - 'SELECT history.id AS history_id, history.file_id' . - ' FROM cc_playout_history AS history' . - ' WHERE history.file_id IS NOT NULL' . - ') AS history_file'; + $historyFile = '(' + . 'SELECT history.id AS history_id, history.file_id' + . ' FROM cc_playout_history AS history' + . ' WHERE history.file_id IS NOT NULL' + . ') AS history_file'; - $fileMd = '(' . - 'SELECT %NON_NULL_FILE_SELECT%' . - ' FROM cc_files AS file' . - ') AS file_md'; + $fileMd = '(' + . 'SELECT %NON_NULL_FILE_SELECT%' + . ' FROM cc_files AS file' + . ') AS file_md'; $fileMd = str_replace('%NON_NULL_FILE_SELECT%', implode(', ', $nonNullFileSelect), $fileMd); // null files are from manually added data (filling in webstream info etc) - $nullFile = '(' . - 'SELECT history.id AS history_id' . - ' FROM cc_playout_history AS history' . - ' WHERE history.file_id IS NULL' . - ') AS null_file'; + $nullFile = '(' + . 'SELECT history.id AS history_id' + . ' FROM cc_playout_history AS history' + . ' WHERE history.file_id IS NULL' + . ') AS null_file'; // ---------------------------------- // building the file inner query - $fileSqlQuery = - 'SELECT ' . implode(', ', $fileSelect) . - " FROM {$historyFile}" . - " LEFT JOIN {$fileMd} USING (file_id)" . - ' UNION' . - ' SELECT ' . implode(', ', $nullFileSelect) . - " FROM {$nullFile}"; + $fileSqlQuery + = 'SELECT ' . implode(', ', $fileSelect) + . " FROM {$historyFile}" + . " LEFT JOIN {$fileMd} USING (file_id)" + . ' UNION' + . ' SELECT ' . implode(', ', $nullFileSelect) + . " FROM {$nullFile}"; foreach ($fileMdFilters as $filter) { - $fileSqlQuery .= - " LEFT JOIN {$filter} USING(history_id)"; + $fileSqlQuery .= " LEFT JOIN {$filter} USING(history_id)"; } } @@ -158,18 +157,18 @@ class Application_Service_HistoryService $mainSelect[] = "{$key}_filter.{$key}::{$type}"; } - $mainSqlQuery .= - 'SELECT ' . implode(', ', $mainSelect) . - " FROM {$historyRange}"; + $mainSqlQuery + .= 'SELECT ' . implode(', ', $mainSelect) + . " FROM {$historyRange}"; if (isset($fileSqlQuery)) { - $mainSqlQuery .= - " LEFT JOIN ( {$fileSqlQuery} ) as file_info USING(history_id)"; + $mainSqlQuery + .= " LEFT JOIN ( {$fileSqlQuery} ) as file_info USING(history_id)"; } foreach ($mdFilters as $filter) { - $mainSqlQuery .= - " LEFT JOIN {$filter} USING(history_id)"; + $mainSqlQuery + .= " LEFT JOIN {$filter} USING(history_id)"; } // ---------------------------------------------------------------------- @@ -216,8 +215,8 @@ class Application_Service_HistoryService if (count($orderBys) > 0) { $orders = implode(', ', $orderBys); - $mainSqlQuery .= - " ORDER BY {$orders}"; + $mainSqlQuery + .= " ORDER BY {$orders}"; } // --------------------------------------------------------------- @@ -226,8 +225,8 @@ class Application_Service_HistoryService $displayLength = empty($opts['iDisplayLength']) ? -1 : intval($opts['iDisplayLength']); // limit the results returned. if ($displayLength !== -1) { - $mainSqlQuery .= - ' OFFSET :offset LIMIT :limit'; + $mainSqlQuery + .= ' OFFSET :offset LIMIT :limit'; $paramMap['offset'] = intval($opts['iDisplayStart']); $paramMap['limit'] = $displayLength; @@ -339,9 +338,9 @@ class Application_Service_HistoryService ) AS playout LEFT JOIN cc_files AS file ON (file.id = playout.file_id)) AS summary'; - $mainSqlQuery .= - 'SELECT ' . implode(', ', $select) . - " FROM {$fileSummaryTable}"; + $mainSqlQuery + .= 'SELECT ' . implode(', ', $select) + . " FROM {$fileSummaryTable}"; // ------------------------------------------------------------------------- // need to count the total rows to tell Datatables. @@ -375,16 +374,16 @@ class Application_Service_HistoryService if ($numOrderColumns > 0) { $orders = implode(', ', $orderBys); - $mainSqlQuery .= - " ORDER BY {$orders}"; + $mainSqlQuery + .= " ORDER BY {$orders}"; } // ------------------------------------------------------------ // using datatables params to add limits/offsets $displayLength = intval($opts['iDisplayLength']); if ($displayLength !== -1) { - $mainSqlQuery .= - ' OFFSET :offset LIMIT :limit'; + $mainSqlQuery + .= ' OFFSET :offset LIMIT :limit'; $paramMap['offset'] = $opts['iDisplayStart']; $paramMap['limit'] = $displayLength; diff --git a/legacy/application/services/PodcastEpisodeService.php b/legacy/application/services/PodcastEpisodeService.php index a0b25532e..e3d803c74 100644 --- a/legacy/application/services/PodcastEpisodeService.php +++ b/legacy/application/services/PodcastEpisodeService.php @@ -466,8 +466,9 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir // Logging::info($enclosure); $itemId = $item->get_id(); $ingested = in_array($itemId, $episodeIds) ? (empty($episodeFiles[$itemId]) ? -1 : 1) : 0; - $file = $ingested > 0 && !empty($episodeFiles[$itemId]) ? - CcFiles::getSanitizedFileById($episodeFiles[$itemId]) : []; + $file = $ingested > 0 && !empty($episodeFiles[$itemId]) + ? CcFiles::getSanitizedFileById($episodeFiles[$itemId]) + : []; // If the analyzer hasn't finished with the file, leave it as pending if (!empty($file) && $file['import_status'] == CcFiles::IMPORT_STATUS_PENDING) { $ingested = -1; diff --git a/legacy/application/services/SchedulerService.php b/legacy/application/services/SchedulerService.php index e8806ab60..a52f3c76d 100644 --- a/legacy/application/services/SchedulerService.php +++ b/legacy/application/services/SchedulerService.php @@ -189,8 +189,8 @@ class Application_Service_SchedulerService } $linkedShowSchedule_sql = $con->prepare( - 'select * from cc_schedule where instance_id = :instance_id ' . - 'order by starts' + 'select * from cc_schedule where instance_id = :instance_id ' + . 'order by starts' ); $linkedShowSchedule_sql->bindParam(':instance_id', $instanceId); $linkedShowSchedule_sql->execute(); @@ -216,8 +216,8 @@ class Application_Service_SchedulerService // get time_filled so we can update cc_show_instances if (!empty($linkedShowSchedule)) { - $timeFilled_sql = 'SELECT time_filled FROM cc_show_instances ' . - "WHERE id = {$linkedShowSchedule[0]['instance_id']}"; + $timeFilled_sql = 'SELECT time_filled FROM cc_show_instances ' + . "WHERE id = {$linkedShowSchedule[0]['instance_id']}"; $timeFilled = Application_Common_Database::prepareAndExecute( $timeFilled_sql, [], @@ -245,8 +245,8 @@ class Application_Service_SchedulerService self::clearShowInstanceContents($id); // Now fill the show instance with the same content that $linkedShowSchedule has. - $instanceStart_sql = 'SELECT starts FROM cc_show_instances ' . - "WHERE id = {$id} " . 'ORDER BY starts'; + $instanceStart_sql = 'SELECT starts FROM cc_show_instances ' + . "WHERE id = {$id} " . 'ORDER BY starts'; // What's tricky here is that when we copy the content, we have to adjust // the start and end times of each track so they're inside the new show instance's time slot. @@ -275,13 +275,13 @@ class Application_Service_SchedulerService $item['stream_id'] = 'null'; } - $values[] = '(' . "'{$nextStartDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " . - "'{$endTimeDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " . - "'{$item['clip_length']}', " . - "'{$item['fade_in']}', '{$item['fade_out']}', " . - "'{$item['cue_in']}', '{$item['cue_out']}', " . - "{$item['file_id']}, {$item['stream_id']}, " . - "{$id}, {$item['position']})"; + $values[] = '(' . "'{$nextStartDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " + . "'{$endTimeDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " + . "'{$item['clip_length']}', " + . "'{$item['fade_in']}', '{$item['fade_out']}', " + . "'{$item['cue_in']}', '{$item['cue_out']}', " + . "{$item['file_id']}, {$item['stream_id']}, " + . "{$id}, {$item['position']})"; $nextStartDT = self::findTimeDifference( $endTimeDT, @@ -290,10 +290,10 @@ class Application_Service_SchedulerService } // foreach show item if (!empty($values)) { - $insert_sql = 'INSERT INTO cc_schedule (starts, ends, ' . - 'clip_length, fade_in, fade_out, cue_in, cue_out, ' . - 'file_id, stream_id, instance_id, position) VALUES ' . - implode(',', $values); + $insert_sql = 'INSERT INTO cc_schedule (starts, ends, ' + . 'clip_length, fade_in, fade_out, cue_in, cue_out, ' + . 'file_id, stream_id, instance_id, position) VALUES ' + . implode(',', $values); Application_Common_Database::prepareAndExecute( $insert_sql, [], diff --git a/legacy/application/services/ShowFormService.php b/legacy/application/services/ShowFormService.php index d2a68404d..43e452011 100644 --- a/legacy/application/services/ShowFormService.php +++ b/legacy/application/services/ShowFormService.php @@ -364,8 +364,8 @@ class Application_Service_ShowFormService private function populateFormStyle($form) { - $src = $this->ccShow->getDbImagePath() ? - $this->imagePathToDataUri($this->ccShow->getDbImagePath()) : ''; + $src = $this->ccShow->getDbImagePath() + ? $this->imagePathToDataUri($this->ccShow->getDbImagePath()) : ''; $form->populate( [ @@ -405,8 +405,8 @@ class Application_Service_ShowFormService } // return the data URI - data:{mime};base64,{data} - return ($imageData === null || $imageData === '') ? - '' : 'data: ' . mime_content_type($path) . ';base64,' . $imageData; + return ($imageData === null || $imageData === '') + ? '' : 'data: ' . mime_content_type($path) . ';base64,' . $imageData; } private function populateFormLive($form) diff --git a/legacy/application/services/ShowService.php b/legacy/application/services/ShowService.php index be61e71ec..0594b20e0 100644 --- a/legacy/application/services/ShowService.php +++ b/legacy/application/services/ShowService.php @@ -77,8 +77,9 @@ class Application_Service_ShowService // DateTime in shows's local time $newStartDateTime = new DateTime( - $showData['add_show_start_date'] . ' ' . - $showData['add_show_start_time'], + $showData['add_show_start_date'] + . ' ' + . $showData['add_show_start_time'], new DateTimeZone($showData['add_show_timezone']) ); @@ -1055,8 +1056,9 @@ SQL; $showId = $this->ccShow->getDbId(); // DateTime in show's local time $newStartDateTime = new DateTime( - $showData['add_show_start_date'] . ' ' . - $showData['add_show_start_time'], + $showData['add_show_start_date'] + . ' ' + . $showData['add_show_start_time'], new DateTimeZone($showData['add_show_timezone']) ); @@ -1333,10 +1335,9 @@ SQL; } // We will only need this if the repeat type is MONTHLY_WEEKLY - [$weekNumberOfMonth, $dayOfWeek] = - self::getMonthlyWeeklyRepeatInterval( - new DateTime($first_show, new DateTimeZone($timezone)) - ); + [$weekNumberOfMonth, $dayOfWeek] = self::getMonthlyWeeklyRepeatInterval( + new DateTime($first_show, new DateTimeZone($timezone)) + ); $this->repeatType = $showDay->getDbRepeatType(); @@ -1520,8 +1521,8 @@ SQL; $tempDT = clone $dt; $fifthWeekExists = false; do { - $nextDT = date_create($weekNumberOfMonth . ' ' . $dayOfWeek . - ' of ' . $tempDT->format('F') . ' ' . $tempDT->format('Y')); + $nextDT = date_create($weekNumberOfMonth . ' ' . $dayOfWeek + . ' of ' . $tempDT->format('F') . ' ' . $tempDT->format('Y')); $nextDT->setTimezone(new DateTimeZone($timezone)); /* We have to check if the next date is in the same month in case @@ -1918,8 +1919,8 @@ SQL; if (isset($offset)) { // $offset["hours"] and $offset["mins"] represents the start time // of a rebroadcast show - $startDateTime = new DateTime($startDateTime->format('Y-m-d') . ' ' . - $offset['hours'] . ':' . $offset['mins'], $timezone); + $startDateTime = new DateTime($startDateTime->format('Y-m-d') . ' ' + . $offset['hours'] . ':' . $offset['mins'], $timezone); $startDateTime->add(new DateInterval("P{$offset['days']}D")); } diff --git a/legacy/tests/application/helpers/AirtimeInstall.php b/legacy/tests/application/helpers/AirtimeInstall.php index 19427572b..f55056355 100644 --- a/legacy/tests/application/helpers/AirtimeInstall.php +++ b/legacy/tests/application/helpers/AirtimeInstall.php @@ -131,8 +131,8 @@ class AirtimeInstall } catch (Exception $e) { echo $e->getMessage() . PHP_EOL; echo 'Database connection problem.' . PHP_EOL; - echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists" . - ' with corresponding permissions.' . PHP_EOL; + echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists" + . ' with corresponding permissions.' . PHP_EOL; if ($p_exitOnError) { exit(1); } diff --git a/legacy/tools/composer.json b/legacy/tools/composer.json index b1c79995c..dd50843de 100644 --- a/legacy/tools/composer.json +++ b/legacy/tools/composer.json @@ -1,6 +1,6 @@ { "require-dev": { "php": "^7.4", - "friendsofphp/php-cs-fixer": "<3.64.1" + "friendsofphp/php-cs-fixer": "<3.85.2" } }