Source for file Color.php
Documentation is available at Color.php
* Validates Color as defined by CSS.
public function validate($color, $config, $context) {
if ($colors ===
null) $colors =
$config->get('Core', 'ColorKeywords');
if ($color ===
'') return false;
if (isset
($colors[$lower])) return $colors[$lower];
if (strpos($color, 'rgb(') !==
false) {
if (strpos($color, ')') !==
$length -
1) return false;
$triad =
substr($color, 4, $length -
4 -
1);
if (count($parts) !==
3) return false;
$type =
false; // to ensure that they're all the same type
foreach ($parts as $part) {
if ($part ===
'') return false;
if ($part[$length -
1] ===
'%') {
} elseif ($type !==
'percentage') {
$num = (float)
substr($part, 0, $length -
1);
if ($num >
100) $num =
100;
} elseif ($type !==
'integer') {
if ($num >
255) $num =
255;
$new_parts[] = (string)
$num;
$new_triad =
implode(',', $new_parts);
$color =
"rgb($new_triad)";
if ($length !==
3 &&
$length !==
6) return false;
Documentation generated on Thu, 19 Jun 2008 18:48:56 -0400 by phpDocumentor 1.4.2