Crawls the given HTML string for OpenGraph data.

@param   string  $html           HTML string, usually whole content of crawled web resource.
@param   string  $fallbackUrl    URL to use when fallback mode is enabled.

@return  ObjectBase
496196
public function loadHtml($html, $fallbackUrl = null)
    {
        // Extract all data that can be found
        $page = $this->extractOpenGraphData($html);

        // Use the user's URL as fallback
        if ($this->useFallbackMode && $page->url === null) {
            $page->url = $fallbackUrl;
        }

        // Return result
        return $page;
    }
305375
protected function setFallbackURL()
    {
        $this->setLocalPSLName($this->url);
        if (null === $this->url) {
            $this->url = file_exists(__DIR__ . $this->localPSL) ? $this->localPSL : $this->sourceURL;
        }
    }
660011
static function linkUrls($html)
    {
        return preg_replace_callback(self::URLS_REGEXP, function($matches) {
            // Is URL already linked?
            if (preg_match('/<a\s/i', $matches[1])) return $matches[0];
            
            $url = ($matches[2] == "www." ? "http://www." : $matches[2]) . $matches[3];
            return 
                $matches[1] . 
                '<a href="' . Html::escape($url) . '">' . Html::escape(Html::humanUrl($url)) . '</a>' . 
                $matches[4];
        }, $html);
    }
898278
public static function getBacklinksTotal($url = false)
    {
        $url   = parent::getUrl($url);
        $query = urlencode("link:{$url}");

        return self::getSearchResultsTotal($query);
    }
1183307
public static function get_html( array $mf, $propname, $fallback = null ) {
		if ( ! empty( $mf['properties'][ $propname ] ) && is_array( $mf['properties'][ $propname ] ) ) {
			return self::to_html( current( $mf['properties'][ $propname ] ) ); }
		return $fallback;
	}
421831
protected static function processLinkUrl($linkUrl)
    {
        static $absRefPrefix = null;
        static $absRefPrefixLength = 0;
        $ret = $linkUrl;
        $tsfe = self::getTsfe();


        // Fetch abs ref prefix if available/set
        if ($absRefPrefix === null) {
            if (!empty($tsfe->tmpl->setup['config.']['absRefPrefix'])) {
                $absRefPrefix       = $tsfe->tmpl->setup['config.']['absRefPrefix'];
                $absRefPrefixLength = strlen($absRefPrefix);
            } else {
                $absRefPrefix = false;
            }
        }

        $absRefPrefixLengthTmp = $absRefPrefixLength; //makes sure we do not write back to static variable

        // remove abs ref prefix
        if ($absRefPrefix !== false && strpos($ret, $absRefPrefix) === 0) {
            $parsedUrl = parse_url($linkUrl);
            if ($parsedUrl !== false
                && $parsedUrl['path'] === $absRefPrefix
                && substr($absRefPrefix, -1) === '/'  //sanity check: must end with /
            ) {
                //for root pages: treat '/' like a suffix, not like a prefix => don't remove last '/' in that case!
                //This ensures that for an absRefPrefix = '/abc/' or '/' we return '/' instead of empty strings
                $absRefPrefixLengthTmp--;
            }

            $ret = substr($ret, $absRefPrefixLengthTmp);
        }

        return $ret;
    }
791171
public function back($actions='insert|update|do_delete', $url="")
    {

        if ($url == "") {
            if (count($this->links)) {
                $url = array_pop($this->links);
            } else {
                return $this;
            }
        } else {
            $base = str_replace(Request::path(),'',strtok(Request::fullUrl(),'?'));
            $match_url = str_replace($base, '/', strtok($url,'?'));
            if (Request::path()!= $match_url) {
                $url = Persistence::get($match_url);
            }
        }

        $this->back_on = explode("|", $actions);
        $this->back_url = $url;

        return $this;
    }
144807
public function getPreviousUrl(bool $fallBackToReferer = true) : string
    {
        if (!empty($this->previousUrl)) {
            return $this->previousUrl;
        }

        if ($fallBackToReferer) {
            return $this->headers->get('REFERER', '');
        }

        return '';
    }
1210607
public function html($html_string=null)
    {
        if ($html_string !== null) { // set html for all nodes
            foreach ($this as $node) {
                $node->get(0)->nodeValue = '';
                $node->append($html_string);
            }

            return $this;
        }
        // get html for first node
        return $this->getInnerHtml();
    }
427826
public function discoverFromHtml($html)
    {
        $links = $this->findLinks($html);

        if ( ! $link = reset($links)) {
            return;
        }

        $type = null;

        switch($link['type']) {
        case 'application/json+oembed':
            $type = Provider::TYPE_JSON;
            break;
        case 'text/xml+oembed':
            $type = Provider::TYPE_XML;
            break;
        }

        $url = $link['href'];
        $endpoint = $this->getEndpointUrl($url);

        return new Provider($endpoint, $type);
    }
