Example #1
0
 /**
  *    Replaces unknown sections to turn a relative
  *    URL into an absolute one. The base URL can
  *    be either a string or a SimpleUrl object.
  *
  *    @param string/SimpleUrl $base       Base URL.
  */
 public function makeAbsolute($base)
 {
     if (!is_object($base)) {
         $base = new self($base);
     }
     if ($this->getHost()) {
         $scheme = $this->getScheme();
         $host = $this->getHost();
         $port = $this->getPort() ? ':' . $this->getPort() : '';
         $identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
         if (!$identity) {
             $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
         }
     } else {
         $scheme = $base->getScheme();
         $host = $base->getHost();
         $port = $base->getPort() ? ':' . $base->getPort() : '';
         $identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
     }
     $path = $this->normalisePath($this->_extractAbsolutePath($base));
     $encoded = $this->getEncodedRequest();
     $fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
     $coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
     return new self("{$scheme}://{$identity}{$host}{$port}{$path}{$encoded}{$fragment}{$coords}");
 }