/**
  * Constructs a SiteUrl object from request variables
  *
  * @param HttpUrlDictionary $dictionary dictionary of values to be used in building the SiteUrl
  * @param string $baseHost optional host to be treated as base host
  * @param string $baseUri optional uri to be treated as base uri
  *
  * @return SiteUrl
  */
 static function import(HttpUrlDictionary $dictionary, $baseHost = null, $baseUri = '/')
 {
     $url = new self();
     if ($baseHost) {
         $url->setBaseHost($baseHost);
     }
     $url->setBasePath($baseUri);
     $url->setScheme($dictionary->getField(HttpUrlDictionary::HTTPS) ? 'https' : 'http')->setHost($dictionary->getField(HttpUrlDictionary::HOST))->setPort($dictionary->getField(HttpUrlDictionary::PORT));
     //get the URI itself
     $uri = $dictionary->getField(HttpUrlDictionary::URI);
     if (!preg_match('/^https?:\\/\\//', $uri)) {
         $uri = '/' . ltrim($uri, '/');
     }
     $parts = parse_url($uri);
     if (isset($parts['path'])) {
         $path = urldecode($parts['path']);
         $url->setPath($path);
     }
     if (isset($parts['query'])) {
         $newQuery = $query = array();
         parse_str($parts['query'], $query);
         foreach ($query as $k => $v) {
             $newQuery[urldecode($k)] = is_array($v) ? $v : urldecode($v);
         }
         $url->setQuery($newQuery);
     }
     return $url;
 }
 protected function getDefaultValues()
 {
     return array(self::HTTP_REFERER => '') + parent::getDefaultValues();
 }