forked from wallabag/wallabag
simplepie via composer
This commit is contained in:
83
inc/3rdparty/makefulltextfeedHelpers.php
vendored
83
inc/3rdparty/makefulltextfeedHelpers.php
vendored
@ -12,7 +12,6 @@ function autoload($class_name) {
|
||||
// Include ContentExtractor and Readability for identifying and extracting content from URLs
|
||||
'ContentExtractor' => 'content-extractor/ContentExtractor.php',
|
||||
'SiteConfig' => 'content-extractor/SiteConfig.php',
|
||||
'Readability' => 'readability/Readability.php',
|
||||
// Include Humble HTTP Agent to allow parallel requests and response caching
|
||||
'HumbleHttpAgent' => 'humble-http-agent/HumbleHttpAgent.php',
|
||||
'SimplePie_HumbleHttpAgent' => 'humble-http-agent/SimplePie_HumbleHttpAgent.php',
|
||||
@ -35,8 +34,6 @@ function autoload($class_name) {
|
||||
}
|
||||
}
|
||||
spl_autoload_register('autoload');
|
||||
require dirname(__FILE__).'/libraries/simplepie/autoloader.php';
|
||||
|
||||
|
||||
class DummySingleItemFeed {
|
||||
public $item;
|
||||
@ -66,38 +63,38 @@ class DummySingleItem {
|
||||
// HELPER FUNCTIONS
|
||||
///////////////////////////////
|
||||
|
||||
// Adapted from WordPress
|
||||
// http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/formatting.php#L2173
|
||||
function get_excerpt($text, $num_words=55, $more=null) {
|
||||
if (null === $more) $more = '…';
|
||||
$text = strip_tags($text);
|
||||
//TODO: Check if word count is based on single characters (East Asian characters)
|
||||
/*
|
||||
if (1==2) {
|
||||
$text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' ');
|
||||
preg_match_all('/./u', $text, $words_array);
|
||||
$words_array = array_slice($words_array[0], 0, $num_words + 1);
|
||||
$sep = '';
|
||||
} else {
|
||||
$words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY);
|
||||
$sep = ' ';
|
||||
}
|
||||
*/
|
||||
$words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY);
|
||||
$sep = ' ';
|
||||
if (count($words_array) > $num_words) {
|
||||
array_pop($words_array);
|
||||
$text = implode($sep, $words_array);
|
||||
$text = $text.$more;
|
||||
} else {
|
||||
$text = implode($sep, $words_array);
|
||||
}
|
||||
// trim whitespace at beginning or end of string
|
||||
// See: http://stackoverflow.com/questions/4166896/trim-unicode-whitespace-in-php-5-2
|
||||
$text = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
// Adapted from WordPress
|
||||
// http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/formatting.php#L2173
|
||||
function get_excerpt($text, $num_words=55, $more=null) {
|
||||
if (null === $more) $more = '…';
|
||||
$text = strip_tags($text);
|
||||
//TODO: Check if word count is based on single characters (East Asian characters)
|
||||
/*
|
||||
if (1==2) {
|
||||
$text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' ');
|
||||
preg_match_all('/./u', $text, $words_array);
|
||||
$words_array = array_slice($words_array[0], 0, $num_words + 1);
|
||||
$sep = '';
|
||||
} else {
|
||||
$words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY);
|
||||
$sep = ' ';
|
||||
}
|
||||
*/
|
||||
$words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY);
|
||||
$sep = ' ';
|
||||
if (count($words_array) > $num_words) {
|
||||
array_pop($words_array);
|
||||
$text = implode($sep, $words_array);
|
||||
$text = $text.$more;
|
||||
} else {
|
||||
$text = implode($sep, $words_array);
|
||||
}
|
||||
// trim whitespace at beginning or end of string
|
||||
// See: http://stackoverflow.com/questions/4166896/trim-unicode-whitespace-in-php-5-2
|
||||
$text = preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u', '', $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function url_allowed($url) {
|
||||
global $options;
|
||||
if (!empty($options->allowed_urls)) {
|
||||
@ -378,12 +375,12 @@ function debug($msg) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_base_url($dom) {
|
||||
$xpath = new DOMXPath($dom);
|
||||
$base_url = @$xpath->evaluate('string(//head/base/@href)', $dom);
|
||||
if ($base_url !== '') {
|
||||
return $base_url;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
function get_base_url($dom) {
|
||||
$xpath = new DOMXPath($dom);
|
||||
$base_url = @$xpath->evaluate('string(//head/base/@href)', $dom);
|
||||
if ($base_url !== '') {
|
||||
return $base_url;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user