From 3d243468a7199e79ca9c1fe16e728b53f969f63c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 10 Jul 2012 10:36:53 -0400 Subject: [PATCH] CC-4090: Make code style PSR compliant Subjects.php --- .../application/controllers/ApiController.php | 18 +++++----- .../controllers/ScheduleController.php | 4 +-- airtime_mvc/application/forms/AddShowWhat.php | 2 +- airtime_mvc/application/models/Show.php | 33 +++++++++++-------- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index a46367c9d..30c533368 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -270,18 +270,18 @@ class ApiController extends Zend_Controller_Action $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'); if($type == "endofday") { - // 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, 5, $utcTimeEnd)); + "nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, 5, $utcTimeEnd)); - Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); + Application_Model_Show::convertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); }else{ $limit = $request->getParam('limit'); @@ -292,8 +292,8 @@ class ApiController extends Zend_Controller_Action $result = Application_Model_Schedule::GetPlayOrderRange(); //Convert from UTC to localtime for user. - 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. @@ -324,10 +324,10 @@ class ApiController extends Zend_Controller_Action $result = array(); 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")); + Application_Model_Show::convertToLocalTimeZone($shows, array("starts", "ends", "start_timestamp", "end_timestamp")); $result[$dow[$i]] = $shows; } @@ -413,7 +413,7 @@ class ApiController extends Zend_Controller_Action $this->view->server_timezone = Application_Model_Preference::GetTimezone(); $rows = Application_Model_Show::GetCurrentShow($today_timestamp); - Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp")); + Application_Model_Show::convertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp")); if (count($rows) > 0){ $this->view->is_recording = ($rows[0]['record'] == 1); diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index cf74f305d..f7293d4ab 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -357,8 +357,8 @@ class ScheduleController extends Zend_Controller_Action $range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]); } - Application_Model_Show::ConvertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); - Application_Model_Show::ConvertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); + Application_Model_Show::convertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); + Application_Model_Show::convertToLocalTimeZone($range["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp")); $source_status = array(); $switch_status = array(); diff --git a/airtime_mvc/application/forms/AddShowWhat.php b/airtime_mvc/application/forms/AddShowWhat.php index 5e91a38b4..9c1f04905 100644 --- a/airtime_mvc/application/forms/AddShowWhat.php +++ b/airtime_mvc/application/forms/AddShowWhat.php @@ -6,7 +6,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm { // retrieves the length limit for each char field // and store to assoc array - $maxLens = Application_Model_Show::GetMaxLengths(); + $maxLens = Application_Model_Show::getMaxLengths(); // Hidden element to indicate whether the show is new or // whether we are updating an existing show. diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index e7cf6967b..9d7c5c00e 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1733,7 +1733,8 @@ class Application_Model_Show { $timeNow = $date->getUtcTimestamp(); } //TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin - $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends" + $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name," + ." s.id, si.id as instance_id, si.record, s.url, starts, ends" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." WHERE si.show_id = s.id" ." AND si.starts <= TIMESTAMP '$timeNow'" @@ -1746,14 +1747,16 @@ class Application_Model_Show { } /** - * Gets the current show, previous and next with an 2day window from the given timeNow, so timeNow-2days and timeNow+2days. + * Gets the current show, previous and next with an 2day window from + * the given timeNow, so timeNow-2days and timeNow+2days. */ public static function getPrevCurrentNext($p_timeNow) { global $CC_CONFIG; $con = Propel::getConnection(); //TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin - $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name, s.id, si.id as instance_id, si.record, s.url, starts, ends" + $sql = "SELECT si.starts as start_timestamp, si.ends as end_timestamp, s.name," + ." s.id, si.id as instance_id, si.record, s.url, starts, ends" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s" ." WHERE si.show_id = s.id" ." AND si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '2 days'" @@ -1770,10 +1773,11 @@ class Application_Model_Show { $timeNowAsMillis = strtotime($p_timeNow); - for( $i = 0; $i < $numberOfRows; ++$i ){ + for ($i = 0; $i < $numberOfRows; ++$i) { //Find the show that is within the current time. - if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) > $timeNowAsMillis)){ - if ( $i - 1 >= 0){ + if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) + && (strtotime($rows[$i]['ends']) > $timeNowAsMillis)) { + if ($i-1 >= 0) { $results['previousShow'][0] = array( "id"=>$rows[$i-1]['id'], "instance_id"=>$rows[$i-1]['instance_id'], @@ -1789,7 +1793,7 @@ class Application_Model_Show { $results['currentShow'][0] = $rows[$i]; - if ( isset($rows[$i+1])){ + if (isset($rows[$i+1])) { $results['nextShow'][0] = array( "id"=>$rows[$i+1]['id'], "instance_id"=>$rows[$i+1]['instance_id'], @@ -1801,7 +1805,6 @@ class Application_Model_Show { "ends"=>$rows[$i+1]['ends'], "record"=>$rows[$i+1]['record'], "type"=>"show"); - } break; } @@ -1855,7 +1858,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(); @@ -1878,7 +1881,7 @@ class Application_Model_Show { ." ORDER BY si.starts"; // defaults to retrieve all shows within the interval if $limit not set - if($limit != "0") { + if ($limit != "0") { $sql = $sql . " LIMIT $limit"; } @@ -1893,20 +1896,22 @@ class Application_Model_Show { * @param type $rows arrays of arrays containing database query result * @param type $columnsToConvert array of column names to convert */ - public static function ConvertToLocalTimeZone(&$rows, $columnsToConvert) { + public static function convertToLocalTimeZone(&$rows, $columnsToConvert) + { $timezone = date_default_timezone_get(); if (!is_array($rows)) { return; } - foreach($rows as &$row) { - foreach($columnsToConvert as $column) { + foreach ($rows as &$row) { + foreach ($columnsToConvert as $column) { $row[$column] = Application_Common_DateHelper::ConvertToLocalDateTimeString($row[$column]); } } } - public static function GetMaxLengths() { + public static function getMaxLengths() + { global $CC_CONFIG; $con = Propel::getConnection();