From f5e64d35c05b14016eb4fffff7199386a97a9b43 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 21 Oct 2014 17:02:59 +0200 Subject: use spaces for indention in itemcontroller class --- controller/itemcontroller.php | 196 +++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 98 deletions(-) (limited to 'controller') diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php index d62e704f7..89dd51d03 100644 --- a/controller/itemcontroller.php +++ b/controller/itemcontroller.php @@ -26,25 +26,25 @@ use \OCA\News\Service\FeedService; class ItemController extends Controller { - use JSONHttpError; - - private $itemService; - private $feedService; - private $userId; - private $settings; - - 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; - $this->settings = $settings; - } + use JSONHttpError; + + private $itemService; + private $feedService; + private $userId; + private $settings; + + 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; + $this->settings = $settings; + } /** @@ -56,42 +56,42 @@ class ItemController extends Controller { * @param int $offset * @return array */ - 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'; + 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'; - $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 = []; + $params = []; - try { + try { - // the offset is 0 if the user clicks on a new feed - // we need to pass the newest feeds to not let the unread count get - // out of sync - if($offset === 0) { - $params['newestItemId'] = - $this->itemService->getNewestItemId($this->userId); - $params['feeds'] = $this->feedService->findAll($this->userId); - $params['starred'] = $this->itemService->starredCount($this->userId); - } + // the offset is 0 if the user clicks on a new feed + // we need to pass the newest feeds to not let the unread count get + // out of sync + if($offset === 0) { + $params['newestItemId'] = + $this->itemService->getNewestItemId($this->userId); + $params['feeds'] = $this->feedService->findAll($this->userId); + $params['starred'] = $this->itemService->starredCount($this->userId); + } - $params['items'] = $this->itemService->findAll( - $id, $type, $limit, $offset, $showAll, $oldestFirst, - $this->userId - ); + $params['items'] = $this->itemService->findAll( + $id, $type, $limit, $offset, $showAll, $oldestFirst, + $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; - } + return $params; + } /** @@ -102,25 +102,25 @@ 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 = []; + $params = []; - try { - $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId); - $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); + try { + $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId); + $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); - // 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; - } + return $params; + } /** @@ -131,16 +131,16 @@ class ItemController extends Controller { * @param bool $isStarred * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function star($feedId, $guidHash, $isStarred){ - try { - $this->itemService->star($feedId, $guidHash, $isStarred, - $this->userId); - } catch(ServiceException $ex) { - return $this->error($ex, Http::STATUS_NOT_FOUND); - } + public function star($feedId, $guidHash, $isStarred){ + try { + $this->itemService->star($feedId, $guidHash, $isStarred, + $this->userId); + } catch(ServiceException $ex) { + return $this->error($ex, Http::STATUS_NOT_FOUND); + } return []; - } + } /** @@ -150,15 +150,15 @@ class ItemController extends Controller { * @param bool $isRead * @return array|\OCP\AppFramework\Http\JSONResponse */ - public function read($itemId, $isRead=true){ - try { - $this->itemService->read($itemId, $isRead, $this->userId); - } catch(ServiceException $ex) { - return $this->error($ex, Http::STATUS_NOT_FOUND); - } + public function read($itemId, $isRead=true){ + try { + $this->itemService->read($itemId, $isRead, $this->userId); + } catch(ServiceException $ex) { + return $this->error($ex, Http::STATUS_NOT_FOUND); + } return []; - } + } /** @@ -167,26 +167,26 @@ class ItemController extends Controller { * @param int $highestItemId * @return array */ - public function readAll($highestItemId){ - $this->itemService->readAll($highestItemId, $this->userId); - return ['feeds' => $this->feedService->findAll($this->userId)]; - } - - - /** - * @NoAdminRequired - * - * @param int[] item ids - */ - public function readMultiple($itemIds) { - foreach($itemIds as $id) { - try { - $this->itemService->read($id, true, $this->userId); - } catch(ServiceNotFoundException $ex) { - continue; - } - } - } + public function readAll($highestItemId){ + $this->itemService->readAll($highestItemId, $this->userId); + return ['feeds' => $this->feedService->findAll($this->userId)]; + } + + + /** + * @NoAdminRequired + * + * @param int[] item ids + */ + public function readMultiple($itemIds) { + foreach($itemIds as $id) { + try { + $this->itemService->read($id, true, $this->userId); + } catch(ServiceNotFoundException $ex) { + continue; + } + } + } } \ No newline at end of file -- cgit v1.2.3