config = &$config; $this->name = $name; $this->value = $value; $this->description = $description; $this->required = $required; $this->type = $type; $this->syntax = $syntax; $this->values = $values; $this->display = $display; $class = get_class(); $this->postName = "{$class}_{$this->name}"; } /*! \brief Enabled or disabled the widget. */ function setEnabled($bool = TRUE) { $this->enabled = $bool; } /*! \brief Sets the writeable status for a widget */ function setWriteable($bool = TRUE) { $this->writeable = $bool; } /*! \brief Sets the readable status for a widget */ function setReadable($bool = TRUE) { $this->readable = $bool; } /*! \brief Returns the enable status. */ function isEnabled() { return($this->enabled); } /*! \brief Returns the writeable status. */ function isWriteable() { return($this->writeable); } /*! \brief Returns the readable status. */ function isReadable() { return($this->readable); } /*! \brief Returns the display-name for the current widget. * @return String The display-name for the widget, this * name will usually be rendered infront of input fields. */ function getDisplayName() { $must = ($this->required)?"*":""; return($this->display.$must); } /*! \brief Returns the description for the widget. */ function getDescription() { return($this->description); } /*! \brief Generates the HTML code for the widget. * @return The HTML content for the widget. */ function render() { return(""); } /*! \brief Keep track of posted values. */ function save_object() { if(isset($_POST[$this->postName])){ $this->value = get_post($this->postName); } } /*! \brief Returns the current value. * @return Mixed The widgets value. */ function getValue() { return($this->value); } /*! \brief Returns the name of the widget. * @param String The widgets name. */ function getName() { return($this->name); } /*! \brief Sets a new value for the widget. * @param String The new value. */ function setValue($value) { $this->value = $value; } /*! \brief Check the value entry using the provieded syntax. * @return Array Returns a list of errors */ function check() { if($this->required && empty($this->value)){ return(array(msgPool::required($this->display))); } if(!empty($this->value) && !empty($this->syntax) && !empty($this->syntax) && !preg_match($this->syntax, $this->value)){ return(array(msgPool::invalid($this->display, $this->value, $this->syntax))); } return(array()); } } ?>