當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validators::isUrl方法代碼示例

本文整理匯總了PHP中Nette\Utils\Validators::isUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validators::isUrl方法的具體用法?PHP Validators::isUrl怎麽用?PHP Validators::isUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nette\Utils\Validators的用法示例。


在下文中一共展示了Validators::isUrl方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: unsubscribeLink

 /**
  * @param string $unsubscribeLink
  * @return $this
  * @throws EmailException
  */
 public function unsubscribeLink($unsubscribeLink)
 {
     if (!Nette\Utils\Validators::isUrl($unsubscribeLink)) {
         throw new EmailException('Email is not valid', EmailException::INVALID_EMAIL);
     }
     $this->unsubscribeLink = $unsubscribeLink;
     return $this;
 }
開發者ID:trejjam,項目名稱:email,代碼行數:13,代碼來源:Email.php

示例2: reformatMarkdownLinks

 /**
  * @param Github $github
  */
 protected function reformatMarkdownLinks(Github $github)
 {
     $github->content = Strings::replace($github->content, '#\\[(.*)\\]\\((.+)\\)#iU', function ($matches) use($github) {
         list($all, $title, $url) = $matches;
         if (!Validators::isUrl($url)) {
             $url = $github->linker->getBlobUrl($matches[2]);
         }
         return sprintf('[%s](%s)', $title, $url);
     });
 }
開發者ID:milo,項目名稱:componette.com,代碼行數:13,代碼來源:GenerateContentTask.php

示例3: redirectUrl

 /**
  * Redirects using JavaScript.
  * @param string $url 
  * @return void
  */
 public static function redirectUrl($url)
 {
     if (FALSE === Validators::isUrl($url)) {
         throw new \Nette\InvalidArgumentException($url . " is not valid URL.");
     }
     $template = new FileTemplate(dirname(__FILE__) . '/' . self::$TEMPLATE_DIR . '/iframeRedirect.latte');
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $template->registerFilter(new \Nette\Latte\Engine());
     $template->url = $url;
     $template->render();
     exit;
 }
開發者ID:illagrenan,項目名稱:nette-facebook-connect,代碼行數:17,代碼來源:IframeRedirect.php

示例4: getImageInfo

 /**
  * Get Image from source
  * @param  mixed $source Source of image
  * @return array|NULL ["image" => Nette\Utils\Image, "filename" => string]
  */
 public function getImageInfo($source)
 {
     if (is_string($source)) {
         foreach ($this->dirs as $dir) {
             if (file_exists($dir . $source)) {
                 $path_parts = pathinfo($source);
                 $filename = $path_parts['filename'];
                 return ["image" => Image::fromFile($dir . $source), "filename" => $filename, "lazy" => TRUE, "params" => ["dir" => $path_parts['dirname'], "ext" => $path_parts['extension']]];
             } elseif (Validators::isUrl($source)) {
                 return ["image" => Image::fromFile($source), "filename" => basename($source)];
             }
         }
     }
 }
開發者ID:romanmatyus,項目名稱:Thorin,代碼行數:19,代碼來源:PathProvider.php

示例5: pingback_ping

 public function pingback_ping($source, $target)
 {
     if (!Validators::isUrl($source)) {
         return $this->xmlrpc_fault(self::RESPONSE_FAULT_SOURCE);
     }
     if (!Validators::isUrl($target)) {
         return $this->xmlrpc_fault(self::RESPONSE_FAULT_TARGET);
     }
     $curl = curl_init($target);
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_NOBODY, true);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     $headers = http_parse_headers(curl_exec($curl));
     curl_close($curl);
     if (isset($headers['X-Pingback']) && !empty($headers['X-Pingback'])) {
         $this->pingback_url = $headers['X-Pingback'];
     } else {
         if (preg_match(self::REGEXP_PINGBACK_LINK, file_get_contents($target), $match)) {
             $this->pingback_url = $match[1];
         } else {
             return $this->xmlrpc_fault(self::RESPONSE_FAULT_TARGET_INVALID);
         }
     }
     $content = file_get_contents($source);
     if ($content !== false) {
         $doc = new \DOMDocument();
         @$doc->loadHTML($content);
         foreach ($doc->getElementsByTagName('a') as $link) {
             if ($link->getAttribute('href') == $target) {
                 break;
             }
         }
     } else {
         return $this->xmlrpc_fault(self::RESPONSE_FAULT_SOURCE_LINK);
     }
     return xmlrpc_encode([$this->responses[self::RESPONSE_SUCCESS]]);
     //musí odkazovat na post id
     //pokud v databázi neexistuje záznam o pingback, pak přistoupit na vzdálenou stránku
     //parsování titulku ze vzdálené stránky
 }
