Fix typo preventing canonicalization.
[xhtml-compiler.git] / XHTMLCompiler / DOMFilter / ConfigLinker.php
blob34c0165a2a718ab651a3e3abcbc15b454013c859
1 <?php
3 /**
4 * Implements the xc:configdoc attribute on a tags, which gets converted
5 * into a link to the appropriate configuration documentation, and,
6 * if the contents of the tag is empty, expands the configuration
7 * directive text to %NS.Directive.
8 */
9 class XHTMLCompiler_DOMFilter_ConfigLinker extends XHTMLCompiler_DOMFilter
12 protected $name = 'ConfigLinker';
13 protected $xcAttr = array('configdoc');
15 public function process(DOMDocument $dom, $page, $manager) {
17 // this is the absolute path implementation of the functionality
18 $xc = XHTMLCompiler::getInstance();
19 $configdoc = $xc->getConf('configdoc');
20 $nodes = $this->query("//html:a[@xc:configdoc]");
21 if ($nodes) $manager->addDependency(__FILE__);
22 foreach ($nodes as $node) {
23 $directive = $this->confiscateAttr($node, $this->ns, 'configdoc');
24 if (!$configdoc) continue;
25 if ($directive) {
26 // $directive is "Namespace.Directive" to convert
27 $node->setAttribute('href', str_replace('%s', $directive, $configdoc));
28 if (!$node->hasChildNodes()) {
29 $text = $dom->createTextNode('%' . $directive);
30 $node->appendChild($text);