本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}