diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-17 23:59:04 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-17 23:59:04 +0100 |
commit | 1b2b30a269912d52956c5b656aa3d06d06b5b24a (patch) | |
tree | 0c4e33770efaf748d0e4142756888a0f2ac54b41 /controller/news.controller.php | |
parent | d6069363ffabb92d21f2205ce9b49f01a17b1f2b (diff) |
fixed notice in news app
Diffstat (limited to 'controller/news.controller.php')
-rw-r--r-- | controller/news.controller.php | 147 |
1 files changed, 74 insertions, 73 deletions
diff --git a/controller/news.controller.php b/controller/news.controller.php index 9913f28a9..13b1c6745 100644 --- a/controller/news.controller.php +++ b/controller/news.controller.php @@ -15,83 +15,84 @@ namespace OCA\News; class NewsController extends Controller { - private $feedMapper; - private $folderMapper; - - /** - * @param Request $request: the object with the request instance - * @param string $api: an instance of the api wrapper object - * @param FolderMapper $folderMapper: an instance of the folder mapper - * @param FeedMapper $feedMapper: an instance of the feed mapper - */ - public function __construct($request, $api, $feedMapper, $folderMapper){ - parent::__construct($request, $api); - $this->feedMapper = $feedMapper; - $this->folderMapper = $folderMapper; - $this->api->activateNavigationEntry(); + private $feedMapper; + private $folderMapper; + + /** + * @param Request $request: the object with the request instance + * @param string $api: an instance of the api wrapper object + * @param FolderMapper $folderMapper: an instance of the folder mapper + * @param FeedMapper $feedMapper: an instance of the feed mapper + */ + public function __construct($request, $api, $feedMapper, $folderMapper){ + parent::__construct($request, $api); + $this->feedMapper = $feedMapper; + $this->folderMapper = $folderMapper; + $this->api->activateNavigationEntry(); + } + + + /** + * OPML export download page + */ + public function exportOPML($urlParams=array()){ + $opmlExporter = new OPMLExporter($this->api); + + $allFeeds = $this->folderMapper->childrenOfWithFeeds(0); + $opml = $opmlExporter->buildOPML($allFeeds); + + $fileName = 'ownCloud ' . $this->trans->t('News') . ' ' . $this->userId . '.opml'; + $contentType = 'application/x.opml+xml'; + $response = new TextDownloadResponse($opml, $fileName, $contentType); + + return $response; + } + + + /** + * Decides wether to show the feedpage or the firstrun page + */ + public function index($urlParams=array()){ + $this->api->add3rdPartyScript('angular/angular'); + $this->api->add3rdPartyScript('angular-ui/angular-ui'); + $this->api->add3rdPartyScript('moment.min'); + $this->api->addScript('app'); + $this->api->addScript('multiselect', 'core'); + + $this->api->addStyle('owncloud'); + $this->api->addStyle('addnew'); + $this->api->addStyle('feeds'); + $this->api->addStyle('items'); + $this->api->addStyle('settings'); + $this->api->addStyle('addnew'); + $this->api->addStyle('showall'); + + if(array_key_exists('feedid', $urlParams)){ + $this->api->setUserValue('lastViewedFeed', $urlParams['feedid']); + $this->api->setUserValue('lastViewedFeedType', FeedType::FEED); } - - /** - * OPML export download page - */ - public function exportOPML($urlParams=array()){ - $opmlExporter = new OPMLExporter($this->api); - - $allFeeds = $this->folderMapper->childrenOfWithFeeds(0); - $opml = $opmlExporter->buildOPML($allFeeds); - - $fileName = 'ownCloud ' . $this->trans->t('News') . ' ' . $this->userId . '.opml'; - $contentType = 'application/x.opml+xml'; - $response = new TextDownloadResponse($opml, $fileName, $contentType); - - return $response; + $lastViewedFeedId = $this->api->getUserValue('lastViewedFeed'); + $lastViewedFeedType = $this->api->getUserValue('lastViewedFeedType'); + + if( $lastViewedFeedId === null || $lastViewedFeedType === null) { + + $this->api->setUserValue('lastViewedFeed', $this->feedMapper->mostRecent());; + $this->api->setUserValue('lastViewedFeedType', FeedType::FEED); + + } else { + // check if the last selected feed or folder exists + if(($lastViewedFeedType === FeedType::FEED && + $this->feedMapper->findById($lastViewedFeedId) === null) || + ($lastViewedFeedType === FeedType::FOLDER && + $this->folderMapper->findById($lastViewedFeedId) === null)){ + $this->api->setUserValue('lastViewedFeed', $this->feedMapper->mostRecent());; + $this->api->setUserValue('lastViewedFeedType', FeedType::FEED); + } } - - /** - * Decides wether to show the feedpage or the firstrun page - */ - public function index($urlParams=array()){ - $this->api->add3rdPartyScript('angular/angular'); - $this->api->add3rdPartyScript('angular-ui/angular-ui'); - $this->api->add3rdPartyScript('moment.min'); - $this->api->addScript('app'); - $this->api->addScript('multiselect', 'core'); - - $this->api->addStyle('owncloud'); - $this->api->addStyle('addnew'); - $this->api->addStyle('feeds'); - $this->api->addStyle('items'); - $this->api->addStyle('settings'); - $this->api->addStyle('addnew'); - $this->api->addStyle('showall'); - - if($urlParams['feedid']){ - $this->api->setUserValue('lastViewedFeed', $urlParams['feedid']); - $this->api->setUserValue('lastViewedFeedType', FeedType::FEED); - } - - $lastViewedFeedId = $this->api->getUserValue('lastViewedFeed'); - $lastViewedFeedType = $this->api->getUserValue('lastViewedFeedType'); - - if( $lastViewedFeedId === null || $lastViewedFeedType === null) { - $this->api->setUserValue('lastViewedFeed', $this->feedMapper->mostRecent());; - $this->api->setUserValue('lastViewedFeedType', FeedType::FEED); - - } else { - // check if the last selected feed or folder exists - if(($lastViewedFeedType === FeedType::FEED && - $this->feedMapper->findById($lastViewedFeedId) === null) || - ($lastViewedFeedType === FeedType::FOLDER && - $this->folderMapper->findById($lastViewedFeedId) === null)){ - $this->api->setUserValue('lastViewedFeed', $this->feedMapper->mostRecent());; - $this->api->setUserValue('lastViewedFeedType', FeedType::FEED); - } - } - - return $this->render('main'); - } + return $this->render('main'); + } } |