style(legacy): format files (#1946)

This commit is contained in:
Jonas L 2022-07-07 20:01:15 +02:00 committed by GitHub
parent eb19283d96
commit 4d393fa14e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 775 additions and 565 deletions

View file

@ -46,19 +46,22 @@ class Application_Service_CalendarService
if (!isset($ccFile)) {
$menu['error when recording'] = [
'name' => _("Record file doesn't exist"),
'icon' => 'error', ];
'icon' => 'error',
];
} else {
$menu['view_recorded'] = [
'name' => _('View Recorded File Metadata'),
'icon' => 'overview',
'url' => $baseUrl . 'library/edit-file-md/id/' . $ccFile->getDbId(), ];
'url' => $baseUrl . 'library/edit-file-md/id/' . $ccFile->getDbId(),
];
}
} else {
$menu['content'] = [
// "name"=> _("Show Content"),
'name' => _('View'),
'icon' => 'overview',
'url' => $baseUrl . 'schedule/show-content-dialog', ];
'url' => $baseUrl . 'schedule/show-content-dialog',
];
}
} else {
// Show content can be modified from the calendar if:
@ -77,7 +80,8 @@ class Application_Service_CalendarService
// "name"=> _("Add / Remove Content"),
'name' => _('Schedule Tracks'),
'icon' => 'add-remove-content',
'url' => $baseUrl . 'showbuilder/builder-dialog/', ];
'url' => $baseUrl . 'showbuilder/builder-dialog/',
];
}
}
@ -88,7 +92,8 @@ class Application_Service_CalendarService
// "name"=> _("Show Content"),
'name' => _('View'),
'icon' => 'overview',
'url' => $baseUrl . 'schedule/show-content-dialog', ];
'url' => $baseUrl . 'schedule/show-content-dialog',
];
}
// user can remove all content if the show has not started
@ -100,7 +105,8 @@ class Application_Service_CalendarService
// "name"=> _("Remove All Content"),
'name' => _('Clear Show'),
'icon' => 'remove-all-content',
'url' => $baseUrl . 'schedule/clear-show', ];
'url' => $baseUrl . 'schedule/clear-show',
];
}
}
@ -113,12 +119,14 @@ class Application_Service_CalendarService
$menu['cancel_recorded'] = [
// "name"=> _("Cancel Current Show"),
'name' => _('Cancel Show'),
'icon' => 'delete', ];
'icon' => 'delete',
];
} else {
$menu['cancel'] = [
// "name"=> _("Cancel Current Show"),
'name' => _('Cancel Show'),
'icon' => 'delete', ];
'icon' => 'delete',
];
}
}
@ -167,7 +175,8 @@ class Application_Service_CalendarService
'name' => _('Edit Show'),
'icon' => 'edit',
'_type' => 'all',
'url' => $baseUrl . 'Schedule/populate-show-form', ];
'url' => $baseUrl . 'Schedule/populate-show-form',
];
}
}
@ -182,29 +191,34 @@ class Application_Service_CalendarService
$menu['del'] = [
'name' => _('Delete'),
'icon' => 'delete',
'items' => [], ];
'items' => [],
];
$menu['del']['items']['single'] = [
// "name"=> _("Delete This Instance"),
'name' => _('Delete Instance'),
'icon' => 'delete',
'url' => $baseUrl . 'schedule/delete-show-instance', ];
'url' => $baseUrl . 'schedule/delete-show-instance',
];
$menu['del']['items']['following'] = [
// "name"=> _("Delete This Instance and All Following"),
'name' => _('Delete Instance and All Following'),
'icon' => 'delete',
'url' => $baseUrl . 'schedule/delete-show', ];
'url' => $baseUrl . 'schedule/delete-show',
];
} elseif ($populateInstance) {
$menu['del'] = [
'name' => _('Delete'),
'icon' => 'delete',
'url' => $baseUrl . 'schedule/delete-show-instance', ];
'url' => $baseUrl . 'schedule/delete-show-instance',
];
} else {
$menu['del'] = [
'name' => _('Delete'),
'icon' => 'delete',
'url' => $baseUrl . 'schedule/delete-show', ];
'url' => $baseUrl . 'schedule/delete-show',
];
}
}
}

View file

