Source for file Pixels.php

Documentation is available at Pixels.php

  1. <?php
  2.  
  3. /**
  4.  * Validates an integer representation of pixels according to the HTML spec.
  5.  */
  6. {
  7.     
  8.     protected $max;
  9.     
  10.     public function __construct($max null{
  11.         $this->max = $max;
  12.     }
  13.     
  14.     public function validate($string$config$context{
  15.         
  16.         $string trim($string);
  17.         if ($string === '0'return $string;
  18.         if ($string === '')  return false;
  19.         $length strlen($string);
  20.         if (substr($string$length 2== 'px'{
  21.             $string substr($string0$length 2);
  22.         }
  23.         if (!is_numeric($string)) return false;
  24.         $int = (int) $string;
  25.         
  26.         if ($int 0return '0';
  27.         
  28.         // upper-bound value, extremely high values can
  29.         // crash operating systems, see <http://ha.ckers.org/imagecrash.html>
  30.         // WARNING, above link WILL crash you if you're using Windows
  31.         
  32.         if ($this->max !== null && $int $this->maxreturn (string) $this->max;
  33.         
  34.         return (string) $int;
  35.         
  36.     }
  37.     
  38.     public function make($string{
  39.         if ($string === ''$max null;
  40.         else $max = (int) $string;
  41.         $class get_class($this);
  42.         return new $class($max);
  43.     }
  44.     
  45. }

Documentation generated on Thu, 19 Jun 2008 18:50:12 -0400 by phpDocumentor 1.4.2