diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index 29c819fac..19e3fc064 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -27,23 +27,23 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm ) )); - //Default station fade in - $this->addElement('text', 'stationDefaultCrossfadeDuration', array( - 'class' => 'input_text', - 'label' => _('Default Crossfade Duration (s):'), - 'required' => true, - 'filters' => array('StringTrim'), - 'validators' => array( - array( - $rangeValidator, - $notEmptyValidator, - 'regex', false, array('/^[0-9]{1,2}(\.\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')) - ) - ), - 'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(), - 'decorators' => array( - 'ViewHelper' - ) + //Default station fade in + $this->addElement('text', 'stationDefaultCrossfadeDuration', array( + 'class' => 'input_text', + 'label' => _('Default Crossfade Duration (s):'), + 'required' => true, + 'filters' => array('StringTrim'), + 'validators' => array( + array( + $rangeValidator, + $notEmptyValidator, + 'regex', false, array('/^[0-9]{1,2}(\.\d{1})?$/', 'messages' => _('enter a time in seconds 0{.0}')) + ) + ), + 'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(), + 'decorators' => array( + 'ViewHelper' + ) )); //Default station fade in diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 0735c87e4..f2eeee8a4 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -195,21 +195,21 @@ class Application_Model_Preference } } - public static function SetDefaultCrossfadeDuration($duration) - { - self::setValue("default_crossfade_duration", $duration); - } - - public static function GetDefaultCrossfadeDuration() - { - $duration = self::getValue("default_crossfade_duration"); - - if ($duration === "") { - // the default value of the fade is 00.5 - return "0"; - } - - return $duration; + public static function SetDefaultCrossfadeDuration($duration) + { + self::setValue("default_crossfade_duration", $duration); + } + + public static function GetDefaultCrossfadeDuration() + { + $duration = self::getValue("default_crossfade_duration"); + + if ($duration === "") { + // the default value of the fade is 00.5 + return "0"; + } + + return $duration; } public static function SetDefaultFadeIn($fade) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 77527f72f..7f6272cee 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -262,8 +262,8 @@ class Application_Model_Scheduler $cueout = Application_Common_DateHelper::calculateLengthInSeconds($data["cueout"]); $data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein); - //fade is in format SS.uuuuuu - $data["fadein"] = Application_Model_Preference::GetDefaultFadeIn(); + //fade is in format SS.uuuuuu + $data["fadein"] = Application_Model_Preference::GetDefaultFadeIn(); $data["fadeout"] = Application_Model_Preference::GetDefaultFadeOut(); $data["type"] = 0; @@ -333,29 +333,29 @@ class Application_Model_Scheduler return $files; } - /* - * @param DateTime startDT in UTC - * @param string duration - * in format H:i:s.u (could be more that 24 hours) - * - * @return DateTime endDT in UTC - */ - private function findTimeDifference($p_startDT, $p_seconds) - { - $startEpoch = $p_startDT->format("U.u"); - - //add two float numbers to 6 subsecond precision - //DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number. - $newEpoch = bcsub($startEpoch , (string) $p_seconds, 6); - - $dt = DateTime::createFromFormat("U.u", $newEpoch, new DateTimeZone("UTC")); - - if ($dt === false) { - //PHP 5.3.2 problem - $dt = DateTime::createFromFormat("U", intval($newEpoch), new DateTimeZone("UTC")); - } - - return $dt; + /* + * @param DateTime startDT in UTC + * @param string duration + * in format H:i:s.u (could be more that 24 hours) + * + * @return DateTime endDT in UTC + */ + private function findTimeDifference($p_startDT, $p_seconds) + { + $startEpoch = $p_startDT->format("U.u"); + + //add two float numbers to 6 subsecond precision + //DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number. + $newEpoch = bcsub($startEpoch , (string) $p_seconds, 6); + + $dt = DateTime::createFromFormat("U.u", $newEpoch, new DateTimeZone("UTC")); + + if ($dt === false) { + //PHP 5.3.2 problem + $dt = DateTime::createFromFormat("U", intval($newEpoch), new DateTimeZone("UTC")); + } + + return $dt; } /* @@ -415,41 +415,41 @@ class Application_Model_Scheduler return $nextDT; } - /* - * @param int $showInstance + /* + * @param int $showInstance * This function recalculates the start/end times of items in a gapless show to - * account for crossfade durations. - */ - private function calculateCrossfades($showInstance) - { - Logging::info("adjusting start, end times of scheduled items to account for crossfades show instance #".$showInstance); - - $instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con); - if (is_null($instance)) { - throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!")); - } - + * account for crossfade durations. + */ + private function calculateCrossfades($showInstance) + { + Logging::info("adjusting start, end times of scheduled items to account for crossfades show instance #".$showInstance); + + $instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con); + if (is_null($instance)) { + throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!")); + } + $itemStartDT = $instance->getDbStarts(null); - $itemEndDT = null; - - $schedule = CcScheduleQuery::create() - ->filterByDbInstanceId($showInstance) - ->orderByDbStarts() - ->find($this->con); - - foreach ($schedule as $item) { + $itemEndDT = null; + + $schedule = CcScheduleQuery::create() + ->filterByDbInstanceId($showInstance) + ->orderByDbStarts() + ->find($this->con); + + foreach ($schedule as $item) { $itemEndDT = $item->getDbEnds(null); - + $item - ->setDbStarts($itemStartDT) - ->setDbEnds($itemEndDT); - + ->setDbStarts($itemStartDT) + ->setDbEnds($itemEndDT); + $itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration); - $itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength()); - } - - $schedule->save($this->con); + $itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength()); + } + + $schedule->save($this->con); } /*