Get HTML wrapper for an available page link.

@param  string  $url
@param  int  $page
@param  string|null  $rel
@return string
171314
protected function getAvailablePageWrapper($url, $page, $rel = null)
	{
		$rel = is_null($rel) ? '' : ' rel="'.$rel.'"';

		return '<li class="page-item"><a class="page-link" href="'.htmlentities($url).'"'.$rel.'>'.$page.'</a></li>';
	}
1115877
public function get($wrap = "",$retArr = false)
    {
        $curpage = intval(isset($_GET[$this->param]) ? $_GET[$this->param] : 1);
        $pages   = $this->getLink($this->url, $curpage);
        if ($wrap) {
            foreach ($pages as &$page) {
                $page = '<' . $wrap . '>' . $page . '</' . $wrap . '>';
            }
        }
        return $retArr ? $pages : implode('', $pages);
    }
174274
public function getText(Page $page = null)
    {
        if ($contents = $this->get('Contents')) {

            if ($contents instanceof ElementMissing) {
                return '';
			} elseif ($contents instanceof ElementNull) {
				return '';
            } elseif ($contents instanceof PDFObject) {
                $elements = $contents->getHeader()->getElements();

                if (is_numeric(key($elements))) {
                    $new_content = '';

                    foreach ($elements as $element) {
                        if ($element instanceof ElementXRef) {
                            $new_content .= $element->getObject()->getContent();
                        } else {
                            $new_content .= $element->getContent();
                        }
                    }

                    $header   = new Header(array(), $this->document);
                    $contents = new PDFObject($this->document, $header, $new_content);
                }
            } elseif ($contents instanceof ElementArray) {
                // Create a virtual global content.
                $new_content = '';

                foreach ($contents->getContent() as $content) {
                    $new_content .= $content->getContent() . "\n";
                }

                $header   = new Header(array(), $this->document);
                $contents = new PDFObject($this->document, $header, $new_content);
            }

            return $contents->getText($this);
        }

        return '';
    }
955615
public function getLink($page, $header = null)
    {
        $id = preg_replace('/[^a-z0-9\/]+/i', '', $page);
        $link = $this->getBaseUrl() . '/' . $id;

        if ($header !== null) {
            $link .= '#' . $this->createId($header);
        } else if ($id == 'index') {
            $link = $this->getBaseUrl();
        }

        return $link;
    }
878776
private function getSinglePage($html, $url)
    {
        $this->logger->info('Looking for site config files to see if single page link exists');
        $siteConfig = $this->configBuilder->buildFromUrl($url);

        // no single page found?
        if (empty($siteConfig->single_page_link)) {
            $this->logger->info('No "single_page_link" config found');

            return false;
        }

        // Build DOM tree from HTML
        $readability = new Readability($html, $url);
        $xpath = new \DOMXPath($readability->dom);

        // Loop through single_page_link xpath expressions
        $singlePageUrl = null;

        foreach ($siteConfig->single_page_link as $pattern) {
            // Do we have conditions?
            $condition = $siteConfig->getIfPageContainsCondition('single_page_link', $pattern);

            if ($condition) {
                $elems = $xpath->evaluate($condition, $readability->dom);

                // move on to next single_page_link XPath in case condition isn't met
                if (!($elems instanceof \DOMNodeList && $elems->length > 0)) {
                    continue;
                }
            }

            $elems = $xpath->evaluate($pattern, $readability->dom);

            if (\is_string($elems)) {
                $singlePageUrl = trim($elems);
                break;
            } elseif ($elems instanceof \DOMNodeList && $elems->length > 0) {
                foreach ($elems as $item) {
                    if ($item instanceof \DOMElement && $item->hasAttribute('href')) {
                        $singlePageUrl = $item->getAttribute('href');
                        break 2;
                    } elseif ($item instanceof \DOMAttr && $item->value) {
                        $singlePageUrl = $item->value;
                        break 2;
                    }
                }
            }
        }

        if (!$singlePageUrl) {
            $this->logger->info('No single page url found');

            return false;
        }

        // try to resolve against $url
        $singlePageUrl = $this->makeAbsoluteStr($url, $singlePageUrl);

        // check it's not what we have already!
        if (false !== $singlePageUrl && $singlePageUrl !== $url) {
            // it's not, so let's try to fetch it...
            $response = $this->httpClient->fetch($singlePageUrl, false, $siteConfig->http_header);

            if ($response['status'] < 300) {
                $this->logger->info('Single page content found with url', ['url' => $singlePageUrl]);

                return $response;
            }
        }

        $this->logger->info('No content found with url', ['url' => $singlePageUrl]);

        return false;
    }
