4 * Implements the xc:absolute attribute, which allows links to be made
5 * relative to the XHTML Compiler configured document root (and not
6 * the absolute web root.) This greatly simplifies inter-directory linking
9 class XHTMLCompiler_DOMFilter_AbsolutePath
extends XHTMLCompiler_DOMFilter
12 protected $name = 'AbsolutePath';
13 protected $xcAttr = array('absolute');
15 public function process(DOMDocument
$dom, $page, $manager) {
17 // this is the absolute path implementation of the functionality
18 $xc = XHTMLCompiler
::getInstance();
19 $prefix = $xc->getConf('web_path') . '/';
21 // this is the relative path implementation of the functionality
22 //$prefix = str_repeat('../', $page->getDepth());
24 $nodes = $this->query("//*[@xc:absolute]");
26 foreach ($nodes as $node) {
27 $attribute = $this->confiscateAttr($node, $this->ns
, 'absolute');
29 // $attribute is the name of the attribute to convert
30 // to absolute form, we can extend the syntax to allow
31 // multiple attributes.
32 $uri = $node->getAttribute($attribute);
34 if ($uri == '.' && $prefix) $uri = '';
35 $node->setAttribute($attribute, $prefix . $uri);