diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-19 14:48:03 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-19 14:48:03 +0100 |
commit | 820d81aa614f0a6c7e52b049c39ef167c9debd51 (patch) | |
tree | 9cbee4942426148d9d846634fee967fc585c54bd /inc/3rdparty/makefulltextfeedHelpers.php | |
parent | 3329f1bf3d855849ee2b3f8333be542d53b62fb8 (diff) | |
download | wallabag-820d81aa614f0a6c7e52b049c39ef167c9debd51.tar.gz wallabag-820d81aa614f0a6c7e52b049c39ef167c9debd51.tar.zst wallabag-820d81aa614f0a6c7e52b049c39ef167c9debd51.zip |
simplepie via composer
Diffstat (limited to 'inc/3rdparty/makefulltextfeedHelpers.php')
-rwxr-xr-x | inc/3rdparty/makefulltextfeedHelpers.php | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/inc/3rdparty/makefulltextfeedHelpers.php b/inc/3rdparty/makefulltextfeedHelpers.php index ac872ab8..453856dd 100755 --- a/inc/3rdparty/makefulltextfeedHelpers.php +++ b/inc/3rdparty/makefulltextfeedHelpers.php | |||
@@ -12,7 +12,6 @@ function autoload($class_name) { | |||
12 | // Include ContentExtractor and Readability for identifying and extracting content from URLs | 12 | // Include ContentExtractor and Readability for identifying and extracting content from URLs |
13 | 'ContentExtractor' => 'content-extractor/ContentExtractor.php', | 13 | 'ContentExtractor' => 'content-extractor/ContentExtractor.php', |
14 | 'SiteConfig' => 'content-extractor/SiteConfig.php', | 14 | 'SiteConfig' => 'content-extractor/SiteConfig.php', |
15 | 'Readability' => 'readability/Readability.php', | ||
16 | // Include Humble HTTP Agent to allow parallel requests and response caching | 15 | // Include Humble HTTP Agent to allow parallel requests and response caching |
17 | 'HumbleHttpAgent' => 'humble-http-agent/HumbleHttpAgent.php', | 16 | 'HumbleHttpAgent' => 'humble-http-agent/HumbleHttpAgent.php', |
18 | 'SimplePie_HumbleHttpAgent' => 'humble-http-agent/SimplePie_HumbleHttpAgent.php', | 17 | 'SimplePie_HumbleHttpAgent' => 'humble-http-agent/SimplePie_HumbleHttpAgent.php', |
@@ -35,8 +34,6 @@ function autoload($class_name) { | |||
35 | } | 34 | } |
36 | } | 35 | } |
37 | spl_autoload_register('autoload'); | 36 | spl_autoload_register('autoload'); |
38 | require dirname(__FILE__).'/libraries/simplepie/autoloader.php'; | ||
39 | |||
40 | 37 | ||
41 | class DummySingleItemFeed { | 38 | class DummySingleItemFeed { |
42 | public $item; | 39 | public $item; |
@@ -66,38 +63,38 @@ class DummySingleItem { | |||
66 | // HELPER FUNCTIONS | 63 | // HELPER FUNCTIONS |
67 | /////////////////////////////// | 64 | /////////////////////////////// |
68 | 65 | ||
69 | // Adapted from WordPress | 66 | // Adapted from WordPress |
70 | // http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/formatting.php#L2173 | 67 | // http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/formatting.php#L2173 |
71 | function get_excerpt($text, $num_words=55, $more=null) { | 68 | function get_excerpt($text, $num_words=55, $more=null) { |
72 | if (null === $more) $more = '…'; | 69 | if (null === $more) $more = '…'; |
73 | $text = strip_tags($text); | 70 | $text = strip_tags($text); |
74 | //TODO: Check if word count is based on single characters (East Asian characters) | 71 | //TODO: Check if word count is based on single characters (East Asian characters) |
75 | /* | 72 | /* |
76 | if (1==2) { | 73 | if (1==2) { |
77 | $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); | 74 | $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
78 | preg_match_all('/./u', $text, $words_array); | 75 | preg_match_all('/./u', $text, $words_array); |
79 | $words_array = array_slice($words_array[0], 0, $num_words + 1); | 76 | $words_array = array_slice($words_array[0], 0, $num_words + 1); |
80 | $sep = ''; | 77 | $sep = ''; |
81 | } else { | 78 | } else { |
82 | $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); | 79 | $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
83 | $sep = ' '; | 80 | $sep = ' '; |
84 | } | 81 | } |
85 | */ | 82 | */ |
86 | $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); | 83 | $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
87 | $sep = ' '; | 84 | $sep = ' '; |
88 | if (count($words_array) > $num_words) { | 85 | if (count($words_array) > $num_words) { |
89 | array_pop($words_array); | 86 | array_pop($words_array); |
90 | $text = implode($sep, $words_array); | 87 | $text = implode($sep, $words_array); |
91 | $text = $text.$more; | 88 | $text = $text.$more; |
92 | } else { | 89 | } else { |
93 | $text = implode($sep, $words_array); | 90 | $text = implode($sep, $words_array); |
94 | } | 91 | } |
95 | // trim whitespace at beginning or end of string | 92 | // trim whitespace at beginning or end of string |
96 | // See: http://stackoverflow.com/questions/4166896/trim-unicode-whitespace-in-php-5-2 | 93 | // See: http://stackoverflow.com/questions/4166896/trim-unicode-whitespace-in-php-5-2 |
97 | $text = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $text); | 94 | $text = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $text); |
98 | return $text; | 95 | return $text; |
99 | } | 96 | } |
100 | 97 | ||
101 | function url_allowed($url) { | 98 | function url_allowed($url) { |
102 | global $options; | 99 | global $options; |
103 | if (!empty($options->allowed_urls)) { | 100 | if (!empty($options->allowed_urls)) { |
@@ -378,12 +375,12 @@ function debug($msg) { | |||
378 | } | 375 | } |
379 | } | 376 | } |
380 | 377 | ||
381 | function get_base_url($dom) { | 378 | function get_base_url($dom) { |
382 | $xpath = new DOMXPath($dom); | 379 | $xpath = new DOMXPath($dom); |
383 | $base_url = @$xpath->evaluate('string(//head/base/@href)', $dom); | 380 | $base_url = @$xpath->evaluate('string(//head/base/@href)', $dom); |
384 | if ($base_url !== '') { | 381 | if ($base_url !== '') { |
385 | return $base_url; | 382 | return $base_url; |
386 | } else { | 383 | } else { |
387 | return false; | 384 | return false; |
388 | } | 385 | } |
389 | } | 386 | } |