374558
protected function _getPaginatedUrl($page)
    {
        $url = $this->_getSortUrl();

        if ($page > 1) {
            if (!isset($url['?'])) {
                $url['?'] = [];
            }
            $url['?']['p'] = $page;
        }

        return $url;
    }
783680
public function getPageLinkWrapper($url, $page, $rel = null)
    {
        $rel = is_null($rel) ? '' : ' rel="'.$rel.'"';
        $class = Config::get('pagination::scroll.infinite_more_link_class');

        return '<li><a class='.$class.' href="'.$url.'"'.$rel.'>'.$page.'</a></li>';
    }
785993
public static function linkUrl($pageId, $pageUrl)
    {
        if (self::$pages === null) {
            self::initPages();
        }

        if ($pageUrl) {
            if (strpos($pageUrl, 'http') === 0) {
                return Url::to($pageUrl);
            }

            return Url::to([$pageUrl]);
        }

        if (isset(self::$pages[$pageId]['link'])) {
            if (self::$pages[$pageId]['link']) {
                return Url::to(['/' . self::$pages[$pageId]['link']]);
            }
        }

        return Url::home();
    }
539745
public static Link getLinkByRel(Entity entity, String... rel) {
        if(entity == null) {
            throw new IllegalArgumentException("entity cannot be null.");
        }
        if(ArrayUtils.isEmpty(rel)) {
            throw new IllegalArgumentException("rel cannot be null or empty");
        }
        List<Link> links = entity.getLinks();
        if (links == null)
            return null;
        Link link = null;
        for (Link l : links) {
            if (ArrayUtils.isNotEmpty(l.getRel()) && ArrayUtils.toString(rel).equals(ArrayUtils.toString(l.getRel()))) {
                link = l;
                break;
            }
        }
        return link;
    }
639996
public function show($version, $page = null)
    {
        $documentation = $this->documentationRepository->get($version, $page);

        if (Gate::has('viewLarecipe')) {
            $this->authorize('viewLarecipe', $documentation);
        }

        if ($this->documentationRepository->isNotPublishedVersion($version)) {
            return redirect()->route(
                'larecipe.show',
                [
                    'version' => config('larecipe.versions.default'),
                    'page' => config('larecipe.docs.landing')
                ]
            );
        }

        return response()->view('larecipe::docs', [
            'title'          => $documentation->title,
            'index'          => $documentation->index,
            'content'        => $documentation->content,
            'currentVersion' => $version,
            'versions'       => $documentation->publishedVersions,
            'currentSection' => $documentation->currentSection,
            'canonical'      => $documentation->canonical,
        ], $documentation->statusCode);
    }
408816
def get_link(self, rel):
        
        if rel in self.links:
            return self.links[rel]
        raise ResourceNotFound('Resource requested: %r is not available '
            'on this element.' % rel)
