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


PHP Uri::setFragment方法代码示例

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


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

示例1: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $uri->setHost('www.vimeo.com');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setQuery('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:22,代码来源:Vimeo.php

示例2: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $query = $uri->getQueryAsArray();
     if (empty($query['v'])) {
         return false;
     }
     $uri->setQuery(array('v' => $query['v']));
     $uri->setHost('www.youtube.com');
     $uri->setPath('/watch');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:27,代码来源:Youtube.php

示例3: extractReview

 /**
  * Extract a single review into a review instance
  * @param  DomElement $node
  * @return Review
  */
 public function extractReview(DomElement $node)
 {
     $review = new Review();
     $doc = new DomDocument();
     $html = $node->ownerDocument->saveHtml($node);
     $doc->loadHtml('<?xml encoding="utf-8" ?>' . $html);
     $xpath = new DOMXpath($doc);
     /**
      * Author Username
      * // member_info/ * /username/span
      */
     $nodes = $xpath->query("//div[contains(@class, 'member_info')]/*/div[contains(@class, 'username')]/span");
     if ($nodes->length === 1) {
         $review->setAuthor(trim($nodes->item(0)->nodeValue));
     }
     /**
      * Author Location
      */
     $nodes = $xpath->query("//div[contains(@class, 'member_info')]/div[contains(@class, 'location')]");
     if ($nodes->length === 1) {
         $review->setAuthorLocation(trim($nodes->item(0)->nodeValue));
     }
     /**
      * Review Permalink
      */
     $nodes = $xpath->query("//div[contains(@class, 'quote')]/a");
     if ($nodes->length === 1) {
         // URL linked to from the title is an absolute path without host/scheme
         // Also, URL contains a fragment that should be removed
         $path = trim($nodes->item(0)->getAttribute('href'));
         $url = new Uri($this->getOptions()->getUrl());
         $new = sprintf('%s://%s/%s', $url->getScheme(), $url->getHost(), ltrim($path, '/'));
         $url = new Uri($new);
         $url->setFragment(null);
         $review->setUrl((string) $url);
     }
     /**
      * Title Quote
      */
     $nodes = $xpath->query("//div[contains(@class, 'quote')]/a/span[contains(@class, 'noQuotes')]");
     if ($nodes->length === 1) {
         $review->setTitle(trim($nodes->item(0)->nodeValue));
     }
     /**
      * Rating as an alt tag in an image
      */
     $nodes = $xpath->query("//div[contains(@class, 'rating')]/span[contains(@class, 'rate')]/img");
     if ($nodes->length === 1) {
         $img = $nodes->item(0);
         $alt = $img->getAttribute('alt');
         if (preg_match('/([0-9\\.]+)\\s[\\w]+\\s([0-9\\.]+)/', $alt, $match)) {
             $review->setStarRating((double) $match[1]);
             $review->setMaxStarRating((double) $match[2]);
         }
     }
     /**
      * Rating Date
      */
     $nodes = $xpath->query("//div[contains(@class, 'rating')]/span[contains(@class, 'ratingDate')]");
     if ($nodes->length === 1) {
         $span = $nodes->item(0);
         if ($span->hasAttribute('title')) {
             $dateString = $span->getAttribute('title');
             $date = DateTime::createFromFormat('d F Y', $dateString);
             if (false !== $date) {
                 $review->setDate($date);
             }
         } else {
             if (preg_match('/([0-9]{1,2}\\s[\\w]+\\s[0-9]{4})/i', trim($span->nodeValue), $match)) {
                 $date = DateTime::createFromFormat('d F Y', $match[1]);
                 if (false !== $date) {
                     $review->setDate($date);
                 }
             }
         }
     }
     /**
      * Review Excerpt
      */
     $nodes = $xpath->query("//div[contains(@class, 'entry')]/p[contains(@class, 'partial_entry')]");
     if ($nodes->length === 1) {
         // Use first child node->nodeValue to skip links for 'more...'
         $review->setExcerpt(trim($nodes->item(0)->childNodes->item(0)->nodeValue));
     }
     return $review;
 }
开发者ID:netglue,项目名称:zf2-tripadvisor-module,代码行数:91,代码来源:Scraper.php

示例4: clearUri

 /**
  * Get clear uri.
  *
  * @static
  *
  * @param \Zend\Uri\Uri $uri
  *
  * @return boolean|\Zend\Uri\Uri False if uri is not auhorized
  */
 public static function clearUri(Uri $uri)
 {
     if ($uri->getScheme() !== 'http') {
         return false;
     }
     $paths = explode('/', $uri->getPath());
     $pathsCount = count($paths);
     if ($pathsCount < 2) {
         return false;
     }
     $type = $paths[$pathsCount - 2];
     if (!in_array($type, self::$typesAuthorized)) {
         return false;
     }
     $uri->setHost('www.deezer.com');
     // clear
     $uri->setPort(0);
     $uri->setUserInfo('');
     $uri->setQuery('');
     $uri->setFragment('');
     return $uri;
 }
开发者ID:pokap,项目名称:media,代码行数:31,代码来源:Deezer.php

示例5: setFragment

 /**
  * Set the URI fragment part
  *
  * @param  string $fragment
  * @return \Zend\Uri\Uri
  * @throws Exception\InvalidUriPartException If the schema definition
  * does not have this part
  */
 public function setFragment($fragment)
 {
     $this->uri->setFragment($fragment);
     return $this;
 }
开发者ID:sunnyct,项目名称:silexcmf-core,代码行数:13,代码来源:Uri.php


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