Improve documentation.
[xhtml-compiler.git] / XHTMLCompiler / DOMFilter / AbsolutePath.php
blob419a9eed645baec1032403abb1f8565f46be4f35
1 <?php
3 /**
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
7 * and styling.
8 */
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 an absolute path implementation of the functionality
18 //$xc = XHTMLCompiler::getInstance();
19 //$prefix = $xc->getConf('web_path') . '/';
21 $prefix = str_repeat('../', $page->getDepth());
23 $nodes = $this->query("//*[@xc:absolute]");
25 foreach ($nodes as $node) {
26 $attribute = $this->confiscateAttr($node, $this->ns, 'absolute');
27 if ($attribute) {
28 // $attribute is the name of the attribute to convert
29 // to absolute form, we can extend the syntax to allow
30 // multiple attributes.
31 $uri = $node->getAttribute($attribute);
32 $node->setAttribute($attribute, $prefix . $uri);