CC-4090: Make code style PSR compliant

Subjects.php
This commit is contained in:
Martin Konecny 2012-07-10 10:36:53 -04:00
parent dc2b4fed0a
commit 3d243468a7
4 changed files with 31 additions and 26 deletions

View File

@ -270,18 +270,18 @@ class ApiController extends Zend_Controller_Action
$date = new Application_Common_DateHelper; $date = new Application_Common_DateHelper;
$utcTimeNow = $date->getUtcTimestamp(); $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(); $request = $this->getRequest();
$type = $request->getParam('type'); $type = $request->getParam('type');
if($type == "endofday") { if($type == "endofday") {
// make GetNextShows use end of day // make getNextShows use end of day
$utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc(); $utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc();
$result = array("env"=>APPLICATION_ENV, $result = array("env"=>APPLICATION_ENV,
"schedulerTime"=>gmdate("Y-m-d H:i:s"), "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{ }else{
$limit = $request->getParam('limit'); $limit = $request->getParam('limit');
@ -292,8 +292,8 @@ class ApiController extends Zend_Controller_Action
$result = Application_Model_Schedule::GetPlayOrderRange(); $result = Application_Model_Schedule::GetPlayOrderRange();
//Convert from UTC to localtime for user. //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["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["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. $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(); $result = array();
for ($i=0; $i<7; $i++){ for ($i=0; $i<7; $i++){
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart); $utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
$shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd); $shows = Application_Model_Show::getNextShows($utcDayStart, "0", $utcDayEnd);
$utcDayStart = $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; $result[$dow[$i]] = $shows;
} }
@ -413,7 +413,7 @@ class ApiController extends Zend_Controller_Action
$this->view->server_timezone = Application_Model_Preference::GetTimezone(); $this->view->server_timezone = Application_Model_Preference::GetTimezone();
$rows = Application_Model_Show::GetCurrentShow($today_timestamp); $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){ if (count($rows) > 0){
$this->view->is_recording = ($rows[0]['record'] == 1); $this->view->is_recording = ($rows[0]['record'] == 1);

View File

@ -357,8 +357,8 @@ class ScheduleController extends Zend_Controller_Action
$range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]); $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["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["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
$source_status = array(); $source_status = array();
$switch_status = array(); $switch_status = array();

View File

@ -6,7 +6,7 @@ class Application_Form_AddShowWhat extends Zend_Form_SubForm
{ {
// retrieves the length limit for each char field // retrieves the length limit for each char field
// and store to assoc array // 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 // Hidden element to indicate whether the show is new or
// whether we are updating an existing show. // whether we are updating an existing show.

View File

@ -1733,7 +1733,8 @@ class Application_Model_Show {
$timeNow = $date->getUtcTimestamp(); $timeNow = $date->getUtcTimestamp();
} }
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin //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" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id" ." WHERE si.show_id = s.id"
." AND si.starts <= TIMESTAMP '$timeNow'" ." 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) public static function getPrevCurrentNext($p_timeNow)
{ {
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin //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" ." FROM $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
." WHERE si.show_id = s.id" ." WHERE si.show_id = s.id"
." AND si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '2 days'" ." AND si.starts > TIMESTAMP '$p_timeNow' - INTERVAL '2 days'"
@ -1770,10 +1773,11 @@ class Application_Model_Show {
$timeNowAsMillis = strtotime($p_timeNow); $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. //Find the show that is within the current time.
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) > $timeNowAsMillis)){ if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis)
if ( $i - 1 >= 0){ && (strtotime($rows[$i]['ends']) > $timeNowAsMillis)) {
if ($i-1 >= 0) {
$results['previousShow'][0] = array( $results['previousShow'][0] = array(
"id"=>$rows[$i-1]['id'], "id"=>$rows[$i-1]['id'],
"instance_id"=>$rows[$i-1]['instance_id'], "instance_id"=>$rows[$i-1]['instance_id'],
@ -1789,7 +1793,7 @@ class Application_Model_Show {
$results['currentShow'][0] = $rows[$i]; $results['currentShow'][0] = $rows[$i];
if ( isset($rows[$i+1])){ if (isset($rows[$i+1])) {
$results['nextShow'][0] = array( $results['nextShow'][0] = array(
"id"=>$rows[$i+1]['id'], "id"=>$rows[$i+1]['id'],
"instance_id"=>$rows[$i+1]['instance_id'], "instance_id"=>$rows[$i+1]['instance_id'],
@ -1801,7 +1805,6 @@ class Application_Model_Show {
"ends"=>$rows[$i+1]['ends'], "ends"=>$rows[$i+1]['ends'],
"record"=>$rows[$i+1]['record'], "record"=>$rows[$i+1]['record'],
"type"=>"show"); "type"=>"show");
} }
break; break;
} }
@ -1855,7 +1858,7 @@ class Application_Model_Show {
* @param String $timeEnd - interval end time (in UTC) * @param String $timeEnd - interval end time (in UTC)
* @return array - the next $limit number of shows within the time interval * @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; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();
@ -1878,7 +1881,7 @@ class Application_Model_Show {
." ORDER BY si.starts"; ." ORDER BY si.starts";
// defaults to retrieve all shows within the interval if $limit not set // defaults to retrieve all shows within the interval if $limit not set
if($limit != "0") { if ($limit != "0") {
$sql = $sql . " LIMIT $limit"; $sql = $sql . " LIMIT $limit";
} }
@ -1893,20 +1896,22 @@ class Application_Model_Show {
* @param type $rows arrays of arrays containing database query result * @param type $rows arrays of arrays containing database query result
* @param type $columnsToConvert array of column names to convert * @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(); $timezone = date_default_timezone_get();
if (!is_array($rows)) { if (!is_array($rows)) {
return; return;
} }
foreach($rows as &$row) { foreach ($rows as &$row) {
foreach($columnsToConvert as $column) { foreach ($columnsToConvert as $column) {
$row[$column] = Application_Common_DateHelper::ConvertToLocalDateTimeString($row[$column]); $row[$column] = Application_Common_DateHelper::ConvertToLocalDateTimeString($row[$column]);
} }
} }
} }
public static function GetMaxLengths() { public static function getMaxLengths()
{
global $CC_CONFIG; global $CC_CONFIG;
$con = Propel::getConnection(); $con = Propel::getConnection();