開發者ID:krausv,項目名稱:www.zeminem.cz,代碼行數:40,代碼來源:Xmlrpc.php

示例6: validateUrl

 /**
  * Is control's value valid URL?
  * @return bool
  */
 public static function validateUrl(IControl $control)
 {
     if (Validators::isUrl($value = $control->getValue())) {
         return TRUE;
     } elseif (Validators::isUrl($value = "http://{$value}")) {
         $control->setValue($value);
         return TRUE;
     }
     return FALSE;
 }
開發者ID:rostenkowski,項目名稱:nette,代碼行數:14,代碼來源:Validator.php

示例7: validateUrl

 /**
  * Validate URL
  * @param string $value
  * @param Rule $rule
  * @throws ValidationException
  */
 public static function validateUrl($value, Rule $rule)
 {
     if (!Validators::isUrl($value)) {
         throw ValidationException::createFromRule($rule, $value);
     }
 }
開發者ID:lucien144,項目名稱:Restful,代碼行數:12,代碼來源:Validator.php

示例8: validateUrl

 /**
  * URL validator: is control's value valid URL?
  * @param  TextBase
  * @return bool
  */
 public static function validateUrl(TextBase $control)
 {
     return Validators::isUrl($control->getValue()) || Validators::isUrl('http://' . $control->getValue());
 }
開發者ID:ppwalks33,項目名稱:cleansure,代碼行數:9,代碼來源:TextBase.php

示例9: presenter

 /**
  * @param $destination
  * @param array $args
  * @return BrowserSession|Nette\Application\Request
  */
 public function presenter($destination = NULL, $args = array())
 {
     if ($destination !== NULL) {
         if (preg_match('~^\\:?([a-z0-9_]+)(:[a-z0-9_]+)*\\:?$~i', $destination)) {
             $args = array(0 => '//' . ltrim($destination, '/')) + func_get_args();
             $url = new Nette\Http\UrlScript(call_user_func_array(array($this->linkGenerator, 'link'), $args));
         } elseif (Nette\Utils\Validators::isUrl($destination)) {
             $url = new Nette\Http\UrlScript($destination);
         } else {
             $url = clone $this->httpServerUrl;
             $url->setPath($destination);
         }
         $this->url((string) $url);
         return $this;
     }
     $appRequest = NULL;
     $currentUrl = new Nette\Http\UrlScript($this->url());
     parse_str($currentUrl->query, $query);
     $router = $this->serviceLocator->getByType('Nette\\Application\\IRouter');
     /** @var Nette\Application\IRouter[]|Nette\Application\IRouter $router */
     if (!class_exists('Kdyby\\Console\\CliRouter')) {
         $appRequest = $router->match(new Nette\Http\Request($currentUrl, $query, array(), array(), array(), array(), 'GET'));
     } else {
         foreach ($router as $route) {
             if ($route instanceof Kdyby\Console\CliRouter || $route instanceof Nette\Application\Routers\CliRouter) {
                 continue;
             }
             if ($appRequest = $route->match(new Nette\Http\Request($currentUrl, $query, array(), array(), array(), array(), 'GET'))) {
                 break;
             }
         }
     }
     return $appRequest;
 }
開發者ID:kdyby,項目名稱:selenium,代碼行數:39,代碼來源:BrowserSession.php