@ -56,8 +56,8 @@ 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';
'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';
@ -71,11 +71,11 @@ 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';
'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',
@ -112,39 +112,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';
'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';
'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';
'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}";
'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)";
" LEFT JOIN {$filter} USING(history_id)";
}
}
@ -159,17 +159,17 @@ class Application_Service_HistoryService
}
$mainSqlQuery .=
'SELECT ' . implode(', ', $mainSelect) .
" FROM {$historyRange}";
'SELECT ' . implode(', ', $mainSelect) .
" FROM {$historyRange}";
if (isset($fileSqlQuery)) {
$mainSqlQuery .=
" LEFT JOIN ( {$fileSqlQuery} ) as file_info USING(history_id)";
" LEFT JOIN ( {$fileSqlQuery} ) as file_info USING(history_id)";
}
foreach ($mdFilters as $filter) {
$mainSqlQuery .=
" LEFT JOIN {$filter} USING(history_id)";
" LEFT JOIN {$filter} USING(history_id)";
}
// ----------------------------------------------------------------------
@ -217,7 +217,7 @@ class Application_Service_HistoryService
$orders = implode(', ', $orderBys);
$mainSqlQuery .=
" ORDER BY {$orders}";
" ORDER BY {$orders}";
}
// ---------------------------------------------------------------
@ -227,7 +227,7 @@ class Application_Service_HistoryService
// limit the results returned.
if ($displayLength !== -1) {
$mainSqlQuery .=
' OFFSET :offset LIMIT :limit';
' OFFSET :offset LIMIT :limit';
$paramMap['offset'] = intval($opts['iDisplayStart']);
$paramMap['limit'] = $displayLength;
@ -340,8 +340,8 @@ class Application_Service_HistoryService
LEFT JOIN cc_files AS file ON (file.id = playout.file_id)) AS summary';
$mainSqlQuery .=
'SELECT ' . implode(', ', $select) .
" FROM {$fileSummaryTable}";
'SELECT ' . implode(', ', $select) .
" FROM {$fileSummaryTable}";
// -------------------------------------------------------------------------
// need to count the total rows to tell Datatables.
@ -376,7 +376,7 @@ class Application_Service_HistoryService
$orders = implode(', ', $orderBys);
$mainSqlQuery .=
" ORDER BY {$orders}";
" ORDER BY {$orders}";
}
// ------------------------------------------------------------
@ -384,7 +384,7 @@ class Application_Service_HistoryService
$displayLength = intval($opts['iDisplayLength']);
if ($displayLength !== -1) {
$mainSqlQuery .=
' OFFSET :offset LIMIT :limit';
' OFFSET :offset LIMIT :limit';
$paramMap['offset'] = $opts['iDisplayStart'];
$paramMap['limit'] = $displayLength;

View file

@ -189,7 +189,8 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
'api_key' => $CC_CONFIG['apiKey'][0],
'podcast_name' => $title,
'album_override' => $album_override,
'track_title' => $track_title, ];
'track_title' => $track_title,
];
$task = $this->_executeTask(static::$_CELERY_TASKS[self::DOWNLOAD], $data);
// Get the created ThirdPartyTaskReference and set the episode ID so
// we can remove the placeholder if the import ends up stuck in a pending state
@ -378,7 +379,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir
->find();
return $isStationPodcast ? $this->_getStationPodcastEpisodeArray($episodes)
: $this->_getImportedPodcastEpisodeArray($podcast, $episodes);
: $this->_getImportedPodcastEpisodeArray($podcast, $episodes);
}
/**

View file

@ -190,7 +190,7 @@ class Application_Service_SchedulerService
$linkedShowSchedule_sql = $con->prepare(
'select * from cc_schedule where instance_id = :instance_id ' .
'order by starts'
'order by starts'
);
$linkedShowSchedule_sql->bindParam(':instance_id', $instanceId);
$linkedShowSchedule_sql->execute();
@ -217,7 +217,7 @@ 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']}";
"WHERE id = {$linkedShowSchedule[0]['instance_id']}";
$timeFilled = Application_Common_Database::prepareAndExecute(
$timeFilled_sql,
[],

View file

@ -67,16 +67,20 @@ class Application_Service_ShowFormService
public function populateNewShowForms($formWhat, $formWhen, $formRepeats)
{
$formWhat->populate(
['add_show_id' => '-1',
'add_show_instance_id' => '-1', ]
[
'add_show_id' => '-1',
'add_show_instance_id' => '-1',
]
);
$formWhen->populate(
['add_show_start_date' => date('Y-m-d'),
[
'add_show_start_date' => date('Y-m-d'),
'add_show_start_time' => '00:00',
'add_show_end_date_no_repeate' => date('Y-m-d'),
'add_show_end_time' => '01:00',
'add_show_duration' => '01h 00m', ]
'add_show_duration' => '01h 00m',
]
);
$formRepeats->populate(['add_show_end_date' => date('Y-m-d')]);
@ -204,7 +208,8 @@ class Application_Service_ShowFormService
'add_show_end_time' => $showEnd->format('H:i'),
'add_show_duration' => $ccShowDay->formatDuration(true),
'add_show_timezone' => $ccShowDay->getDbTimezone(),
'add_show_repeats' => $ccShowDay->isRepeating() ? 1 : 0, ]
'add_show_repeats' => $ccShowDay->isRepeating() ? 1 : 0,
]
);
return $showStart;
@ -269,7 +274,8 @@ class Application_Service_ShowFormService
$timezone
),
'add_show_timezone' => $timezone,
'add_show_repeats' => 0, ]
'add_show_repeats' => 0,
]
);
$form->getElement('add_show_repeats')->setOptions(['disabled' => true]);
@ -321,7 +327,8 @@ class Application_Service_ShowFormService
'add_show_day_check' => $days,
'add_show_end_date' => (!is_null($repeatEndDate)) ? $repeatEndDate->format('Y-m-d') : null,
'add_show_no_end' => (is_null($repeatEndDate)),
'add_show_monthly_repeat_type' => $monthlyRepeatType, ]
'add_show_monthly_repeat_type' => $monthlyRepeatType,
]
);
if (!$this->ccShow->isLinkable() || $this->ccShow->isRecorded()) {
@ -362,7 +369,8 @@ class Application_Service_ShowFormService
[
'add_show_background_color' => $this->ccShow->getDbBackgroundColor(),
'add_show_color' => $this->ccShow->getDbColor(),
'add_show_logo_current' => $src, ]
'add_show_logo_current' => $src,
]
);
}
@ -405,7 +413,8 @@ class Application_Service_ShowFormService
'cb_airtime_auth' => $this->ccShow->getDbLiveStreamUsingAirtimeAuth(),
'cb_custom_auth' => $this->ccShow->getDbLiveStreamUsingCustomAuth(),
'custom_username' => $this->ccShow->getDbLiveStreamUser(),
'custom_password' => $this->ccShow->getDbLiveStreamPass(), ]
'custom_password' => $this->ccShow->getDbLiveStreamPass(),
]
);
}
@ -414,7 +423,8 @@ class Application_Service_ShowFormService
$form->populate(
[
'add_show_record' => $this->ccShow->isRecorded(),
'add_show_rebroadcast' => $this->ccShow->isRebroadcast(), ]
'add_show_rebroadcast' => $this->ccShow->isRebroadcast(),
]
);
$form->getElement('add_show_record')->setOptions(['disabled' => true]);

View file

@ -78,7 +78,7 @@ 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_time'],
new DateTimeZone($showData['add_show_timezone'])
);
@ -261,8 +261,10 @@ class Application_Service_ShowService
* to ignore that difference when re-calculating schedule start times.
* Otherwise it might calculate a difference of a week, for example.
*/
if ($this->ccShow->isRepeating()
&& $this->origCcShowDay->getLocalStartDateAndTime()->format('Y-m-d') != $showData['add_show_start_date']) {
if (
$this->ccShow->isRepeating()
&& $this->origCcShowDay->getLocalStartDateAndTime()->format('Y-m-d') != $showData['add_show_start_date']
) {
$showData['add_show_start_date'] = $this->origCcShowDay->getLocalStartDateAndTime()->format('Y-m-d');
}
@ -507,7 +509,8 @@ AND rebroadcast = 1;
SQL;
Application_Common_Database::prepareAndExecute($sql, [
':showId' => $this->ccShow->getDbId(),
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT), ], 'execute');
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
], 'execute');
}
private function deleteAllShowDays($showId)
@ -572,11 +575,15 @@ SQL;
// if the start date changes, these are the repeat types
// that require show instance deletion
$deleteRepeatTypes = [REPEAT_BI_WEEKLY, REPEAT_TRI_WEEKLY, REPEAT_QUAD_WEEKLY, REPEAT_MONTHLY_MONTHLY,
REPEAT_MONTHLY_WEEKLY, ];
$deleteRepeatTypes = [
REPEAT_BI_WEEKLY, REPEAT_TRI_WEEKLY, REPEAT_QUAD_WEEKLY, REPEAT_MONTHLY_MONTHLY,
REPEAT_MONTHLY_WEEKLY,
];
if (in_array($this->repeatType, $deleteRepeatTypes)
&& $showData['add_show_start_date'] != $localShowStart->format('Y-m-d')) {
if (
in_array($this->repeatType, $deleteRepeatTypes)
&& $showData['add_show_start_date'] != $localShowStart->format('Y-m-d')
) {
// Start date has changed when repeat type is bi-weekly or monthly.
// This screws up the repeating positions of show instances, so
// we need to delete them (CC-2351)
@ -631,8 +638,10 @@ SQL;
}
}
if ($showData['add_show_start_date'] != $localShowStart->format('Y-m-d')
|| $showData['add_show_start_time'] != $localShowStart->format('H:i')) {
if (
$showData['add_show_start_date'] != $localShowStart->format('Y-m-d')
|| $showData['add_show_start_time'] != $localShowStart->format('H:i')
) {
// start date has been pushed forward so we need to delete
// any instances of this show scheduled before the new start date
if ($showData['add_show_start_date'] > $localShowStart->format('Y-m-d')) {
@ -723,7 +732,8 @@ WHERE date(starts) >= :endDate::DATE
SQL;
Application_Common_Database::prepareAndExecute($sql, [
':endDate' => $endDate, ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId, ], 'execute');
':showId' => $showId,
], 'execute');
}
private function deleteInstancesBeforeDate($newStartDate, $showId)
@ -738,7 +748,8 @@ SQL;
Application_Common_Database::prepareAndExecute($sql, [
':newStartDate' => $newStartDate, ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId, ], 'execute');
':showId' => $showId,
], 'execute');
}
/**
@ -784,7 +795,8 @@ SQL;
Application_Common_Database::prepareAndExecute(
$sql,
[
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT), ':showId' => $showId, ],
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT), ':showId' => $showId,
],
'execute'
);
}
@ -977,8 +989,10 @@ WHERE starts > :timestamp::TIMESTAMP
SQL;
Application_Common_Database::prepareAndExecute(
$sql,
[':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId, ],
[
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId,
],
'execute'
);
}
@ -996,9 +1010,11 @@ WHERE starts > :timestamp::TIMESTAMP
SQL;
Application_Common_Database::prepareAndExecute(
$sql,
[':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
[
':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
':showId' => $showId,
':firstShow' => $firstShow->format(DEFAULT_TIMESTAMP_FORMAT), ],
':firstShow' => $firstShow->format(DEFAULT_TIMESTAMP_FORMAT),
],
'execute'
);
}
@ -1043,7 +1059,7 @@ SQL;
// DateTime in show's local time
$newStartDateTime = new DateTime(
$showData['add_show_start_date'] . ' ' .
$showData['add_show_start_time'],
$showData['add_show_start_time'],
new DateTimeZone($showData['add_show_timezone'])
);
@ -1088,8 +1104,10 @@ SQL;
Application_Common_Database::prepareAndExecute(
$sql,
[':diff1' => $diff, ':diff2' => $diff,
':showId' => $this->ccShow->getDbId(), ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT), ],
[
':diff1' => $diff, ':diff2' => $diff,
':showId' => $this->ccShow->getDbId(), ':timestamp' => gmdate(DEFAULT_TIMESTAMP_FORMAT),
],
'execute'
);
}
@ -1241,8 +1259,10 @@ SQL;
* Make sure start date is less than populate until date AND
* last show date is null OR start date is less than last show date
*/
if ($utcStartDateTime <= $populateUntil
&& (is_null($utcLastShowDateTime) || $utcStartDateTime < $utcLastShowDateTime)) {
if (
$utcStartDateTime <= $populateUntil
&& (is_null($utcLastShowDateTime) || $utcStartDateTime < $utcLastShowDateTime)
) {
$lastCreatedShow = clone $utcStartDateTime;
/* There may not always be an instance when editing a show
* This will be the case when we are adding a new show day to
@ -1341,9 +1361,11 @@ SQL;
* Make sure start date is less than populate until date AND
* last show date is null OR start date is less than last show date
*/
if ($utcStartDateTime->getTimestamp() <= $populateUntil->getTimestamp()
&& (is_null($utcLastShowDateTime)
|| $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())) {
if (
$utcStartDateTime->getTimestamp() <= $populateUntil->getTimestamp()
&& (is_null($utcLastShowDateTime)
|| $utcStartDateTime->getTimestamp() < $utcLastShowDateTime->getTimestamp())
) {
$lastCreatedShow = clone $utcStartDateTime;
/* There may not always be an instance when editing a show
* This will be the case when we are adding a new show day to
@ -1742,8 +1764,10 @@ SQL;
}
if (is_null($endDate) || $startDateTimeClone->getTimestamp() <= $endDateTime->getTimestamp()) {
if ($this->isUpdate) {
if ($this->origCcShowDay->getDbRepeatType() == 2
|| $this->origCcShowDay->getDbRepeatType() == 3) {
if (
$this->origCcShowDay->getDbRepeatType() == 2
|| $this->origCcShowDay->getDbRepeatType() == 3
) {
$day = null;
} elseif (!$this->origShowRepeatStatus) {
// keep current show day to use for updating cc_show_day rule

View file

@ -102,7 +102,7 @@ abstract class Application_Service_ThirdPartyService
->findOneByDbTrackReference($ref->getDbId());
return $task->getDbStatus() == CELERY_PENDING_STATUS ? -1
: ($task->getDbStatus() == CELERY_FAILED_STATUS ? 0 : 1);
: ($task->getDbStatus() == CELERY_FAILED_STATUS ? 0 : 1);
}
return 0;