public function indexAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendScript("var calendarPref = {};\n" . "calendarPref.weekStart = " . Application_Model_Preference::GetWeekStartDay() . ";\n" . "calendarPref.timestamp = " . time() . ";\n" . "calendarPref.timezoneOffset = " . Application_Common_DateHelper::getUserTimezoneOffset() . ";\n" . "calendarPref.timeScale = '" . Application_Model_Preference::GetCalendarTimeScale() . "';\n" . "calendarPref.timeInterval = " . Application_Model_Preference::GetCalendarTimeInterval() . ";\n" . "calendarPref.weekStartDay = " . Application_Model_Preference::GetWeekStartDay() . ";\n" . "var calendarEvents = null;");
     $this->view->headScript()->appendFile($baseUrl . 'js/contextmenu/jquery.contextMenu.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     //full-calendar-functions.js requires this variable, so that datePicker widget can be offset to server time instead of client time
     //this should be as a default, however with our new drop down timezone changing for shows, we should reset this offset then??
     $this->view->headScript()->appendScript("var timezoneOffset = " . Application_Common_DateHelper::getStationTimezoneOffset() . "; //in seconds");
     //set offset to ensure it loads last
     $this->view->headScript()->offsetSetFile(90, $baseUrl . 'js/airtime/schedule/full-calendar-functions.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/fullcalendar/fullcalendar.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/timepicker/jquery.ui.timepicker.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/colorpicker/js/colorpicker.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/schedule/add-show.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->offsetSetFile(100, $baseUrl . 'js/airtime/schedule/schedule.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/blockui/jquery.blockUI.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/jquery.ui.timepicker.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/fullcalendar.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/colorpicker/css/colorpicker.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/add-show.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/jquery.contextMenu.css?' . $CC_CONFIG['airtime_version']);
     //Start Show builder JS/CSS requirements
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/js/jquery.dataTables.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.pluginAPI.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.fnSetFilteringDelay.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.ColVis.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.ColReorder.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.FixedColumns.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/datatables/plugin/dataTables.columnFilter.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/buttons/buttons.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/library/events/library_showbuilder.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/library/library.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/showbuilder/builder.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/media_library.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/jquery.contextMenu.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/datatables/css/ColVis.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/datatables/css/ColReorder.css?' . $CC_CONFIG['airtime_version']);
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/showbuilder.css?' . $CC_CONFIG['airtime_version']);
     //End Show builder JS/CSS requirements
     $this->createShowFormAction(true);
     $user = Application_Model_User::getCurrentUser();
     if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
         $this->view->preloadShowForm = true;
     }
     $this->view->addNewShow = true;
 }
Exemplo n.º 2
0
 /**
  * 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);
         $utcTimeNow = gmdate("Y-m-d H:i:s");
         $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
             $end = Application_Common_DateHelper::getTodayStationEndDateTime();
             $end->setTimezone(new DateTimeZone("UTC"));
             $utcTimeEnd = $end->format("Y-m-d H:i:s");
             $result = array("env" => APPLICATION_ENV, "schedulerTime" => $utcTimeNow, "currentShow" => Application_Model_Show::getCurrentShow($utcTimeNow), "nextShow" => Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd));
         } else {
             $result = Application_Model_Schedule::GetPlayOrderRange();
             // XSS exploit prevention
             $result["previous"]["name"] = htmlspecialchars($result["previous"]["name"]);
             $result["current"]["name"] = htmlspecialchars($result["current"]["name"]);
             $result["next"]["name"] = htmlspecialchars($result["next"]["name"]);
         }
         // XSS exploit prevention
         foreach ($result["currentShow"] as &$current) {
             $current["name"] = htmlspecialchars($current["name"]);
         }
         foreach ($result["nextShow"] as &$next) {
             $next["name"] = htmlspecialchars($next["name"]);
         }
         //For consistency, all times here are being sent in the station timezone, which
         //seems to be what we've normalized everything to.
         //Convert the UTC scheduler time ("now") to the station timezone.
         $result["schedulerTime"] = Application_Common_DateHelper::UTCStringToStationTimezoneString($result["schedulerTime"]);
         $result["timezone"] = Application_Common_DateHelper::getStationTimezoneAbbreviation();
         $result["timezoneOffset"] = Application_Common_DateHelper::getStationTimezoneOffset();
         //Convert from UTC to station time for Web Browser.
         Application_Common_DateHelper::convertTimestamps($result["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"), "station");
         Application_Common_DateHelper::convertTimestamps($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"), "station");
         //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: application/json");
         // 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;
     }
 }