CC-2833: Use ClassLoaders for PHP Files

-autoload DateHelper class
This commit is contained in:
martin 2011-09-26 15:29:12 -04:00
parent b8838a5bda
commit 9e6a1ebf44
7 changed files with 29 additions and 29 deletions

View File

@ -20,7 +20,7 @@ require_once 'DB.php';
//require_once 'Shows.php'; //require_once 'Shows.php';
//require_once 'User.php'; //require_once 'User.php';
//require_once 'RabbitMq.php'; //require_once 'RabbitMq.php';
require_once 'DateHelper.php'; //require_once 'DateHelper.php';
require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php'; require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php';
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;

View File

@ -158,7 +158,7 @@ class ApiController extends Zend_Controller_Action
$this->view->layout()->disableLayout(); $this->view->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timeNow = $date->getTimestamp(); $timeNow = $date->getTimestamp();
$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"),

View File

@ -152,8 +152,8 @@ class ScheduleController extends Zend_Controller_Action
$params = '/format/json/id/#id#'; $params = '/format/json/id/#id#';
$showStartDateHelper = DateHelper::ConvertToLocalDateTime($show->getShowStart()); $showStartDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowStart());
$showEndDateHelper = DateHelper::ConvertToLocalDateTime($show->getShowEnd()); $showEndDateHelper = Application_Model_DateHelper::ConvertToLocalDateTime($show->getShowEnd());
if ($epochNow < $showStartDateHelper->getTimestamp()) { if ($epochNow < $showStartDateHelper->getTimestamp()) {
@ -461,7 +461,7 @@ class ScheduleController extends Zend_Controller_Action
$i = 1; $i = 1;
foreach ($rebroadcastsRelative as $rebroadcast){ foreach ($rebroadcastsRelative as $rebroadcast){
$rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset']; $rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset'];
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']); $rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Application_Model_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
$i++; $i++;
} }
$formRebroadcast->populate($rebroadcastFormValues); $formRebroadcast->populate($rebroadcastFormValues);
@ -471,7 +471,7 @@ class ScheduleController extends Zend_Controller_Action
$i = 1; $i = 1;
foreach ($rebroadcastsAbsolute as $rebroadcast){ foreach ($rebroadcastsAbsolute as $rebroadcast){
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date']; $rebroadcastAbsoluteFormValues["add_show_rebroadcast_date_absolute_$i"] = $rebroadcast['start_date'];
$rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = DateHelper::removeSecondsFromTime($rebroadcast['start_time']); $rebroadcastAbsoluteFormValues["add_show_rebroadcast_time_absolute_$i"] = Application_Model_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
$i++; $i++;
} }
$formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues); $formAbsoluteRebroadcast->populate($rebroadcastAbsoluteFormValues);

View File

@ -1,6 +1,6 @@
<?php <?php
class DateHelper class Application_Model_DateHelper
{ {
private $_dateTime; private $_dateTime;

View File

@ -14,10 +14,10 @@ class Application_Model_Nowplaying
foreach ($p_dbRows as $dbRow){ foreach ($p_dbRows as $dbRow){
$showStartDateTime = DateHelper::ConvertToLocalDateTime($dbRow['show_starts']); $showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
$showEndDateTime = DateHelper::ConvertToLocalDateTime($dbRow['show_ends']); $showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
$itemStartDateTime = DateHelper::ConvertToLocalDateTime($dbRow['item_starts']); $itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
$itemEndDateTime = DateHelper::ConvertToLocalDateTime($dbRow['item_ends']); $itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
$showStarts = $showStartDateTime->format("Y-m-d H:i:s"); $showStarts = $showStartDateTime->format("Y-m-d H:i:s");
$showEnds = $showEndDateTime->format("Y-m-d H:i:s"); $showEnds = $showEndDateTime->format("Y-m-d H:i:s");
@ -61,7 +61,7 @@ class Application_Model_Nowplaying
$startCutoff = 60; $startCutoff = 60;
$endCutoff = 86400; //60*60*24 - seconds in a day $endCutoff = 86400; //60*60*24 - seconds in a day
} else { } else {
$date = new DateHelper; $date = new Application_Model_DateHelper;
$time = $date->getTime(); $time = $date->getTime();
$date->setDate($dateString." ".$time); $date->setDate($dateString." ".$time);
$timeNow = $date->getUtcTimestamp(); $timeNow = $date->getUtcTimestamp();
@ -81,8 +81,8 @@ class Application_Model_Nowplaying
$showId = $si->getShowId(); $showId = $si->getShowId();
$show = new Application_Model_Show($showId); $show = new Application_Model_Show($showId);
$showStartDateTime = DateHelper::ConvertToLocalDateTime($si->getShowStart()); $showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowStart());
$showEndDateTime = DateHelper::ConvertToLocalDateTime($si->getShowEnd()); $showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowEnd());
//append show header row //append show header row
$data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s")); $data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s"));

View File

