2 rcs_id('$Id: Tools.php,v 1.1 2003-01-23 00:32:04 zorloc Exp $')
\r
4 Copyright 2002 $ThePhpWikiProgrammingTeam
\r
6 This file is part of PhpWiki.
\r
8 PhpWiki is free software; you can redistribute it and/or modify
\r
9 it under the terms of the GNU General Public License as published by
\r
10 the Free Software Foundation; either version 2 of the License, or
\r
11 (at your option) any later version.
\r
13 PhpWiki is distributed in the hope that it will be useful,
\r
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 GNU General Public License for more details.
\r
18 You should have received a copy of the GNU General Public License
\r
19 along with PhpWiki; if not, write to the Free Software
\r
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
36 function ConfigValue($params){
\r
37 $this->name = $params['name'];
\r
38 $this->defaultValue = $params['defaultValue'];
\r
39 $this->description = $params['description'];
\r
40 $this->validator = &$params['validator'];
\r
41 $this->currentValue = $this->getStarting();
\r
44 function valid($value){
\r
45 if ($this->validator->validate($value)) {
\r
48 trigger_error("Value for " . $this->name . "is invalid", E_USER_WARNING);
\r
52 function getStarting(){
\r
53 return $this->defaultValue;
\r
56 function getCurrent(){
\r
57 return $this->currentValue;
\r
60 function setCurrent($value){
\r
61 if ($this->valid($value)) {
\r
62 $this->currentValue = $value;
\r
70 function getDefaultValue(){
\r
71 return $this->defaultValue;
\r
74 function getShortDescription(){
\r
75 return $this->description['short'];
\r
78 function getFullDescription(){
\r
79 return $this->description['full'];
\r
86 class ConfigConstant extends ConfigValue {
\r
88 function getStarting(){
\r
89 if (defined($this->name)) {
\r
90 $starting = constant($this->name);
\r
91 if ($this->valid($starting)) {
\r
95 return $this->defaultValue;
\r
102 class ConfigVariable extends ConfigValue {
\r
104 function getStarting(){
\r
105 if (isset(${$this->name})) {
\r
106 $starting = ${$this->name};
\r
107 if ($this->valid($starting)) {
\r
111 return $this->defaultValue;
\r
115 //$Log: not supported by cvs2svn $
\r
117 // Local Variables:
\r
120 // c-basic-offset: 4
\r
121 // c-hanging-comment-ender-p: nil
\r
122 // indent-tabs-mode: nil
\r