public function loadPageConfigurationFromXml($dom, $configPath, $configPagePath)
{
// authorization
if (($authorizationNode = $dom->getElementByTagName('authorization')) !== null) {
$rules = array();
foreach ($authorizationNode->getElements() as $node) {
$patterns = $node->getAttribute('pages');
$ruleApplies = false;
if (empty($patterns) || trim($patterns) === '*') {
// null or empty string
$ruleApplies = true;
} else {
foreach (explode(',', $patterns) as $pattern) {
if (($pattern = trim($pattern)) !== '') {
// we know $configPagePath and $this->_pagePath
if ($configPagePath !== '') {
// prepend the pattern with ConfigPagePath
$pattern = $configPagePath . '.' . $pattern;
}
if (strcasecmp($pattern, $this->_pagePath) === 0) {
$ruleApplies = true;
break;
}
if ($pattern[strlen($pattern) - 1] === '*') {
if (strncasecmp($this->_pagePath, $pattern, strlen($pattern) - 1) === 0) {
$ruleApplies = true;
break;
}
}
}
}
}
if ($ruleApplies) {
$rules[] = new TAuthorizationRule($node->getTagName(), $node->getAttribute('users'), $node->getAttribute('roles'), $node->getAttribute('verb'), $node->getAttribute('ips'));
}
}
$this->_rules = array_merge($rules, $this->_rules);
}
// pages
if (($pagesNode = $dom->getElementByTagName('pages')) !== null) {
$this->_properties = array_merge($this->_properties, $pagesNode->getAttributes()->toArray());
// at the page folder
foreach ($pagesNode->getElementsByTagName('page') as $node) {
$properties = $node->getAttributes();
$id = $properties->remove('id');
if (empty($id)) {
throw new TConfigurationException('pageserviceconf_page_invalid', $configPath);
}
$matching = false;
$id = $configPagePath === '' ? $id : $configPagePath . '.' . $id;
if (strcasecmp($id, $this->_pagePath) === 0) {
$matching = true;
} else {
if ($id[strlen($id) - 1] === '*') {
// try wildcard matching
$matching = strncasecmp($this->_pagePath, $id, strlen($id) - 1) === 0;
}
}
if ($matching) {
$this->_properties = array_merge($this->_properties, $properties->toArray());
}
}
}
// external configurations
foreach ($dom->getElementsByTagName('include') as $node) {
if (($when = $node->getAttribute('when')) === null) {
$when = true;
}
if (($filePath = $node->getAttribute('file')) === null) {
throw new TConfigurationException('pageserviceconf_includefile_required');
}
if (isset($this->_includes[$filePath])) {
$this->_includes[$filePath] = array($configPagePath, '(' . $this->_includes[$filePath][1] . ') || (' . $when . ')');
} else {
$this->_includes[$filePath] = array($configPagePath, $when);
}
}
}