Changeset 20236

Show
Ignore:
Timestamp:
09/30/08 00:04:49 (5 years ago)
Author:
sabel
Message:

update Sabel rev. 2825

Location:
events/phpframework/sabel/trunk/Sabel/sabel
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • events/phpframework/sabel/trunk/Sabel/sabel/Context.php

    r20063 r20236  
    1414  protected static $context = null; 
    1515   
    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; 
    2019   
    2120  public static function setContext($context) 
     
    5352  } 
    5453   
    55   public function setRedirector($redirector) 
    56   { 
    57     $this->redirector = $redirector; 
    58   } 
    59    
    60   public function getRedirector() 
    61   { 
    62     return $this->redirector; 
    63   } 
    64    
    6554  public function setException($exception) 
    6655  { 
     
    7261    return $this->exception; 
    7362  } 
     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  } 
    7493} 
  • events/phpframework/sabel/trunk/Sabel/sabel/request/Internal.php

    r20063 r20236  
    6060  public function request($uri, Sabel_Bus_Config $config = null) 
    6161  { 
    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      } 
    6469    } 
    6570     
    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); 
    6979     
    7080    if (isset($parsedUri["query"])) { 
     
    7989    $currentContext = Sabel_Context::getContext(); 
    8090    $currentBus = $currentContext->getBus(); 
    81      
    8291    $request->method($this->method); 
    8392    $request->values($this->values); 
    8493     
     94    Sabel_Context::setContext(new Sabel_Context()); 
     95     
    8596    $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); 
    98100    $bus->run($config); 
    99101     
     
    101103    $this->response["result"]   = $bus->get("result"); 
    102104     
     105    // restore context. 
    103106    $currentContext->setBus($currentBus); 
    104107    Sabel_Context::setContext($currentContext); 
  • events/phpframework/sabel/trunk/Sabel/sabel/request/Object.php

    r20063 r20236  
    281281     
    282282    $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    ); 
    286288     
    287289    foreach ($values as $value) { 
  • events/phpframework/sabel/trunk/Sabel/sabel/response/Object.php

    r20065 r20236  
    129129  } 
    130130   
    131   public function setLocation($to, $host = null) 
     131  public function setLocation($location) 
    132132  { 
    133     if ($host === null) { 
    134       $this->location = $to; 
    135     } else { 
    136       $this->location = "http://" . $host . "/" . ltrim($to, "/"); 
    137     } 
    138      
     133    $this->location = $location; 
    139134    $this->status->setCode(Sabel_Response::FOUND); 
    140135     
  • events/phpframework/sabel/trunk/Sabel/sabel/response/Redirector.php

    r20063 r20236  
    5050  public function to($uriParameter, $parameters = array()) 
    5151  { 
    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); 
    5460  } 
    5561   
     
    8086  public function uri($uri) 
    8187  { 
     88    $this->uri = "/" . ltrim($uri, "/"); 
    8289    $this->redirected = true; 
    83      
    84     if ($this->hasParameters()) { 
    85       $this->uri = $uri . "?" . http_build_query($this->parameters, "", "&"); 
    86     } else { 
    87       $this->uri = $uri; 
    88     } 
    8990     
    9091    return $this->uri;