summaryrefslogtreecommitdiffstats
path: root/controllers/news.controller.php
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-10-31 21:28:17 +0100
committerBernhard Posselt <nukeawhale@gmail.com>2012-10-31 22:02:19 +0100
commit323dd4c9b18c331516f024332fd5ee354e337492 (patch)
treed348a3f1c24ebbde53a63639a859a78a8165d38b /controllers/news.controller.php
parentbb092e1545285cb3b3a63cc0451355257e41db3c (diff)
added request object, added url function that does all the security checks, improved controller object
Diffstat (limited to 'controllers/news.controller.php')
-rw-r--r--controllers/news.controller.php26
1 files changed, 15 insertions, 11 deletions
diff --git a/controllers/news.controller.php b/controllers/news.controller.php
index be3cdbf08..3a77d5f7e 100644
--- a/controllers/news.controller.php
+++ b/controllers/news.controller.php
@@ -12,23 +12,27 @@
namespace OCA\News;
+require_once \OC_App::getAppPath('news') . '/controllers/controller.php';
+
+
class NewsController extends Controller {
/**
* Decides wether to show the feedpage or the firstrun page
*/
- public function index(){
+ public function index($request){
+ echo "hi";
$feedMapper = new FeedMapper($this->userId);
if($feedMapper->feedCount() > 0){
- $this->feedPage();
+ $this->feedPage($request);
} else {
- $this->firstRun();
+ $this->firstRun($request);
}
}
- public function firstRun(){
+ public function firstRun($request){
$this->addScript('news');
$this->addScript('firstrun');
$this->addStyle('firstrun');
@@ -36,7 +40,7 @@ class NewsController extends Controller {
}
- public function feedPage(){
+ public function feedPage($request){
$this->addScript('main');
$this->addScript('news');
$this->addScript('menu');
@@ -51,10 +55,10 @@ class NewsController extends Controller {
$itemMapper = new ItemMapper($this->userId);
// if no feed id is passed as parameter, then show the last viewed feed on reload
- $lastViewedFeedId = isset( $_GET['feedid'] ) ? $_GET['feedid'] : (int)$this->getUserValue('lastViewedFeed');
- $lastViewedFeedType = isset( $_GET['feedid'] ) ? FeedType::FEED : (int)$this->getUserValue('lastViewedFeedType');
+ $lastViewedFeedId = isset( $request->get['feedid'] ) ? $request->get['feedid'] : (int)$this->getUserValue('lastViewedFeed');
+ $lastViewedFeedType = isset( $request->get['feedid'] ) ? FeedType::FEED : (int)$this->getUserValue('lastViewedFeedType');
- $showAll = $this->getUserValue('showAll');
+ $showAll = $this->getUserValue('showAll');
if( $lastViewedFeedId === null || $lastViewedFeedType === null) {
$lastViewedFeedId = $feedMapper->mostRecent();
@@ -87,7 +91,7 @@ class NewsController extends Controller {
'items' => $items
);
- $this->render('main', $params, array('items' => true));
+ $this->renderTemplate('main', $params, array('items' => true));
}
@@ -98,7 +102,7 @@ class NewsController extends Controller {
* @param $showAll if true, it will also include unread items
* @return an array with all items
*/
- public function getItems($feedType, $feedId, $showAll){
+ private function getItems($feedType, $feedId, $showAll){
$items = array();
$itemMapper = new ItemMapper($this->userId);
@@ -148,7 +152,7 @@ class NewsController extends Controller {
* @param $feedId the id of the feed or folder
* @return the unread count
*/
- public function getItemUnreadCount($feedType, $feedId){
+ private function getItemUnreadCount($feedType, $feedId){
$unreadCount = 0;
$itemMapper = new ItemMapper($this->userId);