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]");
25 if ($nodes) $manager->addDependency(__FILE__
);
27 foreach ($nodes as $node) {
28 $attribute = $this->confiscateAttr($node, $this->ns
, 'absolute');
30 // $attribute is the name of the attribute to convert
31 // to absolute form, we can extend the syntax to allow
32 // multiple attributes.
33 $uri = $node->getAttribute($attribute);
35 if ($uri == '.' && $prefix) $uri = '';
36 $node->setAttribute($attribute, $prefix . $uri);