Changeset 20236
- Timestamp:
- 09/30/08 00:04:49 (5 years ago)
- Location:
- events/phpframework/sabel/trunk/Sabel/sabel
- Files:
-
- 5 modified
-
Context.php (modified) (3 diffs)
-
request/Internal.php (modified) (3 diffs)
-
request/Object.php (modified) (1 diff)
-
response/Object.php (modified) (1 diff)
-
response/Redirector.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/sabel/trunk/Sabel/sabel/Context.php
r20063 r20236 14 14 protected static $context = null; 15 15 16 protected $bus = null; 17 protected $candidate = null; 18 protected $redirector = null; 19 protected $exception = null; 16 protected $bus = null; 17 protected $candidate = null; 18 protected $exception = null; 20 19 21 20 public static function setContext($context) … … 53 52 } 54 53 55 public function setRedirector($redirector)56 {57 $this->redirector = $redirector;58 }59 60 public function getRedirector()61 {62 return $this->redirector;63 }64 65 54 public function setException($exception) 66 55 { … … 72 61 return $this->exception; 73 62 } 63 64 public static function getRequest() 65 { 66 $context = self::getContext(); 67 return ($context->bus) ? $context->bus->get("request") : null; 68 } 69 70 public static function getDestination() 71 { 72 $context = self::getContext(); 73 return ($context->bus) ? $context->bus->get("destination") : null; 74 } 75 76 public static function getSession() 77 { 78 $context = self::getContext(); 79 return ($context->bus) ? $context->bus->get("session") : null; 80 } 81 82 public static function getController() 83 { 84 $context = self::getContext(); 85 return ($context->bus) ? $context->bus->get("controller") : null; 86 } 87 88 public static function getResponse() 89 { 90 $context = self::getContext(); 91 return ($context->bus) ? $context->bus->get("response") : null; 92 } 74 93 } -
events/phpframework/sabel/trunk/Sabel/sabel/request/Internal.php
r20063 r20236 60 60 public function request($uri, Sabel_Bus_Config $config = null) 61 61 { 62 if (strpos($uri, ":")) { 63 $uri = uri($uri); 62 if ($config === null) { 63 if (class_exists("Config_Bus", false)) { 64 $config = new Config_Bus(); 65 } else { 66 $message = __METHOD__ . "() class Config_Bus not found."; 67 throw new Sabel_Exception_Runtime($message); 68 } 64 69 } 65 70 66 $uri = "http://localhost/{$uri}"; 67 $parsedUri = parse_url($uri); 68 $request = new Sabel_Request_Object(ltrim($parsedUri["path"], "/")); 71 if (strpos($uri, ":")) { 72 $context = Sabel_Context::getContext(); 73 $uri = $context->getCandidate()->uri($uri); 74 } else { 75 $uri = ltrim($uri, "/"); 76 } 77 78 $request = new Sabel_Request_Object($uri); 69 79 70 80 if (isset($parsedUri["query"])) { … … 79 89 $currentContext = Sabel_Context::getContext(); 80 90 $currentBus = $currentContext->getBus(); 81 82 91 $request->method($this->method); 83 92 $request->values($this->values); 84 93 94 Sabel_Context::setContext(new Sabel_Context()); 95 85 96 $bus = new Sabel_Bus(); 86 $bus->set("request", $request); 87 $bus->set("session", $currentBus->get("session")); 88 $bus->set("noLayout", !$this->withLayout); 89 90 $context = new Sabel_Context(); 91 $context->setBus($bus); 92 Sabel_Context::setContext($context); 93 94 if ($config === null) { 95 $config = new Config_Bus(); 96 } 97 97 $bus->set("request", $request); 98 $bus->set("session", $currentBus->get("session")); 99 $bus->set("NO_LAYOUT", !$this->withLayout); 98 100 $bus->run($config); 99 101 … … 101 103 $this->response["result"] = $bus->get("result"); 102 104 105 // restore context. 103 106 $currentContext->setBus($currentBus); 104 107 Sabel_Context::setContext($currentContext); -
events/phpframework/sabel/trunk/Sabel/sabel/request/Object.php
r20063 r20236 281 281 282 282 $result = null; 283 $values = array($this->fetchPostValues(), 284 $this->fetchGetValues(), 285 $this->fetchParameterValues()); 283 $values = array( 284 $this->fetchPostValues(), 285 $this->fetchGetValues(), 286 $this->fetchParameterValues() 287 ); 286 288 287 289 foreach ($values as $value) { -
events/phpframework/sabel/trunk/Sabel/sabel/response/Object.php
r20065 r20236 129 129 } 130 130 131 public function setLocation($ to, $host = null)131 public function setLocation($location) 132 132 { 133 if ($host === null) { 134 $this->location = $to; 135 } else { 136 $this->location = "http://" . $host . "/" . ltrim($to, "/"); 137 } 138 133 $this->location = $location; 139 134 $this->status->setCode(Sabel_Response::FOUND); 140 135 -
events/phpframework/sabel/trunk/Sabel/sabel/response/Redirector.php
r20063 r20236 50 50 public function to($uriParameter, $parameters = array()) 51 51 { 52 $this->parameters = $parameters; 53 return $this->uri(uri($uriParameter)); 52 $context = Sabel_Context::getContext(); 53 $uri = $context->getCandidate()->uri($uriParameter); 54 55 if ($this->parameters = $parameters) { 56 $uri .= "?" . http_build_query($this->parameters, "", "&"); 57 } 58 59 return $this->uri($uri); 54 60 } 55 61 … … 80 86 public function uri($uri) 81 87 { 88 $this->uri = "/" . ltrim($uri, "/"); 82 89 $this->redirected = true; 83 84 if ($this->hasParameters()) {85 $this->uri = $uri . "?" . http_build_query($this->parameters, "", "&");86 } else {87 $this->uri = $uri;88 }89 90 90 91 return $this->uri;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)