/** * Set the background image url * * @link http://www.w3.org/TR/CSS21/colors.html#background-properties * @param string $url */ function set_background_image($val) { if (mb_strpos($val, "url") !== false) { $val = preg_replace("/url\\(['\"]?([^'\")]+)['\"]?\\)/", "\\1", trim($val)); } else { $val = "none"; } // Resolve the url now in the context of the current stylesheet $parsed_url = explode_url($val); if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") { $url = realpath($this->_stylesheet->get_base_path() . $parsed_url["file"]); } else { $url = build_url($this->_stylesheet->get_protocol(), $this->_stylesheet->get_host(), $this->_stylesheet->get_base_path(), $val); } $this->_props["background_image"] = $url; }
protected function _image($val) { $DEBUGCSS = DEBUGCSS; $parsed_url = "none"; if (mb_strpos($val, "url") === false) { $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none } else { $val = preg_replace("/url\\(['\"]?([^'\")]+)['\"]?\\)/", "\\1", trim($val)); // Resolve the url now in the context of the current stylesheet $parsed_url = explode_url($val); if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") { if ($parsed_url["path"][0] === '/' || $parsed_url["path"][0] === '\\') { $path = $_SERVER["DOCUMENT_ROOT"] . '/'; } else { $path = $this->_stylesheet->get_base_path(); } $path .= $parsed_url["path"] . $parsed_url["file"]; $path = realpath($path); // If realpath returns FALSE then specifically state that there is no background image if (!$path) { $path = 'none'; } } else { $path = build_url($this->_stylesheet->get_protocol(), $this->_stylesheet->get_host(), $this->_stylesheet->get_base_path(), $val); } } if ($DEBUGCSS) { print "<pre>[_image\n"; print_r($parsed_url); print $this->_stylesheet->get_protocol() . "\n" . $this->_stylesheet->get_base_path() . "\n" . $path . "\n"; print "_image]</pre>"; } return $path; }