761835
public function setHtmlBody(string $html, string $basePath = null)
    {
        if ($basePath) {
            $cids = [];
            $matches = Strings::matchAll(
                $html,
                '#
					(<img[^<>]*\s src\s*=\s*
					|<body[^<>]*\s background\s*=\s*
					|<[^<>]+\s style\s*=\s* ["\'][^"\'>]+[:\s] url\(
					|<style[^>]*>[^<]+ [:\s] url\()
					(["\']?)(?![a-z]+:|[/\\#])([^"\'>)\s]+)
					|\[\[ ([\w()+./@~-]+) \]\]
				#ix',
                PREG_OFFSET_CAPTURE
            );
            foreach (\array_reverse($matches) as $m) {
                $file = \rtrim($basePath, '/\\') . '/' . (isset($m[4]) ? $m[4][0] : \urldecode($m[3][0]));
                if (!isset($cids[$file])) {
                    $cids[$file] = \substr($this->addEmbeddedFile($file)->getHeader('Content-ID'), 1, -1);
                }
                $html = \substr_replace($html,
                    "{$m[1][0]}{$m[2][0]}cid:{$cids[$file]}",
                    $m[0][1], \strlen($m[0][0])
                );
            }
        }

        if ($this->getSubject() == null) { // intentionally ==
            $html = Strings::replace($html, '#<title>(.+?)</title>#is', function (array $m): void {
                $this->setSubject(\html_entity_decode($m[1], ENT_QUOTES, 'UTF-8'));
            });
        }

        $this->htmlBody = \ltrim(\str_replace("\r", '', $html), "\n");

        if ($html !== '' && $this->getBody() === '') {
            $this->setBody($this->buildText($html));
        }

        return $this;
    }
1273241
public function getHtmlTop($beginA, $endA, $beginB, $endB, $limit)
    {
        $top = $this->getTop($beginA, $endA, $beginB, $endB, $limit);

        $html = '<table border="0">';
        $html .= '<tbody>';


        $line = '
            <tr>
                <td align="center">%d</td>
                <td class="center" width="344">
		            <a href="%s">%s</a>
	            </td>
	            <td width="82" align="right">%s posts</td>
	            <td width="40" align="center">
	             %s
	            </td>
	        </tr>';

        $bottom1 = '
            <tr>
                <td align="right">%d - %d</td>
                <td width="334"></td>
                <td width="82" align="right">%d posts</td>
                <td></td>
            </tr>';

        $bottom2 = '  
            <tr>
                <td align="right">Total</td>
                <td width="334"></td>
                <td width="82" align="right">%d posts</td>
                <td></td>
            </tr>';
        foreach ($top['playerList'] as $row) {
            $html .= sprintf($line, $row['rank'], 'URL', $row['idPlayer'], $row['nb'], $this->diff($row, count($top['playerList'])));
        }

        if ($top['nbTotalPost'] > $top['nbPostFromList']) {
            $html .= sprintf($bottom1, count($top['playerList']) + 1, $top['nbGame'], $top['nbTotalPost'] - $top['nbPostFromList']);
        }
        $html .= sprintf($bottom2, $top['nbTotalPost']);
        $html .= '</tbody>';
        $html .= '</table>';

        return $html;
    }
218713
public function parseHtml($html)
    {
        return Parser::table($html, '#DBGrid', [
            'status', 'name', 'credit', 'examination', 'property', 'teacher', 'code', 'week',
            ['hour', function (Crawler $crawler) {
                return $crawler->attr("title") ?: $crawler->text();
            }],
            ['place', function (Crawler $crawler) {
                return $crawler->text() == ";" ? '' : ($crawler->attr("title") ?: $crawler->text());
            }],
            'campus',
            ['class', function (Crawler $crawler) {
                return $crawler->attr("title") ?: $crawler->text();
            }],
        ], 12, 1, 'text');
    }
672721
public function Save($callBackURL = null)
	{
		if ($this->request == null)
		{
			throw new GrabzItException("No parameters have been set.", GrabzItException::PARAMETER_MISSING_PARAMETERS);
		}

		$sig = $this->encode($this->request->getOptions()->_getSignatureString($this->applicationSecret, $callBackURL, $this->request->getTargetUrl()));
		
		$obj = $this->_take($sig, $callBackURL);
		
		if ($obj == null)
		{
			$obj = $this->_take($sig, $callBackURL);
		}
		
		if ($obj == null)
		{
			throw new GrabzItException("An unknown network error occurred, please try calling this method again.", GrabzItException::NETWORK_GENERAL_ERROR);
		}

		if ($obj->ID != null)
		{
			return $obj->ID->__toString();
		}
		
		return $obj->ID;
	}
412010
private function url()
    {
        if (isset($this->_options[self::ENTRY_BASEURL])) {
            return $this->_options[self::ENTRY_BASEURL];
        }

        // this is the fallback
        return Urls::URL_CURSOR;
    }
303975
public function getReferrerUrl($fallBackToReferer = true)
    {
        if (!empty($this->refererUrl)) {
            return $this->refererUrl;
        }

        if ($fallBackToReferer) {
            return $this->header->get('REFERER', '');
        }

        return '';
    }
683710
public function discover($url, array $args = [])
    {
        $url = trim($url);
        $html = HtmlExplorer::fromWeb($url, $this->http);

        $typePattern = '#^('.join('|', array_keys($this->formats)).')\+oembed$#';

        $nodes = $html->findTags('link');
        foreach ($nodes as $node) {
            $rel = strtolower(trim($node->getAttribute('rel')));
            $type = strtolower(trim($node->getAttribute('type')));

            if (in_array($rel, ['alternate', 'alternative']) && preg_match($typePattern, $type, $matches)) {
                $url = trim($node->getAttribute('href'));
                $result = $this->queryProvider($url, null, null, $args);
                if ($result->success) {
                    $parser = $this->formats[$matches[1]];
                    return $parser($result->data);
                }
            }
        }

        return false;
    }