function parse_in($value) { if (preg_match("/(" . LENGTH_REGEXP . "|" . PERCENTAGE_REGEXP . "|" . TEXT_REGEXP . "|\\b0\\b)\\s+(" . LENGTH_REGEXP . "|" . PERCENTAGE_REGEXP . "|" . TEXT_REGEXP . "|\\b0\\b)/", $value, $matches)) { $x = $matches[1]; $y = $matches[2]; $type_x = CSSBackgroundPosition::detect_type($x); $type_y = CSSBackgroundPosition::detect_type($y); if (is_null($type_x) && is_null($type_y)) { return CSSBackgroundPosition::build_value($x, $y); } if ($type_x == BG_POSITION_SUBVALUE_TYPE_HORZ || $type_y == BG_POSITION_SUBVALUE_TYPE_VERT) { return CSSBackgroundPosition::build_value($x, $y); } return CSSBackgroundPosition::build_value($y, $x); } // These values should be processed separately at lastt if (preg_match("/\\b(top)\\b/", $value)) { return array(array(50, true), array(0, true)); } if (preg_match("/\\b(center)\\b/", $value)) { return array(array(50, true), array(50, true)); } if (preg_match("/\\b(bottom)\\b/", $value)) { return array(array(50, true), array(100, true)); } if (preg_match("/\\b(left)\\b/", $value)) { return array(array(0, true), array(50, true)); } if (preg_match("/\\b(right)\\b/", $value)) { return array(array(100, true), array(50, true)); } if (preg_match("/" . LENGTH_REGEXP . "|" . PERCENTAGE_REGEXP . "/", $value, $matches)) { $x = $matches[0]; return CSSBackgroundPosition::build_value($x, "50%"); } return null; }