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


PHP Validator::url方法代码示例

本文整理汇总了PHP中Respect\Validation\Validator::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::url方法的具体用法?PHP Validator::url怎么用?PHP Validator::url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Respect\Validation\Validator的用法示例。


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

示例1: __construct

 /**
  * @param string $username BulkSMS username
  * @param string $password BulkSMS password
  * @param string $baseUrl  Optional - defaults to "http://bulksms.vsms.net:5567"
  * @param cURL   $curl     Optional - a new instance will be constructed if null is passed.
  */
 public function __construct($username, $password, $baseUrl = "http://bulksms.vsms.net:5567", $curl = null)
 {
     v::url()->setName("Base Bulksms URL")->check($baseUrl);
     $this->baseUrl = $baseUrl;
     $this->username = $username;
     $this->password = $password;
     $this->curl = $curl ?: new cURL();
 }
开发者ID:roarkmccolgan,项目名称:php-bulk-sms,代码行数:14,代码来源:BulkSmsService.php

示例2: display

 function display()
 {
     $validate_url = Validator::url();
     $url = rawurldecode(urldecode($this->get('url')));
     if ($validate_url->validate($url)) {
         $this->view->assign('url', $url);
     }
 }
开发者ID:christine-ho-dev,项目名称:movim,代码行数:8,代码来源:Share.php

示例3: validateForm

 private function validateForm($data)
 {
     $l = Movim\i18n\Locale::start();
     if (Validator::in(array_keys($l->getList()))->validate($data['language']) && Validator::in(array('show', 'hide'))->validate($data['roster']) && ($data['cssurl'] == '' || Validator::url()->validate($data['cssurl']))) {
         return true;
     }
     return false;
 }
开发者ID:christine-ho-dev,项目名称:movim,代码行数:8,代码来源:Config.php

示例4: validateConfig

 private function validateConfig(array $config)
 {
     if (empty($config)) {
         throw new \InvalidArgumentException('Empty config is not allowed');
     }
     $validator = v::arrayVal()->notEmpty()->key('search', v::arrayVal()->notEmpty()->key('uri', v::url()->notEmpty())->key('key', v::alnum()->notEmpty()))->key('data', v::arrayVal()->notEmpty()->key('uri', v::url()->notEmpty())->key('key', v::alnum()->notEmpty()));
     $validator->assert($config);
 }
开发者ID:dafiti,项目名称:datajet-client,代码行数:8,代码来源:Product.php

示例5: setData

 /**
  * (non-PHPdoc)
  * 
  * @see \Solvire\API\Serializers\DataFields\DataField::setData()
  */
 public function setData($data)
 {
     if (!is_string($data) || !v::url()->validate($data)) {
         throw new \RuntimeException('URLField data must be a string representation of a URL ' . $data);
     }
     $this->data = $data;
     return $this;
 }
开发者ID:hectorbenitez,项目名称:php-hypermedia-api,代码行数:13,代码来源:URLField.php

示例6: __construct

 /**
  * @param string $username BulkSMS username
  * @param string $password BulkSMS password
  * @param        $baseUrl
  * @param cURL   $curl
  */
 public function __construct($username, $password, $baseUrl, $routingGroup, cURL $curl = null)
 {
     v::url()->setName("Base Bulksms URL")->check($baseUrl);
     $this->baseUrl = $baseUrl;
     $this->username = $username;
     $this->password = $password;
     $this->curl = $curl ?: new cURL();
     $this->routingGroup = $routingGroup;
 }
开发者ID:pauls6832,项目名称:php-bulk-sms,代码行数:15,代码来源:AbstractSender.php

示例7: isWordPress

 public function isWordPress()
 {
     $isUrl = v::url()->notEmpty()->validate($this->target);
     if ($isUrl) {
         $baseUrlWordPress = $this->getBaseUrlWordPressCrawler();
         if ($baseUrlWordPress) {
             return true;
         }
         return false;
     }
 }
