2011-05-11 01:06:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Application_Model_Dashboard
|
|
|
|
{
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetPreviousItem($p_timeNow)
|
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
// get previous show and previous item in the schedule table.
|
|
|
|
// Compare the two and if the last show was recorded and started
|
|
|
|
// after the last item in the schedule table, then return the show's
|
|
|
|
// name. Else return the last item from the schedule.
|
2011-05-11 01:06:35 +02:00
|
|
|
|
2011-09-23 16:54:20 +02:00
|
|
|
$showInstance = Application_Model_ShowInstance::GetLastShowInstance($p_timeNow);
|
2011-09-23 22:50:00 +02:00
|
|
|
$row = Application_Model_Schedule::GetLastScheduleItem($p_timeNow);
|
2011-05-11 01:06:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (is_null($showInstance)) {
|
|
|
|
if (count($row) == 0) {
|
2011-05-11 01:06:35 +02:00
|
|
|
return null;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $row[0]['artist_name'] . ' - ' . $row[0]['track_title'],
|
2021-10-11 16:10:47 +02:00
|
|
|
'starts' => $row[0]['starts'],
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $row[0]['ends'],
|
|
|
|
];
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
if (count($row) == 0) {
|
|
|
|
if ($showInstance->isRecorded()) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// last item is a show instance
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $showInstance->getName(),
|
2021-10-11 16:10:47 +02:00
|
|
|
'starts' => $showInstance->getShowInstanceStart(),
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $showInstance->getShowInstanceEnd(),
|
|
|
|
];
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2022-03-14 11:15:04 +01:00
|
|
|
// return the one that started later.
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($row[0]['starts'] >= $showInstance->getShowInstanceStart()) {
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $row[0]['artist_name'] . ' - ' . $row[0]['track_title'],
|
2021-10-11 16:10:47 +02:00
|
|
|
'starts' => $row[0]['starts'],
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $row[0]['ends'],
|
|
|
|
];
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $showInstance->getName(),
|
2021-10-11 16:10:47 +02:00
|
|
|
'starts' => $showInstance->getShowInstanceStart(),
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $showInstance->getShowInstanceEnd(),
|
|
|
|
];
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetCurrentItem($p_timeNow)
|
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
// get previous show and previous item in the schedule table.
|
|
|
|
// Compare the two and if the last show was recorded and started
|
|
|
|
// after the last item in the schedule table, then return the show's
|
|
|
|
// name. Else return the last item from the schedule.
|
2011-05-11 01:06:35 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
$row = [];
|
2011-09-23 16:54:20 +02:00
|
|
|
$showInstance = Application_Model_ShowInstance::GetCurrentShowInstance($p_timeNow);
|
2012-07-16 03:17:13 +02:00
|
|
|
if (!is_null($showInstance)) {
|
2011-06-03 23:03:11 +02:00
|
|
|
$instanceId = $showInstance->getShowInstanceId();
|
2011-09-23 22:50:00 +02:00
|
|
|
$row = Application_Model_Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId);
|
2011-06-03 23:03:11 +02:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
if (is_null($showInstance)) {
|
|
|
|
if (count($row) == 0) {
|
2011-05-11 01:06:35 +02:00
|
|
|
return null;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
/* Should never reach here, but lets return the track information
|
|
|
|
* just in case we allow tracks to be scheduled without a show
|
|
|
|
* in the future.
|
|
|
|
*/
|
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $row[0]['artist_name'] . ' - ' . $row[0]['track_title'],
|
2021-10-11 16:10:47 +02:00
|
|
|
'artwork_data' => $row[0]['artwork_data'],
|
|
|
|
'starts' => $row[0]['starts'],
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $row[0]['ends'],
|
|
|
|
];
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
if (count($row) == 0) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// last item is a show instance
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($showInstance->isRecorded()) {
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $showInstance->getName(),
|
2021-10-11 16:10:47 +02:00
|
|
|
'starts' => $showInstance->getShowInstanceStart(),
|
|
|
|
'ends' => $showInstance->getShowInstanceEnd(),
|
|
|
|
'media_item_played' => false,
|
2022-07-07 20:01:15 +02:00
|
|
|
'record' => true,
|
|
|
|
];
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return null;
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $row[0]['artist_name'] . ' - ' . $row[0]['track_title'],
|
2021-10-11 16:10:47 +02:00
|
|
|
'artwork_data' => $row[0]['artwork_data'],
|
|
|
|
'starts' => $row[0]['starts'],
|
|
|
|
'ends' => $row[0]['ends'],
|
|
|
|
'media_item_played' => $row[0]['media_item_played'],
|
2022-07-07 20:01:15 +02:00
|
|
|
'record' => 0,
|
|
|
|
];
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public static function GetNextItem($p_timeNow)
|
|
|
|
{
|
2022-03-14 11:15:04 +01:00
|
|
|
// get previous show and previous item in the schedule table.
|
|
|
|
// Compare the two and if the last show was recorded and started
|
|
|
|
// after the last item in the schedule table, then return the show's
|
|
|
|
// name. Else return the last item from the schedule.
|
2011-05-11 01:06:35 +02:00
|
|
|
|
2011-09-23 16:54:20 +02:00
|
|
|
$showInstance = Application_Model_ShowInstance::GetNextShowInstance($p_timeNow);
|
2011-09-23 22:50:00 +02:00
|
|
|
$row = Application_Model_Schedule::GetNextScheduleItem($p_timeNow);
|
2011-05-11 01:06:35 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if (is_null($showInstance)) {
|
|
|
|
if (count($row) == 0) {
|
2011-05-11 01:06:35 +02:00
|
|
|
return null;
|
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $row[0]['artist_name'] . ' - ' . $row[0]['track_title'],
|
2021-10-11 16:10:47 +02:00
|
|
|
'artwork_data' => $row[0]['artwork_data'],
|
|
|
|
'starts' => $row[0]['starts'],
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $row[0]['ends'],
|
|
|
|
];
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
if (count($row) == 0) {
|
|
|
|
if ($showInstance->isRecorded()) {
|
2022-03-14 11:15:04 +01:00
|
|
|
// last item is a show instance
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $showInstance->getName(),
|
2021-10-11 16:10:47 +02:00
|
|
|
'starts' => $showInstance->getShowInstanceStart(),
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $showInstance->getShowInstanceEnd(),
|
|
|
|
];
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
2021-10-11 16:10:47 +02:00
|
|
|
|
|
|
|
return null;
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|
2022-03-14 11:15:04 +01:00
|
|
|
// return the one that starts sooner.
|
2011-05-11 01:06:35 +02:00
|
|
|
|
2021-10-11 16:10:47 +02:00
|
|
|
if ($row[0]['starts'] <= $showInstance->getShowInstanceStart()) {
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $row[0]['artist_name'] . ' - ' . $row[0]['track_title'],
|
2021-10-11 16:10:47 +02:00
|
|
|
'artwork_data' => $row[0]['artwork_data'],
|
|
|
|
'starts' => $row[0]['starts'],
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $row[0]['ends'],
|
|
|
|
];
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
|
|
|
|
2022-07-07 20:01:15 +02:00
|
|
|
return [
|
|
|
|
'name' => $showInstance->getName(),
|
2021-10-11 16:10:47 +02:00
|
|
|
'starts' => $showInstance->getShowInstanceStart(),
|
2022-07-07 20:01:15 +02:00
|
|
|
'ends' => $showInstance->getShowInstanceEnd(),
|
|
|
|
];
|
2021-10-11 16:10:47 +02:00
|
|
|
}
|
2011-05-11 01:06:35 +02:00
|
|
|
}
|