parent
fe5191eac1
commit
a0217f715f
|
@ -188,6 +188,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
"nextShow"=>Application_Model_Show::GetNextShows($timeNow, 5),
|
"nextShow"=>Application_Model_Show::GetNextShows($timeNow, 5),
|
||||||
"timezone"=> date("T"),
|
"timezone"=> date("T"),
|
||||||
"timezoneOffset"=> date("Z"));
|
"timezoneOffset"=> date("Z"));
|
||||||
|
|
||||||
|
//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"));
|
||||||
|
|
||||||
//echo json_encode($result);
|
//echo json_encode($result);
|
||||||
header("Content-type: text/javascript");
|
header("Content-type: text/javascript");
|
||||||
|
@ -213,6 +217,8 @@ class ApiController extends Zend_Controller_Action
|
||||||
$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($timeNow, 5, $timeEnd));
|
"nextShow"=>Application_Model_Show::GetNextShows($timeNow, 5, $timeEnd));
|
||||||
|
|
||||||
|
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||||
|
|
||||||
header("Content-type: text/javascript");
|
header("Content-type: text/javascript");
|
||||||
echo $_GET['callback'].'('.json_encode($result).')';
|
echo $_GET['callback'].'('.json_encode($result).')';
|
||||||
|
@ -234,7 +240,10 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
for ($i=0; $i<7; $i++){
|
for ($i=0; $i<7; $i++){
|
||||||
$result[$dow[$i]] = Application_Model_Show::GetShowsByDayOfWeek($i);
|
$shows = Application_Model_Show::GetShowsByDayOfWeek($i);
|
||||||
|
Application_Model_Show::ConvertToLocalTimeZone($shows, array("show_starts", "show_ends"));
|
||||||
|
|
||||||
|
$result[$dow[$i]] = $shows;
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-type: text/javascript");
|
header("Content-type: text/javascript");
|
||||||
|
@ -361,6 +370,8 @@ class ApiController extends Zend_Controller_Action
|
||||||
$this->view->is_recording = false;
|
$this->view->is_recording = false;
|
||||||
|
|
||||||
$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"));
|
||||||
|
|
||||||
if (count($rows) > 0){
|
if (count($rows) > 0){
|
||||||
$this->view->is_recording = ($rows[0]['record'] == 1);
|
$this->view->is_recording = ($rows[0]['record'] == 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,27 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function getCurrentPlaylistAction()
|
public function getCurrentPlaylistAction()
|
||||||
{
|
{
|
||||||
$this->view->entries = Application_Model_Schedule::GetPlayOrderRange();
|
|
||||||
|
$range = Application_Model_Schedule::GetPlayOrderRange();
|
||||||
|
|
||||||
|
/* Convert all UTC times to localtime before sending back to user. */
|
||||||
|
if (isset($range["previous"])){
|
||||||
|
$range["previous"]["starts"] = Application_Model_DateHelper::ConvertToLocalDateTimeString($range["previous"]["starts"]);
|
||||||
|
$range["previous"]["ends"] = Application_Model_DateHelper::ConvertToLocalDateTimeString($range["previous"]["ends"]);
|
||||||
|
}
|
||||||
|
if (isset($range["current"])){
|
||||||
|
$range["current"]["starts"] = Application_Model_DateHelper::ConvertToLocalDateTimeString($range["current"]["starts"]);
|
||||||
|
$range["current"]["ends"] = Application_Model_DateHelper::ConvertToLocalDateTimeString($range["current"]["ends"]);
|
||||||
|
}
|
||||||
|
if (isset($range["next"])){
|
||||||
|
$range["next"]["starts"] = Application_Model_DateHelper::ConvertToLocalDateTimeString($range["next"]["starts"]);
|
||||||
|
$range["next"]["ends"] = Application_Model_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"));
|
||||||
|
|
||||||
|
$this->view->entries = $range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findPlaylistsAction()
|
public function findPlaylistsAction()
|
||||||
|
|
|
@ -245,11 +245,22 @@ class Application_Model_DateHelper
|
||||||
return $dateTime;
|
return $dateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ConvertToLocalDateTimeString($p_dateString, $format="Y-m-d H:i:s"){
|
/* Convenience method to return a date formatted into a String rather than a
|
||||||
$dateTime = new DateTime($p_dateString, new DateTimeZone("UTC"));
|
* DateTime object. Note that if an empty string is provided for $p_dateString
|
||||||
$dateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
* then the current time is provided.
|
||||||
|
*
|
||||||
return $dateTime->format($format);
|
* @param $p_dateString
|
||||||
|
* Date string in UTC timezone.
|
||||||
|
* @param $p_format
|
||||||
|
* Format which the string should be returned in.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* Date String in localtime
|
||||||
|
* */
|
||||||
|
public static function ConvertToLocalDateTimeString($p_dateString, $p_format="Y-m-d H:i:s"){
|
||||||
|
if (is_null($p_dateString) || strlen($p_dateString) == 0)
|
||||||
|
return $p_dateString;
|
||||||
|
return self::ConvertToLocalDateTime($p_dateString)->format($p_format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,9 @@ class Application_Model_Nowplaying
|
||||||
$data[] = self::CreateGapRow($gapTime);
|
$data[] = self::CreateGapRow($gapTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array("currentShow"=>Application_Model_Show::GetCurrentShow($timeNow), "rows"=>$data);
|
$rows = Application_Model_Show::GetCurrentShow($timeNow);
|
||||||
|
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||||
|
return array("currentShow"=>$rows, "rows"=>$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ShouldShowPopUp(){
|
public static function ShouldShowPopUp(){
|
||||||
|
|
|
@ -145,15 +145,18 @@ class Application_Model_Schedule {
|
||||||
|
|
||||||
$date = new Application_Model_DateHelper;
|
$date = new Application_Model_DateHelper;
|
||||||
$timeNow = $date->getTimestamp();
|
$timeNow = $date->getTimestamp();
|
||||||
return array("env"=>APPLICATION_ENV,
|
$utcTimeNow = $date->getUtcTimestamp();
|
||||||
|
$range = array("env"=>APPLICATION_ENV,
|
||||||
"schedulerTime"=>$timeNow,
|
"schedulerTime"=>$timeNow,
|
||||||
"previous"=>Application_Model_Dashboard::GetPreviousItem($timeNow),
|
"previous"=>Application_Model_Dashboard::GetPreviousItem($utcTimeNow),
|
||||||
"current"=>Application_Model_Dashboard::GetCurrentItem($timeNow),
|
"current"=>Application_Model_Dashboard::GetCurrentItem($utcTimeNow),
|
||||||
"next"=>Application_Model_Dashboard::GetNextItem($timeNow),
|
"next"=>Application_Model_Dashboard::GetNextItem($utcTimeNow),
|
||||||
"currentShow"=>Application_Model_Show::GetCurrentShow($timeNow),
|
"currentShow"=>Application_Model_Show::GetCurrentShow($utcTimeNow),
|
||||||
"nextShow"=>Application_Model_Show::GetNextShows($timeNow, 1),
|
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 1),
|
||||||
"timezone"=> date("T"),
|
"timezone"=> date("T"),
|
||||||
"timezoneOffset"=> date("Z"));
|
"timezoneOffset"=> date("Z"));
|
||||||
|
|
||||||
|
return $range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLastScheduleItem($p_timeNow){
|
public static function GetLastScheduleItem($p_timeNow){
|
||||||
|
|
|
@ -1373,20 +1373,15 @@ class Application_Model_Show {
|
||||||
public static function GetCurrentShow($timeNow)
|
public static function GetCurrentShow($timeNow)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
// Need this in the query below, so that we are NOT comparing UTC
|
|
||||||
// timestamps si.starts/si.ends with local timestamps $timeNow
|
|
||||||
$timezoneInterval = Application_Model_Show::GetTimezoneIntervalString(true);
|
|
||||||
|
|
||||||
$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"
|
$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"
|
||||||
." 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' + $timezoneInterval"
|
." AND si.starts <= TIMESTAMP '$timeNow'"
|
||||||
." AND si.ends > TIMESTAMP '$timeNow' + $timezoneInterval";
|
." AND si.ends > TIMESTAMP '$timeNow'";
|
||||||
|
|
||||||
// Convert back to local timezone
|
// Convert back to local timezone
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
@ -1404,30 +1399,24 @@ class Application_Model_Show {
|
||||||
public static function GetNextShows($timeNow, $limit, $timeEnd = "")
|
public static function GetNextShows($timeNow, $limit, $timeEnd = "")
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
// Need this in the query below, so that we are NOT comparing UTC
|
|
||||||
// timestamps si.starts with local timestamps $timeNow
|
|
||||||
$timezoneInterval = Application_Model_Show::GetTimezoneIntervalString(true);
|
|
||||||
|
|
||||||
// defaults to retrieving shows from next 2 days if no end time has
|
// defaults to retrieving shows from next 2 days if no end time has
|
||||||
// been specified
|
// been specified
|
||||||
if($timeEnd == "") {
|
if($timeEnd == "") {
|
||||||
$timeEnd = "'$timeNow' + INTERVAL '2 days' + $timezoneInterval";
|
$timeEnd = "'$timeNow' + INTERVAL '2 days'";
|
||||||
} else {
|
} else {
|
||||||
$timeEnd = "'$timeEnd' + $timezoneInterval";
|
$timeEnd = "'$timeEnd'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM "
|
$sql = "SELECT *, si.starts as start_timestamp, si.ends as end_timestamp FROM "
|
||||||
." $CC_CONFIG[showInstances] si, $CC_CONFIG[showTable] s"
|
." $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' + $timezoneInterval"
|
." AND si.starts >= TIMESTAMP '$timeNow'"
|
||||||
." AND si.starts < TIMESTAMP $timeEnd"
|
." AND si.starts < TIMESTAMP $timeEnd"
|
||||||
." ORDER BY si.starts"
|
." ORDER BY si.starts"
|
||||||
." LIMIT $limit";
|
." LIMIT $limit";
|
||||||
|
|
||||||
// Convert timestamps to local timezone
|
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("starts", "ends", "start_timestamp", "end_timestamp"));
|
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
@ -1447,12 +1436,7 @@ class Application_Model_Show {
|
||||||
//Result: 5
|
//Result: 5
|
||||||
|
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
// Need this in the query below, so that we are NOT extracting DOW and WEEK
|
|
||||||
// information from UTC timestamps si.starts, and comparing with a local
|
|
||||||
// timezone based variable $day and localtimestamp
|
|
||||||
$timezoneInterval = Application_Model_Show::GetTimezoneIntervalString();
|
|
||||||
|
|
||||||
$sql = "SELECT"
|
$sql = "SELECT"
|
||||||
." si.starts as show_starts,"
|
." si.starts as show_starts,"
|
||||||
." si.ends as show_ends,"
|
." si.ends as show_ends,"
|
||||||
|
@ -1461,13 +1445,12 @@ class Application_Model_Show {
|
||||||
." FROM $CC_CONFIG[showInstances] si"
|
." FROM $CC_CONFIG[showInstances] si"
|
||||||
." LEFT JOIN $CC_CONFIG[showTable] s"
|
." LEFT JOIN $CC_CONFIG[showTable] s"
|
||||||
." ON si.show_id = s.id"
|
." ON si.show_id = s.id"
|
||||||
." WHERE EXTRACT(DOW FROM si.starts + $timezoneInterval) = $day"
|
." WHERE EXTRACT(DOW FROM si.starts) = $day"
|
||||||
." AND EXTRACT(WEEK FROM si.starts + $timezoneInterval) = EXTRACT(WEEK FROM localtimestamp)"
|
." AND EXTRACT(WEEK FROM si.starts) = EXTRACT(WEEK FROM localtimestamp)"
|
||||||
." ORDER BY si.starts";
|
." ORDER BY si.starts";
|
||||||
|
|
||||||
// Convert result timestamps to local timezone
|
// Convert result timestamps to local timezone
|
||||||
$rows = $CC_DBC->GetAll($sql);
|
$rows = $CC_DBC->GetAll($sql);
|
||||||
Application_Model_Show::ConvertToLocalTimeZone($rows, array("show_starts", "show_ends"));
|
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
@ -1501,6 +1484,7 @@ class Application_Model_Show {
|
||||||
*
|
*
|
||||||
* @param type $fromLocalToUtc true if we're converting from local to UTC
|
* @param type $fromLocalToUtc true if we're converting from local to UTC
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
public static function GetTimeZoneIntervalString($fromLocalToUtc = false) {
|
public static function GetTimeZoneIntervalString($fromLocalToUtc = false) {
|
||||||
$date = new Application_Model_DateHelper;
|
$date = new Application_Model_DateHelper;
|
||||||
$timezoneHour = $date->getLocalOffsetHour();
|
$timezoneHour = $date->getLocalOffsetHour();
|
||||||
|
@ -1514,6 +1498,7 @@ class Application_Model_Show {
|
||||||
|
|
||||||
return "INTERVAL '$timezoneHour hours $timezoneMin minutes'";
|
return "INTERVAL '$timezoneHour hours $timezoneMin minutes'";
|
||||||
}
|
}
|
||||||
|
* */
|
||||||
|
|
||||||
public static function GetMaxLengths() {
|
public static function GetMaxLengths() {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
Loading…
Reference in New Issue