当前位置: 首页>>代码示例>>PHP>>正文


PHP Http\Url类代码示例

本文整理汇总了PHP中Nette\Http\Url的典型用法代码示例。如果您正苦于以下问题:PHP Url类的具体用法?PHP Url怎么用?PHP Url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Url类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 public function render($rowData)
 {
     if ($this->_renderer) {
         return call_user_func($this->_renderer, $this);
     }
     // Direct URL
     if ($this->_url !== NULL) {
         // URL callback
         if (is_callable($this->_url)) {
             $url = call_user_func($this->_url, $rowData);
         } else {
             $url = new Nette\Http\Url($this->_url);
             foreach ($this->_table->getIdColumns() as $key) {
                 $url->appendQuery(array('record' . ucfirst($key) => isset($rowData->{$key}) ? $rowData->{$key} : NULL));
             }
         }
         $this->element->href((string) $url);
         // Standard action's URL
     } else {
         $this->element->href($this->_table->createActionLink($this->getName(), $rowData));
     }
     // Class
     if (($class = $this->getClass($rowData)) !== NULL) {
         $this->element->class .= " {$class}";
     }
     return (string) $this->element;
 }
开发者ID:vbuilder,项目名称:framework,代码行数:27,代码来源:DataTableButton.php

示例2: constructUrl

 public function constructUrl(Request $appRequest, Url $refUrl)
 {
     // Module prefix not match.
     if ($this->module && !Strings::startsWith($appRequest->getPresenterName(), $this->module)) {
         return null;
     }
     $params = $appRequest->getParameters();
     $urlStack = [];
     // Module prefix
     $moduleFrags = explode(":", Strings::lower($appRequest->getPresenterName()));
     $resourceName = array_pop($moduleFrags);
     $urlStack += $moduleFrags;
     // Resource
     $urlStack[] = Strings::lower($resourceName);
     // Id
     if (isset($params['id']) && is_scalar($params['id'])) {
         $urlStack[] = $params['id'];
         unset($params['id']);
     }
     // Set custom action
     if (isset($params['action']) && $this->_isApiAction($params['action'])) {
         unset($params['action']);
     }
     $url = $refUrl->getBaseUrl() . implode('/', $urlStack);
     // Add query parameters
     if (!empty($params)) {
         $url .= "?" . http_build_query($params);
     }
     return $url;
 }
开发者ID:bauer01,项目名称:unimapper-nette,代码行数:30,代码来源:Route.php

示例3: addTrackingParameters

 /**
  * @param Payment $payment
  * @return Payment
  */
 public static function addTrackingParameters(Payment $payment)
 {
     $resURL = $payment->getResURL();
     $url = new Url($resURL);
     $url->setQueryParameter('utm_nooverride', 1);
     $payment->setResURL($url->getAbsoluteUrl());
     return $payment;
 }
开发者ID:metisfw,项目名称:adyen,代码行数:12,代码来源:GaTracking.php

示例4: addTrackingParameters

 public static function addTrackingParameters(Payment $payment)
 {
     $redirectUrls = $payment->getRedirectUrls();
     $url = new Url($redirectUrls->getReturnUrl());
     $url->setQueryParameter('utm_nooverride', 1);
     $redirectUrls->setReturnUrl($url->getAbsoluteUrl());
     $payment->setRedirectUrls($redirectUrls);
     return $payment;
 }
开发者ID:metisfw,项目名称:paypal,代码行数:9,代码来源:GaTracking.php

示例5: getVideoByUrl

 /**
  * Fetches video data by youtube url
  * @param  string  $videoUrl YouTube url
  * @return Video
  */
 public function getVideoByUrl($videoUrl)
 {
     $url = new Nette\Http\Url($videoUrl);
     if (stripos($url->host, 'youtu.be') !== false) {
         return $this->getVideo(trim($url->getPath(), '/'));
     }
     $videoId = $url->getQueryParameter('v');
     if (stripos($url->host, 'youtube.com') === false || $videoId === null) {
         throw new Nette\InvalidArgumentException('videoUrl must be valid youtube url.');
     }
     return $this->getVideo($videoId);
 }
开发者ID:nextras,项目名称:youtube-api,代码行数:17,代码来源:Reader.php

示例6: redirectToRequest

 /**
  * Restores request from session.
  * @param string $key
  */
 public function redirectToRequest($key)
 {
     $request = $this->requestStorage->loadRequest($key);
     if (!$request) {
         return;
     }
     $parameters = $request->getParameters();
     $parameters[Presenter::FLASH_KEY] = $this->getParameter(Presenter::FLASH_KEY);
     $parameters[RequestStorage::REQUEST_KEY] = $key;
     $request->setParameters($parameters);
     $refUrl = new Url($this->httpRequest->getUrl());
     $refUrl->setPath($this->httpRequest->getUrl()->getScriptPath());
     $url = $this->router->constructUrl($request, $refUrl);
     $this->redirectUrl($url);
 }
开发者ID:enumag,项目名称:application,代码行数:19,代码来源:RequestStoragePresenterTrait.php

示例7: constructUrl

 /**
  * Constructs absolute URL from Request object.
  *
  * @param  Nette\Application\Request
  * @param  Nette\Http\Url
  *
  * @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 (strncasecmp($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://' : 'http://') . $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;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:37,代码来源:SimpleRouter.php

示例8: validateRecaptcha

 /**
  * @return bool
  */
 public function validateRecaptcha()
 {
     $httpData = $this->getForm()->getHttpData();
     if (!isset($httpData['g-recaptcha-response'])) {
         $this->addError($this->getFilledMessage());
         return TRUE;
     }
     $this->validateKeys();
     $url = new Url();
     $url->setHost('www.google.com')->setScheme('https')->setPath('recaptcha/api/siteverify')->setQueryParameter('secret', $this->secretKey)->setQueryParameter('response', $httpData['g-recaptcha-response']);
     $data = json_decode(file_get_contents((string) $url));
     if (!isset($data->success) || $data->success !== TRUE) {
         $this->addError($this->getValidMessage());
     }
     return TRUE;
 }