开发者ID:aszone,项目名称:hacking,代码行数:11,代码来源:WordPress.php

示例8: __construct

 public function __construct(array $options)
 {
     $options = ['baseUri' => Arr::get($options, 'baseUri', $this->baseUri), 'timeout' => Arr::get($options, 'timeout', $this->timeout), 'proxy' => Arr::get($options, 'proxy', $this->proxy), 'auth' => Arr::get($options, 'auth', $this->auth), 'logger' => Arr::get($options, 'logger')];
     try {
         V::arrayVal()->key('baseUri', V::url()->notEmpty())->key('timeout', V::floatVal()->min(0))->key('proxy', V::optional(V::url()))->key('auth', V::arrayVal()->key('user', V::stringType())->key('pass', V::stringType()))->key('logger', V::instance('\\Psr\\Log\\LoggerInterface'))->assert($options);
     } catch (\InvalidArgumentException $e) {
         $errors = array_filter($e->findMessages(['baseUri' => 'Required correct baseUri', 'timeout' => 'Required correct timeout', 'proxy' => 'Required correct proxy', 'auth' => 'Required correct authuser', 'logger' => 'Required a logger instance of psr\\log']));
         $errmsg = array_shift($errors);
         throw new Exception($errmsg);
     }
     $this->baseUri = $options['baseUri'];
     $this->timeout = $options['timeout'];
     $this->proxy = $options['proxy'];
     $this->auth = $options['auth'];
     $this->logger = $options['logger'];
 }
开发者ID:qinyuguang,项目名称:libyaf,代码行数:16,代码来源:Conf.php

示例9: add

 public static function add(array $data)
 {
     extract($data);
     if (empty($title) or empty($desc) or empty($link)) {
         throw new \InvalidArgumentException("Você precisa enviar todos os campos");
     }
     if (!v::string()->length(3, 100)->validate($title)) {
         throw new \InvalidArgumentException("Título inválido");
     }
     if (!v::string()->length(5, 500)->validate($desc)) {
         throw new \InvalidArgumentException("Descrição inválida");
     }
     if (!v::string()->length(5, 270)->validate($link)) {
         throw new \InvalidArgumentException("Link inválido");
     }
     if (!v::url()->validate($link)) {
         throw new \InvalidArgumentException("Isso não é um link");
     }
     return true;
 }
开发者ID:CakePHPBrasil,项目名称:cakephpbrasil.com.br,代码行数:20,代码来源:Validation.php

示例10: getAttachements

 public function getAttachements()
 {
     $attachements = null;
     $this->picture = null;
     if (isset($this->links)) {
         $attachements = array('pictures' => array(), 'files' => array(), 'links' => array());
         $links = unserialize($this->links);
         foreach ($links as $l) {
             if (isset($l['type']) && $this->typeIsPicture($l['type'])) {
                 if ($this->picture == null) {
                     $this->picture = $l['href'];
                 }
                 array_push($attachements['pictures'], $l);
             } elseif ((isset($l['type']) && $this->typeIsLink($l['type']) || in_array($l['rel'], array('related', 'alternate'))) && Validator::url()->validate($l['href'])) {
                 if ($this->youtube == null && preg_match('%(?:youtube(?:-nocookie)?\\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\\.be/)([^"&?/ ]{11})%i', $l['href'], $match)) {
                     $this->youtube = $match[1];
                 }
                 array_push($attachements['links'], array('href' => $l['href'], 'url' => parse_url($l['href'])));
             } elseif (isset($l['rel']) && $l['rel'] == 'enclosure') {
                 array_push($attachements['files'], $l);
             }
         }
     }
     if (empty($attachements['pictures'])) {
         unset($attachements['pictures']);
     }
     if (empty($attachements['files'])) {
         unset($attachements['files']);
     }
     if (empty($attachements['links'])) {
         unset($attachements['links']);
     }
     return $attachements;
 }
开发者ID:Hywan,项目名称:movim,代码行数:34,代码来源:Postn.php

