Example #1
0
 function parse($value)
 {
     if ($value == 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     // Remove spaces between color values in rgb() color definition; this will allow us to tread
     // this declaration as a single value
     $value = preg_replace("/\\s*,\\s*/", ",", $value);
     // Remove spaces before and after parens in rgb color definition
     $value = preg_replace("/rgb\\s*\\(\\s*(.*?)\\s*\\)/", 'rgb(\\1)', $value);
     $subvalues = explode(" ", $value);
     $border = CSS::getDefaultValue(CSS_BORDER);
     foreach ($subvalues as $subvalue) {
         $subvalue = trim(strtolower($subvalue));
         switch (CSSBorder::detect_border_value_type($subvalue)) {
             case BORDER_VALUE_COLOR:
                 $color_handler = CSS::get_handler(CSS_BORDER_COLOR);
                 $border_color = $color_handler->parse($subvalue);
                 $color_handler->setValue($border, $border_color);
                 break;
             case BORDER_VALUE_WIDTH:
                 $width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
                 $border_width = $width_handler->parse($subvalue);
                 $width_handler->setValue($border, $border_width);
                 break;
             case BORDER_VALUE_STYLE:
                 $style_handler = CSS::get_handler(CSS_BORDER_STYLE);
                 $border_style = $style_handler->parse($subvalue);
                 $style_handler->setValue($border, $border_style);
                 break;
         }
     }
     return $border;
 }
 function parse($value)
 {
     if ($value == 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     $border = CSSBorder::parse($value);
     return $border->left;
 }