summaryrefslogtreecommitdiffstats
path: root/lib/Controller/ItemController.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Controller/ItemController.php')
-rw-r--r--lib/Controller/ItemController.php108
1 files changed, 64 insertions, 44 deletions
diff --git a/lib/Controller/ItemController.php b/lib/Controller/ItemController.php
index 332b9933f..9c0801b1d 100644
--- a/lib/Controller/ItemController.php
+++ b/lib/Controller/ItemController.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\Controller;
@@ -24,7 +24,8 @@ use \OCA\News\Service\ItemService;
use \OCA\News\Service\FeedService;
-class ItemController extends Controller {
+class ItemController extends Controller
+{
use JSONHttpError;
@@ -33,13 +34,14 @@ class ItemController extends Controller {
private $userId;
private $settings;
- public function __construct($AppName,
- IRequest $request,
- FeedService $feedService,
- ItemService $itemService,
- IConfig $settings,
- $UserId){
- parent::__construct($AppName, $request);
+ public function __construct($appName,
+ IRequest $request,
+ FeedService $feedService,
+ ItemService $itemService,
+ IConfig $settings,
+ $UserId
+ ) {
+ parent::__construct($appName, $request);
$this->itemService = $itemService;
$this->feedService = $feedService;
$this->userId = $UserId;
@@ -50,23 +52,24 @@ class ItemController extends Controller {
/**
* @NoAdminRequired
*
- * @param int $type
- * @param int $id
- * @param int $limit
- * @param int $offset
- * @param bool $showAll
- * @param bool $oldestFirst
+ * @param int $type
+ * @param int $id
+ * @param int $limit
+ * @param int $offset
+ * @param bool $showAll
+ * @param bool $oldestFirst
* @param string $search
* @return array
*/
public function index($type=3, $id=0, $limit=50, $offset=0, $showAll=null,
- $oldestFirst=null, $search='') {
+ $oldestFirst=null, $search=''
+ ) {
// in case this is called directly and not from the website use the
// internal state
if ($showAll === null) {
$showAll = $this->settings->getUserValue(
- $this->userId, $this->appName,'showAll'
+ $this->userId, $this->appName, 'showAll'
) === '1';
}
@@ -76,10 +79,14 @@ class ItemController extends Controller {
) === '1';
}
- $this->settings->setUserValue($this->userId, $this->appName,
- 'lastViewedFeedId', $id);
- $this->settings->setUserValue($this->userId, $this->appName,
- 'lastViewedFeedType', $type);
+ $this->settings->setUserValue(
+ $this->userId, $this->appName,
+ 'lastViewedFeedId', $id
+ );
+ $this->settings->setUserValue(
+ $this->userId, $this->appName,
+ 'lastViewedFeedType', $type
+ );
$params = [];
@@ -110,9 +117,10 @@ class ItemController extends Controller {
$this->userId, $search
);
- // this gets thrown if there are no items
- // in that case just return an empty array
- } catch(ServiceException $ex) {}
+ // this gets thrown if there are no items
+ // in that case just return an empty array
+ } catch(ServiceException $ex) {
+ }
return $params;
}
@@ -126,9 +134,12 @@ class ItemController extends Controller {
* @param int $lastModified
* @return array
*/
- public function newItems($type, $id, $lastModified=0) {
- $showAll = $this->settings->getUserValue($this->userId, $this->appName,
- 'showAll') === '1';
+ public function newItems($type, $id, $lastModified=0)
+ {
+ $showAll = $this->settings->getUserValue(
+ $this->userId, $this->appName,
+ 'showAll'
+ ) === '1';
$params = [];
@@ -138,12 +149,15 @@ class ItemController extends Controller {
$params['feeds'] = $this->feedService->findAll($this->userId);
$params['starred'] =
$this->itemService->starredCount($this->userId);
- $params['items'] = $this->itemService->findAllNew($id, $type,
- $lastModified, $showAll, $this->userId);
+ $params['items'] = $this->itemService->findAllNew(
+ $id, $type,
+ $lastModified, $showAll, $this->userId
+ );
- // this gets thrown if there are no items
- // in that case just return an empty array
- } catch(ServiceException $ex) {}
+ // this gets thrown if there are no items
+ // in that case just return an empty array
+ } catch(ServiceException $ex) {
+ }
return $params;
}
@@ -152,15 +166,18 @@ class ItemController extends Controller {
/**
* @NoAdminRequired
*
- * @param int $feedId
+ * @param int $feedId
* @param string $guidHash
- * @param bool $isStarred
+ * @param bool $isStarred
* @return array|\OCP\AppFramework\Http\JSONResponse
*/
- public function star($feedId, $guidHash, $isStarred){
+ public function star($feedId, $guidHash, $isStarred)
+ {
try {
- $this->itemService->star($feedId, $guidHash, $isStarred,
- $this->userId);
+ $this->itemService->star(
+ $feedId, $guidHash, $isStarred,
+ $this->userId
+ );
} catch(ServiceException $ex) {
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
@@ -172,11 +189,12 @@ class ItemController extends Controller {
/**
* @NoAdminRequired
*
- * @param int $itemId
+ * @param int $itemId
* @param bool $isRead
* @return array|\OCP\AppFramework\Http\JSONResponse
*/
- public function read($itemId, $isRead=true){
+ public function read($itemId, $isRead=true)
+ {
try {
$this->itemService->read($itemId, $isRead, $this->userId);
} catch(ServiceException $ex) {
@@ -193,7 +211,8 @@ class ItemController extends Controller {
* @param int $highestItemId
* @return array
*/
- public function readAll($highestItemId){
+ public function readAll($highestItemId)
+ {
$this->itemService->readAll($highestItemId, $this->userId);
return ['feeds' => $this->feedService->findAll($this->userId)];
}
@@ -204,7 +223,8 @@ class ItemController extends Controller {
*
* @param int[] item ids
*/
- public function readMultiple($itemIds) {
+ public function readMultiple($itemIds)
+ {
foreach($itemIds as $id) {
try {
$this->itemService->read($id, true, $this->userId);