From 3259c3d9e3ebdb70ac7ddc3dcc59d6dc062ff7ee Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 11 Mar 2011 00:07:40 +0100 Subject: [PATCH] backend accepts now parameters via POST --- lib/View/HTTP/Request.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/View/HTTP/Request.php b/lib/View/HTTP/Request.php index 96fd9f5..291efde 100644 --- a/lib/View/HTTP/Request.php +++ b/lib/View/HTTP/Request.php @@ -80,8 +80,35 @@ class Request { public function getHeader($header) { return $this->headers[$header]; } public function getMethod() { return $this->method; } - public function getParameter($name, $method = 'get') { return (isset($this->parameters[$method][$name])) ? $this->parameters[$method][$name] : NULL; } - public function getParameters($method = 'get') { return $this->parameters[$method]; } + + public function getParameter($name, $method = NULL) { + if (isset($method) && isset($this->parameters[$method][$name])) { + return $this->parameters[$method][$name]; + } + else { // fall through: get -> post -> cookie -> files + foreach (array_keys($this->parameters) as $method) { + if (isset($this->parameters[$method][$name])) { + return $this->parameters[$method][$name]; + } + } + } + return NULL; + } + + public function getParameters($method = NULL) { + if (isset($method)) { + return $this->parameters[$method]; + } + else { // merge all + return array_merge( + $this->parameters['files'], + $this->parameters['cookies'], + $this->parameters['post'], + $this->parameters['get'] + ); + } + return NULL; + } }