From 95530f62513a82c385d9378b4a59da57d74092d9 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 5 Nov 2014 11:30:27 +0100 Subject: update picofeed, add max size setting, fix #642 --- 3rdparty/autoload.php | 2 +- 3rdparty/composer/autoload_real.php | 10 +- 3rdparty/composer/installed.json | 12 +- 3rdparty/fguillot/picofeed/.gitignore | 3 +- 3rdparty/fguillot/picofeed/.travis.yml | 4 +- 3rdparty/fguillot/picofeed/README.markdown | 9 +- .../fguillot/picofeed/docs/feed-parsing.markdown | 269 ++- .../fguillot/picofeed/docs/installation.markdown | 71 +- 3rdparty/fguillot/picofeed/docs/tests.markdown | 14 + 3rdparty/fguillot/picofeed/lib/PicoFeed/Client.php | 559 ------- .../picofeed/lib/PicoFeed/Client/Client.php | 540 ++++++ .../lib/PicoFeed/Client/ClientException.php | 16 + .../fguillot/picofeed/lib/PicoFeed/Client/Curl.php | 324 ++++ .../picofeed/lib/PicoFeed/Client/Favicon.php | 170 ++ .../picofeed/lib/PicoFeed/Client/Grabber.php | 403 +++++ .../Client/InvalidCertificateException.php | 13 + .../lib/PicoFeed/Client/InvalidUrlException.php | 13 + .../lib/PicoFeed/Client/MaxRedirectException.php | 13 + .../lib/PicoFeed/Client/MaxSizeException.php | 13 + .../picofeed/lib/PicoFeed/Client/Stream.php | 170 ++ .../lib/PicoFeed/Client/TimeoutException.php | 13 + .../fguillot/picofeed/lib/PicoFeed/Client/Url.php | 254 +++ .../picofeed/lib/PicoFeed/Clients/Curl.php | 290 ---- .../picofeed/lib/PicoFeed/Clients/Stream.php | 167 -- 3rdparty/fguillot/picofeed/lib/PicoFeed/Config.php | 90 - .../picofeed/lib/PicoFeed/Config/Config.php | 90 + .../fguillot/picofeed/lib/PicoFeed/Encoding.php | 171 -- .../picofeed/lib/PicoFeed/Encoding/Encoding.php | 171 ++ 3rdparty/fguillot/picofeed/lib/PicoFeed/Export.php | 132 -- .../fguillot/picofeed/lib/PicoFeed/Favicon.php | 163 -- 3rdparty/fguillot/picofeed/lib/PicoFeed/Feed.php | 188 --- 3rdparty/fguillot/picofeed/lib/PicoFeed/Filter.php | 141 -- .../picofeed/lib/PicoFeed/Filter/Attribute.php | 27 +- .../picofeed/lib/PicoFeed/Filter/Filter.php | 170 ++ .../fguillot/picofeed/lib/PicoFeed/Filter/Html.php | 15 +- .../fguillot/picofeed/lib/PicoFeed/Filter/Tag.php | 2 +- .../fguillot/picofeed/lib/PicoFeed/Grabber.php | 398 ----- 3rdparty/fguillot/picofeed/lib/PicoFeed/Import.php | 169 -- 3rdparty/fguillot/picofeed/lib/PicoFeed/Item.php | 202 --- .../fguillot/picofeed/lib/PicoFeed/Logging.php | 83 - .../picofeed/lib/PicoFeed/Logging/Logging.php | 95 ++ 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser.php | 423 ----- .../fguillot/picofeed/lib/PicoFeed/Parser/Atom.php | 281 ++++ .../fguillot/picofeed/lib/PicoFeed/Parser/Feed.php | 188 +++ .../fguillot/picofeed/lib/PicoFeed/Parser/Item.php | 202 +++ .../lib/PicoFeed/Parser/MalformedXmlException.php | 13 + .../picofeed/lib/PicoFeed/Parser/Parser.php | 610 +++++++ .../lib/PicoFeed/Parser/ParserException.php | 16 + .../picofeed/lib/PicoFeed/Parser/Rss10.php | 77 + .../picofeed/lib/PicoFeed/Parser/Rss20.php | 291 ++++ .../picofeed/lib/PicoFeed/Parser/Rss91.php | 13 + .../picofeed/lib/PicoFeed/Parser/Rss92.php | 13 + .../picofeed/lib/PicoFeed/Parser/XmlParser.php | 232 +++ .../picofeed/lib/PicoFeed/Parsers/Atom.php | 292 ---- .../picofeed/lib/PicoFeed/Parsers/Rss10.php | 88 - .../picofeed/lib/PicoFeed/Parsers/Rss20.php | 300 ---- .../picofeed/lib/PicoFeed/Parsers/Rss91.php | 17 - .../picofeed/lib/PicoFeed/Parsers/Rss92.php | 17 - .../fguillot/picofeed/lib/PicoFeed/PicoFeed.php | 25 - .../picofeed/lib/PicoFeed/PicoFeedException.php | 15 + 3rdparty/fguillot/picofeed/lib/PicoFeed/Reader.php | 310 ---- .../picofeed/lib/PicoFeed/Reader/Reader.php | 232 +++ .../lib/PicoFeed/Reader/ReaderException.php | 16 + .../Reader/SubscriptionNotFoundException.php | 13 + .../Reader/UnsupportedFeedFormatException.php | 13 + .../picofeed/lib/PicoFeed/Serialization/Export.php | 132 ++ .../picofeed/lib/PicoFeed/Serialization/Import.php | 172 ++ .../picofeed/lib/PicoFeed/Syndication/Atom.php | 220 +++ .../picofeed/lib/PicoFeed/Syndication/Rss20.php | 207 +++ .../picofeed/lib/PicoFeed/Syndication/Writer.php | 97 ++ 3rdparty/fguillot/picofeed/lib/PicoFeed/Url.php | 254 --- 3rdparty/fguillot/picofeed/lib/PicoFeed/Writer.php | 97 -- .../picofeed/lib/PicoFeed/Writers/Atom.php | 221 --- .../picofeed/lib/PicoFeed/Writers/Rss20.php | 208 --- .../fguillot/picofeed/lib/PicoFeed/XmlParser.php | 232 --- 3rdparty/fguillot/picofeed/phpunit.xml | 2 +- 3rdparty/fguillot/picofeed/picofeed | 6 +- .../fguillot/picofeed/tests/AtomParserTest.php | 240 --- .../fguillot/picofeed/tests/AtomWriterTest.php | 90 - .../picofeed/tests/AttributeFilterTest.php | 139 -- .../fguillot/picofeed/tests/Client/ClientTest.php | 83 + .../fguillot/picofeed/tests/Client/CurlTest.php | 53 + .../fguillot/picofeed/tests/Client/FaviconTest.php | 143 ++ .../fguillot/picofeed/tests/Client/GrabberTest.php | 60 + .../fguillot/picofeed/tests/Client/StreamTest.php | 63 + .../fguillot/picofeed/tests/Client/UrlTest.php | 220 +++ 3rdparty/fguillot/picofeed/tests/ClientTest.php | 85 - 3rdparty/fguillot/picofeed/tests/CurlTest.php | 64 - 3rdparty/fguillot/picofeed/tests/ExportTest.php | 70 - 3rdparty/fguillot/picofeed/tests/FaviconTest.php | 144 -- .../picofeed/tests/Filter/AttributeFilterTest.php | 140 ++ .../fguillot/picofeed/tests/Filter/FilterTest.php | 88 + .../picofeed/tests/Filter/HtmlFilterTest.php | 168 ++ .../picofeed/tests/Filter/TagFilterTest.php | 33 + 3rdparty/fguillot/picofeed/tests/FilterTest.php | 87 - 3rdparty/fguillot/picofeed/tests/GrabberTest.php | 64 - .../fguillot/picofeed/tests/HtmlFilterTest.php | 168 -- 3rdparty/fguillot/picofeed/tests/ImportTest.php | 61 - .../picofeed/tests/Parser/AtomParserTest.php | 178 ++ .../fguillot/picofeed/tests/Parser/ParserTest.php | 75 + .../picofeed/tests/Parser/Rss10ParserTest.php | 112 ++ .../picofeed/tests/Parser/Rss20ParserTest.php | 252 +++ .../picofeed/tests/Parser/Rss91ParserTest.php | 30 + .../picofeed/tests/Parser/Rss92ParserTest.php | 28 + .../picofeed/tests/Parser/XmlParserTest.php | 105 ++ 3rdparty/fguillot/picofeed/tests/ParserTest.php | 99 -- .../fguillot/picofeed/tests/Reader/ReaderTest.php | 157 ++ 3rdparty/fguillot/picofeed/tests/ReaderTest.php | 108 -- .../fguillot/picofeed/tests/Rss10ParserTest.php | 131 -- .../fguillot/picofeed/tests/Rss20ParserTest.php | 334 ---- .../fguillot/picofeed/tests/Rss20WriterTest.php | 85 - .../fguillot/picofeed/tests/Rss91ParserTest.php | 30 - .../fguillot/picofeed/tests/Rss92ParserTest.php | 29 - .../picofeed/tests/Serialization/ExportTest.php | 70 + .../picofeed/tests/Serialization/ImportTest.php | 61 + 3rdparty/fguillot/picofeed/tests/StreamTest.php | 85 - .../picofeed/tests/Syndication/AtomWriterTest.php | 90 + .../picofeed/tests/Syndication/Rss20WriterTest.php | 85 + 3rdparty/fguillot/picofeed/tests/TagFilterTest.php | 33 - 3rdparty/fguillot/picofeed/tests/UrlTest.php | 220 --- 3rdparty/fguillot/picofeed/tests/XmlParserTest.php | 103 -- .../fguillot/picofeed/tests/fixtures/groovehq.xml | 1767 ++++++++++++++++++++ .../picofeed/tests/fixtures/womensweardaily.xml | 63 + CHANGELOG.md | 1 + README.md | 1 + appinfo/application.php | 12 +- composer.json | 2 +- composer.lock | 12 +- config/config.php | 17 + controller/admincontroller.php | 6 +- fetcher/feedfetcher.php | 81 +- js/admin/Admin.js | 5 + service/feedservice.php | 8 +- templates/admin.php | 17 + .../articleenhancer/XPathArticleEnhancerTest.php | 2 +- tests/unit/config/ConfigTest.php | 4 + tests/unit/controller/AdminControllerTest.php | 13 +- tests/unit/fetcher/FeedFetcherTest.php | 111 +- tests/unit/service/FeedServiceTest.php | 2 - utility/picofeedclientfactory.php | 4 +- utility/picofeedfaviconfactory.php | 4 +- utility/picofeedreaderfactory.php | 38 - 142 files changed, 10044 insertions(+), 8093 deletions(-) create mode 100644 3rdparty/fguillot/picofeed/docs/tests.markdown delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Client.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Curl.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Favicon.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/InvalidCertificateException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/InvalidUrlException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/MaxRedirectException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/MaxSizeException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Stream.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/TimeoutException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Url.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Clients/Curl.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Clients/Stream.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Config.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Config/Config.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Encoding.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Export.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Favicon.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Feed.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Filter.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Filter/Filter.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Grabber.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Import.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Item.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Logging.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Logging/Logging.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Item.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/MalformedXmlException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Parser.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/ParserException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Rss10.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Rss91.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/Rss92.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parsers/Atom.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parsers/Rss10.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parsers/Rss20.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parsers/Rss91.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Parsers/Rss92.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/PicoFeed.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/PicoFeedException.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Reader.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Reader/Reader.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Reader/ReaderException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Reader/SubscriptionNotFoundException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Reader/UnsupportedFeedFormatException.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Serialization/Export.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Serialization/Import.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Syndication/Atom.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Syndication/Rss20.php create mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Syndication/Writer.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Url.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Writer.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Writers/Atom.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/Writers/Rss20.php delete mode 100644 3rdparty/fguillot/picofeed/lib/PicoFeed/XmlParser.php delete mode 100644 3rdparty/fguillot/picofeed/tests/AtomParserTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/AtomWriterTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/AttributeFilterTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Client/ClientTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Client/CurlTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Client/FaviconTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Client/GrabberTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Client/StreamTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Client/UrlTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/ClientTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/CurlTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/ExportTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/FaviconTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Filter/AttributeFilterTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Filter/FilterTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Filter/HtmlFilterTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Filter/TagFilterTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/FilterTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/GrabberTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/HtmlFilterTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/ImportTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Parser/AtomParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Parser/ParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Parser/Rss10ParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Parser/Rss20ParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Parser/Rss91ParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Parser/Rss92ParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Parser/XmlParserTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/ParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Reader/ReaderTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/ReaderTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/Rss10ParserTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/Rss20ParserTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/Rss20WriterTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/Rss91ParserTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/Rss92ParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Serialization/ExportTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Serialization/ImportTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/StreamTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Syndication/AtomWriterTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/Syndication/Rss20WriterTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/TagFilterTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/UrlTest.php delete mode 100644 3rdparty/fguillot/picofeed/tests/XmlParserTest.php create mode 100644 3rdparty/fguillot/picofeed/tests/fixtures/groovehq.xml create mode 100644 3rdparty/fguillot/picofeed/tests/fixtures/womensweardaily.xml delete mode 100644 utility/picofeedreaderfactory.php diff --git a/3rdparty/autoload.php b/3rdparty/autoload.php index 120b16acc..3cd25b0d2 100644 --- a/3rdparty/autoload.php +++ b/3rdparty/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInit7bb1478f65d3f193519a3262170cb8bf::getLoader(); +return ComposerAutoloaderInit4750e3a2a6327c742e19653287d1e34f::getLoader(); diff --git a/3rdparty/composer/autoload_real.php b/3rdparty/composer/autoload_real.php index 1a9ed9123..16fe7ad69 100644 --- a/3rdparty/composer/autoload_real.php +++ b/3rdparty/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit7bb1478f65d3f193519a3262170cb8bf +class ComposerAutoloaderInit4750e3a2a6327c742e19653287d1e34f { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInit7bb1478f65d3f193519a3262170cb8bf return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit7bb1478f65d3f193519a3262170cb8bf', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit4750e3a2a6327c742e19653287d1e34f', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit7bb1478f65d3f193519a3262170cb8bf', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit4750e3a2a6327c742e19653287d1e34f', 'loadClassLoader')); $includePaths = require __DIR__ . '/include_paths.php'; array_push($includePaths, get_include_path()); @@ -46,14 +46,14 @@ class ComposerAutoloaderInit7bb1478f65d3f193519a3262170cb8bf $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - composerRequire7bb1478f65d3f193519a3262170cb8bf($file); + composerRequire4750e3a2a6327c742e19653287d1e34f($file); } return $loader; } } -function composerRequire7bb1478f65d3f193519a3262170cb8bf($file) +function composerRequire4750e3a2a6327c742e19653287d1e34f($file) { require $file; } diff --git a/3rdparty/composer/installed.json b/3rdparty/composer/installed.json index cc63486b6..f7a314210 100644 --- a/3rdparty/composer/installed.json +++ b/3rdparty/composer/installed.json @@ -114,23 +114,23 @@ }, { "name": "fguillot/picofeed", - "version": "dev-master", - "version_normalized": "9999999-dev", + "version": "dev-0.1.0-dev", + "version_normalized": "dev-0.1.0-dev", "source": { "type": "git", "url": "https://github.com/fguillot/picoFeed.git", - "reference": "dd5c122aea0a95ec2c932ee487a8fb4fd307cc6f" + "reference": "e7e32522b487256c3164eeece30203313b09456a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/dd5c122aea0a95ec2c932ee487a8fb4fd307cc6f", - "reference": "dd5c122aea0a95ec2c932ee487a8fb4fd307cc6f", + "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/e7e32522b487256c3164eeece30203313b09456a", + "reference": "e7e32522b487256c3164eeece30203313b09456a", "shasum": "" }, "require": { "php": ">=5.3.0" }, - "time": "2014-10-19 18:18:06", + "time": "2014-11-05 01:21:29", "type": "library", "installation-source": "dist", "autoload": { diff --git a/3rdparty/fguillot/picofeed/.gitignore b/3rdparty/fguillot/picofeed/.gitignore index 496ee2ca6..b0ef0680a 100644 --- a/3rdparty/fguillot/picofeed/.gitignore +++ b/3rdparty/fguillot/picofeed/.gitignore @@ -1 +1,2 @@ -.DS_Store \ No newline at end of file +.DS_Store +vendor/ \ No newline at end of file diff --git a/3rdparty/fguillot/picofeed/.travis.yml b/3rdparty/fguillot/picofeed/.travis.yml index 83334e8c4..0c3d0fe55 100644 --- a/3rdparty/fguillot/picofeed/.travis.yml +++ b/3rdparty/fguillot/picofeed/.travis.yml @@ -7,4 +7,6 @@ php: - "5.3" before_script: wget https://phar.phpunit.de/phpunit.phar -script: php phpunit.phar +script: + - composer dump-autoload + - php phpunit.phar diff --git a/3rdparty/fguillot/picofeed/README.markdown b/3rdparty/fguillot/picofeed/README.markdown index 99ef68237..8f01b4e8e 100644 --- a/3rdparty/fguillot/picofeed/README.markdown +++ b/3rdparty/fguillot/picofeed/README.markdown @@ -38,17 +38,20 @@ Authors ------- - Original author: [Frédéric Guillot](http://fredericguillot.com/) -- Contributors: See pull-requests, issues tracker and commit history +- Major Contributors: + - [Bernhard Posselt](https://github.com/Raydiation) + - [David Pennington](https://github.com/Xeoncross) Documentation ------------- - [Installation](docs/installation.markdown) -- [OPML file importation](docs/opml-import.markdown) -- [OPML file exportation](docs/opml-export.markdown) +- [Running unit tests](docs/tests.markdown) - [Feed parsing](docs/feed-parsing.markdown) - [Feed creation](docs/feed-creation.markdown) - [Favicon fetcher](docs/favicon.markdown) +- [OPML file importation](docs/opml-import.markdown) +- [OPML file exportation](docs/opml-export.markdown) - [Web scraping](docs/grabber.markdown) - [Debugging](docs/debugging.markdown) - [Configuration](docs/config.markdown) diff --git a/3rdparty/fguillot/picofeed/docs/feed-parsing.markdown b/3rdparty/fguillot/picofeed/docs/feed-parsing.markdown index 10f20d31a..22f84339b 100644 --- a/3rdparty/fguillot/picofeed/docs/feed-parsing.markdown +++ b/3rdparty/fguillot/picofeed/docs/feed-parsing.markdown @@ -1,205 +1,164 @@ Feed parsing ============ -Download and parse a feed -------------------------- - -Try this example from a command line script: +Parsing a subscription +---------------------- ```php -download('http://bbc.co.uk/news'); + $reader = new Reader; -$parser = $reader->getParser(); + // Return a resource + $resource = $reader->download('https://linuxfr.org/news.atom'); -if ($parser !== false) { + // Return the right parser instance according to the feed format + $parser = $reader->getParser( + $resource->getUrl(), + $resource->getContent(), + $resource->getEncoding() + ); + // Return a Feed object $feed = $parser->execute(); - if ($feed !== false) { - echo $feed; - } + // Print the feed properties with the magic method __toString() + echo $feed; +} +catch (PicoFeedException $e) { + // Do Something... } ``` -- The method `getParser()` return `false` when there is something wrong during the download or the feed detection -- The call `$parser->execute()` return `false` when there is a parsing error - -In your terminal you will got an output like that: - -``` -Feed::id = http://www.bbc.co.uk/news/#sa-ns_mchannel=rss&ns_source=PublicRSS20-sa -Feed::title = BBC News - Home -Feed::url = http://www.bbc.co.uk/news/#sa-ns_mchannel=rss&ns_source=PublicRSS20-sa -Feed::date = 1399934742 -Feed::language = en-gb -Feed::items = 84 items +- The Reader class is the entry point for feed reading +- The method `download()` fetch the remote content and return a resource, an instance of `PicoFeed\Client\Client` +- The method `getParser()` returns a Parser instance according to the feed format Atom, Rss 2.0... +- The parser itself returns a `Feed` object that contains feed and item properties + +Output: + +```bash +Feed::id = tag:linuxfr.org,2005:/news +Feed::title = LinuxFr.org : les dépêches +Feed::url = http://linuxfr.org/news +Feed::date = 1415138079 +Feed::language = en-US +Feed::description = +Feed::logo = +Feed::items = 15 items ---- -Item::id = e411a646 -Item::title = Nigeria rejects captive girls 'swap' -Item::url = http://www.bbc.co.uk/news/world-africa-27386285#sa-ns_mchannel=rss&ns_source=PublicRSS20-sa -Item::date = 1399933404 -Item::language = en-gb -Item::author = +Item::id = 38d8f48284fb03940cbb3aff9101089b81e44efb1281641bdd7c3e7e4bf3b0cd +Item::title = openSUSE 13.2 : nouvelle version du caméléon disponible ! +Item::url = http://linuxfr.org/news/opensuse-13-2-nouvelle-version-du-cameleon-disponible +Item::date = 1415122640 +Item::language = en-US +Item::author = Syvolc Item::enclosure_url = Item::enclosure_type = -Item::content =

