CSSPropertyHandler(false, false); $this->_defaultValue = BorderPDF::create(array('top' => array('width' => Value::fromString('2px'), 'color' => array(0,0,0), 'style' => BS_NONE), 'right' => array('width' => Value::fromString('2px'), 'color' => array(0,0,0), 'style' => BS_NONE), 'bottom' => array('width' => Value::fromString('2px'), 'color' => array(0,0,0), 'style' => BS_NONE), 'left' => array('width' => Value::fromString('2px'), 'color' => array(0,0,0), 'style' => BS_NONE))); } function default_value() { return $this->_defaultValue; } 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->set_value($border, $border_color); break; case BORDER_VALUE_WIDTH: $width_handler = CSS::get_handler(CSS_BORDER_WIDTH); $border_width = $width_handler->parse($subvalue); $width_handler->set_value($border, $border_width); break; case BORDER_VALUE_STYLE: $style_handler = CSS::get_handler(CSS_BORDER_STYLE); $border_style = $style_handler->parse($subvalue); $style_handler->set_value($border, $border_style); break; }; }; return $border; } function get_property_code() { return CSS_BORDER; } function get_property_name() { return 'border'; } function detect_border_value_type($value) { $color = _parse_color_declaration($value, $success); if ($success) { return BORDER_VALUE_COLOR; }; // if (preg_match("/\b(transparent|black|silver|gray|white|maroon|red|purple|fuchsia|green|lime|olive|yellow|navy|blue|teal|aqua|rgb(.*?))\b/i",$value)) { return BORDER_VALUE_COLOR; }; // // We must detect hecadecimal values separately, as #-sign will not match the \b metacharacter at the beginning of previous regexp // if (preg_match("/#([[:xdigit:]]{3}|[[:xdigit:]]{6})\b/i",$value)) { return BORDER_VALUE_COLOR; }; // Note that unit name is in general not required, so that we can meet rule like "border: 0" in CSS! if (preg_match("/\b(thin|medium|thick|[+-]?\d+(.\d*)?(em|ex|px|in|cm|mm|pt|pc)?)\b/i",$value)) { return BORDER_VALUE_WIDTH; }; if (preg_match("/\b(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)\b/",$value)) { return BORDER_VALUE_STYLE; }; return; } } $border = new CSSBorder(); CSS::register_css_property($border); CSS::register_css_property(new CSSBorderColor($border)); CSS::register_css_property(new CSSBorderWidth($border)); CSS::register_css_property(new CSSBorderStyle($border)); CSS::register_css_property(new CSSBorderTop($border, 'top')); CSS::register_css_property(new CSSBorderRight($border, 'right')); CSS::register_css_property(new CSSBorderBottom($border, 'bottom')); CSS::register_css_property(new CSSBorderLeft($border, 'left')); CSS::register_css_property(new CSSBorderLeftColor($border)); CSS::register_css_property(new CSSBorderTopColor($border)); CSS::register_css_property(new CSSBorderRightColor($border)); CSS::register_css_property(new CSSBorderBottomColor($border)); CSS::register_css_property(new CSSBorderLeftStyle($border)); CSS::register_css_property(new CSSBorderTopStyle($border)); CSS::register_css_property(new CSSBorderRightStyle($border)); CSS::register_css_property(new CSSBorderBottomStyle($border)); CSS::register_css_property(new CSSBorderLeftWidth($border)); CSS::register_css_property(new CSSBorderTopWidth($border)); CSS::register_css_property(new CSSBorderRightWidth($border)); CSS::register_css_property(new CSSBorderBottomWidth($border)); ?>