Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
c61f74b06f
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
class Application_Model_DateHelper
|
||||
class Application_Common_DateHelper
|
||||
{
|
||||
private $_dateTime;
|
||||
|
||||
|
@ -83,8 +83,8 @@ class Application_Model_DateHelper
|
|||
}
|
||||
|
||||
public static function GetDayEndTimestampInUtc($time = "") {
|
||||
$dayEndTimestamp = Application_Model_DateHelper::GetDayEndTimestamp($time);
|
||||
return Application_Model_DateHelper::ConvertToUtcDateTimeString($dayEndTimestamp);
|
||||
$dayEndTimestamp = Application_Common_DateHelper::GetDayEndTimestamp($time);
|
||||
return Application_Common_DateHelper::ConvertToUtcDateTimeString($dayEndTimestamp);
|
||||
}
|
||||
|
||||
/**
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
class Application_Common_OsPath{
|
||||
// this function is from http://stackoverflow.com/questions/2670299/is-there-a-php-equivalent-function-to-the-python-os-path-normpath
|
||||
public static function normpath($path)
|
||||
{
|
||||
if (empty($path))
|
||||
return '.';
|
||||
|
||||
if (strpos($path, '/') === 0)
|
||||
$initial_slashes = true;
|
||||
else
|
||||
$initial_slashes = false;
|
||||
if (
|
||||
($initial_slashes) &&
|
||||
(strpos($path, '//') === 0) &&
|
||||
(strpos($path, '///') === false)
|
||||
)
|
||||
$initial_slashes = 2;
|
||||
$initial_slashes = (int) $initial_slashes;
|
||||
|
||||
$comps = explode('/', $path);
|
||||
$new_comps = array();
|
||||
foreach ($comps as $comp)
|
||||
{
|
||||
if (in_array($comp, array('', '.')))
|
||||
continue;
|
||||
if (
|
||||
($comp != '..') ||
|
||||
(!$initial_slashes && !$new_comps) ||
|
||||
($new_comps && (end($new_comps) == '..'))
|
||||
)
|
||||
array_push($new_comps, $comp);
|
||||
elseif ($new_comps)
|
||||
array_pop($new_comps);
|
||||
}
|
||||
$comps = $new_comps;
|
||||
$path = implode('/', $comps);
|
||||
if ($initial_slashes)
|
||||
$path = str_repeat('/', $initial_slashes) . $path;
|
||||
if ($path)
|
||||
return $path;
|
||||
else
|
||||
return '.';
|
||||
}
|
||||
}
|
|
@ -258,7 +258,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$utcTimeNow = $date->getUtcTimestamp();
|
||||
$utcTimeEnd = ""; // if empty, GetNextShows will use interval instead of end of day
|
||||
|
||||
|
@ -266,7 +266,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$type = $request->getParam('type');
|
||||
if($type == "endofday") {
|
||||
// make GetNextShows use end of day
|
||||
$utcTimeEnd = Application_Model_DateHelper::GetDayEndTimestampInUtc();
|
||||
$utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc();
|
||||
}
|
||||
|
||||
$limit = $request->getParam('limit');
|
||||
|
@ -298,15 +298,15 @@ class ApiController extends Zend_Controller_Action
|
|||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$dayStart = $date->getWeekStartDate();
|
||||
$utcDayStart = Application_Model_DateHelper::ConvertToUtcDateTimeString($dayStart);
|
||||
$utcDayStart = Application_Common_DateHelper::ConvertToUtcDateTimeString($dayStart);
|
||||
|
||||
$dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
|
||||
|
||||
$result = array();
|
||||
for ($i=0; $i<7; $i++){
|
||||
$utcDayEnd = Application_Model_DateHelper::GetDayEndTimestamp($utcDayStart);
|
||||
$utcDayEnd = Application_Common_DateHelper::GetDayEndTimestamp($utcDayStart);
|
||||
$shows = Application_Model_Show::GetNextShows($utcDayStart, "0", $utcDayEnd);
|
||||
$utcDayStart = $utcDayEnd;
|
||||
|
||||
|
@ -394,8 +394,8 @@ class ApiController extends Zend_Controller_Action
|
|||
$end_timestamp = $now->add(new DateInterval("PT2H"));
|
||||
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
|
||||
|
||||
$this->view->shows = Application_Model_Show::getShows(Application_Model_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()),
|
||||
Application_Model_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
|
||||
$this->view->shows = Application_Model_Show::getShows(Application_Common_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()),
|
||||
Application_Common_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
|
||||
$excludeInstance=NULL, $onlyRecord=TRUE);
|
||||
|
||||
|
||||
|
@ -467,7 +467,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$show_inst->setRecordedFile($file_id);
|
||||
$show_name = $show_inst->getName();
|
||||
$show_genre = $show_inst->getGenre();
|
||||
$show_start_time = Application_Model_DateHelper::ConvertToLocalDateTimeString($show_inst->getShowInstanceStart());
|
||||
$show_start_time = Application_Common_DateHelper::ConvertToLocalDateTimeString($show_inst->getShowInstanceStart());
|
||||
|
||||
} catch (Exception $e){
|
||||
//we've reached here probably because the show was
|
||||
|
|
|
@ -224,8 +224,8 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
$isDJ = $user->isHost($instance->getShowId());
|
||||
|
||||
$showStartLocalDT = Application_Model_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
|
||||
$showEndLocalDT = Application_Model_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
|
||||
$showStartLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceStart());
|
||||
$showEndLocalDT = Application_Common_DateHelper::ConvertToLocalDateTime($instance->getShowInstanceEnd());
|
||||
|
||||
if ($epochNow < $showStartLocalDT->getTimestamp()) {
|
||||
|
||||
|
@ -338,16 +338,16 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
/* 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"]);
|
||||
$range["previous"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["previous"]["starts"]);
|
||||
$range["previous"]["ends"] = Application_Common_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"]);
|
||||
$range["current"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["current"]["starts"]);
|
||||
$range["current"]["ends"] = Application_Common_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"]);
|
||||
$range["next"]["starts"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["starts"]);
|
||||
$range["next"]["ends"] = Application_Common_DateHelper::ConvertToLocalDateTimeString($range["next"]["ends"]);
|
||||
}
|
||||
|
||||
Application_Model_Show::ConvertToLocalTimeZone($range["currentShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
|
@ -425,7 +425,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
//convert from UTC to user's timezone for display.
|
||||
$originalDateTime = new DateTime($originalShowStart, new DateTimeZone("UTC"));
|
||||
$originalDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
//$timestamp = Application_Model_DateHelper::ConvertToLocalDateTimeString($originalDateTime->format("Y-m-d H:i:s"));
|
||||
//$timestamp = Application_Common_DateHelper::ConvertToLocalDateTimeString($originalDateTime->format("Y-m-d H:i:s"));
|
||||
$this->view->additionalShowInfo =
|
||||
"Rebroadcast of show \"$originalShowName\" from "
|
||||
.$originalDateTime->format("l, F jS")." at ".$originalDateTime->format("G:i");
|
||||
|
@ -643,7 +643,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$i = 1;
|
||||
foreach ($rebroadcastsRelative as $rebroadcast){
|
||||
$rebroadcastFormValues["add_show_rebroadcast_date_$i"] = $rebroadcast['day_offset'];
|
||||
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Application_Model_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
|
||||
$rebroadcastFormValues["add_show_rebroadcast_time_$i"] = Application_Common_DateHelper::removeSecondsFromTime($rebroadcast['start_time']);
|
||||
$i++;
|
||||
}
|
||||
$formRebroadcast->populate($rebroadcastFormValues);
|
||||
|
@ -761,7 +761,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
//Changing the start date was disabled, since the
|
||||
//array key does not exist. We need to repopulate this entry from the db.
|
||||
//The start date will be returned in UTC time, so lets convert it to local time.
|
||||
$dt = Application_Model_DateHelper::ConvertToLocalDateTime($show->getStartDate());
|
||||
$dt = Application_Common_DateHelper::ConvertToLocalDateTime($show->getStartDate());
|
||||
$data['add_show_start_date'] = $dt->format("Y-m-d");
|
||||
$validateStartDate = false;
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ class Application_Model_MusicDir {
|
|||
if(!is_dir($p_path)){
|
||||
return array("code"=>2, "error"=>"'$p_path' is not a valid directory.");
|
||||
}
|
||||
$real_path = realpath($p_path)."/";
|
||||
$real_path = Application_Common_OsPath::normpath($p_path)."/";
|
||||
if($real_path != "/"){
|
||||
$p_path = $real_path;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ class Application_Model_MusicDir {
|
|||
}
|
||||
|
||||
$dir->setType($p_type);
|
||||
$p_path = realpath($p_path)."/";
|
||||
$p_path = Application_Common_OsPath::normpath($p_path)."/";
|
||||
|
||||
|
||||
try {
|
||||
|
@ -245,7 +245,7 @@ class Application_Model_MusicDir {
|
|||
|
||||
//newly added watched directory object
|
||||
$propel_new_watch = CcMusicDirsQuery::create()
|
||||
->filterByDirectory(realpath($p_path)."/")
|
||||
->filterByDirectory(Application_Common_OsPath::normpath($p_path)."/")
|
||||
->findOne();
|
||||
|
||||
//any files of the deprecated "link" type.
|
||||
|
@ -344,7 +344,7 @@ class Application_Model_MusicDir {
|
|||
{
|
||||
// we want to be consistent when storing dir path.
|
||||
// path should always ends with trailing '/'
|
||||
$p_dir = realpath($p_dir)."/";
|
||||
$p_dir = Application_Common_OsPath::normpath($p_dir)."/";
|
||||
if(!is_dir($p_dir)){
|
||||
return array("code"=>2, "error"=>"'$p_dir' is not a valid directory.");
|
||||
}else if(Application_Model_Preference::GetImportTimestamp()+10 > time()){
|
||||
|
@ -396,7 +396,7 @@ class Application_Model_MusicDir {
|
|||
* otherwise, it will set "Exists" flag to true
|
||||
**/
|
||||
public static function removeWatchedDir($p_dir, $userAddedWatchedDir=true){
|
||||
$real_path = realpath($p_dir)."/";
|
||||
$real_path = Application_Common_OsPath::normpath($p_dir)."/";
|
||||
if($real_path != "/"){
|
||||
$p_dir = $real_path;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class Application_Model_Schedule {
|
|||
return array();
|
||||
}
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timeNow = $date->getTimestamp();
|
||||
$utcTimeNow = $date->getUtcTimestamp();
|
||||
|
||||
|
@ -563,8 +563,8 @@ class Application_Model_Schedule {
|
|||
'uri' => $uri,
|
||||
'fade_in' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_in"]),
|
||||
'fade_out' => Application_Model_Schedule::WallTimeToMillisecs($item["fade_out"]),
|
||||
'cue_in' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_in"]),
|
||||
'cue_out' => Application_Model_DateHelper::CalculateLengthInSeconds($item["cue_out"]),
|
||||
'cue_in' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_in"]),
|
||||
'cue_out' => Application_Common_DateHelper::CalculateLengthInSeconds($item["cue_out"]),
|
||||
'start' => $start,
|
||||
'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]),
|
||||
'show_name' => $showName
|
||||
|
|
|
@ -520,7 +520,7 @@ class Application_Model_Show {
|
|||
$timestamp = gmdate("Y-m-d H:i:s");
|
||||
|
||||
if(is_null($p_date)) {
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$p_date = $date->getDate();
|
||||
}
|
||||
|
||||
|
@ -663,7 +663,7 @@ class Application_Model_Show {
|
|||
* true if the StartDate is in the past, false otherwise
|
||||
*/
|
||||
public function isStartDateTimeInPast(){
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$current_timestamp = $date->getUtcTimestamp();
|
||||
return ($current_timestamp > ($this->getStartDate()." ".$this->getStartTime()));
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ class Application_Model_Show {
|
|||
public function getAllFutureInstanceIds(){
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$showId = $this->getId();
|
||||
|
@ -708,7 +708,7 @@ class Application_Model_Show {
|
|||
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
$sql = "UPDATE cc_show_days "
|
||||
|
@ -729,7 +729,7 @@ class Application_Model_Show {
|
|||
|
||||
global $CC_DBC;
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timestamp = $date->getTimestamp();
|
||||
|
||||
//TODO fix this from overwriting info.
|
||||
|
@ -1313,9 +1313,9 @@ class Application_Model_Show {
|
|||
$start = $first_show." ".$start_time;
|
||||
}
|
||||
|
||||
$utcStartDateTime = Application_Model_DateHelper::ConvertToUtcDateTime($start, $timezone);
|
||||
$utcStartDateTime = Application_Common_DateHelper::ConvertToUtcDateTime($start, $timezone);
|
||||
//convert $last_show into a UTC DateTime object, or null if there is no last show.
|
||||
$utcLastShowDateTime = $last_show ? Application_Model_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
||||
$utcLastShowDateTime = $last_show ? Application_Common_DateHelper::ConvertToUtcDateTime($last_show, $timezone) : null;
|
||||
|
||||
$sql = "SELECT * FROM cc_show_rebroadcast WHERE show_id={$show_id}";
|
||||
$rebroadcasts = $CC_DBC->GetAll($sql);
|
||||
|
@ -1736,7 +1736,7 @@ class Application_Model_Show {
|
|||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if($timeNow == null){
|
||||
$date = new Application_Model_DateHelper;
|
||||
$date = new Application_Common_DateHelper;
|
||||
$timeNow = $date->getUtcTimestamp();
|
||||
}
|
||||
//TODO, returning starts + ends twice (once with an alias). Unify this after the 2.0 release. --Martin
|
||||
|
@ -1896,7 +1896,7 @@ class Application_Model_Show {
|
|||
}
|
||||
foreach($rows as &$row) {
|
||||
foreach($columnsToConvert as $column) {
|
||||
$row[$column] = Application_Model_DateHelper::ConvertToLocalDateTimeString($row[$column]);
|
||||
$row[$column] = Application_Common_DateHelper::ConvertToLocalDateTimeString($row[$column]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ set_include_path(implode(PATH_SEPARATOR, array(
|
|||
realpath(APPLICATION_PATH . '/../library')
|
||||
)));
|
||||
|
||||
set_include_path(APPLICATION_PATH . '/common' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
//Propel classes.
|
||||
set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
|
|
Loading…
Reference in New Issue