* This class map the <setting> XML block, from our settings XML format
*/
classSetting{
public$key;
//Rendering variables
public$field;
public$regExp;
public$choices;
//get/set variables
public$object;
private$property;
private$method;
private$handler;
//error variable
public$lastError;
/**
* Gets the current setting value
*
* @return string the setting value
*/
functionget(){
//1 - Evaluates custom handler
if(array_key_exists('get',$this->handler)){
returneval($this->handler['get']);
}
//2 - Gets object property
if($this->object&&$property=$this->property){
return$GLOBALS[$this->object]->$property;
}
if($this->field=="password"){
//Okay not to have a value for password fields
return;
}
message_die(GENERAL_ERROR,"Setting $this->key haven't any get indication. Please set <object> and <property> / or a custom <handler><get></get></handler> block.","Settings error");
}
/**
* Sets a new value
*
* @param $value the setting new value
* @return boolean true if the setting have been successfully set ; otherwise, false.
*/
functionset($value){
//Validates data
if($this->regExp){
if(!preg_match('/^'.$this->regExp.'$/',$value)){
$this->lastError="Invalid format for $this->key setting";
message_die(GENERAL_ERROR,"Setting $this->key haven't any set indication. Please set <object> (and wheter <method>, whether <property>) or a custom <handler><set></set></handler> block.","Settings error");
}
/**
* Saves setting
*
* @return mixed the SETTINGS_SAVE_METHOD method value, or false if there's no method call;