summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorcarlgmathisen <>2008-12-02 00:02:51 +0000
committercarlgmathisen <>2008-12-02 00:02:51 +0000
commit439b0b12dc8f6cbeb769fe4f2c0061ff9d3c9d31 (patch)
tree30046fc52a8c2ae53bad05224c95dbabd0d5238f /framework
parentc356dfc6660d68f1e7fbde92aaf15c6a94894d4f (diff)
php configuration type
Diffstat (limited to 'framework')
-rw-r--r--framework/Data/TDataSourceConfig.php28
-rw-r--r--framework/PradoBase.php6
-rw-r--r--framework/Security/TUserManager.php63
-rw-r--r--framework/TApplication.php231
-rw-r--r--framework/Web/Services/TPageService.php156
-rw-r--r--framework/Web/Services/TSoapService.php38
6 files changed, 467 insertions, 55 deletions
diff --git a/framework/Data/TDataSourceConfig.php b/framework/Data/TDataSourceConfig.php
index a02c68a1..804ea848 100644
--- a/framework/Data/TDataSourceConfig.php
+++ b/framework/Data/TDataSourceConfig.php
@@ -1,10 +1,10 @@
-<?php
+<?php
/**
* TDataSourceConfig class file.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Data
@@ -58,11 +58,23 @@ class TDataSourceConfig extends TModule
*/
public function init($xml)
{
- if($prop=$xml->getElementByTagName('database'))
+ if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
{
- $db=$this->getDbConnection();
- foreach($prop->getAttributes() as $name=>$value)
- $db->setSubproperty($name,$value);
+ if(isset($xml['database']) && is_array($xml['database']))
+ {
+ $db=$this->getDbConnection();
+ foreach($xml['database'] as $name=>$value)
+ $db->setSubProperty($name,$value);
+ }
+ }
+ else
+ {
+ if($prop=$xml->getElementByTagName('database'))
+ {
+ $db=$this->getDbConnection();
+ foreach($prop->getAttributes() as $name=>$value)
+ $db->setSubproperty($name,$value);
+ }
}
}
@@ -153,5 +165,5 @@ class TDataSourceConfig extends TModule
throw new TConfigurationException('datasource_dbconnection_invalid',$id);
}
}
-
-?>
+
+?>
diff --git a/framework/PradoBase.php b/framework/PradoBase.php
index e6a77136..15932cad 100644
--- a/framework/PradoBase.php
+++ b/framework/PradoBase.php
@@ -7,7 +7,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System
@@ -66,7 +66,7 @@ class PradoBase
*/
public static function getVersion()
{
- return '3.1.3a';
+ return '3.2a';
}
/**
@@ -611,4 +611,4 @@ PradoBase::using('System.TComponent');
PradoBase::using('System.Exceptions.TException');
PradoBase::using('System.Util.TLogger');
-?>
+?>
diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php
index 20b2cbb1..6326803d 100644
--- a/framework/Security/TUserManager.php
+++ b/framework/Security/TUserManager.php
@@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Security
@@ -83,25 +83,72 @@ class TUserManager extends TModule implements IUserManager
* Initializes the module.
* This method is required by IModule and is invoked by application.
* It loads user/role information from the module configuration.
- * @param TXmlElement module configuration
+ * @param mixed module configuration
*/
public function init($config)
{
- $this->loadUserData($config);
+ $isPhp = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP;
+ if($isPhp)
+ $this->loadUserDataFromPhp($config);
+ else
+ $this->loadUserDataFromXml($config);
+
if($this->_userFile!==null)
{
- $dom=new TXmlDocument;
- $dom->loadFromFile($this->_userFile);
- $this->loadUserData($dom);
+ if($isPhp)
+ {
+ $this->loadUserDataFromPhp($config);
+ }
+ else
+ {
+ $dom=new TXmlDocument;
+ $dom->loadFromFile($this->_userFile);
+ $this->loadUserDataFromXml($dom);
+ }
}
$this->_initialized=true;
}
+ private function loadUserDataFromPhp($config)
+ {
+ if(isset($config['users']) && is_array($config['users']))
+ {
+ foreach($config['users'] as $user)
+ {
+ $name = trim(strtolower(isset($user['name'])?$user['name']:''));
+ $password = isset($user['password'])?$user['password']:'';
+ $this->_users[$name] = $password;
+ $roles = isset($user['roles'])?$user['roles']:'';
+ if($roles!=='')
+ {
+ foreach(explode(',',$roles) as $role)
+ {
+ if(($role=trim($role))!=='')
+ $this->_roles[$name][]=$role;
+ }
+ }
+ }
+ }
+ if(isset($config['roles']) && is_array($config['roles']))
+ {
+ foreach($config['roles'] as $role)
+ {
+ $name = isset($role['name'])?$role['name']:'';
+ $users = isset($role['users'])?$role['users']:'';
+ foreach(explode(',',$users) as $user)
+ {
+ if(($user=trim($user))!=='')
+ $this->_roles[strtolower($user)][]=$name;
+ }
+ }
+ }
+ }
+
/**
* Loads user/role information from an XML node.
* @param TXmlElement the XML node containing the user information
*/
- private function loadUserData($xmlNode)
+ private function loadUserDataFromXml($xmlNode)
{
foreach($xmlNode->getElementsByTagName('user') as $node)
{
@@ -320,4 +367,4 @@ class TUserManagerPasswordMode extends TEnumerable
const SHA1='SHA1';
}
-?>
+?>
diff --git a/framework/TApplication.php b/framework/TApplication.php
index 9677d192..d9626179 100644
--- a/framework/TApplication.php
+++ b/framework/TApplication.php
@@ -127,11 +127,28 @@ class TApplication extends TComponent
/**
* Application configuration file name
*/
- const CONFIG_FILE='application.xml';
+ const CONFIG_FILE_XML='application.xml';
/**
* File extension for external config files
*/
- const CONFIG_FILE_EXT='.xml';
+ const CONFIG_FILE_EXT_XML='.xml';
+ /**
+ * Configuration file type, application.xml and config.xml
+ */
+ const CONFIG_TYPE_XML = 'xml';
+ /**
+ * Application configuration file name
+ */
+ const CONFIG_FILE_PHP='application.php';
+ /**
+ * File extension for external config files
+ */
+ const CONFIG_FILE_EXT_PHP='.php';
+ /**
+ * Configuration file type, application.php and config.php
+ */
+ const CONFIG_TYPE_PHP = 'php';
+
/**
* Runtime directory name
*/
@@ -201,6 +218,14 @@ class TApplication extends TComponent
*/
private $_configFile;
/**
+ * @var string configuration file extension
+ */
+ private $_configFileExt;
+ /**
+ * @var string configuration type
+ */
+ private $_configType;
+ /**
* @var string application base path
*/
private $_basePath;
@@ -287,11 +312,11 @@ class TApplication extends TComponent
* @param boolean whether to cache application configuration. Defaults to true.
* @throws TConfigurationException if configuration file cannot be read or the runtime path is invalid.
*/
- public function __construct($basePath='protected',$cacheConfig=true)
+ public function __construct($basePath='protected',$cacheConfig=true, $configType=self::CONFIG_TYPE_XML)
{
// register application as a singleton
Prado::setApplication($this);
-
+ $this->setConfigurationType($configType);
$this->resolvePaths($basePath);
if($cacheConfig)
@@ -319,8 +344,8 @@ class TApplication extends TComponent
// determine configuration path and file
if(empty($basePath) || ($basePath=realpath($basePath))===false)
throw new TConfigurationException('application_basepath_invalid',$basePath);
- if(is_file($basePath.DIRECTORY_SEPARATOR.self::CONFIG_FILE))
- $configFile=$basePath.DIRECTORY_SEPARATOR.self::CONFIG_FILE;
+ if(is_file($basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName()))
+ $configFile=$basePath.DIRECTORY_SEPARATOR.$this->getConfigurationFileName();
else if(is_file($basePath))
{
$configFile=$basePath;
@@ -541,6 +566,49 @@ class TApplication extends TComponent
$this->_configFile=$value;
}
+ public function getConfigurationType()
+ {
+ return $this->_configType;
+ }
+
+ public function setConfigurationType($value)
+ {
+ $this->_configType = $value;
+ }
+
+ public function getConfigurationFileExt()
+ {
+ if($this->_configFileExt===null)
+ {
+ switch($this->_configType)
+ {
+ case TApplication::CONFIG_TYPE_PHP:
+ $this->_configFileExt = TApplication::CONFIG_FILE_EXT_PHP;
+ break;
+ default:
+ $this->_configFileExt = TApplication::CONFIG_FILE_EXT_XML;
+ }
+ }
+ return $this->_configFileExt;
+ }
+
+ public function getConfigurationFileName()
+ {
+ static $fileName;
+ if($fileName == null)
+ {
+ switch($this->_configType)
+ {
+ case TApplication::CONFIG_TYPE_PHP:
+ $fileName = TApplication::CONFIG_FILE_PHP;
+ break;
+ default:
+ $fileName = TApplication::CONFIG_FILE_XML;
+ }
+ }
+ return $fileName;
+ }
+
/**
* @return string the directory storing cache data and application-level persistent data. (absolute path)
*/
@@ -890,7 +958,7 @@ class TApplication extends TComponent
$condition=$this->evaluateExpression($condition);
if($condition)
{
- if(($path=Prado::getPathOfNamespace($filePath,self::CONFIG_FILE_EXT))===null || !is_file($path))
+ if(($path=Prado::getPathOfNamespace($filePath,$this->getConfigurationFileExt()))===null || !is_file($path))
throw new TConfigurationException('application_includefile_invalid',$filePath);
$c=new TApplicationConfiguration;
$c->loadFromFile($path);
@@ -958,7 +1026,10 @@ class TApplication extends TComponent
if($configElement!==null)
{
$config=new TApplicationConfiguration;
- $config->loadFromXml($configElement,$this->getBasePath());
+ if($this->getConfigurationType()==self::CONFIG_TYPE_PHP)
+ $config->loadFromPhp($configElement,$this->getBasePath());
+ else
+ $config->loadFromXml($configElement,$this->getBasePath());
$this->applyConfiguration($config,true);
}
@@ -1188,9 +1259,17 @@ class TApplicationConfiguration extends TComponent
*/
public function loadFromFile($fname)
{
- $dom=new TXmlDocument;
- $dom->loadFromFile($fname);
- $this->loadFromXml($dom,dirname($fname));
+ if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
+ {
+ $fcontent = include $fname;
+ $this->loadFromPhp($fcontent,dirname($fname));
+ }
+ else
+ {
+ $dom=new TXmlDocument;
+ $dom->loadFromFile($fname);
+ $this->loadFromXml($dom,dirname($fname));
+ }
}
/**
@@ -1201,6 +1280,34 @@ class TApplicationConfiguration extends TComponent
return $this->_empty;
}
+ public function loadFromPhp($config, $configPath)
+ {
+ // application properties
+ if(isset($config['application']))
+ {
+ foreach($config['application'] as $name=>$value)
+ {
+ $this->_properties[$name]=$value;
+ }
+ $this->_empty = false;
+ }
+
+ if(isset($config['paths']) && is_array($config['paths']))
+ $this->loadPathsPhp($config['paths'],$configPath);
+
+ if(isset($config['modules']) && is_array($config['modules']))
+ $this->loadModulesPhp($config['modules'],$configPath);
+
+ if(isset($config['services']) && is_array($config['services']))
+ $this->loadServicesPhp($config['services'],$configPath);
+
+ if(isset($config['parameters']) && is_array($config['parameters']))
+ $this->loadParametersPhp($config['parameters'], $configPath);
+
+ if(isset($config['includes']) && is_array($config['includes']))
+ $this->loadExternalXml($config['includes'],$configPath);
+ }
+
/**
* Parses the application configuration given in terms of a TXmlElement.
* @param TXmlElement the XML element
@@ -1241,6 +1348,34 @@ class TApplicationConfiguration extends TComponent
}
}
+ protected function loadPathsPhp($pathsNode, $configPath)
+ {
+ if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases']))
+ {
+ foreach($pathsNode['aliases'] as $id=>$path)
+ {
+ $path=str_replace('\\','/',$path);
+ if(preg_match('/^\\/|.:\\/|.:\\\\/',$path)) // if absolute path
+ $p=realpath($path);
+ else
+ $p=realpath($configPath.DIRECTORY_SEPARATOR.$path);
+ if($p===false || !is_dir($p))
+ throw new TConfigurationException('appconfig_aliaspath_invalid',$id,$path);
+ if(isset($this->_aliases[$id]))
+ throw new TConfigurationException('appconfig_alias_redefined',$id);
+ $this->_aliases[$id]=$p;
+ }
+ }
+
+ if(isset($pathsNode['using']) && is_array($pathsNode['using']))
+ {
+ foreach($pathsNode['using'] as $namespace)
+ {
+ $this->_usings[] = $namespace;
+ }
+ }
+ }
+
/**
* Loads the paths XML node.
* @param TXmlElement the paths XML node
@@ -1287,6 +1422,26 @@ class TApplicationConfiguration extends TComponent
}
}
+ protected function loadModulesPhp($modulesNode, $configPath)
+ {
+ foreach($modulesNode as $id=>$module)
+ {
+ if(!isset($module['class']))
+ throw new TConfigurationException('appconfig_moduletype_required',$id);
+ $type = $module['class'];
+ unset($module['class']);
+ $properties = array();
+ if(isset($module['properties']))
+ {
+ $properties = $module['properties'];
+ unset($module['properties']);
+ }
+ $properties['id'] = $id;
+ $this->_modules[$id]=array($type,$properties,$module);
+ $this->_empty=false;
+ }
+ }
+
/**
* Loads the modules XML node.
* @param TXmlElement the modules XML node
@@ -1315,6 +1470,22 @@ class TApplicationConfiguration extends TComponent
}
}
+ protected function loadServicesPhp($servicesNode,$configPath)
+ {
+ foreach($servicesNode as $id => $service)
+ {
+ if(!isset($service['class']))
+ throw new TConfigurationException('appconfig_servicetype_required');
+ $type = $service['class'];
+ unset($service['class']);
+ $properties = isset($service['properties']) ? $service['properties'] : array();
+ unset($service['properties']);
+ $properties['id'] = $id;
+ $this->_services[$id] = array($type,$properties,$service);
+ $this->_empty = false;
+ }
+ }
+
/**
* Loads the services XML node.
* @param TXmlElement the services XML node
@@ -1340,6 +1511,28 @@ class TApplicationConfiguration extends TComponent
}
}
+ protected function loadParametersPhp($parametersNode,$configPath)
+ {
+ foreach($parametersNode as $id => $parameter)
+ {
+ if(is_array($parameter))
+ {
+ if(isset($parameter['class']))
+ {
+ $type = $parameter['class'];
+ unset($parameter['class']);
+ $properties = isset($service['properties']) ? $service['properties'] : array();
+ $properties['id'] = $id;
+ $this->_parameters[$id] = array($type,$properties);
+ }
+ }
+ else
+ {
+ $this->_parameters[$id] = $parameter;
+ }
+ }
+ }
+
/**
* Loads the parameters XML node.
* @param TXmlElement the parameters XML node
@@ -1370,6 +1563,22 @@ class TApplicationConfiguration extends TComponent
}
}
+ protected function loadExternalPhp($includeNode,$configPath)
+ {
+ foreach($includeNode as $include)
+ {
+ $when = isset($include['when'])?true:false;
+ if(!isset($include['file']))
+ throw new TConfigurationException('appconfig_includefile_required');
+ $filePath = $include['file'];
+ if(isset($this->_includes[$filePath]))
+ $this->_includes[$filePath]='('.$this->_includes[$filePath].') || ('.$when.')';
+ else
+ $$this->_includes[$filePath]=$when;
+ $this->_empty=false;
+ }
+ }
+
/**
* Loads the external XML configurations.
* @param TXmlElement the application DOM element
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index 1901e7b9..10c7da6e 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -4,7 +4,7 @@
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
- * @copyright Copyright &copy; 2005-2008 PradoSoft
+ * @copyright Copyright &copy; 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.Services
@@ -78,7 +78,11 @@ class TPageService extends TService
/**
* Configuration file name
*/
- const CONFIG_FILE='config.xml';
+ const CONFIG_FILE_XML='config.xml';
+ /**
+ * Configuration file name
+ */
+ const CONFIG_FILE_PHP='config.php';
/**
* Default base path
*/
@@ -178,7 +182,7 @@ class TPageService extends TService
$condition=$this->evaluateExpression($condition);
if($condition)
{
- if(($path=Prado::getPathOfNamespace($filePath,TApplication::CONFIG_FILE_EXT))===null || !is_file($path))
+ if(($path=Prado::getPathOfNamespace($filePath,Prado::getApplication()->getConfigurationFileExt()))===null || !is_file($path))
throw new TConfigurationException('pageservice_includefile_invalid',$filePath);
$c=new TPageConfiguration($pagePath);
$c->loadFromFile($path,$configPagePath);
@@ -213,7 +217,12 @@ class TPageService extends TService
{
$pageConfig=new TPageConfiguration($pagePath);
if($config!==null)
- $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
+ {
+ if($application->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
+ $pageConfig->loadPageConfigurationFromPhp($config,$application->getBasePath(),'');
+ else
+ $pageConfig->loadPageConfigurationFromXml($config,$application->getBasePath(),'');
+ }
$pageConfig->loadFromFiles($this->getBasePath());
}
else
@@ -249,9 +258,12 @@ class TPageService extends TService
$configCached=false;
$paths=explode('.',$pagePath);
$configPath=$this->getBasePath();
+ $fileName = $this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP
+ ? self::CONFIG_FILE_PHP
+ : self::CONFIG_FILE_XML;
foreach($paths as $path)
{
- $configFile=$configPath.DIRECTORY_SEPARATOR.self::CONFIG_FILE;
+ $configFile=$configPath.DIRECTORY_SEPARATOR.$fileName;
$currentTimestamp[$configFile]=@filemtime($configFile);
$configPath.=DIRECTORY_SEPARATOR.$path;
}
@@ -581,16 +593,19 @@ class TPageConfiguration extends TComponent
$page=array_pop($paths);
$path=$basePath;
$configPagePath='';
+ $fileName = Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP
+ ? TPageService::CONFIG_FILE_PHP
+ : TPageService::CONFIG_FILE_XML;
foreach($paths as $p)
{
- $this->loadFromFile($path.DIRECTORY_SEPARATOR.TPageService::CONFIG_FILE,$configPagePath);
+ $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath);
$path.=DIRECTORY_SEPARATOR.$p;
if($configPagePath==='')
$configPagePath=$p;
else
$configPagePath.='.'.$p;
}
- $this->loadFromFile($path.DIRECTORY_SEPARATOR.TPageService::CONFIG_FILE,$configPagePath);
+ $this->loadFromFile($path.DIRECTORY_SEPARATOR.$fileName,$configPagePath);
$this->_rules=new TAuthorizationRuleCollection($this->_rules);
}
@@ -604,11 +619,26 @@ class TPageConfiguration extends TComponent
Prado::trace("Loading page configuration file $fname",'System.Web.Services.TPageService');
if(empty($fname) || !is_file($fname))
return;
- $dom=new TXmlDocument;
- if($dom->loadFromFile($fname))
- $this->loadFromXml($dom,dirname($fname),$configPagePath);
+
+ if(Prado::getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
+ {
+ $fcontent = include $fname;
+ $this->loadFromPhp($fcontent,dirname($fname),$configPagePath);
+ }
else
- throw new TConfigurationException('pageserviceconf_file_invalid',$fname);
+ {
+ $dom=new TXmlDocument;
+ if($dom->loadFromFile($fname))
+ $this->loadFromXml($dom,dirname($fname),$configPagePath);
+ else
+ throw new TConfigurationException('pageserviceconf_file_invalid',$fname);
+ }
+ }
+
+ public function loadFromPhp($config,$configPath,$configPagePath)
+ {
+ $this->loadApplicationConfigurationFromPhp($config,$configPath);
+ $this->loadPageConfigurationFromPhp($config,$configPath,$configPagePath);
}
/**
@@ -624,6 +654,13 @@ class TPageConfiguration extends TComponent
$this->loadApplicationConfigurationFromXml($dom,$configPath);
$this->loadPageConfigurationFromXml($dom,$configPath,$configPagePath);
}
+
+ public function loadApplicationConfigurationFromPhp($config,$configPath)
+ {
+ $appConfig=new TApplicationConfiguration;
+ $appConfig->loadFromPhp($config,$configPath);
+ $this->_appConfigs[]=$appConfig;
+ }
/**
* Loads the configuration specific for application part
@@ -637,6 +674,99 @@ class TPageConfiguration extends TComponent
$this->_appConfigs[]=$appConfig;
}
+ public function loadPageConfigurationFromPhp($config, $configPath, $configPagePath)
+ {
+ // authorization
+ if(isset($config['authorization']) && is_array($config['authorization']))
+ {
+ $rules = array();
+ foreach($config['authorization'] as $authorization)
+ {
+ $patterns=isset($authorization['pages'])?$authorization['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]==='*') // try wildcard matching
+ {
+ if(strncasecmp($this->_pagePath,$pattern,strlen($pattern)-1)===0)
+ {
+ $ruleApplies=true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if($ruleApplies)
+ {
+ $action = isset($authorization['action'])?$authorization['action']:'';
+ $users = isset($authorization['users'])?$authorization['users']:'';
+ $roles = isset($authorization['roles'])?$authorization['roles']:'';
+ $verb = isset($authorization['verb'])?$authorization['verb']:'';
+ $ips = isset($authorization['ips'])?$authorization['ips']:'';
+ $rules[]=new TAuthorizationRule($action,$users,$roles,$verb,$ips);
+ }
+ }
+ }
+ // pages
+ if(isset($config['pages']) && is_array($config['pages']))
+ {
+ if(isset($config['pages']['properties']))
+ {
+ $this->_properties = array_merge($this->_properties, $config['pages']['properties']);
+ unset($config['pages']['properties']);
+ }
+ foreach($config['pages'] as $id => $page)
+ {
+ $properties = array();
+ if(isset($page['properties']))
+ {
+ $properties=$page['properties'];
+ unset($page['properties']);
+ }
+ $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);
+ }
+ $this->_rules=array_merge($rules,$this->_rules);
+ }
+
+ // external configurations
+ if(isset($config['includes']) && is_array($config['includes']))
+ {
+ foreach($config['includes'] as $include)
+ {
+ $when = isset($include['when'])?true:false;
+ if(!isset($include['file']))
+ throw new TConfigurationException('pageserviceconf_includefile_required');
+ $filePath = $include['file'];
+ if(isset($this->_includes[$filePath]))
+ $this->_includes[$filePath]=array($configPagePath,'('.$this->_includes[$filePath][1].') || ('.$when.')');
+ else
+ $this->_includes[$filePath]=array($configPagePath,$when);
+ }
+ }
+ }
+
/**
* Loads the configuration specific for page service.
* @param TXmlElement config xml element
@@ -721,6 +851,4 @@ class TPageConfiguration extends TComponent
$this->_includes[$filePath]=array($configPagePath,$when);
}
}
-}
-
-?>
+} \ No newline at end of file
diff --git a/framework/Web/Services/TSoapService.php b/framework/Web/Services/TSoapService.php
index 24f95a35..259fa5f8 100644
--- a/framework/Web/Services/TSoapService.php
+++ b/framework/Web/Services/TSoapService.php
@@ -148,19 +148,35 @@ class TSoapService extends TService
/**
* Loads configuration from an XML element
- * @param TXmlElement configuration node
+ * @param mixed configuration node
* @throws TConfigurationException if soap server id is not specified or duplicated
*/
- private function loadConfig($xml)
- {
- foreach($xml->getElementsByTagName('soap') as $serverXML)
+ private function loadConfig($config)
+ {
+ if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP)
+ {
+ if(is_array($config))
+ {
+ foreach($config as $id => $server)
+ {
+ $properties = isset($server['properties'])?$server['properties']:array();
+ if(isset($this->_servers[$id]))
+ throw new TConfigurationException('soapservice_serverid_duplicated',$id);
+ $this->_servers[$id]=$properties;
+ }
+ }
+ }
+ else
{
- $properties=$serverXML->getAttributes();
- if(($id=$properties->remove('id'))===null)
- throw new TConfigurationException('soapservice_serverid_required');
- if(isset($this->_servers[$id]))
- throw new TConfigurationException('soapservice_serverid_duplicated',$id);
- $this->_servers[$id]=$properties;
+ foreach($config->getElementsByTagName('soap') as $serverXML)
+ {
+ $properties=$serverXML->getAttributes();
+ if(($id=$properties->remove('id'))===null)
+ throw new TConfigurationException('soapservice_serverid_required');
+ if(isset($this->_servers[$id]))
+ throw new TConfigurationException('soapservice_serverid_duplicated',$id);
+ $this->_servers[$id]=$properties;
+ }
}
}
@@ -221,7 +237,7 @@ class TSoapService extends TService
protected function createServer()
{
$properties=$this->_servers[$this->_serverID];
- if(($serverClass=$properties->remove('class'))===null)
+ if($this->getApplication()->getConfigurationType()==TApplication::CONFIG_TYPE_PHP || ($serverClass=$properties->remove('class'))===null)
$serverClass=self::DEFAULT_SOAP_SERVER;
Prado::using($serverClass);
$className=($pos=strrpos($serverClass,'.'))!==false?substr($serverClass,$pos+1):$serverClass;