Source for file Number.php
Documentation is available at Number.php
* Validates a number as defined by the CSS spec.
* Bool indicating whether or not only positive values allowed.
* @param $non_negative Bool indicating whether negatives are forbidden
* @warning Some contexts do not pass $config, $context. These
* variables should not be used without checking HTMLPurifier_Length
public function validate($number, $config, $context) {
if ($number ===
'') return false;
if ($number ===
'0') return '0';
$number =
ltrim($number, '0');
return $number ?
$sign .
$number :
'0';
// Period is the only non-numeric character allowed
if (strpos($number, '.') ===
false) return false;
list
($left, $right) =
explode('.', $number, 2);
if ($left ===
'' &&
$right ===
'') return false;
$left =
ltrim($left, '0');
$right =
rtrim($right, '0');
return $left ?
$sign .
$left :
'0';
return $sign .
$left .
'.' .
$right;
Documentation generated on Thu, 19 Jun 2008 18:49:50 -0400 by phpDocumentor 1.4.2