Exemplo n.º 1
0
 /**
  * url
  *
  * @param int    $size
  * @param int    $id
  * @param string $u
  *
  * @return  string
  */
 public static function url($size = 300, $id = null, $u = null)
 {
     $uri = new Uri(static::$host);
     $size = $size ?: 300;
     $uri->setPath('/' . $size);
     if ($id) {
         $uri->setVar('id', (int) $id);
     }
     if ($u) {
         $uri->setVar('u', $u);
     }
     return $uri->toString();
 }
Exemplo n.º 2
0
 /**
  * Get system Uri object.
  *
  * @param   string  $requestUri  The request uri string.
  * @param   bool    $refresh     Refresh the uri.
  *
  * @return  Uri  The system Uri object.
  *
  * @since   2.0
  */
 protected function getSystemUri($requestUri = null, $refresh = false)
 {
     if ($this->uri && !$refresh) {
         return $this->uri;
     }
     $requestUri = $requestUri ?: $this->detectRequestUri();
     // Start with the requested URI.
     $uri = new Uri($requestUri);
     // If we are working from a CGI SAPI with the 'cgi.fix_pathinfo' directive disabled we use PHP_SELF.
     if (strpos(php_sapi_name(), 'cgi') !== false && !ini_get('cgi.fix_pathinfo') && !empty($_SERVER['REQUEST_URI'])) {
         // We aren't expecting PATH_INFO within PHP_SELF so this should work.
         $uri->setPath(rtrim(dirname($_SERVER['PHP_SELF']), '/\\'));
     } else {
         $uri->setPath(rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\'));
     }
     // Clear the unused parts of the requested URI.
     $uri->setQuery(null);
     $uri->setFragment(null);
     return $this->uri = $uri;
 }
Exemplo n.º 3
0
 /**
  * Test the setPath method.
  *
  * @return  void
  *
  * @since   1.0
  * @covers  Windwalker\Uri\Uri::setPath
  */
 public function testSetPath()
 {
     $this->object->setPath('/this/is/a/path/to/a/file.htm');
     $this->assertThat($this->object->getPath(), $this->equalTo('/this/is/a/path/to/a/file.htm'));
 }