/** * Retrieve the currently playing show as well as upcoming shows. * Number of shows returned and the time interval in which to * get the next shows can be configured as GET parameters. * * TODO: in the future, make interval length a parameter instead of hardcode to 48 * * Possible parameters: * type - Can have values of "endofday" or "interval". If set to "endofday", * the function will retrieve shows from now to end of day. * If set to "interval", shows in the next 48 hours will be retrived. * Default is "interval". * limit - How many shows to retrieve * Default is "5". */ 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 Application_Common_DateHelper(); $utcTimeNow = $date->getUtcTimestamp(); $utcTimeEnd = ""; // if empty, getNextShows will use interval instead of end of day $request = $this->getRequest(); $type = $request->getParam('type'); /* This is some *extremely* lazy programming that needs to bi fixed. For some reason * we are using two entirely different codepaths for very similar functionality (type = endofday * vs type = interval). Needs to be fixed for 2.3 - MK */ if ($type == "endofday") { $limit = $request->getParam('limit'); if ($limit == "" || !is_numeric($limit)) { $limit = "5"; } // make getNextShows use end of day $utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc(); $result = array("env" => APPLICATION_ENV, "schedulerTime" => gmdate("Y-m-d H:i:s"), "currentShow" => Application_Model_Show::getCurrentShow($utcTimeNow), "nextShow" => Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)); Application_Model_Show::convertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::convertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); } else { $result = Application_Model_Schedule::GetPlayOrderRange(); //Convert from UTC to localtime for Web Browser. Application_Model_Show::ConvertToLocalTimeZone($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); } //used by caller to determine if the airtime they are running or widgets in use is out of date. $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; header("Content-type: text/javascript"); // If a callback is not given, then just provide the raw JSON. echo isset($_GET['callback']) ? $_GET['callback'] . '(' . json_encode($result) . ')' : json_encode($result); } else { header('HTTP/1.0 401 Unauthorized'); print 'You are not allowed to access this resource. '; exit; } }