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); }
public function makeContextMenuAction() { $id = $this->_getParam('id'); $today_timestamp = date("Y-m-d H:i:s"); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); $show = new ShowInstance($id); $params = '/format/json/id/#id#'; if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER, UTYPE_HOST), $show->getShowId()) && !$show->isRecorded() && !$show->isRebroadcast()) { $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/schedule-show-dialog' . $params, 'callback' => 'window["buildScheduleDialog"]'), 'title' => 'Add / Remove Content'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/clear-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Remove All Content'); } } if (!$show->isRecorded()) { $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/show-content-dialog' . $params, 'callback' => 'window["buildContentDialog"]'), 'title' => 'Show Content'); } if (strtotime($show->getShowEnd()) <= strtotime($today_timestamp) && is_null($show->getSoundCloudFileId()) && $show->isRecorded() && Application_Model_Preference::GetDoSoundCloudUpload()) { $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['uploadToSoundCloud']({$id})"), 'title' => 'Upload to Soundcloud'); } if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) && strtotime($today_timestamp) < strtotime($show->getShowEnd()) && $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $menu[] = array('action' => array('type' => 'fn', 'callback' => "window['confirmCancelShow']({$id})"), 'title' => 'Cancel Current Show'); } if (strtotime($today_timestamp) < strtotime($show->getShowStart())) { if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) { $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/edit-show/format/json/id/' . $id, 'callback' => 'window["beginEditShow"]'), 'title' => 'Edit Show'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/delete-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance'); $menu[] = array('action' => array('type' => 'ajax', 'url' => '/Schedule/cancel-show' . $params, 'callback' => 'window["scheduleRefetchEvents"]'), 'title' => 'Delete This Instance and All Following'); } } //returns format jjmenu is looking for. die(json_encode($menu)); }