CC-5975: Default fade-in/out, and crossfade time validators don't work
* Fixed the number formatting and validation in the preferences and streaming preferences (the silly 00.5-style numbers are gone) * Regex decmical validation of the default fade-in, fade-out, and crossfade duration was totally broken (you could enter words and it would work). That's fixed now.
This commit is contained in:
parent
17a577fbbb
commit
caf37e1b87
3 changed files with 16 additions and 52 deletions
|
@ -34,11 +34,9 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
'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}'))
|
||||
)
|
||||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
'value' => Application_Model_Preference::GetDefaultCrossfadeDuration(),
|
||||
'decorators' => array(
|
||||
|
@ -53,11 +51,9 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
'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}'))
|
||||
)
|
||||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
'value' => $defaultFadeIn,
|
||||
'decorators' => array(
|
||||
|
@ -72,11 +68,9 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
'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}'))
|
||||
)
|
||||
array('regex', false, array('/^[0-9]+(\.\d+)?$/', 'messages' => _('Please enter a time in seconds (eg. 0.5)')))
|
||||
),
|
||||
'value' => $defaultFadeOut,
|
||||
'decorators' => array(
|
||||
|
|
|
@ -10,9 +10,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true";
|
||||
|
||||
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
||||
if ($defaultFade == "") {
|
||||
$defaultFade = '00.000000';
|
||||
}
|
||||
|
||||
// automatic trasition on source disconnection
|
||||
$auto_transition = new Zend_Form_Element_Checkbox("auto_transition");
|
||||
|
@ -32,8 +29,8 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$transition_fade = new Zend_Form_Element_Text("transition_fade");
|
||||
$transition_fade->setLabel(_("Switch Transition Fade (s)"))
|
||||
->setFilters(array('StringTrim'))
|
||||
->addValidator('regex', false, array('/^[0-9]{1,2}(\.\d{1,6})?$/',
|
||||
'messages' => _('enter a time in seconds 00{.000000}')))
|
||||
->addValidator('regex', false, array('/^[0-9]{1,2}(\.\d{1,3})?$/',
|
||||
'messages' => _('enter a time in seconds 0{.000}')))
|
||||
->setValue($defaultFade)
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($transition_fade);
|
||||
|
|
|
@ -263,7 +263,7 @@ class Application_Model_Preference
|
|||
|
||||
if ($fade === "") {
|
||||
// the default value of the fade is 00.5
|
||||
return "00.5";
|
||||
return "0.5";
|
||||
}
|
||||
|
||||
return $fade;
|
||||
|
@ -279,8 +279,8 @@ class Application_Model_Preference
|
|||
$fade = self::getValue("default_fade_out");
|
||||
|
||||
if ($fade === "") {
|
||||
// the default value of the fade is 00.5
|
||||
return "00.5";
|
||||
// the default value of the fade is 0.5
|
||||
return "0.5";
|
||||
}
|
||||
|
||||
return $fade;
|
||||
|
@ -291,33 +291,6 @@ class Application_Model_Preference
|
|||
self::setValue("default_fade", $fade);
|
||||
}
|
||||
|
||||
public static function GetDefaultFade()
|
||||
{
|
||||
$fade = self::getValue("default_fade");
|
||||
|
||||
if ($fade === "") {
|
||||
// the default value of the fade is 00.5
|
||||
return "00.5";
|
||||
}
|
||||
|
||||
// we need this function to work with 2.0 version on default_fade value in cc_pref
|
||||
// it has 00:00:00.000000 format where in 2.1 we have 00.000000 format
|
||||
if (preg_match("/([0-9]{2}):([0-9]{2}):([0-9]{2}).([0-9]{6})/", $fade, $matches) == 1 && count($matches) == 5) {
|
||||
$out = 0;
|
||||
$out += intval($matches[1] * 3600);
|
||||
$out += intval($matches[2] * 60);
|
||||
$out += intval($matches[3]);
|
||||
$out .= ".$matches[4]";
|
||||
$fade = $out;
|
||||
}
|
||||
|
||||
$fade = number_format($fade, 1, '.', '');
|
||||
//fades need 2 leading zeros for DateTime conversion
|
||||
$fade = str_pad($fade, 4, "0", STR_PAD_LEFT);
|
||||
|
||||
return $fade;
|
||||
}
|
||||
|
||||
public static function SetDefaultTransitionFade($fade)
|
||||
{
|
||||
self::setValue("default_transition_fade", $fade);
|
||||
|
@ -330,7 +303,7 @@ class Application_Model_Preference
|
|||
public static function GetDefaultTransitionFade()
|
||||
{
|
||||
$transition_fade = self::getValue("default_transition_fade");
|
||||
return ($transition_fade == "") ? "00.000000" : $transition_fade;
|
||||
return ($transition_fade == "") ? "0.000" : $transition_fade;
|
||||
}
|
||||
|
||||
public static function SetStreamLabelFormat($type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue