summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSean Molenaar <SMillerDev@users.noreply.github.com>2018-03-27 15:35:06 +0200
committerBernhard Posselt <BernhardPosselt@users.noreply.github.com>2018-03-27 15:35:06 +0200
commit5b94705cf3918dc7986c6043b1fbe776bf22958f (patch)
tree4e8059818a0a913d24938e35238913a721fa6373 /lib
parentf3c9d13551cef5968baea99c2f25085baee0ed5f (diff)
Core: Fix compatibility with nextcloud codestyle (#280)
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php331
-rw-r--r--lib/Command/Updater/AfterUpdate.php20
-rw-r--r--lib/Command/Updater/AllFeeds.php20
-rw-r--r--lib/Command/Updater/BeforeUpdate.php20
-rw-r--r--lib/Command/Updater/UpdateFeed.php20
-rw-r--r--lib/Config/Config.php66
-rw-r--r--lib/Config/DependencyException.php15
-rw-r--r--lib/Controller/AdminController.php121
-rw-r--r--lib/Controller/ApiController.php30
-rw-r--r--lib/Controller/EntityApiSerializer.php28
-rw-r--r--lib/Controller/ExportController.php40
-rw-r--r--lib/Controller/FeedApiController.php76
-rw-r--r--lib/Controller/FeedController.php123
-rw-r--r--lib/Controller/FolderApiController.php41
-rw-r--r--lib/Controller/FolderController.php57
-rw-r--r--lib/Controller/ItemApiController.php91
-rw-r--r--lib/Controller/ItemController.php108
-rw-r--r--lib/Controller/JSONHttpError.php12
-rw-r--r--lib/Controller/PageController.php68
-rw-r--r--lib/Controller/UserApiController.php25
-rw-r--r--lib/Controller/UtilityApiController.php42
-rw-r--r--lib/Cron/Updater.php16
-rw-r--r--lib/Db/EntityJSONSerializer.php14
-rw-r--r--lib/Db/Feed.php38
-rw-r--r--lib/Db/FeedMapper.php42
-rw-r--r--lib/Db/FeedType.php11
-rw-r--r--lib/Db/Folder.php33
-rw-r--r--lib/Db/FolderMapper.php39
-rw-r--r--lib/Db/IAPI.php11
-rw-r--r--lib/Db/Item.php75
-rw-r--r--lib/Db/ItemMapper.php116
-rw-r--r--lib/Db/MapperFactory.php39
-rw-r--r--lib/Db/Mysql/ItemMapper.php21
-rw-r--r--lib/Db/NewsMapper.php47
-rw-r--r--lib/DependencyInjection/IFactory.php12
-rw-r--r--lib/Explore/RecommendedSiteNotFoundException.php11
-rw-r--r--lib/Explore/RecommendedSites.php19
-rw-r--r--lib/Fetcher/FeedFetcher.php180
-rw-r--r--lib/Fetcher/Fetcher.php63
-rw-r--r--lib/Fetcher/FetcherException.php15
-rw-r--r--lib/Fetcher/IFeedFetcher.php43
-rw-r--r--lib/Fetcher/YoutubeFetcher.php49
-rw-r--r--lib/Hooks/User.php14
-rw-r--r--lib/Http/TextDownloadResponse.php25
-rw-r--r--lib/Http/TextResponse.php23
-rw-r--r--lib/Migration/MigrateStatusFlags.php24
-rw-r--r--lib/Plugin/Client/Plugin.php23
-rw-r--r--lib/PostProcessor/LWNProcessor.php36
-rw-r--r--lib/Service/FeedService.php142
-rw-r--r--lib/Service/FolderService.php87
-rw-r--r--lib/Service/ItemService.php202
-rw-r--r--lib/Service/Service.php30
-rw-r--r--lib/Service/ServiceConflictException.php15
-rw-r--r--lib/Service/ServiceException.php15
-rw-r--r--lib/Service/ServiceNotFoundException.php15
-rw-r--r--lib/Service/ServiceValidationException.php15
-rw-r--r--lib/Service/StatusService.php20
-rw-r--r--lib/Settings/Admin.php15
-rw-r--r--lib/Settings/Section.php18
-rw-r--r--lib/Utility/OPMLExporter.php25
-rw-r--r--lib/Utility/PicoFeedClientFactory.php18
-rw-r--r--lib/Utility/PicoFeedFaviconFactory.php18
-rw-r--r--lib/Utility/ProxyConfigParser.php18
-rw-r--r--lib/Utility/Time.php11
-rw-r--r--lib/Utility/Updater.php25
65 files changed, 1851 insertions, 1231 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 5abd0c5be..d633de743 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -5,10 +5,10 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
- * @author Alessandro Cosentino <cosenal@gmail.com>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Alessandro Cosentino 2012
- * @copyright Bernhard Posselt 2012, 2014
+ * @author Alessandro Cosentino <cosenal@gmail.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright 2012 Alessandro Cosentino
+ * @copyright 2012-2014 Bernhard Posselt
*/
namespace OCA\News\AppInfo;
@@ -40,9 +40,11 @@ use OCA\News\Explore\RecommendedSites;
use OCA\News\Utility\ProxyConfigParser;
-class Application extends App {
+class Application extends App
+{
- public function __construct(array $urlParams=[]) {
+ public function __construct(array $urlParams=[])
+ {
parent::__construct('news', $urlParams);
// files
@@ -60,192 +62,245 @@ class Application extends App {
/**
* App config parser
*/
- /** @noinspection PhpParamsInspection */
- $this->registerService(AppConfig::class, function($c) {
- $config = new AppConfig(
- $c->query(INavigationManager::class),
- $c->query(IURLGenerator::class),
- $c->query(IJobList::class)
- );
-
- $config->loadConfig($c->query('info'));
-
- return $config;
- });
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ AppConfig::class, function ($c) {
+ $config = new AppConfig(
+ $c->query(INavigationManager::class),
+ $c->query(IURLGenerator::class),
+ $c->query(IJobList::class)
+ );
+
+ $config->loadConfig($c->query('info'));
+
+ return $config;
+ }
+ );
/**
* Core
*/
- /** @noinspection PhpParamsInspection */
- $this->registerService('LoggerParameters', function($c) {
- return ['app' => $c->query('AppName')];
- });
-
- /** @noinspection PhpParamsInspection */
- $this->registerService('databaseType', function($c) {
- return $c->query(IConfig::class)->getSystemValue('dbtype');
- });
-
- /** @noinspection PhpParamsInspection */
- $this->registerService('ConfigView', function($c) {
- $fs = $c->query(IRootFolder::class);
- $path = 'news/config';
- if ($fs->nodeExists($path)) {
- return $fs->get($path);
- } else {
- return $fs->newFolder($path);
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ 'LoggerParameters', function ($c) {
+ return ['app' => $c->query('AppName')];
}
- });
-
-
- /** @noinspection PhpParamsInspection */
- $this->registerService(Config::class, function($c) {
- $config = new Config(
- $c->query('ConfigView'),
- $c->query(ILogger::class),
- $c->query('LoggerParameters')
- );
- $config->read($c->query('configFile'), true);
- return $config;
- });
-
- /** @noinspection PhpParamsInspection */
- $this->registerService(HTMLPurifier::class, function($c) {
- $directory = $c->query(IConfig::class)
- ->getSystemValue('datadirectory') . '/news/cache/purifier';
-
- if(!is_dir($directory)) {
- mkdir($directory, 0770, true);
+ );
+
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ 'databaseType', function ($c) {
+ return $c->query(IConfig::class)->getSystemValue('dbtype');
}
+ );
+
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ 'ConfigView', function ($c) {
+ $fs = $c->query(IRootFolder::class);
+ $path = 'news/config';
+ if ($fs->nodeExists($path)) {
+ return $fs->get($path);
+ } else {
+ return $fs->newFolder($path);
+ }
+ }
+ );
- $config = HTMLPurifier_Config::createDefault();
- $config->set('HTML.ForbiddenAttributes', 'class');
- $config->set('Cache.SerializerPath', $directory);
- $config->set('HTML.SafeIframe', true);
- $config->set('URI.SafeIframeRegexp',
- '%^https://(?:www\.)?(' .
- 'youtube(?:-nocookie)?.com/embed/|' .
- 'player.vimeo.com/video/|' .
- 'vk.com/video_ext.php)%'); //allow YouTube and Vimeo
- $def = $config->getHTMLDefinition(true);
- $def->addAttribute('iframe', 'allowfullscreen', 'Bool');
- return new HTMLPurifier($config);
- });
/**
- * Fetchers
- */
- /** @noinspection PhpParamsInspection */
- $this->registerService(PicoFeedConfig::class, function($c) {
- // FIXME: move this into a separate class for testing?
- $config = $c->query(Config::class);
- $proxy = $c->query(ProxyConfigParser::class);
-
- // use chrome's user agent string since mod_security rules
- // assume that only browsers can send user agent strings. This
- // can lead to blocked feed updates like joomla.org
- // For more information see
- // https://www.atomicorp.com/wiki/index.php/WAF_309925
- $userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36' .
- '(KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36';
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ Config::class, function ($c) {
+ $config = new Config(
+ $c->query('ConfigView'),
+ $c->query(ILogger::class),
+ $c->query('LoggerParameters')
+ );
+ $config->read($c->query('configFile'), true);
+ return $config;
+ }
+ );
- $pico = new PicoFeedConfig();
- $pico->setClientUserAgent($userAgent)
- ->setClientTimeout($config->getFeedFetcherTimeout())
- ->setMaxRedirections($config->getMaxRedirects())
- ->setMaxBodySize($config->getMaxSize())
- ->setParserHashAlgo('md5');
-
- // proxy settings
- $proxySettings = $proxy->parse();
- $host = $proxySettings['host'];
- $port = $proxySettings['port'];
- $user = $proxySettings['user'];
- $password = $proxySettings['password'];
-
- if ($host) {
- $pico->setProxyHostname($host);
-
- if ($port) {
- $pico->setProxyPort($port);
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ HTMLPurifier::class, function ($c) {
+ $directory = $c->query(IConfig::class)
+ ->getSystemValue('datadirectory') . '/news/cache/purifier';
+
+ if(!is_dir($directory)) {
+ mkdir($directory, 0770, true);
}
- }
- if ($user) {
- $pico->setProxyUsername($user)
- ->setProxyPassword($password);
+ $config = HTMLPurifier_Config::createDefault();
+ $config->set('HTML.ForbiddenAttributes', 'class');
+ $config->set('Cache.SerializerPath', $directory);
+ $config->set('HTML.SafeIframe', true);
+ $config->set(
+ 'URI.SafeIframeRegexp',
+ '%^https://(?:www\.)?(' .
+ 'youtube(?:-nocookie)?.com/embed/|' .
+ 'player.vimeo.com/video/|' .
+ 'vk.com/video_ext.php)%'
+ ); //allow YouTube and Vimeo
+ $def = $config->getHTMLDefinition(true);
+ $def->addAttribute('iframe', 'allowfullscreen', 'Bool');
+ return new HTMLPurifier($config);
}
+ );
- return $pico;
- });
+ /**
+ * Fetchers
+ */
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ PicoFeedConfig::class, function ($c) {
+ // FIXME: move this into a separate class for testing?
+ $config = $c->query(Config::class);
+ $proxy = $c->query(ProxyConfigParser::class);
+
+ // use chrome's user agent string since mod_security rules
+ // assume that only browsers can send user agent strings. This
+ // can lead to blocked feed updates like joomla.org
+ // For more information see
+ // https://www.atomicorp.com/wiki/index.php/WAF_309925
+ $userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36' .
+ '(KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36';
- $this->registerService(PicoFeedReader::class, function ($c) {
- return new PicoFeedReader($c->query(PicoFeedConfig::class));
- });
+ $pico = new PicoFeedConfig();
+ $pico->setClientUserAgent($userAgent)
+ ->setClientTimeout($config->getFeedFetcherTimeout())
+ ->setMaxRedirections($config->getMaxRedirects())
+ ->setMaxBodySize($config->getMaxSize())
+ ->setParserHashAlgo('md5');
+
+ // proxy settings
+ $proxySettings = $proxy->parse();
+ $host = $proxySettings['host'];
+ $port = $proxySettings['port'];
+ $user = $proxySettings['user'];
+ $password = $proxySettings['password'];
+
+ if ($host) {
+ $pico->setProxyHostname($host);
+
+ if ($port) {
+ $pico->setProxyPort($port);
+ }
+ }
- /** @noinspection PhpParamsInspection */
- $this->registerService(Fetcher::class, function($c) {
- $fetcher = new Fetcher();
+ if ($user) {
+ $pico->setProxyUsername($user)
+ ->setProxyPassword($password);
+ }
- // register fetchers in order, the most generic fetcher should be
- // the last one
- $fetcher->registerFetcher($c->query(YoutubeFetcher::class));
- $fetcher->registerFetcher($c->query(FeedFetcher::class));
+ return $pico;
+ }
+ );
- return $fetcher;
- });
+ $this->registerService(
+ PicoFeedReader::class, function ($c) {
+ return new PicoFeedReader($c->query(PicoFeedConfig::class));
+ }
+ );
+
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ Fetcher::class, function ($c) {
+ $fetcher = new Fetcher();
+
+ // register fetchers in order, the most generic fetcher should be
+ // the last one
+ $fetcher->registerFetcher($c->query(YoutubeFetcher::class));
+ $fetcher->registerFetcher($c->query(FeedFetcher::class));
+
+ return $fetcher;
+ }
+ );
}
/**
* Registers the content of a file under a key
+ *
* @param string $key
* @param string $file path relative to this file, __DIR__ will be prepended
*/
- private function registerFileContents($key, $file) {
- /** @noinspection PhpParamsInspection */
- $this->registerService($key, function () use ($file) {
- return file_get_contents(__DIR__ . '/' . $file);
- });
+ private function registerFileContents($key, $file)
+ {
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ $key, function () use ($file) {
+ return file_get_contents(__DIR__ . '/' . $file);
+ }
+ );
}
/**
* Shortcut for registering a service
- * @param string $key
+ *
+ * @param string $key
* @param closure $factory
* @param boolean $shared
*/
- private function registerService($key, $factory, $shared=true) {
+ private function registerService($key, $factory, $shared=true)
+ {
$this->getContainer()->registerService($key, $factory, $shared);
}
/**
* Shortcut for registering a parameter
+ *
* @param string $key
- * @param mixed $value
+ * @param mixed $value
*/
- private function registerParameter($key, $value) {
+ private function registerParameter($key, $value)
+ {
$this->getContainer()->registerParameter($key, $value);
}
/**
* Register a class containing the app construction logic instead of the
* inlining everything in this class to enhance testability
- * @param string $key fully qualified class name
+ *
+ * @param string $key fully qualified class name
* @param string $factory fully qualified factory class name
*/
- private function registerFactory($key, $factory) {
- /** @noinspection PhpParamsInspection */
- $this->registerService($key, function ($c) use ($factory) {
- return $c->query($factory)->build();
- });
+ private function registerFactory($key, $factory)
+ {
+ /**
+ * @noinspection PhpParamsInspection
+*/
+ $this->registerService(
+ $key, function ($c) use ($factory) {
+ return $c->query($factory)->build();
+ }
+ );
}
/**
* Register the additional config parameters found in the info.xml
*/
- public function registerConfig() {
+ public function registerConfig()
+ {
$this->getContainer()->query(AppConfig::class)->registerAll();
}
diff --git a/lib/Command/Updater/AfterUpdate.php b/lib/Command/Updater/AfterUpdate.php
index 728d2a937..a9becf543 100644
--- a/lib/Command/Updater/AfterUpdate.php
+++ b/lib/Command/Updater/AfterUpdate.php
@@ -5,7 +5,7 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2016
*/
@@ -19,21 +19,27 @@ use Symfony\Component\Console\Output\OutputInterface;
use \OCA\News\Utility\Updater;
-class AfterUpdate extends Command {
+class AfterUpdate extends Command
+{
private $updater;
- public function __construct(Updater $updater) {
+ public function __construct(Updater $updater)
+ {
parent::__construct();
$this->updater = $updater;
}
- protected function configure() {
+ protected function configure()
+ {
$this->setName('news:updater:after-update')
- ->setDescription('This is used to clean up the database. It ' .
- 'removes old read articles which are not starred');
+ ->setDescription(
+ 'This is used to clean up the database. It ' .
+ 'removes old read articles which are not starred'
+ );
}
- protected function execute(InputInterface $input, OutputInterface $output) {
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
$this->updater->afterUpdate();
}
diff --git a/lib/Command/Updater/AllFeeds.php b/lib/Command/Updater/AllFeeds.php
index 838ce1404..8947c714e 100644
--- a/lib/Command/Updater/AllFeeds.php
+++ b/lib/Command/Updater/AllFeeds.php
@@ -5,7 +5,7 @@
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2016
*/
@@ -20,23 +20,29 @@ use Symfony\Component\Console\Output\OutputInterface;
use OCA\News\Service\FeedService;
-class AllFeeds extends Command {
+class AllFeeds exte