From 66c73a96ac2dda076bcfe0dc0a1ca2a7e169149d Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 21 Oct 2014 18:19:23 +0200 Subject: first try to set indention limit at 80 characters in php --- .scrutinizer.yml | 2 + appinfo/application.php | 26 +- appinfo/routes.php | 354 +++++++++++++++++---- articleenhancer/globalarticleenhancer.php | 3 +- articleenhancer/xpatharticleenhancer.php | 26 +- config/appconfig.php | 30 +- config/config.php | 37 ++- controller/admincontroller.php | 6 +- controller/exportcontroller.php | 4 +- controller/feedapicontroller.php | 8 +- controller/foldercontroller.php | 4 +- controller/itemapicontroller.php | 4 +- controller/itemcontroller.php | 13 +- controller/pagecontroller.php | 16 +- db/feedmapper.php | 48 +-- db/item.php | 3 +- db/itemmapper.php | 21 +- fetcher/feedfetcher.php | 18 +- fetcher/fetcher.php | 4 +- fetcher/ifeedfetcher.php | 4 +- http/textdownloadresponse.php | 3 +- service/feedservice.php | 45 ++- service/folderservice.php | 13 +- service/itemservice.php | 26 +- templates/admin.php | 13 +- templates/index.php | 28 +- templates/part.content.firstrun.php | 12 +- templates/part.content.php | 91 ++++-- templates/part.content.shortcuts.php | 12 +- templates/part.navigation.addfeed.php | 33 +- templates/part.navigation.addfolder.php | 14 +- templates/part.navigation.feed.php | 38 ++- templates/part.navigation.folder.php | 72 ++++- templates/part.navigation.unreadfeed.php | 6 +- templates/part.settings.php | 31 +- tests/classloader.php | 11 +- .../articleenhancer/GlobalArticleEnhancerTest.php | 18 +- .../articleenhancer/XPathArticleEnhancerTest.php | 18 +- tests/unit/config/ConfigTest.php | 60 ++-- tests/unit/controller/ExportControllerTest.php | 5 +- tests/unit/controller/FeedApiControllerTest.php | 16 +- tests/unit/controller/FeedControllerTest.php | 21 +- tests/unit/controller/FolderApiControllerTest.php | 32 +- tests/unit/controller/FolderControllerTest.php | 14 +- tests/unit/controller/ItemApiControllerTest.php | 16 +- tests/unit/controller/ItemControllerTest.php | 2 +- tests/unit/controller/PageControllerTest.php | 8 +- tests/unit/controller/UtilityApiControllerTest.php | 5 +- tests/unit/db/FeedMapperTest.php | 79 +++-- tests/unit/db/FolderMapperTest.php | 12 +- tests/unit/db/ItemMapperTest.php | 106 +++--- tests/unit/db/MapperFactoryTest.php | 3 +- tests/unit/db/postgres/ItemMapperTest.php | 2 +- tests/unit/fetcher/FeedFetcherTest.php | 6 +- tests/unit/http/TextDownloadResponseTest.php | 4 +- tests/unit/service/FeedServiceTest.php | 35 +- tests/unit/service/FolderServiceTest.php | 16 +- tests/unit/service/ItemServiceTest.php | 12 +- tests/unit/service/ServiceTest.php | 8 +- tests/unit/utility/FaviconFetcherTest.php | 6 +- tests/unit/utility/OPMLExporterTest.php | 37 ++- 61 files changed, 1147 insertions(+), 473 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index ead3dd199..d343f1edc 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -27,3 +27,5 @@ checks: # this is not working properly with core exceptions catch_class_exists: false avoid_tab_indentation: true + line_length: + max_length: '80' diff --git a/appinfo/application.php b/appinfo/application.php index 8a1f02a4c..5b76680c4 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -72,7 +72,7 @@ foreach ($thirdPartyLibs as $class => $path) { class Application extends App { - public function __construct(array $urlParams=array()){ + public function __construct(array $urlParams=[]) { parent::__construct('news', $urlParams); $container = $this->getContainer(); @@ -323,7 +323,8 @@ class Application extends App { }); $container->registerService('DatabaseType', function($c) { - return $c->query('ServerContainer')->getConfig()->getSystemValue('dbtype'); + return $c->query('ServerContainer') + ->getConfig()->getSystemValue('dbtype'); }); @@ -354,8 +355,8 @@ class Application extends App { }); $container->registerService('simplePieCacheDirectory', function($c) { - $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') . - '/news/cache/simplepie'; + $directory = $c->query('CoreConfig') + ->getSystemValue('datadirectory') . '/news/cache/simplepie'; if(!is_dir($directory)) { mkdir($directory, 0770, true); @@ -364,8 +365,8 @@ class Application extends App { }); $container->registerService('HTMLPurifier', function($c) { - $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') . - '/news/cache/purifier'; + $directory = $c->query('CoreConfig') + ->getSystemValue('datadirectory') . '/news/cache/purifier'; if(!is_dir($directory)) { mkdir($directory, 0770, true); @@ -394,7 +395,8 @@ class Application extends App { __DIR__ . '/../articleenhancer/xpathenhancers.json' ); - foreach(json_decode($xpathEnhancerConfig, true) as $feed => $config) { + $xpathEnhancerConfig = json_decode($xpathEnhancerConfig, true); + foreach($xpathEnhancerConfig as $feed => $config) { $articleEnhancer = new XPathArticleEnhancer( $c->query('SimplePieAPIFactory'), $config, @@ -406,14 +408,18 @@ class Application extends App { $regexEnhancerConfig = file_get_contents( __DIR__ . '/../articleenhancer/regexenhancers.json' ); - foreach(json_decode($regexEnhancerConfig, true) as $feed => $config) { + $regexEnhancerConfig = json_decode($regexEnhancerConfig, true); + foreach($regexEnhancerConfig as $feed => $config) { foreach ($config as $matchArticleUrl => $regex) { - $articleEnhancer = new RegexArticleEnhancer($matchArticleUrl, $regex); + $articleEnhancer = + new RegexArticleEnhancer($matchArticleUrl, $regex); $enhancer->registerEnhancer($feed, $articleEnhancer); } } - $enhancer->registerGlobalEnhancer($c->query('GlobalArticleEnhancer')); + $enhancer->registerGlobalEnhancer( + $c->query('GlobalArticleEnhancer') + ); return $enhancer; }); diff --git a/appinfo/routes.php b/appinfo/routes.php index 4287bd4a9..ac309a5ea 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -18,81 +18,317 @@ use \OCA\News\AppInfo\Application; $application = new Application(); $application->registerRoutes($this, ['routes' => [ // page - ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], - ['name' => 'page#settings', 'url' => '/settings', 'verb' => 'GET'], - ['name' => 'page#update_settings', 'url' => '/settings', 'verb' => 'PUT'], - ['name' => 'page#manifest', 'url' => '/manifest.webapp', 'verb' => 'GET'], + [ + 'name' => 'page#index', + 'url' => '/', + 'verb' => 'GET' + ], + [ + 'name' => 'page#settings', + 'url' => '/settings', + 'verb' => 'GET' + ], + [ + 'name' => 'page#update_settings', + 'url' => '/settings', + 'verb' => 'PUT' + ], + [ + 'name' => 'page#manifest', + 'url' => '/manifest.webapp', + 'verb' => 'GET' + ], // admin - ['name' => 'admin#update', 'url' => '/admin', 'verb' => 'PUT'], + [ + 'name' => 'admin#update', + 'url' => '/admin', + 'verb' => 'PUT' + ], // folders - ['name' => 'folder#index', 'url' => '/folders', 'verb' => 'GET'], - ['name' => 'folder#create', 'url' => '/folders', 'verb' => 'POST'], - ['name' => 'folder#delete', 'url' => '/folders/{folderId}', 'verb' => 'DELETE'], - ['name' => 'folder#restore', 'url' => '/folders/{folderId}/restore', 'verb' => 'POST'], - ['name' => 'folder#rename', 'url' => '/folders/{folderId}/rename', 'verb' => 'POST'], - ['name' => 'folder#read', 'url' => '/folders/{folderId}/read', 'verb' => 'POST'], - ['name' => 'folder#open', 'url' => '/folders/{folderId}/open', 'verb' => 'POST'], + [ + 'name' => 'folder#index', + 'url' => '/folders', + 'verb' => 'GET' + ], + [ + 'name' => 'folder#create', + 'url' => '/folders', + 'verb' => 'POST' + ], + [ + 'name' => 'folder#delete', + 'url' => '/folders/{folderId}', + 'verb' => 'DELETE' + ], + [ + 'name' => 'folder#restore', + 'url' => '/folders/{folderId}/restore', + 'verb' => 'POST' + ], + [ + 'name' => 'folder#rename', + 'url' => '/folders/{folderId}/rename', + 'verb' => 'POST' + ], + [ + 'name' => 'folder#read', + 'url' => '/folders/{folderId}/read', + 'verb' => 'POST' + ], + [ + 'name' => 'folder#open', + 'url' => '/folders/{folderId}/open', + 'verb' => 'POST' + ], // feeds - ['name' => 'feed#index', 'url' => '/feeds', 'verb' => 'GET'], - ['name' => 'feed#create', 'url' => '/feeds', 'verb' => 'POST'], - ['name' => 'feed#delete', 'url' => '/feeds/{feedId}', 'verb' => 'DELETE'], - ['name' => 'feed#restore', 'url' => '/feeds/{feedId}/restore', 'verb' => 'POST'], - ['name' => 'feed#move', 'url' => '/feeds/{feedId}/move', 'verb' => 'POST'], - ['name' => 'feed#rename', 'url' => '/feeds/{feedId}/rename', 'verb' => 'POST'], - ['name' => 'feed#read', 'url' => '/feeds/{feedId}/read', 'verb' => 'POST'], - ['name' => 'feed#update', 'url' => '/feeds/{feedId}/update', 'verb' => 'POST'], - ['name' => 'feed#active', 'url' => '/feeds/active', 'verb' => 'GET'], - ['name' => 'feed#import', 'url' => '/feeds/import/articles', 'verb' => 'POST'], + [ + 'name' => 'feed#index', + 'url' => '/feeds', + 'verb' => 'GET' + ], + [ + 'name' => 'feed#create', + 'url' => '/feeds', + 'verb' => 'POST' + ], + [ + 'name' => 'feed#delete', + 'url' => '/feeds/{feedId}', + 'verb' => 'DELETE' + ], + [ + 'name' => 'feed#restore', + 'url' => '/feeds/{feedId}/restore', + 'verb' => 'POST' + ], + [ + 'name' => 'feed#move', + 'url' => '/feeds/{feedId}/move', + 'verb' => 'POST' + ], + [ + 'name' => 'feed#rename', + 'url' => '/feeds/{feedId}/rename', + 'verb' => 'POST' + ], + [ + 'name' => 'feed#read', + 'url' => '/feeds/{feedId}/read', + 'verb' => 'POST' + ], + [ + 'name' => 'feed#update', + 'url' => '/feeds/{feedId}/update', + 'verb' => 'POST' + ], + [ + 'name' => 'feed#active', + 'url' => '/feeds/active', + 'verb' => 'GET' + ], + [ + 'name' => 'feed#import', + 'url' => '/feeds/import/articles', + 'verb' => 'POST' + ], // items - ['name' => 'item#index', 'url' => '/items', 'verb' => 'GET'], - ['name' => 'item#new_items', 'url' => '/items/new', 'verb' => 'GET'], - ['name' => 'item#readAll', 'url' => '/items/read', 'verb' => 'POST'], - ['name' => 'item#read', 'url' => '/items/{itemId}/read', 'verb' => 'POST'], - ['name' => 'item#read_multiple', 'url' => '/items/read/multiple', 'verb' => 'POST'], - ['name' => 'item#star', 'url' => '/items/{feedId}/{guidHash}/star', 'verb' => 'POST'], + [ + 'name' => 'item#index', + 'url' => '/items', + 'verb' => 'GET' + ], + [ + 'name' => 'item#new_items', + 'url' => '/items/new', + 'verb' => 'GET' + ], + [ + 'name' => 'item#readAll', + 'url' => '/items/read', + 'verb' => 'POST' + ], + [ + 'name' => 'item#read', + 'url' => '/items/{itemId}/read', + 'verb' => 'POST' + ], + [ + 'name' => 'item#read_multiple', + 'url' => '/items/read/multiple', + 'verb' => 'POST' + ], + [ + 'name' => 'item#star', + 'url' => '/items/{feedId}/{guidHash}/star', + 'verb' => 'POST' + ], // export - ['name' => 'export#opml', 'url' => '/export/opml', 'verb' => 'GET'], - ['name' => 'export#articles', 'url' => '/export/articles', 'verb' => 'GET'], + [ + 'name' => 'export#opml', + 'url' => '/export/opml', + 'verb' => 'GET' + ], + [ + 'name' => 'export#articles', + 'url' => '/export/articles', + 'verb' => 'GET' + ], // API 1.2 - ['name' => 'utility_api#version', 'url' => '/api/v1-2/version', 'verb' => 'GET'], - ['name' => 'utility_api#before_update', 'url' => '/api/v1-2/cleanup/before-update', 'verb' => 'GET'], - ['name' => 'utility_api#after_update', 'url' => '/api/v1-2/cleanup/after-update', 'verb' => 'GET'], - ['name' => 'utility_api#preflighted_cors', 'url' => '/api/v1-2/{path}', 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']], + [ + 'name' => 'utility_api#version', + 'url' => '/api/v1-2/version', + 'verb' => 'GET' + ], + [ + 'name' => 'utility_api#before_update', + 'url' => '/api/v1-2/cleanup/before-update', + 'verb' => 'GET' + ], + [ + 'name' => 'utility_api#after_update', + 'url' => '/api/v1-2/cleanup/after-update', + 'verb' => 'GET' + ], + [ + 'name' => 'utility_api#preflighted_cors', + 'url' => '/api/v1-2/{path}', + 'verb' => 'OPTIONS' + , 'requirements' => ['path' => '.+']], // folders - ['name' => 'folder_api#index', 'url' => '/api/v1-2/folders', 'verb' => 'GET'], - ['name' => 'folder_api#create', 'url' => '/api/v1-2/folders', 'verb' => 'POST'], - ['name' => 'folder_api#update', 'url' => '/api/v1-2/folders/{folderId}', 'verb' => 'PUT'], - ['name' => 'folder_api#delete', 'url' => '/api/v1-2/folders/{folderId}', 'verb' => 'DELETE'], - ['name' => 'folder_api#read', 'url' => '/api/v1-2/folders/{folderId}/read', 'verb' => 'PUT'], // FIXME: POST would be more correct + [ + 'name' => 'folder_api#index', + 'url' => '/api/v1-2/folders', + 'verb' => 'GET' + ], + [ + 'name' => 'folder_api#create', + 'url' => '/api/v1-2/folders', + 'verb' => 'POST' + ], + [ + 'name' => 'folder_api#update', + 'url' => '/api/v1-2/folders/{folderId}', + 'verb' => 'PUT' + ], + [ + 'name' => 'folder_api#delete', + 'url' => '/api/v1-2/folders/{folderId}', + 'verb' => 'DELETE' + ], + [ + 'name' => 'folder_api#read', + 'url' => '/api/v1-2/folders/{folderId}/read', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct // feeds - ['name' => 'feed_api#index', 'url' => '/api/v1-2/feeds', 'verb' => 'GET'], - ['name' => 'feed_api#create', 'url' => '/api/v1-2/feeds', 'verb' => 'POST'], - ['name' => 'feed_api#update', 'url' => '/api/v1-2/feeds/{feedId}', 'verb' => 'PUT'], - ['name' => 'feed_api#delete', 'url' => '/api/v1-2/feeds/{feedId}', 'verb' => 'DELETE'], - ['name' => 'feed_api#from_all_users', 'url' => '/api/v1-2/feeds/all', 'verb' => 'GET'], - ['name' => 'feed_api#move', 'url' => '/api/v1-2/feeds/{feedId}/move', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'feed_api#rename', 'url' => '/api/v1-2/feeds/{feedId}/rename', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'feed_api#read', 'url' => '/api/v1-2/feeds/{feedId}/read', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'feed_api#update', 'url' => '/api/v1-2/feeds/update', 'verb' => 'GET'], + [ + 'name' => 'feed_api#index', + 'url' => '/api/v1-2/feeds', + 'verb' => 'GET' + ], + [ + 'name' => 'feed_api#create', + 'url' => '/api/v1-2/feeds', + 'verb' => 'POST' + ], + [ + 'name' => 'feed_api#update', + 'url' => '/api/v1-2/feeds/{feedId}', + 'verb' => 'PUT' + ], + [ + 'name' => 'feed_api#delete', + 'url' => '/api/v1-2/feeds/{feedId}', + 'verb' => 'DELETE' + ], + [ + 'name' => 'feed_api#from_all_users', + 'url' => '/api/v1-2/feeds/all', + 'verb' => 'GET' + ], + [ + 'name' => 'feed_api#move', + 'url' => '/api/v1-2/feeds/{feedId}/move', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'feed_api#rename', + 'url' => '/api/v1-2/feeds/{feedId}/rename', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'feed_api#read', + 'url' => '/api/v1-2/feeds/{feedId}/read', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'feed_api#update', + 'url' => '/api/v1-2/feeds/update', + 'verb' => 'GET' + ], // items - ['name' => 'item_api#index', 'url' => '/api/v1-2/items', 'verb' => 'GET'], - ['name' => 'item_api#updated', 'url' => '/api/v1-2/items/updated', 'verb' => 'GET'], - ['name' => 'item_api#read', 'url' => '/api/v1-2/items/{itemId}/read', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#unread', 'url' => '/api/v1-2/items/{itemId}/unread', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#read_all', 'url' => '/api/v1-2/items/read', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#read_multiple', 'url' => '/api/v1-2/items/read/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#unread_multiple', 'url' => '/api/v1-2/items/unread/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#star', 'url' => '/api/v1-2/items/{feedId}/{guidHash}/star', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#unstar', 'url' => '/api/v1-2/items/{feedId}/{guidHash}/unstar', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#star_multiple', 'url' => '/api/v1-2/items/star/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct - ['name' => 'item_api#unstar_multiple', 'url' => '/api/v1-2/items/unstar/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct + [ + 'name' => 'item_api#index', + 'url' => '/api/v1-2/items', + 'verb' => 'GET' + ], + [ + 'name' => 'item_api#updated', + 'url' => '/api/v1-2/items/updated', + 'verb' => 'GET' + ], + [ + 'name' => 'item_api#read', + 'url' => '/api/v1-2/items/{itemId}/read', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#unread', + 'url' => '/api/v1-2/items/{itemId}/unread', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#read_all', + 'url' => '/api/v1-2/items/read', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#read_multiple', + 'url' => '/api/v1-2/items/read/multiple', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#unread_multiple', + 'url' => '/api/v1-2/items/unread/multiple', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#star', + 'url' => '/api/v1-2/items/{feedId}/{guidHash}/star', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#unstar', + 'url' => '/api/v1-2/items/{feedId}/{guidHash}/unstar', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#star_multiple', + 'url' => '/api/v1-2/items/star/multiple', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct + [ + 'name' => 'item_api#unstar_multiple', + 'url' => '/api/v1-2/items/unstar/multiple', + 'verb' => 'PUT' + ], // FIXME: POST would be more correct ]]); diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php index b556a285a..4c01a238c 100644 --- a/articleenhancer/globalarticleenhancer.php +++ b/articleenhancer/globalarticleenhancer.php @@ -49,7 +49,8 @@ class GlobalArticleEnhancer implements ArticleEnhancer { // src needs to be matched against regex to prevent false positives // and because theres no XPath matches function available $src = $element->getAttribute('src'); - $regex = '%^(http://|https://|//)(www\.)?youtube.com/.*\?.*autoplay=1.*%i'; + $regex = '%^(http://|https://|//)(www\.)?youtube.com/' . + '.*\?.*autoplay=1.*%i'; if (preg_match($regex, $src)) { $replaced = str_replace('autoplay=1', 'autoplay=0', $src); diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 7d80868f5..7dcb9a340 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -64,8 +64,10 @@ class XPathArticleEnhancer implements ArticleEnhancer { $contentType = $file->headers['content-type']; $body = $file->body; - if( preg_match( '/(?<=charset=)[^;]*/', $contentType, $matches ) ) { - $body = mb_convert_encoding($body, 'HTML-ENTITIES', $matches[0]); + if(preg_match('/(?<=charset=)[^;]*/', $contentType, $matches)) { + $encoding = $matches[0]; + $body = mb_convert_encoding($body, 'HTML-ENTITIES', + $encoding); } $dom = new DOMDocument(); @@ -86,7 +88,9 @@ class XPathArticleEnhancer implements ArticleEnhancer { $xpathResult = trim($xpathResult); // convert all relative to absolute URLs - $xpathResult = $this->substituteRelativeLinks($xpathResult, $item->getUrl()); + $xpathResult = $this->substituteRelativeLinks( + $xpathResult, $item->getUrl() + ); if($xpathResult) { $item->setBody($xpathResult); @@ -108,8 +112,10 @@ class XPathArticleEnhancer implements ArticleEnhancer { /** * Method which converts all relative "href" and "src" URLs of * a HTML snippet with their absolute equivalent - * @param string $xmlString a HTML snippet as string with the relative URLs to be replaced - * @param string $absoluteUrl the approptiate absolute url of the HTML snippet + * @param string $xmlString a HTML snippet as string with the relative URLs + * to be replaced + * @param string $absoluteUrl the approptiate absolute url of the HTML + * snippet * @return string the result HTML snippet as a string */ protected function substituteRelativeLinks($xmlString, $absoluteUrl) { @@ -136,14 +142,17 @@ class XPathArticleEnhancer implements ArticleEnhancer { "and not(starts-with(@" . $attribute . ", '//'))]"); foreach ($xpathResult as $linkNode) { $urlElement = $linkNode->attributes->getNamedItem($attribute); - $abs = $this->relativeToAbsoluteUrl($urlElement->nodeValue, $absoluteUrl); + $abs = $this->relativeToAbsoluteUrl( + $urlElement->nodeValue, $absoluteUrl + ); $urlElement->nodeValue = htmlspecialchars($abs); } } $xmlString = $dom->saveHTML(); - // domdocument spoils the string with line breaks between the elements. strip them. + // domdocument spoils the string with line breaks between the elements + // strip them $xmlString = str_replace("\n", '', $xmlString); return $xmlString; @@ -153,9 +162,6 @@ class XPathArticleEnhancer implements ArticleEnhancer { /** * Method which builds a URL by taking a relative URL and its corresponding * absolute URL - * For example relative URL "../example/path/file.php?a=1#anchor" and - * absolute URL "https://username:password@www.website.com/subfolder/index.html" - * will result in "https://username:password@www.website.com/example/path/file.php?a=1#anchor" * @param string $relativeUrl the relative URL * @param string $absoluteUrl the absolute URL with at least scheme and host * @return string the resulting absolute URL diff --git a/config/appconfig.php b/config/appconfig.php index a9045eb9a..62e1490ee 100644 --- a/config/appconfig.php +++ b/config/appconfig.php @@ -52,7 +52,8 @@ class AppConfig { /** - * @param string|array $data path to the config file or an array with the config + * @param string|array $data path to the config file or an array with the + * config */ public function loadConfig($data) { if(is_array($data)) { @@ -122,7 +123,8 @@ class AppConfig { 'name' => $nav['name'] ]; - $navConfig['href'] = $this->urlGenerator->linkToRoute($nav['route']); + $navConfig['href'] = + $this->urlGenerator->linkToRoute($nav['route']); $navConfig['icon'] = $this->urlGenerator->imagePath($nav['id'], $nav['icon']); @@ -157,8 +159,8 @@ class AppConfig { * Registers all hooks in the config */ public function registerHooks() { - // FIXME: this is temporarily static because core emitters are not future - // proof, therefore legacy code in here + // FIXME: this is temporarily static because core emitters are not + // future proof, therefore legacy code in here foreach ($this->config['hooks'] as $listen => $react) { $listener = explode('::', $listen); $reaction = explode('::', $react); @@ -200,10 +202,13 @@ class AppConfig { if (array_key_exists('libs', $deps)) { foreach ($deps['libs'] as $lib => $versions) { if(array_key_exists($lib, $this->installedExtensions)) { - return $this->requireVersion($this->installedExtensions[$lib], - $versions, 'PHP extension ' . $lib); + return $this->requireVersion( + $this->installedExtensions[$lib], + $versions, 'PHP extension ' . $lib + ); } else { - return 'PHP extension ' . $lib . ' required but not installed'; + return 'PHP extension ' . $lib . + ' required but not installed'; } } } @@ -249,9 +254,11 @@ class AppConfig { if($version['version'] === '*') { continue; } - if(!version_compare($actual, $version['version'], $version['operator'])) { - return $versionType . ' Version not satisfied: ' . $version['operator'] . - $version['version'] . ' required but found ' . $actual . '\n'; + $operator = $version['operator']; + $requiredVersion = $version['version']; + if(!version_compare($actual, $requiredVersion, $operator)) { + return $versionType . ' Version not satisfied: ' . $operator . + $requiredVersion . ' required but found ' . $actual . '\n'; } } @@ -270,7 +277,8 @@ class AppConfig { $versions = explode(',', $versions); foreach($versions as $version) { - preg_match('/^(?<|<=|>=|>|<>)?(?.*)$/', $version, $matches); + preg_match('/^(?<|<=|>=|>|<>)?(?.*)$/', $version, + $matches); if($matches['operator'] !== '') { $required = [ 'version' => $matches['version'], diff --git a/config/config.php b/config/config.php index 25e8a2294..44650c3ac 100644 --- a/config/config.php +++ b/config/config.php @@ -156,8 +156,10 @@ class Config { $configValues = parse_ini_string($content); if($configValues === false || count($configValues) === 0) { - $this->logger->warning('Configuration invalid. Ignoring values.', - $this->loggerParams); + $this->logger->warning( + 'Configuration invalid. Ignoring values.', + $this->loggerParams + ); } else { foreach($configValues as $key => $value) { @@ -166,8 +168,11 @@ class Config { settype($value, $type); $this->$key = $value; } else { - $this->logger->warning('Configuration value "' . $key . - '" does not exist. Ignored value.' , $this->loggerParams); + $this->logger->warning( + 'Configuration value "' . $key . + '" does not exist. Ignored value.' , + $this->loggerParams + ); } } @@ -178,15 +183,21 @@ class Config { public function write($configPath) { $ini = - "autoPurgeMinimumInterval = " . $this->autoPurgeMinimumInterval . "\n" . - "autoPurgeCount = " . $this->autoPurgeCount . "\n" . - "simplePieCacheDuration = " . $this->simplePieCacheDuration . "\n" . - "feedFetcherTimeout = " . $this->feedFetcherTimeout . "\n" . - "useCronUpdates = " . var_export($this->useCronUpdates, true) . "\n" . - "proxyHost = " . $this->proxyHost . "\n" . - "proxyPort = " . $this->proxyPort . "\n" . - "proxyUser = " . $this->proxyUser . "\n" . - "proxyPassword = " . $this->proxyPassword; + 'autoPurgeMinimumInterval = ' . + $this->autoPurgeMinimumInterval . "\n" . + 'autoPurgeCount = ' . + $this->autoPurgeCount . "\n" . + 'simplePieCacheDuration = ' . + $this->simplePieCacheDuration . "\n" . + 'feedFetcherTimeout = ' . + $this->feedFetcherTimeout . "\n" . + 'useCronUpdates = ' . + var_export($this->useCronUpdates, true) . "\n" . + + 'proxyHost = ' . $this->proxyHost . "\n" . + 'proxyPort = ' . $this->proxyPort . "\n" . + 'proxyUser = ' . $this->proxyUser . "\n" . + 'proxyPassword = ' . $this->proxyPassword; ; $this->fileSystem->file_put_contents($configPath, $ini); diff --git a/controller/admincontroller.php b/controller/admincontroller.php index cd3ae9df4..71bcf0d29 100644 --- a/controller/admincontroller.php +++ b/controller/admincontroller.php @@ -35,7 +35,8 @@ class AdminController extends Controller { // in admin/admin.php public function index() { $data = [ - 'autoPurgeMinimumInterval' => $this->config->getAutoPurgeMinimumInterval(), + 'autoPurgeMinimumInterval' => + $this->config->getAutoPurgeMinimumInterval(), 'autoPurgeCount' => $this->config->getAutoPurgeCount(), 'cacheDuration' => $this->config->getSimplePieCacheDuration(), 'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), @@ -64,7 +65,8 @@ class AdminController extends Controller { $this->config->write($this->configPath); return [ - 'autoPurgeMinimumInterval' => $this->config->getAutoPurgeMinimumInterval(), + 'autoPurgeMinimumInterval' => + $this->config->getAutoPurgeMinimumInterval(), 'autoPurgeCount' => $this->config->getAutoPurgeCount(), 'cacheDuration' => $this->config->getSimplePieCacheDuration(), 'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(), diff --git a/controller/exportcontroller.php b/controller/exportcontroller.php index 1d0f7086c..b1d62f015 100644 --- a/controller/exportcontroller.php +++ b/controller/exportcontroller.php @@ -56,7 +56,9 @@ class ExportController extends Controller { $feeds = $this->feedService->findAll($this->userId); $folders = $this->folderService->findAll($this->userId); $opml = $this->opmlExporter->build($folders, $feeds)->saveXML(); - return new TextDownloadResponse($opml, 'subscriptions.opml', 'text/xml'); + $name = 'subscriptions.opml'; + $mimeType = 'text/xml'; + return new TextDownloadResponse($opml, $name, $mimeType); } diff --git a/controller/feedapicontroller.php b/controller/feedapicontroller.php index c75cd5879..2e48b5afe 100644 --- a/controller/feedapicontroller.php +++ b/controller/feedapicontroller.php @@ -66,7 +66,8 @@ class FeedApiController extends ApiController { try { - $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId); + $result['newestItemId'] = + $this->itemService->getNewestItemId($this->userId); // in case there are no items, ignore } catch(ServiceNotFoundException $ex) {} @@ -92,7 +93,8 @@ class FeedApiController extends ApiController { $result = ['feeds' => [$feed]]; try { - $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId); + $result['newestItemId'] = + $this->itemService->getNewestItemId($this->userId); // in case there are no items, ignore } catch(ServiceNotFoundException $ex) {} @@ -207,7 +209,7 @@ class FeedApiController extends ApiController { public function update($userId, $feedId) { try { $this->feedService->update($feedId, $userId); - // ignore update failure (feed could not be reachable etc, we don't care) + // ignore update failure } catch(\Exception $ex) { $this->logger->debug('Could not update feed ' . $ex->getMessage(), $this->loggerParams); diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php index d5ccc7c62..e5ad9a24f 100644 --- a/controller/foldercontroller.php +++ b/controller/foldercontroller.php @@ -148,7 +148,9 @@ class FolderController extends Controller { * @return array */ public function read($folderId, $highestItemId) { - $this->itemService->readFolder($folderId, $highestItemId, $this->userId); + $this->itemService->readFolder( + $folderId, $highestItemId, $this->userId + ); return ['feeds' => $this->feedService->findAll($this->userId)]; } diff --git a/controller/itemapicontroller.php b/controller/itemapicontroller.php index 3674d644c..187a2b6b1 100644 --- a/controller/itemapicontroller.php +++ b/controller/itemapicontroller.php @@ -120,7 +120,9 @@ class ItemApiController extends ApiController { private function setStarred($isStarred, $feedId, $guidHash) { try { - $this->itemService->star($feedId, $guidHash, $isStarred, $this->userId); + $this->itemService->star( + $feedId, $guidHash, $isStarred, $this->userId + ); } catch(ServiceNotFoundException $ex){ return $this->error($ex, Http::STATUS_NOT_FOUND); } diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index 89dd51d03..4aee6402a 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -59,8 +59,8 @@ class ItemController extends Controller { public function index($type, $id, $limit=50, $offset=0) { $showAll = $this->settings->getUserValue($this->userId, $this->appName, 'showAll') === '1'; - $oldestFirst = $this->settings->getUserValue($this->userId, $this->appName, - 'oldestFirst') === '1'; + $oldestFirst = $this->settings->getUserValue($this->userId, + $this->appName, 'oldestFirst') === '1'; $this->settings->setUserValue($this->userId, $this->appName, 'lastViewedFeedId', $id); @@ -78,7 +78,8 @@ class ItemController extends Controller { $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId); $params['feeds'] = $this->feedService->findAll($this->userId); - $params['starred'] = $this->itemService->starredCount($this->userId); + $params['starred'] = + $this->itemService->starredCount($this->userId); } $params['items'] = $this->itemService->findAll( @@ -109,9 +110,11 @@ class ItemController extends Controller { $params = []; try { - $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId); + $params['newestItemId'] = + $this->itemService->getNewestItemId($this->userId); $params['feeds'] = $this->feedService->findAll($this->userId); - $params['starred'] = $this->itemService->starredCount($this->userId); + $params['starred'] = + $this->itemService->starredCount($this->userId); $params['items'] = $this->itemService->findAllNew($id, $type, $lastModified, $showAll, $this->userId); diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php index 90f702d49..f55900a39 100644 --- a/controller/pagecontroller.php +++ b/controller/pagecontroller.php @@ -59,7 +59,12 @@ class PageController extends Controller { * @NoAdminRequired */ public function settings() { - $settings = ['showAll', 'compact', 'preventReadOnScroll', 'oldestFirst']; + $settings = [ + 'showAll', + 'compact', + 'preventReadOnScroll', + 'oldestFirst' + ]; $result = ['language' => $this->l10n->getLanguageCode()]; @@ -80,8 +85,13 @@ class PageController extends Controller { * @param bool $preventReadOnScroll * @param bool $oldestFirst */ - public function updateSettings($showAll, $compact, $preventReadOnScroll, $oldestFirst) { - $settings = ['showAll', 'compact', 'preventReadOnScroll', 'oldestFirst']; + public function updateSettings($showAll, $compact, $preventReadOnScroll, + $oldestFirst) { + $settings = ['showAll', + 'compact', + 'preventReadOnScroll', + 'oldestFirst' + ]; foreach ($settings as $setting) { $this->settings->setUserValue($this->userId, $this->appName, diff --git a/db/feedmapper.php b/db/feedmapper.php index ab55c6f1b..0d00057d3 100644 --- a/db/feedmapper.php +++ b/db/feedmapper.php @@ -30,18 +30,19 @@ class FeedMapper extends NewsMapper { 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . 'ON `feeds`.`id` = `items`.`feed_id` ' . - // WARNING: this is a desperate attempt at making this query work - // because prepared statements dont work. This is a possible - // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. + // WARNING: this is a desperate attempt at making this query + // work because prepared statements dont work. This is a + // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . StatusFlag::UNREAD . ' ' . 'WHERE `feeds`.`id` = ? ' . 'AND `feeds`.`user_id` = ? ' . - 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. - '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`, '. + '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '. + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $params = [$id, $userId]; return $this->findEntity($sql, $params); @@ -55,9 +56,9 @@ class FeedMapper extends NewsMapper { 'ON `feeds`.`folder_id` = `folders`.`id` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . 'ON `feeds`.`id` = `items`.`feed_id` ' . - // WARNING: this is a desperate attempt at making this query work - // because prepared statements dont work. This is a possible - // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. + // WARNING: this is a desperate attempt at making this query + // work because prepared statements dont work. This is a + // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . StatusFlag::UNREAD . ' ' . @@ -68,8 +69,9 @@ class FeedMapper extends NewsMapper { 'AND `feeds`.`deleted_at` = 0 ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $params = [$userId]; return $this->findEntities($sql, $params); @@ -83,9 +85,9 @@ class FeedMapper extends NewsMapper { 'ON `feeds`.`folder_id` = `folders`.`id` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . 'ON `feeds`.`id` = `items`.`feed_id` ' . - // WARNING: this is a desperate attempt at making this query work - // because prepared statements don't work. This is a possible - // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. + // WARNING: this is a desperate attempt at making this query + // work because prepared statements dont work. This is a + // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . StatusFlag::UNREAD . ' ' . @@ -95,8 +97,9 @@ class FeedMapper extends NewsMapper { 'AND `feeds`.`deleted_at` = 0 ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; return $this->findEntities($sql); } @@ -107,9 +110,9 @@ class FeedMapper extends NewsMapper { 'FROM `*PREFIX*news_feeds` `feeds` ' . 'LEFT JOIN `*PREFIX*news_items` `items` ' . 'ON `feeds`.`id` = `items`.`feed_id` ' . - // WARNING: this is a desperate attempt at making this query work - // because prepared statements dont work. This is a possible - // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. + // WARNING: this is a desperate attempt at making this query + // work because prepared statements dont work. This is a + // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT. // think twice when changing this 'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' . StatusFlag::UNREAD . ' ' . @@ -117,8 +120,9 @@ class FeedMapper extends NewsMapper { 'AND `feeds`.`user_id` = ? ' . 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'. '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'. - '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'. - '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`'; + '`feeds`.`favicon_link`, `feeds`.`added`, ' . + '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' . + '`feeds`.`prevent_update`, `feeds`.`deleted_at`'; $params = [$hash, $userId]; return $this->findEntity($sql, $params); diff --git a/db/item.php b/db/item.php index 5c353b058..8a8b19e59 100644 --- a/db/item.php +++ b/db/item.php @@ -209,7 +209,8 @@ class Item extends Entity implements IAPI, \JsonSerializable { public function setBody($body) { - // FIXME: this should not happen if the target="_blank" is already on the link + // FIXME: this should not happen if the target="_blank" is already + // on the link parent::setBody(str_replace('getOperator($oldestFirst) . ' ? '; + $sql .= 'AND `items`.`id` ' . + $this->getOperator($oldestFirst) . ' ? '; $params[] = $offset; } $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst); @@ -183,11 +186,13 @@ class ItemMapper extends NewsMapper { } - public function findAllFolder($id, $limit, $offset, $status, $oldestFirst, $userId){ + public function findAllFolder($id, $limit, $offset, $status, $oldestFirst, + $userId){ $params = [$userId, $id]; $sql = 'AND `feeds`.`folder_id` = ? '; if($offset !== 0){ - $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? '; + $sql .= 'AND `items`.`id` ' . + $this->getOperator($oldestFirst) . ' ? '; $params[] = $offset; } $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst); @@ -199,7 +204,8 @@ class ItemMapper extends NewsMapper { $params = [$userId]; $sql = ''; if($offset !== 0){ - $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? '; + $sql .= 'AND `items`.`id` ' . + $this->getOperator($oldestFirst) . ' ? '; $params[] = $offset; } $sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst); @@ -262,7 +268,8 @@ class ItemMapper extends NewsMapper { public function getNewestItemId($userId) { - $sql = 'SELECT MAX(`items`.`id`) AS `max_id` FROM `*PREFIX*news_items` `items` '. + $sql = 'SELECT MAX(`items`.`id`) AS `max_id` ' . + 'FROM `*PREFIX*news_items` `items` '. 'JOIN `*PREFIX*news_feeds` `feeds` ' . 'ON `feeds`.`id` = `items`.`feed_id` '. 'AND `feeds`.`user_id` = ?'; diff --git a/fetcher/feedfetcher.php b/fetcher/feedfetcher.php index 648cb90d8..c658dd36c 100644 --- a/fetcher/feedfetcher.php +++ b/fetcher/feedfetcher.php @@ -64,8 +64,8 @@ class FeedFetcher implements IFeedFetcher { /** * Fetch a feed from remote * @param string $url remote url of the feed - * @param boolean $getFavicon if the favicon should also be fetched, defaults - * to true + * @param boolean $getFavicon if the favicon should also be fetched, + * defaults to true * @throws FetcherException if simple pie fails * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items @@ -74,9 +74,12 @@ class FeedFetcher implements IFeedFetcher { $simplePie = $this->simplePieFactory->getCore(); $simplePie->set_feed_url($url); $simplePie->enable_cache(true); - $simplePie->set_useragent('ownCloud News/' . + $simplePie->set_useragent( + 'ownCloud News/' . $this->appConfig->getConfig('version') . - ' (+https://owncloud.org/; 1 subscriber; feed-url=' . $url . ')'); + ' (+https://owncloud.org/; 1 subscriber; ' . + 'feed-url=' . $url . ')' + ); $simplePie->set_stupidly_fast(true); // disable simple pie sanitation // we use htmlpurifier $simplePie->set_timeout($this->fetchTimeout); @@ -91,7 +94,9 @@ class FeedFetcher implements IFeedFetcher { try { if (!$simplePie->init()) { - throw new \Exception('Could not initialize simple pie on feed with url ' . $url); + throw new \Exception( + 'Could not initialize simple pie on feed with url ' . $url + ); } // somehow $simplePie turns into a feed after init @@ -204,7 +209,8 @@ class FeedFetcher implements IFeedFetcher { $feed->setAdded($this->time->getTime()); if ($getFavicon) { - // use the favicon from the page first since most feeds use a weird image + // use the favicon from the page first since most feeds use a weird + // image $favicon = $this->faviconFetcher->fetch($feed->getLink()); if (!$favicon) { diff --git a/fetcher/fetcher.php b/fetcher/fetcher.php index 4b4c09e1c..ae46d6212 100644 --- a/fetcher/fetcher.php +++ b/fetcher/fetcher.php @@ -34,8 +34,8 @@ class Fetcher { /** * Fetch a feed from remote * @param string $url remote url of the feed - * @param boolean $getFavicon if the favicon should also be fetched, defaults - * to true + * @param boolean $getFavicon if the favicon should also be fetched, + * defaults to true * @throws FetcherException if simple pie fails * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items diff --git a/fetcher/ifeedfetcher.php b/fetcher/ifeedfetcher.php index 8869d9292..68b1bcf64 100644 --- a/fetcher/ifeedfetcher.php +++ b/fetcher/ifeedfetcher.php @@ -17,8 +17,8 @@ interface IFeedFetcher { /** * @param string $url remote url of the feed - * @param boolean $getFavicon if the favicon should also be fetched, defaults - * to true + * @param boolean $getFavicon if the favicon should also be fetched, + * defaults to true * @throws FetcherException if the fetcher encounters a problem * @return array an array containing the new feed and its items, first * element being the Feed and second element being an array of Items diff --git a/http/textdownloadresponse.php b/http/textdownloadresponse.php index 9a90e6454..ccf959b5b 100644 --- a/http/textdownloadresponse.php +++ b/http/textdownloadresponse.php @@ -28,7 +28,8 @@ class TextDownloadResponse extends DownloadResponse { * contains the passed string * @param string $content the content that should be written into the file * @param string $filename the name that the downloaded file should have - * @param string $contentType the mimetype that the downloaded file should have + * @param string $contentType the mimetype that the downloaded file should + * have */ public function __construct($content, $filename, $contentType){ parent::__construct($filename, $contentType); diff --git a/service/feedservice.php b/service/feedservice.php index ca3335396..872f05ef8 100644 --- a/service/feedservice.php +++ b/service/feedservice.php @@ -56,7 +56,8 @@ class FeedService extends Service { $this->logger = $logger; $this->l10n = $l10n; $this->timeFactory = $timeFactory; - $this->autoPurgeMinimumInterval = $config->getAutoPurgeMinimumInterval(); + $this->autoPurgeMinimumInterval = + $config->getAutoPurgeMinimumInterval(); $this->enhancer = $enhancer; $this->purifier = $purifier; $this->feedMapper = $feedMapper; @@ -85,7 +86,8 @@ class FeedService extends Service { /** * Creates a new feed * @param string $feedUrl the url to the feed - * @param int $folderId the folder where it should be put into, 0 for root folder + * @param int $folderId the folder where it should be put into, 0 for root + * folder * @param string $userId for which user the feed should be created * @param string $title if given, this is used for the opml feed title * @throws ServiceConflictException if the feed exists already @@ -117,8 +119,8 @@ class FeedService extends Service { $feed = $this->feedMapper->insert($feed); - // insert items in reverse order because the first one is usually the - // newest item + // insert items in reverse order because the first one is usually + // the newest item $unreadCount = 0; for($i=count($items)-1; $i>=0; $i--){ $item = $items[$i]; @@ -146,8 +148,11 @@ class FeedService extends Service { $this->logger->debug($ex->getMessage(), $this->loggerParams); throw new ServiceNotFoundException( $this->l10n->t( - 'Can not add feed: URL does not exist, SSL Certificate can not be validated ' . - 'or feed has invalid xml')); + 'Can not add feed: URL does not exist, ' . + 'SSL Certificate can not be validated ' . + 'or feed has invalid xml' + ) + ); } } @@ -162,8 +167,10 @@ class FeedService extends Service { try { $this->update($feed->getId(), $feed->getUserId()); } catch(\Exception $ex){ - $this->logger->debug('Could not update feed ' . $ex->getMessage(), - $this->loggerParams); + $this->logger->debug( + 'Could not update feed ' . $ex->getMessage(), + $this->loggerParams + ); } } } @@ -194,18 +201,22 @@ class FeedService extends Service { $this->feedMapper->update($existingFeed); } - // insert items in reverse order because the first one is usually - // the newest item + // insert items in reverse order because the first one is + // usually the newest item for($i=count($items)-1; $i>=0; $i--){ $item = $items[$i]; $item->setFeedId($existingFeed->getId()); try { - $this->itemMapper->findByGuidHash($item->getGuidHash(), $feedId, $userId); + $this->itemMapper->findByGuidHash( + $item->getGuidHash(), $feedId, $userId + ); } catch(DoesNotExistException $ex){ $item = $this->enhancer->enhance($item, $existingFeed->getLink()); - $item->setBody($this->purifier->purify($item->getBody())); + $item->setBody( + $this->purifier->purify($item->getBody()) + ); $this->itemMapper->insert($item); } } @@ -213,8 +224,11 @@ class FeedService extends Service { } catch(FetcherException $ex){ // failed updating is not really a problem, so only log it - $this->logger->debug('Can not update feed with url ' . $existingFeed->getUrl() . - ': Not found or bad source', $this->loggerParams); + $this->logger->debug( + 'Can not update feed with url ' . $existingFeed->getUrl() . + ': Not found or bad source', + $this->loggerParams + ); $this->logger->debug($ex->getMessage(), $this->loggerParams); } @@ -230,7 +244,8 @@ class FeedService extends Service { /** * Moves a feed into a different folder * @param int $feedId the id of the feed that should be moved - * @param int $folderId the id of the folder where the feed should be moved to + * @param int $folderId the id of the folder where the feed should be moved + * to * @param string $userId the name of the user whose feed should be moved * @throws ServiceNotFoundException if the feed does not exist */ diff --git a/service/folderservice.php b/service/folderservice.php index eb1e584f5..982837c92 100644 --- a/service/folderservice.php +++ b/service/folderservice.php @@ -34,7 +34,8 @@ class FolderService extends Service { parent::__construct($folderMapper); $this->l10n = $l10n; $this->timeFactory = $timeFactory; - $this->autoPurgeMinimumInterval = $config->getAutoPurgeMinimumInterval(); + $this->autoPurgeMinimumInterval = + $config->getAutoPurgeMinimumInterval(); $this->folderMapper = $folderMapper; } @@ -49,7 +50,8 @@ class FolderService extends Service { private function validateFolder($folderName, $userId){ - $existingFolders = $this->folderMapper->findByName($folderName, $userId); + $existingFolders = + $this->folderMapper->findByName($folderName, $userId); if(count($existingFolders) > 0){ throw new ServiceConflictException( @@ -57,7 +59,9 @@ class FolderService extends Service { } if(mb_strlen($folderName) === 0) { - throw new ServiceValidationException('Folder name can not be empty'); + throw new ServiceValidationException( + 'Folder name can not be empty' + ); } } @@ -66,7 +70,8 @@ class FolderService extends Service { * Creates a new folder * @param string $folderName the name of the folder * @param string $userId the name of the user for whom it should be created - * @param int $parentId the parent folder id, deprecated we don't nest folders + * @param int $parentId the parent folder id, deprecated we don't nest + * folders * @throws ServiceConflictException if name exists already * @throws ServiceValidationException if the folder has invalid parameters * @return Folder the newly created folder diff --git a/service/itemservice.php b/service/itemservice.php index 1b94c089f..628f89206 100644 --- a/service/itemservice.php +++ b/service/itemservice.php @@ -106,13 +106,16 @@ class ItemService extends Service { * Star or unstar an item * @param int $feedId the id of the item's feed that should be starred * @param string $guidHash the guidHash of the item that should be starred - * @param boolean $isStarred if true the item will be marked as starred, if false unstar + * @param boolean $isStarred if true the item will be marked as starred, + * if false unstar * @param string $userId the name of the user for security reasons * @throws ServiceNotFoundException if the item does not exist */ public function star($feedId, $guidHash, $isStarred, $userId){ try { - $item = $this->itemMapper->findByGuidHash($guidHash, $feedId, $userId); + $item = $this->itemMapper->findByGuidHash( + $guidHash, $feedId, $userId + ); $item->setLastModified($this->timeFactory->getTime()); if($isStarred){ @@ -130,7 +133,8 @@ class ItemService extends Service { /** * Read or unread an item * @param int $itemId the id of the item that should be read - * @param boolean $isRead if true the item will be marked as read, if false unread + * @param boolean $isRead if true the item will be marked as read, + * if false unread * @param string $userId the name of the user for security reasons * @throws ServiceNotFoundException if the item does not exist */ @@ -148,8 +152,8 @@ class ItemService extends Service { /** * Set all items read - * @param int $highestItemId all items below that are marked read. This is used - * to prevent marking items as read that the users hasn't seen yet + * @param int $highestItemId all items below that are marked read. This is + * used to prevent marking items as read that the users hasn't seen yet * @param string $userId the name of the user */ public function readAll($highestItemId, $userId){ @@ -161,21 +165,23 @@ class ItemService extends Service { /** * Set a folder read * @param int $folderId the id of the folder that should be marked read - * @param int $highestItemId all items below that are marked read. This is used - * to prevent marking items as read that the users hasn't seen yet + * @param int $highestItemId all items below that are marked read. This is + * used to prevent marking items as read that the users hasn't seen yet * @param string $userId the name of the user */ public function readFolder($folderId, $highestItemId, $userId){ $time = $this->timeFactory->getTime(); - $this->itemMapper->readFolder($folderId, $highestItemId, $time, $userId); + $this->itemMapper->readFolder( + $folderId, $highestItemId, $time, $userId + ); } /** * Set a feed read * @param int $feedId the id of the feed that should be marked read - * @param int $highestItemId all items below that are marked read. This is used - * to prevent marking items as read that