开发者ID:webchemistry,项目名称:forms-controls,代码行数:19,代码来源:Recaptcha.php

示例9: exec

 /**
  * Calls remote API.
  *
  * @param string
  * @return mixed json-decoded result
  * @throws \NetteAddons\IOException
  */
 protected function exec($path)
 {
     try {
         $url = new Url($this->baseUrl . '/' . ltrim($path, '/'));
         if ($this->clientId && $this->clientSecret) {
             $url->appendQuery(array('client_id' => $this->clientId, 'client_secret' => $this->clientSecret));
         }
         $request = $this->requestFactory->create($url);
         $request->addHeader('Accept', "application/vnd.github.{$this->apiVersion}+json");
         return \Nette\Utils\Json::decode($request->execute());
     } catch (\NetteAddons\Utils\StreamException $e) {
         throw new \NetteAddons\IOException('Request execution failed.', NULL, $e);
     } catch (\Nette\Utils\JsonException $e) {
         throw new \NetteAddons\IOException('GitHub API returned invalid JSON.', NULL, $e);
     }
 }
开发者ID:newPOPE,项目名称:web-addons.nette.org,代码行数:23,代码来源:Repository.php

示例10: process

 private function process($url, string $directory, string $parameter, array &$dependencies = []) : string
 {
     $url = new Nette\Http\Url($url);
     $time = NULL;
     if ($url->getHost() && (!$this->request || $url->getHost() !== $this->request->getUrl()->getHost())) {
         $headers = @get_headers($url, TRUE);
         if (is_array($headers) && isset($headers['Last-Modified'])) {
             $time = (new DateTime($headers['Last-Modified']))->getTimestamp();
         }
     } elseif (is_file($filename = implode(DIRECTORY_SEPARATOR, [rtrim($directory, '\\/'), ltrim($url->getPath(), '\\/')]))) {
         $time = filemtime($filename);
         unset($dependencies[Nette\Caching\Cache::EXPIRE]);
         $dependencies[Nette\Caching\Cache::FILES] = $filename;
     }
     $url->setQueryParameter($parameter, $time ?: ($this->time ?: ($this->time = time())));
     return preg_replace($pattern = '#^(\\+|/+)#', preg_match($pattern, $url->getPath()) ? DIRECTORY_SEPARATOR : NULL, $url);
 }
开发者ID:vitkutny,项目名称:version,代码行数:17,代码来源:Filter.php

示例11: validateRecaptcha

 public function validateRecaptcha()
 {
     $httpData = $this->getForm()->getHttpData();
     if (!isset($httpData['g-recaptcha-response'])) {
         $this->addError('Please fill antispam.');
         return TRUE;
     }
     $url = new Url();
     $url->setHost('www.google.com')->setScheme('https')->setPath('recaptcha/api/siteverify')->setQueryParameter('secret', $this->secretKey)->setQueryParameter('response', $httpData['g-recaptcha-response']);
     $data = json_decode(file_get_contents((string) $url));
     if (isset($data->success) && $data->success === TRUE) {
         return TRUE;
     } else {
         $this->addError('Antispam detection wasn\'t success.');
         return TRUE;
     }
 }
开发者ID:enumag,项目名称:WebChemistry-Forms-Controls,代码行数:17,代码来源:Recaptcha.php

示例12: 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");
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:38,代码来源:RequestHelper.php

示例13: createComponentPlayer

 public function createComponentPlayer()
 {
     $host = explode(".", $this->playUrl->getHost());
     $provider = Nette\Utils\Strings::lower($host[count($host) - 2]);
     $handler = "\\App\\Controls\\" . ucfirst($provider) . "Player";
     if (class_exists($handler)) {
         $player = new $handler($this->playUrl);
     } else {
         $player = new \App\Controls\NoPlayer($this->playUrl);
     }
     return $player;
 }
开发者ID:sg3tester,项目名称:songator,代码行数:12,代码来源:SongPresenter.php

示例14: 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;
 }
开发者ID:nette,项目名称:routing,代码行数:25,代码来源:SimpleRouter.php

示例15: constructUrl

 /**
  * Constructs absolute URL from Request object.
  *
  * @return string|NULL
  */
 public function constructUrl(AppRequest $appRequest, Url $refUrl)
 {
     if ($this->flags & self::ONE_WAY) {
         return NULL;
     }
     $params = $appRequest->getParameters();
     if (!isset($params['action']) || !is_string($params['action'])) {
         return NULL;
     }
     $key = $appRequest->getPresenterName() . ':' . $params['action'];
     if (!isset($this->tableOut[$key])) {
         return NULL;
     }
     if ($this->lastRefUrl !== $refUrl) {
         $this->lastBaseUrl = $refUrl->getBaseUrl();
         $this->lastRefUrl = $refUrl;
     }
     unset($params['action']);
     $slug = $this->tableOut[$key];
     $query = ($tmp = http_build_query($params)) ? '?' . $tmp : '';
     $url = $this->lastBaseUrl . $slug . $query;
     return $url;
 }
开发者ID:nextras,项目名称:static-router,代码行数:28,代码来源:StaticRouter.php


注:本文中的Nette\Http\Url类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。