protected function _generateBaseUri()
 {
     $uri = new Solar_Uri();
     $uri->setPath($this->_config['dbname']);
     $uri->host = $this->_config['host'];
     $uri->port = $this->_config['port'];
     if ($this->_config['encrypted'] == false) {
         $uri->scheme = 'http';
     } else {
         $uri->scheme = 'https';
     }
     if (isset($this->_config['user']) and isset($this->_config['password'])) {
         $uri->user = $this->_config['user'];
         $uri->pass = $this->_config['password'];
     }
     return $uri;
 }
Beispiel #2
0
 /**
  * 
  * Rewrite the URI path according to a dynamic ruleset.
  * 
  * @param Solar_Uri $uri The URI to rewrite in place.
  * 
  * @return void
  * 
  */
 protected function _rewrite($uri)
 {
     // pre-empt rewrites
     if (!$this->_rewrite) {
         $this->_explain['rewrite_rule'] = 'no rules';
         return;
     }
     // get the original URI path, trimming slashes
     $orig = trim($uri->getPath(), '/');
     // start matching against regexen
     foreach ($this->_rewrite as $find => $repl) {
         // convert substitution expressions
         $find = str_replace(array_keys($this->_replace), array_values($this->_replace), $find);
         // trim slashes and wrap as a full regex
         $find = '#^' . trim($find, '/') . '$#';
         // is there a match?
         if (preg_match($find, $orig)) {
             // do replacement for new path (trim slashes)
             $repl = trim($repl, '/');
             $path = preg_replace($find, $repl, $orig);
             // set the new path, trimming slashes again
             $uri->setPath(trim($path, '/'));
             $this->_explain['rewrite_rule'] = "matched '{$find}'";
             $this->_explain['rewrite_uri'] = $uri->getPath();
             return;
         }
     }
     $this->_explain['rewrite_rule'] = 'none matched';
 }