From 29130c17def4e63475b3fd775f48832e8d07bda0 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Sun, 2 Apr 2006 15:39:57 +0000
Subject: Added TParameterModule.
---
.gitattributes | 1 +
HISTORY | 1 +
.../protected/pages/Configurations/AppConfig.page | 2 +-
framework/Exceptions/messages.txt | 6 +-
framework/Security/TUserManager.php | 22 ++--
framework/Util/TParameterModule.php | 131 +++++++++++++++++++++
framework/Web/Services/TPageService.php | 6 +-
7 files changed, 154 insertions(+), 15 deletions(-)
create mode 100644 framework/Util/TParameterModule.php
diff --git a/.gitattributes b/.gitattributes
index 6081156b..d00acc93 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -670,6 +670,7 @@ framework/TService.php -text
framework/Util/TDataFieldAccessor.php -text
framework/Util/TLogRouter.php -text
framework/Util/TLogger.php -text
+framework/Util/TParameterModule.php -text
framework/Util/TSimpleDateFormatter.php -text
framework/Util/TVarDumper.php -text
framework/Web/Javascripts/TJSON.php -text
diff --git a/HISTORY b/HISTORY
index 1c2d0534..b41eac85 100644
--- a/HISTORY
+++ b/HISTORY
@@ -25,6 +25,7 @@ NEW: TImageMap control (Qiang)
NEW: TWizard control (Qiang)
NEW: TVarDumper and PradoBase::varDump() (Qiang)
NEW: TComponentReflection (Qiang)
+NEW: TParameterModule (Qiang)
Version 3.0b March 6, 2006
==========================
diff --git a/demos/quickstart/protected/pages/Configurations/AppConfig.page b/demos/quickstart/protected/pages/Configurations/AppConfig.page
index d617a280..48243200 100644
--- a/demos/quickstart/protected/pages/Configurations/AppConfig.page
+++ b/demos/quickstart/protected/pages/Configurations/AppConfig.page
@@ -33,7 +33,7 @@ Configuration for an application is stored in an XML file named application.
diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt
index b4f81c8b..dd680098 100644
--- a/framework/Exceptions/messages.txt
+++ b/framework/Exceptions/messages.txt
@@ -273,4 +273,8 @@ texthighlighter_stylesheet_invalid = Unable to find the stylesheet file for TTe
hotspotcollection_hotspot_required = THotSpotCollection can only accept instance of THotSpot or its derived classes.
htmlarea_textmode_readonly = THtmlArea.TextMode is read-only.
-htmlarea_tarfile_invalid = THtmlArea is unable to locate the TinyMCE tar file.
\ No newline at end of file
+htmlarea_tarfile_invalid = THtmlArea is unable to locate the TinyMCE tar file.
+
+parametermodule_parameterfile_unchangeable = TParameterModule.ParameterFile is not changeable because the module is already initialized.
+parametermodule_parameterfile_invalid = TParameterModule.ParameterFile '{0}' is invalid. Make sure it is in namespace format and the file extension is '.xml'.
+parametermodule_parameterid_required = Parameter element must have 'id' attribute.
\ No newline at end of file
diff --git a/framework/Security/TUserManager.php b/framework/Security/TUserManager.php
index 5ad582e1..5bd18d0c 100644
--- a/framework/Security/TUserManager.php
+++ b/framework/Security/TUserManager.php
@@ -168,12 +168,19 @@ class TUser extends TComponent implements IUser
*
* TUserManager manages a static list of users {@link TUser}.
* The user information is specified via module configuration using the following XML syntax,
+ *
*
+ *
+ * In addition, user information can also be loaded from an external file
+ * specified by {@link setUserFile UserFile} property. Note, the property
+ * only accepts a file path in namespace format. The user file format is
+ * similar to the above sample.
*
* The user passwords may be specified as clear text, SH1 or MD5 hashed by setting
* {@link setPasswordMode PasswordMode} as Clear, SH1 or MD5.
@@ -228,18 +235,13 @@ class TUserManager extends TModule
*/
public function init($config)
{
+ $this->loadUserData($config);
if($this->_userFile!==null)
{
- if(is_file($this->_userFile))
- {
- $dom=new TXmlDocument;
- $dom->loadFromFile($this->_userFile);
- $this->loadUserData($dom);
- }
- else
- throw new TConfigurationException('usermanager_userfile_invalid',$this->_userFile);
+ $dom=new TXmlDocument;
+ $dom->loadFromFile($this->_userFile);
+ $this->loadUserData($dom);
}
- $this->loadUserData($config);
$this->_initialized=true;
}
@@ -287,7 +289,7 @@ class TUserManager extends TModule
{
if($this->_initialized)
throw new TInvalidOperationException('usermanager_userfile_unchangeable');
- else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null)
+ else if(($this->_userFile=Prado::getPathOfNamespace($value,self::USER_FILE_EXT))===null || !is_file($this->_userFile))
throw new TConfigurationException('usermanager_userfile_invalid',$value);
}
diff --git a/framework/Util/TParameterModule.php b/framework/Util/TParameterModule.php
new file mode 100644
index 00000000..a72e8fe8
--- /dev/null
+++ b/framework/Util/TParameterModule.php
@@ -0,0 +1,131 @@
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
+ * @package System.Util
+ */
+
+/**
+ * TParameterModule class
+ *
+ * TParameterModule enables loading application parameters from external
+ * storage other than the application configuration.
+ * To load parameters from an XML file, configure the module by setting
+ * its {@link setParameterFile ParameterFile} property.
+ * Note, the property only accepts a file path in namespace format with
+ * file extension being '.xml'. The file format is as follows, which is
+ * similar to the parameter portion in an application configuration,
+ *
+ *
+ *
+ * In addition, any content enclosed within the module tag is also treated
+ * as parameters, e.g.,
+ *
+ *
+ *
+ * If a parameter is defined both in the external file and within the module
+ * tag, the former takes precedence.
+ *
+ * @author Qiang Xue