summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appinfo/app.php4
-rw-r--r--appinfo/application.php6
-rw-r--r--articleenhancer/enhancer.php7
-rw-r--r--articleenhancer/xpatharticleenhancer.php17
-rw-r--r--config/appconfig.php6
-rw-r--r--controller/entityapiserializer.php4
-rw-r--r--controller/feedapicontroller.php73
-rw-r--r--controller/feedcontroller.php108
-rw-r--r--controller/folderapicontroller.php49
-rw-r--r--controller/foldercontroller.php79
-rw-r--r--controller/itemapicontroller.php120
-rw-r--r--controller/itemcontroller.php75
-rw-r--r--controller/jsonhttperror.php2
-rw-r--r--db/feed.php2
-rw-r--r--db/item.php5
-rw-r--r--db/mapperfactory.php4
-rw-r--r--fetcher/fetcher.php2
-rw-r--r--service/feedservice.php5
-rw-r--r--service/itemservice.php1
-rw-r--r--templates/part.content.php2
-rw-r--r--templates/part.items.php4
21 files changed, 324 insertions, 251 deletions
diff --git a/appinfo/app.php b/appinfo/app.php
index e50525a5c..cacd0637d 100644
--- a/appinfo/app.php
+++ b/appinfo/app.php
@@ -13,6 +13,8 @@
namespace OCA\News\AppInfo;
+use \OCA\News\Config\DependencyException;
+
$container = new Application();
$config = $container->getAppConfig();
@@ -24,7 +26,7 @@ $config->registerHooks();
// check for correct app dependencies
try {
$config->testDependencies();
-} catch(\OCA\News\Config\DependencyException $e) {
+} catch(DependencyException $e) {
$logger = $container->getLogger();
$params = $container->getLoggerParameters();
$logger->emergency($e->getMessage(), $params);
diff --git a/appinfo/application.php b/appinfo/application.php
index d2e846ded..ddc3cb903 100644
--- a/appinfo/application.php
+++ b/appinfo/application.php
@@ -15,6 +15,8 @@ namespace OCA\News\AppInfo;
use \OC\Files\View;
use \OCP\AppFramework\App;
+use \OCP\Util;
+use \OCP\User;
use \OCA\News\Config\AppConfig;
@@ -260,7 +262,7 @@ class Application extends App {
$c->query('L10N'),
$c->query('ServerContainer')->getURLGenerator(),
phpversion(),
- implode('.', \OCP\Util::getVersion()),
+ implode('.', Util::getVersion()),
$apps,
$extensions,
$c->query('DatabaseType')
@@ -275,7 +277,7 @@ class Application extends App {
});
$container->registerService('UserId', function() {
- return \OCP\User::getUser();
+ return User::getUser();
});
$container->registerService('Logger', function($c) {
diff --git a/articleenhancer/enhancer.php b/articleenhancer/enhancer.php
index f9b4d5d64..9aa2153d1 100644
--- a/articleenhancer/enhancer.php
+++ b/articleenhancer/enhancer.php
@@ -50,9 +50,10 @@ class Enhancer {
}
- /**
- * @param string $url
- */
+ /**
+ * @param string $url
+ * @return string
+ */
private function removeTrailingSlash($url) {
if($url[strlen($url)-1] === '/') {
return substr($url, 0, -1);
diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php
index ecde135bf..2499476e9 100644
--- a/articleenhancer/xpatharticleenhancer.php
+++ b/articleenhancer/xpatharticleenhancer.php
@@ -21,20 +21,21 @@ use \OCA\News\Utility\Config;
class XPathArticleEnhancer implements ArticleEnhancer {
- private $feedRegex;
private $fileFactory;
private $maximumTimeout;
private $config;
private $regexXPathPair;
- /**
- * @param SimplePieFileFactory a factory for getting a simple pie file instance
- * @param array $regexXPathPair an associative array containing regex to
- * match the url and the xpath that should be used for it to extract the
- * page
- * @param int $maximumTimeout maximum timeout in seconds, defaults to 10 sec
- */
+ /**
+ * @param \OCA\News\Utility\SimplePieAPIFactory $fileFactory
+ * @param array $regexXPathPair an associative array containing regex to
+ * match the url and the xpath that should be used for it to extract the
+ * page
+ * @param \OCA\News\Utility\Config $config
+ * @internal param \OCA\News\ArticleEnhancer\a $SimplePieFileFactory factory for getting a simple pie file instance
+ * @internal param int $maximumTimeout maximum timeout in seconds, defaults to 10 sec
+ */
public function __construct(SimplePieAPIFactory $fileFactory,
array $regexXPathPair, Config $config){
$this->regexXPathPair = $regexXPathPair;
diff --git a/config/appconfig.php b/config/appconfig.php
index 4315569d6..456b3d2e3 100644
--- a/config/appconfig.php
+++ b/config/appconfig.php
@@ -19,6 +19,8 @@ use OCP\BackgroundJob\IJobList;
use OCP\INavigationManager;
use OCP\IL10N;
use OCP\IURLGenerator;
+use \OCP\Backgroundjob;
+use \OCP\Util;
// Used to parse app.json file, should be in core at some point
@@ -136,7 +138,7 @@ class AppConfig {
// FIXME: this is temporarily static because core jobs are not public
// yet, therefore legacy code
foreach ($this->config['jobs'] as $job) {
- \OCP\Backgroundjob::addRegularTask($job, 'run');
+ Backgroundjob::addRegularTask($job, 'run');
}
}
@@ -152,7 +154,7 @@ class AppConfig {
$reaction = explode('::', $react);
// config is written like HookNamespace::method => Class::method
- \OCP\Util::connectHook($listener[0], $listener[1], $reaction[0],
+ Util::connectHook($listener[0], $listener[1], $reaction[0],
$reaction[1]);
}
}
diff --git a/controller/entityapiserializer.php b/controller/entityapiserializer.php
index eb60bc7c5..5153d9aa3 100644
--- a/controller/entityapiserializer.php
+++ b/controller/entityapiserializer.php
@@ -26,11 +26,13 @@ class EntityApiSerializer {
/**
* Call toAPI() method on all entities. Works on
- * @param mixed $data:
+ *
+ * @param mixed $data :
* * Entity
* * Entity[]
* * array('level' => Entity[])
* * Response
+ * @return array|mixed
*/
public function serialize($data) {
diff --git a/controller/feedapicontroller.php b/controller/feedapicontroller.php
index 4ba3b9be5..f0af19f4a 100644
--- a/controller/feedapicontroller.php
+++ b/controller/feedapicontroller.php
@@ -60,7 +60,6 @@ class FeedApiController extends ApiController {
public function index() {
$result = [
- 'feeds' => [],
'starredCount' => $this->itemService->starredCount($this->userId),
'feeds' => $this->feedService->findAll($this->userId)
];
@@ -76,14 +75,15 @@ class FeedApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param string $url
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param string $url
+ * @param int $folderId
+ * @return array|mixed|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($url, $folderId=0) {
try {
$this->feedService->purgeDeleted($this->userId, false);
@@ -107,19 +107,22 @@ class FeedApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function delete($feedId) {
try {
$this->feedService->delete($feedId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
@@ -136,37 +139,43 @@ class FeedApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @param int $folderId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function move($feedId, $folderId) {
try {
$this->feedService->move($feedId, $folderId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $feedId
- * @param string $feedTitle
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $feedId
+ * @param string $feedTitle
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function rename($feedId, $feedTitle) {
try {
$this->feedService->rename($feedId, $feedTitle, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php
index 3b9ab5cf9..d62b05c45 100644
--- a/controller/feedcontroller.php
+++ b/controller/feedcontroller.php
@@ -118,13 +118,14 @@ class FeedController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param string $url
- * @param int $parentFolderId
- * @param string $title
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $url
+ * @param int $parentFolderId
+ * @param string $title
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($url, $parentFolderId, $title){
try {
// we need to purge deleted feeds if a feed is created to
@@ -150,28 +151,33 @@ class FeedController extends Controller {
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY);
}
+
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function delete($feedId){
try {
$this->feedService->markDeleted($feedId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function update($feedId){
try {
$feed = $this->feedService->update($feedId, $this->userId);
@@ -190,43 +196,51 @@ class FeedController extends Controller {
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- * @param int $parentFolderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @param int $parentFolderId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function move($feedId, $parentFolderId){
try {
$this->feedService->move($feedId, $parentFolderId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- * @param string $feedTitle
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @param string $feedTitle
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function rename($feedId, $feedTitle) {
try {
$this->feedService->rename($feedId, $feedTitle, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param array $json
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param array $json
+ * @return array
+ */
public function import($json) {
$feed = $this->feedService->importArticles($json, $this->userId);
@@ -240,12 +254,13 @@ class FeedController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- * @param int $highestItemId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @param int $highestItemId
+ * @return array
+ */
public function read($feedId, $highestItemId){
$this->itemService->readFeed($feedId, $highestItemId, $this->userId);
@@ -260,17 +275,20 @@ class FeedController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $feedId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $feedId
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
public function restore($feedId){
try {
$this->feedService->unmarkDeleted($feedId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/folderapicontroller.php b/controller/folderapicontroller.php
index 666f4cfa2..84f1dbdf5 100644
--- a/controller/folderapicontroller.php
+++ b/controller/folderapicontroller.php
@@ -58,13 +58,14 @@ class FolderApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param string $name
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param string $name
+ * @return array|mixed|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($name) {
try {
$this->folderService->purgeDeleted($this->userId, false);
@@ -79,29 +80,33 @@ class FolderApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function delete($folderId) {
try {
$this->folderService->delete($folderId, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- * @param int $folderId
- * @param string $name
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ * @param int $folderId
+ * @param string $name
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function update($folderId, $name) {
try {
$this->folderService->rename($folderId, $name, $this->userId);
@@ -113,6 +118,8 @@ class FolderApiController extends ApiController {
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php
index 576fee422..9488a7d6c 100644
--- a/controller/foldercontroller.php
+++ b/controller/foldercontroller.php
@@ -57,26 +57,30 @@ class FolderController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- * @param bool $open
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @param bool $open
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function open($folderId, $open) {
try {
$this->folderService->open($folderId, $open, $this->userId);
} catch(ServiceNotFoundException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param string $folderName
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $folderName
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function create($folderName) {
try {
// we need to purge deleted folders if a folder is created to
@@ -95,26 +99,30 @@ class FolderController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function delete($folderId) {
try {
$this->folderService->markDeleted($folderId, $this->userId);
} catch (ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
- /**
- * @NoAdminRequired
- *
- * @param string $folderName
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param string $folderName
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function rename($folderName, $folderId) {
try {
$folder = $this->folderService->rename($folderId, $folderName,
@@ -129,14 +137,16 @@ class FolderController extends Controller {
} catch (ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- * @param int $highestItemId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @param int $highestItemId
+ * @return array
+ */
public function read($folderId, $highestItemId) {
$this->itemService->readFolder($folderId, $highestItemId, $this->userId);
@@ -144,17 +154,20 @@ class FolderController extends Controller {
}
- /**
- * @NoAdminRequired
- *
- * @param int $folderId
- */
+ /**
+ * @NoAdminRequired
+ *
+ * @param int $folderId
+ * @return array|\OCP\AppFramework\Http\JSONResponse
+ */
public function restore($folderId) {
try {
$this->folderService->unmarkDeleted($folderId, $this->userId);
} catch (ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
+
+ return [];
}
diff --git a/controller/itemapicontroller.php b/controller/itemapicontroller.php
index 40366a936..ff66de951 100644
--- a/controller/itemapicontroller.php
+++ b/controller/itemapicontroller.php
@@ -39,18 +39,19 @@ class ItemApiController extends ApiController {
}
- /**
- * @NoAdminRequired
- * @NoCSRFRequired
- * @CORS
- *
- * @param int $type
- * @param int $id
- * @param bool $getRead
- * @param int $batchSize
- * @param int $offset
- * @param int $oldestFirst
- */
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ * @CORS
+ *
+ * @param int $type
+ * @param int $id
+ * @param bool $getRead
+ * @param int $batchSize
+ * @param int $offset
+ * @param bool $oldestFirst
+ * @return array|mixed
+ */
public function index($type, $id, $getRead, $batchSize=20, $offset=0,
$oldestFirst=false) {
return $this->serializer->serialize(
@@ -62,15 +63,16 @@ class ItemApiController extends ApiController {
}
- /**
- * @NoAdminRequired<