示例11: url

 /**
  * 是否为正确的URL
  *
  * @param  string $value URL
  * @return bool
  */
 public static function url($value)
 {
     return Validator::url()->validate($value);
 }
开发者ID:tourze,项目名称:base,代码行数:10,代码来源:Valid.php

示例12: getAttachments

 public function getAttachments()
 {
     $attachments = null;
     $this->openlink = null;
     if (isset($this->links)) {
         $links = unserialize($this->links);
         $attachments = ['pictures' => [], 'files' => [], 'links' => []];
         foreach ($links as $l) {
             // If the href is not a valid URL we skip
             if (!Validator::url()->validate($l['href'])) {
                 continue;
             }
             // Prepare the switch
             $rel = isset($l['rel']) ? $l['rel'] : null;
             switch ($rel) {
                 case 'enclosure':
                     if ($this->typeIsPicture($l['type'])) {
                         array_push($attachments['pictures'], $l);
                     } elseif ($l['type'] != 'picture') {
                         array_push($attachments['files'], $l);
                     }
                     break;
                 case 'related':
                     if (preg_match('%(?:youtube(?:-nocookie)?\\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\\.be/)([^"&?/ ]{11})%i', $l['href'], $match)) {
                         $this->youtube = $match[1];
                     }
                     array_push($attachments['links'], ['href' => $l['href'], 'url' => parse_url($l['href']), 'rel' => 'related']);
                     break;
                 case 'alternate':
                 default:
                     $this->openlink = $l['href'];
                     if (!$this->isMicroblog()) {
                         array_push($attachments['links'], ['href' => $l['href'], 'url' => parse_url($l['href']), 'rel' => 'alternate']);
                     }
                     break;
             }
         }
     }
     if (empty($attachments['pictures'])) {
         unset($attachments['pictures']);
     }
     if (empty($attachments['files'])) {
         unset($attachments['files']);
     }
     if (empty($attachments['links'])) {
         unset($attachments['links']);
     }
     return $attachments;
 }
开发者ID:Anon215,项目名称:movim,代码行数:49,代码来源:Postn.php

示例13: ajaxVcardSubmit

 function ajaxVcardSubmit($vcard)
 {
     # Format it ISO 8601:
     if ($vcard->year->value != -1 && $vcard->month->value != -1 && $vcard->day->value != -1) {
         $vcard->date->value = $vcard->year->value . '-' . $vcard->month->value . '-' . $vcard->day->value;
     }
     unset($vcard->year->value);
     unset($vcard->month->value);
     unset($vcard->day->value);
     $cd = new \Modl\ContactDAO();
     $c = $cd->get($this->user->getLogin());
     if ($c == null) {
         $c = new \Modl\Contact();
     }
     $c->jid = $this->user->getLogin();
     if (isset($vcard->date->value)) {
         $c->date = $vcard->date->value;
     }
     if (Validator::string()->length(0, 40)->validate($vcard->name->value)) {
         $c->name = $vcard->name->value;
     }
     if (Validator::string()->length(0, 40)->validate($vcard->fn->value)) {
         $c->fn = $vcard->fn->value;
     }
     if (Validator::url()->validate($vcard->url->value)) {
         $c->url = $vcard->url->value;
     }
     if (Validator::in(array_keys(getGender()))->validate($vcard->gender->value)) {
         $c->gender = $vcard->gender->value;
     }
     if (Validator::in(array_keys(getMarital()))->validate($vcard->marital->value)) {
         $c->marital = $vcard->marital->value;
     }
     $c->adrlocality = $vcard->locality->value;
     $c->adrcountry = $vcard->country->value;
     if (Validator::email()->validate($vcard->email->value)) {
         $c->email = $vcard->email->value;
     }
     $c->twitter = $vcard->twitter->value;
     $c->skype = $vcard->skype->value;
     $c->yahoo = $vcard->yahoo->value;
     if (Validator::string()->validate($vcard->desc->value)) {
         $c->description = trim($vcard->desc->value);
     }
     $cd = new \Modl\ContactDAO();
     $cd->set($c);
     $r = new Set();
     $r->setData($c)->request();
     $r = new Moxl\Xec\Action\Vcard\Set();
     $r->setData($vcard)->request();
 }
