baseUri = $baseUri;
$this->namespaceMap = $namespaceMap;
}
/**
* Generates a 'full' url based on a relative one.
*
* For relative urls, the base of the application is taken as the reference
* url, not the 'current url of the current request'.
*
* Absolute urls are left alone.
*
* @param string $path
* @return string
*/
function fullUrl($path) {
return Uri\resolve($this->baseUri, $path);
}
/**
* Escape string for HTML output.
*
* @param string $input
* @return string
*/
function h($input) {
return htmlspecialchars($input, ENT_COMPAT, 'UTF-8');
}
/**
* Generates a full -tag.
*
* Url is automatically expanded. If label is not specified, we re-use the
* url.
*
* @param string $url
* @param string $label
* @return string
*/
function link($url, $label = null) {
$url = $this->h($this->fullUrl($url));
return '' . ($label ? $this->h($label) : $url) . '';
}
/**
* This method takes an xml element in clark-notation, and turns it into a
* shortened version with a prefix, if it was a known namespace.
*
* @param string $element
* @return string
*/
function xmlName($element) {
list($ns, $localName) = XmlService::parseClarkNotation($element);
if (isset($this->namespaceMap[$ns])) {
$propName = $this->namespaceMap[$ns] . ':' . $localName;
} else {
$propName = $element;
}
return "h($element) . "\">" . $this->h($propName) . "";
}
}