/** * Sets/gets default value. * For dropdown settings, default value is array of all possible value strings. * @param $default */ function def($default = NULL) { // Only allow default to be set once if ($this->type === NULL && $default !== NULL) { // For dropdown settings if (is_array($default)) { // The only time we don't use $this->is_array // If empty, set to blank array if (empty($default)) { $default = array(''); } else { // Ensure all values are unique strings $default = CrayonUtil::array_unique_str($default); } $this->value = 0; // initial index $this->is_array = TRUE; $this->type = gettype(0); // Type is int (index) } else { $this->is_array = FALSE; $this->type = gettype($default); } $this->default = $default; } else { return $this->default; } }