Nigeria insists i... (152 bytes) +Item::content = 18307 bytes ---- -Item::id = 6c50fcf2 -Item::title = Woman tells of Harris 'assaults' -Item::url = http://www.bbc.co.uk/news/uk-27371573#sa-ns_mchannel=rss&ns_source=PublicRSS20-sa -Item::date = 1399908906 -Item::language = en-gb -Item::author = +Item::id = d0ebddc90bfc3f109f9be00a3bb0b4a770af7a647cdc88454fe15d79168e0dea +Item::title = Fuzix OS, parce que les petites choses sont belles +Item::url = http://linuxfr.org/news/fuzix-os-parce-que-les-petites-choses-sont-belles +Item::date = 1415112167 +Item::language = en-US +Item::author = Thomas DEBESSE Item::enclosure_url = Item::enclosure_type = -Item::content =

A woman tells the... (142 bytes) -........... -``` - -This ouput is generated by the magic method `__toString()` of the class `Feed` and `Item`. -All properties are public and they are also available with getter methods: - -```php - -// Examples for the feed: -echo $feed->getId(); // Unique feed id -echo $feed->getTitle(); // Feed title -echo $feed->getUrl(); // Feed url -echo $feed->getDate(); // Feed last updated date -echo $feed->getLanguage(); // Feed language -echo $feed->getDescription(); // Feed description -echo $feed->getLogo(); // Feed logo (can be a large image, different from icon) -echo $feed->getItems(); // List of items - -// Examples for items: -echo $feed->items[0]->getId(); -echo $feed->items[0]->getTitle(); -echo $feed->items[0]->getUrl(); -echo $feed->items[0]->getDate(); -echo $feed->items[0]->getLanguage(); -echo $feed->items[0]->getAuthor(); -echo $feed->items[0]->getEnclosureUrl(); -echo $feed->items[0]->getEnclosureType(); -echo $feed->items[0]->getContent(); +Item::content = 6104 bytes +.... ``` -Handle HTTP cache ------------------ - -To avoid downloading and parsing the feed each time, it's a good idea to handle the HTTP caching: +Get the list of available subscriptions for a website +----------------------------------------------------- -1. After the first HTTP request, we save somewhere (in a database) the headers Etag and Last-Modified for the next checks -2. If the feed is not modified, we don't need to parse again the feed - -Example: +The example below will returns all available subscriptions for the website: ```php -use PicoFeed\Reader; - -$reader = new Reader; +use PicoFeed\Reader\Reader; -// Get last modified infos from previous requests -$lastModified = '...'; -$etag = '...'; +try { -// Download directly the feed -$resource = $reader->download('http://linuxfr.org/news.atom', $lastModified, $etag); + $reader = new Reader; + $resource = $reader->download('http://www.cnn.com'); -// Return true is the feed has changed -if ($resource->isModified()) { + $feeds = $reader->find( + $resource->getUrl(), + $resource->getContent() + ); - $parser = $reader->getParser(); - - if ($parser !== false) { - - $feed = $parser->execute(); - - if ($feed !== false) { - - // Save cache infos for the next request - $lastModified = $resource->getLastModified(); - $etag = $resource->getEtag(); - } - } + print_r($feeds); +} +catch (PicoFeedException $e) { + // Do something... } ``` -Use a custom user agent ------------------------ - -You have to define a custom configuration for that: +Output: ```php -use PicoFeed\Reader; -use PicoFeed\Config; - -$config = new Config; -$config->setClientUserAgent('My RSS Reader'); - -$reader = new Reader($config); -... +Array +( + [0] => http://rss.cnn.com/rss/cnn_topstories.rss + [1] => http://rss.cnn.com/rss/cnn_latest.rss +) ``` -The complete config parameters are [described here](config.markdown). +Feed discovery and parsing +-------------------------- -Set a custom timezone ---------------------- - -By default, the timezone used is UTC but you can define a custom timezone for the logging and item parsing. +This example will discover automatically the subscription and parse the feed: ```php -use PicoFeed\Reader; -use PicoFeed\Config; - -$config = new Config; -$config->setTimezone('Europe/Paris'); +try { -$reader = new Reader($config); -... -``` - -[List of supported TimeZones](http://php.net/manual/en/timezones.php) - -Disable content filtering -------------------------- + $reader = new Reader; + $resource = $reader->discover('http://linuxfr.org'); -If you want to disable the internal filtering system to use an external library like [HTMLPurifier](http://htmlpurifier.org): - -```php -use PicoFeed\Reader; -use PicoFeed\Config; + $parser = $reader->getParser( + $resource->getUrl(), + $resource->getContent(), + $resource->getEncoding() + ); -$config = new Config; -$config->setTimezone('Europe/Paris'); -$config->setContentFiltering(false); - -$reader = new Reader($config); -... + $feed = $parser->execute(); + echo $feed; +} +catch (PicoFeedException $e) { +} ``` -or +HTTP caching +------------ -```php -use PicoFeed\Reader; +TODO -$reader = new Reader; -$reader->download('http://.....'); -$parser = $reader->getParser(); +Feed and item properties +------------------------ -if ($parser !== false) { - - $parser->disableContentFiltering(); // <= Disable content filtering - $feed = $parser->execute(); - // ... -} +```php +// Feed object +$feed->getId(); // Unique feed id +$feed->getTitle(); // Feed title +$feed->getUrl(); // Website url +$feed->getDate(); // Feed last updated date +$feed->getLanguage(); // Feed language +$feed->getDescription(); // Feed description +$feed->getLogo(); // Feed logo (can be a large image, different from icon) +$feed->getItems(); // List of item objects + +// Item object +$feed->items[0]->getId(); // Item unique id (hash) +$feed->items[0]->getTitle(); // Item title +$feed->items[0]->getUrl(); // Item url +$feed->items[0]->getDate(); // Item published date (timestamp) +$feed->items[0]->getLanguage(); // Item language +$feed->items[0]->getAuthor(); // Item author +$feed->items[0]->getEnclosureUrl(); // Enclosure url +$feed->items[0]->getEnclosureType(); // Enclosure mime-type (audio/mp3, image/png...) +$feed->items[0]->getContent(); // Item content (filtered or raw) ``` diff --git a/3rdparty/fguillot/picofeed/docs/installation.markdown b/3rdparty/fguillot/picofeed/docs/installation.markdown index d88c590e1..827908f75 100644 --- a/3rdparty/fguillot/picofeed/docs/installation.markdown +++ b/3rdparty/fguillot/picofeed/docs/installation.markdown @@ -1,23 +1,38 @@ Installation ============ -Installation with Composer and AutoLoading ------------------------------------------- +Versions +-------- + +- Development version: branch master +- Available versions: + - v0.1.0 (stable) + - v0.0.2 + - v0.0.1 + +Installation with Composer +-------------------------- Configure your `composer.json`: ```json { "require": { - "fguillot/picofeed": "dev-master" + "fguillot/picofeed": "0.1.0" } } ``` +Or simply: + +```bash +composer require fguillot/picofeed:0.1.0 +``` + And download the code: ```bash -php composer.phar install # or update +composer install # or update ``` Usage example with the Composer autoloading: @@ -27,48 +42,24 @@ Usage example with the Composer autoloading: require 'vendor/autoload.php'; -use PicoFeed\Reader; +use PicoFeed\Reader\Reader; -$reader = new Reader; -$reader->download('http://linuxfr.org/news.atom'); +try { -$parser = $reader->getParser(); + $reader = new Reader; + $resource = $reader->download('https://linuxfr.org/news.atom'); -if ($parser !== false) { + $parser = $reader->getParser( + $resource->getUrl(), + $resource->getContent(), + $resource->getEncoding() + ); $feed = $parser->execute(); - if ($feed !== false) { - echo $feed->title; - } + echo $feed; } -``` - -Installation without AutoLoading --------------------------------- - -If you don't want to use an autoloader, you can include the file `PicoFeed.php`. - -Example: - -```php -download('http://linuxfr.org/news.atom'); - -$parser = $reader->getParser(); - -if ($parser !== false) { - - $feed = $parser->execute(); - - if ($feed !== false) { - echo $feed->title; - } +catch (Exception $e) { + // Do something... } ``` diff --git a/3rdparty/fguillot/picofeed/docs/tests.markdown b/3rdparty/fguillot/picofeed/docs/tests.markdown new file mode 100644 index 000000000..72bb48b0f --- /dev/null +++ b/3rdparty/fguillot/picofeed/docs/tests.markdown @@ -0,0 +1,14 @@ +Running unit tests +================== + +If the autoloader is not yet installed run: + +```php +composer dump-autoload +``` + +Then run: + +```php +phpunit tests +``` diff --git a/3rdparty/fguillot/picofeed/lib/PicoFeed/Client.php b/3rdparty/fguillot/picofeed/lib/PicoFeed/Client.php deleted file mode 100644 index 59e9aa9ce..000000000 --- a/3rdparty/fguillot/picofeed/lib/PicoFeed/Client.php +++ /dev/null @@ -1,559 +0,0 @@ -url = $url; - } - - Logging::setMessage(get_called_class().' Fetch URL: '.$this->url); - Logging::setMessage(get_called_class().' Etag provided: '.$this->etag); - Logging::setMessage(get_called_class().' Last-Modified provided: '.$this->last_modified); - - $response = $this->doRequest(); - - if (is_array($response)) { - $this->handleNotModifiedResponse($response); - $this->handleNotFoundResponse($response); - $this->handleNormalResponse($response); - return true; - } - - return false; - } - - /** - * Handle not modified response - * - * @access public - * @param array $response Client response - */ - public function handleNotModifiedResponse(array $response) - { - if ($response['status'] == 304) { - $this->is_modified = false; - } - else if ($response['status'] == 200) { - - $etag = $this->getHeader($response, 'ETag'); - $last_modified = $this->getHeader($response, 'Last-Modified'); - - if ($this->isPropertyEquals('etag', $etag) || $this->isPropertyEquals('last_modified', $last_modified)) { - $this->is_modified = false; - } - - $this->etag = $etag; - $this->last_modified = $last_modified; - } - - if ($this->is_modified === false) { - Logging::setMessage(get_called_class().' Resource not modified'); - } - } - - /** - * Handle not found response - * - * @access public - * @param array $response Client response - */ - public function handleNotFoundResponse(array $response) - { - if ($response['status'] == 404) { - $this->is_not_found = true; - Logging::setMessage(get_called_class().' Resource not found'); - } - } - - /** - * Handle normal response - * - * @access public - * @param array $response Client response - */ - public function handleNormalResponse(array $response) - { - if ($response['status'] == 200) { - $this->content = $response['body']; - $this->encoding = $this->findCharset($response); - } - } - - /** - * Check if a class property equals to a value - * - * @access public - * @param string $property Class property - * @param string $value Value - * @return boolean - */ - private function isPropertyEquals($property, $value) - { - return $this->$property && $this->$property === $value; - } - - /** - * Find charset from response headers - * - * @access public - * @param array $response Client response - */ - public function findCharset(array $response) - { - $result = explode('charset=', strtolower($this->getHeader($response, 'Content-Type'))); - return isset($result[1]) ? $result[1] : ''; - } - - /** - * Get header value from a client response - * - * @access public - * @param array $response Client response - * @param string $header Header name - * @return string - */ - public function getHeader(array $response, $header) - { - return isset($response['headers'][$header]) ? $response['headers'][$header] : ''; - } - - /** - * Parse HTTP headers - * - * @access public - * @param array $lines List of headers - * @return array - */ - public function parseHeaders(array $lines) - { - $status = 200; - $headers = array(); - - foreach ($lines as $line) { - - if (strpos($line, 'HTTP') === 0) { - $status = (int) substr($line, 9, 3); - } - else if (strpos($line, ':') !== false) { - - @list($name, $value) = explode(': ', $line); - if ($value) $headers[trim($name)] = trim($value); - } - } - - Logging::setMessage(get_called_class().' HTTP status code: '.$status); - - foreach ($headers as $name => $value) { - Logging::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value); - } - - return array($status, $headers); - } - - /** - * Set the Last-Modified HTTP header - * - * @access public - * @param string $last_modified Header value - * @return \PicoFeed\Client - */ - public function setLastModified($last_modified) - { - $this->last_modified = $last_modified; - return $this; - } - - /** - * Get the value of the Last-Modified HTTP header - * - * @access public - * @return string - */ - public function getLastModified() - { - return $this->last_modified; - } - - /** - * Set the value of the Etag HTTP header - * - * @access public - * @param string $etag Etag HTTP header value - * @return \PicoFeed\Client - */ - public function setEtag($etag) - { - $this->etag = $etag; - return $this; - } - - /** - * Get the Etag HTTP header value - * - * @access public - * @return string - */ - public function getEtag() - { - return $this->etag; - } - - /** - * Get the final url value - * - * @access public - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * Set the url - * - * @access public - * @return string - * @return \PicoFeed\Client - */ - public function setUrl($url) - { - $this->url = $url; - return $this; - } - - /** - * Get the body of the HTTP response - * - * @access public - * @return string - */ - public function getContent() - { - return $this->content; - } - - /** - * Get the encoding value from HTTP headers - * - * @access public - * @return string - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * Return true if the remote resource has changed - * - * @access public - * @return bool - */ - public function isModified() - { - return $this->is_modified; - } - - /** - * Return true if the remote resource is not found - * - * @access public - * @return bool - */ - public function isNotFound() - { - return $this->is_not_found; - } - - /** - * Set connection timeout - * - * @access public - * @param integer $timeout Connection timeout - * @return \PicoFeed\Client - */ - public function setTimeout($timeout) - { - $this->timeout = $timeout ?: $this->timeout; - return $this; - } - - /** - * Set a custom user agent - * - * @access public - * @param string $user_agent User Agent - * @return \PicoFeed\Client - */ - public function setUserAgent($user_agent) - { - $this->user_agent = $user_agent ?: $this->user_agent; - return $this; - } - - /** - * Set the mximum number of HTTP redirections - * - * @access public - * @param integer $max Maximum - * @return \PicoFeed\Client - */ - public function setMaxRedirections($max) - { - $this->max_redirects = $max ?: $this->max_redirects; - return $this; - } - - /** - * Set the maximum size of the HTTP body - * - * @access public - * @param integer $max Maximum - * @return \PicoFeed\Client - */ - public function setMaxBodySize($max) - { - $this->max_body_size = $max ?: $this->max_body_size; - return $this; - } - - /** - * Set the proxy hostname - * - * @access public - * @param string $hostname Proxy hostname - * @return \PicoFeed\Client - */ - public function setProxyHostname($hostname) - { - $this->proxy_hostname = $hostname ?: $this->proxy_hostname; - return $this; - } - - /** - * Set the proxy port - * - * @access public - * @param integer $port Proxy port - * @return \PicoFeed\Client - */ - public function setProxyPort($port) - { - $this->proxy_port = $port ?: $this->proxy_port; - return $this; - } - - /** - * Set the proxy username - * - * @access public - * @param string $username Proxy username - * @return \PicoFeed\Client - */ - public function setProxyUsername($username) - { - $this->proxy_username = $username ?: $this->proxy_username; - return $this; - } - - /** - * Set the proxy password - * - * @access public - * @param string $password Password - * @return \PicoFeed\Client - */ - public function setProxyPassword($password) - { - $this->proxy_password = $password ?: $this->proxy_password; - return $this; - } - - /** - * Set config object - * - * @access public - * @param \PicoFeed\Config $config Config instance - * @return \PicoFeed\Client - */ - public function setConfig($config) - { - if ($config !== null) { - $this->setTimeout($config->getGrabberTimeout()); - $this->setUserAgent($config->getGrabberUserAgent()); - $this->setMaxRedirections($config->getMaxRedirections()); - $this->setMaxBodySize($config->getMaxBodySize()); - $this->setProxyHostname($config->getProxyHostname()); - $this->setProxyPort($config->getProxyPort()); - $this->setProxyUsername($config->getProxyUsername()); - $this->setProxyPassword($config->getProxyPassword()); - } - - return $this; - } -} diff --git a/3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Client.php b/3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Client.php new file mode 100644 index 000000000..7328b2c75 --- /dev/null +++ b/3rdparty/fguillot/picofeed/lib/PicoFeed/Client/Client.php @@ -0,0 +1,540 @@ +url = $url; + } + + Logging::setMessage(get_called_class().' Fetch URL: '.$this->url); + Logging::setMessage(get_called_class().' Etag provided: '.$this->etag); + Logging::setMessage(get_called_class().' Last-Modified provided: '.$this->last_modified); + + $response = $this->doRequest(); + + $this->handleNotModifiedResponse($response); + $this->handleNotFoundResponse($response); + $this->handleNormalResponse($response); + + return $this; + } + + /** + * Handle not modified response + * + * @access public + * @param array $response Client response + */ + public function handleNotModifiedResponse(array $response) + { + if ($response['status'] == 304) { + $this->is_modified = false; + } + else if ($response['status'] == 200) { + + $etag = $this->getHeader($response, 'ETag'); + $last_modified = $this->getHeader($response, 'Last-Modified'); + + if ($this->isPropertyEquals('etag', $etag) || $this->isPropertyEquals('last_modified', $last_modified)) { + $this->is_modified = false; + } + + $this->etag = $etag; + $this->last_modified = $last_modified; + } + + if ($this->is_modified === false) { + Logging::setMessage(get_called_class().' Resource not modified'); + } + } + + /** + * Handle not found response + * + * @access public + * @param array $response Client response + */ + public function handleNotFoundResponse(array $response) + { + if ($response['status'] == 404) { + throw new InvalidUrlException('Resource not found'); + } + } + + /** + * Handle normal response + * + * @access public + * @param array $response Client response + */ + public function handleNormalResponse(array $response) + { + if ($response['status'] == 200) { + $this->content = $response['body']; + $this->encoding = $this->findCharset($response); + } + } + + /** + * Check if a class property equals to a value + * + * @access public + * @param string $property Class property + * @param string $value Value + * @return boolean + */ + private function isPropertyEquals($property, $value) + { + return $this->$property && $this->$property === $value; + } + + /** + * Find charset from response headers + * + * @access public + * @param array $response Client response + */ + public function findCharset(array $response) + { + $result = explode('charset=', strtolower($this->getHeader($response, 'Content-Type'))); + return isset($result[1]) ? $result[1] : ''; + } + + /** + * Get header value from a client response + * + * @access public + * @param array $response Client response + * @param string $header Header name + * @return string + */ + public function getHeader(array $response, $header) + { + return isset($response['headers'][$header]) ? $response['headers'][$header] : ''; + } + + /** + * Parse HTTP headers + * + * @access public + * @param array $lines List of headers + * @return array + */ + public function parseHeaders(array $lines) + { + $status = 200; + $headers = array(); + + foreach ($lines as $line) { + + if (strpos($line, 'HTTP') === 0) { + $status = (int) substr($line, 9, 3); + } + else if (strpos($line, ':') !== false) { + + @list($name, $value) = explode(': ', $line); + if ($value) $headers[trim($name)] = trim($value); + } + } + + Logging::setMessage(get_called_class().' HTTP status code: '.$status); + + foreach ($headers as $name => $value) { + Logging::setMessage(get_called_class().' HTTP header: '.$name.' => '.$value); + } + + return array($status, $headers); + } + + /** + * Set the Last-Modified HTTP header + * + * @access public + * @param string $last_modified Header value + * @return \PicoFeed\Client\Client + */ + public function setLastModified($last_modified) + { + $this->last_modified = $last_modified; + return $this; + } + + /** + * Get the value of the Last-Modified HTTP header + * + * @access public + * @return string + */ + public function getLastModified() + { + return $this->last_modified; + } + + /** + * Set the value of the Etag HTTP header + * + * @access public + * @param string $etag Etag HTTP header value + * @return \PicoFeed\Client\Client + */ + public function setEtag($etag) + { + $this->etag = $etag; + return $this; + } + + /** + * Get the Etag HTTP header value + * + * @access public + * @return string + */ + public function getEtag() + { + return $this->etag; + } + + /** + * Get the final url value + * + * @access public + * @return string + */ + public function getUrl() + { + return $this->url; + } + + /** + * Set the url + * + * @access public + * @return string + * @return \PicoFeed\Client\Client + */ + public function setUrl($url) + { + $this->url = $url; + return $this; + } + + /** + * Get the body of the HTTP response + * + * @access public + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Get the encoding value from HTTP headers + * + * @access public + * @return string + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * Return true if the remote resource has changed + * + * @access public + * @return bool + */ + public function isModified() + { + return $this->is_modified; + } + + /** + * Set connection timeout + * + * @access public + * @param integer $timeout Connection timeout + * @return \PicoFeed\Client\Client + */ + public function setTimeout($timeout) + { + $this->timeout = $timeout ?: $this->timeout; + return $this; + } + + /** + * Set a custom user agent + * + * @access public + * @param string $user_agent User Agent + * @return \PicoFeed\Client\Client + */ + public function setUserAgent($user_agent) + { + $this->user_agent = $user_agent ?: $this->user_agent; + return $this; + } + + /** + * Set the mximum number of HTTP redirections + * + * @access public + * @param integer $max Maximum + * @return \PicoFeed\Client\Client + */ + public function setMaxRedirections($max) + { + $this->max_redirects = $max ?: $this->max_redirects; + return $this; + } + + /** + * Set the maximum size of the HTTP body + * + * @access public + * @param integer $max Maximum + * @return \PicoFeed\Client\Client + */ + public function setMaxBodySize($max) + { + $this->max_body_size = $max ?: $this->max_body_size; + return $this; + } + + /** + * Set the proxy hostname + * + * @access public + * @param string $hostname Proxy hostname + * @return \PicoFeed\Client\Client + */ + public function setProxyHostname($hostname) + { + $this->proxy_hostname = $hostname ?: $this->proxy_hostname; + return $this; + } + + /** + * Set the proxy port + * + * @access public + * @param integer $port Proxy port + * @return \PicoFeed\Client\Client + */ + public function setProxyPort($port) + { + $this->proxy_port = $port ?: $this->proxy_port; + return $this; + } + + /** + * Set the proxy username + * + * @access public + * @param string $username Proxy username + * @return \PicoFeed\Client\Client + */ + public function setProxyUsername($username) + { + $this->proxy_username = $username ?: $this->proxy_username; + return $this; + } + + /** + * Set the proxy password + * + * @access public + * @param string $password Password + * @return \PicoFeed\Client\Client + */ + public function setProxyPassword($password) + { + $this->proxy_password = $password ?: $this->proxy_password; + return $this; + } + + /** + * Set config object + * + * @access public + * @param \PicoFeed\Config\Config $config Config instance + * @return \PicoFeed\Config\Config + */ + public function setConfig($config) + { + if ($config !== null) { + $this->setTimeout($config->getGrabberTimeout()); + $this->setUserAgent($config->getGrabberUserAgent()); + $this->setMaxRedirections($config->getMaxRedirections()); + $this->setMaxBodySize($config->getMaxBodySize()); + $this->setProxyHostname($config->getProxyHostname()); + $this->setProxyPort($config->getProxyPort()); + $this->setProxyUsername($config->getProxyUsername()); + $this->setProxyPassword($config->getProxyPassword()); + } + + return $this; + } +} diff --git a/3rdparty/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php b/3rdparty/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php new file mode 100644 index 000000000..0e27452ed --- /dev/null +++ b/3rdparty/fguillot/picofeed/lib/PicoFeed/Client/ClientException.php @@ -0,0 +1,16 @@ +body_length += $length; + + if ($this->body_length > $this->max_body_size) { + return -1; + } + + $this->body .= $buffer; + + return $length; + } + + /** + * cURL callback to read HTTP headers + * + * @access public + * @param resource $ch cURL handler + * @param string $buffer Header line + * @return integer Length of the buffer + */ + public function readHeaders($ch, $buffer) + { + $length = strlen($buffer); + + if ($buffer === "\r\n") { + $this->headers_counter++; + } + else { + + if (! isset($this->headers[$this->headers_counter])) { + $this->headers[$this->headers_counter] = ''; + } + + $this->headers[$this->headers_counter] .= $buffer; + } + + return $length; + } + + /** + * Prepare HTTP headers + * + * @access private + * @return array + */ + private function prepareHeaders() + { + $headers = array( + 'Connection: close', + 'User-Agent: '.$this->user_agent, + ); + + if ($this->etag) { + $headers[] = 'If-None-Match: '.$this->etag; + } + + if ($this->last_modified) { + $headers[] = 'If-Modified-Since: '.$this->last_modified; + } + + return $headers; + } + + /** + * Prepare curl proxy context + * + * @access private + * @return resource + */ + private function prepareProxy