aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-05 18:24:28 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-05 18:24:28 +0200
commit9a0d01be0cb627b30424e9f938face34c6c3814d (patch)
tree19be98eccd0461db74d0e8b715ca9793a6951407 /app/Controllers
parent3831961b2e515ff7d8d352c0f7b6a15b3a613c25 (diff)
Coding style
Remove spaces before parenthesis. See https://github.com/marienfressinaud/FreshRSS/issues/655
Diffstat (limited to 'app/Controllers')
-rwxr-xr-xapp/Controllers/entryController.php78
-rw-r--r--app/Controllers/errorController.php28
-rwxr-xr-xapp/Controllers/feedController.php184
-rwxr-xr-xapp/Controllers/indexController.php229
-rwxr-xr-xapp/Controllers/javascriptController.php6
-rw-r--r--app/Controllers/statsController.php2
6 files changed, 269 insertions, 258 deletions
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php
index 048ac1c69..ec90666ed 100755
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
@@ -1,47 +1,47 @@
<?php
class FreshRSS_entry_Controller extends Minz_ActionController {
- public function firstAction () {
+ public function firstAction() {
if (!$this->view->loginOk) {
- Minz_Error::error (
+ Minz_Error::error(
403,
- array ('error' => array (_t('access_denied')))
+ array('error' => array(_t('access_denied')))
);
}
- $this->params = array ();
+ $this->params = array();
$output = Minz_Request::param('output', '');
if (($output != '') && ($this->view->conf->view_mode !== $output)) {
$this->params['output'] = $output;
}
$this->redirect = false;
- $ajax = Minz_Request::param ('ajax');
+ $ajax = Minz_Request::param('ajax');
if ($ajax) {
- $this->view->_useLayout (false);
+ $this->view->_useLayout(false);
}
}
- public function lastAction () {
- $ajax = Minz_Request::param ('ajax');
+ public function lastAction() {
+ $ajax = Minz_Request::param('ajax');
if (!$ajax && $this->redirect) {
- Minz_Request::forward (array (
+ Minz_Request::forward(array(
'c' => 'index',
'a' => 'index',
'params' => $this->params
), true);
} else {
- Minz_Request::_param ('ajax');
+ Minz_Request::_param('ajax');
}
}
- public function readAction () {
+ public function readAction() {
$this->redirect = true;
- $id = Minz_Request::param ('id');
- $get = Minz_Request::param ('get');
- $nextGet = Minz_Request::param ('nextGet', $get);
- $idMax = Minz_Request::param ('idMax', 0);
+ $id = Minz_Request::param('id');
+ $get = Minz_Request::param('get');
+ $nextGet = Minz_Request::param('nextGet', $get);
+ $idMax = Minz_Request::param('idMax', 0);
$entryDAO = FreshRSS_Factory::createEntryDao();
if ($id == false) {
@@ -50,47 +50,47 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
}
if (!$get) {
- $entryDAO->markReadEntries ($idMax);
+ $entryDAO->markReadEntries($idMax);
} else {
$typeGet = $get[0];
- $get = substr ($get, 2);
- switch ($typeGet) {
- case 'c':
- $entryDAO->markReadCat ($get, $idMax);
- break;
- case 'f':
- $entryDAO->markReadFeed ($get, $idMax);
- break;
- case 's':
- $entryDAO->markReadEntries ($idMax, true);
- break;
- case 'a':
- $entryDAO->markReadEntries ($idMax);
- break;
+ $get = substr($get, 2);
+ switch($typeGet) {
+ case 'c':
+ $entryDAO->markReadCat($get, $idMax);
+ break;
+ case 'f':
+ $entryDAO->markReadFeed($get, $idMax);
+ break;
+ case 's':
+ $entryDAO->markReadEntries($idMax, true);
+ break;
+ case 'a':
+ $entryDAO->markReadEntries($idMax);
+ break;
}
if ($nextGet !== 'a') {
$this->params['get'] = $nextGet;
}
}
- $notif = array (
+ $notif = array(
'type' => 'good',
'content' => _t('feeds_marked_read')
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
} else {
- $is_read = (bool)(Minz_Request::param ('is_read', true));
- $entryDAO->markRead ($id, $is_read);
+ $is_read = (bool)(Minz_Request::param('is_read', true));
+ $entryDAO->markRead($id, $is_read);
}
}
- public function bookmarkAction () {
+ public function bookmarkAction() {
$this->redirect = true;
- $id = Minz_Request::param ('id');
+ $id = Minz_Request::param('id');
if ($id) {
$entryDAO = FreshRSS_Factory::createEntryDao();
- $entryDAO->markFavorite ($id, (bool)(Minz_Request::param ('is_favorite', true)));
+ $entryDAO->markFavorite($id, (bool)(Minz_Request::param('is_favorite', true)));
}
}
@@ -109,11 +109,11 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
invalidateHttpCache();
- $notif = array (
+ $notif = array(
'type' => 'good',
'content' => _t('optimization_complete')
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
}
Minz_Request::forward(array(
diff --git a/app/Controllers/errorController.php b/app/Controllers/errorController.php
index 64a5c06fd..36312b56c 100644
--- a/app/Controllers/errorController.php
+++ b/app/Controllers/errorController.php
@@ -3,20 +3,20 @@
class FreshRSS_error_Controller extends Minz_ActionController {
public function indexAction() {
switch (Minz_Request::param('code')) {
- case 403:
- $this->view->code = 'Error 403 - Forbidden';
- break;
- case 404:
- $this->view->code = 'Error 404 - Not found';
- break;
- case 500:
- $this->view->code = 'Error 500 - Internal Server Error';
- break;
- case 503:
- $this->view->code = 'Error 503 - Service Unavailable';
- break;
- default:
- $this->view->code = 'Error 404 - Not found';
+ case 403:
+ $this->view->code = 'Error 403 - Forbidden';
+ break;
+ case 404:
+ $this->view->code = 'Error 404 - Not found';
+ break;
+ case 500:
+ $this->view->code = 'Error 500 - Internal Server Error';
+ break;
+ case 503:
+ $this->view->code = 'Error 503 - Service Unavailable';
+ break;
+ default:
+ $this->view->code = 'Error 404 - Not found';
}
$errors = Minz_Request::param('logs', array());
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 029f9fa68..93a8d7c2e 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -1,27 +1,27 @@
<?php
class FreshRSS_feed_Controller extends Minz_ActionController {
- public function firstAction () {
+ public function firstAction() {
if (!$this->view->loginOk) {
// Token is useful in the case that anonymous refresh is forbidden
// and CRON task cannot be used with php command so the user can
// set a CRON task to refresh his feeds by using token inside url
$token = $this->view->conf->token;
- $token_param = Minz_Request::param ('token', '');
+ $token_param = Minz_Request::param('token', '');
$token_is_ok = ($token != '' && $token == $token_param);
- $action = Minz_Request::actionName ();
+ $action = Minz_Request::actionName();
if (!(($token_is_ok || Minz_Configuration::allowAnonymousRefresh()) &&
$action === 'actualize')
) {
- Minz_Error::error (
+ Minz_Error::error(
403,
- array ('error' => array (_t('access_denied')))
+ array('error' => array(_t('access_denied')))
);
}
}
}
- public function addAction () {
+ public function addAction() {
$url = Minz_Request::param('url_rss', false);
if ($url === false) {
@@ -32,16 +32,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
$feedDAO = FreshRSS_Factory::createFeedDao();
- $this->catDAO = new FreshRSS_CategoryDAO ();
- $this->catDAO->checkDefault ();
+ $this->catDAO = new FreshRSS_CategoryDAO();
+ $this->catDAO->checkDefault();
if (Minz_Request::isPost()) {
@set_time_limit(300);
- $cat = Minz_Request::param ('category', false);
+ $cat = Minz_Request::param('category', false);
if ($cat === 'nc') {
- $new_cat = Minz_Request::param ('new_category');
+ $new_cat = Minz_Request::param('new_category');
if (empty($new_cat['name'])) {
$cat = false;
} else {
@@ -49,55 +49,55 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
if ($cat === false) {
- $def_cat = $this->catDAO->getDefault ();
- $cat = $def_cat->id ();
+ $def_cat = $this->catDAO->getDefault();
+ $cat = $def_cat->id();
}
- $user = Minz_Request::param ('http_user');
- $pass = Minz_Request::param ('http_pass');
- $params = array ();
+ $user = Minz_Request::param('http_user');
+ $pass = Minz_Request::param('http_pass');
+ $params = array();
$transactionStarted = false;
try {
- $feed = new FreshRSS_Feed ($url);
- $feed->_category ($cat);
+ $feed = new FreshRSS_Feed($url);
+ $feed->_category($cat);
$httpAuth = '';
if ($user != '' || $pass != '') {
$httpAuth = $user . ':' . $pass;
}
- $feed->_httpAuth ($httpAuth);
+ $feed->_httpAuth($httpAuth);
$feed->load(true);
- $values = array (
- 'url' => $feed->url (),
- 'category' => $feed->category (),
- 'name' => $feed->name (),
- 'website' => $feed->website (),
- 'description' => $feed->description (),
- 'lastUpdate' => time (),
- 'httpAuth' => $feed->httpAuth (),
+ $values = array(
+ 'url' => $feed->url(),
+ 'category' => $feed->category(),
+ 'name' => $feed->name(),
+ 'website' => $feed->website(),
+ 'description' => $feed->description(),
+ 'lastUpdate' => time(),
+ 'httpAuth' => $feed->httpAuth(),
);
- if ($feedDAO->searchByUrl ($values['url'])) {
+ if ($feedDAO->searchByUrl($values['url'])) {
// on est déjà abonné à ce flux
- $notif = array (
+ $notif = array(
'type' => 'bad',
- 'content' => _t('already_subscribed', $feed->name ())
+ 'content' => _t('already_subscribed', $feed->name())
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
} else {
- $id = $feedDAO->addFeed ($values);
+ $id = $feedDAO->addFeed($values);
if (!$id) {
// problème au niveau de la base de données
- $notif = array (
+ $notif = array(
'type' => 'bad',
- 'content' => _t('feed_not_added', $feed->name ())
+ 'content' => _t('feed_not_added', $feed->name())
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
} else {
- $feed->_id ($id);
+ $feed->_id($id);
$feed->faviconPrepare();
$is_read = $this->view->conf->mark_when['reception'] ? 1 : 0;
@@ -107,7 +107,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// on calcule la date des articles les plus anciens qu'on accepte
$nb_month_old = $this->view->conf->old_entries;
- $date_min = time () - (3600 * 24 * 30 * $nb_month_old);
+ $date_min = time() - (3600 * 24 * 30 * $nb_month_old);
//MySQL: http://docs.oracle.com/cd/E17952_01/refman-5.5-en/optimizing-innodb-transaction-management.html
//SQLite: http://stackoverflow.com/questions/1711631/how-do-i-improve-the-performance-of-sqlite
@@ -129,44 +129,50 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$transactionStarted = false;
// ok, ajout terminé
- $notif = array (
+ $notif = array(
'type' => 'good',
- 'content' => _t('feed_added', $feed->name ())
+ 'content' => _t('feed_added', $feed->name())
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
// permet de rediriger vers la page de conf du flux
- $params['id'] = $feed->id ();
+ $params['id'] = $feed->id();
}
}
} catch (FreshRSS_BadUrl_Exception $e) {
- Minz_Log::record ($e->getMessage (), Minz_Log::WARNING);
- $notif = array (
+ Minz_Log::record($e->getMessage(), Minz_Log::WARNING);
+ $notif = array(
'type' => 'bad',
'content' => _t('invalid_url', $url)
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
} catch (FreshRSS_Feed_Exception $e) {
- Minz_Log::record ($e->getMessage (), Minz_Log::WARNING);
- $notif = array (
+ Minz_Log::record($e->getMessage(), Minz_Log::WARNING);
+ $notif = array(
'type' => 'bad',
- 'content' => _t('internal_problem_feed', Minz_Url::display(array('a' => 'logs')))
+ 'content' => _t('internal_problem_feed',
+ Minz_Url::display(array('a' => 'logs')))
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
} catch (Minz_FileNotExistException $e) {
// Répertoire de cache n'existe pas
- Minz_Log::record ($e->getMessage (), Minz_Log::ERROR);
- $notif = array (
+ Minz_Log::record($e->getMessage(), Minz_Log::ERROR);
+ $notif = array(
'type' => 'bad',
- 'content' => _t('internal_problem_feed', Minz_Url::display(array('a' => 'logs')))
+ 'content' => _t('internal_problem_feed',
+ Minz_Url::display(array('a' => 'logs')))
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
}
if ($transactionStarted) {
- $feedDAO->rollBack ();
+ $feedDAO->rollBack();
}
- Minz_Request::forward (array ('c' => 'subscription', 'a' => 'index', 'params' => $params), true);
+ Minz_Request::forward(array(
+ 'c' => 'subscription',
+ 'a' => 'index',
+ 'params' => $params
+ ), true);
} else {
// GET request so we must ask confirmation to user
@@ -201,41 +207,43 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
- public function truncateAction () {
- if (Minz_Request::isPost ()) {
- $id = Minz_Request::param ('id');
+ public function truncateAction() {
+ if (Minz_Request::isPost()) {
+ $id = Minz_Request::param('id');
$feedDAO = FreshRSS_Factory::createFeedDao();
$n = $feedDAO->truncate($id);
$notif = array(
'type' => $n === false ? 'bad' : 'good',
'content' => _t('n_entries_deleted', $n)
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
invalidateHttpCache();
- Minz_Request::forward (array ('c' => 'subscription',
- 'a' => 'index',
- 'params' => array('id' => $id)), true);
+ Minz_Request::forward(array(
+ 'c' => 'subscription',
+ 'a' => 'index',
+ 'params' => array('id' => $id)
+ ), true);
}
}
- public function actualizeAction () {
+ public function actualizeAction() {
@set_time_limit(300);
$feedDAO = FreshRSS_Factory::createFeedDao();
$entryDAO = FreshRSS_Factory::createEntryDao();
Minz_Session::_param('actualize_feeds', false);
- $id = Minz_Request::param ('id');
- $force = Minz_Request::param ('force', false);
+ $id = Minz_Request::param('id');
+ $force = Minz_Request::param('force', false);
// on créé la liste des flux à mettre à actualiser
// si on veut mettre un flux à jour spécifiquement, on le met
// dans la liste, mais seul (permet d'automatiser le traitement)
- $feeds = array ();
+ $feeds = array();
if ($id) {
- $feed = $feedDAO->searchById ($id);
+ $feed = $feedDAO->searchById($id);
if ($feed) {
- $feeds = array ($feed);
+ $feeds = array($feed);
}
} else {
$feeds = $feedDAO->listFeedsOrderUpdate($this->view->conf->ttl_default);
@@ -243,7 +251,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// on calcule la date des articles les plus anciens qu'on accepte
$nb_month_old = max($this->view->conf->old_entries, 1);
- $date_min = time () - (3600 * 24 * 30 * $nb_month_old);
+ $date_min = time() - (3600 * 24 * 30 * $nb_month_old);
$i = 0;
$flux_update = 0;
@@ -263,7 +271,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
if (count($entries) > 0) {
//For this feed, check last n entry GUIDs already in database
- $existingGuids = array_fill_keys ($entryDAO->listLastGuidsByFeed ($feed->id (), count($entries) + 10), 1);
+ $existingGuids = array_fill_keys(
+ $entryDAO->listLastGuidsByFeed($feed->id(),
+ count($entries) + 10), 1);
$useDeclaredDate = empty($existingGuids);
if ($feedHistory == -2) { //default
@@ -295,14 +305,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
if (!$hasTransaction) {
$feedDAO->beginTransaction();
}
- $nb = $feedDAO->cleanOldEntries ($feed->id (), $date_min, max($feedHistory, count($entries) + 10));
+ $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, max($feedHistory, count($entries) + 10));
if ($nb > 0) {
- Minz_Log::record ($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG);
+ Minz_Log::record($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG);
}
}
// on indique que le flux vient d'être mis à jour en BDD
- $feedDAO->updateLastUpdate ($feed->id (), 0, $hasTransaction);
+ $feedDAO->updateLastUpdate($feed->id(), 0, $hasTransaction);
if ($hasTransaction) {
$feedDAO->commit();
}
@@ -312,8 +322,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feedDAO->updateFeed($feed->id(), array('url' => $feed->url()));
}
} catch (FreshRSS_Feed_Exception $e) {
- Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE);
- $feedDAO->updateLastUpdate ($feed->id (), 1);
+ Minz_Log::record($e->getMessage(), Minz_Log::NOTICE);
+ $feedDAO->updateLastUpdate($feed->id(), 1);
}
$feed->faviconPrepare();
@@ -328,23 +338,23 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
- $url = array ();
+ $url = array();
if ($flux_update === 1) {
// on a mis un seul flux à jour
- $feed = reset ($feeds);
- $notif = array (
+ $feed = reset($feeds);
+ $notif = array(
'type' => 'good',
- 'content' => _t('feed_actualized', $feed->name ())
+ 'content' => _t('feed_actualized', $feed->name())
);
} elseif ($flux_update > 1) {
// plusieurs flux on été mis à jour
- $notif = array (
+ $notif = array(
'type' => 'good',
'content' => _t('n_feeds_actualized', $flux_update)
);
} else {
// aucun flux n'a été mis à jour, oups
- $notif = array (
+ $notif = array(
'type' => 'good',
'content' => _t('no_feed_to_refresh')
);
@@ -353,26 +363,26 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
if ($i === 1) {
// Si on a voulu mettre à jour qu'un flux
// on filtre l'affichage par ce flux
- $feed = reset ($feeds);
- $url['params'] = array ('get' => 'f_' . $feed->id ());
+ $feed = reset($feeds);
+ $url['params'] = array('get' => 'f_' . $feed->id());
}
- if (Minz_Request::param ('ajax', 0) === 0) {
- Minz_Session::_param ('notification', $notif);
- Minz_Request::forward ($url, true);
+ if (Minz_Request::param('ajax', 0) === 0) {
+ Minz_Session::_param('notification', $notif);
+ Minz_Request::forward($url, true);
} else {
// Une requête Ajax met un seul flux à jour.
// Comme en principe plusieurs requêtes ont lieu,
// on indique que "plusieurs flux ont été mis à jour".
// Cela permet d'avoir une notification plus proche du
// ressenti utilisateur
- $notif = array (
+ $notif = array(
'type' => 'good',
'content' => _t('feeds_actualized')
);
- Minz_Session::_param ('notification', $notif);
+ Minz_Session::_param('notification', $notif);
// et on désactive le layout car ne sert à rien
- $this->view->_useLayout (false);
+ $this->view->_useLayout(false);
}
}
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');
diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php
index 67148350f..2a0dbd3d9 100755
--- a/app/Controllers/javascriptController.php
+++ b/app/Controllers/javascriptController.php
@@ -1,11 +1,11 @@
<?php
class FreshRSS_javascript_Controller extends Minz_ActionController {
- public function firstAction () {
- $this->view->_useLayout (false);
+ public function firstAction() {
+ $this->view->_useLayout(false);
}
- public function actualizeAction () {
+ public function actualizeAction() {
header('Content-Type: text/javascript; charset=UTF-8');
$feedDAO = FreshRSS_Factory::createFeedDao();
$this->view->feeds = $feedDAO->listFeedsOrderUpdate($this->view->conf->ttl_default);
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index 4adb5e75d..99c57c809 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -99,7 +99,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController {
$categoryDAO = new FreshRSS_CategoryDAO();
$feedDAO = FreshRSS_Factory::createFeedDao();
Minz_View::appendScript(Minz_Url::display('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js')));
- $id = Minz_Request::param ('id', null);
+ $id = Minz_Request::param('id', null);
$this->view->categories = $categoryDAO->listCategories();
$this->view->feed = $feedDAO->searchById($id);
$this->view->days = $statsDAO->getDays();