开发者ID:vijo,项目名称:movim,代码行数:51,代码来源:Vcard4.php

示例14: load

 function load()
 {
     if ($this->_view == 'node') {
         $this->_from = $this->get('s');
         $this->_node = $this->get('n');
         if (!$this->validateServerNode($this->_from, $this->_node)) {
             return;
         }
         $pd = new \Modl\ItemDAO();
         $this->_item = $pd->getItem($this->_from, $this->_node);
         $this->_mode = 'group';
         $this->url = Route::urlize('node', array($this->_from, $this->_node));
     } elseif ($this->_view == 'tag' && $this->validateTag($this->get('t'))) {
         $this->_mode = 'tag';
         $this->_tag = $this->get('t');
         $this->title = '#' . $this->_tag;
     } else {
         $this->_from = $this->get('f');
         $cd = new \modl\ContactDAO();
         $this->_contact = $cd->get($this->_from, true);
         if (filter_var($this->_from, FILTER_VALIDATE_EMAIL)) {
             $this->_node = 'urn:xmpp:microblog:0';
         } else {
             return;
         }
         $this->_mode = 'blog';
         $this->url = Route::urlize('blog', $this->_from);
     }
     $pd = new \modl\PostnDAO();
     if ($this->_id = $this->get('i')) {
         if (Validator::intType()->between(0, 100)->validate($this->_id)) {
             if (isset($this->_tag)) {
                 $this->_messages = $pd->getPublicTag($this->get('t'), $this->_id * $this->_paging, $this->_paging + 1);
             } else {
                 $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, $this->_id * $this->_paging, $this->_paging + 1);
             }
             $this->_page = $this->_id + 1;
         } elseif (Validator::stringType()->length(5, 100)->validate($this->_id)) {
             $this->_messages = $pd->getPublicItem($this->_from, $this->_node, $this->_id);
             if (is_object($this->_messages[0])) {
                 $this->title = $this->_messages[0]->title;
                 $description = stripTags($this->_messages[0]->contentcleaned);
                 if (!empty($description)) {
                     $this->description = $description;
                 }
                 $attachements = $this->_messages[0]->getAttachements();
                 if ($attachements && array_key_exists('pictures', $attachements)) {
                     $this->image = urldecode($attachements['pictures'][0]['href']);
                 }
             }
             if ($this->_view == 'node') {
                 $this->url = Route::urlize('node', array($this->_from, $this->_node, $this->_id));
             } else {
                 $this->url = Route::urlize('blog', array($this->_from, $this->_id));
             }
         }
     } else {
         $this->_page = 1;
         if (isset($this->_tag)) {
             $this->_messages = $pd->getPublicTag($this->get('t'), 0, $this->_paging + 1);
         } else {
             $this->_messages = $pd->getNodeUnfiltered($this->_from, $this->_node, 0, $this->_paging + 1);
         }
     }
     if (count($this->_messages) == $this->_paging + 1) {
         array_pop($this->_messages);
     }
     $this->user = new User($this->_from);
     $cssurl = $this->user->getDumpedConfig('cssurl');
     if (isset($cssurl) && $cssurl != '' && Validator::url()->validate($cssurl)) {
         $this->addrawcss($cssurl);
     }
 }
开发者ID:christine-ho-dev,项目名称:movim,代码行数:73,代码来源:Blog.php

示例15: checkPicture

 public function checkPicture()
 {
     $body = trim($this->body);
     if (Validator::url()->notEmpty()->validate($body) && isSmallPicture($body)) {
         $this->picture = $body;
     }
 }
开发者ID:Anon215,项目名称:movim,代码行数:7,代码来源:Message.php


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