From 456de639123ae3da6320bed6140ab69ac9925e74 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 31 Aug 2010 21:26:50 +0200 Subject: [feature/request-class] Refactor request classes to use autoloading All class names have been adjusted to use a phpbb_request prefix, allowing them to be autoloaded. Also introduces some improvements to autoloading in general. PHPBB3-9716 --- phpBB/includes/request/interface.php | 103 +++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 phpBB/includes/request/interface.php (limited to 'phpBB/includes/request/interface.php') diff --git a/phpBB/includes/request/interface.php b/phpBB/includes/request/interface.php new file mode 100644 index 0000000000..7b5b600100 --- /dev/null +++ b/phpBB/includes/request/interface.php @@ -0,0 +1,103 @@ + "a") + * then specifying array("var", 1) as the name will return "a". + * @param mixed $default A default value that is returned if the variable was not set. + * This function will always return a value of the same type as the default. + * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters + * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * Specifies which super global should be used + * + * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the + * the same as that of $default. If the variable is not set $default is returned. + */ + public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST); + + /** + * Checks whether a certain variable was sent via POST. + * To make sure that a request was sent using POST you should call this function + * on at least one variable. + * + * @param string $name The name of the form variable which should have a + * _p suffix to indicate the check in the code that creates the form too. + * + * @return bool True if the variable was set in a POST request, false otherwise. + */ + public function is_set_post($name); + + /** + * Checks whether a certain variable is set in one of the super global + * arrays. + * + * @param string $var Name of the variable + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * Specifies the super global which shall be checked + * + * @return bool True if the variable was sent as input + */ + public function is_set($var, $super_global = phpbb_request_interface::REQUEST); + + /** + * Returns all variable names for a given super global + * + * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global + * The super global from which names shall be taken + * + * @return array All variable names that are set for the super global. + * Pay attention when using these, they are unsanitised! + */ + public function variable_names($super_global = phpbb_request_interface::REQUEST); +} -- cgit v1.2.1