X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FService%2FExtractor.php;h=4c067d3afef985fa5226c0359bc81260c2eb7eec;hb=8c55a9e6c9a563c3a4b3b3d35581e1c67a8a8c04;hp=e4ec96f6d41f4156b00772b3c077fb467dc1924a;hpb=8af35ad932177e0363412a868afc128b406e3322;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Service/Extractor.php b/src/Wallabag/CoreBundle/Service/Extractor.php index e4ec96f6..4c067d3a 100644 --- a/src/Wallabag/CoreBundle/Service/Extractor.php +++ b/src/Wallabag/CoreBundle/Service/Extractor.php @@ -9,8 +9,8 @@ final class Extractor { public static function extract($url) { - $pageContent = Extractor::getPageContent(new Url(base64_encode($url))); - $title = $pageContent['rss']['channel']['item']['title'] ?: 'Untitled'; + $pageContent = self::getPageContent(new Url(base64_encode($url))); + $title = $pageContent['rss']['channel']['item']['title'] ?: parse_url($url, PHP_URL_HOST); $body = $pageContent['rss']['channel']['item']['description']; $content = new Content(); @@ -21,9 +21,10 @@ final class Extractor } /** - * Get the content for a given URL (by a call to FullTextFeed) + * Get the content for a given URL (by a call to FullTextFeed). + * + * @param Url $url * - * @param Url $url * @return mixed */ public static function getPageContent(Url $url) @@ -32,8 +33,8 @@ final class Extractor $REAL = array(); foreach ($GLOBALS as $key => $value) { if ($key != 'GLOBALS' && $key != '_SESSION' && $key != 'HTTP_SESSION_VARS') { - $GLOBALS[$key] = array(); - $REAL[$key] = $value; + $GLOBALS[$key] = array(); + $REAL[$key] = $value; } } // Saving and clearing session @@ -49,12 +50,12 @@ final class Extractor $scope = function () { extract(func_get_arg(1)); $_GET = $_REQUEST = array( - "url" => $url->getUrl(), - "max" => 5, - "links" => "preserve", - "exc" => "", - "format" => "json", - "submit" => "Create Feed", + 'url' => $url->getUrl(), + 'max' => 5, + 'links' => 'preserve', + 'exc' => '', + 'format' => 'json', + 'submit' => 'Create Feed', ); ob_start(); require func_get_arg(0); @@ -67,11 +68,11 @@ final class Extractor // Silence $scope function to avoid // issues with FTRSS when error_reporting is to high // FTRSS generates PHP warnings which break output - $json = @$scope(__DIR__."/../../../../vendor/wallabag/Fivefilters_Libraries/makefulltextfeed.php", array("url" => $url)); + $json = @$scope(__DIR__.'/../../../../vendor/wallabag/Fivefilters_Libraries/makefulltextfeed.php', array('url' => $url)); // Clearing and restoring context foreach ($GLOBALS as $key => $value) { - if ($key != "GLOBALS" && $key != "_SESSION") { + if ($key != 'GLOBALS' && $key != '_SESSION') { unset($GLOBALS[$key]); } }