diff options
| author | 2014-10-05 18:24:28 +0200 | |
|---|---|---|
| committer | 2014-10-05 18:24:28 +0200 | |
| commit | 9a0d01be0cb627b30424e9f938face34c6c3814d (patch) | |
| tree | 19be98eccd0461db74d0e8b715ca9793a6951407 /app/Controllers/indexController.php | |
| parent | 3831961b2e515ff7d8d352c0f7b6a15b3a613c25 (diff) | |
Coding style
Remove spaces before parenthesis.
See https://github.com/marienfressinaud/FreshRSS/issues/655
Diffstat (limited to 'app/Controllers/indexController.php')
| -rwxr-xr-x | app/Controllers/indexController.php | 229 |
1 files changed, 115 insertions, 114 deletions
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 346739523..73638acb3 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -3,18 +3,18 @@ class FreshRSS_index_Controller extends Minz_ActionController { private $nb_not_read_cat = 0; - public function indexAction () { - $output = Minz_Request::param ('output'); + public function indexAction() { + $output = Minz_Request::param('output'); $token = $this->view->conf->token; // check if user is logged in if (!$this->view->loginOk && !Minz_Configuration::allowAnonymous()) { - $token_param = Minz_Request::param ('token', ''); + $token_param = Minz_Request::param('token', ''); $token_is_ok = ($token != '' && $token === $token_param); if ($output === 'rss' && !$token_is_ok) { - Minz_Error::error ( + Minz_Error::error( 403, - array ('error' => array (_t('access_denied'))) + array('error' => array(_t('access_denied'))) ); return; } elseif ($output !== 'rss') { @@ -25,12 +25,12 @@ class FreshRSS_index_Controller extends Minz_ActionController { } } - $params = Minz_Request::params (); - if (isset ($params['search'])) { - $params['search'] = urlencode ($params['search']); + $params = Minz_Request::params(); + if (isset($params['search'])) { + $params['search'] = urlencode($params['search']); } - $this->view->url = array ( + $this->view->url = array( 'c' => 'index', 'a' => 'index', 'params' => $params @@ -38,31 +38,31 @@ class FreshRSS_index_Controller extends Minz_ActionController { if ($output === 'rss') { // no layout for RSS output - $this->view->_useLayout (false); + $this->view->_useLayout(false); header('Content-Type: application/rss+xml; charset=utf-8'); } elseif ($output === 'global') { - Minz_View::appendScript (Minz_Url::display ('/scripts/global_view.js?' . @filemtime(PUBLIC_PATH . '/scripts/global_view.js'))); + Minz_View::appendScript(Minz_Url::display('/scripts/global_view.js?' . @filemtime(PUBLIC_PATH . '/scripts/global_view.js'))); } $catDAO = new FreshRSS_CategoryDAO(); $entryDAO = FreshRSS_Factory::createEntryDao(); - $this->view->cat_aside = $catDAO->listCategories (); - $this->view->nb_favorites = $entryDAO->countUnreadReadFavorites (); + $this->view->cat_aside = $catDAO->listCategories(); + $this->view->nb_favorites = $entryDAO->countUnreadReadFavorites(); $this->view->nb_not_read = FreshRSS_CategoryDAO::CountUnreads($this->view->cat_aside, 1); $this->view->currentName = ''; $this->view->get_c = ''; $this->view->get_f = ''; - $get = Minz_Request::param ('get', 'a'); + $get = Minz_Request::param('get', 'a'); $getType = $get[0]; - $getId = substr ($get, 2); - if (!$this->checkAndProcessType ($getType, $getId)) { - Minz_Log::record ('Not found [' . $getType . '][' . $getId . ']', Minz_Log::DEBUG); - Minz_Error::error ( + $getId = substr($get, 2); + if (!$this->checkAndProcessType($getType, $getId)) { + Minz_Log::record('Not found [' . $getType . '][' . $getId . ']', Minz_Log::DEBUG); + Minz_Error::error( 404, - array ('error' => array (_t('page_not_found'))) + array('error' => array(_t('page_not_found'))) ); return; } @@ -77,11 +77,11 @@ class FreshRSS_index_Controller extends Minz_ActionController { // On récupère les différents éléments de filtrage $this->view->state = Minz_Request::param('state', $this->view->conf->default_view); - $state_param = Minz_Request::param ('state', null); - $filter = Minz_Request::param ('search', ''); - $this->view->order = $order = Minz_Request::param ('order', $this->view->conf->sort_order); - $nb = Minz_Request::param ('nb', $this->view->conf->posts_per_page); - $first = Minz_Request::param ('next', ''); + $state_param = Minz_Request::param('state', null); + $filter = Minz_Request::param('search', ''); + $this->view->order = $order = Minz_Request::param('order', $this->view->conf->sort_order); + $nb = Minz_Request::param('nb', $this->view->conf->posts_per_page); + $first = Minz_Request::param('next', ''); $ajax_request = Minz_Request::param('ajax', false); if ($output === 'reader') { @@ -90,23 +90,24 @@ class FreshRSS_index_Controller extends Minz_ActionController { if ($this->view->state === FreshRSS_Entry::STATE_NOT_READ) { //Any unread article in this category at all? switch ($getType) { - case 'a': - $hasUnread = $this->view->nb_not_read > 0; - break; - case 's': - // This is deprecated. The favorite button does not exist anymore - $hasUnread = $this->view->nb_favorites['unread'] > 0; - break; - case 'c': - $hasUnread = (!isset($this->view->cat_aside[$getId])) || ($this->view->cat_aside[$getId]->nbNotRead() > 0); - break; - case 'f': - $myFeed = FreshRSS_CategoryDAO::findFeed($this->view->cat_aside, $getId); - $hasUnread = ($myFeed === null) || ($myFeed->nbNotRead() > 0); - break; - default: - $hasUnread = true; - break; + case 'a': + $hasUnread = $this->view->nb_not_read > 0; + break; + case 's': + // This is deprecated. The favorite button does not exist anymore + $hasUnread = $this->view->nb_favorites['unread'] > 0; + break; + case 'c': + $hasUnread = (!isset($this->view->cat_aside[$getId]) || + $this->view->cat_aside[$getId]->nbNotRead() > 0); + break; + case 'f': + $myFeed = FreshRSS_CategoryDAO::findFeed($this->view->cat_aside, $getId); + $hasUnread = ($myFeed === null) || ($myFeed->nbNotRead() > 0); + break; + default: + $hasUnread = true; + break; } if (!$hasUnread && ($state_param === null)) { $this->view->state = FreshRSS_Entry::STATE_ALL; @@ -142,10 +143,10 @@ class FreshRSS_index_Controller extends Minz_ActionController { $this->view->entries = $entries; } catch (FreshRSS_EntriesGetter_Exception $e) { - Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); - Minz_Error::error ( + Minz_Log::record($e->getMessage(), Minz_Log::NOTICE); + Minz_Error::error( 404, - array ('error' => array (_t('page_not_found'))) + array('error' => array(_t('page_not_found'))) ); } } @@ -155,98 +156,98 @@ class FreshRSS_index_Controller extends Minz_ActionController { * + Initialise correctement les variables de vue get_c et get_f * + Met à jour la variable $this->nb_not_read_cat */ - private function checkAndProcessType ($getType, $getId) { - switch ($getType) { - case 'a': - $this->view->currentName = _t('your_rss_feeds'); - $this->nb_not_read_cat = $this->view->nb_not_read; - $this->view->get_c = $getType; + private function checkAndProcessType($getType, $getId) { + switch($getType) { + case 'a': + $this->view->currentName = _t('your_rss_feeds'); + $this->nb_not_read_cat = $this->view->nb_not_read; + $this->view->get_c = $getType; + return true; + case 's': + $this->view->currentName = _t('your_favorites'); + $this->nb_not_read_cat = $this->view->nb_favorites['unread']; + $this->view->get_c = $getType; + return true; + case 'c': + $cat = isset($this->view->cat_aside[$getId]) ? $this->view->cat_aside[$getId] : null; + if ($cat === null) { + $catDAO = new FreshRSS_CategoryDAO(); + $cat = $catDAO->searchById($getId); + } + if ($cat) { + $this->view->currentName = $cat->name(); + $this->nb_not_read_cat = $cat->nbNotRead(); + $this->view->get_c = $getId; return true; - case 's': - $this->view->currentName = _t('your_favorites'); - $this->nb_not_read_cat = $this->view->nb_favorites['unread']; - $this->view->get_c = $getType; + } else { + return false; + } + case 'f': + $feed = FreshRSS_CategoryDAO::findFeed($this->view->cat_aside, $getId); + if (empty($feed)) { + $feedDAO = FreshRSS_Factory::createFeedDao(); + $feed = $feedDAO->searchById($getId); + } + if ($feed) { + $this->view->currentName = $feed->name(); + $this->nb_not_read_cat = $feed->nbNotRead(); + $this->view->get_f = $getId; + $this->view->get_c = $feed->category(); return true; - case 'c': - $cat = isset($this->view->cat_aside[$getId]) ? $this->view->cat_aside[$getId] : null; - if ($cat === null) { - $catDAO = new FreshRSS_CategoryDAO(); - $cat = $catDAO->searchById($getId); - } - if ($cat) { - $this->view->currentName = $cat->name (); - $this->nb_not_read_cat = $cat->nbNotRead (); - $this->view->get_c = $getId; - return true; - } else { - return false; - } - case 'f': - $feed = FreshRSS_CategoryDAO::findFeed($this->view->cat_aside, $getId); - if (empty($feed)) { - $feedDAO = FreshRSS_Factory::createFeedDao(); - $feed = $feedDAO->searchById($getId); - } - if ($feed) { - $this->view->currentName = $feed->name (); - $this->nb_not_read_cat = $feed->nbNotRead (); - $this->view->get_f = $getId; - $this->view->get_c = $feed->category (); - return true; - } else { - return false; - } - default: + } else { return false; + } + default: + return false; } } - public function aboutAction () { - Minz_View::prependTitle (_t('about') . ' · '); + public function aboutAction() { + Minz_View::prependTitle(_t('about') . ' · '); } - public function logsAction () { + public function logsAction() { if (!$this->view->loginOk) { - Minz_Error::error ( + Minz_Error::error( 403, - array ('error' => array (_t('access_denied'))) + array('error' => array(_t('access_denied'))) ); } - Minz_View::prependTitle (_t('logs') . ' · '); + Minz_View::prependTitle(_t('logs') . ' · '); - if (Minz_Request::isPost ()) { + if (Minz_Request::isPost()) { FreshRSS_LogDAO::truncate(); } $logs = FreshRSS_LogDAO::lines(); //TODO: ask only the necessary lines //gestion pagination - $page = Minz_Request::param ('page', 1); - $this->view->logsPaginator = new Minz_Paginator ($logs); - $this->view->logsPaginator->_nbItemsPerPage (50); - $this->view->logsPaginator->_currentPage ($page); + $page = Minz_Request::param('page', 1); + $this->view->logsPaginator = new Minz_Paginator($logs); + $this->view->logsPaginator->_nbItemsPerPage(50); + $this->view->logsPaginator->_currentPage($page); } - public function loginAction () { - $this->view->_useLayout (false); + public function loginAction() { + $this->view->_useLayout(false); $url = 'https://verifier.login.persona.org/verify'; - $assert = Minz_Request::param ('assertion'); + $assert = Minz_Request::param('assertion'); $params = 'assertion=' . $assert . '&audience=' . - urlencode (Minz_Url::display (null, 'php', true)); - $ch = curl_init (); - $options = array ( + urlencode(Minz_Url::display(null, 'php', true)); + $ch = curl_init(); + $options = array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POST => 2, CURLOPT_POSTFIELDS => $params ); - curl_setopt_array ($ch, $options); - $result = curl_exec ($ch); - curl_close ($ch); + curl_setopt_array($ch, $options); + $result = curl_exec($ch); + curl_close($ch); - $res = json_decode ($result, true); + $res = json_decode($result, true); $loginOk = false; $reason = ''; @@ -273,21 +274,21 @@ class FreshRSS_index_Controller extends Minz_ActionController { } if ($loginOk) { Minz_Session::_param('currentUser', $currentUser); - Minz_Session::_param ('mail', $email); + Minz_Session::_param('mail', $email); $this->view->loginOk = true; invalidateHttpCache(); } else { - $res = array (); + $res = array(); $res['status'] = 'failure'; $res['reason'] = $reason == '' ? _t('invalid_login') : $reason; - Minz_Log::record ('Persona: ' . $res['reason'], Minz_Log::WARNING); + Minz_Log::record('Persona: ' . $res['reason'], Minz_Log::WARNING); } header('Content-Type: application/json; charset=UTF-8'); - $this->view->res = json_encode ($res); + $this->view->res = json_encode($res); } - public function logoutAction () { + public function logoutAction() { $this->view->_useLayout(false); invalidateHttpCache(); Minz_Session::_param('currentUser'); @@ -330,7 +331,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } } - public function formLoginAction () { + public function formLoginAction() { if ($this->view->loginOk) { Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } @@ -401,15 +402,15 @@ class FreshRSS_index_Controller extends Minz_ActionController { } Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } elseif (!Minz_Configuration::canLogIn()) { - Minz_Error::error ( + Minz_Error::error( 403, - array ('error' => array (_t('access_denied'))) + array('error' => array(_t('access_denied'))) ); } invalidateHttpCache(); } - public function formLogoutAction () { + public function formLogoutAction() { $this->view->_useLayout(false); invalidateHttpCache(); Minz_Session::_param('currentUser'); |
