summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rw-r--r--framework/Exceptions/messages.txt2
-rw-r--r--framework/TApplication.php1
-rw-r--r--framework/Web/Services/TPageService.php55
4 files changed, 55 insertions, 4 deletions
diff --git a/HISTORY b/HISTORY
index 71f2fa86..45b4a427 100644
--- a/HISTORY
+++ b/HISTORY
@@ -8,6 +8,7 @@ BUG: Ticket#652 - OFFSET must be specified together with LIMIT for TScaffoldView
BUG: Ticket#653 - TUrlMapping: ServiceId irgnored in URL-Map (Qiang)
BUG: TWizard Sidebar using TDataListItemRenderer has error (Qiang)
BUG: TOutputCache crashes when a default button is set (Qiang)
+BUG: Fix the bug that <include> tag was ignored in page configurations (Qiang)
BUG: Ticket#654 - TAssetManager::copyDirectory() do not run closedir on an invalid resource (Knut)
BUG: Ticket#655 - TAssetManager::publishTarFile() exception for 'assetmanager_tarchecksum_invalid' is not thrown on BSD systems (Knut)
ENH: Ticket#625 - Added @ to represent authenticated users in auth rules (Qiang)
diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt
index e2fc5dce..baddb754 100644
--- a/framework/Exceptions/messages.txt
+++ b/framework/Exceptions/messages.txt
@@ -109,6 +109,7 @@ pageservice_page_required = Page Name Required
pageservice_defaultpage_unchangeable = TPageService.DefaultPage cannot be modified after the service is initialized.
pageservice_basepath_unchangeable = TPageService.BasePath cannot be modified after the service is initialized.
pageservice_pageclass_invalid = Page class {0} is invalid. It should be TPage or extend from TPage.
+pageservice_includefile_invalid = Unable to find page service configuration {0}. Make sure it is in namespace format and the file ends with ".xml".
pageserviceconf_file_invalid = Unable to open page directory configuration file '{0}'.
pageserviceconf_aliaspath_invalid = <alias id="{0}"> uses an invalid file path "{1}" in page directory configuration file '{2}'.
@@ -118,6 +119,7 @@ pageserviceconf_module_invalid = <module> element must have an "id" attribute
pageserviceconf_moduletype_required = <module id="{0}"> must have a "class" attribute in page directory configuration file '{1}'.
pageserviceconf_parameter_invalid = <parameter> element must have an "id" attribute in page directory configuration file '{0}'.
pageserviceconf_page_invalid = <page> element must have an "id" attribute in page directory configuration file '{0}'.
+pageserviceconf_includefile_required = Page configuration <include> element must have a "file" attribute.
template_closingtag_unexpected = Unexpected closing tag '{0}' is found.
template_closingtag_expected = Closing tag '{0}' is expected.
diff --git a/framework/TApplication.php b/framework/TApplication.php
index 3e50d53d..4454d763 100644
--- a/framework/TApplication.php
+++ b/framework/TApplication.php
@@ -1314,6 +1314,7 @@ class TApplicationConfiguration extends TComponent
$this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
else
$this->_includes[$filePath]=$when;
+ $this->_empty=false;
}
}
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index 58b7d57b..343508b8 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -154,14 +154,36 @@ class TPageService extends TService
protected function initPageContext($pageConfig)
{
$application=$this->getApplication();
-
foreach($pageConfig->getApplicationConfigurations() as $appConfig)
$application->applyConfiguration($appConfig);
+ $this->applyConfiguration($pageConfig);
+ }
+
+ /**
+ * Applies a page configuration.
+ * @param TPageConfiguration the configuration
+ */
+ protected function applyConfiguration($config)
+ {
// initial page properties (to be set when page runs)
- $this->_properties=$pageConfig->getProperties();
+ $this->_properties=$config->getProperties();
+ $this->getApplication()->getAuthorizationRules()->mergeWith($config->getRules());
+ // external configurations
+ foreach($config->getExternalConfigurations() as $filePath=>$condition)
+ {
+ if($condition!==true)
+ $condition=$this->evaluateExpression($condition);
+ if($condition)
+ {
+ if(($path=Prado::getPathOfNamespace($filePath,TApplication::CONFIG_FILE_EXT))===null || !is_file($path))
+ throw new TConfigurationException('pageservice_includefile_invalid',$filePath);
+ $c=new TPageConfiguration;
+ $c->loadFromFile($path,null);
+ $this->applyConfiguration($c);
+ }
+ }
- $application->getAuthorizationRules()->mergeWith($pageConfig->getRules());
}
/**
@@ -483,6 +505,18 @@ class TPageConfiguration extends TComponent
* @var TAuthorizationRuleCollection list of authorization rules
*/
private $_rules=array();
+ /**
+ * @var array list of included configurations
+ */
+ private $_includes=array();
+
+ /**
+ * @return array list of external configuration files. Each element is like $filePath=>$condition
+ */
+ public function getExternalConfigurations()
+ {
+ return $this->_includes;
+ }
/**
* Returns list of page initial property values.
@@ -538,7 +572,7 @@ class TPageConfiguration extends TComponent
* @param string config file name
* @param string page name, null if page is not required
*/
- private function loadFromFile($fname,$page)
+ public function loadFromFile($fname,$page)
{
Prado::trace("Loading $page with file $fname",'System.Web.Services.TPageService');
if(empty($fname) || !is_file($fname))
@@ -628,6 +662,19 @@ class TPageConfiguration extends TComponent
}
}
}
+
+ // 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]='('.$this->_includes[$filePath].') || ('.$when.')';
+ else
+ $this->_includes[$filePath]=$when;
+ }
}
}