differenciate in our serverside user-agent detection between Chrome and Safari, and disable html5 form validation for float, as Chrome 12 rejects float values with comma as decimal separator

This commit is contained in:
Ralf Becker 2011-07-07 11:50:06 +00:00
parent 8d9003fbf8
commit 4f60da9af5
2 changed files with 7 additions and 2 deletions

View File

@ -1243,6 +1243,11 @@ class etemplate extends boetemplate
// a few html5 options // a few html5 options
if ((string)$min !== '') $options .= ' min="'.htmlspecialchars($min).'"'; if ((string)$min !== '') $options .= ' min="'.htmlspecialchars($min).'"';
if ((string)$max !== '') $options .= ' max="'.htmlspecialchars($max).'"'; if ((string)$max !== '') $options .= ' max="'.htmlspecialchars($max).'"';
// disable html5 form validation for float, as Chrome 12 rejects float values with comma as decimal separator
if ($type == 'float' && !$readonly && html::$user_agent == 'chrome' && strpos(self::$form_options,'novalidate') === false)
{
self::$form_options .= ' novalidate="novalidate"';
}
if ($cell_options == '' && !$readonly) if ($cell_options == '' && !$readonly)
{ {
$cell_options = $cell['type'] == 'int' ? 5 : 8; $cell_options = $cell['type'] == 'int' ? 5 : 8;

View File

@ -20,7 +20,7 @@
class html class html
{ {
/** /**
* user-agent: 'firefox', 'msie', 'safari' (incl. iPhone, Chrome), 'opera', 'konqueror', 'mozilla' * user-agent: 'firefox', 'msie', 'safari' (incl. iPhone), 'chrome', 'opera', 'konqueror', 'mozilla'
* @var string * @var string
*/ */
static $user_agent; static $user_agent;
@ -65,7 +65,7 @@ class html
if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts)) if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts))
{ {
preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts,PREG_SET_ORDER); preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts,PREG_SET_ORDER);
$parts = array_pop($parts); $parts = $parts[2][1] == 'Chrome' ? $parts[2] : array_pop($parts);
} }
list(,self::$user_agent,self::$ua_version) = $parts; list(,self::$user_agent,self::$ua_version) = $parts;
if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera'; if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera';