From 8c512b0d2d73a0930a420030dd6fecb8cb2d506f Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 18 Jan 2013 14:00:40 -0500 Subject: [ticket/11334] Properly generate controller URL until paths issue gets fixed PHPBB3-11334 --- phpBB/includes/controller/helper.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 6cacc8fefa..2098f51edf 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -85,17 +85,14 @@ class phpbb_controller_helper } /** - * Easily generate a URL + * Generate a URL * - * @param array $url_parts Each array element is a 'folder' - * i.e. array('my', 'ext') maps to ./app.php/my/ext - * @param mixed $query The Query string, passed directly into the second - * argument of append_sid() - * @return string A URL that has already been run through append_sid() + * @param string $route The route to travel + * @return string The URL already passed through append_sid() */ - public function url(array $url_parts, $query = '') + protected function url($route) { - return append_sid($this->phpbb_root_path . implode('/', $url_parts), $query); + return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, array('controller' => $route)); } /** -- cgit v1.2.1 From d3e2fae66d74f79ef7dcfe2e24f47efaa5c106e2 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 15 Feb 2013 16:48:43 -0500 Subject: [ticket/11334] Add a test for the controller helper URL method PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 2098f51edf..0e64829874 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -55,7 +55,7 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) + public function __construct(phpbb_template $template = null, phpbb_user $user = null, $phpbb_root_path = './', $php_ext = '.php') { $this->template = $template; $this->user = $user; -- cgit v1.2.1 From 5e89ce1898857f29e5345adf31d62bbed1fb985b Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 15 Feb 2013 16:52:54 -0500 Subject: [ticket/11334] Make url helper method public PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 0e64829874..f2beca2056 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -90,7 +90,7 @@ class phpbb_controller_helper * @param string $route The route to travel * @return string The URL already passed through append_sid() */ - protected function url($route) + public function url($route) { return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, array('controller' => $route)); } -- cgit v1.2.1 From 5850a2cbf6e8313feeb55154e1083d73b45f4dc3 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 16 Feb 2013 19:21:34 -0500 Subject: [ticket/11334] Remove extraneous period PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index f2beca2056..451c448a18 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -92,7 +92,7 @@ class phpbb_controller_helper */ public function url($route) { - return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext, array('controller' => $route)); + return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, array('controller' => $route)); } /** -- cgit v1.2.1 From ff9a0e4ef4756c5a9cce3f023b07d9f9a0e5653a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Mar 2013 13:35:43 +0100 Subject: [ticket/11334] Expand functionality of helper->url() Expanded the functionality of helper->url() to support all parameters of append_sid() itself. PHPBB3-11334 --- phpBB/includes/controller/helper.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 451c448a18..4c021849f4 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -87,12 +87,30 @@ class phpbb_controller_helper /** * Generate a URL * - * @param string $route The route to travel + * @param string $route The route to travel + * @param mixed $params String or array of additional url parameters + * @param bool $is_amp Is url using & (true) or & (false) + * @param string $session_id Possibility to use a custom session id instead of the global one * @return string The URL already passed through append_sid() */ - public function url($route) + public function url($route, $params = false, $is_amp = true, $session_id = false) { - return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, array('controller' => $route)); + if (is_array($params) && !empty($params)) + { + $params = array_merge(array( + 'controller' => $route, + ), $params); + } + else if (is_string($params) && $params) + { + $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; + } + else + { + $params = array('controller' => $route); + } + + return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From 076711d9a95e05083143b7ac4a589914a2e2b2ad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Mar 2013 14:02:46 +0100 Subject: [ticket/11334] Use mocks instead of making parameters optional PHPBB3-11334 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 4c021849f4..1464267711 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -55,7 +55,7 @@ class phpbb_controller_helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP extension */ - public function __construct(phpbb_template $template = null, phpbb_user $user = null, $phpbb_root_path = './', $php_ext = '.php') + public function __construct(phpbb_template $template, phpbb_user $user, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; -- cgit v1.2.1 From 3b0cdc53629c3a852762ae9b96b809cf4b1af2c4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 15 Mar 2013 15:21:15 +0100 Subject: [ticket/11334] Allow parameters to be specified in the route PHPBB3-11334 --- phpBB/includes/controller/helper.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 1464267711..46c6307cb4 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -95,6 +95,13 @@ class phpbb_controller_helper */ public function url($route, $params = false, $is_amp = true, $session_id = false) { + $route_params = ''; + if (($route_delim = strpos($route, '?')) !== false) + { + $route_params = substr($route, $route_delim); + $route = substr($route, 0, $route_delim); + } + if (is_array($params) && !empty($params)) { $params = array_merge(array( @@ -110,7 +117,7 @@ class phpbb_controller_helper $params = array('controller' => $route); } - return append_sid($this->phpbb_root_path . 'app' . $this->php_ext, $params, $is_amp, $session_id); + return append_sid($this->phpbb_root_path . 'app' . $this->php_ext . $route_params, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From 6ef363547abf98445d20db61ffa5bac66b260603 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 24 Apr 2013 17:10:17 -0500 Subject: [ticket/11335] (controller/helper.php) Make php_ext 'php' not '.php' PHPBB3-11335 --- phpBB/includes/controller/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php index 46c6307cb4..74410ddfd1 100644 --- a/phpBB/includes/controller/helper.php +++ b/phpBB/includes/controller/helper.php @@ -117,7 +117,7 @@ class phpbb_controller_helper $params = array('controller' => $route); } - return append_sid($this->phpbb_root_path . 'app' . $this->php_ext . $route_params, $params, $is_amp, $session_id); + return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id); } /** -- cgit v1.2.1 From 7030578bbe9e11c18b5becaf8b06e670e3c2e3cd Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 01:32:34 -0400 Subject: [ticket/11698] Moving all autoloadable files to phpbb/ PHPBB3-11698 --- phpBB/includes/controller/helper.php | 139 ----------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 phpBB/includes/controller/helper.php (limited to 'phpBB/includes/controller/helper.php') diff --git a/phpBB/includes/controller/helper.php b/phpBB/includes/controller/helper.php deleted file mode 100644 index 74410ddfd1..0000000000 --- a/phpBB/includes/controller/helper.php +++ /dev/null @@ -1,139 +0,0 @@ -template = $template; - $this->user = $user; - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $php_ext; - } - - /** - * Automate setting up the page and creating the response object. - * - * @param string $handle The template handle to render - * @param string $page_title The title of the page to output - * @param int $status_code The status code to be sent to the page header - * @return Response object containing rendered page - */ - public function render($template_file, $page_title = '', $status_code = 200) - { - page_header($page_title); - - $this->template->set_filenames(array( - 'body' => $template_file, - )); - - page_footer(true, false, false); - - return new Response($this->template->assign_display('body'), $status_code); - } - - /** - * Generate a URL - * - * @param string $route The route to travel - * @param mixed $params String or array of additional url parameters - * @param bool $is_amp Is url using & (true) or & (false) - * @param string $session_id Possibility to use a custom session id instead of the global one - * @return string The URL already passed through append_sid() - */ - public function url($route, $params = false, $is_amp = true, $session_id = false) - { - $route_params = ''; - if (($route_delim = strpos($route, '?')) !== false) - { - $route_params = substr($route, $route_delim); - $route = substr($route, 0, $route_delim); - } - - if (is_array($params) && !empty($params)) - { - $params = array_merge(array( - 'controller' => $route, - ), $params); - } - else if (is_string($params) && $params) - { - $params = 'controller=' . $route . (($is_amp) ? '&' : '&') . $params; - } - else - { - $params = array('controller' => $route); - } - - return append_sid($this->phpbb_root_path . 'app.' . $this->php_ext . $route_params, $params, $is_amp, $session_id); - } - - /** - * Output an error, effectively the same thing as trigger_error - * - * @param string $message The error message - * @param string $code The error code (e.g. 404, 500, 503, etc.) - * @return Response A Reponse instance - */ - public function error($message, $code = 500) - { - $this->template->assign_vars(array( - 'MESSAGE_TEXT' => $message, - 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), - )); - - return $this->render('message_body.html', $this->user->lang('INFORMATION'), $code); - } -} -- cgit v1.2.1