aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/makefulltextfeedHelpers.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/3rdparty/makefulltextfeedHelpers.php')
-rwxr-xr-xinc/3rdparty/makefulltextfeedHelpers.php83
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}
37spl_autoload_register('autoload'); 36spl_autoload_register('autoload');
38require dirname(__FILE__).'/libraries/simplepie/autoloader.php';
39
40 37
41class DummySingleItemFeed { 38class 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
71function get_excerpt($text, $num_words=55, $more=null) { 68function 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
101function url_allowed($url) { 98function 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
381function get_base_url($dom) { 378function 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}