示例10: processLinkAnnotations

 /**
  * @param string $value
  * @return string
  */
 private function processLinkAnnotations($value)
 {
     list($url, $description) = Strings::split($value);
     if (Validators::isUrl($url)) {
         return $this->linkBuilder->build($url, $description ?: $url);
     }
     return null;
 }
開發者ID:apigen,項目名稱:apigen,代碼行數:12,代碼來源:UrlFilters.php

示例11: isUrl

 public function isUrl()
 {
     return Validators::isUrl($this->link) or preg_match('~^/[^/]~', $this->link) or $this->link[0] == '#';
 }
開發者ID:kollarovic,項目名稱:navigation,代碼行數:4,代碼來源:Item.php

示例12: filterUrl

 /**
  * URL string cleanup.
  * @param  string
  * @return string
  */
 public static function filterUrl($s)
 {
     return Validators::isUrl('http://' . $s) ? 'http://' . $s : $s;
 }
開發者ID:Johnik010,項目名稱:rezervace,代碼行數:9,代碼來源:TextBase.php

示例13: resolveLinks

 /**
  * Resolves links in documentation.
  *
  * @param string                    $text    Processed documentation text
  * @param \ApiGen\ReflectionElement $context Reflection object
  *
  * @return string
  */
 private function resolveLinks($text, ReflectionElement $context)
 {
     $that = $this;
     return preg_replace_callback('~{@(?:link|see)\\s+([^}]+)}~', function ($matches) use($context, $that) {
         // Texy already added <a> so it has to be stripped
         list($url, $description) = $that->split(strip_tags($matches[1]));
         if (Nette\Utils\Validators::isUrl($url)) {
             return $that->link($url, $description ?: $url);
         }
         return $that->resolveLink($matches[1], $context) ?: $matches[1];
     }, $text);
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:20,代碼來源:Template.php

示例14: setRedirectUri

 /**
  * Nastaví URL na kterou bude uživatel z Facebook.com přesměrován
  * Přijímá nette zápis odkazů (např.: Homepage:default) nebo absolutní URL
  * @param string $redirectUri
  * @throws \Nette\InvalidArgumentException
  * @return void
  */
 public function setRedirectUri($redirectUri)
 {
     /* @var $currentPresenter \Nette\Application\UI\Presenter */
     $currentPresenter = $this->application->getPresenter();
     $netteAbsoluteLinkPrexix = "//";
     try {
         if (\Nette\Utils\Strings::startsWith($redirectUri, "//")) {
             $netteAbsoluteLinkPrexix = "";
         }
         $absoluteUri = $currentPresenter->link($netteAbsoluteLinkPrexix . $redirectUri);
         if (\Nette\Utils\Strings::startsWith($absoluteUri, "error:")) {
             throw new \Nette\Application\UI\InvalidLinkException();
         }
     } catch (\Nette\Application\UI\InvalidLinkException $exc) {
         if (Validators::isUrl($redirectUri) === TRUE) {
             $absoluteUri = $redirectUri;
         } else {
             throw new Exceptions\InvalidRedirectUriException("Given \"" . $redirectUri . "\" is not valid absolute URL or nette link.");
         }
     }
     $this->redirectUri = $absoluteUri;
 }
開發者ID:illagrenan,項目名稱:nette-facebook-connect,代碼行數:29,代碼來源:FacebookConnect.php

示例15: getUrl

 /**
  * @return string
  */
 public function getUrl()
 {
     if ($this->isAutoUrl() && isset($this->request)) {
         $url = $this->request->url;
     } else {
         $url = $this->url;
     }
     if (Validators::isUrl($url)) {
         return $url;
     } else {
         trigger_error('Url "' . $url . '" is not valid url address.!', E_USER_WARNING);
     }
 }
開發者ID:f3l1x,項目名稱:nette-plugins,代碼行數:16,代碼來源:FbTools.php


注:本文中的Nette\Utils\Validators::isUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。