Esempio n. 1
0
 public static function GetDataGridData($viewType, $dateString)
 {
     if ($viewType == "now") {
         $date = new DateHelper();
         $timeNow = $date->getTimestamp();
         $startCutoff = 60;
         $endCutoff = 86400;
         //60*60*24 - seconds in a day
     } else {
         $date = new DateHelper();
         $time = $date->getTime();
         $date->setDate($dateString . " " . $time);
         $timeNow = $date->getTimestamp();
         $startCutoff = $date->getNowDayStartDiff();
         $endCutoff = $date->getNowDayEndDiff();
     }
     $data = array();
     $showIds = ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff);
     foreach ($showIds as $showId) {
         $instanceId = $showId['id'];
         $si = new ShowInstance($instanceId);
         $showId = $si->getShowId();
         $show = new Show($showId);
         //append show header row
         $data[] = Application_Model_Nowplaying::CreateHeaderRow($show->getName(), $si->getShowStart(), $si->getShowEnd());
         $scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
         $dataTablesRows = Application_Model_Nowplaying::CreateDatatableRows($scheduledItems);
         //append show audio item rows
         $data = array_merge($data, $dataTablesRows);
         //append show gap time row
         $gapTime = Application_Model_Nowplaying::FormatDuration($si->getShowEndGapTime(), true);
         if ($si->isRecorded()) {
             $data[] = Application_Model_Nowplaying::CreateRecordingRow($si);
         } else {
             if ($gapTime > 0) {
                 $data[] = Application_Model_Nowplaying::CreateGapRow($gapTime);
             }
         }
     }
     return array("currentShow" => Show_DAL::GetCurrentShow($timeNow), "rows" => $data);
 }
Esempio n. 2
0
 private static function populateRepeatingShow($show_id, $next_pop_date, $first_show, $last_show, $start_time, $duration, $day, $record, $end_timestamp, $interval)
 {
     global $CC_DBC;
     if (isset($next_pop_date)) {
         $next_date = $next_pop_date . " " . $start_time;
     } else {
         $next_date = $first_show . " " . $start_time;
     }
     $sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
     $rebroadcasts = $CC_DBC->GetAll($sql);
     $show = new Show($show_id);
     $date = new DateHelper();
     $currentTimestamp = $date->getTimestamp();
     while (strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {
         $start = $next_date;
         $sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
         $end = $CC_DBC->GetOne($sql);
         if ($show->hasInstanceOnDate($start)) {
             $ccShowInstance = $show->getInstanceOnDate($start);
             $newInstance = false;
         } else {
             $ccShowInstance = new CcShowInstances();
             $newInstance = true;
         }
         /* When editing the start/end time of a repeating show, we don't want to
          * change shows that started in the past. So check the start time.
          */
         if ($newInstance || $ccShowInstance->getDbStarts() > $currentTimestamp) {
             $ccShowInstance->setDbShowId($show_id);
             $ccShowInstance->setDbStarts($start);
             $ccShowInstance->setDbEnds($end);
             $ccShowInstance->setDbRecord($record);
             $ccShowInstance->save();
         }
         $show_instance_id = $ccShowInstance->getDbId();
         $showInstance = new ShowInstance($show_instance_id);
         if (!$newInstance) {
             $showInstance->correctScheduleStartTimes();
         }
         foreach ($rebroadcasts as $rebroadcast) {
             $timeinfo = explode(" ", $next_date);
             $sql = "SELECT timestamp '{$timeinfo[0]}' + interval '{$rebroadcast["day_offset"]}' + interval '{$rebroadcast["start_time"]}'";
             $rebroadcast_start_time = $CC_DBC->GetOne($sql);
             $sql = "SELECT timestamp '{$rebroadcast_start_time}' + interval '{$duration}'";
             $rebroadcast_end_time = $CC_DBC->GetOne($sql);
             if ($rebroadcast_start_time > $currentTimestamp) {
                 $newRebroadcastInstance = new CcShowInstances();
                 $newRebroadcastInstance->setDbShowId($show_id);
                 $newRebroadcastInstance->setDbStarts($rebroadcast_start_time);
                 $newRebroadcastInstance->setDbEnds($rebroadcast_end_time);
                 $newRebroadcastInstance->setDbRecord(0);
                 $newRebroadcastInstance->setDbRebroadcast(1);
                 $newRebroadcastInstance->setDbOriginalShow($show_instance_id);
                 $newRebroadcastInstance->save();
             }
         }
         $sql = "SELECT timestamp '{$start}' + interval '{$interval}'";
         $next_date = $CC_DBC->GetOne($sql);
     }
     Show::setNextPop($next_date, $show_id, $day);
     RabbitMq::PushSchedule();
 }
Esempio n. 3
0
 /**
  * Returns data related to the scheduled items.
  *
  * @param int $prev
  * @param int $next
  * @return date
  */
 public static function GetPlayOrderRange($prev = 1, $next = 1)
 {
     if (!is_int($prev) || !is_int($next)) {
         //must enter integers to specify ranges
         return array();
     }
     global $CC_CONFIG;
     $date = new DateHelper();
     $timeNow = $date->getTimestamp();
     return array("env" => APPLICATION_ENV, "schedulerTime" => gmdate("Y-m-d H:i:s"), "previous" => Application_Model_Dashboard::GetPreviousItem($timeNow), "current" => Application_Model_Dashboard::GetCurrentItem($timeNow), "next" => Application_Model_Dashboard::GetNextItem($timeNow), "currentShow" => Show_DAL::GetCurrentShow($timeNow), "nextShow" => Show_DAL::GetNextShows($timeNow, 1), "timezone" => date("T"), "timezoneOffset" => date("Z"));
 }
Esempio n. 4
0
 public function liveInfoAction()
 {
     if (Application_Model_Preference::GetAllow3rdPartyApi()) {
         // disable the view and the layout
         $this->view->layout()->disableLayout();
         $this->_helper->viewRenderer->setNoRender(true);
         $date = new DateHelper();
         $timeNow = $date->getTimestamp();
         $result = array("env" => APPLICATION_ENV, "schedulerTime" => gmdate("Y-m-d H:i:s"), "currentShow" => Show_DAL::GetCurrentShow($timeNow), "nextShow" => Show_DAL::GetNextShows($timeNow, 5), "timezone" => date("T"), "timezoneOffset" => date("Z"));
         //echo json_encode($result);
         header("Content-type: text/javascript");
         echo $_GET['callback'] . '(' . json_encode($result) . ')';
     } else {
         header('HTTP/1.0 401 Unauthorized');
         print 'You are not allowed to access this resource. ';
         exit;
     }
 }