987979
private function _build_uri($page) {

        // if page propagation method is through SEO friendly URLs
        if ($this->_properties['method'] == 'url') {

            // see if the current page is already set in the URL
            if (preg_match('/\b' . $this->_properties['variable_name'] . '([0-9]+)\b/i', $this->_properties['base_url']) > 0) {

                // build string
                $url = str_replace('//', '/', preg_replace(

                    // replace the currently existing value
                    '/\b' . $this->_properties['variable_name'] . '([0-9]+)\b/i',

                    // if on the first page, remove it in order to avoid duplicate content
                    ($page == 1 ? '' : $this->_properties['variable_name'] . $page),

                    $this->_properties['base_url']

                ));

            // if the current page is not yet in the URL, set it, unless we're on the first page
            // case in which we don't set it in order to avoid duplicate content
            } else $url = rtrim($this->_properties['base_url'], '/') . '/' . ($this->_properties['variable_name'] . $page);

            // handle trailing slash according to preferences
            $url = rtrim($url, '/') . ($this->_properties['trailing_slash'] ? '/' : '');

            // if values in the query string - other than those set through base_url() - are not to be preserved
            // preserve only those set initially
            if (!$this->_properties['preserve_query_string']) $query = implode('&', $this->_properties['base_url_query']);

            // otherwise, get the current query string
            else $query = $_SERVER['QUERY_STRING'];

            // return the built string also appending the query string, if any
            return $url . ($query != '' ? '?' . $query : '');

        // if page propagation is to be done through GET
        } else {

            // if values in the query string - other than those set through base_url() - are not to be preserved
            // preserve only those set initially
            if (!$this->_properties['preserve_query_string']) $query = $this->_properties['base_url_query'];

            // otherwise, get the current query string, if any, and transform it to an array
            else parse_str($_SERVER['QUERY_STRING'], $query);

            // if we are avoiding duplicate content and if not the first/last page (depending on whether the pagination links are shown in natural or reversed order)
            if (!$this->_properties['avoid_duplicate_content'] || ($page != ($this->_properties['reverse'] ? $this->_properties['total_pages'] : 1)))

                // add/update the page number
                $query[$this->_properties['variable_name']] = $page;

            // if we are avoiding duplicate content, don't use the "page" variable on the first/last page
            elseif ($this->_properties['avoid_duplicate_content'] && $page == ($this->_properties['reverse'] ? $this->_properties['total_pages'] : 1))

                unset($query[$this->_properties['variable_name']]);

            // make sure the returned HTML is W3C compliant
            return htmlspecialchars(html_entity_decode($this->_properties['base_url']) . (!empty($query) ? '?' . urldecode(http_build_query($query)) : ''));

        }

    }
210925
protected function getSHDWrapper($url)
    {
        $content = $this->fetchSerpContent($url);
        // sanity check
        if (GenericValidator::invalidContent($content, self::DEFAULT_MAX_FILE_SIZE))
            return false;
        // create the wrapper
        $dom = new SimpleHtmlDom(null, self::SHD_USE_INCLUDE_PATH,
                                 self::SHD_FORCE_TAGS_CLOSED,
                                 $this->getCharset(), self::SHD_STRIP_RN,
                                 self::SHD_DEFAULT_BR_TEXT,
                                 self::SHD_DEFAULT_SPAN_TEXT);
        // load the fetched content in the wrapper
        $dom->load($content, self::SHD_LOWERCASE, self::SHD_STRIP_RN);
        return $dom;
    }
141616
public function getPageUrl(Page $page)
    {
        return $this->config['base_url'].'/'.
            ($page->getSubFolder() === null ? '' : $page->getSubFolder().'/').
            $this->getPagePublishFilename($page);
    }
768572
protected function _addPageNrParam($url, $currentPage, $languageId = null)
    {
        if (\OxidEsales\Eshop\Core\Registry::getUtils()->seoIsActive() && ($category = $this->getActiveCategory())) {
            if ($currentPage) {
                // only if page number > 0
                $url = $category->getBaseSeoLink($languageId, $currentPage);
            }
        } else {
            $url = parent::_addPageNrParam($url, $currentPage, $languageId);
        }

        return $url;
    }
763000
public function findOneByUrlJoinLangJoinUrl(string $url) : ?Page
    {
        $page = PageQuery::create()
            ->joinWithPageUrl()
            ->leftJoinWithSocial()
            ->leftJoinWithPrimary()
            ->usePageUrlQuery()
                ->joinWithLang()
                ->filterByUrl($url)->limit(1)
            ->endUse()
            ->findOne();

        return $page;
    }
1094570
public function links($relType, $urn = null)
    {
        $rawLinks = [];
        if (!empty($this->links->$relType)) {
            $rawLinks = $this->links->$relType;
        }
        $links = new CollectionDocJsonLinks($rawLinks, $this->_auth);

        // optionally filter by urn
        if ($urn) {
            return $links->rels([$urn]);
        } else {
            return $links;
        }
    }