@ -143,7 +143,7 @@ class Application_Model_Schedule {
global $CC_CONFIG; global $CC_CONFIG;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timeNow = $date->getUtcTimestamp(); $timeNow = $date->getUtcTimestamp();
return array("env"=>APPLICATION_ENV, return array("env"=>APPLICATION_ENV,
"schedulerTime"=>$timeNow, "schedulerTime"=>$timeNow,
@ -499,8 +499,8 @@ class Application_Model_Schedule {
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]), 'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),
'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]), 'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]),
'fade_cross' => 0, 'fade_cross' => 0,
'cue_in' => DateHelper::CalculateLengthInSeconds($item["cue_in"]), 'cue_in' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_in"]),
'cue_out' => DateHelper::CalculateLengthInSeconds($item["cue_out"]), 'cue_out' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_out"]),
'export_source' => 'scheduler', 'export_source' => 'scheduler',
'start' => $starts, 'start' => $starts,
'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["ends"]) 'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["ends"])

View File

@ -137,7 +137,7 @@ class Application_Model_Show {
$uncheckedDaysImploded = implode(",", $p_uncheckedDays); $uncheckedDaysImploded = implode(",", $p_uncheckedDays);
$showId = $this->getId(); $showId = $this->getId();
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$sql = "DELETE FROM cc_show_instances" $sql = "DELETE FROM cc_show_instances"
@ -302,7 +302,7 @@ class Application_Model_Show {
public function deleteAllInstances(){ public function deleteAllInstances(){
global $CC_DBC; global $CC_DBC;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$showId = $this->getId(); $showId = $this->getId();
@ -321,7 +321,7 @@ class Application_Model_Show {
public function deleteAllRebroadcasts(){ public function deleteAllRebroadcasts(){
global $CC_DBC; global $CC_DBC;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$showId = $this->getId(); $showId = $this->getId();
@ -343,11 +343,11 @@ class Application_Model_Show {
public function removeAllInstancesFromDate($p_date=null){ public function removeAllInstancesFromDate($p_date=null){
global $CC_DBC; global $CC_DBC;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
if(is_null($p_date)) { if(is_null($p_date)) {
$date = new DateHelper; $date = new Application_Model_DateHelper;
$p_date = $date->getDate(); $p_date = $date->getDate();
} }
@ -377,7 +377,7 @@ class Application_Model_Show {
public function removeAllInstancesBeforeDate($p_date){ public function removeAllInstancesBeforeDate($p_date){
global $CC_DBC; global $CC_DBC;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$showId = $this->getId(); $showId = $this->getId();
@ -481,7 +481,7 @@ class Application_Model_Show {
* true if the StartDate is in the past, false otherwise * true if the StartDate is in the past, false otherwise
*/ */
public function isStartDateTimeInPast(){ public function isStartDateTimeInPast(){
$date = new DateHelper; $date = new Application_Model_DateHelper;
$current_timestamp = $date->getTimestamp(); $current_timestamp = $date->getTimestamp();
return ($current_timestamp > $this->getStartDate()." ".$this->getStartTime()); return ($current_timestamp > $this->getStartDate()." ".$this->getStartTime());
} }
@ -495,7 +495,7 @@ class Application_Model_Show {
public function getAllFutureInstanceIds(){ public function getAllFutureInstanceIds(){
global $CC_DBC; global $CC_DBC;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$showId = $this->getId(); $showId = $this->getId();
@ -517,7 +517,7 @@ class Application_Model_Show {
global $CC_DBC; global $CC_DBC;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$sql = "UPDATE cc_show_days " $sql = "UPDATE cc_show_days "
@ -538,7 +538,7 @@ class Application_Model_Show {
global $CC_DBC; global $CC_DBC;
$date = new DateHelper; $date = new Application_Model_DateHelper;
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$sql = "UPDATE cc_show_days " $sql = "UPDATE cc_show_days "
@ -955,7 +955,7 @@ class Application_Model_Show {
$sql = "SELECT timestamp '{$start}' + interval '{$duration}'"; $sql = "SELECT timestamp '{$start}' + interval '{$duration}'";
$end = $CC_DBC->GetOne($sql); $end = $CC_DBC->GetOne($sql);
$date = new DateHelper(); $date = new Application_Model_DateHelper();
$currentTimestamp = $date->getTimestamp(); $currentTimestamp = $date->getTimestamp();
$show = new Application_Model_Show($show_id); $show = new Application_Model_Show($show_id);
@ -1028,7 +1028,7 @@ class Application_Model_Show {
$rebroadcasts = $CC_DBC->GetAll($sql); $rebroadcasts = $CC_DBC->GetAll($sql);
$show = new Application_Model_Show($show_id); $show = new Application_Model_Show($show_id);
$date = new DateHelper(); $date = new Application_Model_DateHelper();
$currentTimestamp = $date->getTimestamp(); $currentTimestamp = $date->getTimestamp();
while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) { while(strtotime($next_date) <= strtotime($end_timestamp) && (strtotime($last_show) > strtotime($next_date) || is_null($last_show))) {