本文整理汇总了PHP中Nette\Http\Url::getScheme方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getScheme方法的具体用法?PHP Url::getScheme怎么用?PHP Url::getScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Http\Url
的用法示例。
在下文中一共展示了Url::getScheme方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendBackgroundGetRequest
/**
* Funkce pro odeslání GET požadavku bez čekání na získání odpovědi
* @param string $url
* @throws \Exception
*/
public static function sendBackgroundGetRequest($url)
{
$url = new Url($url);
$host = $url->getHost();
if (empty($host)) {
$host = 'localhost';
}
#region parametry připojení
switch ($url->getScheme()) {
case 'https':
$scheme = 'ssl://';
$port = 443;
break;
case 'http':
default:
$scheme = '';
$port = 80;
}
$urlPort = $url->getPort();
if (!empty($urlPort)) {
$port = $urlPort;
}
#endregion
$fp = @fsockopen($scheme . $host, $port, $errno, $errstr, self::REQUEST_TIMEOUT);
if (!$fp) {
Debugger::log($errstr, ILogger::ERROR);
throw new \Exception($errstr, $errno);
}
$path = $url->getPath() . ($url->getQuery() != "" ? '?' . $url->getQuery() : '');
fputs($fp, "GET " . $path . " HTTP/1.0\r\nHost: " . $host . "\r\n\r\n");
fputs($fp, "Connection: close\r\n");
fputs($fp, "\r\n");
}
示例2: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(array $params, Nette\Http\Url $refUrl)
{
if ($this->flags & self::ONE_WAY) {
return NULL;
}
// remove default values; NULL values are retain
foreach ($this->defaults as $key => $value) {
if (isset($params[$key]) && $params[$key] == $value) {
// intentionally ==
unset($params[$key]);
}
}
$url = ($this->flags & self::SECURED ? 'https://' : $refUrl->getScheme() . '://') . $refUrl->getAuthority() . $refUrl->getPath();
$sep = ini_get('arg_separator.input');
$query = http_build_query($params, '', $sep ? $sep[0] : '&');
if ($query != '') {
// intentionally ==
$url .= '?' . $query;
}
return $url;
}
示例3: constructUrl
//.........这里部分代码省略.........
continue;
} elseif ($meta['fixity'] === self::CONSTANT) {
return NULL;
// missing or wrong parameter '$name'
}
}
if (is_scalar($params[$name]) && isset($meta['filterTable2'][$params[$name]])) {
$params[$name] = $meta['filterTable2'][$params[$name]];
} elseif (isset($meta['filterTable2']) && !empty($meta[self::FILTER_STRICT])) {
return NULL;
} elseif (isset($meta[self::FILTER_OUT])) {
$params[$name] = call_user_func($meta[self::FILTER_OUT], $params[$name]);
}
if (isset($meta[self::PATTERN]) && !preg_match($meta[self::PATTERN], rawurldecode($params[$name]))) {
return NULL;
// pattern not match
}
}
// compositing path
$sequence = $this->sequence;
$brackets = [];
$required = NULL;
// NULL for auto-optional
$url = '';
$i = count($sequence) - 1;
do {
$url = $sequence[$i] . $url;
if ($i === 0) {
break;
}
$i--;
$name = $sequence[$i];
$i--;
// parameter name
if ($name === ']') {
// opening optional part
$brackets[] = $url;
} elseif ($name[0] === '[') {
// closing optional part
$tmp = array_pop($brackets);
if ($required < count($brackets) + 1) {
// is this level optional?
if ($name !== '[!') {
// and not "required"-optional
$url = $tmp;
}
} else {
$required = count($brackets);
}
} elseif ($name[0] === '?') {
// "foo" parameter
continue;
} elseif (isset($params[$name]) && $params[$name] != '') {
// intentionally ==
$required = count($brackets);
// make this level required
$url = $params[$name] . $url;
unset($params[$name]);
} elseif (isset($metadata[$name]['fixity'])) {
// has default value?
if ($required === NULL && !$brackets) {
// auto-optional
$url = '';
} else {
$url = $metadata[$name]['defOut'] . $url;
}
} else {
return NULL;
// missing parameter '$name'
}
} while (TRUE);
$scheme = $this->scheme ?: $refUrl->getScheme();
if ($this->type === self::HOST) {
$host = $refUrl->getHost();
$parts = ip2long($host) ? [$host] : array_reverse(explode('.', $host));
$url = strtr($url, ['/%basePath%/' => $refUrl->getBasePath(), '%tld%' => $parts[0], '%domain%' => isset($parts[1]) ? "{$parts['1']}.{$parts['0']}" : $parts[0], '%sld%' => isset($parts[1]) ? $parts[1] : '', '%host%' => $host]);
$url = $scheme . ':' . $url;
} else {
if ($this->lastRefUrl !== $refUrl) {
$basePath = $this->type === self::RELATIVE ? $refUrl->getBasePath() : '';
$this->lastBaseUrl = $scheme . '://' . $refUrl->getAuthority() . $basePath;
$this->lastRefUrl = $refUrl;
}
$url = $this->lastBaseUrl . $url;
}
if (strpos($url, '//', strlen($scheme) + 3) !== FALSE) {
return NULL;
}
// build query string
if ($this->xlat) {
$params = self::renameKeys($params, $this->xlat);
}
$sep = ini_get('arg_separator.input');
$query = http_build_query($params, '', $sep ? $sep[0] : '&');
if ($query != '') {
// intentionally ==
$url .= '?' . $query;
}
return $url;
}
示例4: constructUrl
/**
* Constructs absolute URL from Request object.
*
* @return string|NULL
*/
public function constructUrl(App\Request $appRequest, Http\Url $refUrl)
{
$params = $appRequest->getParameters();
$query = $params;
unset($query['action'], $query['page_id'], $query['slug'], $query['id'], $query['locale'], $query['prefix']);
if (isset($params['slug'])) {
$slug = strtolower($params['slug']);
} else {
if (isset($params['page_id'])) {
$row = $this->slugManager->getSlugById($params['page_id']);
// todo peekay Change cs for selected language
if (isset($query['locale'])) {
unset($params['locale']);
}
if ($row) {
if (isset($params['locale'])) {
$slug = $row->{'slug_' . $params['locale']};
} else {
$slug = $row->{'slug'};
}
} else {
return NULL;
}
} else {
return NULL;
}
}
if (isset($params['locale'])) {
$locale = $params['locale'] . '/';
} else {
$locale = null;
}
if (isset($params['prefix'])) {
$prefix = $params['prefix'] . '/';
} else {
$prefix = null;
}
$url = $refUrl->getScheme() . '://' . $refUrl->getHost() . $refUrl->getPath() . $locale . $prefix . $slug;
$params = $appRequest->getParameters();
if (isset($params['action']) && $params['action'] !== 'default') {
$url .= $refUrl->getPath();
}
if (isset($params['id'])) {
if ($params['action'] == 'default' && isset($params['action'])) {
$url .= $refUrl->getPath();
}
$url .= $refUrl->getPath() . $params['id'];
}
if (count($query) > 0) {
$queryString = '?';
foreach ($query as $key => $parameter) {
$queryString .= $key . '=' . $parameter . '&';
}
$finalQueryString = substr($queryString, 0, -1);
$url .= $finalQueryString;
}
return $url;
}
示例5: constructUrl
/**
* Constructs absolute URL from Request object.
* @return string|NULL
*/
public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
{
if ($this->flags & self::ONE_WAY) {
return NULL;
}
$params = $appRequest->getParameters();
// presenter name
$presenter = $appRequest->getPresenterName();
if (strncmp($presenter, $this->module, strlen($this->module)) === 0) {
$params[self::PRESENTER_KEY] = substr($presenter, strlen($this->module));
} else {
return NULL;
}
// remove default values; NULL values are retain
foreach ($this->defaults as $key => $value) {
if (isset($params[$key]) && $params[$key] == $value) {
// intentionally ==
unset($params[$key]);
}
}
$url = ($this->flags & self::SECURED ? 'https://' : $refUrl->getScheme() . '://') . $refUrl->getAuthority() . $refUrl->getPath();
$sep = ini_get('arg_separator.input');
$query = http_build_query($params, '', $sep ? $sep[0] : '&');
if ($query != '') {
// intentionally ==
$url .= '?' . $query;
}
return $url;
}