本文整理匯總了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;
}
示例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);
});
}
示例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;
}
示例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)];
}
}
}
}
示例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
}
示例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;
}
示例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);
}
}
示例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());
}
示例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;
}
示例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;
}
示例11: isUrl
public function isUrl()
{
return Validators::isUrl($this->link) or preg_match('~^/[^/]~', $this->link) or $this->link[0] == '#';
}
示例12: filterUrl
/**
* URL string cleanup.
* @param string
* @return string
*/
public static function filterUrl($s)
{
return Validators::isUrl('http://' . $s) ? 'http://' . $s : $s;
}
示例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);
}
示例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;
}
示例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);
}
}