Source for file Color.php

Documentation is available at Color.php

  1. <?php
  2.  
  3. /**
  4.  * Validates a color according to the HTML spec.
  5.  */
  6. {
  7.     
  8.     public function validate($string$config$context{
  9.         
  10.         static $colors null;
  11.         if ($colors === null$colors $config->get('Core''ColorKeywords');
  12.         
  13.         $string trim($string);
  14.         
  15.         if (empty($string)) return false;
  16.         if (isset($colors[$string])) return $colors[$string];
  17.         if ($string[0=== '#'$hex substr($string1);
  18.         else $hex $string;
  19.         
  20.         $length strlen($hex);
  21.         if ($length !== && $length !== 6return false;
  22.         if (!ctype_xdigit($hex)) return false;
  23.         if ($length === 3$hex $hex[0].$hex[0].$hex[1].$hex[1].$hex[2].$hex[2];
  24.         
  25.         return "#$hex";
  26.         
  27.     }
  28.     
  29. }

Documentation generated on Thu, 19 Jun 2008 18:48:55 -0400 by phpDocumentor 1.4.2