diff options
56 files changed, 564 insertions, 961 deletions
diff --git a/appinfo/app.php b/appinfo/app.php index daf0ec5b4..e50525a5c 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -27,6 +27,6 @@ try { } catch(\OCA\News\Config\DependencyException $e) { $logger = $container->getLogger(); $params = $container->getLoggerParameters(); - $logger->warning($e->getMessage(), $params); + $logger->emergency($e->getMessage(), $params); } diff --git a/appinfo/application.php b/appinfo/application.php index 8b7f46e25..d325adf00 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -243,16 +243,16 @@ class Application extends App { // not performant but well :/ // $config = $c->query('ServerContainer')->getAppConfig(); oc7 only $installedApps = \OC_Appconfig::getApps(); - $apps = array(); + $apps = []; foreach($installedApps as $app) { - $apps[] = array( + $apps[] = [ $app => \OC_Appconfig::getValue($app, 'installed_version', '0') - ); + ]; } // order extensions in name => version $loadedExtensions = get_loaded_extensions(); - $extensions = array(); + $extensions = []; foreach ($loadedExtensions as $extension) { $extensions[$extension] = phpversion($extension); } @@ -285,7 +285,7 @@ class Application extends App { }); $container->registerService('LoggerParameters', function($c) { - return array('app' => $c->query('AppName')); + return ['app' => $c->query('AppName')]; }); $container->registerService('Db', function($c) { diff --git a/appinfo/routes.php b/appinfo/routes.php index 2d59e7ff7..fd9e513d3 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -18,82 +18,82 @@ use \OCP\AppFramework\App; use \OCA\News\AppInfo\Application; $application = new Application(); -$application->registerRoutes($this, array('routes' => array( +$application->registerRoutes($this, ['routes' => [ // page - array('name' => 'page#index', 'url' => '/', 'verb' => 'GET'), - array('name' => 'page#settings', 'url' => '/settings', 'verb' => 'GET'), - array('name' => 'page#update_settings', 'url' => '/settings', 'verb' => 'POST'), + ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], + ['name' => 'page#settings', 'url' => '/settings', 'verb' => 'GET'], + ['name' => 'page#update_settings', 'url' => '/settings', 'verb' => 'POST'], // folders - array('name' => 'folder#index', 'url' => '/folders', 'verb' => 'GET'), - array('name' => 'folder#create', 'url' => '/folders', 'verb' => 'POST'), - array('name' => 'folder#delete', 'url' => '/folders/{folderId}', 'verb' => 'DELETE'), - array('name' => 'folder#restore', 'url' => '/folders/{folderId}/restore', 'verb' => 'POST'), - array('name' => 'folder#rename', 'url' => '/folders/{folderId}/rename', 'verb' => 'POST'), - array('name' => 'folder#read', 'url' => '/folders/{folderId}/read', 'verb' => 'POST'), - array('name' => 'folder#open', 'url' => '/folders/{folderId}/open', 'verb' => 'POST'), - array('name' => 'folder#collapse', 'url' => '/folders/{folderId}/collapse', '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'], + ['name' => 'folder#collapse', 'url' => '/folders/{folderId}/collapse', 'verb' => 'POST'], // feeds - array('name' => 'feed#index', 'url' => '/feeds', 'verb' => 'GET'), - array('name' => 'feed#create', 'url' => '/feeds', 'verb' => 'POST'), - array('name' => 'feed#delete', 'url' => '/feeds/{feedId}', 'verb' => 'DELETE'), - array('name' => 'feed#restore', 'url' => '/feeds/{feedId}/restore', 'verb' => 'POST'), - array('name' => 'feed#move', 'url' => '/feeds/{feedId}/move', 'verb' => 'POST'), - array('name' => 'feed#rename', 'url' => '/feeds/{feedId}/rename', 'verb' => 'POST'), - array('name' => 'feed#read', 'url' => '/feeds/{feedId}/read', 'verb' => 'POST'), - array('name' => 'feed#update', 'url' => '/feeds/{feedId}/update', 'verb' => 'POST'), - array('name' => 'feed#active', 'url' => '/feeds/active', 'verb' => 'GET'), - array('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 - array('name' => 'item#index', 'url' => '/items', 'verb' => 'GET'), - array('name' => 'item#new_items', 'url' => '/items/new', 'verb' => 'GET'), - array('name' => 'item#readAll', 'url' => '/items/read', 'verb' => 'POST'), - array('name' => 'item#read', 'url' => '/items/{itemId}/read', 'verb' => 'POST'), - array('name' => 'item#unread', 'url' => '/items/{itemId}/unread', 'verb' => 'POST'), - array('name' => 'item#star', 'url' => '/items/{feedId}/{guidHash}/star', 'verb' => 'POST'), - array('name' => 'item#unstar', 'url' => '/items/{feedId}/{guidHash}/unstar', '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#unread', 'url' => '/items/{itemId}/unread', 'verb' => 'POST'], + ['name' => 'item#star', 'url' => '/items/{feedId}/{guidHash}/star', 'verb' => 'POST'], + ['name' => 'item#unstar', 'url' => '/items/{feedId}/{guidHash}/unstar', 'verb' => 'POST'], // export - array('name' => 'export#opml', 'url' => '/export/opml', 'verb' => 'GET'), - array('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 - array('name' => 'utility_api#version', 'url' => '/api/v1-2/version', 'verb' => 'GET'), - array('name' => 'utility_api#before_update', 'url' => '/api/v1-2/cleanup/before-update', 'verb' => 'GET'), - array('name' => 'utility_api#after_update', 'url' => '/api/v1-2/cleanup/after-update', 'verb' => 'GET'), - array('name' => 'utility_api#preflighted_cors', 'url' => '/api/v1-2/{path}', 'verb' => 'OPTIONS', 'requirements' => array('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 - array('name' => 'folder_api#index', 'url' => '/api/v1-2/folders', 'verb' => 'GET'), - array('name' => 'folder_api#create', 'url' => '/api/v1-2/folders', 'verb' => 'POST'), - array('name' => 'folder_api#update', 'url' => '/api/v1-2/folders/{folderId}', 'verb' => 'PUT'), - array('name' => 'folder_api#delete', 'url' => '/api/v1-2/folders/{folderId}', 'verb' => 'DELETE'), - array('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 - array('name' => 'feed_api#index', 'url' => '/api/v1-2/feeds', 'verb' => 'GET'), - array('name' => 'feed_api#create', 'url' => '/api/v1-2/feeds', 'verb' => 'POST'), - array('name' => 'feed_api#update', 'url' => '/api/v1-2/feeds/{feedId}', 'verb' => 'PUT'), - array('name' => 'feed_api#delete', 'url' => '/api/v1-2/feeds/{feedId}', 'verb' => 'DELETE'), - array('name' => 'feed_api#from_all_users', 'url' => '/api/v1-2/feeds/all', 'verb' => 'GET'), - array('name' => 'feed_api#move', 'url' => '/api/v1-2/feeds/{feedId}/move', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'feed_api#rename', 'url' => '/api/v1-2/feeds/{feedId}/rename', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'feed_api#read', 'url' => '/api/v1-2/feeds/{feedId}/read', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('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 - array('name' => 'item_api#index', 'url' => '/api/v1-2/items', 'verb' => 'GET'), - array('name' => 'item_api#updated', 'url' => '/api/v1-2/items/updated', 'verb' => 'GET'), - array('name' => 'item_api#read', 'url' => '/api/v1-2/items/{itemId}/read', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'item_api#unread', 'url' => '/api/v1-2/items/{itemId}/unread', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'item_api#read_all', 'url' => '/api/v1-2/items/read', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'item_api#read_multiple', 'url' => '/api/v1-2/items/read/multiple', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'item_api#unread_multiple', 'url' => '/api/v1-2/items/unread/multiple', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'item_api#star', 'url' => '/api/v1-2/items/{feedId}/{guidHash}/star', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'item_api#unstar', 'url' => '/api/v1-2/items/{feedId}/{guidHash}/unstar', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('name' => 'item_api#star_multiple', 'url' => '/api/v1-2/items/star/multiple', 'verb' => 'PUT'), // FIXME: POST would be more correct - array('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/enhancer.php b/articleenhancer/enhancer.php index cfdc960b6..f9b4d5d64 100644 --- a/articleenhancer/enhancer.php +++ b/articleenhancer/enhancer.php @@ -16,7 +16,7 @@ namespace OCA\News\ArticleEnhancer; class Enhancer { - private $enhancers = array(); + private $enhancers = []; /** * @param string $feedUrl diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php index 6761fd0c5..ecde135bf 100644 --- a/articleenhancer/xpatharticleenhancer.php +++ b/articleenhancer/xpatharticleenhancer.php @@ -136,7 +136,7 @@ class XPathArticleEnhancer implements ArticleEnhancer { // remove <html></html> $dom->replaceChild($dom->firstChild->firstChild, $dom->firstChild); - $substitution = array("href", "src"); + $substitution = ["href", "src"]; foreach ($substitution as $attribute) { $xpath = new \DOMXpath($dom); diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php index acb999aa4..46e7ab2da 100644 --- a/businesslayer/feedbusinesslayer.php +++ b/businesslayer/feedbusinesslayer.php @@ -260,7 +260,7 @@ class FeedBusinessLayer extends BusinessLayer { // build assoc array for fast access $feeds = $this->findAll($userId); - $feedsDict = array(); + $feedsDict = []; foreach($feeds as $feed) { $feedsDict[$feed->getLink()] = $feed; } diff --git a/config/appconfig.php b/config/appconfig.php index b42301209..4315569d6 100644 --- a/config/appconfig.php +++ b/config/appconfig.php @@ -55,7 +55,7 @@ class AppConfig { $this->installedApps = $installedApps; $this->installedExtensions = $installedExtensions; $this->databaseType = $databaseType; - $this->config = array(); + $this->config = []; } @@ -75,13 +75,13 @@ class AppConfig { $nav =& $this->config['navigation']; // add defaults - $defaults = array( + $defaults = [ 'id' => $this->config['id'], 'route' => $this->config['id'] . '.page.index', 'order' => 10, 'icon' => 'app.svg', 'name' => $this->config['name'] - ); + ]; foreach($defaults as $key => $value) { if(!array_key_exists($key, $nav)) { @@ -113,10 +113,10 @@ class AppConfig { if(array_key_exists('navigation', $this->config)) { $nav =& $this->config['navigation']; - $navConfig = array( + $navConfig = [ 'id' => $nav['id'], 'order' => $nav['order'] - ); + ]; $navConfig['name'] = $this->l10n->t($nav['name']); $navConfig['href'] = $this->urlGenerator->linkToRoute($nav['route']); @@ -252,21 +252,21 @@ class AppConfig { * @return array of arrays with key=version value=operator */ private function splitVersions($versions) { - $result = array(); + $result = []; $versions = explode(',', $versions); foreach($versions as $version) { preg_match('/^(?<operator><|<=|>=|>|<>)?(?<version>.*)$/', $version, $matches); if($matches['operator'] !== '') { - $required = array( + $required = [ 'version' => $matches['version'], 'operator' => $matches['operator'], - ); + ]; } else { - $required = array( + $required = [ 'version' => $matches['version'], 'operator' => '==', - ); + ]; } $result[] = $required; } diff --git a/controller/entityapiserializer.php b/controller/entityapiserializer.php index b84006750..c09e27dbd 100644 --- a/controller/entityapiserializer.php +++ b/controller/entityapiserializer.php @@ -40,17 +40,13 @@ class EntityApiSerializer implements IResponseSerializer { } if($data instanceof IAPI) { - return array( - $this->level => array($data->toAPI()) - ); + return [$this->level => [$data->toAPI()]]; } if(is_array($data) && array_key_exists($this->level, $data)) { $data[$this->level] = $this->convert($data[$this->level]); } elseif(is_array($data)) { - $data = array( - $this->level => $this->convert($data) - ); + $data = [$this->level => $this->convert($data)]; } return $data; @@ -58,13 +54,15 @@ class EntityApiSerializer implements IResponseSerializer { private function convert($entities) { - $converted = array(); + $converted = []; foreach($entities as $entity) { if($entity instanceof IAPI) { $converted[] = $entity->toAPI(); + + // break if it contains anything else than entities } else { - $converted[] = $entity; + return $entities; } } diff --git a/controller/exportcontroller.php b/controller/exportcontroller.php index 61cf37c9c..4652fa9a4 100644 --- a/controller/exportcontroller.php +++ b/controller/exportcontroller.php @@ -70,14 +70,14 @@ class ExportController extends Controller { $items = $this->itemBusinessLayer->getUnreadOrStarred($this->userId); // build assoc array for fast access - $feedsDict = array(); + $feedsDict = []; foreach($feeds as $feed) { $feedsDict['feed' . $feed->getId()] = $feed; } - $articles = array(); + $articles = []; foreach($items as $item) { - array_push($articles, $item->toExport($feedsDict)); + $articles[] = $item->toExport($feedsDict); } $response = new JSONResponse($articles); |