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:
Albert Santoni 2015-01-13 12:18:57 -05:00
parent 17a577fbbb
commit caf37e1b87
3 changed files with 16 additions and 52 deletions

View file

@ -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)