當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。