]> git.mxchange.org Git - friendica.git/blobdiff - src/ParseUrl.php
Merge pull request #4103 from Rudloff/feature/profile_colors
[friendica.git] / src / ParseUrl.php
index 919a5ad9f9bed0b69d722c9c5beba2b01d212613..9e46281ec91a73ec6d159be72dc84068c91aaeb1 100644 (file)
@@ -6,14 +6,15 @@
 namespace Friendica;
 
 use Friendica\Core\Config;
-use Friendica\Util\Xml;
+use Friendica\Object\Image;
+use Friendica\Util\XML;
 
 use dba;
-use DomXPath;
+use DOMXPath;
 use DOMDocument;
 
+require_once 'include/dba.php';
 require_once "include/network.php";
-require_once "include/Photo.php";
 require_once "include/oembed.php";
 
 /**
@@ -24,10 +25,10 @@ class ParseUrl
        /**
         * @brief Search for chached embeddable data of an url otherwise fetch it
         *
-        * @param type $url         The url of the page which should be scraped
-        * @param type $no_guessing If true the parse doens't search for
+        * @param string $url         The url of the page which should be scraped
+        * @param bool $no_guessing If true the parse doens't search for
         *                          preview pictures
-        * @param type $do_oembed   The false option is used by the function fetch_oembed()
+        * @param bool $do_oembed   The false option is used by the function fetch_oembed()
         *                          to avoid endless loops
         *
         * @return array which contains needed data for embedding
@@ -88,12 +89,12 @@ class ParseUrl
         * like \<title\>Awesome Title\</title\> or
         * \<meta name="description" content="An awesome description"\>
         *
-        * @param type $url         The url of the page which should be scraped
-        * @param type $no_guessing If true the parse doens't search for
+        * @param string $url         The url of the page which should be scraped
+        * @param bool $no_guessing If true the parse doens't search for
         *                          preview pictures
-        * @param type $do_oembed   The false option is used by the function fetch_oembed()
+        * @param bool $do_oembed   The false option is used by the function fetch_oembed()
         *                          to avoid endless loops
-        * @param type $count       Internal counter to avoid endless loops
+        * @param int $count       Internal counter to avoid endless loops
         *
         * @return array which contains needed data for embedding
         *    string 'url' => The url of the parsed page
@@ -203,19 +204,19 @@ class ParseUrl
                $doc = new DOMDocument();
                @$doc->loadHTML($body);
 
-               Xml::deleteNode($doc, "style");
-               Xml::deleteNode($doc, "script");
-               Xml::deleteNode($doc, "option");
-               Xml::deleteNode($doc, "h1");
-               Xml::deleteNode($doc, "h2");
-               Xml::deleteNode($doc, "h3");
-               Xml::deleteNode($doc, "h4");
-               Xml::deleteNode($doc, "h5");
-               Xml::deleteNode($doc, "h6");
-               Xml::deleteNode($doc, "ol");
-               Xml::deleteNode($doc, "ul");
+               XML::deleteNode($doc, "style");
+               XML::deleteNode($doc, "script");
+               XML::deleteNode($doc, "option");
+               XML::deleteNode($doc, "h1");
+               XML::deleteNode($doc, "h2");
+               XML::deleteNode($doc, "h3");
+               XML::deleteNode($doc, "h4");
+               XML::deleteNode($doc, "h5");
+               XML::deleteNode($doc, "h6");
+               XML::deleteNode($doc, "ol");
+               XML::deleteNode($doc, "ul");
 
-               $xpath = new DomXPath($doc);
+               $xpath = new DOMXPath($doc);
 
                $list = $xpath->query("//meta[@content]");
                foreach ($list as $node) {
@@ -353,7 +354,7 @@ class ParseUrl
                                }
 
                                $src = self::completeUrl($attr["src"], $url);
-                               $photodata = get_photo_info($src);
+                               $photodata = Image::getInfoFromURL($src);
 
                                if (($photodata) && ($photodata[0] > 150) && ($photodata[1] > 150)) {
                                        if ($photodata[0] > 300) {
@@ -374,7 +375,7 @@ class ParseUrl
 
                        unset($siteinfo["image"]);
 
-                       $photodata = get_photo_info($src);
+                       $photodata = Image::getInfoFromURL($src);
 
                        if (($photodata) && ($photodata[0] > 10) && ($photodata[1] > 10)) {
                                $siteinfo["images"][] = array("src" => $src,
@@ -454,6 +455,7 @@ class ParseUrl
         *
         * @param string $tag The pure tag name
         * @param int    $k   Counter for internal use
+        * @return void
         */
        private static function arrAddHashes(&$tag, $k)
        {