[Phpcms-plugins-cvs] admin4phpCMS/modules/config class.module_config.php,1.3,1.4 config.xml,1.1,1.2
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-06-04 11:12:07
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12823/modules/config Modified Files: class.module_config.php config.xml Log Message: several changes Index: config.xml =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/config/config.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- config.xml 30 May 2004 18:03:40 -0000 1.1 +++ config.xml 4 Jun 2004 11:11:57 -0000 1.2 @@ -5,9 +5,12 @@ <config name="userfile" value="Auth_XML.xml" /> <config name="permfile" value="Perm_XML.xml" /> </module> - <module id="layout" name="layout-service" include="class.module_layout.php" class="module_layout"> - <config name="tplfile" value="layout/layout.xml" /> + <module id="layout" name="layout-service" include="class.module_layout.php" class="module_layout" /> + <module id="debug" name="debug-service" include="class.module_debug.php" class="module_debug" /> + <module id="filemanager" name="filemanager" include="class.module_filemanager.php" class="module_filemanager"> + <config name="startupdir" value="/" /> </module> + <module id="error" name="error-service" include="class.module_error.php" class="module_error" /> <module id="mail" name="email-service" include="class.module_mail.php" class="module_mail"> <config name="admin-email" value="ma...@mj..." /> Index: class.module_config.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/config/class.module_config.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- class.module_config.php 30 May 2004 18:03:40 -0000 1.3 +++ class.module_config.php 4 Jun 2004 11:11:57 -0000 1.4 @@ -1,11 +1,80 @@ <?php +/** +* The config module manages the configuration-file config.xml and provide its data +* to the other modules. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* @author Martin Jahn <mj...@us...> +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @copyright Copyright (c) 2004, Martin Jahn +* @version $Id$ +* @package admin4phpCMS +* @subpackage module_config +* +**/ -require_once 'XML/Tree.php'; +/* +* $Log$ +* Revision 1.4 2004/06/04 11:11:57 mjahn +* several changes +* +*/ +/** +* include the PEAR::XML_Tree class +**/ +include_once 'XML/Tree.php'; +/** +* the config-classe encapsulates the access to the configfile against the framework +* +* @package admin4phpCMS +* @subpackage module_config +**/ class module_config extends module { - var $configfile; + /** + * @var string path to the configfile + * @access private + **/ + var $_configfile = ''; + + /** + * @var array saves the configuration-data in an array-structur + * @access private + **/ + var $_config = array (); + /** + * registers events and actions provided to the framework + * + * Events: + * <ul> + * <li><b>CONFIG_READ</b> read and parse the configfile + * $actiondata['configfile'] contains the path to the configfile</li> + * <li><b>CONFIG_GET</b> get configuration-data + * $actiondata['module'] contains the id of the module + * $actiondata['config'] returns the configuration of the module + * if no module-id is given, it will return the full configuration-array + * <li><b>CONFIG_SAVE</b> saves the configuration in a file + * $actiondata['configfile'] path to save the config in; + * if no path is given, it saves to configfile from read-method</li> + * <li><b>CONFIG_SET_FILE</b> sets path to configfile + * $actiondata['configfile'] contains the path to configfile</li> + * </ul> + **/ function init () { $this->_registerEvent ('CONFIG_READ', 'doReadConfig'); $this->_registerAction ('doReadConfig', 'readConfig'); @@ -17,53 +86,80 @@ $this->_registerAction ('doSetConfigFile', 'setConfigFile'); } + /** + * read and parse the configfile + * + * @example /home/martin/devel/admin4phpCMS/modules/config/config.xml sample configfile + * @param array $actiondata $actiondata['configfile'] contains the path to the configfile + **/ function readConfig (&$actiondata) { if (isset ($actiondata['configfile'])) { - $this->configfile = $actiondata ['configfile']; + $this->_configfile = $actiondata ['configfile']; } else { - $this->configfile = dirname (__FILE__).'/config.xml'; + $this->_configfile = dirname (__FILE__).'/config.xml'; } - if (!isset($this->configfile)) { + if (!isset($this->_configfile)) { $actiondata = array ('errortext'=>'Konfigurationsdatei konnte nicht geladen werden!'); $this->_callEvent ('ERROR_NOTICE', $actiondata); return false; } - if (!file_exists ($this->configfile)) { - unset ($this->configfile); + if (!file_exists ($this->_configfile)) { + unset ($this->_configfile); $actiondata = array ('errortext'=>'Konfigurationsdatei konnte nicht geladen werden!'); $this->_callEvent ('ERROR_NOTICE', $actiondata); return false; } - $XML =& new XML_Tree ($this->configfile); + $XML =& new XML_Tree ($this->_configfile); $configdata =& $XML->getTreeFromFile (); for ($i = 0; $i < count ($configdata->children); $i++) { - $this->config[$configdata->children[$i]->attributes['id']] =& $configdata->children[$i]; + $this->_config[$configdata->children[$i]->attributes['id']] =& $configdata->children[$i]; } return true; } + /** + * get configuration data + * + * $actiondata['module'] contains the id of the module + * $actiondata['config'] return the configuration of the module + * if there is no module-id, it returns the full config-array + * + * @param array $actiondata + **/ function getConfig (&$actiondata) { - if (!isset($actiondata['module']) || !isset ($this->config[$actiondata['module']])) { - $actiondata['config'] =& $this->config; + if (!isset($actiondata['module']) || !isset ($this->_config[$actiondata['module']])) { + $actiondata['config'] =& $this->_config; } else { - $actiondata['config'] =& $this->config[$actiondata['module']]; + $actiondata['config'] =& $this->_config[$actiondata['module']]; } return true; } + /** + * save configuration in a file + * + * $actiondata['configfile'] contains the full path to the file + * if there is not given an path, i will overwrite the config-file given in the read-method + * + * @param array $actiondata + **/ function saveConfig (&$actiondata) { } + /** + * commit the path to the configfile + * + * $actiondata['configfile'] contains the path to the configuraton-file + * + * @param array $actiondata + **/ function setConfigFile (&$actiondata) { - $this->configfile = $actiondata['configfile']; + $this->_configfile = $actiondata['configfile']; } } - - - ?> \ No newline at end of file |