From 78cee1df0b05ca3cb8aa2e7dd40cbc75da95f7ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 24 Mar 2009 06:54:28 +0000 Subject: [PATCH] ConsoleRequest class basicly finished --- .../request/console/class_ConsoleRequest.php | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/inc/classes/main/request/console/class_ConsoleRequest.php b/inc/classes/main/request/console/class_ConsoleRequest.php index 3ac92eb8..6ef86f5e 100644 --- a/inc/classes/main/request/console/class_ConsoleRequest.php +++ b/inc/classes/main/request/console/class_ConsoleRequest.php @@ -55,7 +55,35 @@ class ConsoleRequest extends BaseRequest implements Requestable { * @todo Needs to be implemented */ public function prepareRequestData () { - $this->partialStub("Please implement this method."); + // Get the "request data" from the command-line argument list + $args = $_SERVER['argv']; + + // Are there less than two parameters? + if ($_SERVER['argc'] < 2) { + // Skip this + return; + } // END - if + + // Is the first element "index.php" ? + if ($args[0] == "index.php") { + // Then remove it + array_shift($args); + } // END - if + + // Try to determine next parameters + foreach ($args as $arg) { + // Seperate arguemnt name from value + $argArray = explode("=", $arg); + + // Is the second one set? + if (!isset($argArray[1])) { + // Add it likewise, but empty value + $this->setRequestElement($argArray[0], ""); + } else { + // Set a name=value pair + $this->setRequestElement($argArray[0], $argArray[1]); + } + } // END - foreach } /** @@ -74,8 +102,7 @@ class ConsoleRequest extends BaseRequest implements Requestable { * @return $requestMethod Used request method */ public final function getRequestMethod () { - $this->partialStub("Please implement this method."); - return $_SERVER['REQUEST_METHOD']; + return "LOCAL"; } /** @@ -85,7 +112,8 @@ class ConsoleRequest extends BaseRequest implements Requestable { * @return $cookieValue Value of cookie or null if not found */ public final function readCookie ($cookieName) { - $this->partialStub("Please implement this method."); + // @TODO There are no cookies on console + return null; } } -- 2.30.2