Source for file ImportantDecorator.php

Documentation is available at ImportantDecorator.php

  1. <?php
  2.  
  3. /**
  4.  * Decorator which enables !important to be used in CSS values.
  5.  */
  6. {
  7.     protected $def$allow;
  8.     
  9.     /**
  10.      * @param $def Definition to wrap
  11.      * @param $allow Whether or not to allow !important
  12.      */
  13.     public function __construct($def$allow false{
  14.         $this->def = $def;
  15.         $this->allow = $allow;
  16.     }
  17.     /**
  18.      * Intercepts and removes !important if necessary
  19.      */
  20.     public function validate($string$config$context{
  21.         // test for ! and important tokens
  22.         $string trim($string);
  23.         $is_important false;
  24.         // :TODO: optimization: test directly for !important and ! important
  25.         if (strlen($string>= && substr($string-9=== 'important'{
  26.             $temp rtrim(substr($string0-9));
  27.             // use a temp, because we might want to restore important
  28.             if (strlen($temp>= && substr($temp-1=== '!'{
  29.                 $string rtrim(substr($temp0-1));
  30.                 $is_important true;
  31.             }
  32.         }
  33.         $string $this->def->validate($string$config$context);
  34.         if ($this->allow && $is_important$string .= ' !important';
  35.         return $string;
  36.     }
  37. }

Documentation generated on Thu, 19 Jun 2008 18:49:37 -0400 by phpDocumentor 1.4.2