/** * gets/sets a wiki_param variable. Also can execute some special actions * over a wiki_param (defined by $special param): * 'unset' => unsets a wiki_param * 'print' or 'print_object': do a print_object of a wiki_param * 'isset' => will returns only true or false if a wiki_param is set * 'set_info' => load main info into global structure * 'all_ws' => (deprecated) returns all variables in a single object * * @param String $name: wiki_param name * @param mixed $value=null: assign wiki_param value * @param Stirng $special=false: some special actions * @return mixed: wiki_param value or null if it's not set */ function wiki_param($name, $value = null, $special = false) { global $WS; if (!isset($WS)) { $WS = new storage(); $WS->recover_variables(); } if ($special == 'set_info') { $WS->set_info(); } //this is a deprecated line and will be removed shortly if ($special == 'all_ws') { return $WS; } if (!$name) { return null; } if ($value !== null) { $WS->{$name} = $value; } //special actions switch ($special) { case 'isset': return isset($WS->{$name}); break; case 'unset': if (isset($WS->{$name})) { unset($WS->{$name}); } break; case 'print': case 'print_object': if (isset($WS->{$name})) { print_object(); } else { echo '$WS->' . $name . ' is not set!'; } break; } if (!isset($WS->{$name})) { return null; } return $WS->{$name}; }