Exemplo n.º 1
0
 public function weekInfoAction()
 {
     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();
         $dayStart = $date->getWeekStartDate();
         $utcDayStart = Application_Common_DateHelper::ConvertToUtcDateTimeString($dayStart);
         $dow = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday");
         $result = array();
         for ($i = 0; $i < 7; $i++) {
             $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
             $shows = Application_Model_Show::getNextShows($utcDayStart, "ALL", $utcDayEnd);
             $utcDayStart = $utcDayEnd;
             Application_Model_Show::convertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp"));
             $result[$dow[$i]] = $shows;
         }
         //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;
     }
 }