From 40023d9086efba75be185a062a0c37f7a81b07d9 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 6 Aug 2012 17:07:18 -0400 Subject: [PATCH] CC-4152: Widget does not display current show in some modes -fixed --- .../application/controllers/ApiController.php | 36 ++++++++++++------- airtime_mvc/application/models/Schedule.php | 2 +- airtime_mvc/application/models/Show.php | 6 ++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index b9d302008..a8646d1a0 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -260,41 +260,51 @@ class ApiController extends Zend_Controller_Action */ public function liveInfoAction() { - if (Application_Model_Preference::GetAllow3rdPartyApi()){ + 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 + $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.2 - MK */ if ($type == "endofday") { $limit = $request->getParam('limit'); - if($limit == "" || !is_numeric($limit)) { + if ($limit == "" || !is_numeric($limit)) { $limit = "5"; } - // make GetNextShows use end of day + // make getNextShows use end of day $utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc(); $result = array("env"=>APPLICATION_ENV, "schedulerTime"=>gmdate("Y-m-d H:i:s"), - "nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, $limit, $utcTimeEnd)); + "currentShow"=>Application_Model_Show::getCurrentShow($utcTimeNow), + "nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd) + ); - Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); + 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")); + 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")); } - - $result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION; //used by caller to determine if the airtime they are running or widgets in use is out of date. + //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. @@ -308,7 +318,7 @@ class ApiController extends Zend_Controller_Action public function weekInfoAction() { - if (Application_Model_Preference::GetAllow3rdPartyApi()){ + if (Application_Model_Preference::GetAllow3rdPartyApi()) { // disable the view and the layout $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); @@ -320,9 +330,9 @@ class ApiController extends Zend_Controller_Action $dow = array("monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"); $result = array(); - for ($i=0; $i<7; $i++){ + for ($i=0; $i<7; $i++) { $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart); - $shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd); + $shows = Application_Model_Show::getNextShows($utcDayStart, "0", $utcDayEnd); $utcDayStart = $utcDayEnd; Application_Model_Show::ConvertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp")); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index caed912ab..c8d0fd7f8 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -109,7 +109,7 @@ class Application_Model_Schedule { $sql .= ' AND st.playout_status > 0 ORDER BY st.starts'; - $rows = $con->query($sql)->fetchAll(); + $rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC); $numberOfRows = count($rows); $results['previous'] = null; diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 5f86b4363..6c2f51ba6 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1736,7 +1736,7 @@ class Application_Model_Show { ." AND modified_instance != TRUE"; // Convert back to local timezone - $rows = $con->query($sql)->fetchAll(); + $rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC); return $rows; } @@ -1850,7 +1850,7 @@ class Application_Model_Show { * @param String $timeEnd - interval end time (in UTC) * @return array - the next $limit number of shows within the time interval */ - public static function GetNextShows($timeStart, $limit = "0", $timeEnd = "") + public static function getNextShows($timeStart, $limit = "0", $timeEnd = "") { global $CC_CONFIG; $con = Propel::getConnection(); @@ -1877,7 +1877,7 @@ class Application_Model_Show { $sql = $sql . " LIMIT $limit"; } - $rows = $con->query($sql)->fetchAll(); + $rows = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC); return $rows; }