From cd88414abcffd94cfce933cf578ecc640b691381 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Mon, 29 Sep 2014 18:54:03 -0400 Subject: Add an average per day for the 30 day period --- app/Controllers/statsController.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/Controllers') diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 256543f37..3069be34d 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -21,6 +21,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { Minz_View::appendScript(Minz_Url::display('/scripts/flotr2.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/flotr2.min.js'))); $this->view->repartition = $statsDAO->calculateEntryRepartition(); $this->view->count = $statsDAO->calculateEntryCount(); + $this->view->average = $statsDAO->calculateEntryAverage(); $this->view->feedByCategory = $statsDAO->calculateFeedByCategory(); $this->view->entryByCategory = $statsDAO->calculateEntryByCategory(); $this->view->topFeed = $statsDAO->calculateTopFeed(); -- cgit v1.2.3 From edb02c8fefdb292c96d7b37ad4e2c311e9d43b44 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 30 Sep 2014 15:02:56 +0200 Subject: Move creation of categories in a new Controller Category names are 255 chars max --- app/Controllers/categoryController.php | 64 +++++++++++++++++++++++++++++++++ app/Controllers/configureController.php | 12 ------- app/Models/Category.php | 2 +- app/views/configure/categorize.phtml | 2 +- 4 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 app/Controllers/categoryController.php (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php new file mode 100644 index 000000000..e2d98a509 --- /dev/null +++ b/app/Controllers/categoryController.php @@ -0,0 +1,64 @@ +view->loginOk) { + Minz_Error::error( + 403, + array('error' => array(_t('access_denied'))) + ); + } + + $catDAO = new FreshRSS_CategoryDAO(); + $catDAO->checkDefault(); + } + + /** + * This action creates a new category. + * + * URL parameter is: + * - new-category + */ + public function createAction() { + $catDAO = new FreshRSS_CategoryDAO(); + $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + + if (Minz_Request::isPost()) { + invalidateHttpCache(); + + $cat_name = Minz_Request::param('new-category'); + if (!$cat_name) { + Minz_Request::bad(_t('category_no_name'), $url_redirect); + } + + $cat = new FreshRSS_Category($cat_name); + + if ($catDAO->searchByName($cat->name()) != null) { + Minz_Request::bad(_t('category_name_exists'), $url_redirect); + } + + $values = array( + 'id' => $cat->id(), + 'name' => $cat->name(), + ); + + if ($catDAO->addCategory($values)) { + Minz_Request::good(_t('category_created', $cat->name()), $url_redirect); + } else { + Minz_Request::bad(_t('category_not_created'), $url_redirect); + } + } + + Minz_Request::forward($url_redirect, true); + } +} diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 231865bd7..7ef144090 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -45,7 +45,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { if (Minz_Request::isPost()) { $cats = Minz_Request::param('categories', array()); $ids = Minz_Request::param('ids', array()); - $newCat = trim(Minz_Request::param('new_category', '')); foreach ($cats as $key => $name) { if (strlen($name) > 0) { @@ -64,17 +63,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { } } - if ($newCat != '') { - $cat = new FreshRSS_Category($newCat); - $values = array( - 'id' => $cat->id(), - 'name' => $cat->name(), - ); - - if ($catDAO->searchByName($newCat) == null) { - $catDAO->addCategory($values); - } - } invalidateHttpCache(); Minz_Request::good(_t('categories_updated'), diff --git a/app/Models/Category.php b/app/Models/Category.php index 0a0dbd3ca..e5f6c4334 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -61,7 +61,7 @@ class FreshRSS_Category extends Minz_Model { $this->id = $value; } public function _name ($value) { - $this->name = $value; + $this->name = substr(trim($value), 0, 255); } public function _feeds ($values) { if (!is_array ($values)) { diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 7091ff1cf..e7435e1c7 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -7,7 +7,7 @@
-
+
-- cgit v1.2.3 From 9e0a62727f8ff3c6a68b4ef85089633677ff67ef Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 30 Sep 2014 15:44:45 +0200 Subject: Move empty cat action in the new Controller feedController::delete is simpler than before. Improve coding style See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/categoryController.php | 43 ++++++++++++++++++++-- app/Controllers/feedController.php | 66 +++++++++++----------------------- app/views/configure/categorize.phtml | 8 +++-- 3 files changed, 66 insertions(+), 51 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index e2d98a509..6863c3bb8 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -26,7 +26,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { /** * This action creates a new category. * - * URL parameter is: + * Request parameter is: * - new-category */ public function createAction() { @@ -55,7 +55,46 @@ class FreshRSS_category_Controller extends Minz_ActionController { if ($catDAO->addCategory($values)) { Minz_Request::good(_t('category_created', $cat->name()), $url_redirect); } else { - Minz_Request::bad(_t('category_not_created'), $url_redirect); + Minz_Request::bad(_t('error_occured'), $url_redirect); + } + } + + Minz_Request::forward($url_redirect, true); + } + + /** + * This action deletes all the feeds relative to a given category + * + * Request parameter is: + * - id (of a category) + */ + public function emptyAction() { + $feedDAO = FreshRSS_Factory::createFeedDao(); + $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + + if (Minz_Request::isPost()) { + invalidateHttpCache(); + + $id = Minz_Request::param('id'); + if (!$id) { + Minz_Request::bad(_t('category_no_id'), $url_redirect); + } + + // List feeds to remove then related user queries. + $feeds = $feedDAO->listByCategory($id); + + if ($feedDAO->deleteFeedByCategory($id)) { + // TODO: Delete old favicons + + // Remove related queries + foreach ($feeds as $feed) { + $this->view->conf->remove_query_by_get('f_' . $feed->id()); + } + $this->view->conf->save(); + + Minz_Request::good(_t('category_emptied'), $url_redirect); + } else { + Minz_Request::bad(_t('error_occured'), $url_redirect); } } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c7cc25fbb..7ef427ac2 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -376,62 +376,36 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } - public function deleteAction () { - if (Minz_Request::isPost ()) { - $type = Minz_Request::param ('type', 'feed'); - $id = Minz_Request::param ('id'); - + public function deleteAction() { + if (Minz_Request::isPost()) { + $id = Minz_Request::param('id'); $feedDAO = FreshRSS_Factory::createFeedDao(); - if ($type == 'category') { - // List feeds to remove then related user queries. - $feeds = $feedDAO->listByCategory($id); - - if ($feedDAO->deleteFeedByCategory ($id)) { - // Remove related queries - foreach ($feeds as $feed) { - $this->view->conf->remove_query_by_get('f_' . $feed->id()); - } - $this->view->conf->save(); - $notif = array ( - 'type' => 'good', - 'content' => Minz_Translate::t ('category_emptied') - ); - //TODO: Delete old favicons - } else { - $notif = array ( - 'type' => 'bad', - 'content' => Minz_Translate::t ('error_occured') - ); - } - } else { - if ($feedDAO->deleteFeed ($id)) { - // Remove related queries - $this->view->conf->remove_query_by_get('f_' . $id); - $this->view->conf->save(); + if ($feedDAO->deleteFeed($id)) { + // TODO: Delete old favicon - $notif = array ( - 'type' => 'good', - 'content' => Minz_Translate::t ('feed_deleted') - ); - //TODO: Delete old favicon - } else { - $notif = array ( - 'type' => 'bad', - 'content' => Minz_Translate::t ('error_occured') - ); - } + // Remove related queries + $this->view->conf->remove_query_by_get('f_' . $id); + $this->view->conf->save(); + + $notif = array( + 'type' => 'good', + 'content' => _t('feed_deleted') + ); + } else { + $notif = array( + 'type' => 'bad', + 'content' => _t('error_occured') + ); } - Minz_Session::_param ('notification', $notif); + Minz_Session::_param('notification', $notif); $redirect_url = Minz_Request::param('r', false, true); if ($redirect_url) { Minz_Request::forward($redirect_url); - } elseif ($type == 'category') { - Minz_Request::forward(array ('c' => 'configure', 'a' => 'categorize'), true); } else { - Minz_Request::forward(array ('c' => 'configure', 'a' => 'feed'), true); + Minz_Request::forward(array('c' => 'configure', 'a' => 'feed'), true); } } } diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index e7435e1c7..2d9dd65ca 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -1,7 +1,6 @@ partial('aside_feed'); ?>
-
@@ -14,6 +13,8 @@
+ + categories as $cat) { $feeds = $cat->feeds(); @@ -32,8 +33,9 @@ + form="controller-category" + formaction="id()); ?>"> +
  • -- cgit v1.2.3 From 13fb1170c06bd67ba69534e823ea6f5861c745dd Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 30 Sep 2014 16:31:38 +0200 Subject: Move deletion of categories into new Controller Fix i18n (occured -> occurred) See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/categoryController.php | 47 ++++++++++++++++++++++++++++++--- app/Controllers/configureController.php | 7 ----- app/views/configure/categorize.phtml | 9 ++++++- 3 files changed, 52 insertions(+), 11 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 6863c3bb8..be8524749 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -55,7 +55,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { if ($catDAO->addCategory($values)) { Minz_Request::good(_t('category_created', $cat->name()), $url_redirect); } else { - Minz_Request::bad(_t('error_occured'), $url_redirect); + Minz_Request::bad(_t('error_occurred'), $url_redirect); } } @@ -63,7 +63,48 @@ class FreshRSS_category_Controller extends Minz_ActionController { } /** - * This action deletes all the feeds relative to a given category + * This action deletes a category. + * Feeds in the given category are moved in the default category. + * Related user queries are deleted too. + * + * Request parameter is: + * - id (of a category) + */ + public function deleteAction() { + $feedDAO = FreshRSS_Factory::createFeedDao(); + $catDAO = new FreshRSS_CategoryDAO(); + $default_category = $catDAO->getDefault(); + $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + + if (Minz_Request::isPost()) { + invalidateHttpCache(); + + $id = Minz_Request::param('id'); + if (!$id) { + Minz_Request::bad(_t('category_no_id'), $url_redirect); + } + + if ($feedDAO->changeCategory($id, $default_category->id()) === false) { + Minz_Request::bad(_t('error_occurred'), $url_redirect); + } + + if ($catDAO->deleteCategory($id) === false) { + Minz_Request::bad(_t('error_occurred'), $url_redirect); + } + + // Remove related queries. + $this->view->conf->remove_query_by_get('c_' . $id); + $this->view->conf->save(); + + Minz_Request::good(_t('category_deleted'), $url_redirect); + } + + Minz_Request::forward($url_redirect, true); + } + + /** + * This action deletes all the feeds relative to a given category. + * Feed-related queries are deleted. * * Request parameter is: * - id (of a category) @@ -94,7 +135,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { Minz_Request::good(_t('category_emptied'), $url_redirect); } else { - Minz_Request::bad(_t('error_occured'), $url_redirect); + Minz_Request::bad(_t('error_occurred'), $url_redirect); } } diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 7ef144090..a7def6d9a 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -53,13 +53,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { 'name' => $cat->name(), ); $catDAO->updateCategory($ids[$key], $values); - } elseif ($ids[$key] != $defaultId) { - $feedDAO->changeCategory($ids[$key], $defaultId); - $catDAO->deleteCategory($ids[$key]); - - // Remove related queries. - $this->view->conf->remove_query_by_get('c_' . $ids[$key]); - $this->view->conf->save(); } } diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 5cd962ae4..781c4bb14 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -44,7 +44,14 @@ formaction="id()); ?>"> -
  • +
  • + +
  • -- cgit v1.2.3 From dc714d3949373b79344438335cfc0edde77de036 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 30 Sep 2014 17:11:31 +0200 Subject: Cat updating system works Add a submit button Each box contains a specific form See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/categoryController.php | 39 ++++++++++++++++++++++++ app/views/configure/categorize.phtml | 54 +++++++++++++++++++--------------- 2 files changed, 69 insertions(+), 24 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index be8524749..65fe631cc 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -62,6 +62,45 @@ class FreshRSS_category_Controller extends Minz_ActionController { Minz_Request::forward($url_redirect, true); } + /** + * This action updates the given category. + * + * Request parameters are: + * - id + * - name + */ + public function updateAction() { + $catDAO = new FreshRSS_CategoryDAO(); + $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + + if (Minz_Request::isPost()) { + invalidateHttpCache(); + + $id = Minz_Request::param('id'); + $name = Minz_Request::param('name', ''); + if (strlen($name) <= 0) { + Minz_Request::bad(_t('category_no_name'), $url_redirect); + } + + if ($catDAO->searchById($id) == null) { + Minz_Request::bad(_t('category_not_exist'), $url_redirect); + } + + $cat = new FreshRSS_Category($name); + $values = array( + 'name' => $cat->name(), + ); + + if ($catDAO->updateCategory($id, $values)) { + Minz_Request::good(_t('category_updated'), $url_redirect); + } else { + Minz_Request::bad(_t('error_occurred'), $url_redirect); + } + } + + Minz_Request::forward($url_redirect, true); + } + /** * This action deletes a category. * Feeds in the given category are moved in the default category. diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 781c4bb14..b9d04ddb8 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -28,32 +28,38 @@ ?>
    - - + + +
    +
      -- cgit v1.2.3 From a5a0bd9a350836cb7e504fdb501c82cda37d2562 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 30 Sep 2014 22:28:47 +0200 Subject: SQL performance: Removed filter to hide old articles As discussed on https://github.com/marienfressinaud/FreshRSS/issues/493#issuecomment-56266415 For performance, but this is also a good simplification. Will help with PostgreSQL https://github.com/marienfressinaud/FreshRSS/issues/416 and SQLite too https://github.com/marienfressinaud/FreshRSS/issues/100 because the main query becomes simpler. Me may need to introduce another system to hide old articles, if this is a problem for some users. Also, the feature showing "empty feeds" in another colour may need to be adapted. --- app/Controllers/indexController.php | 12 +++--------- app/Models/EntryDAO.php | 29 ++++++++++------------------- 2 files changed, 13 insertions(+), 28 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index e8e26b142..1b6563bb3 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -113,16 +113,10 @@ class FreshRSS_index_Controller extends Minz_ActionController { } } - $today = @strtotime('today'); - $this->view->today = $today; - - // on calcule la date des articles les plus anciens qu'on affiche - $nb_month_old = $this->view->conf->old_entries; - $date_min = $today - (3600 * 24 * 30 * $nb_month_old); //Do not use a fast changing value such as time() to allow SQL caching - $keepHistoryDefault = $this->view->conf->keep_history_default; + $this->view->today = @strtotime('today'); try { - $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb + 1, $first, $filter, $date_min, true, $keepHistoryDefault); + $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb + 1, $first, $filter); // Si on a récupéré aucun article "non lus" // on essaye de récupérer tous les articles @@ -135,7 +129,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Log::record('Failed to automatically correct nbNotRead! ' + $ex->getMessage(), Minz_Log::NOTICE); } $this->view->state = FreshRSS_Entry::STATE_ALL; - $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb, $first, $filter, $date_min, true, $keepHistoryDefault); + $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb, $first, $filter); } Minz_Request::_param('state', $this->view->state); diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index c1f87ee34..751ee6da7 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -299,7 +299,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return 'CONCAT(' . $s1 . ',' . $s2 . ')'; //MySQL } - private function sqlListWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { + private function sqlListWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { if (!$state) { $state = FreshRSS_Entry::STATE_ALL; } @@ -356,23 +356,14 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { default: throw new FreshRSS_EntriesGetter_Exception('Bad order in Entry->listByType: [' . $order . ']!'); } - if ($firstId === '' && parent::$sharedDbType === 'mysql') { - $firstId = $order === 'DESC' ? '9000000000'. '000000' : '0'; //MySQL optimization. Tested on MySQL 5.5 with 150k articles - } + /*if ($firstId === '' && parent::$sharedDbType === 'mysql') { + $firstId = $order === 'DESC' ? '9000000000'. '000000' : '0'; //MySQL optimization. TODO: check if this is needed again, after the filtering for old articles has been removed in 0.9-dev + }*/ if ($firstId !== '') { $where .= 'AND e1.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' '; } - if (($date_min > 0) && ($type !== 's')) { - $where .= 'AND (e1.id >= ' . $date_min . '000000'; - if ($showOlderUnreadsorFavorites) { //Lax date constraint - $where .= ' OR e1.is_read=0 OR e1.is_favorite=1 OR (f.keep_history <> 0'; - if (intval($keepHistoryDefault) === 0) { - $where .= ' AND f.keep_history <> -2'; //default - } - $where .= ')'; - } - $where .= ') '; - $joinFeed = true; + if ($date_min > 0) { + $where .= 'AND e1.id >= ' . $date_min . '000000 '; } $search = ''; if ($filter !== '') { @@ -434,8 +425,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { . ($limit > 0 ? ' LIMIT ' . $limit : '')); //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/ } - public function listWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { - list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault); + public function listWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { + list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min); $sql = 'SELECT e.id, e.guid, e.title, e.author, ' . ($this->isCompressed() ? 'UNCOMPRESS(content_bin) AS content' : 'content') @@ -452,8 +443,8 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return self::daoToEntry($stm->fetchAll(PDO::FETCH_ASSOC)); } - public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { //For API - list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault); + public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) { //For API + list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min); $stm = $this->bd->prepare($sql); $stm->execute($values); -- cgit v1.2.3 From 7481887db746fd2d6eefab021776b8abd4076429 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 1 Oct 2014 10:06:04 +0200 Subject: Load feed configuration on the same page Need improvements See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/configureController.php | 4 ++++ app/views/configure/categorize.phtml | 5 ++++- app/views/configure/feed.phtml | 8 ++++++-- p/scripts/main.js | 30 ++++++++++++++++++++++++++++++ p/themes/base-theme/template.css | 5 +++++ 5 files changed, 49 insertions(+), 3 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index a7def6d9a..dd7a0a441 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -90,6 +90,10 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * Default values are empty strings unless specified. */ public function feedAction() { + if (Minz_Request::param('ajax')) { + $this->view->_useLayout(false); + } + $catDAO = new FreshRSS_CategoryDAO(); $this->view->categories = $catDAO->listCategories(false); diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 8f77f9724..008dc8c98 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -73,7 +73,7 @@ $empty = $feed->nbEntries() == 0 ? ' empty' : ''; ?>
    • - + ✇ name(); ?>
    • + +
      +
      diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index e96a28739..f58ac65af 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -1,8 +1,12 @@ -partial ('aside_feed'); ?> +partial('aside_feed'); + } +?> flux) { ?>
      - +

      flux->name (); ?>

      flux->description (); ?> diff --git a/p/scripts/main.js b/p/scripts/main.js index f6d5d2907..7fed7a819 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1240,6 +1240,35 @@ function faviconNbUnread(n) { } } +function init_slider_observers() { + var slider = $('#slider'); + if (slider.length < 1) { + return; + } + + $('.open-slider').on('click', function() { + if (ajax_loading) { + return false; + } + + ajax_loading = true; + + var url_slide = $(this).attr('href'); + + $.ajax({ + type: 'GET', + url: url_slide, + data : { ajax: true } + }).done(function (data) { + slider.html(data); + slider.show(); + ajax_loading = false; + }); + + return false; + }) +} + function init_all() { if (!(window.$ && window.url_freshrss)) { if (window.console) { @@ -1275,6 +1304,7 @@ function init_all() { init_feed_observers(); init_password_observers(); init_stats_observers(); + init_slider_observers(); } if (window.console) { diff --git a/p/themes/base-theme/template.css b/p/themes/base-theme/template.css index a5a29ab23..397f943a6 100644 --- a/p/themes/base-theme/template.css +++ b/p/themes/base-theme/template.css @@ -645,6 +645,11 @@ br + br + br { display: none; } +/*=== Slider */ +#slider { + min-height: 50px; +} + /*=== DIVERS */ /*===========*/ .nav-login, -- cgit v1.2.3 From fdb63fbbe695b6a6bc32f0e93f2ff702ca42329c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 1 Oct 2014 10:19:38 +0200 Subject: Simplify configureController Remove useless code for category configuration. See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/configureController.php | 33 +-------------------------------- app/views/configure/categorize.phtml | 2 +- 2 files changed, 2 insertions(+), 33 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index dd7a0a441..3fd1d5149 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -28,43 +28,12 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * This action handles the category configuration page * * It displays the category configuration page. - * If this action is reached through a POST request, it loops through - * every category to check for modification then add a new category if - * needed then sends a notification to the user. - * If a category name is emptied, the category is deleted and all - * related feeds are moved to the default category. Related user queries - * are deleted too. - * If a category name is changed, it is updated. */ public function categorizeAction() { - $feedDAO = FreshRSS_Factory::createFeedDao(); $catDAO = new FreshRSS_CategoryDAO(); - $defaultCategory = $catDAO->getDefault(); - $defaultId = $defaultCategory->id(); - - if (Minz_Request::isPost()) { - $cats = Minz_Request::param('categories', array()); - $ids = Minz_Request::param('ids', array()); - - foreach ($cats as $key => $name) { - if (strlen($name) > 0) { - $cat = new FreshRSS_Category($name); - $values = array( - 'name' => $cat->name(), - ); - $catDAO->updateCategory($ids[$key], $values); - } - } - - invalidateHttpCache(); - - Minz_Request::good(_t('categories_updated'), - array('c' => 'configure', 'a' => 'categorize')); - } $this->view->categories = $catDAO->listCategories(false); - $this->view->defaultCategory = $catDAO->getDefault(); - $this->view->feeds = $feedDAO->listFeeds(); + $this->view->default_category = $catDAO->getDefault(); Minz_View::prependTitle(_t('categories_management') . ' · '); } diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml index 008dc8c98..f5030ef2c 100644 --- a/app/views/configure/categorize.phtml +++ b/app/views/configure/categorize.phtml @@ -6,7 +6,7 @@

      - defaultCategory->name()); ?> + default_category->name()); ?>

      -- cgit v1.2.3 From 1eef7893068655f8d145a3e06061a9e6296ac1f3 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 1 Oct 2014 11:27:41 +0200 Subject: Reorganize subscription management code There is still a lot of work to do. Some links are broken. See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/configureController.php | 116 ------------------ app/Controllers/subscriptionController.php | 130 ++++++++++++++++++++ app/Models/Themes.php | 1 + app/layout/aside_feed.phtml | 60 ---------- app/layout/aside_flux.phtml | 4 +- app/layout/aside_subscription.phtml | 17 +++ app/views/configure/categorize.phtml | 90 -------------- app/views/configure/feed.phtml | 186 ----------------------------- app/views/importExport/index.phtml | 2 +- app/views/subscription/feed.phtml | 186 +++++++++++++++++++++++++++++ app/views/subscription/index.phtml | 132 ++++++++++++++++++++ p/themes/icons/import.svg | 9 ++ 12 files changed, 478 insertions(+), 455 deletions(-) create mode 100644 app/Controllers/subscriptionController.php delete mode 100644 app/layout/aside_feed.phtml create mode 100644 app/layout/aside_subscription.phtml delete mode 100644 app/views/configure/categorize.phtml delete mode 100644 app/views/configure/feed.phtml create mode 100644 app/views/subscription/feed.phtml create mode 100644 app/views/subscription/index.phtml create mode 100644 p/themes/icons/import.svg (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 3fd1d5149..b7b88b3ba 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -8,9 +8,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * This action is called before every other action in that class. It is * the common boiler plate for every action. It is triggered by the * underlying framework. - * - * @todo see if the category default configuration is needed here or if - * we can move it to the categorize action */ public function firstAction() { if (!$this->view->loginOk) { @@ -19,119 +16,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { array('error' => array(_t('access_denied'))) ); } - - $catDAO = new FreshRSS_CategoryDAO(); - $catDAO->checkDefault(); - } - - /** - * This action handles the category configuration page - * - * It displays the category configuration page. - */ - public function categorizeAction() { - $catDAO = new FreshRSS_CategoryDAO(); - - $this->view->categories = $catDAO->listCategories(false); - $this->view->default_category = $catDAO->getDefault(); - - Minz_View::prependTitle(_t('categories_management') . ' · '); - } - - /** - * This action handles the feed configuration page. - * - * It displays the feed configuration page. - * If this action is reached through a POST request, it stores all new - * configuraiton values then sends a notification to the user. - * - * The options available on the page are: - * - name - * - description - * - website URL - * - feed URL - * - category id (default: default category id) - * - CSS path to article on website - * - display in main stream (default: 0) - * - HTTP authentication - * - number of article to retain (default: -2) - * - refresh frequency (default: -2) - * Default values are empty strings unless specified. - */ - public function feedAction() { - if (Minz_Request::param('ajax')) { - $this->view->_useLayout(false); - } - - $catDAO = new FreshRSS_CategoryDAO(); - $this->view->categories = $catDAO->listCategories(false); - - $feedDAO = FreshRSS_Factory::createFeedDao(); - $this->view->feeds = $feedDAO->listFeeds(); - - $id = Minz_Request::param('id'); - if ($id == false && !empty($this->view->feeds)) { - $id = current($this->view->feeds)->id(); - } - - $this->view->flux = false; - if ($id != false) { - $this->view->flux = $this->view->feeds[$id]; - - if (!$this->view->flux) { - Minz_Error::error( - 404, - array('error' => array(_t('page_not_found'))) - ); - } else { - if (Minz_Request::isPost() && $this->view->flux) { - $user = Minz_Request::param('http_user', ''); - $pass = Minz_Request::param('http_pass', ''); - - $httpAuth = ''; - if ($user != '' || $pass != '') { - $httpAuth = $user . ':' . $pass; - } - - $cat = intval(Minz_Request::param('category', 0)); - - $values = array( - 'name' => Minz_Request::param('name', ''), - 'description' => sanitizeHTML(Minz_Request::param('description', '', true)), - 'website' => Minz_Request::param('website', ''), - 'url' => Minz_Request::param('url', ''), - 'category' => $cat, - 'pathEntries' => Minz_Request::param('path_entries', ''), - 'priority' => intval(Minz_Request::param('priority', 0)), - 'httpAuth' => $httpAuth, - 'keep_history' => intval(Minz_Request::param('keep_history', -2)), - 'ttl' => intval(Minz_Request::param('ttl', -2)), - ); - - if ($feedDAO->updateFeed($id, $values)) { - $this->view->flux->_category($cat); - $this->view->flux->faviconPrepare(); - $notif = array( - 'type' => 'good', - 'content' => _t('feed_updated') - ); - } else { - $notif = array( - 'type' => 'bad', - 'content' => _t('error_occurred_update') - ); - } - invalidateHttpCache(); - - Minz_Session::_param('notification', $notif); - Minz_Request::forward(array('c' => 'configure', 'a' => 'feed', 'params' => array('id' => $id)), true); - } - - Minz_View::prependTitle(_t('rss_feed_management') . ' — ' . $this->view->flux->name() . ' · '); - } - } else { - Minz_View::prependTitle(_t('rss_feed_management') . ' · '); - } } /** diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php new file mode 100644 index 000000000..ab00f3e6a --- /dev/null +++ b/app/Controllers/subscriptionController.php @@ -0,0 +1,130 @@ +view->loginOk) { + Minz_Error::error( + 403, + array('error' => array(_t('access_denied'))) + ); + } + } + + /** + * This action handles the main subscription page + * + * It displays categories and associated feeds. + */ + public function indexAction() { + $catDAO = new FreshRSS_CategoryDAO(); + + $this->view->categories = $catDAO->listCategories(false); + $this->view->default_category = $catDAO->getDefault(); + + Minz_View::prependTitle(_t('subscription_management') . ' · '); + } + + /** + * This action handles the feed configuration page. + * + * It displays the feed configuration page. + * If this action is reached through a POST request, it stores all new + * configuraiton values then sends a notification to the user. + * + * The options available on the page are: + * - name + * - description + * - website URL + * - feed URL + * - category id (default: default category id) + * - CSS path to article on website + * - display in main stream (default: 0) + * - HTTP authentication + * - number of article to retain (default: -2) + * - refresh frequency (default: -2) + * Default values are empty strings unless specified. + */ + public function feedAction() { + if (Minz_Request::param('ajax')) { + $this->view->_useLayout(false); + } + + $catDAO = new FreshRSS_CategoryDAO(); + $this->view->categories = $catDAO->listCategories(false); + + $feedDAO = FreshRSS_Factory::createFeedDao(); + $this->view->feeds = $feedDAO->listFeeds(); + + $id = Minz_Request::param('id'); + if ($id == false && !empty($this->view->feeds)) { + $id = current($this->view->feeds)->id(); + } + + $this->view->flux = false; + if ($id != false) { + $this->view->flux = $this->view->feeds[$id]; + + if (!$this->view->flux) { + Minz_Error::error( + 404, + array('error' => array(_t('page_not_found'))) + ); + } else { + if (Minz_Request::isPost() && $this->view->flux) { + $user = Minz_Request::param('http_user', ''); + $pass = Minz_Request::param('http_pass', ''); + + $httpAuth = ''; + if ($user != '' || $pass != '') { + $httpAuth = $user . ':' . $pass; + } + + $cat = intval(Minz_Request::param('category', 0)); + + $values = array( + 'name' => Minz_Request::param('name', ''), + 'description' => sanitizeHTML(Minz_Request::param('description', '', true)), + 'website' => Minz_Request::param('website', ''), + 'url' => Minz_Request::param('url', ''), + 'category' => $cat, + 'pathEntries' => Minz_Request::param('path_entries', ''), + 'priority' => intval(Minz_Request::param('priority', 0)), + 'httpAuth' => $httpAuth, + 'keep_history' => intval(Minz_Request::param('keep_history', -2)), + 'ttl' => intval(Minz_Request::param('ttl', -2)), + ); + + if ($feedDAO->updateFeed($id, $values)) { + $this->view->flux->_category($cat); + $this->view->flux->faviconPrepare(); + $notif = array( + 'type' => 'good', + 'content' => _t('feed_updated') + ); + } else { + $notif = array( + 'type' => 'bad', + 'content' => _t('error_occurred_update') + ); + } + invalidateHttpCache(); + + Minz_Session::_param('notification', $notif); + Minz_Request::forward(array('c' => 'subscription'), true); + } + + Minz_View::prependTitle(_t('rss_feed_management') . ' · ' . $this->view->flux->name() . ' · '); + } + } else { + Minz_View::prependTitle(_t('rss_feed_management') . ' · '); + } + } +} diff --git a/app/Models/Themes.php b/app/Models/Themes.php index 68fc17a2b..e3b260261 100644 --- a/app/Models/Themes.php +++ b/app/Models/Themes.php @@ -82,6 +82,7 @@ class FreshRSS_Themes extends Minz_Model { 'favorite' => '★', 'help' => 'ⓘ', 'icon' => '⊚', + 'import' => '⤓', 'key' => '⚿', 'link' => '↗', 'login' => '🔒', diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml deleted file mode 100644 index c028c4918..000000000 --- a/app/layout/aside_feed.phtml +++ /dev/null @@ -1,60 +0,0 @@ - diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index aac3c0896..341697103 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -7,8 +7,8 @@
    • - - + +
    • diff --git a/app/layout/aside_subscription.phtml b/app/layout/aside_subscription.phtml new file mode 100644 index 000000000..9a95763c3 --- /dev/null +++ b/app/layout/aside_subscription.phtml @@ -0,0 +1,17 @@ + diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtml deleted file mode 100644 index f5030ef2c..000000000 --- a/app/views/configure/categorize.phtml +++ /dev/null @@ -1,90 +0,0 @@ -partial('aside_feed'); ?> - -
      - - -

      - -

      - default_category->name()); ?> -

      - -
      -
      - -
        -
        -
      • -
      • -
        -
      -
      - - - - categories as $cat) { - $feeds = $cat->feeds(); - ?> -
      -
      -
      - - - -
      -
      - -
        - - inError() ? ' error' : ''; - $empty = $feed->nbEntries() == 0 ? ' empty' : ''; - ?> -
      • - - ✇ name(); ?> -
      • - -
      • - -
      -
      - -
      - -
      -
      diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml deleted file mode 100644 index f58ac65af..000000000 --- a/app/views/configure/feed.phtml +++ /dev/null @@ -1,186 +0,0 @@ -partial('aside_feed'); - } -?> - -flux) { ?> -
      - - -

      flux->name (); ?>

      - flux->description (); ?> - - flux->nbEntries (); ?> - - flux->inError ()) { ?> -

      - -

      - - -
      - -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      - -
      -
      - - -
      -
      -
      -
      - -
      -
      - - -
      - - -
      -
      -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      -
      - - - -
      -
      -
      -
      - - -
      -
      - - - -
      -
      -
      - - - - -
      -
      -
      -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      -
      - - -
      -
      - - - flux->httpAuth (false); ?> -
      - -
      - - -
      - - -
      - -
      -
      - -
      -
      - - -
      -
      - - -
      - -
      - - -
      -
      - -
      -
      - - -
      -
      -
      -
      - - -
      - diff --git a/app/views/importExport/index.phtml b/app/views/importExport/index.phtml index 35371faca..36c0eab4e 100644 --- a/app/views/importExport/index.phtml +++ b/app/views/importExport/index.phtml @@ -1,4 +1,4 @@ -partial('aside_feed'); ?> +partial('aside_subscription'); ?>
      diff --git a/app/views/subscription/feed.phtml b/app/views/subscription/feed.phtml new file mode 100644 index 000000000..e047741a1 --- /dev/null +++ b/app/views/subscription/feed.phtml @@ -0,0 +1,186 @@ +partial('aside_subscription'); + } +?> + +flux) { ?> +
      + + +

      flux->name (); ?>

      + flux->description (); ?> + + flux->nbEntries (); ?> + + flux->inError ()) { ?> +

      + +

      + + +
      + +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      +
      + + +
      +
      +
      +
      + +
      +
      + + +
      + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      +
      + + + +
      +
      +
      +
      + + +
      +
      + + + +
      +
      +
      + + + + +
      +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      +
      + + +
      +
      + + + flux->httpAuth (false); ?> +
      + +
      + + +
      + + +
      + +
      +
      + +
      +
      + + +
      +
      + + +
      + +
      + + +
      +
      + +
      +
      + + +
      +
      +
      +
      + + +
      + diff --git a/app/views/subscription/index.phtml b/app/views/subscription/index.phtml new file mode 100644 index 000000000..444dc9d9b --- /dev/null +++ b/app/views/subscription/index.phtml @@ -0,0 +1,132 @@ +partial('aside_subscription'); ?> + +
      + + +

      + +
      +
      + + + +
      +
      + +

      + default_category->name()); ?> +

      + +
      +
      + +
        +
        +
      • +
      • +
        +
      +
      + + + + categories as $cat) { + $feeds = $cat->feeds(); + ?> +
      +
      +
      + + + +
      +
      + +
        + + inError() ? ' error' : ''; + $empty = $feed->nbEntries() == 0 ? ' empty' : ''; + ?> +
      • + + ✇ name(); ?> +
      • + +
      • + +
      +
      + +
      + +
      +
      diff --git a/p/themes/icons/import.svg b/p/themes/icons/import.svg new file mode 100644 index 000000000..a7f20c909 --- /dev/null +++ b/p/themes/icons/import.svg @@ -0,0 +1,9 @@ + + + + + + + + + -- cgit v1.2.3 From 89c407d7d7f739e42d9e72e40304bbbef00c9b10 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 1 Oct 2014 11:58:08 +0200 Subject: Add selected feed on main subscription page - When an id is given, corresponding feed is displayed - Refactor code - Improve coding style See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/subscriptionController.php | 116 ++++++++---------- app/views/helpers/feed/update.phtml | 175 ++++++++++++++++++++++++++ app/views/subscription/feed.phtml | 191 ++--------------------------- app/views/subscription/index.phtml | 5 + 4 files changed, 242 insertions(+), 245 deletions(-) create mode 100644 app/views/helpers/feed/update.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index ab00f3e6a..83f803edb 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -16,6 +16,11 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { array('error' => array(_t('access_denied'))) ); } + + $catDAO = new FreshRSS_CategoryDAO(); + + $this->view->categories = $catDAO->listCategories(false); + $this->view->default_category = $catDAO->getDefault(); } /** @@ -24,12 +29,13 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { * It displays categories and associated feeds. */ public function indexAction() { - $catDAO = new FreshRSS_CategoryDAO(); - - $this->view->categories = $catDAO->listCategories(false); - $this->view->default_category = $catDAO->getDefault(); - Minz_View::prependTitle(_t('subscription_management') . ' · '); + + $id = Minz_Request::param('id'); + if ($id !== false) { + $feedDAO = FreshRSS_Factory::createFeedDao(); + $this->view->feed = $feedDAO->searchById($id); + } } /** @@ -57,74 +63,56 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { $this->view->_useLayout(false); } - $catDAO = new FreshRSS_CategoryDAO(); - $this->view->categories = $catDAO->listCategories(false); - $feedDAO = FreshRSS_Factory::createFeedDao(); $this->view->feeds = $feedDAO->listFeeds(); $id = Minz_Request::param('id'); - if ($id == false && !empty($this->view->feeds)) { - $id = current($this->view->feeds)->id(); + if ($id === false || !isset($this->view->feeds[$id])) { + Minz_Error::error( + 404, + array('error' => array(_t('page_not_found'))) + ); + return; } - $this->view->flux = false; - if ($id != false) { - $this->view->flux = $this->view->feeds[$id]; + $this->view->feed = $this->view->feeds[$id]; + + Minz_View::prependTitle(_t('rss_feed_management') . ' · ' . $this->view->feed->name() . ' · '); + + if (Minz_Request::isPost()) { + $user = Minz_Request::param('http_user', ''); + $pass = Minz_Request::param('http_pass', ''); + + $httpAuth = ''; + if ($user != '' || $pass != '') { + $httpAuth = $user . ':' . $pass; + } + + $cat = intval(Minz_Request::param('category', 0)); + + $values = array( + 'name' => Minz_Request::param('name', ''), + 'description' => sanitizeHTML(Minz_Request::param('description', '', true)), + 'website' => Minz_Request::param('website', ''), + 'url' => Minz_Request::param('url', ''), + 'category' => $cat, + 'pathEntries' => Minz_Request::param('path_entries', ''), + 'priority' => intval(Minz_Request::param('priority', 0)), + 'httpAuth' => $httpAuth, + 'keep_history' => intval(Minz_Request::param('keep_history', -2)), + 'ttl' => intval(Minz_Request::param('ttl', -2)), + ); + + invalidateHttpCache(); + + if ($feedDAO->updateFeed($id, $values)) { + $this->view->feed->_category($cat); + $this->view->feed->faviconPrepare(); - if (!$this->view->flux) { - Minz_Error::error( - 404, - array('error' => array(_t('page_not_found'))) - ); + Minz_Request::good(_t('feed_updated'), array('c' => 'subscription', 'params' => array('id' => $id))); } else { - if (Minz_Request::isPost() && $this->view->flux) { - $user = Minz_Request::param('http_user', ''); - $pass = Minz_Request::param('http_pass', ''); - - $httpAuth = ''; - if ($user != '' || $pass != '') { - $httpAuth = $user . ':' . $pass; - } - - $cat = intval(Minz_Request::param('category', 0)); - - $values = array( - 'name' => Minz_Request::param('name', ''), - 'description' => sanitizeHTML(Minz_Request::param('description', '', true)), - 'website' => Minz_Request::param('website', ''), - 'url' => Minz_Request::param('url', ''), - 'category' => $cat, - 'pathEntries' => Minz_Request::param('path_entries', ''), - 'priority' => intval(Minz_Request::param('priority', 0)), - 'httpAuth' => $httpAuth, - 'keep_history' => intval(Minz_Request::param('keep_history', -2)), - 'ttl' => intval(Minz_Request::param('ttl', -2)), - ); - - if ($feedDAO->updateFeed($id, $values)) { - $this->view->flux->_category($cat); - $this->view->flux->faviconPrepare(); - $notif = array( - 'type' => 'good', - 'content' => _t('feed_updated') - ); - } else { - $notif = array( - 'type' => 'bad', - 'content' => _t('error_occurred_update') - ); - } - invalidateHttpCache(); - - Minz_Session::_param('notification', $notif); - Minz_Request::forward(array('c' => 'subscription'), true); - } - - Minz_View::prependTitle(_t('rss_feed_management') . ' · ' . $this->view->flux->name() . ' · '); + Minz_Request::bad(_t('error_occurred_update'), array('c' => 'subscription')); } - } else { - Minz_View::prependTitle(_t('rss_feed_management') . ' · '); } } } diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml new file mode 100644 index 000000000..4a6425c45 --- /dev/null +++ b/app/views/helpers/feed/update.phtml @@ -0,0 +1,175 @@ +
      + + +

      feed->name (); ?>

      + feed->description (); ?> + + feed->nbEntries (); ?> + + feed->inError ()) { ?> +

      + +

      + + +
      + +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      +
      + + +
      +
      +
      +
      + +
      +
      + + +
      + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      +
      + + + +
      +
      +
      +
      + + +
      +
      + + + +
      +
      +
      + + + + +
      +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      +
      + + +
      +
      + + + feed->httpAuth (false); ?> +
      + +
      + + +
      + + +
      + +
      +
      + +
      +
      + + +
      +
      + + +
      + +
      + + +
      +
      + +
      +
      + + +
      +
      +
      +
      diff --git a/app/views/subscription/feed.phtml b/app/views/subscription/feed.phtml index e047741a1..48a401c4a 100644 --- a/app/views/subscription/feed.phtml +++ b/app/views/subscription/feed.phtml @@ -1,186 +1,15 @@ partial('aside_subscription'); - } -?> - -flux) { ?> -
      - - -

      flux->name (); ?>

      - flux->description (); ?> - - flux->nbEntries (); ?> - - flux->inError ()) { ?> -

      - -

      - - -
      - -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      - -
      -
      - - -
      -
      -
      -
      - -
      -
      - - -
      - - -
      -
      -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      -
      - - - -
      -
      -
      -
      - - -
      -
      - +if (!Minz_Request::param('ajax')) { + $this->partial('aside_subscription'); +} -
      -
      -
      - - - - -
      -
      -
      -
      - -
      - -
      -
      -
      - -
      - -
      -
      -
      -
      - - -
      -
      - - - flux->httpAuth (false); ?> -
      - -
      - - -
      - - -
      - -
      -
      - -
      -
      - - -
      -
      - - -
      - -
      - - -
      -
      - -
      -
      - - -
      -
      -
      +if ($this->feed) { + $this->renderHelper('feed/update'); +} else { +?> +
      + +
      - - -
      diff --git a/app/views/subscription/index.phtml b/app/views/subscription/index.phtml index 444dc9d9b..bce9eacf1 100644 --- a/app/views/subscription/index.phtml +++ b/app/views/subscription/index.phtml @@ -129,4 +129,9 @@
      +feed) && $this->feed) { + $this->renderHelper('feed/update'); + } +?>
      -- cgit v1.2.3 From a7bf7ced369a046b487ab1cd8b3819acc5ebdafe Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 1 Oct 2014 12:18:32 +0200 Subject: Fix links for feed management See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/categoryController.php | 8 ++++---- app/Controllers/feedController.php | 16 +++++++++------- app/layout/aside_flux.phtml | 2 +- app/views/helpers/view/global_view.phtml | 2 +- app/views/helpers/view/normal_view.phtml | 2 +- app/views/helpers/view/reader_view.phtml | 2 +- app/views/stats/idle.phtml | 2 +- app/views/stats/repartition.phtml | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 65fe631cc..2c99751a4 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -31,7 +31,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { */ public function createAction() { $catDAO = new FreshRSS_CategoryDAO(); - $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + $url_redirect = array('c' => 'subscription', 'a' => 'index'); if (Minz_Request::isPost()) { invalidateHttpCache(); @@ -71,7 +71,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { */ public function updateAction() { $catDAO = new FreshRSS_CategoryDAO(); - $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + $url_redirect = array('c' => 'subscription', 'a' => 'index'); if (Minz_Request::isPost()) { invalidateHttpCache(); @@ -113,7 +113,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { $feedDAO = FreshRSS_Factory::createFeedDao(); $catDAO = new FreshRSS_CategoryDAO(); $default_category = $catDAO->getDefault(); - $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + $url_redirect = array('c' => 'subscription', 'a' => 'index'); if (Minz_Request::isPost()) { invalidateHttpCache(); @@ -150,7 +150,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { */ public function emptyAction() { $feedDAO = FreshRSS_Factory::createFeedDao(); - $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + $url_redirect = array('c' => 'subscription', 'a' => 'index'); if (Minz_Request::isPost()) { invalidateHttpCache(); diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 7ef427ac2..e4859b110 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -26,8 +26,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($url === false) { Minz_Request::forward(array( - 'c' => 'configure', - 'a' => 'feed' + 'c' => 'subscription', + 'a' => 'index' ), true); } @@ -166,7 +166,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->rollBack (); } - Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => $params), true); + Minz_Request::forward (array ('c' => 'subscription', 'a' => 'index', 'params' => $params), true); } else { // GET request so we must ask confirmation to user @@ -193,8 +193,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Session::_param('notification', $notif); Minz_Request::forward(array( - 'c' => 'configure', - 'a' => 'feed', + 'c' => 'subscription', + 'a' => 'index', 'params' => array( 'id' => $feed->id() ) @@ -214,7 +214,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { ); Minz_Session::_param ('notification', $notif); invalidateHttpCache(); - Minz_Request::forward (array ('c' => 'configure', 'a' => 'feed', 'params' => array('id' => $id)), true); + Minz_Request::forward (array ('c' => 'subscription', + 'a' => 'index', + 'params' => array('id' => $id)), true); } } @@ -405,7 +407,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($redirect_url) { Minz_Request::forward($redirect_url); } else { - Minz_Request::forward(array('c' => 'configure', 'a' => 'feed'), true); + Minz_Request::forward(array('c' => 'subscription', 'a' => 'index'), true); } } } diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index 341697103..a8ae2f424 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -89,7 +89,7 @@
    • loginOk) { ?>
    • -
    • +
    • conf->reading_confirm ? 'confirm' : ''; ?> diff --git a/app/views/helpers/view/global_view.phtml b/app/views/helpers/view/global_view.phtml index 72bcf4c73..5e4cad01a 100644 --- a/app/views/helpers/view/global_view.phtml +++ b/app/views/helpers/view/global_view.phtml @@ -48,6 +48,6 @@

      -

      +

      diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml index 6d9789f8d..e469edf58 100644 --- a/app/views/helpers/view/normal_view.phtml +++ b/app/views/helpers/view/normal_view.phtml @@ -186,6 +186,6 @@ if (!empty($this->entries)) {

      -

      +

      diff --git a/app/views/helpers/view/reader_view.phtml b/app/views/helpers/view/reader_view.phtml index c80dca519..413094239 100644 --- a/app/views/helpers/view/reader_view.phtml +++ b/app/views/helpers/view/reader_view.phtml @@ -39,6 +39,6 @@ if (!empty($this->entries)) {

      -

      +

      diff --git a/app/views/stats/idle.phtml b/app/views/stats/idle.phtml index 6f3d4a117..75cba1081 100644 --- a/app/views/stats/idle.phtml +++ b/app/views/stats/idle.phtml @@ -25,7 +25,7 @@
    • - +
    • diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index b425c1458..dac47e189 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -24,7 +24,7 @@ feed) {?> - + -- cgit v1.2.3 From f400621f44c2aac0b1bb4204e95e4c35a8a35f8f Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 1 Oct 2014 13:37:10 +0200 Subject: Fix problem when deleting default category This is not allowed! See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/categoryController.php | 4 ++++ app/Controllers/subscriptionController.php | 1 + app/views/subscription/index.phtml | 12 +++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 2c99751a4..c79f37fa4 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -123,6 +123,10 @@ class FreshRSS_category_Controller extends Minz_ActionController { Minz_Request::bad(_t('category_no_id'), $url_redirect); } + if ($id === $default_category->id()) { + Minz_Request::bad(_t('category_not_delete_default'), $url_redirect); + } + if ($feedDAO->changeCategory($id, $default_category->id()) === false) { Minz_Request::bad(_t('error_occurred'), $url_redirect); } diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index 83f803edb..aabae7b8f 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -19,6 +19,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { $catDAO = new FreshRSS_CategoryDAO(); + $catDAO->checkDefault(); $this->view->categories = $catDAO->listCategories(false); $this->view->default_category = $catDAO->getDefault(); } diff --git a/app/views/subscription/index.phtml b/app/views/subscription/index.phtml index bce9eacf1..2d55890f7 100644 --- a/app/views/subscription/index.phtml +++ b/app/views/subscription/index.phtml @@ -82,9 +82,14 @@
    • -
    • + id() === $this->default_category->id()); - + if (!$no_feed || !$is_default) { + ?> +
    • +
    • - +
    • +
    -- cgit v1.2.3 From db4da3babc0864099c5ab48e3583d0546a2759d8 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 11:39:51 +0200 Subject: First draft for drag and drop We can change feed category by drag and drop! Need improvements... See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/feedController.php | 15 ++++++++ app/Controllers/subscriptionController.php | 2 ++ app/views/subscription/index.phtml | 4 +-- p/scripts/category.js | 55 ++++++++++++++++++++++++++++++ p/scripts/main.js | 2 +- p/themes/Origine/origine.css | 9 +++++ 6 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 p/scripts/category.js (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index e4859b110..315665ef3 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -378,6 +378,21 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } + public function moveAction() { + if (Minz_Request::isPost()) { + $feed_id = Minz_Request::param('f_id'); + $cat_id = Minz_Request::param('c_id'); + + $feedDAO = FreshRSS_Factory::createFeedDao(); + + $values = array( + 'category' => $cat_id, + ); + + $feedDAO->updateFeed($feed_id, $values); + } + } + public function deleteAction() { if (Minz_Request::isPost()) { $id = Minz_Request::param('id'); diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index aabae7b8f..7cc8179a0 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -30,6 +30,8 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { * It displays categories and associated feeds. */ public function indexAction() { + Minz_View::appendScript(Minz_Url::display('/scripts/category.js?' . + @filemtime(PUBLIC_PATH . '/scripts/category.js'))); Minz_View::prependTitle(_t('subscription_management') . ' · '); $id = Minz_Request::param('id'); diff --git a/app/views/subscription/index.phtml b/app/views/subscription/index.phtml index 577ddd972..3a79a34e6 100644 --- a/app/views/subscription/index.phtml +++ b/app/views/subscription/index.phtml @@ -113,14 +113,14 @@ -
      +
        inError() ? ' error' : ''; $empty = $feed->nbEntries() == 0 ? ' empty' : ''; ?> -
      • +
      • ✇ name(); ?>
      • diff --git a/p/scripts/category.js b/p/scripts/category.js new file mode 100644 index 000000000..fe80c3b22 --- /dev/null +++ b/p/scripts/category.js @@ -0,0 +1,55 @@ +"use strict"; + + +function init_draggable() { + var feeds_draggable = '.box-content > .feed', + box_dropzone = '.box-content'; + + $('.box').on('dragstart', feeds_draggable, function(e) { + e.originalEvent.dataTransfer.effectAllowed = 'move'; + e.originalEvent.dataTransfer.setData('html', e.target.outerHTML); + e.originalEvent.dataTransfer.setData('feed-id', e.target.getAttribute('data-feed-id')); + }); + $('.box').on('dragend', feeds_draggable, function(e) { + var parent = e.target.parentNode; + parent.removeChild(e.target); + }); + + $('.box').on('dragenter', box_dropzone, function(e) { + $(e.target).addClass('drag-hover'); + }); + $('.box').on('dragleave', box_dropzone, function(e) { + $(e.target).removeClass('drag-hover'); + }); + $('.box').on('dragover', box_dropzone, function(e) { + e.originalEvent.dataTransfer.dropEffect = "move"; + + return false; + }); + $('.box').on('drop', box_dropzone, function(e) { + var feed_id = e.originalEvent.dataTransfer.getData('feed-id'), + cat_id = e.target.parentNode.getAttribute('data-cat-id'); + + $.ajax({ + type: 'POST', + url: './?c=feed&a=move', + data : { + f_id: feed_id, + c_id: cat_id + } + }); + + $(e.target).after(e.originalEvent.dataTransfer.getData('html')); + $(e.target).removeClass('drag-hover'); + return false; + }); +} + + +if (document.readyState && document.readyState !== 'loading') { + init_draggable(); +} else if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', function () { + init_draggable(); + }, false); +} diff --git a/p/scripts/main.js b/p/scripts/main.js index 005dc961b..e8055e00f 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1247,7 +1247,7 @@ function init_slider_observers() { return; } - $('.open-slider').on('click', function() { + $('.post').on('click', '.open-slider', function() { if (ajax_loading) { return false; } diff --git a/p/themes/Origine/origine.css b/p/themes/Origine/origine.css index e3ae85075..cf6c9a2ef 100644 --- a/p/themes/Origine/origine.css +++ b/p/themes/Origine/origine.css @@ -497,6 +497,15 @@ a.btn { visibility: visible; } +/*=== Draggable */ +.drag-hover { + background: #dfd; + transition: all linear 0.2s; +} +[draggable=true] { + cursor: grab; +} + /*=== STRUCTURE */ /*===============*/ /*=== Header */ -- cgit v1.2.3 From 408ac31dd8751eba037db216243958d396df1c8e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 19:02:43 +0200 Subject: Hack for dragleave (triggered on children!) See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/feedController.php | 7 ++++++- p/scripts/category.js | 33 ++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 315665ef3..b2b53185e 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -389,7 +389,12 @@ class FreshRSS_feed_Controller extends Minz_ActionController { 'category' => $cat_id, ); - $feedDAO->updateFeed($feed_id, $values); + if (!$feedDAO->updateFeed($feed_id, $values)) { + Minz_Error::error( + 404, + array('error' => array(_t('error_occurred'))) + ); + } } } diff --git a/p/scripts/category.js b/p/scripts/category.js index 37ad36b17..872d14490 100644 --- a/p/scripts/category.js +++ b/p/scripts/category.js @@ -4,6 +4,8 @@ var loading = false, dnd_successful = false; function dragend_process(t) { + t.style.display = 'none'; + if (loading) { window.setTimeout(function() { dragend_process(t); @@ -11,13 +13,13 @@ function dragend_process(t) { } if (!dnd_successful) { + t.style.display = 'block'; t.style.opacity = 1.0; } else { t.parentNode.removeChild(t); } } - function init_draggable() { if (!(window.$ && window.url_freshrss)) { if (window.console) { @@ -45,14 +47,31 @@ function init_draggable() { }); $('.drop-section').on('dragenter', dropzone, function(e) { - $(e.target).addClass('drag-hover'); + $(this).addClass('drag-hover'); + + e.preventDefault(); }); $('.drop-section').on('dragleave', dropzone, function(e) { - $(e.target).removeClass('drag-hover'); + var pos_this = $(this).position(), + scroll_top = $(document).scrollTop(), + top = pos_this.top, + left = pos_this.left, + right = left + $(this).width(), + bottom = top + $(this).height(), + mouse_x = e.originalEvent.screenX, + mouse_y = e.originalEvent.clientY + scroll_top; + + if (left <= mouse_x && mouse_x <= right && + top <= mouse_y && mouse_y <= bottom) { + // HACK because dragleave is triggered when hovering children! + return; + } + $(this).removeClass('drag-hover'); }); $('.drop-section').on('dragover', dropzone, function(e) { e.dataTransfer.dropEffect = "move"; + e.preventDefault(); return false; }); $('.drop-section').on('drop', dropzone, function(e) { @@ -70,14 +89,14 @@ function init_draggable() { } }).success(function() { $(e.target).after(e.dataTransfer.getData('text/html')); - loading = false; - }).complete(function() { dnd_successful = true; + }).complete(function() { + loading = false; }); - $(e.target).removeClass('drag-hover'); + $(this).removeClass('drag-hover'); - return false; + e.preventDefault(); }); } -- cgit v1.2.3 From 94520ee326d1ad7323172a6d92ec0645e4606b73 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 Oct 2014 22:02:09 +0200 Subject: Fix category not appear on feed.add page (GET) Must apply to 0.8.1 and 0.9.1 See https://github.com/marienfressinaud/FreshRSS/issues/649 --- app/Controllers/feedController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index b2b53185e..eb26d9786 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -171,7 +171,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // GET request so we must ask confirmation to user Minz_View::prependTitle(Minz_Translate::t('add_rss_feed') . ' · '); - $this->view->categories = $this->catDAO->listCategories(); + $this->view->categories = $this->catDAO->listCategories(false); $this->view->feed = new FreshRSS_Feed($url); try { // We try to get some more information about the feed -- cgit v1.2.3 From dd945df0cb2bae216b4612364506e74aa3259c0b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 3 Oct 2014 12:54:10 +0200 Subject: Fix category not change (updating feed on MySQL) See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/feedController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index eb26d9786..d694c103e 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -384,12 +384,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $cat_id = Minz_Request::param('c_id'); $feedDAO = FreshRSS_Factory::createFeedDao(); - $values = array( 'category' => $cat_id, ); - if (!$feedDAO->updateFeed($feed_id, $values)) { + $feed = $feedDAO->searchById($feed_id); + + if (!$feed || ($feed->category() != $cat_id && + !$feedDAO->updateFeed($feed_id, $values))) { Minz_Error::error( 404, array('error' => array(_t('error_occurred'))) -- cgit v1.2.3 From 5474803aa7a05e4afa851c88bf21fd8383bf59d9 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 10:57:50 +0200 Subject: Add a TODO in feedController --- app/Controllers/feedController.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index d694c103e..92ce40634 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -390,8 +390,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed = $feedDAO->searchById($feed_id); - if (!$feed || ($feed->category() != $cat_id && - !$feedDAO->updateFeed($feed_id, $values))) { + if ($feed && ($feed->category() == $cat_id || + $feedDAO->updateFeed($feed_id, $values))) { + // TODO: return something useful + } else { Minz_Error::error( 404, array('error' => array(_t('error_occurred'))) -- cgit v1.2.3 From 6c8b36f04ea1bc2c022c331bb0980b6c9dccb83c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 15:55:20 +0200 Subject: Let's begin the big refactoring! Minz_Translate::t\s? replaces by _t See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/entryController.php | 8 ++-- app/Controllers/errorController.php | 4 +- app/Controllers/feedController.php | 30 ++++++------- app/Controllers/indexController.php | 22 +++++----- app/Controllers/statsController.php | 4 +- app/Controllers/usersController.php | 8 ++-- app/FreshRSS.php | 2 +- app/Models/CategoryDAO.php | 2 +- app/Models/StatsDAO.php | 2 +- app/Models/UserDAO.php | 4 +- app/layout/aside_stats.phtml | 14 +++--- app/views/configure/archiving.phtml | 36 ++++++++-------- app/views/configure/display.phtml | 44 +++++++++---------- app/views/configure/reading.phtml | 64 +++++++++++++-------------- app/views/configure/sharing.phtml | 24 +++++------ app/views/configure/users.phtml | 74 ++++++++++++++++---------------- app/views/error/index.phtml | 2 +- app/views/feed/add.phtml | 34 +++++++-------- app/views/helpers/feed/update.phtml | 60 +++++++++++++------------- app/views/helpers/javascript_vars.phtml | 8 ++-- app/views/helpers/logs_pagination.phtml | 8 ++-- app/views/helpers/view/normal_view.phtml | 14 +++--- app/views/helpers/view/reader_view.phtml | 2 +- app/views/helpers/view/rss_view.phtml | 2 +- app/views/index/about.phtml | 26 +++++------ app/views/index/logs.phtml | 8 ++-- lib/lib_rss.php | 8 ++-- 27 files changed, 256 insertions(+), 258 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index ab66d9198..048ac1c69 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -5,7 +5,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { if (!$this->view->loginOk) { Minz_Error::error ( 403, - array ('error' => array (Minz_Translate::t ('access_denied'))) + array ('error' => array (_t('access_denied'))) ); } @@ -75,7 +75,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { $notif = array ( 'type' => 'good', - 'content' => Minz_Translate::t ('feeds_marked_read') + 'content' => _t('feeds_marked_read') ); Minz_Session::_param ('notification', $notif); } else { @@ -111,7 +111,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { $notif = array ( 'type' => 'good', - 'content' => Minz_Translate::t ('optimization_complete') + 'content' => _t('optimization_complete') ); Minz_Session::_param ('notification', $notif); } @@ -155,7 +155,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { $notif = array( 'type' => 'good', - 'content' => Minz_Translate::t('purge_completed', $nbTotal) + 'content' => _t('purge_completed', $nbTotal) ); Minz_Session::_param('notification', $notif); diff --git a/app/Controllers/errorController.php b/app/Controllers/errorController.php index 922650b3d..64a5c06fd 100644 --- a/app/Controllers/errorController.php +++ b/app/Controllers/errorController.php @@ -24,11 +24,11 @@ class FreshRSS_error_Controller extends Minz_ActionController { if ($this->view->errorMessage == '') { switch(Minz_Request::param('code')) { case 403: - $this->view->errorMessage = Minz_Translate::t('forbidden_access'); + $this->view->errorMessage = _t('forbidden_access'); break; case 404: default: - $this->view->errorMessage = Minz_Translate::t('page_not_found'); + $this->view->errorMessage = _t('page_not_found'); break; } } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 92ce40634..029f9fa68 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -15,7 +15,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { ) { Minz_Error::error ( 403, - array ('error' => array (Minz_Translate::t ('access_denied'))) + array ('error' => array (_t('access_denied'))) ); } } @@ -84,7 +84,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // on est déjà abonné à ce flux $notif = array ( 'type' => 'bad', - 'content' => Minz_Translate::t ('already_subscribed', $feed->name ()) + 'content' => _t('already_subscribed', $feed->name ()) ); Minz_Session::_param ('notification', $notif); } else { @@ -93,7 +93,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // problème au niveau de la base de données $notif = array ( 'type' => 'bad', - 'content' => Minz_Translate::t ('feed_not_added', $feed->name ()) + 'content' => _t('feed_not_added', $feed->name ()) ); Minz_Session::_param ('notification', $notif); } else { @@ -131,7 +131,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // ok, ajout terminé $notif = array ( 'type' => 'good', - 'content' => Minz_Translate::t ('feed_added', $feed->name ()) + 'content' => _t('feed_added', $feed->name ()) ); Minz_Session::_param ('notification', $notif); @@ -143,14 +143,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', - 'content' => Minz_Translate::t ('invalid_url', $url) + 'content' => _t('invalid_url', $url) ); Minz_Session::_param ('notification', $notif); } catch (FreshRSS_Feed_Exception $e) { Minz_Log::record ($e->getMessage (), Minz_Log::WARNING); $notif = array ( 'type' => 'bad', - 'content' => Minz_Translate::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); } catch (Minz_FileNotExistException $e) { @@ -158,7 +158,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); $notif = array ( 'type' => 'bad', - 'content' => Minz_Translate::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); } @@ -170,7 +170,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } else { // GET request so we must ask confirmation to user - Minz_View::prependTitle(Minz_Translate::t('add_rss_feed') . ' · '); + Minz_View::prependTitle(_t('add_rss_feed') . ' · '); $this->view->categories = $this->catDAO->listCategories(false); $this->view->feed = new FreshRSS_Feed($url); try { @@ -186,9 +186,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // Already subscribe so we redirect to the feed configuration page $notif = array( 'type' => 'bad', - 'content' => Minz_Translate::t( - 'already_subscribed', $feed->name() - ) + 'content' => _t('already_subscribed', $feed->name()) ); Minz_Session::_param('notification', $notif); @@ -210,7 +208,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $n = $feedDAO->truncate($id); $notif = array( 'type' => $n === false ? 'bad' : 'good', - 'content' => Minz_Translate::t ('n_entries_deleted', $n) + 'content' => _t('n_entries_deleted', $n) ); Minz_Session::_param ('notification', $notif); invalidateHttpCache(); @@ -336,19 +334,19 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed = reset ($feeds); $notif = array ( 'type' => 'good', - 'content' => Minz_Translate::t ('feed_actualized', $feed->name ()) + 'content' => _t('feed_actualized', $feed->name ()) ); } elseif ($flux_update > 1) { // plusieurs flux on été mis à jour $notif = array ( 'type' => 'good', - 'content' => Minz_Translate::t ('n_feeds_actualized', $flux_update) + 'content' => _t('n_feeds_actualized', $flux_update) ); } else { // aucun flux n'a été mis à jour, oups $notif = array ( 'type' => 'good', - 'content' => Minz_Translate::t ('no_feed_to_refresh') + 'content' => _t('no_feed_to_refresh') ); } @@ -370,7 +368,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // ressenti utilisateur $notif = array ( 'type' => 'good', - 'content' => Minz_Translate::t ('feeds_actualized') + 'content' => _t('feeds_actualized') ); Minz_Session::_param ('notification', $notif); // et on désactive le layout car ne sert à rien diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 1b6563bb3..346739523 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -14,7 +14,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { if ($output === 'rss' && !$token_is_ok) { Minz_Error::error ( 403, - array ('error' => array (Minz_Translate::t ('access_denied'))) + array ('error' => array (_t('access_denied'))) ); return; } elseif ($output !== 'rss') { @@ -62,7 +62,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Log::record ('Not found [' . $getType . '][' . $getId . ']', Minz_Log::DEBUG); Minz_Error::error ( 404, - array ('error' => array (Minz_Translate::t ('page_not_found'))) + array ('error' => array (_t('page_not_found'))) ); return; } @@ -145,7 +145,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Log::record ($e->getMessage (), Minz_Log::NOTICE); Minz_Error::error ( 404, - array ('error' => array (Minz_Translate::t ('page_not_found'))) + array ('error' => array (_t('page_not_found'))) ); } } @@ -158,12 +158,12 @@ class FreshRSS_index_Controller extends Minz_ActionController { private function checkAndProcessType ($getType, $getId) { switch ($getType) { case 'a': - $this->view->currentName = Minz_Translate::t ('your_rss_feeds'); + $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 = Minz_Translate::t ('your_favorites'); + $this->view->currentName = _t('your_favorites'); $this->nb_not_read_cat = $this->view->nb_favorites['unread']; $this->view->get_c = $getType; return true; @@ -202,18 +202,18 @@ class FreshRSS_index_Controller extends Minz_ActionController { } public function aboutAction () { - Minz_View::prependTitle (Minz_Translate::t ('about') . ' · '); + Minz_View::prependTitle (_t('about') . ' · '); } public function logsAction () { if (!$this->view->loginOk) { Minz_Error::error ( 403, - array ('error' => array (Minz_Translate::t ('access_denied'))) + array ('error' => array (_t('access_denied'))) ); } - Minz_View::prependTitle (Minz_Translate::t ('logs') . ' · '); + Minz_View::prependTitle (_t('logs') . ' · '); if (Minz_Request::isPost ()) { FreshRSS_LogDAO::truncate(); @@ -279,7 +279,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } else { $res = array (); $res['status'] = 'failure'; - $res['reason'] = $reason == '' ? Minz_Translate::t ('invalid_login') : $reason; + $res['reason'] = $reason == '' ? _t('invalid_login') : $reason; Minz_Log::record ('Persona: ' . $res['reason'], Minz_Log::WARNING); } @@ -368,7 +368,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { if (!$ok) { $notif = array( 'type' => 'bad', - 'content' => Minz_Translate::t('invalid_login') + 'content' => _t('invalid_login') ); Minz_Session::_param('notification', $notif); } @@ -403,7 +403,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } elseif (!Minz_Configuration::canLogIn()) { Minz_Error::error ( 403, - array ('error' => array (Minz_Translate::t ('access_denied'))) + array ('error' => array (_t('access_denied'))) ); } invalidateHttpCache(); diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 3069be34d..4adb5e75d 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -120,11 +120,11 @@ class FreshRSS_stats_Controller extends Minz_ActionController { public function firstAction() { if (!$this->view->loginOk) { Minz_Error::error( - 403, array('error' => array(Minz_Translate::t('access_denied'))) + 403, array('error' => array(_t('access_denied'))) ); } - Minz_View::prependTitle(Minz_Translate::t('stats') . ' · '); + Minz_View::prependTitle(_t('stats') . ' · '); } } diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php index a9e6c32bc..8eb82f5d5 100644 --- a/app/Controllers/usersController.php +++ b/app/Controllers/usersController.php @@ -8,7 +8,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { if (!$this->view->loginOk) { Minz_Error::error( 403, - array('error' => array(Minz_Translate::t('access_denied'))) + array('error' => array(_t('access_denied'))) ); } } @@ -90,7 +90,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { $notif = array( 'type' => $ok ? 'good' : 'bad', - 'content' => Minz_Translate::t($ok ? 'configuration_updated' : 'error_occurred') + 'content' => _t($ok ? 'configuration_updated' : 'error_occurred') ); Minz_Session::_param('notification', $notif); } @@ -162,7 +162,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { $notif = array( 'type' => $ok ? 'good' : 'bad', - 'content' => Minz_Translate::t($ok ? 'user_created' : 'error_occurred', $new_user_name) + 'content' => _t($ok ? 'user_created' : 'error_occurred', $new_user_name) ); Minz_Session::_param('notification', $notif); } @@ -194,7 +194,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { $notif = array( 'type' => $ok ? 'good' : 'bad', - 'content' => Minz_Translate::t($ok ? 'user_deleted' : 'error_occurred', $username) + 'content' => _t($ok ? 'user_deleted' : 'error_occurred', $username) ); Minz_Session::_param('notification', $notif); } diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 58aac4059..16f64fd8b 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -10,7 +10,7 @@ class FreshRSS extends Minz_FrontController { $loginOk = false; //Basic protection against XSRF attacks Minz_Error::error( 403, - array('error' => array(Minz_Translate::t('access_denied') . ' [HTTP_REFERER=' . + array('error' => array(_t('access_denied') . ' [HTTP_REFERER=' . htmlspecialchars(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']) . ']')) ); } diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index f11f87f47..5def50a26 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -134,7 +134,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { $def_cat = $this->searchById (1); if ($def_cat == null) { - $cat = new FreshRSS_Category (Minz_Translate::t ('default_category')); + $cat = new FreshRSS_Category (_t('default_category')); $cat->_id (1); $values = array ( diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index 08dd4cd5c..113944508 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -416,7 +416,7 @@ SQL; */ private function convertToTranslatedJson($data = array()) { $translated = array_map(function ($a) { - return Minz_Translate::t($a); + return _t($a); }, $data); return json_encode($translated); diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 9f64fb4a7..0c96d7175 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -9,7 +9,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { $ok = false; if (defined('SQL_CREATE_TABLES')) { //E.g. MySQL - $sql = sprintf(SQL_CREATE_TABLES, $db['prefix'] . $username . '_', Minz_Translate::t('default_category')); + $sql = sprintf(SQL_CREATE_TABLES, $db['prefix'] . $username . '_', _t('default_category')); $stm = $userPDO->bd->prepare($sql); $ok = $stm && $stm->execute(); } else { //E.g. SQLite @@ -17,7 +17,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { if (is_array($SQL_CREATE_TABLES)) { $ok = true; foreach ($SQL_CREATE_TABLES as $instruction) { - $sql = sprintf($instruction, '', Minz_Translate::t('default_category')); + $sql = sprintf($instruction, '', _t('default_category')); $stm = $userPDO->bd->prepare($sql); $ok &= ($stm && $stm->execute()); } diff --git a/app/layout/aside_stats.phtml b/app/layout/aside_stats.phtml index fbfb9d84d..1cd31a99c 100644 --- a/app/layout/aside_stats.phtml +++ b/app/layout/aside_stats.phtml @@ -1,12 +1,12 @@ diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index c9cc7fe02..3180fe933 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -1,31 +1,31 @@ partial('aside_configure'); ?>
        - +
        - -

        + +

        - +
        - -   + +  
        - +
        () + ?> ()
        - +
        () + ?> ()
        - - + +
        - +
        -

        +

        -

        nb_total), ' ', Minz_Translate::t('articles'), ', ', formatBytes($this->size_user); ?>

        +

        nb_total), ' ', _t('articles'), ', ', formatBytes($this->size_user); ?>

        - - + +
        -

        +

        size_total); ?>

        diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index 8eb3a156b..f1b80ab15 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -1,13 +1,13 @@ partial ('aside_configure'); ?>
        - + - +
        - +
        themes as $theme) { ?>conf->content_width; ?>
        - +
        - + - - - - - + + + + + - + @@ -80,7 +80,7 @@ - + @@ -93,16 +93,16 @@
        - +
        - +
        - - + +
        diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml index 8b2da2a28..7e4efc264 100644 --- a/app/views/configure/reading.phtml +++ b/app/views/configure/reading.phtml @@ -1,13 +1,13 @@ partial ('aside_configure'); ?>
        - +
        - +
        - +
        @@ -15,22 +15,22 @@
        - +
        - +
        @@ -50,7 +50,7 @@
        @@ -59,8 +59,8 @@
        @@ -69,8 +69,8 @@
        @@ -79,8 +79,8 @@
        @@ -89,8 +89,8 @@
        @@ -99,8 +99,8 @@
        @@ -109,48 +109,48 @@
        - +
        - +
        - - + +
        diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index 02ce331da..ee276a94e 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -1,7 +1,7 @@ partial ('aside_configure'); ?>
        - + @@ -9,28 +9,28 @@ data-advanced='
        - - + +
        - +
        '> - + conf->sharing as $key => $sharing): ?> conf->shares[$sharing['type']]; ?>
        ' />
        - - + +
        - + @@ -42,7 +42,7 @@
        @@ -51,8 +51,8 @@
        - - + +
        diff --git a/app/views/configure/users.phtml b/app/views/configure/users.phtml index 272896fb2..04e662fa3 100644 --- a/app/views/configure/users.phtml +++ b/app/views/configure/users.phtml @@ -1,36 +1,36 @@ partial('aside_configure'); ?>
        - +
        - +
        - +
        - +
        />
        - +
        - +
        /> @@ -41,36 +41,36 @@
        - + conf->mail_login; ?>
        placeholder="alice@example.net" /> - +
        - - + +
        - +
        - +
        @@ -80,7 +80,7 @@
        @@ -90,7 +90,7 @@
        @@ -100,7 +100,7 @@
        @@ -108,12 +108,12 @@
        - + conf->token; ?>
        - /> - +
        @@ -123,24 +123,24 @@
        - - + +
        - +
        - +
        conf->availableLanguages (); ?> @@ -173,25 +173,25 @@
        - +
        - +
        - +
        - + conf->mail_login; ?>
        @@ -200,8 +200,8 @@
        - - + +
        diff --git a/app/views/error/index.phtml b/app/views/error/index.phtml index ef4fbd39d..5e1949800 100644 --- a/app/views/error/index.phtml +++ b/app/views/error/index.phtml @@ -3,7 +3,7 @@

        code; ?>

        errorMessage; ?>
        - +

        diff --git a/app/views/feed/add.phtml b/app/views/feed/add.phtml index 849dacac6..17e52a571 100644 --- a/app/views/feed/add.phtml +++ b/app/views/feed/add.phtml @@ -1,16 +1,16 @@ feed) { ?>
        -

        +

        load_ok) { ?> -

        +

        - + load_ok) { ?>
        - +
        @@ -18,7 +18,7 @@ feed->description(); if ($desc != '') { ?>
        - +
        @@ -26,7 +26,7 @@
        - +
        feed->website(); ?> @@ -35,17 +35,17 @@
        - +
        - +
        - +
        - +
        - + feed->httpAuth(false); ?>
        - +
        - +
        - +
        - - + +
        diff --git a/app/views/helpers/feed/update.phtml b/app/views/helpers/feed/update.phtml index 678c5f132..8bd645d11 100644 --- a/app/views/helpers/feed/update.phtml +++ b/app/views/helpers/feed/update.phtml @@ -12,27 +12,27 @@ feed->nbEntries (); ?> feed->inError ()) { ?> -

        +

        -

        +

        - +
        - +
        - +
        - +
        @@ -41,18 +41,18 @@
        - +
        - +
        - +
        feed->priority () > 0 ? ' checked="checked"' : ''; ?> /> - +
        @@ -83,7 +83,7 @@
        - +
        @@ -96,21 +96,21 @@
        - +
        - +
        - +
        - +
        @@ -150,24 +150,24 @@
        - - + +
        - +
        - +
        - - + +
        - - + +
        diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 4f7e3db0c..ba02b9fad 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -52,10 +52,10 @@ echo 'authType="', $authType, '",', 'url_login="', _url ('index', 'login'), '",', 'url_logout="', _url ('index', 'logout'), '",'; -echo 'str_confirmation_default="', Minz_Translate::t('confirm_action'), '"', ",\n"; -echo 'str_notif_title_articles="', Minz_Translate::t('notif_title_new_articles'), '"', ",\n"; -echo 'str_notif_body_articles="', Minz_Translate::t('notif_body_new_articles'), '"', ",\n"; -echo 'str_category_empty="', Minz_Translate::t('category_empty'), '"', ",\n"; +echo 'str_confirmation_default="', _t('confirm_action'), '"', ",\n"; +echo 'str_notif_title_articles="', _t('notif_title_new_articles'), '"', ",\n"; +echo 'str_notif_body_articles="', _t('notif_body_new_articles'), '"', ",\n"; +echo 'str_category_empty="', _t('category_empty'), '"', ",\n"; echo 'html5_notif_timeout=', $this->conf->html5_notif_timeout,",\n"; diff --git a/app/views/helpers/logs_pagination.phtml b/app/views/helpers/logs_pagination.phtml index e3d14810e..191cfa8de 100755 --- a/app/views/helpers/logs_pagination.phtml +++ b/app/views/helpers/logs_pagination.phtml @@ -9,14 +9,14 @@
      • currentPage > 1) { ?> - « + «
      • currentPage - 1; ?>
      • currentPage > 1) { ?> - +
      • @@ -34,13 +34,13 @@ currentPage + 1; ?>
      • currentPage < $this->nbPage) { ?> - +
      • nbPage; ?>
      • currentPage < $this->nbPage) { ?> - » + »
      • diff --git a/app/views/helpers/view/normal_view.phtml b/app/views/helpers/view/normal_view.phtml index e469edf58..ee745144f 100644 --- a/app/views/helpers/view/normal_view.phtml +++ b/app/views/helpers/view/normal_view.phtml @@ -30,12 +30,12 @@ if (!empty($this->entries)) {
        - +
        entries as $item) { if ($display_today && $item->isDay (FreshRSS_Days::TODAY, $this->today)) { ?>
        currentName; ?>
        entries)) { } if ($display_yesterday && $item->isDay (FreshRSS_Days::YESTERDAY, $this->today)) { ?>
        currentName; ?>
        entries)) { } if ($display_others && $item->isDay (FreshRSS_Days::BEFORE_YESTERDAY, $this->today)) { ?>
        currentName; ?>
        entries)) {

        title (); ?>

        author(); - echo $author != '' ? '
        ' . Minz_Translate::t('by_author', $author) . '
        ' : '', + echo $author != '' ? '
        ' . _t('by_author', $author) . '
        ' : '', $lazyload && $hidePosts ? lazyimg($item->content()) : $item->content(); ?>
        @@ -133,7 +133,7 @@ if (!empty($this->entries)) { - +
        diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 31c9cdbc1..4f6beb9fd 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -77,11 +77,11 @@ function formatBytes($bytes, $precision = 2, $system = 'IEC') { } function timestamptodate ($t, $hour = true) { - $month = Minz_Translate::t (date('M', $t)); + $month = _t(date('M', $t)); if ($hour) { - $date = Minz_Translate::t ('format_date_hour', $month); + $date = _t('format_date_hour', $month); } else { - $date = Minz_Translate::t ('format_date', $month); + $date = _t('format_date', $month); } return @date ($date, $t); @@ -107,7 +107,7 @@ function html_only_entity_decode($text) { function customSimplePie() { $simplePie = new SimplePie(); - $simplePie->set_useragent(Minz_Translate::t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); + $simplePie->set_useragent(_t('freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ') ' . SIMPLEPIE_NAME . '/' . SIMPLEPIE_VERSION); $simplePie->set_cache_location(CACHE_PATH); $simplePie->set_cache_duration(800); $simplePie->strip_htmltags(array( -- cgit v1.2.3 From 64d1026dd979740010088d1f4237f6dc2a4f4cfd Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 17:55:35 +0200 Subject: Move usersAction into usersController --- app/Controllers/configureController.php | 19 +-- app/Controllers/usersController.php | 13 +- app/layout/aside_configure.phtml | 4 +- app/layout/header.phtml | 2 +- app/views/configure/users.phtml | 211 -------------------------------- app/views/users/index.phtml | 211 ++++++++++++++++++++++++++++++++ 6 files changed, 229 insertions(+), 231 deletions(-) delete mode 100644 app/views/configure/users.phtml create mode 100644 app/views/users/index.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index b7b88b3ba..789e9dfb0 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -168,11 +168,11 @@ class FreshRSS_configure_Controller extends Minz_ActionController { */ public function shortcutAction() { $list_keys = array('a', 'b', 'backspace', 'c', 'd', 'delete', 'down', 'e', 'end', 'enter', - 'escape', 'f', 'g', 'h', 'home', 'i', 'insert', 'j', 'k', 'l', 'left', - 'm', 'n', 'o', 'p', 'page_down', 'page_up', 'q', 'r', 'return', 'right', - 's', 'space', 't', 'tab', 'u', 'up', 'v', 'w', 'x', 'y', - 'z', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', - 'f10', 'f11', 'f12'); + 'escape', 'f', 'g', 'h', 'home', 'i', 'insert', 'j', 'k', 'l', 'left', + 'm', 'n', 'o', 'p', 'page_down', 'page_up', 'q', 'r', 'return', 'right', + 's', 'space', 't', 'tab', 'u', 'up', 'v', 'w', 'x', 'y', + 'z', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', + 'f10', 'f11', 'f12'); $this->view->list_keys = $list_keys; if (Minz_Request::isPost()) { @@ -196,15 +196,6 @@ class FreshRSS_configure_Controller extends Minz_ActionController { Minz_View::prependTitle(_t('shortcuts') . ' · '); } - /** - * This action display the user configuration page - * - * @todo move that action in the user controller - */ - public function usersAction() { - Minz_View::prependTitle(_t('users') . ' · '); - } - /** * This action handles the archive configuration page. * diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php index 8eb82f5d5..7d0171bc7 100644 --- a/app/Controllers/usersController.php +++ b/app/Controllers/usersController.php @@ -13,6 +13,13 @@ class FreshRSS_users_Controller extends Minz_ActionController { } } + /** + * This action display the user configuration page + */ + public function indexAction() { + Minz_View::prependTitle(_t('users') . ' · '); + } + public function authAction() { if (Minz_Request::isPost()) { $ok = true; @@ -94,7 +101,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { ); Minz_Session::_param('notification', $notif); } - Minz_Request::forward(array('c' => 'configure', 'a' => 'users'), true); + Minz_Request::forward(array('c' => 'users', 'a' => 'index'), true); } public function createAction() { @@ -166,7 +173,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { ); Minz_Session::_param('notification', $notif); } - Minz_Request::forward(array('c' => 'configure', 'a' => 'users'), true); + Minz_Request::forward(array('c' => 'users', 'a' => 'index'), true); } public function deleteAction() { @@ -198,6 +205,6 @@ class FreshRSS_users_Controller extends Minz_ActionController { ); Minz_Session::_param('notification', $notif); } - Minz_Request::forward(array('c' => 'configure', 'a' => 'users'), true); + Minz_Request::forward(array('c' => 'users', 'a' => 'index'), true); } } diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml index d5c9bf4c9..e17bcb254 100644 --- a/app/layout/aside_configure.phtml +++ b/app/layout/aside_configure.phtml @@ -19,8 +19,8 @@
      • -
      • - +
      • +
      • -
      • +
      • partial('aside_configure'); ?> - -
        - - -
        - - -
        - -
        - - -
        -
        - -
        - -
        -
        - /> - -
        - -
        -
        - - -
        - -
        -
        - /> - -
        -
        -
        - - -
        - - conf->mail_login; ?> -
        - placeholder="alice@example.net" /> - -
        -
        - -
        -
        - - -
        -
        - - - - - -
        - -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - - -
        - - conf->token; ?> -
        - /> - -
        -
        - - -
        -
        - -
        -
        - -
        -
        - - -
        -
        - - -
        - - -
        - -
        - -
        -
        - -
        -
        - -
        -
        - - -
        - - -
        - -
        - -
        -
        - -
        - -
        - -
        -
        - -
        - -
        -
        - - -
        - -
        -
        - -
        - - conf->mail_login; ?> -
        - -
        -
        - -
        -
        - - -
        -
        - - - - -
        diff --git a/app/views/users/index.phtml b/app/views/users/index.phtml new file mode 100644 index 000000000..517e302e5 --- /dev/null +++ b/app/views/users/index.phtml @@ -0,0 +1,211 @@ +partial('aside_configure'); ?> + +
        + + +
        + + +
        + +
        + + +
        +
        + +
        + +
        +
        + /> + +
        + +
        +
        + + +
        + +
        +
        + /> + +
        +
        +
        + + +
        + + conf->mail_login; ?> +
        + placeholder="alice@example.net" /> + +
        +
        + +
        +
        + + +
        +
        + + + + + +
        + +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + + +
        + + conf->token; ?> +
        + /> + +
        +
        + + +
        +
        + +
        +
        + +
        +
        + + +
        +
        + + +
        + + +
        + +
        + +
        +
        + +
        +
        + +
        +
        + + +
        + + +
        + +
        + +
        +
        + +
        + +
        + +
        +
        + +
        + +
        +
        + + +
        + +
        +
        + +
        + + conf->mail_login; ?> +
        + +
        +
        + +
        +
        + + +
        +
        + + + + +
        -- cgit v1.2.3 From 9a0d01be0cb627b30424e9f938face34c6c3814d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 18:24:28 +0200 Subject: Coding style Remove spaces before parenthesis. See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/entryController.php | 78 +++++------ app/Controllers/errorController.php | 28 ++-- app/Controllers/feedController.php | 184 +++++++++++++------------ app/Controllers/indexController.php | 229 ++++++++++++++++--------------- app/Controllers/javascriptController.php | 6 +- app/Controllers/statsController.php | 2 +- 6 files changed, 269 insertions(+), 258 deletions(-) (limited to 'app/Controllers') 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 @@ 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 @@ 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 @@ 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(); -- cgit v1.2.3 From d8f4681382986524b91acb0500847e9f24badf20 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 19:35:29 +0200 Subject: Replace Minz_Log::record by corresponding methods Please not use Minz_Log::record anymore! See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/entryController.php | 2 +- app/Controllers/feedController.php | 14 +++++++------- app/Controllers/indexController.php | 20 ++++++++++---------- app/Controllers/javascriptController.php | 2 +- app/FreshRSS.php | 2 +- app/Models/CategoryDAO.php | 6 +++--- app/Models/EntryDAO.php | 30 +++++++++++++++--------------- app/Models/EntryDAOSQLite.php | 14 +++++++------- app/Models/FeedDAO.php | 20 ++++++++++---------- app/Models/FeedDAOSQLite.php | 2 +- app/Models/UserDAO.php | 4 ++-- app/views/index/index.phtml | 2 +- lib/Minz/FrontController.php | 4 ++-- lib/Minz/View.php | 12 +++--------- p/api/greader.php | 6 +++--- p/i/index.php | 2 +- 16 files changed, 68 insertions(+), 74 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index ec90666ed..d7be05663 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -143,7 +143,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, $feedHistory); if ($nb > 0) { $nbTotal += $nb; - Minz_Log::record($nb . ' old entries cleaned in feed [' . $feed->url() . ']', Minz_Log::DEBUG); + Minz_Log::debug($nb . ' old entries cleaned in feed [' . $feed->url() . ']'); //$feedDAO->updateLastUpdate($feed->id()); } } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 93a8d7c2e..70d5c4e22 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -140,14 +140,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } } catch (FreshRSS_BadUrl_Exception $e) { - Minz_Log::record($e->getMessage(), Minz_Log::WARNING); + Minz_Log::warning($e->getMessage()); $notif = array( 'type' => 'bad', 'content' => _t('invalid_url', $url) ); Minz_Session::_param('notification', $notif); } catch (FreshRSS_Feed_Exception $e) { - Minz_Log::record($e->getMessage(), Minz_Log::WARNING); + Minz_Log::warning($e->getMessage()); $notif = array( 'type' => 'bad', 'content' => _t('internal_problem_feed', @@ -156,7 +156,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Session::_param('notification', $notif); } catch (Minz_FileNotExistException $e) { // Répertoire de cache n'existe pas - Minz_Log::record($e->getMessage(), Minz_Log::ERROR); + Minz_Log::error($e->getMessage()); $notif = array( 'type' => 'bad', 'content' => _t('internal_problem_feed', @@ -258,7 +258,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; foreach ($feeds as $feed) { if (!$feed->lock()) { - Minz_Log::record('Feed already being actualized: ' . $feed->url(), Minz_Log::NOTICE); + Minz_Log::notice('Feed already being actualized: ' . $feed->url()); continue; } try { @@ -307,7 +307,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } $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::debug($nb . ' old entries cleaned in feed [' . $feed->url() . ']'); } } @@ -318,11 +318,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } $flux_update++; if (($feed->url() !== $url)) { //HTTP 301 Moved Permanently - Minz_Log::record('Feed ' . $url . ' moved permanently to ' . $feed->url(), Minz_Log::NOTICE); + Minz_Log::notice('Feed ' . $url . ' moved permanently to ' . $feed->url()); $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } } catch (FreshRSS_Feed_Exception $e) { - Minz_Log::record($e->getMessage(), Minz_Log::NOTICE); + Minz_Log::notice($e->getMessage()); $feedDAO->updateLastUpdate($feed->id(), 1); } diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 73638acb3..0d2eff700 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -59,7 +59,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { $getType = $get[0]; $getId = substr($get, 2); if (!$this->checkAndProcessType($getType, $getId)) { - Minz_Log::record('Not found [' . $getType . '][' . $getId . ']', Minz_Log::DEBUG); + Minz_Log::debug('Not found [' . $getType . '][' . $getId . ']'); Minz_Error::error( 404, array('error' => array(_t('page_not_found'))) @@ -122,12 +122,12 @@ class FreshRSS_index_Controller extends Minz_ActionController { // Si on a récupéré aucun article "non lus" // on essaye de récupérer tous les articles if ($this->view->state === FreshRSS_Entry::STATE_NOT_READ && empty($entries) && ($state_param === null) && ($filter == '')) { - Minz_Log::record('Conflicting information about nbNotRead!', Minz_Log::DEBUG); + Minz_Log::debug('Conflicting information about nbNotRead!'); $feedDAO = FreshRSS_Factory::createFeedDao(); try { $feedDAO->updateCachedValues(); } catch (Exception $ex) { - Minz_Log::record('Failed to automatically correct nbNotRead! ' + $ex->getMessage(), Minz_Log::NOTICE); + Minz_Log::notice('Failed to automatically correct nbNotRead! ' + $ex->getMessage()); } $this->view->state = FreshRSS_Entry::STATE_ALL; $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb, $first, $filter); @@ -143,7 +143,7 @@ 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_Log::notice($e->getMessage()); Minz_Error::error( 404, array('error' => array(_t('page_not_found'))) @@ -281,7 +281,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { $res = array(); $res['status'] = 'failure'; $res['reason'] = $reason == '' ? _t('invalid_login') : $reason; - Minz_Log::record('Persona: ' . $res['reason'], Minz_Log::WARNING); + Minz_Log::warning('Persona: ' . $res['reason']); } header('Content-Type: application/json; charset=UTF-8'); @@ -358,13 +358,13 @@ class FreshRSS_index_Controller extends Minz_ActionController { self::deleteLongTermCookie(); } } else { - Minz_Log::record('Password mismatch for user ' . $username . ', nonce=' . $nonce . ', c=' . $c, Minz_Log::WARNING); + Minz_Log::warning('Password mismatch for user ' . $username . ', nonce=' . $nonce . ', c=' . $c); } } catch (Minz_Exception $me) { - Minz_Log::record('Login failure: ' . $me->getMessage(), Minz_Log::WARNING); + Minz_Log::warning('Login failure: ' . $me->getMessage()); } } else { - Minz_Log::record('Invalid credential parameters: user=' . $username . ' challenge=' . $c . ' nonce=' . $nonce, Minz_Log::DEBUG); + Minz_Log::debug('Invalid credential parameters: user=' . $username . ' challenge=' . $c . ' nonce=' . $nonce); } if (!$ok) { $notif = array( @@ -395,10 +395,10 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Session::_param('currentUser', $username); Minz_Session::_param('passwordHash', $s); } else { - Minz_Log::record('Unsafe password mismatch for user ' . $username, Minz_Log::WARNING); + Minz_Log::warning('Unsafe password mismatch for user ' . $username); } } catch (Minz_Exception $me) { - Minz_Log::record('Unsafe login failure: ' . $me->getMessage(), Minz_Log::WARNING); + Minz_Log::warning('Unsafe login failure: ' . $me->getMessage()); } Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } elseif (!Minz_Configuration::canLogIn()) { diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php index 2a0dbd3d9..14e6f36de 100755 --- a/app/Controllers/javascriptController.php +++ b/app/Controllers/javascriptController.php @@ -37,7 +37,7 @@ class FreshRSS_javascript_Controller extends Minz_ActionController { return; //Success } } catch (Minz_Exception $me) { - Minz_Log::record('Nonce failure: ' . $me->getMessage(), Minz_Log::WARNING); + Minz_Log::warning('Nonce failure: ' . $me->getMessage()); } } $this->view->nonce = ''; //Failure diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 61e8d83f0..efd302ecc 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -101,7 +101,7 @@ class FreshRSS extends Minz_FrontController { 'content' => 'Invalid configuration for user [' . $currentUser . ']!', ); Minz_Session::_param('notification', $notif); - Minz_Log::record($notif['content'] . ' ' . $me->getMessage(), Minz_Log::WARNING); + Minz_Log::warning($notif['content'] . ' ' . $me->getMessage()); Minz_Session::_param('currentUser', ''); } catch (Exception $e) { die($e->getMessage()); diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php index ce1babfdd..2e333d2f1 100644 --- a/app/Models/CategoryDAO.php +++ b/app/Models/CategoryDAO.php @@ -13,7 +13,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { return $this->bd->lastInsertId(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error addCategory: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error addCategory: ' . $info[2] ); return false; } } @@ -44,7 +44,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error updateCategory: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error updateCategory: ' . $info[2]); return false; } } @@ -59,7 +59,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error deleteCategory: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error deleteCategory: ' . $info[2]); return false; } } diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 34717123c..5a136499a 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -40,11 +40,11 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); if ((int)($info[0] / 1000) !== 23) { //Filter out "SQLSTATE Class code 23: Constraint Violation" because of expected duplicate entries - Minz_Log::record('SQL error addEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] - . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title'], Minz_Log::ERROR); + Minz_Log::error('SQL error addEntry: ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] + . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']); } /*else { - Minz_Log::record ('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] - . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title'], Minz_Log::DEBUG); + Minz_Log::debug('SQL error ' . $info[0] . ': ' . $info[1] . ' ' . $info[2] + . ' while adding entry in feed ' . $valuesTmp['id_feed'] . ' with title: ' . $valuesTmp['title']); }*/ return false; } @@ -94,7 +94,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markFavorite: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markFavorite: ' . $info[2]); return false; } } @@ -124,7 +124,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return true; } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error updateCacheUnreads: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error updateCacheUnreads: ' . $info[2]); return false; } } @@ -147,7 +147,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markRead: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markRead: ' . $info[2]); return false; } $affected = $stm->rowCount(); @@ -166,7 +166,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markRead: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markRead: ' . $info[2]); return false; } } @@ -175,7 +175,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { public function markReadEntries($idMax = 0, $onlyFavorites = false, $priorityMin = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record('Calling markReadEntries(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::debug('Calling markReadEntries(0) is deprecated!'); } $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id ' @@ -190,7 +190,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markReadEntries: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markReadEntries: ' . $info[2]); return false; } $affected = $stm->rowCount(); @@ -203,7 +203,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { public function markReadCat($id, $idMax = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record('Calling markReadCat(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::debug('Calling markReadCat(0) is deprecated!'); } $sql = 'UPDATE `' . $this->prefix . 'entry` e INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id ' @@ -213,7 +213,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markReadCat: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markReadCat: ' . $info[2]); return false; } $affected = $stm->rowCount(); @@ -226,7 +226,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { public function markReadFeed($id, $idMax = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record('Calling markReadFeed(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::debug('Calling markReadFeed(0) is deprecated!'); } $this->bd->beginTransaction(); @@ -237,7 +237,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markReadFeed: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markReadFeed: ' . $info[2]); $this->bd->rollBack(); return false; } @@ -251,7 +251,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markReadFeed: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markReadFeed: ' . $info[2]); $this->bd->rollBack(); return false; } diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index 9dc395c3c..66078aca9 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -26,7 +26,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { return true; } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error updateCacheUnreads: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error updateCacheUnreads: ' . $info[2]); return false; } } @@ -47,7 +47,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markRead 1: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markRead 1: ' . $info[2]); $this->bd->rollBack(); return false; } @@ -59,7 +59,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markRead 2: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markRead 2: ' . $info[2]); $this->bd->rollBack(); return false; } @@ -72,7 +72,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { public function markReadEntries($idMax = 0, $onlyFavorites = false, $priorityMin = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record('Calling markReadEntries(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::debug('Calling markReadEntries(0) is deprecated!'); } $sql = 'UPDATE `' . $this->prefix . 'entry` SET is_read=1 WHERE is_read=0 AND id <= ?'; @@ -85,7 +85,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markReadEntries: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markReadEntries: ' . $info[2]); return false; } $affected = $stm->rowCount(); @@ -98,7 +98,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { public function markReadCat($id, $idMax = 0) { if ($idMax == 0) { $idMax = time() . '000000'; - Minz_Log::record('Calling markReadCat(0) is deprecated!', Minz_Log::DEBUG); + Minz_Log::debug('Calling markReadCat(0) is deprecated!'); } $sql = 'UPDATE `' . $this->prefix . 'entry` ' @@ -109,7 +109,7 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error markReadCat: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error markReadCat: ' . $info[2]); return false; } $affected = $stm->rowCount(); diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index b89ae2045..852de6e36 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -19,7 +19,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $this->bd->lastInsertId(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error addFeed: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error addFeed: ' . $info[2]); return false; } } @@ -77,7 +77,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error updateFeed: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error updateFeed: ' . $info[2]); return false; } } @@ -107,7 +107,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error updateLastUpdate: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error updateLastUpdate: ' . $info[2]); return false; } } @@ -131,7 +131,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error changeCategory: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error changeCategory: ' . $info[2]); return false; } } @@ -146,7 +146,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error deleteFeed: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error deleteFeed: ' . $info[2]); return false; } } @@ -160,7 +160,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error deleteFeedByCategory: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error deleteFeedByCategory: ' . $info[2]); return false; } } @@ -289,7 +289,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error updateCachedValues: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error updateCachedValues: ' . $info[2]); return false; } } @@ -301,7 +301,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { $this->bd->beginTransaction(); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error truncate: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error truncate: ' . $info[2]); $this->bd->rollBack(); return false; } @@ -313,7 +313,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { $stm = $this->bd->prepare($sql); if (!($stm && $stm->execute($values))) { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error truncate: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error truncate: ' . $info[2]); $this->bd->rollBack(); return false; } @@ -338,7 +338,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error cleanOldEntries: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error cleanOldEntries: ' . $info[2]); return false; } } diff --git a/app/Models/FeedDAOSQLite.php b/app/Models/FeedDAOSQLite.php index 0d1872389..7599fda53 100644 --- a/app/Models/FeedDAOSQLite.php +++ b/app/Models/FeedDAOSQLite.php @@ -11,7 +11,7 @@ class FreshRSS_FeedDAOSQLite extends FreshRSS_FeedDAO { return $stm->rowCount(); } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record('SQL error updateCachedValues: ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error updateCachedValues: ' . $info[2]); return false; } } diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 0c96d7175..15215258c 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -28,7 +28,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { return true; } else { $info = empty($stm) ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error : ' . $info[2]); return false; } } @@ -48,7 +48,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { return true; } else { $info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo(); - Minz_Log::record ('SQL error : ' . $info[2], Minz_Log::ERROR); + Minz_Log::error('SQL error : ' . $info[2]); return false; } } diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 5e935b81e..584792e29 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -21,5 +21,5 @@ if ($this->loginOk || Minz_Configuration::allowAnonymous()) { $this->renderHelper('view/rss_view'); } else { // Normally, it should not happen, but log it anyway - Minz_Log::record('Something is wrong in ' . __FILE__ . ' line ' . __LINE__, Minz_Log::ERROR); + Minz_Log::error('Something is wrong in ' . __FILE__ . ' line ' . __LINE__); } diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php index f13882801..e95c56bf3 100644 --- a/lib/Minz/FrontController.php +++ b/lib/Minz/FrontController.php @@ -46,7 +46,7 @@ class Minz_FrontController { ); Minz_Request::forward ($url); } catch (Minz_Exception $e) { - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); + Minz_Log::error($e->getMessage()); $this->killApp ($e->getMessage ()); } @@ -85,7 +85,7 @@ class Minz_FrontController { $this->dispatcher->run(); } catch (Minz_Exception $e) { try { - Minz_Log::record ($e->getMessage (), Minz_Log::ERROR); + Minz_Log::error($e->getMessage()); } catch (Minz_PermissionDeniedException $e) { $this->killApp ($e->getMessage ()); } diff --git a/lib/Minz/View.php b/lib/Minz/View.php index a0dec1824..b40448491 100644 --- a/lib/Minz/View.php +++ b/lib/Minz/View.php @@ -71,9 +71,7 @@ class Minz_View { */ public function render () { if ((include($this->view_filename)) === false) { - Minz_Log::record ('File not found: `' - . $this->view_filename . '`', - Minz_Log::NOTICE); + Minz_Log::notice('File not found: `' . $this->view_filename . '`'); } } @@ -87,9 +85,7 @@ class Minz_View { . $part . '.phtml'; if ((include($fic_partial)) === false) { - Minz_Log::record ('File not found: `' - . $fic_partial . '`', - Minz_Log::WARNING); + Minz_Log::warning('File not found: `' . $fic_partial . '`'); } } @@ -103,9 +99,7 @@ class Minz_View { . $helper . '.phtml'; if ((include($fic_helper)) === false) {; - Minz_Log::record ('File not found: `' - . $fic_helper . '`', - Minz_Log::WARNING); + Minz_Log::warning('File not found: `' . $fic_helper . '`'); } } diff --git a/p/api/greader.php b/p/api/greader.php index 5a6fdad7d..1a66c30fb 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -160,7 +160,7 @@ function authorizationToUserConf() { return $conf; } else { logMe('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1] . "\n"); - Minz_Log::record('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1], Minz_Log::WARNING); + Minz_Log::warning('Invalid API authorisation for user ' . $user . ': ' . $headerAuthX[1]); unauthorized(); } } else { @@ -181,7 +181,7 @@ function clientLogin($email, $pass) { //http://web.archive.org/web/2013060409104 $conf = new FreshRSS_Configuration($email); } catch (Exception $e) { logMe($e->getMessage() . "\n"); - Minz_Log::record('Invalid API user ' . $email, Minz_Log::WARNING); + Minz_Log::warning('Invalid API user ' . $email); unauthorized(); } if ($conf->apiPasswordHash != '' && password_verify($pass, $conf->apiPasswordHash)) { @@ -191,7 +191,7 @@ function clientLogin($email, $pass) { //http://web.archive.org/web/2013060409104 'Auth=', $auth, "\n"; exit(); } else { - Minz_Log::record('Password API mismatch for user ' . $email, Minz_Log::WARNING); + Minz_Log::warning('Password API mismatch for user ' . $email); unauthorized(); } } else { diff --git a/p/i/index.php b/p/i/index.php index 7b34eefd1..ec969c159 100755 --- a/p/i/index.php +++ b/p/i/index.php @@ -46,7 +46,7 @@ if (file_exists(DATA_PATH . '/do-install.txt')) { $front_controller->run(); } catch (Exception $e) { echo '### Fatal error! ###
        ', "\n"; - Minz_Log::record($e->getMessage(), Minz_Log::ERROR); + Minz_Log::error($e->getMessage()); echo 'See logs files.'; } } -- cgit v1.2.3 From f5a95d383c056fddd86e34024cba3444b527730d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 21:16:06 +0200 Subject: Coding style errorController --- app/Controllers/errorController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/errorController.php b/app/Controllers/errorController.php index 36312b56c..bb3431c2b 100644 --- a/app/Controllers/errorController.php +++ b/app/Controllers/errorController.php @@ -23,13 +23,13 @@ class FreshRSS_error_Controller extends Minz_ActionController { $this->view->errorMessage = trim(implode($errors)); if ($this->view->errorMessage == '') { switch(Minz_Request::param('code')) { - case 403: - $this->view->errorMessage = _t('forbidden_access'); - break; - case 404: - default: - $this->view->errorMessage = _t('page_not_found'); - break; + case 403: + $this->view->errorMessage = _t('forbidden_access'); + break; + case 404: + default: + $this->view->errorMessage = _t('page_not_found'); + break; } } -- cgit v1.2.3 From e2da6e6e6b871dc3dbc289cdd40ba401a21d8e91 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 5 Oct 2014 23:20:16 +0200 Subject: Refactor feedController See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/feedController.php | 611 ++++++++++++++++++++----------------- lib/Minz/ModelPdo.php | 7 + 2 files changed, 330 insertions(+), 288 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 70d5c4e22..0f52917e4 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -1,6 +1,14 @@ view->loginOk) { // Token is useful in the case that anonymous refresh is forbidden @@ -10,9 +18,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $token_param = Minz_Request::param('token', ''); $token_is_ok = ($token != '' && $token == $token_param); $action = Minz_Request::actionName(); - if (!(($token_is_ok || Minz_Configuration::allowAnonymousRefresh()) && - $action === 'actualize') - ) { + if ($action !== 'actualize' || + !(Minz_Configuration::allowAnonymousRefresh() || $token_is_ok)) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) @@ -21,10 +28,32 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } } + /** + * This action subscribes to a feed. + * + * It can be reached by both GET and POST requests. + * + * GET request displays a form to add and configure a feed. + * Request parameter is: + * - url_rss (default: false) + * + * POST request adds a feed in database. + * Parameters are: + * - url_rss (default: false) + * - category (default: false) + * - new_category (required if category == 'nc') + * - http_user (default: false) + * - http_pass (default: false) + * It tries to get website information from RSS feed. + * If no category is given, feed is added to the default one. + * + * If url_rss is false, nothing happened. + */ public function addAction() { - $url = Minz_Request::param('url_rss', false); + $url = Minz_Request::param('url_rss'); if ($url === false) { + // No url, do nothing Minz_Request::forward(array( 'c' => 'subscription', 'a' => 'index' @@ -33,14 +62,19 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO = FreshRSS_Factory::createFeedDao(); $this->catDAO = new FreshRSS_CategoryDAO(); - $this->catDAO->checkDefault(); + $url_redirect = array( + 'c' => 'subscription', + 'a' => 'index', + 'params' => array(), + ); if (Minz_Request::isPost()) { @set_time_limit(300); - - $cat = Minz_Request::param('category', false); + $cat = Minz_Request::param('category'); if ($cat === 'nc') { + // User want to create a new category, new_category parameter + // must exist $new_cat = Minz_Request::param('new_category'); if (empty($new_cat['name'])) { $cat = false; @@ -48,139 +82,114 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $cat = $this->catDAO->addCategory($new_cat); } } + if ($cat === false) { + // If category was not given or if creating new category failed, + // get the default category + $this->catDAO->checkDefault(); $def_cat = $this->catDAO->getDefault(); $cat = $def_cat->id(); } + // HTTP information are useful if feed is protected behind a + // HTTP authentication $user = Minz_Request::param('http_user'); $pass = Minz_Request::param('http_pass'); - $params = array(); + $http_auth = ''; + if ($user != '' || $pass != '') { + $http_auth = $user . ':' . $pass; + } - $transactionStarted = false; + $transaction_started = false; try { $feed = new FreshRSS_Feed($url); - $feed->_category($cat); - - $httpAuth = ''; - if ($user != '' || $pass != '') { - $httpAuth = $user . ':' . $pass; - } - $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(), - ); - - if ($feedDAO->searchByUrl($values['url'])) { - // on est déjà abonné à ce flux - $notif = array( - 'type' => 'bad', - 'content' => _t('already_subscribed', $feed->name()) - ); - Minz_Session::_param('notification', $notif); - } else { - $id = $feedDAO->addFeed($values); - if (!$id) { - // problème au niveau de la base de données - $notif = array( - 'type' => 'bad', - 'content' => _t('feed_not_added', $feed->name()) - ); - Minz_Session::_param('notification', $notif); - } else { - $feed->_id($id); - $feed->faviconPrepare(); - - $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; - - $entryDAO = FreshRSS_Factory::createEntryDao(); - $entries = array_reverse($feed->entries()); //We want chronological order and SimplePie uses reverse order - - // 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); - - //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 - $preparedStatement = $entryDAO->addEntryPrepare(); - $transactionStarted = true; - $feedDAO->beginTransaction(); - // on ajoute les articles en masse sans vérification - foreach ($entries as $entry) { - $values = $entry->toArray(); - $values['id_feed'] = $feed->id(); - $values['id'] = min(time(), $entry->date(true)) . uSecString(); - $values['is_read'] = $is_read; - $entryDAO->addEntry($values, $preparedStatement); - } - $feedDAO->updateLastUpdate($feed->id()); - if ($transactionStarted) { - $feedDAO->commit(); - } - $transactionStarted = false; - - // ok, ajout terminé - $notif = array( - 'type' => 'good', - 'content' => _t('feed_added', $feed->name()) - ); - Minz_Session::_param('notification', $notif); - - // permet de rediriger vers la page de conf du flux - $params['id'] = $feed->id(); - } - } } catch (FreshRSS_BadUrl_Exception $e) { + // Given url was not a valid url! Minz_Log::warning($e->getMessage()); - $notif = array( - 'type' => 'bad', - 'content' => _t('invalid_url', $url) - ); - Minz_Session::_param('notification', $notif); + Minz_Request::bad(_t('invalid_url', $url), $url_redirect); + } + + try { + $feed->load(true); } catch (FreshRSS_Feed_Exception $e) { + // Something went bad (timeout, server not found, etc.) Minz_Log::warning($e->getMessage()); - $notif = array( - 'type' => 'bad', - 'content' => _t('internal_problem_feed', - Minz_Url::display(array('a' => 'logs'))) + Minz_Request::bad( + _t('internal_problem_feed', _url('index', 'logs')), + $url_redirect ); - Minz_Session::_param('notification', $notif); } catch (Minz_FileNotExistException $e) { - // Répertoire de cache n'existe pas + // Cache directory doesn't exist! Minz_Log::error($e->getMessage()); - $notif = array( - 'type' => 'bad', - 'content' => _t('internal_problem_feed', - Minz_Url::display(array('a' => 'logs'))) + Minz_Request::bad( + _t('internal_problem_feed', _url('index', 'logs')), + $url_redirect ); - Minz_Session::_param('notification', $notif); } - if ($transactionStarted) { - $feedDAO->rollBack(); + + if ($feedDAO->searchByUrl($feed->url())) { + Minz_Request::bad(_t('already_subscribed', $feed->name()), $url_redirect); } - Minz_Request::forward(array( - 'c' => 'subscription', - 'a' => 'index', - 'params' => $params - ), true); - } else { + $feed->_category($cat); + $feed->_httpAuth($http_auth); + + $values = array( + 'url' => $feed->url(), + 'category' => $feed->category(), + 'name' => $feed->name(), + 'website' => $feed->website(), + 'description' => $feed->description(), + 'lastUpdate' => time(), + 'httpAuth' => $feed->httpAuth(), + ); + + $id = $feedDAO->addFeed($values); + if (!$id) { + // There was an error in database... we cannot say what here. + Minz_Request::bad(_t('feed_not_added', $feed->name()), $url_redirect); + } + + // Ok, feed has been added in database. Now we have to refresh entries. + $feed->_id($id); + $feed->faviconPrepare(); + + $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; + + $entryDAO = FreshRSS_Factory::createEntryDao(); + // We want chronological order and SimplePie uses reverse order. + $entries = array_reverse($feed->entries()); + + // Calculate date of oldest entries we accept in DB. + $nb_month_old = $this->view->conf->old_entries; + $date_min = time() - (3600 * 24 * 30 * $nb_month_old); + + // Use a shared statement and a transaction to improve a LOT the + // performances. + $prepared_statement = $entryDAO->addEntryPrepare(); + $feedDAO->beginTransaction(); + foreach ($entries as $entry) { + // Entries are added without any verification. + $values = $entry->toArray(); + $values['id_feed'] = $feed->id(); + $values['id'] = min(time(), $entry->date(true)) . uSecString(); + $values['is_read'] = $is_read; + $entryDAO->addEntry($values, $prepared_statement); + } + $feedDAO->updateLastUpdate($feed->id()); + $feedDAO->commit(); - // GET request so we must ask confirmation to user + // Entries are in DB, we redirect to feed configuration page. + $url_redirect['params']['id'] = $feed->id(); + Minz_Request::good(_t('feed_added', $feed->name()), $url_redirect); + } else { + // GET request: we must ask confirmation to user before adding feed. Minz_View::prependTitle(_t('add_rss_feed') . ' · '); + $this->view->categories = $this->catDAO->listCategories(false); $this->view->feed = new FreshRSS_Feed($url); try { - // We try to get some more information about the feed + // We try to get more information about the feed. $this->view->feed->load(true); $this->view->load_ok = true; } catch (Exception $e) { @@ -189,43 +198,53 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed = $feedDAO->searchByUrl($this->view->feed->url()); if ($feed) { - // Already subscribe so we redirect to the feed configuration page - $notif = array( - 'type' => 'bad', - 'content' => _t('already_subscribed', $feed->name()) - ); - Minz_Session::_param('notification', $notif); - - Minz_Request::forward(array( - 'c' => 'subscription', - 'a' => 'index', - 'params' => array( - 'id' => $feed->id() - ) - ), true); + // Already subscribe so we redirect to the feed configuration page. + $url_redirect['params']['id'] = $feed->id(); + Minz_Request::good(_t('already_subscribed', $feed->name()), $url_redirect); } } } + /** + * This action remove entries from a given feed. + * + * It should be reached by a POST action. + * + * Parameter is: + * - id (default: false) + */ 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); - invalidateHttpCache(); - Minz_Request::forward(array( - 'c' => 'subscription', - 'a' => 'index', - 'params' => array('id' => $id) - ), true); + $id = Minz_Request::param('id'); + $url_redirect = array( + 'c' => 'subscription', + 'a' => 'index', + 'params' => array('id' => $id) + ); + + if (!Minz_Request::isPost()) { + Minz_Request::forward($url_redirect, true); + } + + $feedDAO = FreshRSS_Factory::createFeedDao(); + $n = $feedDAO->truncate($id); + + invalidateHttpCache(); + if ($n === false) { + Minz_Request::bad(_t('error_occurred'), $url_redirect); + } else { + Minz_Request::good(_t('n_entries_deleted', $n), $url_redirect); } } + /** + * This action actualizes entries from one or several feeds. + * + * Parameters are: + * - id (default: false) + * - force (default: false) + * If id is not specified, all the feeds are actualized. But if force is + * false, process stops at 10 feeds to avoid time execution problem. + */ public function actualizeAction() { @set_time_limit(300); @@ -234,213 +253,229 @@ class FreshRSS_feed_Controller extends Minz_ActionController { Minz_Session::_param('actualize_feeds', false); $id = Minz_Request::param('id'); - $force = Minz_Request::param('force', false); + $force = Minz_Request::param('force'); - // 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) + // Create a list of feeds to actualize. + // If id is set and valid, corresponding feed is added to the list but + // alone in order to automatize further process. $feeds = array(); if ($id) { $feed = $feedDAO->searchById($id); if ($feed) { - $feeds = array($feed); + $feeds[] = $feed; } } else { $feeds = $feedDAO->listFeedsOrderUpdate($this->view->conf->ttl_default); } - // on calcule la date des articles les plus anciens qu'on accepte + // Calculate date of oldest entries we accept in DB. $nb_month_old = max($this->view->conf->old_entries, 1); $date_min = time() - (3600 * 24 * 30 * $nb_month_old); - $i = 0; - $flux_update = 0; + $updated_feeds = 0; $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; foreach ($feeds as $feed) { if (!$feed->lock()) { Minz_Log::notice('Feed already being actualized: ' . $feed->url()); continue; } - try { - $url = $feed->url(); - $feedHistory = $feed->keepHistory(); + try { + // Load entries $feed->load(false); - $entries = array_reverse($feed->entries()); //We want chronological order and SimplePie uses reverse order - $hasTransaction = false; - - 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); - $useDeclaredDate = empty($existingGuids); - - if ($feedHistory == -2) { //default - $feedHistory = $this->view->conf->keep_history_default; - } + } catch (FreshRSS_Feed_Exception $e) { + Minz_Log::notice($e->getMessage()); + $feedDAO->updateLastUpdate($feed->id(), 1); + continue; + } - $preparedStatement = $entryDAO->addEntryPrepare(); - $hasTransaction = true; - $feedDAO->beginTransaction(); + $url = $feed->url(); + $feed_history = $feed->keepHistory(); + if ($feed_history == -2) { + // TODO: -2 must be a constant! + // -2 means we take the default value from configuration + $feed_history = $this->view->conf->keep_history_default; + } - // On ne vérifie pas strictement que l'article n'est pas déjà en BDD - // La BDD refusera l'ajout car (id_feed, guid) doit être unique - foreach ($entries as $entry) { - $eDate = $entry->date(true); - if ((!isset($existingGuids[$entry->guid()])) && - (($feedHistory != 0) || ($eDate >= $date_min))) { - $values = $entry->toArray(); - //Use declared date at first import, otherwise use discovery date - $values['id'] = ($useDeclaredDate || $eDate < $date_min) ? - min(time(), $eDate) . uSecString() : - uTimeString(); - $values['is_read'] = $is_read; - $entryDAO->addEntry($values, $preparedStatement); - } + // We want chronological order and SimplePie uses reverse order. + $entries = array_reverse($feed->entries()); + if (count($entries) > 0) { + // For this feed, check last n entry GUIDs already in database. + $existing_guids = array_fill_keys($entryDAO->listLastGuidsByFeed( + $feed->id(), count($entries) + 10 + ), 1); + $use_declared_date = empty($existing_guids); + + // Add entries in database if possible. + $prepared_statement = $entryDAO->addEntryPrepare(); + $feedDAO->beginTransaction(); + foreach ($entries as $entry) { + $entry_date = $entry->date(true); + if (isset($existing_guids[$entry->guid()]) || + ($feed_history == 0 && $entry_date < $date_min)) { + // This entry already exists in DB or should not be added + // considering configuration and date. + continue; } - } - if (($feedHistory >= 0) && (rand(0, 30) === 1)) { - if (!$hasTransaction) { - $feedDAO->beginTransaction(); - } - $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, max($feedHistory, count($entries) + 10)); - if ($nb > 0) { - Minz_Log::debug($nb . ' old entries cleaned in feed [' . $feed->url() . ']'); + $id = uTimeString(); + if ($use_declared_date || $entry_date < $date_min) { + // Use declared date at first import. + $id = min(time(), $entry_date) . uSecString(); } + + $values = $entry->toArray(); + $values['id'] = $id; + $values['is_read'] = $is_read; + $entryDAO->addEntry($values, $prepared_statement); } + } - // on indique que le flux vient d'être mis à jour en BDD - $feedDAO->updateLastUpdate($feed->id(), 0, $hasTransaction); - if ($hasTransaction) { - $feedDAO->commit(); + if ($feed_history >= 0 && rand(0, 30) === 1) { + // TODO: move this function in web cron when available + // Remove old entries once in 30. + if (!$feedDAO->hasTransaction()) { + $feedDAO->beginTransaction(); } - $flux_update++; - if (($feed->url() !== $url)) { //HTTP 301 Moved Permanently - Minz_Log::notice('Feed ' . $url . ' moved permanently to ' . $feed->url()); - $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); + + $nb = $feedDAO->cleanOldEntries($feed->id(), + $date_min, + max($feed_history, count($entries) + 10)); + if ($nb > 0) { + Minz_Log::debug($nb . ' old entries cleaned in feed [' . + $feed->url() . ']'); } - } catch (FreshRSS_Feed_Exception $e) { - Minz_Log::notice($e->getMessage()); - $feedDAO->updateLastUpdate($feed->id(), 1); + } + + $feedDAO->updateLastUpdate($feed->id(), 0, $feedDAO->hasTransaction()); + if ($feedDAO->hasTransaction()) { + $feedDAO->commit(); + } + + if ($feed->url() !== $url) { + // HTTP 301 Moved Permanently + Minz_Log::notice('Feed ' . $url . ' moved permanently to ' . $feed->url()); + $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } $feed->faviconPrepare(); $feed->unlock(); + $updated_feeds++; unset($feed); - // On arrête à 10 flux pour ne pas surcharger le serveur - // sauf si le paramètre $force est à vrai - $i++; - if ($i >= 10 && !$force) { + // No more than 10 feeds unless $force is true to avoid overloading + // the server. + if ($updated_feeds >= 10 && !$force) { break; } } - $url = array(); - if ($flux_update === 1) { - // on a mis un seul flux à jour - $feed = reset($feeds); + if (Minz_Request::param('ajax')) { + // Most of the time, ajax request is for only one feed. But since + // there are several parallel requests, we should return that there + // are several updated feeds. $notif = array( 'type' => 'good', - 'content' => _t('feed_actualized', $feed->name()) - ); - } elseif ($flux_update > 1) { - // plusieurs flux on été mis à jour - $notif = array( - 'type' => 'good', - 'content' => _t('n_feeds_actualized', $flux_update) - ); - } else { - // aucun flux n'a été mis à jour, oups - $notif = array( - 'type' => 'good', - 'content' => _t('no_feed_to_refresh') + 'content' => _t('feeds_actualized') ); + Minz_Session::_param('notification', $notif); + // No layout in ajax request. + $this->view->_useLayout(false); + return; } - if ($i === 1) { - // Si on a voulu mettre à jour qu'un flux - // on filtre l'affichage par ce flux + // Redirect to the main page with correct notification. + if ($updated_feeds === 1) { $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); + Minz_Request::good(_t('feed_actualized', $feed->name()), + array('get' => 'f_' . $feed->id())); + } elseif ($updated_feeds > 1) { + Minz_Request::good(_t('n_feeds_actualized', $updated_feeds), array()); } 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( - 'type' => 'good', - 'content' => _t('feeds_actualized') - ); - Minz_Session::_param('notification', $notif); - // et on désactive le layout car ne sert à rien - $this->view->_useLayout(false); + Minz_Request::good(_t('no_feed_to_refresh'), array()); } } + /** + * This action changes the category of a feed. + * + * This page must be reached by a POST request. + * + * Parameters are: + * - f_id (default: false) + * - c_id (default: false) + * If c_id is false, default category is used. + * + * @todo should handle order of the feed inside the category. + */ public function moveAction() { - if (Minz_Request::isPost()) { - $feed_id = Minz_Request::param('f_id'); - $cat_id = Minz_Request::param('c_id'); + if (!Minz_Request::isPost()) { + Minz_Request::forward(array('c' => 'subscription'), true); + } - $feedDAO = FreshRSS_Factory::createFeedDao(); - $values = array( - 'category' => $cat_id, - ); + $feed_id = Minz_Request::param('f_id'); + $cat_id = Minz_Request::param('c_id'); - $feed = $feedDAO->searchById($feed_id); + if ($cat_id === false) { + // If category was not given get the default one. + $catDAO = new FreshRSS_CategoryDAO(); + $catDAO->checkDefault(); + $def_cat = $catDAO->getDefault(); + $cat_id = $def_cat->id(); + } - if ($feed && ($feed->category() == $cat_id || - $feedDAO->updateFeed($feed_id, $values))) { - // TODO: return something useful - } else { - Minz_Error::error( - 404, - array('error' => array(_t('error_occurred'))) - ); - } + $feedDAO = FreshRSS_Factory::createFeedDao(); + $values = array('category' => $cat_id); + + $feed = $feedDAO->searchById($feed_id); + if ($feed && ($feed->category() == $cat_id || + $feedDAO->updateFeed($feed_id, $values))) { + // TODO: return something useful + } else { + Minz_Log::warning('Cannot move feed `' . $feed_id . '` ' . + 'in the category `' . $cat_id . '`'); + Minz_Error::error( + 404, + array('error' => array(_t('error_occurred'))) + ); } } + /** + * This action deletes a feed. + * + * This page must be reached by a POST request. + * If there are related queries, they are deleted too. + * + * Parameters are: + * - id (default: false) + * - r (default: false) + * r permits to redirect to a given page at the end of this action. + * + * @todo handle "r" redirection in Minz_Request::forward()? + */ public function deleteAction() { - if (Minz_Request::isPost()) { - $id = Minz_Request::param('id'); - $feedDAO = FreshRSS_Factory::createFeedDao(); - - if ($feedDAO->deleteFeed($id)) { - // TODO: Delete old favicon + $redirect_url = Minz_Request::param('r', false, true); + if (!$redirect_url) { + $redirect_url = array('c' => 'subscription', 'a' => 'index'); + } - // Remove related queries - $this->view->conf->remove_query_by_get('f_' . $id); - $this->view->conf->save(); + if (!Minz_Request::isPost()) { + Minz_Request::forward($redirect_url, true); + } - $notif = array( - 'type' => 'good', - 'content' => _t('feed_deleted') - ); - } else { - $notif = array( - 'type' => 'bad', - 'content' => _t('error_occured') - ); - } + $id = Minz_Request::param('id'); + $feedDAO = FreshRSS_Factory::createFeedDao(); + if ($feedDAO->deleteFeed($id)) { + // TODO: Delete old favicon - Minz_Session::_param('notification', $notif); + // Remove related queries + $this->view->conf->remove_query_by_get('f_' . $id); + $this->view->conf->save(); - $redirect_url = Minz_Request::param('r', false, true); - if ($redirect_url) { - Minz_Request::forward($redirect_url); - } else { - Minz_Request::forward(array('c' => 'subscription', 'a' => 'index'), true); - } + Minz_Request::good(_t('feed_deleted'), $redirect_url); + } else { + Minz_Request::bad(_t('error_occurred'), $redirect_url); } } } diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index b4bfca746..69e46fb39 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -16,6 +16,7 @@ class Minz_ModelPdo { public static $useSharedBd = true; private static $sharedBd = null; private static $sharedPrefix; + private static $has_transaction = false; protected static $sharedDbType; /** @@ -91,12 +92,18 @@ class Minz_ModelPdo { public function beginTransaction() { $this->bd->beginTransaction(); + $this->has_transaction = true; + } + public function hasTransaction() { + return $this->has_transaction; } public function commit() { $this->bd->commit(); + $this->has_transaction = false; } public function rollBack() { $this->bd->rollBack(); + $this->has_transaction = false; } public static function clean() { -- cgit v1.2.3 From d65a9f9bd62e93d8a2cdcb34c520f2af7e02983d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 6 Oct 2014 11:59:27 +0200 Subject: Refactor entryController - Coding style - Refactoring - Comments (set of TODO) See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/entryController.php | 191 +++++++++++++++++++++--------------- app/Controllers/feedController.php | 2 +- 2 files changed, 115 insertions(+), 78 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index d7be05663..c46fbf346 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -1,6 +1,14 @@ view->loginOk) { Minz_Error::error( @@ -9,119 +17,153 @@ class FreshRSS_entry_Controller extends Minz_ActionController { ); } + // Keep parameter information (output) to do a correct redirection at + // the end. $this->params = array(); $output = Minz_Request::param('output', ''); - if (($output != '') && ($this->view->conf->view_mode !== $output)) { + if ($output != '' && $this->view->conf->view_mode !== $output) { $this->params['output'] = $output; } - $this->redirect = false; - $ajax = Minz_Request::param('ajax'); - if ($ajax) { + // If ajax request, we do not print layout + $this->ajax = Minz_Request::param('ajax'); + if ($this->ajax) { $this->view->_useLayout(false); - } - } - - public function lastAction() { - $ajax = Minz_Request::param('ajax'); - if (!$ajax && $this->redirect) { - Minz_Request::forward(array( - 'c' => 'index', - 'a' => 'index', - 'params' => $this->params - ), true); - } else { Minz_Request::_param('ajax'); } } + /** + * Mark one or several entries as read (or not!). + * + * If request concerns several entries, it MUST be a POST request. + * If request concerns several entries, only mark them as read is available. + * + * Parameters are: + * - id (default: false) + * - get (default: false) /(c_\d+|f_\d+|s|a)/ + * - nextGet (default: $get) + * - idMax (default: 0) + * - is_read (default: true) + * + * @todo nextGet system should not be present here... or should be? + */ 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); + $next_get = Minz_Request::param('nextGet', $get); + $id_max = Minz_Request::param('idMax', 0); $entryDAO = FreshRSS_Factory::createEntryDao(); - if ($id == false) { + if ($id === false) { + // id is false? It MUST be a POST request! if (!Minz_Request::isPost()) { return; } if (!$get) { - $entryDAO->markReadEntries($idMax); + // No get? Mark all entries as read (from $id_max) + $entryDAO->markReadEntries($id_max); } else { - $typeGet = $get[0]; + $type_get = $get[0]; $get = substr($get, 2); - switch($typeGet) { + switch($type_get) { case 'c': - $entryDAO->markReadCat($get, $idMax); + $entryDAO->markReadCat($get, $id_max); break; case 'f': - $entryDAO->markReadFeed($get, $idMax); + $entryDAO->markReadFeed($get, $id_max); break; case 's': - $entryDAO->markReadEntries($idMax, true); + $entryDAO->markReadEntries($id_max, true); break; case 'a': - $entryDAO->markReadEntries($idMax); + $entryDAO->markReadEntries($id_max); break; } - if ($nextGet !== 'a') { - $this->params['get'] = $nextGet; + + if ($next_get !== 'a') { + // Redirect to the correct page (category, feed or starred) + // Not "a" because it is the default value if nothing is + // given. + $this->params['get'] = $next_get; } } - - $notif = array( - 'type' => 'good', - 'content' => _t('feeds_marked_read') - ); - Minz_Session::_param('notification', $notif); } else { $is_read = (bool)(Minz_Request::param('is_read', true)); $entryDAO->markRead($id, $is_read); } + + if (!$this->ajax) { + Minz_Request::good(_t('feeds_marked_read'), array( + 'c' => 'index', + 'a' => 'index', + 'params' => $this->params, + ), true); + } } + /** + * This action marks an entry as favourite (bookmark) or not. + * + * Parameter is: + * - id (default: false) + * - is_favorite (default: true) + * If id is false, nothing happened. + */ public function bookmarkAction() { - $this->redirect = true; - $id = Minz_Request::param('id'); - if ($id) { + $is_favourite = (bool)Minz_Request::param('is_favorite', true); + if ($id !== false) { $entryDAO = FreshRSS_Factory::createEntryDao(); - $entryDAO->markFavorite($id, (bool)(Minz_Request::param('is_favorite', true))); + $entryDAO->markFavorite($id, $is_favourite); + } + + if (!$this->ajax) { + Minz_Request::forward(array( + 'c' => 'index', + 'a' => 'index', + 'params' => $this->params, + ), true); } } + /** + * This action optimizes database to reduce its size. + * + * This action shouldbe reached by a POST request. + * + * @todo move this action in configure controller. + * @todo call this action through web-cron when available + */ public function optimizeAction() { - if (Minz_Request::isPost()) { - @set_time_limit(300); + $url_redirect = array( + 'c' => 'configure', + 'a' => 'archiving', + ); - // La table des entrées a tendance à grossir énormément - // Cette action permet d'optimiser cette table permettant de grapiller un peu de place - // Cette fonctionnalité n'est à appeler qu'occasionnellement - $entryDAO = FreshRSS_Factory::createEntryDao(); - $entryDAO->optimizeTable(); + if (!Minz_Request::isPost()) { + Minz_Request::forward($url_redirect, true); + } - $feedDAO = FreshRSS_Factory::createFeedDao(); - $feedDAO->updateCachedValues(); + @set_time_limit(300); - invalidateHttpCache(); + $entryDAO = FreshRSS_Factory::createEntryDao(); + $entryDAO->optimizeTable(); - $notif = array( - 'type' => 'good', - 'content' => _t('optimization_complete') - ); - Minz_Session::_param('notification', $notif); - } + $feedDAO = FreshRSS_Factory::createFeedDao(); + $feedDAO->updateCachedValues(); - Minz_Request::forward(array( - 'c' => 'configure', - 'a' => 'archiving' - ), true); + invalidateHttpCache(); + Minz_Request::good(_t('optimization_complete'), $url_redirect); } + /** + * This action purges old entries from feeds. + * + * @todo should be a POST request + * @todo should be in feedController + */ public function purgeAction() { @set_time_limit(300); @@ -130,21 +172,23 @@ class FreshRSS_entry_Controller extends Minz_ActionController { $feedDAO = FreshRSS_Factory::createFeedDao(); $feeds = $feedDAO->listFeeds(); - $nbTotal = 0; + $nb_total = 0; invalidateHttpCache(); foreach ($feeds as $feed) { - $feedHistory = $feed->keepHistory(); - if ($feedHistory == -2) { //default - $feedHistory = $this->view->conf->keep_history_default; + $feed_history = $feed->keepHistory(); + if ($feed_history == -2) { + // TODO: -2 must be a constant! + // -2 means we take the default value from configuration + $feed_history = $this->view->conf->keep_history_default; } - if ($feedHistory >= 0) { - $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, $feedHistory); + + if ($feed_history >= 0) { + $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, $feed_history); if ($nb > 0) { - $nbTotal += $nb; + $nb_total += $nb; Minz_Log::debug($nb . ' old entries cleaned in feed [' . $feed->url() . ']'); - //$feedDAO->updateLastUpdate($feed->id()); } } } @@ -152,16 +196,9 @@ class FreshRSS_entry_Controller extends Minz_ActionController { $feedDAO->updateCachedValues(); invalidateHttpCache(); - - $notif = array( - 'type' => 'good', - 'content' => _t('purge_completed', $nbTotal) - ); - Minz_Session::_param('notification', $notif); - - Minz_Request::forward(array( + Minz_Request::good(_t('purge_completed', $nb_total), array( 'c' => 'configure', 'a' => 'archiving' - ), true); + )); } } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 0f52917e4..18829d252 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -332,7 +332,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } if ($feed_history >= 0 && rand(0, 30) === 1) { - // TODO: move this function in web cron when available + // TODO: move this function in web cron when available (see entry::purge) // Remove old entries once in 30. if (!$feedDAO->hasTransaction()) { $feedDAO->beginTransaction(); -- cgit v1.2.3 From 34151ea1ae2107d4b5d96cefe8f4b2dc1ae3b70f Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 6 Oct 2014 13:12:36 +0200 Subject: Add comments in error and importExport controllers See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/errorController.php | 17 +++- app/Controllers/importExportController.php | 149 ++++++++++++++++++++++++----- 2 files changed, 140 insertions(+), 26 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/errorController.php b/app/Controllers/errorController.php index bb3431c2b..76ab930e0 100644 --- a/app/Controllers/errorController.php +++ b/app/Controllers/errorController.php @@ -1,8 +1,21 @@ view->code = 'Error 403 - Forbidden'; break; @@ -22,7 +35,7 @@ class FreshRSS_error_Controller extends Minz_ActionController { $errors = Minz_Request::param('logs', array()); $this->view->errorMessage = trim(implode($errors)); if ($this->view->errorMessage == '') { - switch(Minz_Request::param('code')) { + switch($code_int) { case 403: $this->view->errorMessage = _t('forbidden_access'); break; diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index f329766b8..57759f277 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -1,6 +1,14 @@ view->loginOk) { Minz_Error::error( @@ -16,13 +24,23 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->feedDAO = FreshRSS_Factory::createFeedDao(); } + /** + * This action displays the main page for import / export system. + */ public function indexAction() { - $this->view->categories = $this->catDAO->listCategories(); $this->view->feeds = $this->feedDAO->listFeeds(); - Minz_View::prependTitle(_t('import_export') . ' · '); } + /** + * This action handles import action. + * + * It must be reached by a POST request. + * + * Parameter is: + * - file (default: nothing!) + * Available file types are: zip, json or xml. + */ public function importAction() { if (!Minz_Request::isPost()) { Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); @@ -92,10 +110,10 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $error = $this->importOpml($opml_file); } foreach ($list_files['json_starred'] as $article_file) { - $error = $this->importArticles($article_file, true); + $error = $this->importJson($article_file, true); } foreach ($list_files['json_feed'] as $article_file) { - $error = $this->importArticles($article_file); + $error = $this->importJson($article_file); } // And finally, we get import status and redirect to the home page @@ -105,11 +123,15 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { Minz_Request::good($content_notif); } + /** + * This method tries to guess the file type based on its name. + * + * Itis a *very* basic guess file type function. Only based on filename. + * That's could be improved but should be enough for what we have to do. + * + * @todo move into lib_rss.php + */ private function guessFileType($filename) { - // A *very* basic guess file type function. Only based on filename - // That's could be improved but should be enough, at least for a first - // implementation. - if (substr_compare($filename, '.zip', -4) === 0) { return 'zip'; } elseif (substr_compare($filename, '.opml', -5) === 0 || @@ -125,6 +147,12 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } } + /** + * This method parses and imports an OPML file. + * + * @param string $opml_file the OPML file content. + * @return boolean true if an error occured, false else. + */ private function importOpml($opml_file) { $opml_array = array(); try { @@ -139,13 +167,22 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $this->addOpmlElements($opml_array['body']); } + /** + * This method imports an OPML file based on its body. + * + * @param array $opml_elements an OPML element (body or outline). + * @param string $parent_cat the name of the parent category. + * @return boolean true if an error occured, false else. + */ private function addOpmlElements($opml_elements, $parent_cat = null) { $error = false; foreach ($opml_elements as $elt) { $res = false; if (isset($elt['xmlUrl'])) { + // If xmlUrl exists, it means it is a feed $res = $this->addFeedOpml($elt, $parent_cat); } else { + // No xmlUrl? It should be a category! $res = $this->addCategoryOpml($elt, $parent_cat); } @@ -158,6 +195,13 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $error; } + /** + * This method imports an OPML feed element. + * + * @param array $feed_elt an OPML element (must be a feed element). + * @param string $parent_cat the name of the parent category. + * @return boolean true if an error occured, false else. + */ private function addFeedOpml($feed_elt, $parent_cat) { if (is_null($parent_cat)) { // This feed has no parent category so we get the default one @@ -165,8 +209,9 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } $cat = $this->catDAO->searchByName($parent_cat); - if (!$cat) { + // If there is not $cat, it means parent category does not exist in + // database. It should not happened! return true; } @@ -203,6 +248,13 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $error; } + /** + * This method imports an OPML category element. + * + * @param array $cat_elt an OPML element (must be a category element). + * @param string $parent_cat the name of the parent category. + * @return boolean true if an error occured, false else. + */ private function addCategoryOpml($cat_elt, $parent_cat) { // Create a new Category object $cat = new FreshRSS_Category(Minz_Helper::htmlspecialchars_utf8($cat_elt['text'])); @@ -223,7 +275,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $error; } - private function importArticles($article_file, $starred = false) { + /** + * This method import a JSON-based file (Google Reader format). + * + * @param string $article_file the JSON file content. + * @param boolean $starred true if articles from the file must be starred. + * @return boolean true if an error occured, false else. + */ + private function importJson($article_file, $starred = false) { $article_object = json_decode($article_file, true); if (is_null($article_object)) { Minz_Log::warning('Try to import a non-JSON file'); @@ -232,16 +291,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; - $google_compliant = ( - strpos($article_object['id'], 'com.google') !== false - ); + $google_compliant = strpos($article_object['id'], 'com.google') !== false; $error = false; $article_to_feed = array(); // First, we check feeds of articles are in DB (and add them if needed). foreach ($article_object['items'] as $item) { - $feed = $this->addFeedArticles($item['origin'], $google_compliant); + $feed = $this->addFeedJson($item['origin'], $google_compliant); if (is_null($feed)) { $error = true; } else { @@ -254,6 +311,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->entryDAO->beginTransaction(); foreach ($article_object['items'] as $item) { if (!isset($article_to_feed[$item['id']])) { + // Related feed does not exist for this entry, do nothing. continue; } @@ -263,6 +321,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { 'summary' : 'content'; $tags = $item['categories']; if ($google_compliant) { + // Remove tags containing "/state/com.google" which are useless. $tags = array_filter($tags, function($var) { return strpos($var, '/state/com.google') === false; }); @@ -288,7 +347,15 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $error; } - private function addFeedArticles($origin, $google_compliant) { + /** + * This method import a JSON-based feed (Google Reader format). + * + * @param array $origin represents a feed. + * @param boolean $google_compliant takes care of some specific values if true. + * @return FreshRSS_Feed if feed is in database at the end of the process, + * else null. + */ + private function addFeedJson($origin, $google_compliant) { $default_cat = $this->catDAO->getDefault(); $return = null; @@ -298,14 +365,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $website = $origin['htmlUrl']; try { - // Create a Feed object and add it in DB + // Create a Feed object and add it in database. $feed = new FreshRSS_Feed($url); $feed->_category($default_cat->id()); $feed->_name($name); $feed->_website($website); // addFeedObject checks if feed is already in DB so nothing else to - // check here + // check here. $id = $this->feedDAO->addFeedObject($feed); if ($id !== false) { @@ -319,6 +386,16 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $return; } + /** + * This action handles export action. + * + * This action must be reached by a POST request. + * + * Parameters are: + * - export_opml (default: false) + * - export_starred (default: false) + * - export_feeds (default: array()) a list of feed ids + */ public function exportAction() { if (!Minz_Request::isPost()) { Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); @@ -336,7 +413,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } if ($export_starred) { - $export_files['starred.json'] = $this->generateArticles('starred'); + $export_files['starred.json'] = $this->generateEntries('starred'); } foreach ($export_feeds as $feed_id) { @@ -344,9 +421,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { if ($feed) { $filename = 'feed_' . $feed->category() . '_' . $feed->id() . '.json'; - $export_files[$filename] = $this->generateArticles( - 'feed', $feed - ); + $export_files[$filename] = $this->generateEntries('feed', $feed); } } @@ -366,10 +441,16 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $type = $this->guessFileType($filename); $this->exportFile('freshrss_' . $filename, $export_files[$filename], $type); } else { + // Nothing to do... Minz_Request::forward(array('c' => 'importExport', 'a' => 'index'), true); } } + /** + * This method returns the OPML file based on user subscriptions. + * + * @return string the OPML file content. + */ private function generateOpml() { $list = array(); foreach ($this->catDAO->listCategories() as $key => $cat) { @@ -381,7 +462,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $this->view->helperToString('export/opml'); } - private function generateArticles($type, $feed = NULL) { + /** + * This method returns a JSON file content. + * + * @param string $type must be "starred" or "feed" + * @param FreshRSS_Feed $feed feed of which we want to get entries. + * @return string the JSON file content. + */ + private function generateEntries($type, $feed = NULL) { $this->view->categories = $this->catDAO->listCategories(); if ($type == 'starred') { @@ -389,8 +477,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->view->type = 'starred'; $unread_fav = $this->entryDAO->countUnreadReadFavorites(); $this->view->entries = $this->entryDAO->listWhere( - 's', '', FreshRSS_Entry::STATE_ALL, 'ASC', - $unread_fav['all'] + 's', '', FreshRSS_Entry::STATE_ALL, 'ASC', $unread_fav['all'] ); } elseif ($type == 'feed' && !is_null($feed)) { $this->view->list_title = _t('feed_list', $feed->name()); @@ -405,6 +492,12 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return $this->view->helperToString('export/articles'); } + /** + * This method zips a list of files and returns it by HTTP. + * + * @param array $files list of files where key is filename and value the content. + * @throws Exception if Zip extension is not loaded. + */ private function exportZip($files) { if (!extension_loaded('zip')) { throw new Exception(); @@ -428,6 +521,14 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { unlink($zip_file); } + /** + * This method returns a single file (OPML or JSON) by HTTP. + * + * @param string $filename + * @param string $content + * @param string $type the file type (opml, json_feed or json_starred). + * If equals to unknown, nothing happens. + */ private function exportFile($filename, $content, $type) { if ($type === 'unknown') { return; -- cgit v1.2.3 From 79aa5beaf44af13a1828bfa5fc824a08c62054dc Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 6 Oct 2014 23:29:20 +0200 Subject: Refactor authentication system. Big work, not finished. A lot of features have been removed. See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/categoryController.php | 2 +- app/Controllers/configureController.php | 2 +- app/Controllers/entryController.php | 2 +- app/Controllers/feedController.php | 2 +- app/Controllers/importExportController.php | 2 +- app/Controllers/indexController.php | 296 ++++++----------------------- app/Controllers/statsController.php | 2 +- app/Controllers/subscriptionController.php | 2 +- app/Controllers/updateController.php | 2 +- app/Controllers/usersController.php | 2 +- app/FreshRSS.php | 135 ++----------- app/Models/Auth.php | 209 ++++++++++++++++++++ app/layout/aside_flux.phtml | 6 +- app/layout/header.phtml | 32 +--- app/layout/nav_menu.phtml | 4 +- app/views/helpers/view/normal_view.phtml | 6 +- app/views/index/index.phtml | 2 +- app/views/index/login.phtml | 1 - app/views/index/logout.phtml | 1 - app/views/index/resetAuth.phtml | 33 ---- 20 files changed, 309 insertions(+), 434 deletions(-) create mode 100644 app/Models/Auth.php delete mode 100644 app/views/index/login.phtml delete mode 100644 app/views/index/logout.phtml delete mode 100644 app/views/index/resetAuth.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index c79f37fa4..537a2b210 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -12,7 +12,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { * */ public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 789e9dfb0..7e77a757a 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -10,7 +10,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * underlying framework. */ public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index c46fbf346..a1dfacb4d 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -10,7 +10,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { * underlying framework. */ public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 18829d252..2a7238eaf 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -10,7 +10,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { * underlying framework. */ public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { // 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 diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 57759f277..aaac1b68b 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -10,7 +10,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { * underlying framework. */ public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 0d2eff700..3006480f9 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -8,7 +8,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { $token = $this->view->conf->token; // check if user is logged in - if (!$this->view->loginOk && !Minz_Configuration::allowAnonymous()) { + if (!FreshRSS_Auth::hasAccess() && !Minz_Configuration::allowAnonymous()) { $token_param = Minz_Request::param('token', ''); $token_is_ok = ($token != '' && $token === $token_param); if ($output === 'rss' && !$token_is_ok) { @@ -20,7 +20,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } elseif ($output !== 'rss') { // "hard" redirection is not required, just ask dispatcher to // forward to the login form without 302 redirection - Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin')); + Minz_Request::forward(array('c' => 'index', 'a' => 'login')); return; } } @@ -207,7 +207,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } public function logsAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) @@ -229,265 +229,91 @@ class FreshRSS_index_Controller extends Minz_ActionController { $this->view->logsPaginator->_currentPage($page); } + /** + * This action handles the login page. + */ public function loginAction() { - $this->view->_useLayout(false); - - $url = 'https://verifier.login.persona.org/verify'; - $assert = Minz_Request::param('assertion'); - $params = 'assertion=' . $assert . '&audience=' . - 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); - - $res = json_decode($result, true); - - $loginOk = false; - $reason = ''; - if ($res['status'] === 'okay') { - $email = filter_var($res['email'], FILTER_VALIDATE_EMAIL); - if ($email != '') { - $personaFile = DATA_PATH . '/persona/' . $email . '.txt'; - if (($currentUser = @file_get_contents($personaFile)) !== false) { - $currentUser = trim($currentUser); - if (ctype_alnum($currentUser)) { - try { - $this->conf = new FreshRSS_Configuration($currentUser); - $loginOk = strcasecmp($email, $this->conf->mail_login) === 0; - } catch (Minz_Exception $e) { - $reason = 'Invalid configuration for user [' . $currentUser . ']! ' . $e->getMessage(); //Permission denied or conf file does not exist - } - } else { - $reason = 'Invalid username format [' . $currentUser . ']!'; - } - } - } else { - $reason = 'Invalid email format [' . $res['email'] . ']!'; - } - } - if ($loginOk) { - Minz_Session::_param('currentUser', $currentUser); - Minz_Session::_param('mail', $email); - $this->view->loginOk = true; - invalidateHttpCache(); - } else { - $res = array(); - $res['status'] = 'failure'; - $res['reason'] = $reason == '' ? _t('invalid_login') : $reason; - Minz_Log::warning('Persona: ' . $res['reason']); + if (FreshRSS_Auth::hasAccess()) { + Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } - header('Content-Type: application/json; charset=UTF-8'); - $this->view->res = json_encode($res); - } - - public function logoutAction() { - $this->view->_useLayout(false); invalidateHttpCache(); - Minz_Session::_param('currentUser'); - Minz_Session::_param('mail'); - Minz_Session::_param('passwordHash'); - } - - private static function makeLongTermCookie($username, $passwordHash) { - do { - $token = sha1(Minz_Configuration::salt() . $username . uniqid(mt_rand(), true)); - $tokenFile = DATA_PATH . '/tokens/' . $token . '.txt'; - } while (file_exists($tokenFile)); - if (@file_put_contents($tokenFile, $username . "\t" . $passwordHash) === false) { - return false; - } - $expire = time() + 2629744; //1 month //TODO: Use a configuration instead - Minz_Session::setLongTermCookie('FreshRSS_login', $token, $expire); - Minz_Session::_param('token', $token); - return $token; - } - - private static function deleteLongTermCookie() { - Minz_Session::deleteLongTermCookie('FreshRSS_login'); - $token = Minz_Session::param('token', null); - if (ctype_alnum($token)) { - @unlink(DATA_PATH . '/tokens/' . $token . '.txt'); - } - Minz_Session::_param('token'); - if (rand(0, 10) === 1) { - self::purgeTokens(); - } - } - private static function purgeTokens() { - $oldest = time() - 2629744; //1 month //TODO: Use a configuration instead - foreach (new DirectoryIterator(DATA_PATH . '/tokens/') as $fileInfo) { - if ($fileInfo->getExtension() === 'txt' && $fileInfo->getMTime() < $oldest) { - @unlink($fileInfo->getPathname()); - } + $auth_type = Minz_Configuration::authType(); + switch ($auth_type) { + case 'form': + Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin')); + break; + case 'http_auth': + case 'none': + // It should not happened! + Minz_Error::error(404); + default: + // TODO load plugin instead + Minz_Error::error(404); } } + /** + * + */ public function formLoginAction() { - if ($this->view->loginOk) { + if (FreshRSS_Auth::hasAccess()) { Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); } - if (Minz_Request::isPost()) { - $ok = false; - $nonce = Minz_Session::param('nonce'); - $username = Minz_Request::param('username', ''); - $c = Minz_Request::param('challenge', ''); - if (ctype_alnum($username) && ctype_graph($c) && ctype_alnum($nonce)) { - if (!function_exists('password_verify')) { - include_once(LIB_PATH . '/password_compat.php'); - } - try { - $conf = new FreshRSS_Configuration($username); - $s = $conf->passwordHash; - $ok = password_verify($nonce . $s, $c); - if ($ok) { - Minz_Session::_param('currentUser', $username); - Minz_Session::_param('passwordHash', $s); - if (Minz_Request::param('keep_logged_in', false)) { - self::makeLongTermCookie($username, $s); - } else { - self::deleteLongTermCookie(); - } - } else { - Minz_Log::warning('Password mismatch for user ' . $username . ', nonce=' . $nonce . ', c=' . $c); - } - } catch (Minz_Exception $me) { - Minz_Log::warning('Login failure: ' . $me->getMessage()); - } - } else { - Minz_Log::debug('Invalid credential parameters: user=' . $username . ' challenge=' . $c . ' nonce=' . $nonce); - } - if (!$ok) { - $notif = array( - 'type' => 'bad', - 'content' => _t('invalid_login') - ); - Minz_Session::_param('notification', $notif); - } - $this->view->_useLayout(false); - Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); - } elseif (Minz_Configuration::unsafeAutologinEnabled() && isset($_GET['u']) && isset($_GET['p'])) { - Minz_Session::_param('currentUser'); - Minz_Session::_param('mail'); - Minz_Session::_param('passwordHash'); - $username = ctype_alnum($_GET['u']) ? $_GET['u'] : ''; - $passwordPlain = $_GET['p']; - Minz_Request::_param('p'); //Discard plain-text password ASAP - $_GET['p'] = ''; - if (!function_exists('password_verify')) { - include_once(LIB_PATH . '/password_compat.php'); - } - try { - $conf = new FreshRSS_Configuration($username); - $s = $conf->passwordHash; - $ok = password_verify($passwordPlain, $s); - unset($passwordPlain); - if ($ok) { - Minz_Session::_param('currentUser', $username); - Minz_Session::_param('passwordHash', $s); - } else { - Minz_Log::warning('Unsafe password mismatch for user ' . $username); - } - } catch (Minz_Exception $me) { - Minz_Log::warning('Unsafe login failure: ' . $me->getMessage()); - } - Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); - } elseif (!Minz_Configuration::canLogIn()) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); - } invalidateHttpCache(); - } - public function formLogoutAction() { - $this->view->_useLayout(false); - invalidateHttpCache(); - Minz_Session::_param('currentUser'); - Minz_Session::_param('mail'); - Minz_Session::_param('passwordHash'); - self::deleteLongTermCookie(); - Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); - } - - public function resetAuthAction() { - Minz_View::prependTitle(_t('auth_reset') . ' · '); - Minz_View::appendScript(Minz_Url::display( - '/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js') - )); - - $this->view->no_form = false; - // Enable changement of auth only if Persona! - if (Minz_Configuration::authType() != 'persona') { - $this->view->message = array( - 'status' => 'bad', - 'title' => _t('damn'), - 'body' => _t('auth_not_persona') - ); - $this->view->no_form = true; - return; - } - - $conf = new FreshRSS_Configuration(Minz_Configuration::defaultUser()); - // Admin user must have set its master password. - if (!$conf->passwordHash) { - $this->view->message = array( - 'status' => 'bad', - 'title' => _t('damn'), - 'body' => _t('auth_no_password_set') - ); - $this->view->no_form = true; - return; - } - - invalidateHttpCache(); + $file_mtime = @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js'); + Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . $file_mtime)); if (Minz_Request::isPost()) { $nonce = Minz_Session::param('nonce'); $username = Minz_Request::param('username', ''); - $c = Minz_Request::param('challenge', ''); - if (!(ctype_alnum($username) && ctype_graph($c) && ctype_alnum($nonce))) { - Minz_Log::debug('Invalid credential parameters:' . - ' user=' . $username . - ' challenge=' . $c . - ' nonce=' . $nonce); + $challenge = Minz_Request::param('challenge', ''); + try { + $conf = new FreshRSS_Configuration($username); + } catch(Minz_Exception $e) { + // $username is not a valid user, nor the configuration file! + Minz_Log::warning('Login failure: ' . $e->getMessage()); Minz_Request::bad(_t('invalid_login'), - array('c' => 'index', 'a' => 'resetAuth')); - } - - if (!function_exists('password_verify')) { - include_once(LIB_PATH . '/password_compat.php'); + array('c' => 'index', 'a' => 'login')); } - $s = $conf->passwordHash; - $ok = password_verify($nonce . $s, $c); + $ok = FreshRSS_FormAuth::checkCredentials( + $username, $conf->passwordHash, $nonce, $challenge + ); if ($ok) { - Minz_Configuration::_authType('form'); - $ok = Minz_Configuration::writeFile(); - - if ($ok) { - Minz_Request::good(_t('auth_form_set')); + // Set session parameter to give access to the user. + Minz_Session::_param('currentUser', $username); + Minz_Session::_param('passwordHash', $conf->passwordHash); + FreshRSS_Auth::giveAccess(); + + // Set cookie parameter if nedded. + if (Minz_Request::param('keep_logged_in', false)) { + FreshRSS_FormAuth::makeCookie($username, $conf->passwordHash); } else { - Minz_Request::bad(_t('auth_form_not_set'), - array('c' => 'index', 'a' => 'resetAuth')); + FreshRSS_FormAuth::deleteCookie(); } - } else { - Minz_Log::debug('Password mismatch for user ' . $username . - ', nonce=' . $nonce . ', c=' . $c); + // All is good, go back to the index. + Minz_Request::good(_t('login'), + array('c' => 'index', 'a' => 'index')); + } else { + Minz_Log::warning('Password mismatch for' . + ' user=' . $username . + ', nonce=' . $nonce . + ', c=' . $challenge); Minz_Request::bad(_t('invalid_login'), - array('c' => 'index', 'a' => 'resetAuth')); + array('c' => 'index', 'a' => 'login')); } } } + + public function logoutAction() { + invalidateHttpCache(); + FreshRSS_Auth::removeAccess(); + Minz_Request::good(_t('disconnected'), + array('c' => 'index', 'a' => 'index')); + } } diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 99c57c809..0e3430fcc 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -118,7 +118,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { * underlying framework. */ public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) ); diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index 7cc8179a0..a89168eb3 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -10,7 +10,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { * underlying framework. */ public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index da5bddc65..9da1e8657 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -3,7 +3,7 @@ class FreshRSS_update_Controller extends Minz_ActionController { public function firstAction() { $current_user = Minz_Session::param('currentUser', ''); - if (!$this->view->loginOk && Minz_Configuration::isAdmin($current_user)) { + if (!FreshRSS_Auth::hasAccess() && Minz_Configuration::isAdmin($current_user)) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php index 7d0171bc7..c2b1d163f 100644 --- a/app/Controllers/usersController.php +++ b/app/Controllers/usersController.php @@ -5,7 +5,7 @@ class FreshRSS_users_Controller extends Minz_ActionController { const BCRYPT_COST = 9; //Will also have to be computed client side on mobile devices, so do not use a too high cost public function firstAction() { - if (!$this->view->loginOk) { + if (!FreshRSS_Auth::hasAccess()) { Minz_Error::error( 403, array('error' => array(_t('access_denied'))) diff --git a/app/FreshRSS.php b/app/FreshRSS.php index efd302ecc..35a37b887 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -4,130 +4,33 @@ class FreshRSS extends Minz_FrontController { if (!isset($_SESSION)) { Minz_Session::init('FreshRSS'); } - $loginOk = $this->accessControl(Minz_Session::param('currentUser', '')); + + FreshRSS_Auth::init(); + $this->loadConfiguration(); $this->loadParamsView(); if (Minz_Request::isPost() && !is_referer_from_same_domain()) { - $loginOk = false; //Basic protection against XSRF attacks + //Basic protection against XSRF attacks + FreshRSS_Auth::removeAccess(); Minz_Error::error( 403, array('error' => array(_t('access_denied') . ' [HTTP_REFERER=' . - htmlspecialchars(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']) . ']')) + htmlspecialchars(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']) . ']')) ); } - Minz_View::_param('loginOk', $loginOk); - $this->loadStylesAndScripts($loginOk); //TODO: Do not load that when not needed, e.g. some Ajax requests + $this->loadStylesAndScripts(); $this->loadNotifications(); $this->loadExtensions(); } - private static function getCredentialsFromLongTermCookie() { - $token = Minz_Session::getLongTermCookie('FreshRSS_login'); - if (!ctype_alnum($token)) { - return array(); - } - $tokenFile = DATA_PATH . '/tokens/' . $token . '.txt'; - $mtime = @filemtime($tokenFile); - if ($mtime + 2629744 < time()) { //1 month //TODO: Use a configuration instead - @unlink($tokenFile); - return array(); //Expired or token does not exist - } - $credentials = @file_get_contents($tokenFile); - return $credentials === false ? array() : explode("\t", $credentials, 2); - } - - private function accessControl($currentUser) { - if ($currentUser == '') { - switch (Minz_Configuration::authType()) { - case 'form': - $credentials = self::getCredentialsFromLongTermCookie(); - if (isset($credentials[1])) { - $currentUser = trim($credentials[0]); - Minz_Session::_param('passwordHash', trim($credentials[1])); - } - $loginOk = $currentUser != ''; - if (!$loginOk) { - $currentUser = Minz_Configuration::defaultUser(); - Minz_Session::_param('passwordHash'); - } - break; - case 'http_auth': - $currentUser = httpAuthUser(); - $loginOk = $currentUser != ''; - break; - case 'persona': - $loginOk = false; - $email = filter_var(Minz_Session::param('mail'), FILTER_VALIDATE_EMAIL); - if ($email != '') { //TODO: Remove redundancy with indexController - $personaFile = DATA_PATH . '/persona/' . $email . '.txt'; - if (($currentUser = @file_get_contents($personaFile)) !== false) { - $currentUser = trim($currentUser); - $loginOk = true; - } - } - if (!$loginOk) { - $currentUser = Minz_Configuration::defaultUser(); - } - break; - case 'none': - $currentUser = Minz_Configuration::defaultUser(); - $loginOk = true; - break; - default: - $currentUser = Minz_Configuration::defaultUser(); - $loginOk = false; - break; - } - } else { - $loginOk = true; - } - - if (!ctype_alnum($currentUser)) { - Minz_Session::_param('currentUser', ''); - die('Invalid username [' . $currentUser . ']!'); - } - + private function loadConfiguration() { + $current_user = Minz_Session::param('currentUser'); try { - $this->conf = new FreshRSS_Configuration($currentUser); + $this->conf = new FreshRSS_Configuration($current_user); Minz_View::_param('conf', $this->conf); - Minz_Session::_param('currentUser', $currentUser); - } catch (Minz_Exception $me) { - $loginOk = false; - try { - $this->conf = new FreshRSS_Configuration(Minz_Configuration::defaultUser()); - Minz_Session::_param('currentUser', Minz_Configuration::defaultUser()); - Minz_View::_param('conf', $this->conf); - $notif = array( - 'type' => 'bad', - 'content' => 'Invalid configuration for user [' . $currentUser . ']!', - ); - Minz_Session::_param('notification', $notif); - Minz_Log::warning($notif['content'] . ' ' . $me->getMessage()); - Minz_Session::_param('currentUser', ''); - } catch (Exception $e) { - die($e->getMessage()); - } - } - - if ($loginOk) { - switch (Minz_Configuration::authType()) { - case 'form': - $loginOk = Minz_Session::param('passwordHash') === $this->conf->passwordHash; - break; - case 'http_auth': - $loginOk = strcasecmp($currentUser, httpAuthUser()) === 0; - break; - case 'persona': - $loginOk = strcasecmp(Minz_Session::param('mail'), $this->conf->mail_login) === 0; - break; - case 'none': - $loginOk = true; - break; - default: - $loginOk = false; - break; - } + } catch(Minz_Exception $e) { + Minz_Log::error('Cannot load configuration file of user `' . $current_user . '`'); + die($e->getMessage()); } - return $loginOk; } private function loadParamsView() { @@ -140,7 +43,7 @@ class FreshRSS extends Minz_FrontController { } } - private function loadStylesAndScripts($loginOk) { + private function loadStylesAndScripts() { $theme = FreshRSS_Themes::load($this->conf->theme); if ($theme) { foreach($theme['files'] as $file) { @@ -158,16 +61,6 @@ class FreshRSS extends Minz_FrontController { } } - switch (Minz_Configuration::authType()) { - case 'form': - if (!$loginOk) { - Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js'))); - } - break; - case 'persona': - Minz_View::appendScript('https://login.persona.org/include.js'); - break; - } Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js'))); Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); diff --git a/app/Models/Auth.php b/app/Models/Auth.php new file mode 100644 index 000000000..c4a3abd98 --- /dev/null +++ b/app/Models/Auth.php @@ -0,0 +1,209 @@ +getMessage()); + } + + switch (Minz_Configuration::authType()) { + case 'form': + self::$login_ok = Minz_Session::param('passwordHash') === $conf->passwordHash; + break; + case 'http_auth': + self::$login_ok = strcasecmp($current_user, httpAuthUser()) === 0; + break; + case 'none': + self::$login_ok = true; + break; + default: + // TODO: extensions + self::$login_ok = false; + } + + Minz_Session::_param('loginOk', self::$login_ok); + } + + /** + * Returns if current user is connected. + * + * @return boolean true if user is connected, false else. + */ + public static function hasAccess() { + return self::$login_ok; + } + + /** + * Removes all accesses for the current user. + */ + public static function removeAccess() { + Minz_Session::_param('loginOk'); + self::$login_ok = false; + Minz_Session::_param('currentUser', Minz_Configuration::defaultUser()); + + switch (Minz_Configuration::authType()) { + case 'form': + Minz_Session::_param('passwordHash'); + FreshRSS_FormAuth::deleteCookie(); + break; + case 'http_auth': + case 'none': + // Nothing to do... + break; + default: + // TODO: extensions + } + } +} + + +class FreshRSS_FormAuth { + public static function checkCredentials($username, $hash, $nonce, $challenge) { + if (!ctype_alnum($username) || + !ctype_graph($challenge) || + !ctype_alnum($nonce)) { + Minz_Log::debug('Invalid credential parameters:' . + ' user=' . $username . + ' challenge=' . $challenge . + ' nonce=' . $nonce); + return false; + } + + if (!function_exists('password_verify')) { + include_once(LIB_PATH . '/password_compat.php'); + } + + return password_verify($nonce . $hash, $challenge); + } + + public static function getCredentialsFromCookie() { + $token = Minz_Session::getLongTermCookie('FreshRSS_login'); + if (!ctype_alnum($token)) { + return array(); + } + + $token_file = DATA_PATH . '/tokens/' . $token . '.txt'; + $mtime = @filemtime($token_file); + if ($mtime + 2629744 < time()) { + // Token has expired (> 1 month) or does not exist. + // TODO: 1 month -> use a configuration instead + @unlink($token_file); + return array(); + } + + $credentials = @file_get_contents($token_file); + return $credentials === false ? array() : explode("\t", $credentials, 2); + } + + public static function makeCookie($username, $password_hash) { + do { + $token = sha1(Minz_Configuration::salt() . $username . uniqid(mt_rand(), true)); + $token_file = DATA_PATH . '/tokens/' . $token . '.txt'; + } while (file_exists($token_file)); + + if (@file_put_contents($token_file, $username . "\t" . $password_hash) === false) { + return false; + } + + $expire = time() + 2629744; //1 month //TODO: Use a configuration instead + Minz_Session::setLongTermCookie('FreshRSS_login', $token, $expire); + return $token; + } + + public static function deleteCookie() { + $token = Minz_Session::getLongTermCookie('FreshRSS_login'); + Minz_Session::deleteLongTermCookie('FreshRSS_login'); + if (ctype_alnum($token)) { + @unlink(DATA_PATH . '/tokens/' . $token . '.txt'); + } + + if (rand(0, 10) === 1) { + self::purgeTokens(); + } + } + + public static function purgeTokens() { + $oldest = time() - 2629744; // 1 month // TODO: Use a configuration instead + foreach (new DirectoryIterator(DATA_PATH . '/tokens/') as $file_info) { + // $extension = $file_info->getExtension(); doesn't work in PHP < 5.3.7 + $extension = pathinfo($file_info->getFilename(), PATHINFO_EXTENSION); + if ($extension === 'txt' && $file_info->getMTime() < $oldest) { + @unlink($file_info->getPathname()); + } + } + } +} diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index a8ae2f424..a66be2ed9 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -2,7 +2,7 @@
          - loginOk) { ?> +
        • @@ -83,11 +83,11 @@
        - +

        diff --git a/app/views/users/index.phtml b/app/views/users/index.phtml index 95659f727..f1cdf01a3 100644 --- a/app/views/users/index.phtml +++ b/app/views/users/index.phtml @@ -11,7 +11,7 @@
        @@ -44,7 +44,7 @@ conf->mail_login; ?>
        - placeholder="alice@example.net" /> + placeholder="alice@example.net" />
        @@ -56,7 +56,7 @@
        - + diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 4e9da58b4..554bc8c96 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -100,9 +100,6 @@ class Minz_Configuration { public static function defaultUser () { return self::$default_user; } - public static function isAdmin($currentUser) { - return $currentUser === self::$default_user; - } public static function allowAnonymous() { return self::$allow_anonymous; } -- cgit v1.2.3 From 1252b3dd867e59917cf303f0c39c7da938b8ce32 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 7 Oct 2014 16:37:10 +0200 Subject: Authentication system moved + Persona comes back! AuthController is dedicated to auhentication. Persona is back, greater than ever! See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/authController.php | 182 ++++++++++++++++++++++++++++++++ app/Controllers/indexController.php | 90 +--------------- app/FreshRSS.php | 8 ++ app/Models/Auth.php | 21 +++- app/layout/header.phtml | 23 ++-- app/views/auth/formLogin.phtml | 28 +++++ app/views/auth/logout.phtml | 0 app/views/auth/personaLogin.phtml | 24 +++++ app/views/helpers/javascript_vars.phtml | 13 ++- app/views/index/formLogin.phtml | 46 -------- p/scripts/main.js | 65 ------------ p/scripts/persona.js | 76 +++++++++++++ 12 files changed, 356 insertions(+), 220 deletions(-) create mode 100644 app/Controllers/authController.php create mode 100644 app/views/auth/formLogin.phtml create mode 100644 app/views/auth/logout.phtml create mode 100644 app/views/auth/personaLogin.phtml delete mode 100644 app/views/index/formLogin.phtml create mode 100644 p/scripts/persona.js (limited to 'app/Controllers') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php new file mode 100644 index 000000000..2b67e34b8 --- /dev/null +++ b/app/Controllers/authController.php @@ -0,0 +1,182 @@ + 'index', 'a' => 'index'), true); + } + + $auth_type = Minz_Configuration::authType(); + switch ($auth_type) { + case 'form': + Minz_Request::forward(array('c' => 'auth', 'a' => 'formLogin')); + break; + case 'persona': + Minz_Request::forward(array('c' => 'auth', 'a' => 'personaLogin')); + break; + case 'http_auth': + case 'none': + // It should not happened! + Minz_Error::error(404); + default: + // TODO load plugin instead + Minz_Error::error(404); + } + } + + /** + * This action handles form login page. + * + * If this action is reached through a POST request, username and password + * are compared to login the current user. + * + * Parameters are: + * - nonce (default: false) + * - username (default: '') + * - challenge (default: '') + * - keep_logged_in (default: false) + */ + public function formLoginAction() { + invalidateHttpCache(); + + $file_mtime = @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js'); + Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . $file_mtime)); + + if (Minz_Request::isPost()) { + $nonce = Minz_Session::param('nonce'); + $username = Minz_Request::param('username', ''); + $challenge = Minz_Request::param('challenge', ''); + try { + $conf = new FreshRSS_Configuration($username); + } catch(Minz_Exception $e) { + // $username is not a valid user, nor the configuration file! + Minz_Log::warning('Login failure: ' . $e->getMessage()); + Minz_Request::bad(_t('invalid_login'), + array('c' => 'auth', 'a' => 'login')); + } + + $ok = FreshRSS_FormAuth::checkCredentials( + $username, $conf->passwordHash, $nonce, $challenge + ); + if ($ok) { + // Set session parameter to give access to the user. + Minz_Session::_param('currentUser', $username); + Minz_Session::_param('passwordHash', $conf->passwordHash); + FreshRSS_Auth::giveAccess(); + + // Set cookie parameter if nedded. + if (Minz_Request::param('keep_logged_in')) { + FreshRSS_FormAuth::makeCookie($username, $conf->passwordHash); + } else { + FreshRSS_FormAuth::deleteCookie(); + } + + // All is good, go back to the index. + Minz_Request::good(_t('login'), + array('c' => 'index', 'a' => 'index')); + } else { + Minz_Log::warning('Password mismatch for' . + ' user=' . $username . + ', nonce=' . $nonce . + ', c=' . $challenge); + Minz_Request::bad(_t('invalid_login'), + array('c' => 'auth', 'a' => 'login')); + } + } + } + + /** + * This action handles Persona login page. + * + * If this action is reached through a POST request, assertion from Persona + * is verificated and user connected if all is ok. + * + * Parameter is: + * - assertion (default: false) + * + * @todo: Persona system should be moved to a plugin + */ + public function personaLoginAction() { + $this->view->res = false; + + if (Minz_Request::isPost()) { + $this->view->_useLayout(false); + + $assert = Minz_Request::param('assertion'); + $url = 'https://verifier.login.persona.org/verify'; + $params = 'assertion=' . $assert . '&audience=' . + 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); + + $res = json_decode($result, true); + + $login_ok = false; + $reason = ''; + if ($res['status'] === 'okay') { + $email = filter_var($res['email'], FILTER_VALIDATE_EMAIL); + if ($email != '') { + $persona_file = DATA_PATH . '/persona/' . $email . '.txt'; + if (($current_user = @file_get_contents($persona_file)) !== false) { + $current_user = trim($current_user); + try { + $conf = new FreshRSS_Configuration($current_user); + $login_ok = strcasecmp($email, $conf->mail_login) === 0; + } catch (Minz_Exception $e) { + //Permission denied or conf file does not exist + $reason = 'Invalid configuration for user ' . + '[' . $current_user . '] ' . $e->getMessage(); + } + } + } else { + $reason = 'Invalid email format [' . $res['email'] . ']'; + } + } else { + $reason = $res['reason']; + } + + if ($login_ok) { + Minz_Session::_param('currentUser', $current_user); + Minz_Session::_param('mail', $email); + FreshRSS_Auth::giveAccess(); + invalidateHttpCache(); + } else { + Minz_Log::error($reason); + + $res = array(); + $res['status'] = 'failure'; + $res['reason'] = _t('invalid_login'); + } + + header('Content-Type: application/json; charset=UTF-8'); + $this->view->res = $res; + } + } + + /** + * This action removes all accesses of the current user. + */ + public function logoutAction() { + invalidateHttpCache(); + FreshRSS_Auth::removeAccess(); + Minz_Request::good(_t('disconnected'), + array('c' => 'index', 'a' => 'index')); + } +} diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 3006480f9..5b490e672 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -20,7 +20,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } elseif ($output !== 'rss') { // "hard" redirection is not required, just ask dispatcher to // forward to the login form without 302 redirection - Minz_Request::forward(array('c' => 'index', 'a' => 'login')); + Minz_Request::forward(array('c' => 'auth', 'a' => 'login')); return; } } @@ -228,92 +228,4 @@ class FreshRSS_index_Controller extends Minz_ActionController { $this->view->logsPaginator->_nbItemsPerPage(50); $this->view->logsPaginator->_currentPage($page); } - - /** - * This action handles the login page. - */ - public function loginAction() { - if (FreshRSS_Auth::hasAccess()) { - Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); - } - - invalidateHttpCache(); - - $auth_type = Minz_Configuration::authType(); - switch ($auth_type) { - case 'form': - Minz_Request::forward(array('c' => 'index', 'a' => 'formLogin')); - break; - case 'http_auth': - case 'none': - // It should not happened! - Minz_Error::error(404); - default: - // TODO load plugin instead - Minz_Error::error(404); - } - } - - /** - * - */ - public function formLoginAction() { - if (FreshRSS_Auth::hasAccess()) { - Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true); - } - - invalidateHttpCache(); - - $file_mtime = @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js'); - Minz_View::appendScript(Minz_Url::display('/scripts/bcrypt.min.js?' . $file_mtime)); - - if (Minz_Request::isPost()) { - $nonce = Minz_Session::param('nonce'); - $username = Minz_Request::param('username', ''); - $challenge = Minz_Request::param('challenge', ''); - try { - $conf = new FreshRSS_Configuration($username); - } catch(Minz_Exception $e) { - // $username is not a valid user, nor the configuration file! - Minz_Log::warning('Login failure: ' . $e->getMessage()); - Minz_Request::bad(_t('invalid_login'), - array('c' => 'index', 'a' => 'login')); - } - - $ok = FreshRSS_FormAuth::checkCredentials( - $username, $conf->passwordHash, $nonce, $challenge - ); - if ($ok) { - // Set session parameter to give access to the user. - Minz_Session::_param('currentUser', $username); - Minz_Session::_param('passwordHash', $conf->passwordHash); - FreshRSS_Auth::giveAccess(); - - // Set cookie parameter if nedded. - if (Minz_Request::param('keep_logged_in', false)) { - FreshRSS_FormAuth::makeCookie($username, $conf->passwordHash); - } else { - FreshRSS_FormAuth::deleteCookie(); - } - - // All is good, go back to the index. - Minz_Request::good(_t('login'), - array('c' => 'index', 'a' => 'index')); - } else { - Minz_Log::warning('Password mismatch for' . - ' user=' . $username . - ', nonce=' . $nonce . - ', c=' . $challenge); - Minz_Request::bad(_t('invalid_login'), - array('c' => 'index', 'a' => 'login')); - } - } - } - - public function logoutAction() { - invalidateHttpCache(); - FreshRSS_Auth::removeAccess(); - Minz_Request::good(_t('disconnected'), - array('c' => 'index', 'a' => 'index')); - } } diff --git a/app/FreshRSS.php b/app/FreshRSS.php index 35a37b887..6b7a813bf 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -64,6 +64,14 @@ class FreshRSS extends Minz_FrontController { Minz_View::appendScript(Minz_Url::display('/scripts/jquery.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/jquery.min.js'))); Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js'))); Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js'))); + + if (Minz_Configuration::authType() === 'persona') { + // TODO move it in a plugin + // Needed for login AND logout with Persona. + Minz_View::appendScript('https://login.persona.org/include.js'); + $file_mtime = @filemtime(PUBLIC_PATH . '/scripts/persona.js'); + Minz_View::appendScript(Minz_Url::display('/scripts/persona.js?' . $file_mtime)); + } } private function loadNotifications() { diff --git a/app/Models/Auth.php b/app/Models/Auth.php index 992b444a5..cc23d7974 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -20,7 +20,7 @@ class FreshRSS_Auth { Minz_Session::_param('currentUser', $current_user); } - $access_ok = self::accessControl($current_user); + $access_ok = self::accessControl(); if ($access_ok) { self::giveAccess(); @@ -36,10 +36,9 @@ class FreshRSS_Auth { * Required session parameters are also set in this method (such as * currentUser). * - * @param string $username username of the user to check access. * @return boolean true if user can be connected, false else. */ - public static function accessControl($username) { + public static function accessControl() { if (self::$login_ok) { return true; } @@ -61,6 +60,16 @@ class FreshRSS_Auth { Minz_Session::_param('currentUser', $current_user); } return $login_ok; + case 'persona': + $email = filter_var(Minz_Session::param('mail'), FILTER_VALIDATE_EMAIL); + $persona_file = DATA_PATH . '/persona/' . $email . '.txt'; + if (($current_user = @file_get_contents($persona_file)) !== false) { + $current_user = trim($current_user); + Minz_Session::_param('currentUser', $current_user); + Minz_Session::_param('mail', $email); + return true; + } + return false; case 'none': return true; default: @@ -87,6 +96,9 @@ class FreshRSS_Auth { case 'http_auth': self::$login_ok = strcasecmp($current_user, httpAuthUser()) === 0; break; + case 'persona': + self::$login_ok = strcasecmp(Minz_Session::param('mail'), $conf->mail_login) === 0; + break; case 'none': self::$login_ok = true; break; @@ -131,6 +143,9 @@ class FreshRSS_Auth { Minz_Session::_param('passwordHash'); FreshRSS_FormAuth::deleteCookie(); break; + case 'persona': + Minz_Session::_param('mail'); + break; case 'http_auth': case 'none': // Nothing to do... diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 12c86d61d..deb21edc9 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -2,9 +2,9 @@ if (Minz_Configuration::canLogIn()) { ?>
      • -
      • -
        + +
        + +
        +
        diff --git a/app/views/auth/formLogin.phtml b/app/views/auth/formLogin.phtml new file mode 100644 index 000000000..0194a11a5 --- /dev/null +++ b/app/views/auth/formLogin.phtml @@ -0,0 +1,28 @@ +
        +

        + +
        +
        + + +
        +
        + + +
        + +
        +
        + +
        +
        +
        + +
        + + +

        +
        diff --git a/app/views/auth/logout.phtml b/app/views/auth/logout.phtml new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/auth/personaLogin.phtml b/app/views/auth/personaLogin.phtml new file mode 100644 index 000000000..d62fe5818 --- /dev/null +++ b/app/views/auth/personaLogin.phtml @@ -0,0 +1,24 @@ +res === false) { ?> +
        +

        + +

        + + +

        + + + + + +

        + +

        +
        +res); +} +?> diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 8f615ed87..3bbcc3848 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -8,6 +8,15 @@ $hide_posts = ($this->conf->display_posts || Minz_Request::param('output') === 'reader'); $s = $this->conf->shortcuts; +$url_login = Minz_Url::display(array( + 'c' => 'auth', + 'a' => 'login' +), 'php'); +$url_logout = Minz_Url::display(array( + 'c' => 'auth', + 'a' => 'logout' +), 'php'); + echo 'var context={', 'hide_posts:', $hide_posts ? 'false' : 'true', ',', 'display_order:"', Minz_Request::param('order', $this->conf->sort_order), '",', @@ -43,8 +52,8 @@ echo 'shortcuts={', echo 'url={', 'index:"', _url('index', 'index'), '",', - 'login:"', _url('index', 'login'), '",', - 'logout:"', _url('index', 'logout'), '",', + 'login:"', $url_login, '",', + 'logout:"', $url_logout, '",', 'help:"', FRESHRSS_WIKI, '"', "},\n"; diff --git a/app/views/index/formLogin.phtml b/app/views/index/formLogin.phtml deleted file mode 100644 index b05cdced4..000000000 --- a/app/views/index/formLogin.phtml +++ /dev/null @@ -1,46 +0,0 @@ -
        -

        -
        - - -
        -
        - - -
        - -
        -
        - -
        -
        -
        - -
        -

        -

        - - - - - -

        - -

        -
        diff --git a/p/scripts/main.js b/p/scripts/main.js index b01a3a34d..77e1e3f77 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1034,67 +1034,7 @@ function init_crypto_form() { } // -// -function init_persona() { - if (!(navigator.id)) { - if (window.console) { - console.log('FreshRSS waiting for Persona…'); - } - window.setTimeout(init_persona, 100); - return; - } - $('a.signin').click(function() { - navigator.id.request(); - return false; - }); - - $('a.signout').click(function() { - navigator.id.logout(); - return false; - }); - navigator.id.watch({ - loggedInUser: context['current_user_mail'], - - onlogin: function(assertion) { - // A user has logged in! Here you need to: - // 1. Send the assertion to your backend for verification and to create a session. - // 2. Update your UI. - $.ajax ({ - type: 'POST', - url: url['login'], - data: {assertion: assertion}, - success: function(res, status, xhr) { - /*if (res.status === 'failure') { - alert (res_obj.reason); - } else*/ if (res.status === 'okay') { - location.href = url['index']; - } - }, - error: function(res, status, xhr) { - alert("Login failure: " + res); - } - }); - }, - onlogout: function() { - // A user has logged out! Here you need to: - // Tear down the user's session by redirecting the user or making a call to your backend. - // Also, make sure loggedInUser will get set to null on the next page load. - // (That's a literal JavaScript null. Not false, 0, or undefined. null.) - $.ajax ({ - type: 'POST', - url: url['logout'], - success: function(res, status, xhr) { - location.href = url['index']; - }, - error: function(res, status, xhr) { - //alert("logout failure" + res); - } - }); - } - }); -} -// function init_confirm_action() { $('body').on('click', '.confirm', function () { @@ -1274,11 +1214,6 @@ function init_all() { return; } init_notifications(); - switch (context['auth_type']) { - case 'persona': - init_persona(); - break; - } init_confirm_action(); $stream = $('#stream'); if ($stream.length > 0) { diff --git a/p/scripts/persona.js b/p/scripts/persona.js new file mode 100644 index 000000000..36aeeaf56 --- /dev/null +++ b/p/scripts/persona.js @@ -0,0 +1,76 @@ +"use strict"; + +function init_persona() { + if (!(navigator.id && window.$)) { + if (window.console) { + console.log('FreshRSS (Persona) waiting for JS…'); + } + window.setTimeout(init_persona, 100); + return; + } + + $('a.signin').click(function() { + navigator.id.request(); + return false; + }); + + $('a.signout').click(function() { + navigator.id.logout(); + return false; + }); + + navigator.id.watch({ + loggedInUser: context['current_user_mail'], + + onlogin: function(assertion) { + // A user has logged in! Here you need to: + // 1. Send the assertion to your backend for verification and to create a session. + // 2. Update your UI. + $.ajax ({ + type: 'POST', + url: url['login'], + data: {assertion: assertion}, + success: function(res, status, xhr) { + if (res.status === 'failure') { + openNotification(res.reason, 'bad'); + } else if (res.status === 'okay') { + location.href = url['index']; + } + }, + error: function(res, status, xhr) { + // alert(res); + } + }); + }, + onlogout: function() { + // A user has logged out! Here you need to: + // Tear down the user's session by redirecting the user or making a call to your backend. + // Also, make sure loggedInUser will get set to null on the next page load. + // (That's a literal JavaScript null. Not false, 0, or undefined. null.) + $.ajax ({ + type: 'POST', + url: url['logout'], + success: function(res, status, xhr) { + location.href = url['index']; + }, + error: function(res, status, xhr) { + // alert(res); + } + }); + } + }); +} + +if (document.readyState && document.readyState !== 'loading') { + if (window.console) { + console.log('FreshRSS (Persona) immediate init…'); + } + init_persona(); +} else if (document.addEventListener) { + document.addEventListener('DOMContentLoaded', function () { + if (window.console) { + console.log('FreshRSS (Persona) waiting for DOMContentLoaded…'); + } + init_persona(); + }, false); +} -- cgit v1.2.3 From dbf57266b297c3f831602ec4f451c27a5ad71e6b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 7 Oct 2014 16:58:11 +0200 Subject: Reset auth system comes back! It has moved to authController. --- app/Controllers/authController.php | 68 ++++++++++++++++++++++++++++++++++++++ app/views/auth/personaLogin.phtml | 2 +- app/views/auth/reset.phtml | 33 ++++++++++++++++++ 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 app/views/auth/reset.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index 2b67e34b8..e30fa4b72 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -179,4 +179,72 @@ class FreshRSS_auth_Controller extends Minz_ActionController { Minz_Request::good(_t('disconnected'), array('c' => 'index', 'a' => 'index')); } + + /** + * This action resets the authentication system. + * + * After reseting, form auth is set by default. + */ + public function resetAction() { + Minz_View::prependTitle(_t('auth_reset') . ' · '); + + Minz_View::appendScript(Minz_Url::display( + '/scripts/bcrypt.min.js?' . @filemtime(PUBLIC_PATH . '/scripts/bcrypt.min.js') + )); + + $this->view->no_form = false; + // Enable changement of auth only if Persona! + if (Minz_Configuration::authType() != 'persona') { + $this->view->message = array( + 'status' => 'bad', + 'title' => _t('damn'), + 'body' => _t('auth_not_persona') + ); + $this->view->no_form = true; + return; + } + + $conf = new FreshRSS_Configuration(Minz_Configuration::defaultUser()); + // Admin user must have set its master password. + if (!$conf->passwordHash) { + $this->view->message = array( + 'status' => 'bad', + 'title' => _t('damn'), + 'body' => _t('auth_no_password_set') + ); + $this->view->no_form = true; + return; + } + + invalidateHttpCache(); + + if (Minz_Request::isPost()) { + $nonce = Minz_Session::param('nonce'); + $username = Minz_Request::param('username', ''); + $challenge = Minz_Request::param('challenge', ''); + + $ok = FreshRSS_FormAuth::checkCredentials( + $username, $conf->passwordHash, $nonce, $challenge + ); + + if ($ok) { + Minz_Configuration::_authType('form'); + $ok = Minz_Configuration::writeFile(); + + if ($ok) { + Minz_Request::good(_t('auth_form_set')); + } else { + Minz_Request::bad(_t('auth_form_not_set'), + array('c' => 'auth', 'a' => 'reset')); + } + } else { + Minz_Log::warning('Password mismatch for' . + ' user=' . $username . + ', nonce=' . $nonce . + ', c=' . $challenge); + Minz_Request::bad(_t('invalid_login'), + array('c' => 'auth', 'a' => 'reset')); + } + } + } } diff --git a/app/views/auth/personaLogin.phtml b/app/views/auth/personaLogin.phtml index d62fe5818..dd3e22b52 100644 --- a/app/views/auth/personaLogin.phtml +++ b/app/views/auth/personaLogin.phtml @@ -11,7 +11,7 @@ - +

        diff --git a/app/views/auth/reset.phtml b/app/views/auth/reset.phtml new file mode 100644 index 000000000..e501555c4 --- /dev/null +++ b/app/views/auth/reset.phtml @@ -0,0 +1,33 @@ +
        +

        + + message)) { ?> +

        + message['title']; ?>
        + message['body']; ?> +

        + + + no_form) { ?> +
        +

        +
        + +

        + +
        + + +
        +
        + + +
        + +
        +
        + +
        + + +
        -- cgit v1.2.3 From c5fe3bd6593d0a07c087d1e60ae2e4b8ab5f9fa9 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 16 Oct 2014 15:25:46 +0200 Subject: Reorganize user pages Three pages: - User profil - User management - Authentication --- app/Controllers/authController.php | 60 ++++++++++ app/Controllers/userController.php | 198 +++++++++++++++++++++++++++++++++ app/Controllers/usersController.php | 210 ----------------------------------- app/layout/aside_configure.phtml | 12 +- app/layout/header.phtml | 4 +- app/views/auth/index.phtml | 84 ++++++++++++++ app/views/user/manage.phtml | 76 +++++++++++++ app/views/user/profil.phtml | 59 ++++++++++ app/views/users/index.phtml | 211 ------------------------------------ 9 files changed, 490 insertions(+), 424 deletions(-) create mode 100644 app/Controllers/userController.php delete mode 100644 app/Controllers/usersController.php create mode 100644 app/views/auth/index.phtml create mode 100644 app/views/user/manage.phtml create mode 100644 app/views/user/profil.phtml delete mode 100644 app/views/users/index.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index e30fa4b72..751ce1f3f 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -4,6 +4,66 @@ * This controller handles action about authentication. */ class FreshRSS_auth_Controller extends Minz_ActionController { + /** + * This action handles authentication management page. + * + * Parameters are: + * - token (default: current token) + * - anon_access (default: false) + * - anon_refresh (default: false) + * - auth_type (default: none) + * - unsafe_autologin (default: false) + * - api_enabled (default: false) + * + * @todo move unsafe_autologin in an extension. + */ + public function indexAction() { + if (!FreshRSS_Auth::hasAccess('admin')) { + Minz_Error::error(403, + array('error' => array(_t('access_denied')))); + } + + if (Minz_Request::isPost()) { + $ok = true; + + $current_token = $this->view->conf->token; + $token = Minz_Request::param('token', $current_token); + $this->view->conf->_token($token); + $ok &= $this->view->conf->save(); + + $anon = Minz_Request::param('anon_access', false); + $anon = ((bool)$anon) && ($anon !== 'no'); + $anon_refresh = Minz_Request::param('anon_refresh', false); + $anon_refresh = ((bool)$anon_refresh) && ($anon_refresh !== 'no'); + $auth_type = Minz_Request::param('auth_type', 'none'); + $unsafe_autologin = Minz_Request::param('unsafe_autologin', false); + $api_enabled = Minz_Request::param('api_enabled', false); + if ($anon != Minz_Configuration::allowAnonymous() || + $auth_type != Minz_Configuration::authType() || + $anon_refresh != Minz_Configuration::allowAnonymousRefresh() || + $unsafe_autologin != Minz_Configuration::unsafeAutologinEnabled() || + $api_enabled != Minz_Configuration::apiEnabled()) { + + Minz_Configuration::_authType($auth_type); + Minz_Configuration::_allowAnonymous($anon); + Minz_Configuration::_allowAnonymousRefresh($anon_refresh); + Minz_Configuration::_enableAutologin($unsafe_autologin); + Minz_Configuration::_enableApi($api_enabled); + $ok &= Minz_Configuration::writeFile(); + } + + invalidateHttpCache(); + + if ($ok) { + Minz_Request::good('configuration_updated', + array('c' => 'auth', 'a' => 'index')); + } else { + Minz_Request::bad('error_occurred', + array('c' => 'auth', 'a' => 'index')); + } + } + } + /** * This action handles the login page. * diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php new file mode 100644 index 000000000..c516246c9 --- /dev/null +++ b/app/Controllers/userController.php @@ -0,0 +1,198 @@ + array(_t('access_denied'))) + ); + } + } + + /** + * This action displays the user profil page. + */ + public function profilAction() { + Minz_View::prependTitle(_t('users.profil') . ' · '); + + if (Minz_Request::isPost()) { + $ok = true; + + $passwordPlain = Minz_Request::param('passwordPlain', '', true); + if ($passwordPlain != '') { + Minz_Request::_param('passwordPlain'); //Discard plain-text password ASAP + $_POST['passwordPlain'] = ''; + if (!function_exists('password_hash')) { + include_once(LIB_PATH . '/password_compat.php'); + } + $passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST)); + $passwordPlain = ''; + $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js + $ok &= ($passwordHash != ''); + $this->view->conf->_passwordHash($passwordHash); + } + Minz_Session::_param('passwordHash', $this->view->conf->passwordHash); + + $passwordPlain = Minz_Request::param('apiPasswordPlain', '', true); + if ($passwordPlain != '') { + if (!function_exists('password_hash')) { + include_once(LIB_PATH . '/password_compat.php'); + } + $passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST)); + $passwordPlain = ''; + $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js + $ok &= ($passwordHash != ''); + $this->view->conf->_apiPasswordHash($passwordHash); + } + + // TODO: why do we need of hasAccess here? + if (FreshRSS_Auth::hasAccess('admin')) { + $this->view->conf->_mail_login(Minz_Request::param('mail_login', '', true)); + } + $email = $this->view->conf->mail_login; + Minz_Session::_param('mail', $email); + + $ok &= $this->view->conf->save(); + + if ($email != '') { + $personaFile = DATA_PATH . '/persona/' . $email . '.txt'; + @unlink($personaFile); + $ok &= (file_put_contents($personaFile, Minz_Session::param('currentUser', '_')) !== false); + } + + if ($ok) { + Minz_Request::good('users.profil.updated', + array('c' => 'user', 'a' => 'profil')); + } else { + Minz_Request::bad('error_occurred', + array('c' => 'user', 'a' => 'profil')); + } + } + } + + /** + * This action displays the user management page. + */ + public function manageAction() { + Minz_View::prependTitle(_t('users.manage') . ' · '); + } + + public function createAction() { + if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) { + $db = Minz_Configuration::dataBase(); + require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); + + $new_user_language = Minz_Request::param('new_user_language', $this->view->conf->language); + if (!in_array($new_user_language, $this->view->conf->availableLanguages())) { + $new_user_language = $this->view->conf->language; + } + + $new_user_name = Minz_Request::param('new_user_name'); + $ok = ($new_user_name != '') && ctype_alnum($new_user_name); + + if ($ok) { + $ok &= (strcasecmp($new_user_name, Minz_Configuration::defaultUser()) !== 0); //It is forbidden to alter the default user + + $ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers())); //Not an existing user, case-insensitive + + $configPath = DATA_PATH . '/' . $new_user_name . '_user.php'; + $ok &= !file_exists($configPath); + } + if ($ok) { + + $passwordPlain = Minz_Request::param('new_user_passwordPlain', '', true); + $passwordHash = ''; + if ($passwordPlain != '') { + Minz_Request::_param('new_user_passwordPlain'); //Discard plain-text password ASAP + $_POST['new_user_passwordPlain'] = ''; + if (!function_exists('password_hash')) { + include_once(LIB_PATH . '/password_compat.php'); + } + $passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST)); + $passwordPlain = ''; + $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js + $ok &= ($passwordHash != ''); + } + if (empty($passwordHash)) { + $passwordHash = ''; + } + + $new_user_email = filter_var($_POST['new_user_email'], FILTER_VALIDATE_EMAIL); + if (empty($new_user_email)) { + $new_user_email = ''; + } else { + $personaFile = DATA_PATH . '/persona/' . $new_user_email . '.txt'; + @unlink($personaFile); + $ok &= (file_put_contents($personaFile, $new_user_name) !== false); + } + } + if ($ok) { + $config_array = array( + 'language' => $new_user_language, + 'passwordHash' => $passwordHash, + 'mail_login' => $new_user_email, + ); + $ok &= (file_put_contents($configPath, "createUser($new_user_name); + } + invalidateHttpCache(); + + $notif = array( + 'type' => $ok ? 'good' : 'bad', + 'content' => _t($ok ? 'user_created' : 'error_occurred', $new_user_name) + ); + Minz_Session::_param('notification', $notif); + } + + Minz_Request::forward(array('c' => 'user', 'a' => 'manage'), true); + } + + public function deleteAction() { + if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) { + $db = Minz_Configuration::dataBase(); + require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); + + $username = Minz_Request::param('username'); + $ok = ctype_alnum($username); + + if ($ok) { + $ok &= (strcasecmp($username, Minz_Configuration::defaultUser()) !== 0); //It is forbidden to delete the default user + } + if ($ok) { + $configPath = DATA_PATH . '/' . $username . '_user.php'; + $ok &= file_exists($configPath); + } + if ($ok) { + $userDAO = new FreshRSS_UserDAO(); + $ok &= $userDAO->deleteUser($username); + $ok &= unlink($configPath); + //TODO: delete Persona file + } + invalidateHttpCache(); + + $notif = array( + 'type' => $ok ? 'good' : 'bad', + 'content' => _t($ok ? 'user_deleted' : 'error_occurred', $username) + ); + Minz_Session::_param('notification', $notif); + } + + Minz_Request::forward(array('c' => 'user', 'a' => 'manage'), true); + } +} diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php deleted file mode 100644 index 11862ce27..000000000 --- a/app/Controllers/usersController.php +++ /dev/null @@ -1,210 +0,0 @@ - array(_t('access_denied'))) - ); - } - } - - /** - * This action display the user configuration page - */ - public function indexAction() { - Minz_View::prependTitle(_t('users') . ' · '); - } - - public function authAction() { - if (Minz_Request::isPost()) { - $ok = true; - - $passwordPlain = Minz_Request::param('passwordPlain', '', true); - if ($passwordPlain != '') { - Minz_Request::_param('passwordPlain'); //Discard plain-text password ASAP - $_POST['passwordPlain'] = ''; - if (!function_exists('password_hash')) { - include_once(LIB_PATH . '/password_compat.php'); - } - $passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST)); - $passwordPlain = ''; - $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js - $ok &= ($passwordHash != ''); - $this->view->conf->_passwordHash($passwordHash); - } - Minz_Session::_param('passwordHash', $this->view->conf->passwordHash); - - $passwordPlain = Minz_Request::param('apiPasswordPlain', '', true); - if ($passwordPlain != '') { - if (!function_exists('password_hash')) { - include_once(LIB_PATH . '/password_compat.php'); - } - $passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST)); - $passwordPlain = ''; - $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js - $ok &= ($passwordHash != ''); - $this->view->conf->_apiPasswordHash($passwordHash); - } - - if (FreshRSS_Auth::hasAccess('admin')) { - $this->view->conf->_mail_login(Minz_Request::param('mail_login', '', true)); - } - $email = $this->view->conf->mail_login; - Minz_Session::_param('mail', $email); - - $ok &= $this->view->conf->save(); - - if ($email != '') { - $personaFile = DATA_PATH . '/persona/' . $email . '.txt'; - @unlink($personaFile); - $ok &= (file_put_contents($personaFile, Minz_Session::param('currentUser', '_')) !== false); - } - - if (FreshRSS_Auth::hasAccess('admin')) { - $current_token = $this->view->conf->token; - $token = Minz_Request::param('token', $current_token); - $this->view->conf->_token($token); - $ok &= $this->view->conf->save(); - - $anon = Minz_Request::param('anon_access', false); - $anon = ((bool)$anon) && ($anon !== 'no'); - $anon_refresh = Minz_Request::param('anon_refresh', false); - $anon_refresh = ((bool)$anon_refresh) && ($anon_refresh !== 'no'); - $auth_type = Minz_Request::param('auth_type', 'none'); - $unsafe_autologin = Minz_Request::param('unsafe_autologin', false); - $api_enabled = Minz_Request::param('api_enabled', false); - if ($anon != Minz_Configuration::allowAnonymous() || - $auth_type != Minz_Configuration::authType() || - $anon_refresh != Minz_Configuration::allowAnonymousRefresh() || - $unsafe_autologin != Minz_Configuration::unsafeAutologinEnabled() || - $api_enabled != Minz_Configuration::apiEnabled()) { - - Minz_Configuration::_authType($auth_type); - Minz_Configuration::_allowAnonymous($anon); - Minz_Configuration::_allowAnonymousRefresh($anon_refresh); - Minz_Configuration::_enableAutologin($unsafe_autologin); - Minz_Configuration::_enableApi($api_enabled); - $ok &= Minz_Configuration::writeFile(); - } - } - - invalidateHttpCache(); - - $notif = array( - 'type' => $ok ? 'good' : 'bad', - 'content' => _t($ok ? 'configuration_updated' : 'error_occurred') - ); - Minz_Session::_param('notification', $notif); - } - Minz_Request::forward(array('c' => 'users', 'a' => 'index'), true); - } - - public function createAction() { - if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) { - $db = Minz_Configuration::dataBase(); - require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); - - $new_user_language = Minz_Request::param('new_user_language', $this->view->conf->language); - if (!in_array($new_user_language, $this->view->conf->availableLanguages())) { - $new_user_language = $this->view->conf->language; - } - - $new_user_name = Minz_Request::param('new_user_name'); - $ok = ($new_user_name != '') && ctype_alnum($new_user_name); - - if ($ok) { - $ok &= (strcasecmp($new_user_name, Minz_Configuration::defaultUser()) !== 0); //It is forbidden to alter the default user - - $ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers())); //Not an existing user, case-insensitive - - $configPath = DATA_PATH . '/' . $new_user_name . '_user.php'; - $ok &= !file_exists($configPath); - } - if ($ok) { - - $passwordPlain = Minz_Request::param('new_user_passwordPlain', '', true); - $passwordHash = ''; - if ($passwordPlain != '') { - Minz_Request::_param('new_user_passwordPlain'); //Discard plain-text password ASAP - $_POST['new_user_passwordPlain'] = ''; - if (!function_exists('password_hash')) { - include_once(LIB_PATH . '/password_compat.php'); - } - $passwordHash = password_hash($passwordPlain, PASSWORD_BCRYPT, array('cost' => self::BCRYPT_COST)); - $passwordPlain = ''; - $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js - $ok &= ($passwordHash != ''); - } - if (empty($passwordHash)) { - $passwordHash = ''; - } - - $new_user_email = filter_var($_POST['new_user_email'], FILTER_VALIDATE_EMAIL); - if (empty($new_user_email)) { - $new_user_email = ''; - } else { - $personaFile = DATA_PATH . '/persona/' . $new_user_email . '.txt'; - @unlink($personaFile); - $ok &= (file_put_contents($personaFile, $new_user_name) !== false); - } - } - if ($ok) { - $config_array = array( - 'language' => $new_user_language, - 'passwordHash' => $passwordHash, - 'mail_login' => $new_user_email, - ); - $ok &= (file_put_contents($configPath, "createUser($new_user_name); - } - invalidateHttpCache(); - - $notif = array( - 'type' => $ok ? 'good' : 'bad', - 'content' => _t($ok ? 'user_created' : 'error_occurred', $new_user_name) - ); - Minz_Session::_param('notification', $notif); - } - Minz_Request::forward(array('c' => 'users', 'a' => 'index'), true); - } - - public function deleteAction() { - if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) { - $db = Minz_Configuration::dataBase(); - require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); - - $username = Minz_Request::param('username'); - $ok = ctype_alnum($username); - - if ($ok) { - $ok &= (strcasecmp($username, Minz_Configuration::defaultUser()) !== 0); //It is forbidden to delete the default user - } - if ($ok) { - $configPath = DATA_PATH . '/' . $username . '_user.php'; - $ok &= file_exists($configPath); - } - if ($ok) { - $userDAO = new FreshRSS_UserDAO(); - $ok &= $userDAO->deleteUser($username); - $ok &= unlink($configPath); - //TODO: delete Persona file - } - invalidateHttpCache(); - - $notif = array( - 'type' => $ok ? 'good' : 'bad', - 'content' => _t($ok ? 'user_deleted' : 'error_occurred', $username) - ); - Minz_Session::_param('notification', $notif); - } - Minz_Request::forward(array('c' => 'users', 'a' => 'index'), true); - } -} diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml index 59846a7c8..7a9d0d839 100644 --- a/app/layout/aside_configure.phtml +++ b/app/layout/aside_configure.phtml @@ -19,10 +19,18 @@
      • -
      • - +
      • +
      • +
      • + +
      • +
      • + +
      • diff --git a/app/layout/header.phtml b/app/layout/header.phtml index deb21edc9..7e7c1b477 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -63,8 +63,10 @@ if (Minz_Configuration::canLogIn()) {
      • -
      • +
      • +
      • +
      • diff --git a/app/views/auth/index.phtml b/app/views/auth/index.phtml new file mode 100644 index 000000000..c37a7aef6 --- /dev/null +++ b/app/views/auth/index.phtml @@ -0,0 +1,84 @@ +partial('aside_configure'); ?> + +
        + + +
        + + +
        + +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + +
        +
        + + +
        + + conf->token; ?> +
        + /> + +
        +
        + + +
        +
        + +
        +
        + +
        +
        + + +
        +
        + +
        diff --git a/app/views/user/manage.phtml b/app/views/user/manage.phtml new file mode 100644 index 000000000..03746cabb --- /dev/null +++ b/app/views/user/manage.phtml @@ -0,0 +1,76 @@ +partial('aside_configure'); ?> + +
        + + +
        + + +
        + +
        + +
        +
        + +
        +
        + +
        +
        + + +
        + + +
        + +
        + +
        +
        + +
        + +
        + +
        +
        + +
        + +
        +
        + + +
        + +
        +
        + +
        + + conf->mail_login; ?> +
        + +
        +
        + +
        +
        + + +
        +
        + + +
        diff --git a/app/views/user/profil.phtml b/app/views/user/profil.phtml new file mode 100644 index 000000000..a74c7b6f8 --- /dev/null +++ b/app/views/user/profil.phtml @@ -0,0 +1,59 @@ +partial('aside_configure'); ?> + +
        + + +
        + + +
        + +
        + + +
        +
        + +
        + +
        +
        + /> + +
        + +
        +
        + + +
        + +
        +
        + /> + +
        +
        +
        + + +
        + + conf->mail_login; ?> +
        + placeholder="alice@example.net" /> + +
        +
        + +
        +
        + + +
        +
        + +
        diff --git a/app/views/users/index.phtml b/app/views/users/index.phtml deleted file mode 100644 index f1cdf01a3..000000000 --- a/app/views/users/index.phtml +++ /dev/null @@ -1,211 +0,0 @@ -partial('aside_configure'); ?> - -
        - - -
        - - -
        - -
        - - -
        -
        - -
        - -
        -
        - /> - -
        - -
        -
        - - -
        - -
        -
        - /> - -
        -
        -
        - - -
        - - conf->mail_login; ?> -
        - placeholder="alice@example.net" /> - -
        -
        - -
        -
        - - -
        -
        - - - - - -
        - -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - -
        -
        - - -
        - - conf->token; ?> -
        - /> - -
        -
        - - -
        -
        - -
        -
        - -
        -
        - - -
        -
        - - -
        - - -
        - -
        - -
        -
        - -
        -
        - -
        -
        - - -
        - - -
        - -
        - -
        -
        - -
        - -
        - -
        -
        - -
        - -
        -
        - - -
        - -
        -
        - -
        - - conf->mail_login; ?> -
        - -
        -
        - -
        -
        - - -
        -
        - - - - -
        -- cgit v1.2.3 From 2796cc9ae559842a90fa15cba65c94a11b29195e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 16 Oct 2014 16:43:37 +0200 Subject: User list load a new page Beginning of more options for administrator! --- app/Controllers/userController.php | 4 ++++ app/views/stats/repartition.phtml | 2 +- app/views/user/manage.phtml | 41 +++++++++++++++++++------------------- p/scripts/main.js | 2 +- 4 files changed, 26 insertions(+), 23 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index c516246c9..00b51cc3d 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -88,6 +88,10 @@ class FreshRSS_user_Controller extends Minz_ActionController { */ public function manageAction() { Minz_View::prependTitle(_t('users.manage') . ' · '); + + $this->view->current_user = Minz_Request::param( + 'u', Minz_Session::param('currentUser', '_') + ); } public function createAction() { diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index 670714707..32268a546 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -5,7 +5,7 @@

        - categories as $category) { $feeds = $category->feeds(); diff --git a/app/views/user/manage.phtml b/app/views/user/manage.phtml index 03746cabb..fb569872b 100644 --- a/app/views/user/manage.phtml +++ b/app/views/user/manage.phtml @@ -3,27 +3,6 @@
        -
        - - -
        - -
        - -
        -
        - -
        -
        - -
        -
        - -
        @@ -71,6 +50,26 @@
        + + + + +
        + +
        + +
        +
        + +
        +
        + +
        +
        diff --git a/p/scripts/main.js b/p/scripts/main.js index 77e1e3f77..1e13ff16a 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1086,7 +1086,7 @@ function init_share_observers() { } function init_stats_observers() { - $('#feed_select').on('change', function(e) { + $('.select-change').on('change', function(e) { redirect($(this).find(':selected').data('url')); }); } -- cgit v1.2.3 From d4ad951b9b686f387056bda8f3fa6ede8d9ca3f1 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 16 Oct 2014 17:08:48 +0200 Subject: Show more information about user when selected --- app/Controllers/userController.php | 19 ++++++++++++++++--- app/Models/Factory.php | 18 +++++++++--------- app/Models/UserDAO.php | 4 ++++ app/views/configure/archiving.phtml | 2 +- app/views/user/manage.phtml | 2 ++ 5 files changed, 32 insertions(+), 13 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 00b51cc3d..4a04737f2 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -87,11 +87,24 @@ class FreshRSS_user_Controller extends Minz_ActionController { * This action displays the user management page. */ public function manageAction() { + if (!FreshRSS_Auth::hasAccess('admin')) { + Minz_Error::error(403, + array('error' => array(_t('access_denied')))); + } + Minz_View::prependTitle(_t('users.manage') . ' · '); - $this->view->current_user = Minz_Request::param( - 'u', Minz_Session::param('currentUser', '_') - ); + $userDAO = new FreshRSS_UserDAO(); + + $username = Minz_Request::param('u', Minz_Session::param('currentUser')); + if (!$userDAO->exist($username)) { + $username = Minz_Session::param('currentUser'); + } + $this->view->current_user = $username; + + $entryDAO = FreshRSS_Factory::createEntryDao($this->view->current_user); + $this->view->nb_articles = $entryDAO->count(); + $this->view->size_user = $entryDAO->size(); } public function createAction() { diff --git a/app/Models/Factory.php b/app/Models/Factory.php index 08569b2e2..93f4552f7 100644 --- a/app/Models/Factory.php +++ b/app/Models/Factory.php @@ -2,30 +2,30 @@ class FreshRSS_Factory { - public static function createFeedDao() { + public static function createFeedDao($username = null) { $db = Minz_Configuration::dataBase(); if ($db['type'] === 'sqlite') { - return new FreshRSS_FeedDAOSQLite(); + return new FreshRSS_FeedDAOSQLite($username); } else { - return new FreshRSS_FeedDAO(); + return new FreshRSS_FeedDAO($username); } } - public static function createEntryDao() { + public static function createEntryDao($username = null) { $db = Minz_Configuration::dataBase(); if ($db['type'] === 'sqlite') { - return new FreshRSS_EntryDAOSQLite(); + return new FreshRSS_EntryDAOSQLite($username); } else { - return new FreshRSS_EntryDAO(); + return new FreshRSS_EntryDAO($username); } } - public static function createStatsDAO() { + public static function createStatsDAO($username = null) { $db = Minz_Configuration::dataBase(); if ($db['type'] === 'sqlite') { - return new FreshRSS_StatsDAOSQLite(); + return new FreshRSS_StatsDAOSQLite($username); } else { - return new FreshRSS_StatsDAO(); + return new FreshRSS_StatsDAO($username); } } diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 15215258c..85b45c4a7 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -53,4 +53,8 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { } } } + + public function exist($username) { + return file_exists(DATA_PATH . '/' . $username . '_user.php'); + } } diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml index adbfdb77e..8f424c126 100644 --- a/app/views/configure/archiving.phtml +++ b/app/views/configure/archiving.phtml @@ -60,7 +60,7 @@

        -

        nb_total), ' ', _t('articles'), ', ', formatBytes($this->size_user); ?>

        +

        nb_total)), ' — ', formatBytes($this->size_user); ?>

        diff --git a/app/views/user/manage.phtml b/app/views/user/manage.phtml index fb569872b..65e60add5 100644 --- a/app/views/user/manage.phtml +++ b/app/views/user/manage.phtml @@ -63,6 +63,8 @@ + +

        nb_articles)), ', ', formatBytes($this->size_user); ?>

        -- cgit v1.2.3 From 5797344aff9ceebbdeb6e49305f3984a5c89f82c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 16 Oct 2014 17:15:51 +0200 Subject: Fix a bug to get size of user (SQLite) --- app/Controllers/userController.php | 3 ++- app/Models/EntryDAOSQLite.php | 2 +- lib/Minz/ModelPdo.php | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 4a04737f2..d5c90a382 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -94,14 +94,15 @@ class FreshRSS_user_Controller extends Minz_ActionController { Minz_View::prependTitle(_t('users.manage') . ' · '); + // Get the correct current user. $userDAO = new FreshRSS_UserDAO(); - $username = Minz_Request::param('u', Minz_Session::param('currentUser')); if (!$userDAO->exist($username)) { $username = Minz_Session::param('currentUser'); } $this->view->current_user = $username; + // Get information about the current user. $entryDAO = FreshRSS_Factory::createEntryDao($this->view->current_user); $this->view->nb_articles = $entryDAO->count(); $this->view->size_user = $entryDAO->size(); diff --git a/app/Models/EntryDAOSQLite.php b/app/Models/EntryDAOSQLite.php index 66078aca9..4a3fe24a2 100644 --- a/app/Models/EntryDAOSQLite.php +++ b/app/Models/EntryDAOSQLite.php @@ -124,6 +124,6 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO { } public function size($all = false) { - return @filesize(DATA_PATH . '/' . Minz_Session::param('currentUser', '_') . '.sqlite'); + return @filesize(DATA_PATH . '/' . $this->current_user . '.sqlite'); } } diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 66127ea22..827c89c69 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -24,6 +24,7 @@ class Minz_ModelPdo { */ protected $bd; + protected $current_user; protected $prefix; public function dbType() { @@ -46,6 +47,7 @@ class Minz_ModelPdo { if ($currentUser === null) { $currentUser = Minz_Session::param('currentUser', '_'); } + $this->current_user = $currentUser; try { $type = $db['type']; -- cgit v1.2.3 From 7080a32650ab8b19e917d8add944a75cc98381bc Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Oct 2014 11:54:31 +0200 Subject: Add checking installation feature --- app/Controllers/updateController.php | 14 +++++- app/Models/DatabaseDAO.php | 83 ++++++++++++++++++++++++++++++++++++ app/Models/DatabaseDAOSQLite.php | 48 +++++++++++++++++++++ app/Models/Factory.php | 9 ++++ app/SQL/install.sql.mysql.php | 2 - app/SQL/install.sql.sqlite.php | 2 - app/layout/aside_configure.phtml | 7 ++- app/layout/header.phtml | 1 + app/views/update/checkInstall.phtml | 30 +++++++++++++ lib/lib_rss.php | 62 +++++++++++++++++++++++++++ 10 files changed, 252 insertions(+), 6 deletions(-) create mode 100644 app/Models/DatabaseDAO.php create mode 100644 app/Models/DatabaseDAOSQLite.php create mode 100644 app/views/update/checkInstall.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 9d1e1ddf5..4ebb11f51 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -12,7 +12,6 @@ class FreshRSS_update_Controller extends Minz_ActionController { invalidateHttpCache(); - Minz_View::prependTitle(_t('update_system') . ' · '); $this->view->update_to_apply = false; $this->view->last_update_time = 'unknown'; $this->view->check_last_hour = false; @@ -24,6 +23,8 @@ class FreshRSS_update_Controller extends Minz_ActionController { } public function indexAction() { + Minz_View::prependTitle(_t('update_system') . ' · '); + if (file_exists(UPDATE_FILENAME) && !is_writable(FRESHRSS_PATH)) { $this->view->message = array( 'status' => 'bad', @@ -126,4 +127,15 @@ class FreshRSS_update_Controller extends Minz_ActionController { } } } + + /** + * This action displays information about installation. + */ + public function checkInstallAction() { + Minz_View::prependTitle(_t('gen.title.check_install') . ' · '); + + $this->view->status_php = check_install_php(); + $this->view->status_files = check_install_files(); + $this->view->status_database = check_install_database(); + } } diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php new file mode 100644 index 000000000..0d85718e3 --- /dev/null +++ b/app/Models/DatabaseDAO.php @@ -0,0 +1,83 @@ +bd->prepare($sql); + $stm->execute(); + $res = $stm->fetchAll(PDO::FETCH_ASSOC); + + $tables = array( + $this->prefix . 'category' => false, + $this->prefix . 'feed' => false, + $this->prefix . 'entry' => false, + ); + foreach ($res as $value) { + $tables[array_pop($value)] = true; + } + + return count(array_keys($tables, true, true)) == count($tables); + } + + public function getSchema($table) { + $sql = 'DESC ' . $this->prefix . $table; + $stm = $this->bd->prepare($sql); + $stm->execute(); + + return $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC)); + } + + public function checkTable($table, $schema) { + $columns = $this->getSchema($table); + + $ok = (count($columns) == count($schema)); + foreach ($columns as $c) { + $ok &= in_array($c['name'], $schema); + } + + return $ok; + } + + public function categoryIsCorrect() { + return $this->checkTable('category', array( + 'id', 'name' + )); + } + + public function feedIsCorrect() { + return $this->checkTable('feed', array( + 'id', 'url', 'category', 'name', 'website', 'description', 'lastUpdate', + 'priority', 'pathEntries', 'httpAuth', 'error', 'keep_history', 'ttl', + 'cache_nbEntries', 'cache_nbUnreads' + )); + } + + public function entryIsCorrect() { + return $this->checkTable('entry', array( + 'id', 'guid', 'title', 'author', 'content_bin', 'link', 'date', 'is_read', + 'is_favorite', 'id_feed', 'tags' + )); + } + + public function daoToSchema($dao) { + return array( + 'name' => $dao['Field'], + 'type' => strtolower($dao['Type']), + 'notnull' => (bool)$dao['Null'], + 'default' => $dao['Default'], + ); + } + + public function listDaoToSchema($listDAO) { + $list = array(); + + foreach ($listDAO as $dao) { + $list[] = $this->daoToSchema($dao); + } + + return $list; + } +} diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php new file mode 100644 index 000000000..7f53f967d --- /dev/null +++ b/app/Models/DatabaseDAOSQLite.php @@ -0,0 +1,48 @@ +bd->prepare($sql); + $stm->execute(); + $res = $stm->fetchAll(PDO::FETCH_ASSOC); + + $tables = array( + 'category' => false, + 'feed' => false, + 'entry' => false, + ); + foreach ($res as $value) { + $tables[$value['name']] = true; + } + + return count(array_keys($tables, true, true)) == count($tables); + } + + public function getSchema($table) { + $sql = 'PRAGMA table_info(' . $table . ')'; + $stm = $this->bd->prepare($sql); + $stm->execute(); + + return $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC)); + } + + public function entryIsCorrect() { + return $this->checkTable('entry', array( + 'id', 'guid', 'title', 'author', 'content', 'link', 'date', 'is_read', + 'is_favorite', 'id_feed', 'tags' + )); + } + + public function daoToSchema($dao) { + return array( + 'name' => $dao['name'], + 'type' => strtolower($dao['type']), + 'notnull' => $dao['notnull'] === '1' ? true : false, + 'default' => $dao['dflt_value'], + ); + } +} diff --git a/app/Models/Factory.php b/app/Models/Factory.php index 93f4552f7..91cb84998 100644 --- a/app/Models/Factory.php +++ b/app/Models/Factory.php @@ -29,4 +29,13 @@ class FreshRSS_Factory { } } + public static function createDatabaseDAO($username = null) { + $db = Minz_Configuration::dataBase(); + if ($db['type'] === 'sqlite') { + return new FreshRSS_DatabaseDAOSQLite($username); + } else { + return new FreshRSS_DatabaseDAO($username); + } + } + } diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php index 16cb3a3b8..cf0159199 100644 --- a/app/SQL/install.sql.mysql.php +++ b/app/SQL/install.sql.mysql.php @@ -57,5 +57,3 @@ INSERT IGNORE INTO `%1$scategory` (id, name) VALUES(1, "%2$s"); '); define('SQL_DROP_TABLES', 'DROP TABLES %1$sentry, %1$sfeed, %1$scategory'); - -define('SQL_SHOW_TABLES', 'SHOW tables;'); diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php index 7988ada04..30bca2810 100644 --- a/app/SQL/install.sql.sqlite.php +++ b/app/SQL/install.sql.sqlite.php @@ -55,5 +55,3 @@ $SQL_CREATE_TABLES = array( ); define('SQL_DROP_TABLES', 'DROP TABLES %1$sentry, %1$sfeed, %1$scategory'); - -define('SQL_SHOW_TABLES', 'SELECT name FROM sqlite_master WHERE type="table"'); diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml index 20446c877..32dc19a4e 100644 --- a/app/layout/aside_configure.phtml +++ b/app/layout/aside_configure.phtml @@ -31,7 +31,12 @@
      • -
      • +
      • + +
      • +
      • diff --git a/app/layout/header.phtml b/app/layout/header.phtml index e848ac4eb..506cec175 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -68,6 +68,7 @@ if (Minz_Configuration::canLogIn()) {
      • +
      • diff --git a/app/views/update/checkInstall.phtml b/app/views/update/checkInstall.phtml new file mode 100644 index 000000000..32058714e --- /dev/null +++ b/app/views/update/checkInstall.phtml @@ -0,0 +1,30 @@ +partial('aside_configure'); ?> + +
        + + +

        + + status_php as $key => $status) { ?> +

        + +

        + + +

        + + status_files as $key => $status) { ?> +

        + +

        + + +

        + + status_database as $key => $status) { ?> +

        + +

        + + +
        diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 2f9a2ea45..dbed207d0 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -245,3 +245,65 @@ function is_referer_from_same_domain() { } return (isset($host['port']) ? $host['port'] : 0) === (isset($referer['port']) ? $referer['port'] : 0); } + + +/** + * + */ +function check_install_php() { + return array( + 'php' => version_compare(PHP_VERSION, '5.2.1') >= 0, + 'minz' => file_exists(LIB_PATH . '/Minz'), + 'curl' => extension_loaded('curl'), + 'pdo_mysql' => extension_loaded('pdo_mysql'), + 'pdo_sqlite' => extension_loaded('pdo_sqlite'), + 'pdo' => extension_loaded('pdo_mysql') || extension_loaded('pdo_sqlite'), + 'pcre' => extension_loaded('pcre'), + 'ctype' => extension_loaded('ctype'), + 'dom' => class_exists('DOMDocument'), + 'json' => extension_loaded('json'), + 'zip' => extension_loaded('zip'), + ); +} + + +/** + * + */ +function check_install_files() { + return array( + 'data' => DATA_PATH && is_writable(DATA_PATH), + 'cache' => CACHE_PATH && is_writable(CACHE_PATH), + 'logs' => LOG_PATH && is_writable(LOG_PATH), + 'favicons' => is_writable(DATA_PATH . '/favicons'), + 'persona' => is_writable(DATA_PATH . '/persona'), + 'tokens' => is_writable(DATA_PATH . '/tokens'), + ); +} + + +/** + * + */ +function check_install_database() { + $status = array( + 'connection' => true, + 'tables' => false, + 'categories' => false, + 'feeds' => false, + 'entries' => false, + ); + + try { + $dbDAO = FreshRSS_Factory::createDatabaseDAO(); + + $status['tables'] = $dbDAO->tablesAreCorrect(); + $status['categories'] = $dbDAO->categoryIsCorrect(); + $status['feeds'] = $dbDAO->feedIsCorrect(); + $status['entries'] = $dbDAO->entryIsCorrect(); + } catch(Minz_PDOConnectionException $e) { + $status['connection'] = false; + } + + return $status; +} -- cgit v1.2.3 From df4ddf0e552d9113c9f55d5361212f8279a5c617 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Oct 2014 13:31:49 +0200 Subject: Unsafe autologin comes back Should be moved in an extension later! See https://github.com/marienfressinaud/FreshRSS/issues/655 --- app/Controllers/authController.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'app/Controllers') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index 751ce1f3f..d4b65d849 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -104,6 +104,8 @@ class FreshRSS_auth_Controller extends Minz_ActionController { * - username (default: '') * - challenge (default: '') * - keep_logged_in (default: false) + * + * @todo move unsafe autologin in an extension. */ public function formLoginAction() { invalidateHttpCache(); @@ -151,6 +153,42 @@ class FreshRSS_auth_Controller extends Minz_ActionController { Minz_Request::bad(_t('invalid_login'), array('c' => 'auth', 'a' => 'login')); } + } elseif (Minz_Configuration::unsafeAutologinEnabled()) { + $username = Minz_Request::param('u', ''); + $password = Minz_Request::param('p', ''); + Minz_Request::_param('p'); + + if (!$username) { + return; + } + + try { + $conf = new FreshRSS_Configuration($username); + } catch(Minz_Exception $e) { + // $username is not a valid user, nor the configuration file! + Minz_Log::warning('Login failure: ' . $e->getMessage()); + return; + } + + if (!function_exists('password_verify')) { + include_once(LIB_PATH . '/password_compat.php'); + } + + $s = $conf->passwordHash; + $ok = password_verify($password, $s); + unset($password); + if ($ok) { + Minz_Session::_param('currentUser', $username); + Minz_Session::_param('passwordHash', $s); + FreshRSS_Auth::giveAccess(); + + Minz_Request::good(_t('login'), + array('c' => 'index', 'a' => 'index')); + } else { + Minz_Log::warning('Unsafe password mismatch for user ' . $username); + Minz_Request::bad(_t('invalid_login'), + array('c' => 'auth', 'a' => 'login')); + } } } -- cgit v1.2.3 From 1a22a87fb1b1fcb61d201de399c33c2185dc1f6e Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 20 Oct 2014 18:45:22 +0200 Subject: Use FreshRSS_Context::$conf only - Replace $this->view->conf in controllers - Replace $this->conf in views --- app/Controllers/authController.php | 6 +- app/Controllers/categoryController.php | 8 +-- app/Controllers/configureController.php | 92 +++++++++++++++--------------- app/Controllers/entryController.php | 6 +- app/Controllers/feedController.php | 18 +++--- app/Controllers/importExportController.php | 4 +- app/Controllers/indexController.php | 8 +-- app/Controllers/javascriptController.php | 2 +- app/Controllers/userController.php | 18 +++--- app/FreshRSS.php | 2 - app/layout/aside_flux.phtml | 8 +-- app/layout/layout.phtml | 2 +- app/layout/nav_menu.phtml | 14 ++--- app/views/auth/index.phtml | 4 +- app/views/configure/archiving.phtml | 10 ++-- app/views/configure/display.phtml | 30 +++++----- app/views/configure/queries.phtml | 4 +- app/views/configure/reading.phtml | 42 +++++++------- app/views/configure/sharing.phtml | 6 +- app/views/configure/shortcut.phtml | 2 +- app/views/helpers/javascript_vars.phtml | 16 +++--- app/views/helpers/pagination.phtml | 2 +- app/views/helpers/view/global_view.phtml | 6 +- app/views/helpers/view/normal_view.phtml | 30 +++++----- app/views/helpers/view/reader_view.phtml | 4 +- app/views/user/manage.phtml | 6 +- app/views/user/profil.phtml | 2 +- 27 files changed, 175 insertions(+), 177 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index d4b65d849..4af39cb71 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -26,10 +26,10 @@ class FreshRSS_auth_Controller extends Minz_ActionController { if (Minz_Request::isPost()) { $ok = true; - $current_token = $this->view->conf->token; + $current_token = FreshRSS_Context::$conf->token; $token = Minz_Request::param('token', $current_token); - $this->view->conf->_token($token); - $ok &= $this->view->conf->save(); + FreshRSS_Context::$conf->_token($token); + $ok &= FreshRSS_Context::$conf->save(); $anon = Minz_Request::param('anon_access', false); $anon = ((bool)$anon) && ($anon !== 'no'); diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 537a2b210..977ce51be 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -136,8 +136,8 @@ class FreshRSS_category_Controller extends Minz_ActionController { } // Remove related queries. - $this->view->conf->remove_query_by_get('c_' . $id); - $this->view->conf->save(); + FreshRSS_Context::$conf->remove_query_by_get('c_' . $id); + FreshRSS_Context::$conf->save(); Minz_Request::good(_t('category_deleted'), $url_redirect); } @@ -172,9 +172,9 @@ class FreshRSS_category_Controller extends Minz_ActionController { // Remove related queries foreach ($feeds as $feed) { - $this->view->conf->remove_query_by_get('f_' . $feed->id()); + FreshRSS_Context::$conf->remove_query_by_get('f_' . $feed->id()); } - $this->view->conf->save(); + FreshRSS_Context::$conf->save(); Minz_Request::good(_t('category_emptied'), $url_redirect); } else { diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index fb8c1466e..8a9dcdc62 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -44,23 +44,23 @@ class FreshRSS_configure_Controller extends Minz_ActionController { */ public function displayAction() { if (Minz_Request::isPost()) { - $this->view->conf->_language(Minz_Request::param('language', 'en')); - $this->view->conf->_theme(Minz_Request::param('theme', FreshRSS_Themes::$defaultTheme)); - $this->view->conf->_content_width(Minz_Request::param('content_width', 'thin')); - $this->view->conf->_topline_read(Minz_Request::param('topline_read', false)); - $this->view->conf->_topline_favorite(Minz_Request::param('topline_favorite', false)); - $this->view->conf->_topline_date(Minz_Request::param('topline_date', false)); - $this->view->conf->_topline_link(Minz_Request::param('topline_link', false)); - $this->view->conf->_bottomline_read(Minz_Request::param('bottomline_read', false)); - $this->view->conf->_bottomline_favorite(Minz_Request::param('bottomline_favorite', false)); - $this->view->conf->_bottomline_sharing(Minz_Request::param('bottomline_sharing', false)); - $this->view->conf->_bottomline_tags(Minz_Request::param('bottomline_tags', false)); - $this->view->conf->_bottomline_date(Minz_Request::param('bottomline_date', false)); - $this->view->conf->_bottomline_link(Minz_Request::param('bottomline_link', false)); - $this->view->conf->_html5_notif_timeout(Minz_Request::param('html5_notif_timeout', 0)); - $this->view->conf->save(); - - Minz_Session::_param('language', $this->view->conf->language); + FreshRSS_Context::$conf->_language(Minz_Request::param('language', 'en')); + FreshRSS_Context::$conf->_theme(Minz_Request::param('theme', FreshRSS_Themes::$defaultTheme)); + FreshRSS_Context::$conf->_content_width(Minz_Request::param('content_width', 'thin')); + FreshRSS_Context::$conf->_topline_read(Minz_Request::param('topline_read', false)); + FreshRSS_Context::$conf->_topline_favorite(Minz_Request::param('topline_favorite', false)); + FreshRSS_Context::$conf->_topline_date(Minz_Request::param('topline_date', false)); + FreshRSS_Context::$conf->_topline_link(Minz_Request::param('topline_link', false)); + FreshRSS_Context::$conf->_bottomline_read(Minz_Request::param('bottomline_read', false)); + FreshRSS_Context::$conf->_bottomline_favorite(Minz_Request::param('bottomline_favorite', false)); + FreshRSS_Context::$conf->_bottomline_sharing(Minz_Request::param('bottomline_sharing', false)); + FreshRSS_Context::$conf->_bottomline_tags(Minz_Request::param('bottomline_tags', false)); + FreshRSS_Context::$conf->_bottomline_date(Minz_Request::param('bottomline_date', false)); + FreshRSS_Context::$conf->_bottomline_link(Minz_Request::param('bottomline_link', false)); + FreshRSS_Context::$conf->_html5_notif_timeout(Minz_Request::param('html5_notif_timeout', 0)); + FreshRSS_Context::$conf->save(); + + Minz_Session::_param('language', FreshRSS_Context::$conf->language); Minz_Translate::reset(); invalidateHttpCache(); @@ -102,27 +102,27 @@ class FreshRSS_configure_Controller extends Minz_ActionController { */ public function readingAction() { if (Minz_Request::isPost()) { - $this->view->conf->_posts_per_page(Minz_Request::param('posts_per_page', 10)); - $this->view->conf->_view_mode(Minz_Request::param('view_mode', 'normal')); - $this->view->conf->_default_view((int)Minz_Request::param('default_view', FreshRSS_Entry::STATE_ALL)); - $this->view->conf->_auto_load_more(Minz_Request::param('auto_load_more', false)); - $this->view->conf->_display_posts(Minz_Request::param('display_posts', false)); - $this->view->conf->_display_categories(Minz_Request::param('display_categories', false)); - $this->view->conf->_hide_read_feeds(Minz_Request::param('hide_read_feeds', false)); - $this->view->conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false)); - $this->view->conf->_lazyload(Minz_Request::param('lazyload', false)); - $this->view->conf->_sticky_post(Minz_Request::param('sticky_post', false)); - $this->view->conf->_reading_confirm(Minz_Request::param('reading_confirm', false)); - $this->view->conf->_sort_order(Minz_Request::param('sort_order', 'DESC')); - $this->view->conf->_mark_when(array( + FreshRSS_Context::$conf->_posts_per_page(Minz_Request::param('posts_per_page', 10)); + FreshRSS_Context::$conf->_view_mode(Minz_Request::param('view_mode', 'normal')); + FreshRSS_Context::$conf->_default_view((int)Minz_Request::param('default_view', FreshRSS_Entry::STATE_ALL)); + FreshRSS_Context::$conf->_auto_load_more(Minz_Request::param('auto_load_more', false)); + FreshRSS_Context::$conf->_display_posts(Minz_Request::param('display_posts', false)); + FreshRSS_Context::$conf->_display_categories(Minz_Request::param('display_categories', false)); + FreshRSS_Context::$conf->_hide_read_feeds(Minz_Request::param('hide_read_feeds', false)); + FreshRSS_Context::$conf->_onread_jump_next(Minz_Request::param('onread_jump_next', false)); + FreshRSS_Context::$conf->_lazyload(Minz_Request::param('lazyload', false)); + FreshRSS_Context::$conf->_sticky_post(Minz_Request::param('sticky_post', false)); + FreshRSS_Context::$conf->_reading_confirm(Minz_Request::param('reading_confirm', false)); + FreshRSS_Context::$conf->_sort_order(Minz_Request::param('sort_order', 'DESC')); + FreshRSS_Context::$conf->_mark_when(array( 'article' => Minz_Request::param('mark_open_article', false), 'site' => Minz_Request::param('mark_open_site', false), 'scroll' => Minz_Request::param('mark_scroll', false), 'reception' => Minz_Request::param('mark_upon_reception', false), )); - $this->view->conf->save(); + FreshRSS_Context::$conf->save(); - Minz_Session::_param('language', $this->view->conf->language); + Minz_Session::_param('language', FreshRSS_Context::$conf->language); Minz_Translate::reset(); invalidateHttpCache(); @@ -143,8 +143,8 @@ class FreshRSS_configure_Controller extends Minz_ActionController { public function sharingAction() { if (Minz_Request::isPost()) { $params = Minz_Request::params(); - $this->view->conf->_sharing($params['share']); - $this->view->conf->save(); + FreshRSS_Context::$conf->_sharing($params['share']); + FreshRSS_Context::$conf->save(); invalidateHttpCache(); Minz_Request::good(_t('configuration_updated'), @@ -185,8 +185,8 @@ class FreshRSS_configure_Controller extends Minz_ActionController { } } - $this->view->conf->_shortcuts($shortcuts_ok); - $this->view->conf->save(); + FreshRSS_Context::$conf->_shortcuts($shortcuts_ok); + FreshRSS_Context::$conf->save(); invalidateHttpCache(); Minz_Request::good(_t('shortcuts_updated'), @@ -213,10 +213,10 @@ class FreshRSS_configure_Controller extends Minz_ActionController { */ public function archivingAction() { if (Minz_Request::isPost()) { - $this->view->conf->_old_entries(Minz_Request::param('old_entries', 3)); - $this->view->conf->_keep_history_default(Minz_Request::param('keep_history_default', 0)); - $this->view->conf->_ttl_default(Minz_Request::param('ttl_default', -2)); - $this->view->conf->save(); + FreshRSS_Context::$conf->_old_entries(Minz_Request::param('old_entries', 3)); + FreshRSS_Context::$conf->_keep_history_default(Minz_Request::param('keep_history_default', 0)); + FreshRSS_Context::$conf->_ttl_default(Minz_Request::param('ttl_default', -2)); + FreshRSS_Context::$conf->save(); invalidateHttpCache(); Minz_Request::good(_t('configuration_updated'), @@ -253,8 +253,8 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $query['name'] = _t('query_number', $key + 1); } } - $this->view->conf->_queries($queries); - $this->view->conf->save(); + FreshRSS_Context::$conf->_queries($queries); + FreshRSS_Context::$conf->save(); Minz_Request::good(_t('configuration_updated'), array('c' => 'configure', 'a' => 'queries')); @@ -262,7 +262,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $this->view->query_get = array(); $cat_dao = new FreshRSS_CategoryDAO(); $feed_dao = FreshRSS_Factory::createFeedDao(); - foreach ($this->view->conf->queries as $key => $query) { + foreach (FreshRSS_Context::$conf->queries as $key => $query) { if (!isset($query['get'])) { continue; } @@ -330,7 +330,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { */ public function addQueryAction() { $whitelist = array('get', 'order', 'name', 'search', 'state'); - $queries = $this->view->conf->queries; + $queries = FreshRSS_Context::$conf->queries; $query = Minz_Request::params(); $query['name'] = _t('query_number', count($queries) + 1); foreach ($query as $key => $value) { @@ -342,8 +342,8 @@ class FreshRSS_configure_Controller extends Minz_ActionController { $query['state'] -= FreshRSS_Entry::STATE_STRICT; } $queries[] = $query; - $this->view->conf->_queries($queries); - $this->view->conf->save(); + FreshRSS_Context::$conf->_queries($queries); + FreshRSS_Context::$conf->save(); Minz_Request::good(_t('query_created', $query['name']), array('c' => 'configure', 'a' => 'queries')); diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index a1dfacb4d..449029648 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -21,7 +21,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { // the end. $this->params = array(); $output = Minz_Request::param('output', ''); - if ($output != '' && $this->view->conf->view_mode !== $output) { + if ($output != '' && FreshRSS_Context::$conf->view_mode !== $output) { $this->params['output'] = $output; } @@ -167,7 +167,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { public function purgeAction() { @set_time_limit(300); - $nb_month_old = max($this->view->conf->old_entries, 1); + $nb_month_old = max(FreshRSS_Context::$conf->old_entries, 1); $date_min = time() - (3600 * 24 * 30 * $nb_month_old); $feedDAO = FreshRSS_Factory::createFeedDao(); @@ -181,7 +181,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { if ($feed_history == -2) { // TODO: -2 must be a constant! // -2 means we take the default value from configuration - $feed_history = $this->view->conf->keep_history_default; + $feed_history = FreshRSS_Context::$conf->keep_history_default; } if ($feed_history >= 0) { diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 2a7238eaf..c2859edf4 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -14,7 +14,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // 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 = FreshRSS_Context::$conf->token; $token_param = Minz_Request::param('token', ''); $token_is_ok = ($token != '' && $token == $token_param); $action = Minz_Request::actionName(); @@ -154,14 +154,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed->_id($id); $feed->faviconPrepare(); - $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; + $is_read = FreshRSS_Context::$conf->mark_when['reception'] ? 1 : 0; $entryDAO = FreshRSS_Factory::createEntryDao(); // We want chronological order and SimplePie uses reverse order. $entries = array_reverse($feed->entries()); // Calculate date of oldest entries we accept in DB. - $nb_month_old = $this->view->conf->old_entries; + $nb_month_old = FreshRSS_Context::$conf->old_entries; $date_min = time() - (3600 * 24 * 30 * $nb_month_old); // Use a shared statement and a transaction to improve a LOT the @@ -265,15 +265,15 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feeds[] = $feed; } } else { - $feeds = $feedDAO->listFeedsOrderUpdate($this->view->conf->ttl_default); + $feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$conf->ttl_default); } // Calculate date of oldest entries we accept in DB. - $nb_month_old = max($this->view->conf->old_entries, 1); + $nb_month_old = max(FreshRSS_Context::$conf->old_entries, 1); $date_min = time() - (3600 * 24 * 30 * $nb_month_old); $updated_feeds = 0; - $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; + $is_read = FreshRSS_Context::$conf->mark_when['reception'] ? 1 : 0; foreach ($feeds as $feed) { if (!$feed->lock()) { Minz_Log::notice('Feed already being actualized: ' . $feed->url()); @@ -294,7 +294,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($feed_history == -2) { // TODO: -2 must be a constant! // -2 means we take the default value from configuration - $feed_history = $this->view->conf->keep_history_default; + $feed_history = FreshRSS_Context::$conf->keep_history_default; } // We want chronological order and SimplePie uses reverse order. @@ -470,8 +470,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // TODO: Delete old favicon // Remove related queries - $this->view->conf->remove_query_by_get('f_' . $id); - $this->view->conf->save(); + FreshRSS_Context::$conf->remove_query_by_get('f_' . $id); + FreshRSS_Context::$conf->save(); Minz_Request::good(_t('feed_deleted'), $redirect_url); } else { diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index aaac1b68b..ab277e688 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -289,7 +289,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { return true; } - $is_read = $this->view->conf->mark_when['reception'] ? 1 : 0; + $is_read = FreshRSS_Context::$conf->mark_when['reception'] ? 1 : 0; $google_compliant = strpos($article_object['id'], 'com.google') !== false; @@ -484,7 +484,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $this->view->type = 'feed/' . $feed->id(); $this->view->entries = $this->entryDAO->listWhere( 'f', $feed->id(), FreshRSS_Entry::STATE_ALL, 'ASC', - $this->view->conf->posts_per_page + FreshRSS_Context::$conf->posts_per_page ); $this->view->feed = $feed; } diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 5b490e672..f994e257c 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -5,7 +5,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { public function indexAction() { $output = Minz_Request::param('output'); - $token = $this->view->conf->token; + $token = FreshRSS_Context::$conf->token; // check if user is logged in if (!FreshRSS_Auth::hasAccess() && !Minz_Configuration::allowAnonymous()) { @@ -76,11 +76,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); + $this->view->state = Minz_Request::param('state', FreshRSS_Context::$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); + $this->view->order = $order = Minz_Request::param('order', FreshRSS_Context::$conf->sort_order); + $nb = Minz_Request::param('nb', FreshRSS_Context::$conf->posts_per_page); $first = Minz_Request::param('next', ''); $ajax_request = Minz_Request::param('ajax', false); diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php index 14e6f36de..62f413989 100755 --- a/app/Controllers/javascriptController.php +++ b/app/Controllers/javascriptController.php @@ -8,7 +8,7 @@ class FreshRSS_javascript_Controller extends Minz_ActionController { 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); + $this->view->feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$conf->ttl_default); } public function nbUnreadsPerFeedAction() { diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index d5c90a382..61d33437d 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -42,9 +42,9 @@ class FreshRSS_user_Controller extends Minz_ActionController { $passwordPlain = ''; $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js $ok &= ($passwordHash != ''); - $this->view->conf->_passwordHash($passwordHash); + FreshRSS_Context::$conf->_passwordHash($passwordHash); } - Minz_Session::_param('passwordHash', $this->view->conf->passwordHash); + Minz_Session::_param('passwordHash', FreshRSS_Context::$conf->passwordHash); $passwordPlain = Minz_Request::param('apiPasswordPlain', '', true); if ($passwordPlain != '') { @@ -55,17 +55,17 @@ class FreshRSS_user_Controller extends Minz_ActionController { $passwordPlain = ''; $passwordHash = preg_replace('/^\$2[xy]\$/', '\$2a\$', $passwordHash); //Compatibility with bcrypt.js $ok &= ($passwordHash != ''); - $this->view->conf->_apiPasswordHash($passwordHash); + FreshRSS_Context::$conf->_apiPasswordHash($passwordHash); } // TODO: why do we need of hasAccess here? if (FreshRSS_Auth::hasAccess('admin')) { - $this->view->conf->_mail_login(Minz_Request::param('mail_login', '', true)); + FreshRSS_Context::$conf->_mail_login(Minz_Request::param('mail_login', '', true)); } - $email = $this->view->conf->mail_login; + $email = FreshRSS_Context::$conf->mail_login; Minz_Session::_param('mail', $email); - $ok &= $this->view->conf->save(); + $ok &= FreshRSS_Context::$conf->save(); if ($email != '') { $personaFile = DATA_PATH . '/persona/' . $email . '.txt'; @@ -113,9 +113,9 @@ class FreshRSS_user_Controller extends Minz_ActionController { $db = Minz_Configuration::dataBase(); require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); - $new_user_language = Minz_Request::param('new_user_language', $this->view->conf->language); - if (!in_array($new_user_language, $this->view->conf->availableLanguages())) { - $new_user_language = $this->view->conf->language; + $new_user_language = Minz_Request::param('new_user_language', FreshRSS_Context::$conf->language); + if (!in_array($new_user_language, FreshRSS_Context::$conf->availableLanguages())) { + $new_user_language = FreshRSS_Context::$conf->language; } $new_user_name = Minz_Request::param('new_user_name'); diff --git a/app/FreshRSS.php b/app/FreshRSS.php index e1399ad78..752b14e31 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -24,9 +24,7 @@ class FreshRSS extends Minz_FrontController { } // Load context and configuration. - // TODO: remove $this->view->conf variable which is contained in context FreshRSS_Context::init(); - Minz_View::_param('conf', FreshRSS_Context::$conf); $this->loadParamsView(); $this->loadStylesAndScripts(); diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml index a66be2ed9..114ccbf56 100644 --- a/app/layout/aside_flux.phtml +++ b/app/layout/aside_flux.phtml @@ -1,4 +1,4 @@ -
        +
          @@ -17,7 +17,7 @@ 'index', 'a' => 'index', 'params' => array()); - if ($this->conf->view_mode !== Minz_Request::param('output', 'normal')) { + if (FreshRSS_Context::$conf->view_mode !== Minz_Request::param('output', 'normal')) { $arUrl['params']['output'] = 'normal'; } ?> @@ -47,7 +47,7 @@ $c_show = false; if ($this->get_c == $cat->id()) { $c_active = true; - if (!$this->conf->display_categories || $this->get_f) { + if (!FreshRSS_Context::$conf->display_categories || $this->get_f) { $c_show = true; } } @@ -92,7 +92,7 @@
        • - conf->reading_confirm ? 'confirm' : ''; ?> + reading_confirm ? 'confirm' : ''; ?>
        • - conf->queries as $query) { ?> + queries as $query) { ?>
        • - conf->queries) > 0) { ?> + queries) > 0) { ?>
        • @@ -132,7 +132,7 @@ $string_mark = _t('mark_cat_read'); } $nextGet = $get; - if ($this->conf->onread_jump_next && strlen($get) > 2) { + if (FreshRSS_Context::$conf->onread_jump_next && strlen($get) > 2) { $anotherUnreadId = ''; $foundCurrent = false; switch ($get[0]) { @@ -180,7 +180,7 @@ $arUrl = array('c' => 'entry', 'a' => 'read', 'params' => array('get' => $get, 'nextGet' => $nextGet, 'idMax' => $idMax)); $output = Minz_Request::param('output', ''); - if ($output != '' && $this->conf->view_mode !== $output) { + if ($output != '' && FreshRSS_Context::$conf->view_mode !== $output) { $arUrl['params']['output'] = $output; } $markReadUrl = Minz_Url::display($arUrl); @@ -190,7 +190,7 @@
        - - + + - - + + - - - - - - + + + + + +
         
        conf->topline_read ? ' checked="checked"' : ''; ?> /> conf->topline_favorite ? ' checked="checked"' : ''; ?> /> conf->topline_date ? ' checked="checked"' : ''; ?> /> conf->topline_link ? ' checked="checked"' : ''; ?> />
        conf->bottomline_read ? ' checked="checked"' : ''; ?> /> conf->bottomline_favorite ? ' checked="checked"' : ''; ?> /> conf->bottomline_sharing ? ' checked="checked"' : ''; ?> />
        conf->topline_read ? ' checked="checked"' : ''; ?> />conf->topline_favorite ? ' checked="checked"' : ''; ?> />topline_read ? ' checked="checked"' : ''; ?> />topline_favorite ? ' checked="checked"' : ''; ?> /> conf->topline_date ? ' checked="checked"' : ''; ?> />conf->topline_link ? ' checked="checked"' : ''; ?> />topline_date ? ' checked="checked"' : ''; ?> />topline_link ? ' checked="checked"' : ''; ?> />
        conf->bottomline_read ? ' checked="checked"' : ''; ?> />conf->bottomline_favorite ? ' checked="checked"' : ''; ?> />conf->bottomline_sharing ? ' checked="checked"' : ''; ?> />conf->bottomline_tags ? ' checked="checked"' : ''; ?> />conf->bottomline_date ? ' checked="checked"' : ''; ?> />conf->bottomline_link ? ' checked="checked"' : ''; ?> />bottomline_read ? ' checked="checked"' : ''; ?> />bottomline_favorite ? ' checked="checked"' : ''; ?> />bottomline_sharing ? ' checked="checked"' : ''; ?> />bottomline_tags ? ' checked="checked"' : ''; ?> />bottomline_date ? ' checked="checked"' : ''; ?> />bottomline_link ? ' checked="checked"' : ''; ?> />

        @@ -95,7 +95,7 @@
        - +
        diff --git a/app/views/configure/queries.phtml b/app/views/configure/queries.phtml index e778ce078..994dfc11b 100644 --- a/app/views/configure/queries.phtml +++ b/app/views/configure/queries.phtml @@ -6,7 +6,7 @@
        - conf->queries as $key => $query) { ?> + queries as $key => $query) { ?>
        - conf->queries) > 0) { ?> + queries) > 0) { ?>
        diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml index c8685acf3..ef775b4b1 100644 --- a/app/views/configure/reading.phtml +++ b/app/views/configure/reading.phtml @@ -9,7 +9,7 @@
        - +
        @@ -18,8 +18,8 @@
        @@ -28,9 +28,9 @@
        @@ -39,9 +39,9 @@
        @@ -49,7 +49,7 @@
        @@ -58,7 +58,7 @@
        @@ -68,7 +68,7 @@
        @@ -78,7 +78,7 @@
        @@ -88,7 +88,7 @@
        @@ -98,7 +98,7 @@
        @@ -108,7 +108,7 @@
        @@ -119,19 +119,19 @@
        @@ -141,7 +141,7 @@
        diff --git a/app/views/configure/sharing.phtml b/app/views/configure/sharing.phtml index 09c1e6f40..ef5e85a0c 100644 --- a/app/views/configure/sharing.phtml +++ b/app/views/configure/sharing.phtml @@ -15,8 +15,8 @@
        '> - conf->sharing as $key => $sharing): ?> - conf->shares[$sharing['type']]; ?> + sharing as $key => $sharing): ?> + shares[$sharing['type']]; ?>
        diff --git a/app/views/user/profile.phtml b/app/views/user/profile.phtml new file mode 100644 index 000000000..60257012c --- /dev/null +++ b/app/views/user/profile.phtml @@ -0,0 +1,59 @@ +partial('aside_configure'); ?> + +
        + + +
        + + +
        + +
        + + +
        +
        + +
        + +
        +
        + /> + +
        + +
        +
        + + +
        + +
        +
        + /> + +
        +
        +
        + + +
        + + mail_login; ?> +
        + placeholder="alice@example.net" /> + +
        +
        + +
        +
        + + +
        +
        +
        +
        -- cgit v1.2.3 From 4dec7bf127fdb71c78d09bb4f64995028a60c439 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 26 Oct 2014 12:37:38 +0100 Subject: Fix i18n string Order has been changed due to a little bug in sort order function. --- app/Controllers/authController.php | 6 +- app/i18n/en.php | 109 +++++++++++++++++++------------------ app/i18n/fr.php | 109 +++++++++++++++++++------------------ 3 files changed, 114 insertions(+), 110 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index a08f906e3..491be8d8a 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -23,6 +23,8 @@ class FreshRSS_auth_Controller extends Minz_ActionController { array('error' => array(_t('access_denied')))); } + Minz_View::prependTitle(_t('gen.title.authentication') . ' · '); + if (Minz_Request::isPost()) { $ok = true; @@ -55,10 +57,10 @@ class FreshRSS_auth_Controller extends Minz_ActionController { invalidateHttpCache(); if ($ok) { - Minz_Request::good('configuration_updated', + Minz_Request::good(_t('configuration_updated'), array('c' => 'auth', 'a' => 'index')); } else { - Minz_Request::bad('error_occurred', + Minz_Request::bad(_t('error_occurred'), array('c' => 'auth', 'a' => 'index')); } } diff --git a/app/i18n/en.php b/app/i18n/en.php index 275471e19..1e6621c12 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -1,5 +1,17 @@ '\\A\\p\\r\\i\\l', + 'Aug' => '\\A\\u\\g\\u\\s\\t', + 'Dec' => '\\D\\e\\c\\e\\m\\b\\e\\r', + 'Feb' => '\\F\\e\\b\\r\\u\\a\\r\\y', + 'Jan' => '\\J\\a\\n\\u\\a\\r\\y', + 'Jul' => '\\J\\u\\l\\y', + 'Jun' => '\\J\\u\\n\\e', + 'Mar' => '\\M\\a\\r\\c\\h', + 'May' => '\\M\\a\\y', + 'Nov' => '\\N\\o\\v\\e\\m\\b\\e\\r', + 'Oct' => '\\O\\c\\t\\o\\b\\e\\r', + 'Sep' => '\\S\\e\\p\\t\\e\\m\\b\\e\\r', 'about' => 'About', 'about_freshrss' => 'About FreshRSS', 'access_denied' => 'You don’t have permission to access this page', @@ -61,42 +73,40 @@ 'advanced' => 'Advanced', 'after_onread' => 'After “mark all as read”,', 'agpl3' => 'AGPL 3', + 'all_feeds' => 'All feeds', 'allow_anonymous' => 'Allow anonymous reading of the articles of the default user (%s)', 'allow_anonymous_refresh' => 'Allow anonymous refresh of the articles', - 'all_feeds' => 'All feeds', 'already_subscribed' => 'You have already subscribed to %s', 'api_enabled' => 'Allow API access (required for mobile apps)', - 'Apr' => '\\A\\p\\r\\i\\l', 'apr' => 'apr', 'april' => 'Apr', 'archiving_configuration' => 'Archiving', 'archiving_configuration_help' => 'More options are available in the individual stream settings', 'article' => 'Article', - 'articles' => 'articles', - 'articles_per_page' => 'Number of articles per page', - 'articles_to_display' => 'Articles to display', 'article_icons' => 'Article icons', 'article_open_on_website' => 'when article is opened on its original website', 'article_published_on' => 'This article originally appeared on %s', 'article_published_on_author' => 'This article originally appeared on %s by %s', 'article_viewed' => 'when article is viewed', + 'articles' => 'articles', + 'articles_per_page' => 'Number of articles per page', + 'articles_to_display' => 'Articles to display', 'ask_empty' => 'Clear?', 'attention' => 'Attention!', - 'Aug' => '\\A\\u\\g\\u\\s\\t', 'aug' => 'aug', 'august' => 'Aug', - 'author' => 'Author', 'auth_form' => 'Web form (traditional, requires JavaScript)', 'auth_form_not_set' => 'A problem occured during authentication system configuration. Please retry later.', 'auth_form_set' => 'Form is now your default authentication system.', + 'auth_no_password_set' => 'Administrator password hasn’t been set. This feature isn’t available.', 'auth_none' => 'None (dangerous)', 'auth_not_persona' => 'Only Persona system can be reset.', - 'auth_no_password_set' => 'Administrator password hasn’t been set. This feature isn’t available.', 'auth_persona' => 'Mozilla Persona (modern, requires JavaScript)', 'auth_reset' => 'Authentication reset', 'auth_token' => 'Authentication token', 'auth_type' => 'Authentication method', 'auth_will_reset' => 'Authentication system will be reset: a form will be used instead of Persona.', + 'author' => 'Author', 'auto_load_more' => 'Load next articles at the page bottom', 'auto_read_when' => 'Mark article as read…', 'auto_share' => 'Share', @@ -105,9 +115,9 @@ 'bad_opml_file' => 'Your OPML file is invalid', 'base_url' => 'Base URL', 'bdd' => 'Database', - 'bdd_configuration' => 'Database configuration', 'bdd_conf_is_ko' => 'Verify your database information.', 'bdd_conf_is_ok' => 'Database configuration has been saved.', + 'bdd_configuration' => 'Database configuration', 'bdd_type' => 'Type of database', 'before_one_day' => 'Before one day', 'before_one_week' => 'Before one week', @@ -123,8 +133,8 @@ 'by_email' => 'By email', 'by_feed' => 'by feed', 'cache_is_ok' => 'Permissions on cache directory are good', - 'cancel' => 'Cancel', 'can_not_be_deleted' => 'Cannot be deleted', + 'cancel' => 'Cancel', 'categories' => 'Categories', 'categories_management' => 'Categories management', 'categories_updated' => 'Categories have been updated', @@ -135,10 +145,10 @@ 'category_emptied' => 'Category has been emptied', 'category_empty' => 'Empty category', 'category_name_exists' => 'Category name already exists.', - 'category_not_delete_default' => 'You cannot delete the default category!', - 'category_not_exist' => 'The category does not exist!', 'category_no_id' => 'You must precise the id of the category.', 'category_no_name' => 'Category name cannot be empty.', + 'category_not_delete_default' => 'You cannot delete the default category!', + 'category_not_exist' => 'The category does not exist!', 'category_number' => 'Category n°%d', 'category_updated' => 'Category has been updated.', 'change_value' => 'You should change this value by any other', @@ -165,7 +175,6 @@ 'current_user' => 'Current user', 'damn' => 'Damn!', 'data_is_ok' => 'Permissions on data directory are good', - 'Dec' => '\\D\\e\\c\\e\\m\\b\\e\\r', 'dec' => 'dec', 'december' => 'Dec', 'default_category' => 'Uncategorized', @@ -178,9 +187,9 @@ 'display_articles_unfolded' => 'Show articles unfolded by default', 'display_categories_unfolded' => 'Show categories folded by default', 'display_configuration' => 'Display', + 'do_not_change_if_doubt' => 'Don’t change if you doubt about it', 'dom_is_nok' => 'You lack a required library to browse the DOM (php-xml package)', 'dom_is_ok' => 'You have the required library to browse the DOM', - 'do_not_change_if_doubt' => 'Don’t change if you doubt about it', 'email' => 'Email', 'error_occurred' => 'An error occurred', 'error_occurred_update' => 'Nothing was changed', @@ -193,19 +202,8 @@ 'favicons_is_ok' => 'Permissions on favicons directory are good', 'favorite_feeds' => 'Favourites (%s)', 'feb' => 'feb', - 'Feb' => '\\F\\e\\b\\r\\u\\a\\r\\y', 'february' => 'Feb', 'feed' => 'Feed', - 'feedback.login.error' => 'Login is invalid', - 'feedback.login.success' => 'You are connected', - 'feedback.logout.success' => 'You are disconnected', - 'feedback.user_profile.updated' => 'Your profile has been modified', - 'feeds' => 'Feeds', - 'feeds_actualized' => 'RSS feeds have been updated', - 'feeds_imported' => 'Your feeds have been imported and will now be updated', - 'feeds_imported_with_errors' => 'Your feeds have been imported but some errors occurred', - 'feeds_marked_read' => 'Feeds have been marked as read', - 'feeds_moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under %s.', 'feed_actualized' => '%s has been updated', 'feed_added' => 'RSS feed %s has been added', 'feed_deleted' => 'Feed has been deleted', @@ -217,6 +215,16 @@ 'feed_updated' => 'Feed has been updated', 'feed_url' => 'Feed URL', 'feed_validator' => 'Check the validity of the feed', + 'feedback.login.error' => 'Login is invalid', + 'feedback.login.success' => 'You are connected', + 'feedback.logout.success' => 'You are disconnected', + 'feedback.user_profile.updated' => 'Your profile has been modified', + 'feeds' => 'Feeds', + 'feeds_actualized' => 'RSS feeds have been updated', + 'feeds_imported' => 'Your feeds have been imported and will now be updated', + 'feeds_imported_with_errors' => 'Your feeds have been imported but some errors occurred', + 'feeds_marked_read' => 'Feeds have been marked as read', + 'feeds_moved_category_deleted' => 'When you delete a category, their feeds are automatically classified under %s.', 'file_cannot_be_uploaded' => 'File cannot be uploaded!', 'file_is_nok' => 'Check permissions on %s directory. HTTP server must have rights to write into', 'file_to_import' => 'File to import
        (OPML, Json or Zip)', @@ -239,12 +247,13 @@ 'gen.menu.check_install' => 'Installation checking', 'gen.menu.user_management' => 'Manage users', 'gen.menu.user_profile' => 'Profile', + 'gen.title.authentication' => 'Authentication', 'gen.title.check_install' => 'Installation checking', 'gen.title.global_view' => 'Global view', 'gen.title.user_management' => 'Manage users', 'gen.title.user_profile' => 'Profile', - 'general_configuration' => 'General configuration', 'general_conf_is_ok' => 'General configuration has been saved.', + 'general_configuration' => 'General configuration', 'github_or_email' => 'on Github or by mail', 'global_view' => 'Global view', 'help' => 'Display documentation', @@ -261,24 +270,21 @@ 'import' => 'Import', 'import_export' => 'Import / export', 'informations' => 'Information', + 'install_not_deleted' => 'Something went wrong; you must delete the file %s manually.', 'installation_is_ok' => 'The installation process was successful.
        The final step will now attempt to delete any file and database backup created during the update process.
        You may choose to skip this step by deleting ./data/do-install.txt manually.', 'installation_step' => 'Installation — step %d · FreshRSS', - 'install_not_deleted' => 'Something went wrong; you must delete the file %s manually.', 'internal_problem_feed' => 'The RSS feed could not be added. Check FressRSS logs for details.', 'invalid_login' => 'Login is invalid', 'invalid_url' => 'URL %s is invalid', 'is_admin' => 'is administrator', - 'Jan' => '\\J\\a\\n\\u\\a\\r\\y', 'jan' => 'jan', 'january' => 'Jan', 'javascript_for_shortcuts' => 'JavaScript must be enabled in order to use shortcuts', 'javascript_is_better' => 'FreshRSS is more pleasant with JavaScript enabled', 'javascript_should_be_activated' => 'JavaScript must be enabled', 'jul' => 'jul', - 'Jul' => '\\J\\u\\l\\y', 'july' => 'Jul', 'jump_next' => 'jump to next unread sibling (feed or category)', - 'Jun' => '\\J\\u\\n\\e', 'jun' => 'jun', 'june' => 'Jun', 'keep_history' => 'Minimum number of articles to keep', @@ -295,6 +301,7 @@ 'lead_developer' => 'Lead developer', 'license' => 'License', 'load_more' => 'Load more articles', + 'log_is_ok' => 'Permissions on logs directory are good', 'login' => 'Login', 'login_configuration' => 'Login', 'login_persona_problem' => 'Connection problem with Persona?', @@ -303,41 +310,30 @@ 'logout' => 'Logout', 'logs' => 'Logs', 'logs_empty' => 'Log file is empty', - 'log_is_ok' => 'Permissions on logs directory are good', 'main_stream' => 'Main stream', 'mar' => 'mar', - 'Mar' => '\\M\\a\\r\\c\\h', 'march' => 'Mar', 'mark_all_read' => 'Mark all as read', 'mark_cat_read' => 'Mark category as read', 'mark_favorite' => 'Mark as favourite', 'mark_feed_read' => 'Mark feed as read', 'mark_read' => 'Mark as read', - 'May' => '\\M\\a\\y', 'may' => 'May', 'minz_is_nok' => 'You lack the Minz framework. You should execute build.sh script or download it on Github and install in %s directory the content of its /lib directory.', 'minz_is_ok' => 'You have the Minz framework', 'mon' => 'Mon', 'month' => 'months', 'more_information' => 'More information', - 'newer_first' => 'Newer first', + 'n_entries_deleted' => '%d articles have been deleted', + 'n_feeds_actualized' => '%d feeds have been updated', 'new_article' => 'There are new available articles, click to refresh the page.', 'new_category' => 'New category', + 'newer_first' => 'Newer first', 'next' => 'Next', 'next_article' => 'Skip to the next article', 'next_page' => 'Skip to the next page', 'next_step' => 'Go to the next step', 'no' => 'No', - 'normal_view' => 'Normal view', - 'nothing_to_load' => 'There are no more articles', - 'notif_body_new_articles' => 'There are \\d new articles to read on FreshRSS.', - 'notif_title_new_articles' => 'FreshRSS: new articles!', - 'not_read' => '%d unread', - 'not_reads' => '%d unread', - 'not_yet_implemented' => 'Not yet implemented', - 'Nov' => '\\N\\o\\v\\e\\m\\b\\e\\r', - 'nov' => 'nov', - 'november' => 'Nov', 'no_feed_actualized' => 'No RSS feed has been updated', 'no_feed_to_display' => 'There is no article to show.', 'no_feed_to_refresh' => 'There is no feed to refresh…', @@ -347,12 +343,18 @@ 'no_selected_feed' => 'No feed selected.', 'no_update' => 'No update to apply', 'no_zip_extension' => 'Zip extension is not present on your server.', + 'normal_view' => 'Normal view', + 'not_read' => '%d unread', + 'not_reads' => '%d unread', + 'not_yet_implemented' => 'Not yet implemented', + 'nothing_to_load' => 'There are no more articles', + 'notif_body_new_articles' => 'There are \\d new articles to read on FreshRSS.', + 'notif_title_new_articles' => 'FreshRSS: new articles!', + 'nov' => 'nov', + 'november' => 'Nov', 'number_articles' => '%d articles', 'number_divided_when_reader' => 'Divided by 2 in the reading view.', 'number_feeds' => '%d feeds', - 'n_entries_deleted' => '%d articles have been deleted', - 'n_feeds_actualized' => '%d feeds have been updated', - 'Oct' => '\\O\\c\\t\\o\\b\\e\\r', 'oct' => 'oct', 'october' => 'Oct', 'ok' => 'Ok!', @@ -419,8 +421,8 @@ 'refresh' => 'Refresh', 'related_tags' => 'Related tags', 'retrieve_truncated_feeds' => 'Retrieves truncated RSS feeds (attention, requires more time!)', - 'rss_feeds_of' => 'RSS feed of %s', 'rss_feed_management' => 'RSS feeds management', + 'rss_feeds_of' => 'RSS feed of %s', 'rss_view' => 'RSS feed', 'sat' => 'Sat', 'save' => 'Save', @@ -431,7 +433,6 @@ 'see_on_website' => 'See on original website', 'see_website' => 'See website', 'sep' => 'sep', - 'Sep' => '\\S\\e\\p\\t\\e\\m\\b\\e\\r', 'september' => 'Sep', 'shaarli' => 'Shaarli', 'share' => 'Share', @@ -492,7 +493,6 @@ 'twitter' => 'Twitter', 'unsafe_autologin' => 'Allow unsafe automatic login using the format: ', 'update' => 'Update', - 'updated' => 'Modifications have been updated', 'update_apply' => 'Apply', 'update_can_apply' => 'An update is available.', 'update_check' => 'Check for new updates', @@ -504,15 +504,16 @@ 'update_server_not_found' => 'Update server cannot be found. [%s]', 'update_start' => 'Start update process', 'update_system' => 'Update system', + 'updated' => 'Modifications have been updated', 'upon_reception' => 'upon reception of the article', - 'username' => 'Username', - 'username_admin' => 'Administrator username', - 'users' => 'Users', - 'users_list' => 'List of users', 'user_created' => 'User %s has been created', 'user_deleted' => 'User %s has been deleted', 'user_filter' => 'Access user filters', 'user_filter_help' => 'If there is only one user filter, it is used. Else filters are accessible by their number.', + 'username' => 'Username', + 'username_admin' => 'Administrator username', + 'users' => 'Users', + 'users_list' => 'List of users', 'version' => 'Version', 'version_update' => 'Update', 'wallabag' => 'wallabag', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index e3a49d54c..61a84cc04 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -1,5 +1,17 @@ '\\a\\v\\r\\i\\l', + 'Aug' => '\\a\\o\\û\\t', + 'Dec' => '\\d\\é\\c\\e\\m\\b\\r\\e', + 'Feb' => '\\f\\é\\v\\r\\i\\e\\r', + 'Jan' => '\\j\\a\\n\\v\\i\\e\\r', + 'Jul' => '\\j\\u\\i\\l\\l\\e\\t', + 'Jun' => '\\j\\u\\i\\n', + 'Mar' => '\\m\\a\\r\\s', + 'May' => '\\m\\a\\i', + 'Nov' => '\\n\\o\\v\\e\\m\\b\\r\\e', + 'Oct' => '\\o\\c\\t\\o\\b\\r\\e', + 'Sep' => '\\s\\e\\p\\t\\e\\m\\b\\r\\e', 'about' => 'À propos', 'about_freshrss' => 'À propos de FreshRSS', 'access_denied' => 'Vous n’avez pas le droit d’accéder à cette page !', @@ -61,42 +73,40 @@ 'advanced' => 'Avancé', 'after_onread' => 'Après “marquer tout comme lu”,', 'agpl3' => 'AGPL 3', + 'all_feeds' => 'Tous les flux', 'allow_anonymous' => 'Autoriser la lecture anonyme des articles de l’utilisateur par défaut (%s)', 'allow_anonymous_refresh' => 'Autoriser le rafraîchissement anonyme des flux', - 'all_feeds' => 'Tous les flux', 'already_subscribed' => 'Vous êtes déjà abonné à %s', 'api_enabled' => 'Autoriser l’accès par API (nécessaire pour les applis mobiles)', - 'Apr' => '\\a\\v\\r\\i\\l', 'apr' => 'avr.', 'april' => 'avril', 'archiving_configuration' => 'Archivage', 'archiving_configuration_help' => 'D’autres options sont disponibles dans la configuration individuelle des flux.', 'article' => 'Article', - 'articles' => 'articles', - 'articles_per_page' => 'Nombre d’articles par page', - 'articles_to_display' => 'Articles à afficher', 'article_icons' => 'Icônes d’article', 'article_open_on_website' => 'lorsque l’article est ouvert sur le site d’origine', 'article_published_on' => 'Article publié initialement sur %s', 'article_published_on_author' => 'Article publié initialement sur %s par %s', 'article_viewed' => 'lorsque l’article est affiché', + 'articles' => 'articles', + 'articles_per_page' => 'Nombre d’articles par page', + 'articles_to_display' => 'Articles à afficher', 'ask_empty' => 'Vider ?', 'attention' => 'Attention !', - 'Aug' => '\\a\\o\\û\\t', 'aug' => 'août', 'august' => 'août', - 'author' => 'Auteur', 'auth_form' => 'Formulaire (traditionnel, requiert JavaScript)', 'auth_form_not_set' => 'Un problème est survenu lors de la configuration de votre système d’authentification. Veuillez réessayer plus tard.', 'auth_form_set' => 'Le formulaire est désormais votre système d’authentification.', + 'auth_no_password_set' => 'Aucun mot de passe administrateur n’a été précisé. Cette fonctionnalité n’est pas disponible.', 'auth_none' => 'Aucune (dangereux)', 'auth_not_persona' => 'Seul le système d’authentification Persona peut être réinitialisé.', - 'auth_no_password_set' => 'Aucun mot de passe administrateur n’a été précisé. Cette fonctionnalité n’est pas disponible.', 'auth_persona' => 'Mozilla Persona (moderne, requiert JavaScript)', 'auth_reset' => 'Réinitialisation de l’authentification', 'auth_token' => 'Jeton d’identification', 'auth_type' => 'Méthode d’authentification', 'auth_will_reset' => 'Le système d’authentification va être réinitialisé : un formulaire sera utilisé à la place de Persona.', + 'author' => 'Auteur', 'auto_load_more' => 'Charger les articles suivants en bas de page', 'auto_read_when' => 'Marquer un article comme lu…', 'auto_share' => 'Partager', @@ -105,9 +115,9 @@ 'bad_opml_file' => 'Votre fichier OPML n’est pas valide.', 'base_url' => 'Base de l’URL', 'bdd' => 'Base de données', - 'bdd_configuration' => 'Base de données', 'bdd_conf_is_ko' => 'Vérifiez les informations d’accès à la base de données.', 'bdd_conf_is_ok' => 'La configuration de la base de données a été enregistrée.', + 'bdd_configuration' => 'Base de données', 'bdd_type' => 'Type de base de données', 'before_one_day' => 'Antérieurs à 1 jour', 'before_one_week' => 'Antérieurs à 1 semaine', @@ -123,8 +133,8 @@ 'by_email' => 'Par courriel', 'by_feed' => 'par flux', 'cache_is_ok' => 'Les droits sur le répertoire de cache sont bons', - 'cancel' => 'Annuler', 'can_not_be_deleted' => 'Ne peut pas être supprimée.', + 'cancel' => 'Annuler', 'categories' => 'Catégories', 'categories_management' => 'Gestion des catégories', 'categories_updated' => 'Les catégories ont été mises à jour.', @@ -135,10 +145,10 @@ 'category_emptied' => 'La catégorie a été vidée.', 'category_empty' => 'Catégorie vide', 'category_name_exists' => 'Une catégorie possède déjà ce nom.', - 'category_not_delete_default' => 'Vous ne pouvez pas supprimer la catégorie par défaut !', - 'category_not_exist' => 'Cette catégorie n’existe pas !', 'category_no_id' => 'Vous devez préciser l’id de la catégorie.', 'category_no_name' => 'Vous devez préciser un nom pour la catégorie.', + 'category_not_delete_default' => 'Vous ne pouvez pas supprimer la catégorie par défaut !', + 'category_not_exist' => 'Cette catégorie n’existe pas !', 'category_number' => 'Catégorie n°%d', 'category_updated' => 'La catégorie a été mise à jour.', 'change_value' => 'Vous devriez changer cette valeur par n’importe quelle autre', @@ -165,7 +175,6 @@ 'current_user' => 'Utilisateur actuel', 'damn' => 'Arf !', 'data_is_ok' => 'Les droits sur le répertoire de data sont bons', - 'Dec' => '\\d\\é\\c\\e\\m\\b\\r\\e', 'dec' => 'déc.', 'december' => 'décembre', 'default_category' => 'Sans catégorie', @@ -178,9 +187,9 @@ 'display_articles_unfolded' => 'Afficher les articles dépliés par défaut', 'display_categories_unfolded' => 'Afficher les catégories pliées par défaut', 'display_configuration' => 'Affichage', + 'do_not_change_if_doubt' => 'Laissez tel quel dans le doute', 'dom_is_nok' => 'Il manque une librairie pour parcourir le DOM (paquet php-xml)', 'dom_is_ok' => 'Vous disposez du nécessaire pour parcourir le DOM', - 'do_not_change_if_doubt' => 'Laissez tel quel dans le doute', 'email' => 'Courriel', 'error_occurred' => 'Une erreur est survenue !', 'error_occurred_update' => 'Rien n’a été modifié !', @@ -193,19 +202,8 @@ 'favicons_is_ok' => 'Les droits sur le répertoire des favicons sont bons', 'favorite_feeds' => 'Favoris (%s)', 'feb' => 'fév.', - 'Feb' => '\\f\\é\\v\\r\\i\\e\\r', 'february' => 'février', 'feed' => 'Flux', - 'feedback.login.error' => 'L’identifiant est invalide !', - 'feedback.login.success' => 'Vous êtes désormais connecté', - 'feedback.logout.success' => 'Vous avez été déconnecté', - 'feedback.user_profile.updated' => 'Votre profil a été mis à jour', - 'feeds' => 'Flux', - 'feeds_actualized' => 'Les flux ont été mis à jour.', - 'feeds_imported' => 'Vos flux ont été importés et vont maintenant être actualisés.', - 'feeds_imported_with_errors' => 'Vos flux ont été importés mais des erreurs sont survenues.', - 'feeds_marked_read' => 'Les flux ont été marqués comme lus.', - 'feeds_moved_category_deleted' => 'Lors de la suppression d’une catégorie, ses flux seront automatiquement classés dans %s.', 'feed_actualized' => '%s a été mis à jour.', 'feed_added' => 'Le flux %s a bien été ajouté.', 'feed_deleted' => 'Le flux a été supprimé.', @@ -217,6 +215,16 @@ 'feed_updated' => 'Le flux a été mis à jour.', 'feed_url' => 'URL du flux', 'feed_validator' => 'Vérifier la valididé du flux', + 'feedback.login.error' => 'L’identifiant est invalide !', + 'feedback.login.success' => 'Vous êtes désormais connecté', + 'feedback.logout.success' => 'Vous avez été déconnecté', + 'feedback.user_profile.updated' => 'Votre profil a été mis à jour', + 'feeds' => 'Flux', + 'feeds_actualized' => 'Les flux ont été mis à jour.', + 'feeds_imported' => 'Vos flux ont été importés et vont maintenant être actualisés.', + 'feeds_imported_with_errors' => 'Vos flux ont été importés mais des erreurs sont survenues.', + 'feeds_marked_read' => 'Les flux ont été marqués comme lus.', + 'feeds_moved_category_deleted' => 'Lors de la suppression d’une catégorie, ses flux seront automatiquement classés dans %s.', 'file_cannot_be_uploaded' => 'Le fichier ne peut pas être téléchargé !', 'file_is_nok' => 'Veuillez vérifier les droits sur le répertoire %s. Le serveur HTTP doit être capable d’écrire dedans', 'file_to_import' => 'Fichier à importer
        (OPML, Json ou Zip)', @@ -239,12 +247,13 @@ 'gen.menu.check_install' => 'Vérification de l\'installation', 'gen.menu.user_management' => 'Gestion des utilisateurs', 'gen.menu.user_profile' => 'Profil', + 'gen.title.authentication' => 'Authentification', 'gen.title.check_install' => 'Vérification de l\'installation', 'gen.title.global_view' => 'Vue globale', 'gen.title.user_management' => 'Gestion des utilisateurs', 'gen.title.user_profile' => 'Profil', - 'general_configuration' => 'Configuration générale', 'general_conf_is_ok' => 'La configuration générale a été enregistrée.', + 'general_configuration' => 'Configuration générale', 'github_or_email' => 'sur Github ou par courriel', 'global_view' => 'Vue globale', 'help' => 'Afficher la documentation', @@ -261,24 +270,21 @@ 'import' => 'Importer', 'import_export' => 'Importer / exporter', 'informations' => 'Informations', + 'install_not_deleted' => 'Quelque chose s’est mal passé, vous devez supprimer le fichier %s à la main.', 'installation_is_ok' => 'L’installation s’est bien passée.
        La dernière étape va maintenant tenter de supprimer les fichiers ainsi que d’éventuelles copies de base de données créés durant le processus de mise à jour.
        Vous pouvez choisir de sauter cette étape en supprimant ./data/do-install.txt manuellement.', 'installation_step' => 'Installation — étape %d · FreshRSS', - 'install_not_deleted' => 'Quelque chose s’est mal passé, vous devez supprimer le fichier %s à la main.', 'internal_problem_feed' => 'Le flux ne peut pas être ajouté. Consulter les logs de FreshRSS pour plus de détails.', 'invalid_login' => 'L’identifiant est invalide !', 'invalid_url' => 'L’url %s est invalide.', 'is_admin' => 'est administrateur', - 'Jan' => '\\j\\a\\n\\v\\i\\e\\r', 'jan' => 'jan.', 'january' => 'janvier', 'javascript_for_shortcuts' => 'Le JavaScript doit être activé pour pouvoir profiter des raccourcis.', 'javascript_is_better' => 'FreshRSS est plus agréable à utiliser avec JavaScript activé', 'javascript_should_be_activated' => 'Le JavaScript doit être activé.', 'jul' => 'jui.', - 'Jul' => '\\j\\u\\i\\l\\l\\e\\t', 'july' => 'juillet', 'jump_next' => 'sauter au prochain voisin non lu (flux ou catégorie)', - 'Jun' => '\\j\\u\\i\\n', 'jun' => 'juin', 'june' => 'juin', 'keep_history' => 'Nombre minimum d’articles à conserver', @@ -295,6 +301,7 @@ 'lead_developer' => 'Développeur principal', 'license' => 'Licence', 'load_more' => 'Charger plus d’articles', + 'log_is_ok' => 'Les droits sur le répertoire des logs sont bons', 'login' => 'Connexion', 'login_configuration' => 'Identification', 'login_persona_problem' => 'Problème de connexion à Persona ?', @@ -303,41 +310,30 @@ 'logout' => 'Déconnexion', 'logs' => 'Logs', 'logs_empty' => 'Les logs sont vides.', - 'log_is_ok' => 'Les droits sur le répertoire des logs sont bons', 'main_stream' => 'Flux principal', 'mar' => 'mar.', - 'Mar' => '\\m\\a\\r\\s', 'march' => 'mars', 'mark_all_read' => 'Tout marquer comme lu', 'mark_cat_read' => 'Marquer la catégorie comme lue', 'mark_favorite' => 'Mettre en favori', 'mark_feed_read' => 'Marquer le flux comme lu', 'mark_read' => 'Marquer comme lu', - 'May' => '\\m\\a\\i', 'may' => 'mai.', 'minz_is_nok' => 'Vous ne disposez pas de la librairie Minz. Vous devriez exécuter le script build.sh ou bien la télécharger sur Github et installer dans le répertoire %s le contenu de son répertoire /lib.', 'minz_is_ok' => 'Vous disposez du framework Minz', 'mon' => 'lun.', 'month' => 'mois', 'more_information' => 'Plus d’informations', - 'newer_first' => 'Plus récents en premier', + 'n_entries_deleted' => '%d articles ont été supprimés.', + 'n_feeds_actualized' => '%d flux ont été mis à jour.', 'new_article' => 'Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.', 'new_category' => 'Nouvelle catégorie', + 'newer_first' => 'Plus récents en premier', 'next' => 'Suivant', 'next_article' => 'Passer à l’article suivant', 'next_page' => 'Passer à la page suivante', 'next_step' => 'Passer à l’étape suivante', 'no' => 'Non', - 'normal_view' => 'Vue normale', - 'nothing_to_load' => 'Fin des articles', - 'notif_body_new_articles' => 'Il y a \\d nouveaux articles à lire sur FreshRSS.', - 'notif_title_new_articles' => 'FreshRSS : nouveaux articles !', - 'not_read' => '%d non lu', - 'not_reads' => '%d non lus', - 'not_yet_implemented' => 'Pas encore implémenté', - 'Nov' => '\\n\\o\\v\\e\\m\\b\\r\\e', - 'nov' => 'nov.', - 'november' => 'novembre', 'no_feed_actualized' => 'Aucun flux n’a pu être mis à jour.', 'no_feed_to_display' => 'Il n’y a aucun article à afficher.', 'no_feed_to_refresh' => 'Il n’y a aucun flux à actualiser…', @@ -347,12 +343,18 @@ 'no_selected_feed' => 'Aucun flux sélectionné.', 'no_update' => 'Aucune mise à jour à appliquer', 'no_zip_extension' => 'L’extension Zip n’est pas présente sur votre serveur.', + 'normal_view' => 'Vue normale', + 'not_read' => '%d non lu', + 'not_reads' => '%d non lus', + 'not_yet_implemented' => 'Pas encore implémenté', + 'nothing_to_load' => 'Fin des articles', + 'notif_body_new_articles' => 'Il y a \\d nouveaux articles à lire sur FreshRSS.', + 'notif_title_new_articles' => 'FreshRSS : nouveaux articles !', + 'nov' => 'nov.', + 'november' => 'novembre', 'number_articles' => '%d articles', 'number_divided_when_reader' => 'Divisé par 2 dans la vue de lecture.', 'number_feeds' => '%d flux', - 'n_entries_deleted' => '%d articles ont été supprimés.', - 'n_feeds_actualized' => '%d flux ont été mis à jour.', - 'Oct' => '\\o\\c\\t\\o\\b\\r\\e', 'oct' => 'oct.', 'october' => 'octobre', 'ok' => 'Ok !', @@ -419,8 +421,8 @@ 'refresh' => 'Actualisation', 'related_tags' => 'Tags associés', 'retrieve_truncated_feeds' => 'Permet de récupérer les flux tronqués (attention, demande plus de temps !)', - 'rss_feeds_of' => 'Flux RSS de %s', 'rss_feed_management' => 'Gestion des flux RSS', + 'rss_feeds_of' => 'Flux RSS de %s', 'rss_view' => 'Flux RSS', 'sat' => 'sam.', 'save' => 'Enregistrer', @@ -431,7 +433,6 @@ 'see_on_website' => 'Voir sur le site d’origine', 'see_website' => 'Voir le site', 'sep' => 'sep.', - 'Sep' => '\\s\\e\\p\\t\\e\\m\\b\\r\\e', 'september' => 'septembre', 'shaarli' => 'Shaarli', 'share' => 'Partager', @@ -492,7 +493,6 @@ 'twitter' => 'Twitter', 'unsafe_autologin' => 'Autoriser les connexions automatiques non-sûres au format : ', 'update' => 'Mise à jour', - 'updated' => 'Modifications enregistrées.', 'update_apply' => 'Appliquer la mise à jour', 'update_can_apply' => 'Une mise à jour est disponible.', 'update_check' => 'Vérifier les mises à jour', @@ -504,15 +504,16 @@ 'update_server_not_found' => 'Le serveur de mise à jour n’a pas été trouvé. [%s]', 'update_start' => 'Lancer la mise à jour', 'update_system' => 'Système de mise à jour', + 'updated' => 'Modifications enregistrées.', 'upon_reception' => 'dès la réception du nouvel article', - 'username' => 'Nom d’utilisateur', - 'username_admin' => 'Nom d’utilisateur administrateur', - 'users' => 'Utilisateurs', - 'users_list' => 'Liste des utilisateurs', 'user_created' => 'L’utilisateur %s a été créé.', 'user_deleted' => 'L’utilisateur %s a été supprimé.', 'user_filter' => 'Accéder aux filtres utilisateur', 'user_filter_help' => 'S’il n’y a qu’un filtre utilisateur, celui-ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.', + 'username' => 'Nom d’utilisateur', + 'username_admin' => 'Nom d’utilisateur administrateur', + 'users' => 'Utilisateurs', + 'users_list' => 'Liste des utilisateurs', 'version' => 'Version', 'version_update' => 'Mise à jour', 'wallabag' => 'wallabag', -- cgit v1.2.3 From c6f35ef51c2c536efb4f8e73603ae46b8512cc24 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 27 Oct 2014 21:45:30 +0100 Subject: Global limits for number of feeds and categories New 'limits' sub-array in config.php with 'max_feeds' and 'max_categories'. If the values are < 0, then it is the default value (16384). https://github.com/marienfressinaud/FreshRSS/issues/680 --- app/Controllers/categoryController.php | 7 +++++++ app/Controllers/feedController.php | 7 +++++++ lib/Minz/Configuration.php | 26 ++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 977ce51be..ef8af7ed6 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -33,6 +33,13 @@ class FreshRSS_category_Controller extends Minz_ActionController { $catDAO = new FreshRSS_CategoryDAO(); $url_redirect = array('c' => 'subscription', 'a' => 'index'); + $limits = Minz_Configuration::limits(); + $this->view->categories = $catDAO->listCategories(false); + if (count($this->view->categories) >= $limits['max_categories']) { + Minz_Request::bad(_t('over_max_categories', $limits['max_categories']), $url_redirect); + return; + } + if (Minz_Request::isPost()) { invalidateHttpCache(); diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c2859edf4..39e4b5761 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -68,6 +68,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController { 'params' => array(), ); + $limits = Minz_Configuration::limits(); + $this->view->feeds = $feedDAO->listFeeds(); + if (count($this->view->feeds) >= $limits['max_feeds']) { + Minz_Request::bad(_t('over_max_feeds', $limits['max_feeds']), $url_redirect); + return; + } + if (Minz_Request::isPost()) { @set_time_limit(300); diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 554bc8c96..fe9ea6b2e 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -60,6 +60,12 @@ class Minz_Configuration { 'prefix' => '', ); + const MAX_SMALL_INT = 16384; + private static $limits = array( + 'max_feeds' => Minz_Configuration::MAX_SMALL_INT, + 'max_categories' => Minz_Configuration::MAX_SMALL_INT, + ); + /* * Getteurs */ @@ -97,6 +103,9 @@ class Minz_Configuration { public static function dataBase () { return self::$db; } + public static function limits() { + return self::$limits; + } public static function defaultUser () { return self::$default_user; } @@ -178,6 +187,7 @@ class Minz_Configuration { 'api_enabled' => self::$api_enabled, 'unsafe_autologin_enabled' => self::$unsafe_autologin_enabled, ), + 'limits' => self::$limits, 'db' => self::$db, ); @rename(DATA_PATH . self::CONF_PATH_NAME, DATA_PATH . self::CONF_PATH_NAME . '.bak.php'); @@ -291,6 +301,22 @@ class Minz_Configuration { ); } + if (isset($ini_array['limits'])) { + $limits = $ini_array['limits']; + if (isset($limits['max_feeds'])) { + self::$limits['max_feeds'] = intval($limits['max_feeds']); + if (self::$limits['max_feeds'] < 0 || self::$limits['max_feeds'] > Minz_Configuration::MAX_SMALL_INT) { + self::$limits['max_feeds'] = Minz_Configuration::MAX_SMALL_INT; + } + } + if (isset($limits['max_categories'])) { + self::$limits['max_categories'] = intval($limits['max_categories']); + if (self::$limits['max_categories'] < 0 || self::$limits['max_categories'] > Minz_Configuration::MAX_SMALL_INT) { + self::$limits['max_categories'] = Minz_Configuration::MAX_SMALL_INT; + } + } + } + // Base de données if (isset ($ini_array['db'])) { $db = $ini_array['db']; -- cgit v1.2.3 From 4cbd7e0583709912d790ed04a72b75d79da31b73 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 28 Oct 2014 23:32:55 +0100 Subject: Bug: unlock was not done for feeds with error --- app/Controllers/feedController.php | 1 + 1 file changed, 1 insertion(+) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 39e4b5761..7ac083d56 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -293,6 +293,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } catch (FreshRSS_Feed_Exception $e) { Minz_Log::notice($e->getMessage()); $feedDAO->updateLastUpdate($feed->id(), 1); + $feed->unlock(); continue; } -- cgit v1.2.3 From 9f97f7df8822ed2f32a9bc9d46ece92dee93089c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 29 Oct 2014 00:45:42 +0100 Subject: Ne pas rafraîchir les flux des utilisateurs non logués depuis x jours MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/marienfressinaud/FreshRSS/issues/681 Warning: needs some testing --- CHANGELOG | 2 +- app/Controllers/userController.php | 3 +-- app/Models/Auth.php | 13 +++++-------- app/Models/UserDAO.php | 10 +++++++++- app/actualize_script.php | 10 ++++++++++ lib/Minz/Configuration.php | 7 +++++++ 6 files changed, 33 insertions(+), 12 deletions(-) (limited to 'app/Controllers') diff --git a/CHANGELOG b/CHANGELOG index 688a286e3..a556fcc13 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,7 @@ ## * Configuration - * New options in config.php for cache duration, timeout, max number of feeds and categories per user. + * New options in config.php for cache duration, timeout, max inactivity, max number of feeds and categories per user. ## 2014-09-26 FreshRSS 0.8.0 / 0.9.0 (beta) diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 2343520ca..39db1d879 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -95,9 +95,8 @@ class FreshRSS_user_Controller extends Minz_ActionController { Minz_View::prependTitle(_t('gen.title.user_management') . ' · '); // Get the correct current user. - $userDAO = new FreshRSS_UserDAO(); $username = Minz_Request::param('u', Minz_Session::param('currentUser')); - if (!$userDAO->exist($username)) { + if (!FreshRSS_UserDAO::exist($username)) { $username = Minz_Session::param('currentUser'); } $this->view->current_user = $username; diff --git a/app/Models/Auth.php b/app/Models/Auth.php index cc23d7974..2971d65c8 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -20,10 +20,11 @@ class FreshRSS_Auth { Minz_Session::_param('currentUser', $current_user); } - $access_ok = self::accessControl(); - - if ($access_ok) { + if (self::$login_ok) { self::giveAccess(); + } elseif (self::accessControl()) { + self::giveAccess(); + FreshRSS_UserDAO::touch($current_user); } else { // Be sure all accesses are removed! self::removeAccess(); @@ -38,11 +39,7 @@ class FreshRSS_Auth { * * @return boolean true if user can be connected, false else. */ - public static function accessControl() { - if (self::$login_ok) { - return true; - } - + private static function accessControl() { switch (Minz_Configuration::authType()) { case 'form': $credentials = FreshRSS_FormAuth::getCredentialsFromCookie(); diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 85b45c4a7..60fca71b1 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -54,7 +54,15 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { } } - public function exist($username) { + public static function exist($username) { return file_exists(DATA_PATH . '/' . $username . '_user.php'); } + + public static function touch($username) { + return touch(DATA_PATH . '/' . $username . '_user.php'); + } + + public static function mtime($username) { + return @filemtime(DATA_PATH . '/' . $username . '_user.php'); + } } diff --git a/app/actualize_script.php b/app/actualize_script.php index 9fe499cc9..6ce4178cd 100755 --- a/app/actualize_script.php +++ b/app/actualize_script.php @@ -22,7 +22,17 @@ if (Minz_Configuration::defaultUser() !== ''){ $users = array_unique($users); } +$limits = Minz_Configuration::limits(); +$minLastActivity = time() - $limits['max_inactivity']; + foreach ($users as $myUser) { + if (($myUser !== Minz_Configuration::defaultUser()) && (FreshRSS_UserDAO::mtime($myUser) < $minLastActivity)) { + syslog(LOG_INFO, 'FreshRSS skip inactive user ' . $myUser); + if (defined('STDOUT')) { + fwrite(STDOUT, 'FreshRSS skip inactive user ' . $myUser . "\n"); //Unbuffered + } + continue; + } syslog(LOG_INFO, 'FreshRSS actualize ' . $myUser); if (defined('STDOUT')) { fwrite(STDOUT, 'Actualize ' . $myUser . "...\n"); //Unbuffered diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 9511cb357..6cbc9fc0b 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -64,6 +64,7 @@ class Minz_Configuration { private static $limits = array( 'cache_duration' => 800, //SimplePie cache duration in seconds 'timeout' => 10, //SimplePie timeout in seconds + 'max_inactivity' => PHP_INT_MAX, //Time in seconds after which a user who has not used the account is considered inactive (no auto-refresh of feeds). 'max_feeds' => Minz_Configuration::MAX_SMALL_INT, 'max_categories' => Minz_Configuration::MAX_SMALL_INT, ); @@ -317,6 +318,12 @@ class Minz_Configuration { self::$limits['timeout'] = $v; } } + if (isset($limits['max_inactivity'])) { + $v = intval($limits['max_inactivity']); + if ($v > 0) { + self::$limits['max_inactivity'] = $v; + } + } if (isset($limits['max_feeds'])) { $v = intval($limits['max_feeds']); if ($v > 0 && $v < Minz_Configuration::MAX_SMALL_INT) { -- cgit v1.2.3 From 1ea996c4eaa0f07f4fd906e7cade68a9bee3b11d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 29 Oct 2014 10:15:22 +0100 Subject: Update i18n for limit of category. --- app/Controllers/categoryController.php | 5 +++-- app/i18n/en.php | 5 +---- app/i18n/fr.php | 5 +---- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index ef8af7ed6..609284559 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -35,9 +35,10 @@ class FreshRSS_category_Controller extends Minz_ActionController { $limits = Minz_Configuration::limits(); $this->view->categories = $catDAO->listCategories(false); + if (count($this->view->categories) >= $limits['max_categories']) { - Minz_Request::bad(_t('over_max_categories', $limits['max_categories']), $url_redirect); - return; + Minz_Request::bad(_t('sub.categories.over_max', $limits['max_categories']), + $url_redirect); } if (Minz_Request::isPost()) { diff --git a/app/i18n/en.php b/app/i18n/en.php index 1e6621c12..2c61d822d 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -53,10 +53,6 @@ 'admin.check_install.pcre.ok' => 'You have the required library for regular expressions (PCRE).', 'admin.check_install.pdo.nok' => 'You lack PDO or one of the supported drivers (pdo_mysql, pdo_sqlite).', 'admin.check_install.pdo.ok' => 'You have PDO and at least one of the supported drivers (pdo_mysql, pdo_sqlite).', - 'admin.check_install.pdo_mysql.nok' => 'You lack PDO for MySQL (it\'s ok if PDO is good).', - 'admin.check_install.pdo_mysql.ok' => 'You have PDO for MySQL.', - 'admin.check_install.pdo_sqlite.nok' => 'You lack PDO for SQLite (it\'s ok if PDO is good).', - 'admin.check_install.pdo_sqlite.ok' => 'You have PDO for SQLite.', 'admin.check_install.persona.nok' => 'Check permissions on ./data/persona directory. HTTP server must have rights to write into', 'admin.check_install.persona.ok' => 'Permissions on Mozilla Persona directory are good.', 'admin.check_install.php' => 'PHP installation', @@ -477,6 +473,7 @@ 'status_unread' => 'Unread', 'steps' => 'Steps', 'sticky_post' => 'Stick the article to the top when opened', + 'sub.categories.over_max' => 'You have reached your limit of categories (%d)', 'submit' => 'Submit', 'subscription_management' => 'Subscriptions management', 'sun' => 'Sun', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 61a84cc04..2420b20c3 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -53,10 +53,6 @@ 'admin.check_install.pcre.ok' => 'Vous disposez du nécessaire pour les expressions régulières (PCRE).', 'admin.check_install.pdo.nok' => 'Vous ne disposez pas de PDO ou d’un des drivers supportés (pdo_mysql, pdo_sqlite).', 'admin.check_install.pdo.ok' => 'Vous disposez de PDO et d’au moins un des drivers supportés (pdo_mysql, pdo_sqlite).', - 'admin.check_install.pdo_mysql.nok' => 'Vous ne possédez pas PDO pour MySQL (ok si PDO est bon).', - 'admin.check_install.pdo_mysql.ok' => 'Vous possédez PDO pour MySQL.', - 'admin.check_install.pdo_sqlite.nok' => 'Vous ne possédez pas PDO pour SQLite (ok si PDO est bon).', - 'admin.check_install.pdo_sqlite.ok' => 'Vous possédez PDO pour SQLite.', 'admin.check_install.persona.nok' => 'Veuillez vérifier les droits sur le répertoire ./data/persona. Le serveur HTTP doit être capable d’écrire dedans', 'admin.check_install.persona.ok' => 'Les droits sur le répertoire de Mozilla Persona sont bons.', 'admin.check_install.php' => 'Installation de PHP', @@ -477,6 +473,7 @@ 'status_unread' => 'non lus', 'steps' => 'Étapes', 'sticky_post' => 'Aligner l’article en haut quand il est ouvert', + 'sub.categories.over_max' => 'Vous avez atteint votre limite de catégories (%d)', 'submit' => 'Valider', 'subscription_management' => 'Gestion des abonnements', 'sun' => 'dim.', -- cgit v1.2.3 From cf7350af4768809c8b5117ba586f5165a4e2b1a8 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 29 Oct 2014 10:21:34 +0100 Subject: Update i18n for limit of feeds See https://github.com/marienfressinaud/FreshRSS/issues/680 --- app/Controllers/feedController.php | 4 ++-- app/i18n/en.php | 1 + app/i18n/fr.php | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 7ac083d56..8563b1c0f 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -71,8 +71,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $limits = Minz_Configuration::limits(); $this->view->feeds = $feedDAO->listFeeds(); if (count($this->view->feeds) >= $limits['max_feeds']) { - Minz_Request::bad(_t('over_max_feeds', $limits['max_feeds']), $url_redirect); - return; + Minz_Request::bad(_t('sub.feeds.over_max', $limits['max_feeds']), + $url_redirect); } if (Minz_Request::isPost()) { diff --git a/app/i18n/en.php b/app/i18n/en.php index 2c61d822d..a35a6ccf1 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -474,6 +474,7 @@ 'steps' => 'Steps', 'sticky_post' => 'Stick the article to the top when opened', 'sub.categories.over_max' => 'You have reached your limit of categories (%d)', + 'sub.feeds.over_max' => 'You have reached your limit of feeds (%d)', 'submit' => 'Submit', 'subscription_management' => 'Subscriptions management', 'sun' => 'Sun', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 2420b20c3..c29b6c9ac 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -474,6 +474,7 @@ 'steps' => 'Étapes', 'sticky_post' => 'Aligner l’article en haut quand il est ouvert', 'sub.categories.over_max' => 'Vous avez atteint votre limite de catégories (%d)', + 'sub.feeds.over_max' => 'Vous avez atteint votre limite de flux (%d)', 'submit' => 'Valider', 'subscription_management' => 'Gestion des abonnements', 'sun' => 'dim.', -- cgit v1.2.3 From fb3cda8ac9f7c8895ed33d7db432a92b063a7198 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 29 Oct 2014 11:08:31 +0100 Subject: Fix limits in import OPML files See https://github.com/marienfressinaud/FreshRSS/issues/680 --- app/Controllers/importExportController.php | 55 +++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 12 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index ab277e688..514077bbd 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -176,19 +176,43 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { */ private function addOpmlElements($opml_elements, $parent_cat = null) { $error = false; + + $nb_feeds = count($this->feedDAO->listFeeds()); + $nb_cats = count($this->catDAO->listCategories(false)); + $limits = Minz_Configuration::limits(); + foreach ($opml_elements as $elt) { - $res = false; + $is_error = false; if (isset($elt['xmlUrl'])) { // If xmlUrl exists, it means it is a feed - $res = $this->addFeedOpml($elt, $parent_cat); + if ($nb_feeds >= $limits['max_feeds']) { + Minz_Log::warning(_t('sub.feeds.over_max', + $limits['max_feeds'])); + $is_error = true; + continue; + } + + $is_error = $this->addFeedOpml($elt, $parent_cat); + if (!$is_error) { + $nb_feeds += 1; + } } else { // No xmlUrl? It should be a category! - $res = $this->addCategoryOpml($elt, $parent_cat); + $limit_reached = ($nb_cats >= $limits['max_categories']); + if ($limit_reached) { + Minz_Log::warning(_t('sub.categories.over_max', + $limits['max_categories'])); + } + + $is_error = $this->addCategoryOpml($elt, $parent_cat, $limit_reached); + if (!$is_error) { + $nb_cats += 1; + } } - if (!$error && $res) { + if (!$error && $is_error) { // oops: there is at least one error! - $error = $res; + $error = $is_error; } } @@ -203,16 +227,18 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { * @return boolean true if an error occured, false else. */ private function addFeedOpml($feed_elt, $parent_cat) { + $default_cat = $this->catDAO->getDefault(); if (is_null($parent_cat)) { // This feed has no parent category so we get the default one - $parent_cat = $this->catDAO->getDefault()->name(); + $parent_cat = $default_cat->name(); } $cat = $this->catDAO->searchByName($parent_cat); - if (!$cat) { + if (is_null($cat)) { // If there is not $cat, it means parent category does not exist in - // database. It should not happened! - return true; + // database. + // If it happens, take the default category. + $cat = $default_cat; } // We get different useful information @@ -253,14 +279,19 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { * * @param array $cat_elt an OPML element (must be a category element). * @param string $parent_cat the name of the parent category. + * @param boolean $cat_limit_reached indicates if category limit has been reached. + * if yes, category is not added (but we try for feeds!) * @return boolean true if an error occured, false else. */ - private function addCategoryOpml($cat_elt, $parent_cat) { + private function addCategoryOpml($cat_elt, $parent_cat, $cat_limit_reached) { // Create a new Category object $cat = new FreshRSS_Category(Minz_Helper::htmlspecialchars_utf8($cat_elt['text'])); - $id = $this->catDAO->addCategoryObject($cat); - $error = ($id === false); + $error = true; + if (!$cat_limit_reached) { + $id = $this->catDAO->addCategoryObject($cat); + $error = ($id === false); + } if (isset($cat_elt['@outlines'])) { // Our cat_elt contains more categories or more feeds, so we -- cgit v1.2.3 From d20b5a127fe95f91b55f3ae9391365c67f96c4cc Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 29 Oct 2014 11:47:51 +0100 Subject: Fix limit in import Json files See https://github.com/marienfressinaud/FreshRSS/issues/680 --- app/Controllers/importExportController.php | 28 +++++++++++++++++++++++++--- app/Models/FeedDAO.php | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 514077bbd..8028af8ed 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -327,12 +327,34 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $error = false; $article_to_feed = array(); + $nb_feeds = count($this->feedDAO->listFeeds()); + $limits = Minz_Configuration::limits(); + // First, we check feeds of articles are in DB (and add them if needed). foreach ($article_object['items'] as $item) { - $feed = $this->addFeedJson($item['origin'], $google_compliant); + $key = $google_compliant ? 'htmlUrl' : 'feedUrl'; + $feed = new FreshRSS_Feed($item['origin'][$key]); + $feed = $this->feedDAO->searchByUrl($feed->url()); + if (is_null($feed)) { - $error = true; - } else { + // Feed does not exist in DB,we should to try to add it. + if ($nb_feeds >= $limits['max_feeds']) { + // Oops, no more place! + Minz_Log::warning(_t('sub.feeds.over_max', $limits['max_feeds'])); + } else { + $feed = $this->addFeedJson($item['origin'], $google_compliant); + } + + if (is_null($feed)) { + // Still null? It means something went wrong. + $error = true; + } else { + // Nice! Increase the counter. + $nb_feeds += 1; + } + } + + if (!is_null($feed)) { $article_to_feed[$item['id']] = $feed->id(); } } diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 852de6e36..74597c730 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -191,7 +191,7 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo { $res = $stm->fetchAll(PDO::FETCH_ASSOC); $feed = current(self::daoToFeed($res)); - if (isset($feed)) { + if (isset($feed) && $feed !== false) { return $feed; } else { return null; -- cgit v1.2.3 From 9478d2f0116be69e08071dd02c0f945c5f78d7e0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 30 Oct 2014 12:43:52 +0100 Subject: Add do_post_update support --- app/Controllers/updateController.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 4ebb11f51..4ef5357ea 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -109,6 +109,19 @@ class FreshRSS_update_Controller extends Minz_ActionController { require(UPDATE_FILENAME); + if (Minz_Request::param('post_conf', false)) { + $res = do_post_update(); + + if ($res === true) { + @unlink(UPDATE_FILENAME); + @file_put_contents(DATA_PATH . '/last_update.txt', time()); + Minz_Request::good(_t('update_finished')); + } else { + Minz_Request::bad(_t('update_problem', $res), + array('c' => 'update', 'a' => 'index')); + } + } + if (Minz_Request::isPost()) { save_info_update(); } @@ -117,10 +130,11 @@ class FreshRSS_update_Controller extends Minz_ActionController { $res = apply_update(); if ($res === true) { - @unlink(UPDATE_FILENAME); - @file_put_contents(DATA_PATH . '/last_update.txt', time()); - - Minz_Request::good(_t('update_finished')); + Minz_Request::forward(array( + 'c' => 'update', + 'a' => 'apply', + 'params' => array('post_conf' => true) + ), true); } else { Minz_Request::bad(_t('update_problem', $res), array('c' => 'update', 'a' => 'index')); -- cgit v1.2.3 From ee5bbe48269a2fd5bc9c175fdb1e5a92a2c04502 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 30 Oct 2014 19:19:09 +0100 Subject: Fix bug size with SQLite --- app/Controllers/configureController.php | 2 +- lib/Minz/ModelPdo.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index cafd0e8a8..deb8cc849 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -225,7 +225,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { Minz_View::prependTitle(_t('archiving_configuration') . ' · '); - $entryDAO = FreshRSS_Factory::createEntryDao(); + $entryDAO = FreshRSS_Factory::createEntryDao('freshrss'); $this->view->nb_total = $entryDAO->count(); $this->view->size_user = $entryDAO->size(); diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php index 827c89c69..6198cd85c 100644 --- a/lib/Minz/ModelPdo.php +++ b/lib/Minz/ModelPdo.php @@ -17,6 +17,7 @@ class Minz_ModelPdo { private static $sharedBd = null; private static $sharedPrefix; private static $has_transaction = false; + private static $sharedCurrentUser; protected static $sharedDbType; /** @@ -39,6 +40,7 @@ class Minz_ModelPdo { if (self::$useSharedBd && self::$sharedBd != null && $currentUser === null) { $this->bd = self::$sharedBd; $this->prefix = self::$sharedPrefix; + $this->current_user = self::$sharedCurrentUser; return; } @@ -48,6 +50,7 @@ class Minz_ModelPdo { $currentUser = Minz_Session::param('currentUser', '_'); } $this->current_user = $currentUser; + self::$sharedCurrentUser = $currentUser; try { $type = $db['type']; -- cgit v1.2.3 From 58deab37cdd97e93ac25aba574a32befe1db2243 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 30 Oct 2014 19:57:08 +0100 Subject: Fix Minz_Error::error() -> use default values --- app/Controllers/authController.php | 3 +-- app/Controllers/categoryController.php | 5 +---- app/Controllers/configureController.php | 5 +---- app/Controllers/entryController.php | 5 +---- app/Controllers/feedController.php | 10 ++-------- app/Controllers/importExportController.php | 5 +---- app/Controllers/statsController.php | 29 +++++++++++++---------------- app/Controllers/subscriptionController.php | 10 ++-------- app/Controllers/updateController.php | 5 +---- app/Controllers/userController.php | 8 ++------ 10 files changed, 25 insertions(+), 60 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index 491be8d8a..44496cd3e 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -19,8 +19,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController { */ public function indexAction() { if (!FreshRSS_Auth::hasAccess('admin')) { - Minz_Error::error(403, - array('error' => array(_t('access_denied')))); + Minz_Error::error(403); } Minz_View::prependTitle(_t('gen.title.authentication') . ' · '); diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 609284559..50b1d841a 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -13,10 +13,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { */ public function firstAction() { if (!FreshRSS_Auth::hasAccess()) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } $catDAO = new FreshRSS_CategoryDAO(); diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index deb8cc849..1c8ac9111 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -11,10 +11,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { */ public function firstAction() { if (!FreshRSS_Auth::hasAccess()) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } } diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php index d11f3a520..b4beed619 100755 --- a/app/Controllers/entryController.php +++ b/app/Controllers/entryController.php @@ -11,10 +11,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController { */ public function firstAction() { if (!FreshRSS_Auth::hasAccess()) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } // If ajax request, we do not print layout diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 8563b1c0f..9990a852c 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -20,10 +20,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $action = Minz_Request::actionName(); if ($action !== 'actualize' || !(Minz_Configuration::allowAnonymousRefresh() || $token_is_ok)) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } } } @@ -442,10 +439,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } else { Minz_Log::warning('Cannot move feed `' . $feed_id . '` ' . 'in the category `' . $cat_id . '`'); - Minz_Error::error( - 404, - array('error' => array(_t('error_occurred'))) - ); + Minz_Error::error(404); } } diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 8028af8ed..4e2dbd157 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -11,10 +11,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { */ public function firstAction() { if (!FreshRSS_Auth::hasAccess()) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } require_once(LIB_PATH . '/lib_opml.php'); diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 0e3430fcc..18fbca6df 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -5,6 +5,19 @@ */ class FreshRSS_stats_Controller extends Minz_ActionController { + /** + * This action is called before every other action in that class. It is + * the common boiler plate for every action. It is triggered by the + * underlying framework. + */ + public function firstAction() { + if (!FreshRSS_Auth::hasAccess()) { + Minz_Error::error(403); + } + + Minz_View::prependTitle(_t('stats') . ' · '); + } + /** * This action handles the statistic main page. * @@ -111,20 +124,4 @@ class FreshRSS_stats_Controller extends Minz_ActionController { $this->view->repartitionMonth = $statsDAO->calculateEntryRepartitionPerFeedPerMonth($id); $this->view->averageMonth = $statsDAO->calculateEntryAveragePerFeedPerMonth($id); } - - /** - * This action is called before every other action in that class. It is - * the common boiler plate for every action. It is triggered by the - * underlying framework. - */ - public function firstAction() { - if (!FreshRSS_Auth::hasAccess()) { - Minz_Error::error( - 403, array('error' => array(_t('access_denied'))) - ); - } - - Minz_View::prependTitle(_t('stats') . ' · '); - } - } diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index a89168eb3..67b95eba6 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -11,10 +11,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { */ public function firstAction() { if (!FreshRSS_Auth::hasAccess()) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } $catDAO = new FreshRSS_CategoryDAO(); @@ -71,10 +68,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { $id = Minz_Request::param('id'); if ($id === false || !isset($this->view->feeds[$id])) { - Minz_Error::error( - 404, - array('error' => array(_t('page_not_found'))) - ); + Minz_Error::error(404); return; } diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php index 4ef5357ea..0896b13ac 100644 --- a/app/Controllers/updateController.php +++ b/app/Controllers/updateController.php @@ -4,10 +4,7 @@ class FreshRSS_update_Controller extends Minz_ActionController { public function firstAction() { $current_user = Minz_Session::param('currentUser', ''); if (!FreshRSS_Auth::hasAccess('admin')) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } invalidateHttpCache(); diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 39db1d879..5050571a9 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -15,10 +15,7 @@ class FreshRSS_user_Controller extends Minz_ActionController { */ public function firstAction() { if (!FreshRSS_Auth::hasAccess()) { - Minz_Error::error( - 403, - array('error' => array(_t('access_denied'))) - ); + Minz_Error::error(403); } } @@ -88,8 +85,7 @@ class FreshRSS_user_Controller extends Minz_ActionController { */ public function manageAction() { if (!FreshRSS_Auth::hasAccess('admin')) { - Minz_Error::error(403, - array('error' => array(_t('access_denied')))); + Minz_Error::error(403); } Minz_View::prependTitle(_t('gen.title.user_management') . ' · '); -- cgit v1.2.3 From 960f86ba20fdf7320c957141a9983d17c7e521fa Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sun, 2 Nov 2014 10:05:26 -0500 Subject: Add a feature to hide articles when they are read This is a new reading option to hide articles when they are read. The hidding process occurs when the article is left for an other article. This way, even when the article is marked as read on opening, it is hidden only while navigating to an other article. I'm not really happy with the behavior when the "mark while scrolling" option is enabled. Please review. It is missing the i18n since we're not supposed to push them before it exists on i18n.freshrss.org. Or maybe I misunderstood the process. See #476 --- app/Controllers/configureController.php | 2 ++ app/Models/Configuration.php | 4 ++++ app/Models/Context.php | 22 ++++++++++++++++++++++ app/views/configure/reading.phtml | 10 ++++++++++ app/views/helpers/javascript_vars.phtml | 1 + p/scripts/main.js | 8 ++++++++ 6 files changed, 47 insertions(+) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 1c8ac9111..53536afce 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -89,6 +89,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { * - image lazy loading * - stick open articles to the top * - display a confirmation when reading all articles + * - auto remove article after reading * - article order (default: DESC) * - mark articles as read when: * - displayed @@ -110,6 +111,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { FreshRSS_Context::$conf->_lazyload(Minz_Request::param('lazyload', false)); FreshRSS_Context::$conf->_sticky_post(Minz_Request::param('sticky_post', false)); FreshRSS_Context::$conf->_reading_confirm(Minz_Request::param('reading_confirm', false)); + FreshRSS_Context::$conf->_auto_remove_article(Minz_Request::param('auto_remove_article', false)); FreshRSS_Context::$conf->_sort_order(Minz_Request::param('sort_order', 'DESC')); FreshRSS_Context::$conf->_mark_when(array( 'article' => Minz_Request::param('mark_open_article', false), diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 53f136513..8668470b0 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -24,6 +24,7 @@ class FreshRSS_Configuration { 'lazyload' => true, 'sticky_post' => true, 'reading_confirm' => false, + 'auto_remove_article' => false, 'sort_order' => 'DESC', 'anon_access' => false, 'mark_when' => array( @@ -191,6 +192,9 @@ class FreshRSS_Configuration { public function _reading_confirm($value) { $this->data['reading_confirm'] = ((bool)$value) && $value !== 'no'; } + public function _auto_remove_article($value) { + $this->data['auto_remove_article'] = ((bool)$value) && $value !== 'no'; + } public function _sort_order($value) { $this->data['sort_order'] = $value === 'ASC' ? 'ASC' : 'DESC'; } diff --git a/app/Models/Context.php b/app/Models/Context.php index 36c4087eb..cbd6a5888 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -265,4 +265,26 @@ class FreshRSS_Context { } } } + + /** + * Determine if the auto remove is available in the current context. + * This feature is available if: + * - it is activated in the configuration + * - the "read" state is not enable + * - the "unread" state is enable + * + * @return boolean + */ + public static function isAutoRemoveAvailable() { + if (!self::$conf->auto_remove_article) { + return false; + } + if (self::isStateEnabled(FreshRSS_Entry::STATE_READ)) { + return false; + } + if (!self::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ)) { + return false; + } + return true; + } } diff --git a/app/views/configure/reading.phtml b/app/views/configure/reading.phtml index b8f673466..0f7a3347a 100644 --- a/app/views/configure/reading.phtml +++ b/app/views/configure/reading.phtml @@ -115,6 +115,16 @@
        +
        +
        + +
        +
        +
        diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 8e9141d4e..6424d8d04 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -18,6 +18,7 @@ $url_logout = Minz_Url::display(array( ), 'php'); echo 'var context={', + 'auto_remove_article:', FreshRSS_Context::isAutoRemoveAvailable() ? 'true' : 'false', ',', 'hide_posts:', $hide_posts ? 'false' : 'true', ',', 'display_order:"', Minz_Request::param('order', FreshRSS_Context::$conf->sort_order), '",', 'auto_mark_article:', $mark['article'] ? 'true' : 'false', ',', diff --git a/p/scripts/main.js b/p/scripts/main.js index dc5428048..d1d31c801 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -231,6 +231,14 @@ function toggleContent(new_active, old_active) { } old_active.removeClass("active current"); new_active.addClass("current"); + if (context['auto_remove_article'] && !old_active.hasClass('not_read')) { + var p = old_active.prev(); + var n = old_active.next(); + if (p.hasClass('day') && n.hasClass('day')) { + p.remove(); + } + old_active.remove(); + } } else { new_active.toggleClass('active'); } -- cgit v1.2.3 From 0b7af8f8719f698b67e31b5a84fa19b0f20c0590 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 31 Oct 2014 17:21:35 +0100 Subject: Fix bug on archiving page Introduced by https://github.com/FreshRSS/FreshRSS/commit/ee5bbe48269a2fd5bc9c175fdb1e5a92a2c04502 --- app/Controllers/configureController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/Controllers') diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php index 1c8ac9111..f8d9b47c3 100755 --- a/app/Controllers/configureController.php +++ b/app/Controllers/configureController.php @@ -222,7 +222,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController { Minz_View::prependTitle(_t('archiving_configuration') . ' · '); - $entryDAO = FreshRSS_Factory::createEntryDao('freshrss'); + $entryDAO = FreshRSS_Factory::createEntryDao(); $this->view->nb_total = $entryDAO->count(); $this->view->size_user = $entryDAO->size(); -- cgit v1.2.3 From 38cf7a109ee80cc03edfd420b641676ecd1dfae6 Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Sat, 8 Nov 2014 09:26:01 -0500 Subject: Add more info in article repartition page I added the same information than on the main stat page (total, read, unread and favorite) on the repartition page. Some refactoring was needed. --- app/Controllers/statsController.php | 1 + app/Models/StatsDAO.php | 48 ++++++++++++++++++++----------------- app/views/stats/repartition.phtml | 17 +++++++++++++ 3 files changed, 44 insertions(+), 22 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php index 18fbca6df..578df9434 100644 --- a/app/Controllers/statsController.php +++ b/app/Controllers/statsController.php @@ -117,6 +117,7 @@ class FreshRSS_stats_Controller extends Minz_ActionController { $this->view->feed = $feedDAO->searchById($id); $this->view->days = $statsDAO->getDays(); $this->view->months = $statsDAO->getMonths(); + $this->view->repartition = $statsDAO->calculateEntryRepartitionPerFeed($id); $this->view->repartitionHour = $statsDAO->calculateEntryRepartitionPerFeedPerHour($id); $this->view->averageHour = $statsDAO->calculateEntryAveragePerFeedPerHour($id); $this->view->repartitionDayOfWeek = $statsDAO->calculateEntryRepartitionPerFeedPerDayOfWeek($id); diff --git a/app/Models/StatsDAO.php b/app/Models/StatsDAO.php index 283d5dcb1..0ca251228 100644 --- a/app/Models/StatsDAO.php +++ b/app/Models/StatsDAO.php @@ -6,18 +6,36 @@ class FreshRSS_StatsDAO extends Minz_ModelPdo { /** * Calculates entry repartition for all feeds and for main stream. + * + * @return array + */ + public function calculateEntryRepartition() { + return array( + 'main_stream' => $this->calculateEntryRepartitionPerFeed(null, true), + 'all_feeds' => $this->calculateEntryRepartitionPerFeed(null, false), + ); + } + + /** + * Calculates entry repartition for the selection. * The repartition includes: * - total entries * - read entries * - unread entries * - favorite entries * - * @return type + * @param null|integer $feed feed id + * @param boolean $only_main + * @return array */ - public function calculateEntryRepartition() { - $repartition = array(); - - // Generates the repartition for the main stream of entry + public function calculateEntryRepartitionPerFeed($feed = null, $only_main = false) { + $filter = ''; + if ($only_main) { + $filter .= 'AND f.priority = 10'; + } + if (!is_null($feed)) { + $filter .= "AND e.id_feed = {$feed}"; + } $sql = <<prefix}entry AS e , {$this->prefix}feed AS f WHERE e.id_feed = f.id -AND f.priority = 10 -SQL; - $stm = $this->bd->prepare($sql); - $stm->execute(); - $res = $stm->fetchAll(PDO::FETCH_ASSOC); - $repartition['main_stream'] = $res[0]; - - // Generates the repartition for all entries - $sql = <<prefix}entry AS e +{$filter} SQL; $stm = $this->bd->prepare($sql); $stm->execute(); $res = $stm->fetchAll(PDO::FETCH_ASSOC); - $repartition['all_feeds'] = $res[0]; - return $repartition; + return $res[0]; } /** @@ -179,7 +183,7 @@ SQL; * @return integer */ public function calculateEntryAveragePerFeedPerHour($feed = null) { - return $this->calculateEntryAveragePerFeedPerPeriod(1/24, $feed); + return $this->calculateEntryAveragePerFeedPerPeriod(1 / 24, $feed); } /** diff --git a/app/views/stats/repartition.phtml b/app/views/stats/repartition.phtml index 32268a546..85a750bd0 100644 --- a/app/views/stats/repartition.phtml +++ b/app/views/stats/repartition.phtml @@ -29,6 +29,23 @@ +
        + + + + + + + + + + + + + +
        repartition['total']; ?>repartition['read']; ?>repartition['unread']; ?>repartition['favorite']; ?>
        +
        +

        averageHour); ?>

        -- cgit v1.2.3 From a235f003bd5b78f2c94ccbbe56614f5828918962 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Wed, 12 Nov 2014 22:58:33 +0100 Subject: Better log in case of nonce errors https://github.com/FreshRSS/FreshRSS/issues/676 --- app/Controllers/javascriptController.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/Controllers') diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php index 62f413989..113f58ea9 100755 --- a/app/Controllers/javascriptController.php +++ b/app/Controllers/javascriptController.php @@ -39,6 +39,8 @@ class FreshRSS_javascript_Controller extends Minz_ActionController { } catch (Minz_Exception $me) { Minz_Log::warning('Nonce failure: ' . $me->getMessage()); } + } else { + Minz_Log::notice('Nonce failure due to invalid username!'); } $this->view->nonce = ''; //Failure $this->view->salt1 = ''; -- cgit v1.2.3 From 9fc60317eecba785b66011f04b9a5150296f2df6 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 5 Dec 2014 14:17:02 +0100 Subject: First draft for listing and manipulate extensions See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 43 +++++++++++++++++++++++++++++++++ app/layout/aside_configure.phtml | 4 +++ app/layout/header.phtml | 1 + app/views/extension/index.phtml | 35 +++++++++++++++++++++++++++ lib/Minz/Extension.php | 20 +++++++++++++++ lib/Minz/ExtensionManager.php | 17 +++++++++++++ 6 files changed, 120 insertions(+) create mode 100644 app/Controllers/extensionController.php create mode 100644 app/views/extension/index.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php new file mode 100644 index 000000000..504be56d3 --- /dev/null +++ b/app/Controllers/extensionController.php @@ -0,0 +1,43 @@ +view->extension_list = Minz_ExtensionManager::list_extensions(); + } + + public function configureAction() { + if (Minz_Request::param('ajax')) { + $this->view->_useLayout(false); + } + } + + public function enableAction() { + + } + + public function disableAction() { + + } + + public function removeAction() { + + } +} diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml index 53c52d3e3..f7f3617c4 100644 --- a/app/layout/aside_configure.phtml +++ b/app/layout/aside_configure.phtml @@ -22,6 +22,10 @@ Minz_Request::actionName() === 'profile'? ' active' : ''; ?>"> +
      • + +
      • +
      • diff --git a/app/views/extension/index.phtml b/app/views/extension/index.phtml new file mode 100644 index 000000000..c6b7c84a1 --- /dev/null +++ b/app/views/extension/index.phtml @@ -0,0 +1,35 @@ +partial('aside_configure'); ?> + +
        + + +

        + + extension_list)) { ?> + + extension_list as $ext) { ?> +
          +
        • + getName()); ?> +
          + + is_enabled()) { ?> + + + + + + + +
          +
        • +
        • getName(); ?>
        • +
        + + +

        + +
        + + +
        diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php index ecf510ea2..a1fdd659b 100644 --- a/lib/Minz/Extension.php +++ b/lib/Minz/Extension.php @@ -17,6 +17,8 @@ class Minz_Extension { 'user', ); + private $is_enabled; + /** * The constructor to assign specific information to the extension. * @@ -41,6 +43,8 @@ class Minz_Extension { $this->description = isset($meta_info['description']) ? $meta_info['description'] : ''; $this->version = isset($meta_info['version']) ? $meta_info['version'] : '0.1'; $this->setType(isset($meta_info['type']) ? $meta_info['type'] : 'user'); + + $this->is_enabled = false; } /** @@ -66,6 +70,22 @@ class Minz_Extension { */ public function init() {} + /** + * Set the current extension to enable. + */ + public function enable() { + $this->is_enabled = true; + } + + /** + * Return if the extension is currently enabled. + * + * @return true if extension is enabled, false else. + */ + public function is_enabled() { + return $this->is_enabled; + } + /** * Getters and setters. */ diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 789557b9e..6c32ccf19 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -144,6 +144,7 @@ class Minz_ExtensionManager { if (isset(self::$ext_list[$ext_name])) { $ext = self::$ext_list[$ext_name]; self::$ext_list_enabled[$ext_name] = $ext; + $ext->enable(); $ext->init(); } } @@ -158,4 +159,20 @@ class Minz_ExtensionManager { self::enable($ext_name); } } + + + + /** + * Returns a list of extensions. + * + * @param $only_enabled if true returns only the enabled extensions (false by default). + * @return an array of extensions. + */ + public static function list_extensions($only_enabled = false) { + if ($only_enabled) { + return self::$ext_list_enabled; + } else { + return self::$ext_list; + } + } } -- cgit v1.2.3 From 2e4682ebd451f8dd291e11141553add9164cbbef Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 6 Dec 2014 16:17:11 +0100 Subject: Add enable / disable extension features See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 72 ++++++++++++++++++++++++++++++++- app/Models/Configuration.php | 12 ++++++ lib/Minz/ExtensionManager.php | 18 +++++++-- 3 files changed, 97 insertions(+), 5 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index 504be56d3..415f489a6 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -29,12 +29,80 @@ class FreshRSS_extension_Controller extends Minz_ActionController { } } + /** + * This action enables a disabled extension for the current user. + * + * System extensions can only be enabled by an administrator. + * + * Parameter is: + * - e: the extension name (urlencoded). + */ public function enableAction() { - + $url_redirect = array('c' => 'extension', 'a' => 'index'); + + if (Minz_Request::isPost()) { + $ext_name = urldecode(Minz_Request::param('e')); + $ext = Minz_ExtensionManager::find_extension($ext_name); + + if (is_null($ext)) { + Minz_Request::bad('feedback.extension.not_found', $url_redirect); + } + + if ($ext->is_enabled()) { + Minz_Request::bad('feedback.extension.already_enabled', $url_redirect); + } + + if ($ext->getType() === 'system' && !FreshRSS_Auth::hasAccess('admin')) { + Minz_Request::bad('feedback.extension.no_access', $url_redirect); + } + + $ext->install(); + + FreshRSS_Context::$conf->addExtension($ext_name); + FreshRSS_Context::$conf->save(); + + Minz_Request::good('feedback.extension.enabled', $url_redirect); + } + + Minz_Request::forward($url_redirect, true); } + /** + * This action disables an enabled extension for the current user. + * + * System extensions can only be disabled by an administrator. + * + * Parameter is: + * - e: the extension name (urlencoded). + */ public function disableAction() { - + $url_redirect = array('c' => 'extension', 'a' => 'index'); + + if (Minz_Request::isPost()) { + $ext_name = urldecode(Minz_Request::param('e')); + $ext = Minz_ExtensionManager::find_extension($ext_name); + + if (is_null($ext)) { + Minz_Request::bad('feedback.extension.not_found', $url_redirect); + } + + if (!$ext->is_enabled()) { + Minz_Request::bad('feedback.extension.not_enabled', $url_redirect); + } + + if ($ext->getType() === 'system' && !FreshRSS_Auth::hasAccess('admin')) { + Minz_Request::bad('feedback.extension.no_access', $url_redirect); + } + + $ext->uninstall(); + + FreshRSS_Context::$conf->removeExtension($ext_name); + FreshRSS_Context::$conf->save(); + + Minz_Request::good('feedback.extension.disabled', $url_redirect); + } + + Minz_Request::forward($url_redirect, true); } public function removeAction() { diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index 13ce43990..83a00d4bb 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -350,4 +350,16 @@ class FreshRSS_Configuration { } $this->data['extensions_enabled'] = $value; } + public function removeExtension($ext_name) { + $this->data['extensions_enabled'] = array_diff( + $this->data['extensions_enabled'], + array($ext_name) + ); + } + public function addExtension($ext_name) { + $found = array_search($ext_name, $this->data['extensions_enabled']) !== false; + if (!$found) { + $this->data['extensions_enabled'][] = $ext_name; + } + } } diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 6c32ccf19..46e421bac 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -160,10 +160,8 @@ class Minz_ExtensionManager { } } - - /** - * Returns a list of extensions. + * Return a list of extensions. * * @param $only_enabled if true returns only the enabled extensions (false by default). * @return an array of extensions. @@ -175,4 +173,18 @@ class Minz_ExtensionManager { return self::$ext_list; } } + + /** + * Return an extension by its name. + * + * @param $ext_name the name of the extension. + * @return the corresponding extension or null if it doesn't exist. + */ + public static function find_extension($ext_name) { + if (!isset(self::$ext_list[$ext_name])) { + return null; + } + + return self::$ext_list[$ext_name]; + } } -- cgit v1.2.3 From 4c888590e6f0fd89fc1dccebb5e815883eeaa54c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 6 Dec 2014 16:39:10 +0100 Subject: Improve system/user types for extensions - system extensions can only be managed by an administrator - system extensions are loaded for all users (even if not logged) - user extensions are loaded for logged users only - system extensions loading is saved in global config.php file See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 42 ++++++++++++++++++++++----------- app/FreshRSS.php | 8 ++++--- app/views/extension/index.phtml | 4 ++++ lib/Minz/Configuration.php | 19 +++++++++++++-- 4 files changed, 54 insertions(+), 19 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index 415f489a6..e348d9f31 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -52,16 +52,23 @@ class FreshRSS_extension_Controller extends Minz_ActionController { Minz_Request::bad('feedback.extension.already_enabled', $url_redirect); } - if ($ext->getType() === 'system' && !FreshRSS_Auth::hasAccess('admin')) { - Minz_Request::bad('feedback.extension.no_access', $url_redirect); - } + if ($ext->getType() === 'system' && FreshRSS_Auth::hasAccess('admin')) { + $ext->install(); + + Minz_Configuration::addExtension($ext_name); + Minz_Configuration::writeFile(); - $ext->install(); + Minz_Request::good('feedback.extension.enabled', $url_redirect); + } elseif ($ext->getType() === 'user') { + $ext->install(); - FreshRSS_Context::$conf->addExtension($ext_name); - FreshRSS_Context::$conf->save(); + FreshRSS_Context::$conf->addExtension($ext_name); + FreshRSS_Context::$conf->save(); - Minz_Request::good('feedback.extension.enabled', $url_redirect); + Minz_Request::good('feedback.extension.enabled', $url_redirect); + } else { + Minz_Request::bad('feedback.extension.no_access', $url_redirect); + } } Minz_Request::forward($url_redirect, true); @@ -90,16 +97,23 @@ class FreshRSS_extension_Controller extends Minz_ActionController { Minz_Request::bad('feedback.extension.not_enabled', $url_redirect); } - if ($ext->getType() === 'system' && !FreshRSS_Auth::hasAccess('admin')) { - Minz_Request::bad('feedback.extension.no_access', $url_redirect); - } + if ($ext->getType() === 'system' && FreshRSS_Auth::hasAccess('admin')) { + $ext->uninstall(); + + Minz_Configuration::removeExtension($ext_name); + Minz_Configuration::writeFile(); - $ext->uninstall(); + Minz_Request::good('feedback.extension.disabled', $url_redirect); + } elseif ($ext->getType() === 'user') { + $ext->uninstall(); - FreshRSS_Context::$conf->removeExtension($ext_name); - FreshRSS_Context::$conf->save(); + FreshRSS_Context::$conf->removeExtension($ext_name); + FreshRSS_Context::$conf->save(); - Minz_Request::good('feedback.extension.disabled', $url_redirect); + Minz_Request::good('feedback.extension.disabled', $url_redirect); + } else { + Minz_Request::bad('feedback.extension.no_access', $url_redirect); + } } Minz_Request::forward($url_redirect, true); diff --git a/app/FreshRSS.php b/app/FreshRSS.php index dc7d0b375..b91dfcc46 100644 --- a/app/FreshRSS.php +++ b/app/FreshRSS.php @@ -29,9 +29,11 @@ class FreshRSS extends Minz_FrontController { // Load context and configuration. FreshRSS_Context::init(); - // Enable extensions for the current user. - $ext_list = FreshRSS_Context::$conf->extensions_enabled; - Minz_ExtensionManager::enable_by_list($ext_list); + // Enable extensions for the current (logged) user. + if (FreshRSS_Auth::hasAccess()) { + $ext_list = FreshRSS_Context::$conf->extensions_enabled; + Minz_ExtensionManager::enable_by_list($ext_list); + } // Init i18n. Minz_Session::_param('language', FreshRSS_Context::$conf->language); diff --git a/app/views/extension/index.phtml b/app/views/extension/index.phtml index c6b7c84a1..0be03d7b5 100644 --- a/app/views/extension/index.phtml +++ b/app/views/extension/index.phtml @@ -10,6 +10,7 @@ extension_list as $ext) { ?>
        • + getType() === 'user' || FreshRSS_Auth::hasAccess('admin')) { ?> getName()); ?>
          @@ -22,6 +23,9 @@
          + + +
        • getName(); ?>
        diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 4d3ab0964..4a3221ef5 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -165,6 +165,19 @@ class Minz_Configuration { self::$unsafe_autologin_enabled = (bool)$value; } + public function removeExtension($ext_name) { + self::$extensions_enabled = array_diff( + self::$extensions_enabled, + array($ext_name) + ); + } + public function addExtension($ext_name) { + $found = array_search($ext_name, self::$extensions_enabled) !== false; + if (!$found) { + self::$extensions_enabled[] = $ext_name; + } + } + /** * Initialise les variables de configuration * @exception Minz_FileNotExistException si le CONF_PATH_NAME n'existe pas @@ -197,6 +210,7 @@ class Minz_Configuration { ), 'limits' => self::$limits, 'db' => self::$db, + 'extensions_enabled' => self::$extensions_enabled, ); @rename(DATA_PATH . self::CONF_PATH_NAME, DATA_PATH . self::CONF_PATH_NAME . '.bak.php'); $result = file_put_contents(DATA_PATH . self::CONF_PATH_NAME, " Date: Sat, 6 Dec 2014 16:48:13 +0100 Subject: Fix typo (extensions) - change feedback.extension into feedback.extensions - disable button is pushed by default See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 20 ++++++++++---------- app/views/extension/index.phtml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index e348d9f31..543398b05 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -45,11 +45,11 @@ class FreshRSS_extension_Controller extends Minz_ActionController { $ext = Minz_ExtensionManager::find_extension($ext_name); if (is_null($ext)) { - Minz_Request::bad('feedback.extension.not_found', $url_redirect); + Minz_Request::bad('feedback.extensions.not_found', $url_redirect); } if ($ext->is_enabled()) { - Minz_Request::bad('feedback.extension.already_enabled', $url_redirect); + Minz_Request::bad('feedback.extensions.already_enabled', $url_redirect); } if ($ext->getType() === 'system' && FreshRSS_Auth::hasAccess('admin')) { @@ -58,16 +58,16 @@ class FreshRSS_extension_Controller extends Minz_ActionController { Minz_Configuration::addExtension($ext_name); Minz_Configuration::writeFile(); - Minz_Request::good('feedback.extension.enabled', $url_redirect); + Minz_Request::good('feedback.extensions.enabled', $url_redirect); } elseif ($ext->getType() === 'user') { $ext->install(); FreshRSS_Context::$conf->addExtension($ext_name); FreshRSS_Context::$conf->save(); - Minz_Request::good('feedback.extension.enabled', $url_redirect); + Minz_Request::good('feedback.extensions.enabled', $url_redirect); } else { - Minz_Request::bad('feedback.extension.no_access', $url_redirect); + Minz_Request::bad('feedback.extensions.no_access', $url_redirect); } } @@ -90,11 +90,11 @@ class FreshRSS_extension_Controller extends Minz_ActionController { $ext = Minz_ExtensionManager::find_extension($ext_name); if (is_null($ext)) { - Minz_Request::bad('feedback.extension.not_found', $url_redirect); + Minz_Request::bad('feedback.extensions.not_found', $url_redirect); } if (!$ext->is_enabled()) { - Minz_Request::bad('feedback.extension.not_enabled', $url_redirect); + Minz_Request::bad('feedback.extensions.not_enabled', $url_redirect); } if ($ext->getType() === 'system' && FreshRSS_Auth::hasAccess('admin')) { @@ -103,16 +103,16 @@ class FreshRSS_extension_Controller extends Minz_ActionController { Minz_Configuration::removeExtension($ext_name); Minz_Configuration::writeFile(); - Minz_Request::good('feedback.extension.disabled', $url_redirect); + Minz_Request::good('feedback.extensions.disabled', $url_redirect); } elseif ($ext->getType() === 'user') { $ext->uninstall(); FreshRSS_Context::$conf->removeExtension($ext_name); FreshRSS_Context::$conf->save(); - Minz_Request::good('feedback.extension.disabled', $url_redirect); + Minz_Request::good('feedback.extensions.disabled', $url_redirect); } else { - Minz_Request::bad('feedback.extension.no_access', $url_redirect); + Minz_Request::bad('feedback.extensions.no_access', $url_redirect); } } diff --git a/app/views/extension/index.phtml b/app/views/extension/index.phtml index 0be03d7b5..142ee4bc2 100644 --- a/app/views/extension/index.phtml +++ b/app/views/extension/index.phtml @@ -15,7 +15,7 @@
        is_enabled()) { ?> - + -- cgit v1.2.3 From 2da7c05fa6768b95a5cd0bd1c8f9934bbff05a03 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 6 Dec 2014 17:15:20 +0100 Subject: Update i18n (extensions) See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 30 ++++++++++++++++++++---------- app/i18n/en/admin.php | 5 +++++ app/i18n/en/feedback.php | 8 ++++++++ app/i18n/en/gen.php | 7 +++++++ app/i18n/fr/admin.php | 5 +++++ app/i18n/fr/feedback.php | 8 ++++++++ app/i18n/fr/gen.php | 7 +++++++ app/views/extension/index.phtml | 8 ++++---- 8 files changed, 64 insertions(+), 14 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index 543398b05..35b001094 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -45,11 +45,13 @@ class FreshRSS_extension_Controller extends Minz_ActionController { $ext = Minz_ExtensionManager::find_extension($ext_name); if (is_null($ext)) { - Minz_Request::bad('feedback.extensions.not_found', $url_redirect); + Minz_Request::bad(_t('feedback.extensions.not_found', $ext_name), + $url_redirect); } if ($ext->is_enabled()) { - Minz_Request::bad('feedback.extensions.already_enabled', $url_redirect); + Minz_Request::bad(_t('feedback.extensions.already_enabled', $ext_name), + $url_redirect); } if ($ext->getType() === 'system' && FreshRSS_Auth::hasAccess('admin')) { @@ -58,16 +60,19 @@ class FreshRSS_extension_Controller extends Minz_ActionController { Minz_Configuration::addExtension($ext_name); Minz_Configuration::writeFile(); - Minz_Request::good('feedback.extensions.enabled', $url_redirect); + Minz_Request::good(_t('feedback.extensions.enabled', $ext_name), + $url_redirect); } elseif ($ext->getType() === 'user') { $ext->install(); FreshRSS_Context::$conf->addExtension($ext_name); FreshRSS_Context::$conf->save(); - Minz_Request::good('feedback.extensions.enabled', $url_redirect); + Minz_Request::good(_t('feedback.extensions.enabled', $ext_name), + $url_redirect); } else { - Minz_Request::bad('feedback.extensions.no_access', $url_redirect); + Minz_Request::bad(_t('feedback.extensions.no_access', $ext_name), + $url_redirect); } } @@ -90,11 +95,13 @@ class FreshRSS_extension_Controller extends Minz_ActionController { $ext = Minz_ExtensionManager::find_extension($ext_name); if (is_null($ext)) { - Minz_Request::bad('feedback.extensions.not_found', $url_redirect); + Minz_Request::bad(_t('feedback.extensions.not_found', $ext_name), + $url_redirect); } if (!$ext->is_enabled()) { - Minz_Request::bad('feedback.extensions.not_enabled', $url_redirect); + Minz_Request::bad(_t('feedback.extensions.not_enabled', $ext_name), + $url_redirect); } if ($ext->getType() === 'system' && FreshRSS_Auth::hasAccess('admin')) { @@ -103,16 +110,19 @@ class FreshRSS_extension_Controller extends Minz_ActionController { Minz_Configuration::removeExtension($ext_name); Minz_Configuration::writeFile(); - Minz_Request::good('feedback.extensions.disabled', $url_redirect); + Minz_Request::good(_t('feedback.extensions.disabled', $ext_name), + $url_redirect); } elseif ($ext->getType() === 'user') { $ext->uninstall(); FreshRSS_Context::$conf->removeExtension($ext_name); FreshRSS_Context::$conf->save(); - Minz_Request::good('feedback.extensions.disabled', $url_redirect); + Minz_Request::good(_t('feedback.extensions.disabled', $ext_name), + $url_redirect); } else { - Minz_Request::bad('feedback.extensions.no_access', $url_redirect); + Minz_Request::bad(_t('feedback.extensions.no_access', $ext_name), + $url_redirect); } } diff --git a/app/i18n/en/admin.php b/app/i18n/en/admin.php index 74f01ae06..d73775d96 100644 --- a/app/i18n/en/admin.php +++ b/app/i18n/en/admin.php @@ -86,6 +86,11 @@ return array( 'ok' => 'You have ZIP extension.', ), ), + 'extensions' => array( + 'empty_list' => 'There is no installed extension', + 'system' => 'System extension (you have no rights on it)', + 'title' => 'Extensions', + ), 'users' => array( 'articles_and_size' => '%s articles (%s)', ), diff --git a/app/i18n/en/feedback.php b/app/i18n/en/feedback.php index b3866f1dc..df1dc5725 100644 --- a/app/i18n/en/feedback.php +++ b/app/i18n/en/feedback.php @@ -1,6 +1,14 @@ array( + 'already_enabled' => '%s is already enabled', + 'disabled' => '%s is now disabled', + 'enabled' => '%s is now enabled', + 'no_access' => 'You have no access on %s', + 'not_enabled' => '%s is not enabled yet', + 'not_found' => '%s does not exist', + ), 'login' => array( 'error' => 'Login is invalid', 'success' => 'You are connected', diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 9e06357bc..ba5f0c86d 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -190,10 +190,17 @@ return array( 'freshrss_installation' => 'Installation · FreshRSS', 'fri' => 'Fri', 'g+' => 'Google+', + 'actions' => array( + 'disable' => 'Disable', + 'enable' => 'Enable', + 'manage' => 'Manage', + 'remove' => 'Remove', + ), 'menu' => array( 'admin' => 'Administration', 'authentication' => 'Authentication', 'check_install' => 'Installation checking', + 'extensions' => 'Extensions', 'user_management' => 'Manage users', 'user_profile' => 'Profile', ), diff --git a/app/i18n/fr/admin.php b/app/i18n/fr/admin.php index ad1fae6c0..e46a5a7b0 100644 --- a/app/i18n/fr/admin.php +++ b/app/i18n/fr/admin.php @@ -86,6 +86,11 @@ return array( 'ok' => 'Vous disposez de l\'extension ZIP.', ), ), + 'extensions' => array( + 'empty_list' => 'Il n’y a aucune extension installée.', + 'system' => 'Extension système (vous n’avez aucun droit dessus)', + 'title' => 'Extensions', + ), 'users' => array( 'articles_and_size' => '%s articles (%s)', ), diff --git a/app/i18n/fr/feedback.php b/app/i18n/fr/feedback.php index f4bb7cccf..7d3ab9db7 100644 --- a/app/i18n/fr/feedback.php +++ b/app/i18n/fr/feedback.php @@ -1,6 +1,14 @@ array( + 'already_enabled' => '%s est déjà activée', + 'disabled' => '%s est désormais désactivée', + 'enabled' => '%s est désormais activée', + 'no_access' => 'Vous n’avez aucun accès sur %s', + 'not_enabled' => '%s n’est pas encore activée', + 'not_found' => '%s n’existe pas', + ), 'login' => array( 'error' => 'L’identifiant est invalide !', 'success' => 'Vous êtes désormais connecté', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index 0b2395bd0..44d8fb837 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -191,10 +191,17 @@ return array( 'freshrss_installation' => 'Installation · FreshRSS', 'fri' => 'ven.', 'g+' => 'Google+', + 'actions' => array( + 'disable' => 'Désactiver', + 'enable' => 'Activer', + 'manage' => 'Gérer', + 'remove' => 'Supprimer', + ), 'menu' => array( 'admin' => 'Administration', 'authentication' => 'Authentification', 'check_install' => 'Vérification de l’installation', + 'extensions' => 'Extensions', 'user_management' => 'Gestion des utilisateurs', 'user_profile' => 'Profil', ), diff --git a/app/views/extension/index.phtml b/app/views/extension/index.phtml index 142ee4bc2..d34a84452 100644 --- a/app/views/extension/index.phtml +++ b/app/views/extension/index.phtml @@ -13,14 +13,14 @@ getType() === 'user' || FreshRSS_Auth::hasAccess('admin')) { ?> getName()); ?>
        - + is_enabled()) { ?> - + - + - +
        -- cgit v1.2.3 From bc81979a6b25554c4832d5ccb41b427023096463 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 6 Dec 2014 17:25:01 +0100 Subject: Add default behaviour for configure / remove ext See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 7 ++++++- app/views/extension/configure.phtml | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 app/views/extension/configure.phtml (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index 35b001094..a1e39af37 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -130,6 +130,11 @@ class FreshRSS_extension_Controller extends Minz_ActionController { } public function removeAction() { - + if (!FreshRSS_Auth::hasAccess('admin')) { + Minz_Error::error(403); + } + + $url_redirect = array('c' => 'extension', 'a' => 'index'); + Minz_Request::bad('not implemented yet!', $url_redirect); } } diff --git a/app/views/extension/configure.phtml b/app/views/extension/configure.phtml new file mode 100644 index 000000000..a79e9baac --- /dev/null +++ b/app/views/extension/configure.phtml @@ -0,0 +1,12 @@ +partial('aside_configure'); +} + +?> + +
        +

        Extension name

        + Not implemented yet! +
        \ No newline at end of file -- cgit v1.2.3 From 08546af75ff9a25eac3409649ea4660fe070720c Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 6 Dec 2014 18:48:00 +0100 Subject: Add a first draft for hooks - New Extension->registerHook($hook_name, $hook_function) method to register a new hook - Only one hook works for the moment: entry_before_insert - ExtensionManager::callHook will need to evolve based on future hooks See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/feedController.php | 11 ++++++-- lib/Minz/Extension.php | 10 +++++++ lib/Minz/ExtensionManager.php | 55 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 9990a852c..dce79c57a 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -329,9 +329,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $id = min(time(), $entry_date) . uSecString(); } + $entry->_id($id); + $entry->_isRead($is_read); + + $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); + if (is_null($entry)) { + // An extension has returned a null value, there is nothing to insert. + continue; + } + $values = $entry->toArray(); - $values['id'] = $id; - $values['is_read'] = $is_read; $entryDAO->addEntry($values, $prepared_statement); } } diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php index 490a5c5cb..c93ba2520 100644 --- a/lib/Minz/Extension.php +++ b/lib/Minz/Extension.php @@ -153,4 +153,14 @@ class Minz_Extension { public function registerViews() { Minz_View::addBasePathname($this->path); } + + /** + * Register a new hook. + * + * @param $hook_name the hook name (must exist). + * @param $hook_function the function name to call (must be callable). + */ + public function registerHook($hook_name, $hook_function) { + Minz_ExtensionManager::addHook($hook_name, $hook_function, $this); + } } diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 46e421bac..7557e178f 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -2,6 +2,8 @@ /** * An extension manager to load extensions present in EXTENSIONS_PATH. + * + * @todo see coding style for methods!! */ class Minz_ExtensionManager { private static $ext_metaname = 'metadata.json'; @@ -11,6 +13,11 @@ class Minz_ExtensionManager { private static $ext_auto_enabled = array(); + private static $hook_list = array( + 'entry_before_insert' => array(), // function($entry) + ); + private static $ext_to_hooks = array(); + /** * Initialize the extension manager by loading extensions in EXTENSIONS_PATH. * @@ -131,6 +138,8 @@ class Minz_ExtensionManager { in_array($name, self::$ext_auto_enabled)) { self::enable($ext->getName()); } + + self::$ext_to_hooks[$name] = array(); } /** @@ -187,4 +196,50 @@ class Minz_ExtensionManager { return self::$ext_list[$ext_name]; } + + /** + * Add a hook function to a given hook. + * + * The hook name must be a valid one. For the valid list, see self::$hook_list + * array keys. + * + * @param $hook_name the hook name (must exist). + * @param $hook_function the function name to call (must be callable). + * @param $ext the extension which register the hook. + */ + public static function addHook($hook_name, $hook_function, $ext) { + if (isset(self::$hook_list[$hook_name]) && is_callable($hook_function)) { + self::$hook_list[$hook_name][] = $hook_function; + self::$ext_to_hooks[$ext->getName()][] = $hook_name; + } + } + + /** + * Call functions related to a given hook. + * + * The hook name must be a valid one. For the valid list, see self::$hook_list + * array keys. + * + * @param $hook_name the hook to call. + * @param additionnal parameters (for signature, please see self::$hook_list comments) + * @todo hook functions will have different signatures. So the $res = func($args); + * $args = $res; will not work for all of them in the future. We must + * find a better way to call hooks. + */ + public static function callHook($hook_name) { + $args = func_get_args(); + unset($args[0]); + + $result = $args; + foreach (self::$hook_list[$hook_name] as $function) { + $result = call_user_func_array($function, $args); + + if (is_null($result)) { + break; + } + + $args = $result; + } + return $result; + } } -- cgit v1.2.3 From 7ef4d6c033d6d12a644b6cf39940591901fdcb3b Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 7 Dec 2014 14:39:02 +0100 Subject: Fix entry_before_insert hook The hook must be called also in: - feedController->addAction() - importExportController->importJson() See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/feedController.php | 13 ++++++++++--- app/Controllers/importExportController.php | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index dce79c57a..0a7edbee3 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -174,10 +174,17 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->beginTransaction(); foreach ($entries as $entry) { // Entries are added without any verification. + $entry->_feed($feed->id()); + $entry->_id(min(time(), $entry->date(true)) . uSecString()); + $entry->_isRead($is_read); + + $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); + if (is_null($entry)) { + // An extension has returned a null value, there is nothing to insert. + continue; + } + $values = $entry->toArray(); - $values['id_feed'] = $feed->id(); - $values['id'] = min(time(), $entry->date(true)) . uSecString(); - $values['is_read'] = $is_read; $entryDAO->addEntry($values, $prepared_statement); } $feedDAO->updateLastUpdate($feed->id()); diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 4e2dbd157..c67b30431 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -385,6 +385,12 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $entry->_id(min(time(), $entry->date(true)) . uSecString()); $entry->_tags($tags); + $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); + if (is_null($entry)) { + // An extension has returned a null value, there is nothing to insert. + continue; + } + $values = $entry->toArray(); $id = $this->entryDAO->addEntry($values, $prepared_statement); -- cgit v1.2.3 From c6dfec3ad351ee3b828c6a2c0a273bad5d9ac0df Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 8 Dec 2014 12:01:47 +0100 Subject: Add behaviour to configure action (extensions) - Put extension configure view in dir_ext/configure.phtml - Handle POST action in Extension->handleConfigureAction() method See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 16 ++++++++++++++++ app/views/extension/configure.phtml | 17 ++++++++++++++--- lib/Minz/Extension.php | 21 +++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index a1e39af37..73b8070cb 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -27,6 +27,22 @@ class FreshRSS_extension_Controller extends Minz_ActionController { if (Minz_Request::param('ajax')) { $this->view->_useLayout(false); } + + $ext_name = urldecode(Minz_Request::param('e')); + $ext = Minz_ExtensionManager::find_extension($ext_name); + + if (is_null($ext)) { + Minz_Error::error(404); + } + if ($ext->getType() === 'system' && !FreshRSS_Auth::hasAccess('admin')) { + Minz_Error::error(403); + } + + $this->view->extension = $ext; + + if (Minz_Request::isPost()) { + $this->view->extension->handleConfigureAction(); + } } /** diff --git a/app/views/extension/configure.phtml b/app/views/extension/configure.phtml index a79e9baac..295080d5e 100644 --- a/app/views/extension/configure.phtml +++ b/app/views/extension/configure.phtml @@ -7,6 +7,17 @@ if (!Minz_Request::param('ajax')) { ?>
        -

        Extension name

        - Not implemented yet! -
        \ No newline at end of file +

        extension->getName(); ?> (extension->getVersion(); ?>) — extension->getType(); ?>

        + +

        extension->getDescription(); ?> — extension->getAuthor(); ?>

        + +

        + extension->getConfigureView(); + if ($configure_view !== false) { + echo $configure_view; + } else { + ?> +

        + +
        diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php index c93ba2520..1d706ed80 100644 --- a/lib/Minz/Extension.php +++ b/lib/Minz/Extension.php @@ -86,6 +86,27 @@ class Minz_Extension { return $this->is_enabled; } + /** + * Return the content of the configure view for the current extension. + * + * @return the html content from ext_dir/configure.phtml, false if it does + * not exist. + */ + public function getConfigureView() { + $filename = $this->path . '/configure.phtml'; + if (!file_exists($filename)) { + return false; + } + return @file_get_contents($filename); + } + + /** + * Handle the configure POST action. + * + * It must be redefined by child classes. + */ + public function handleConfigureAction() {} + /** * Getters and setters. */ -- cgit v1.2.3 From 188b517daa174ce494f31dec02ae2cff122488ff Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 8 Dec 2014 13:05:56 +0100 Subject: Add a feed_before_insert hook See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/feedController.php | 6 ++++++ app/Controllers/importExportController.php | 30 ++++++++++++++++++++---------- lib/Minz/ExtensionManager.php | 1 + 3 files changed, 27 insertions(+), 10 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 0a7edbee3..7dda3840e 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -138,6 +138,12 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed->_category($cat); $feed->_httpAuth($http_auth); + // Call the extension hook + $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); + if (is_null($feed)) { + Minz_Request::bad(_t('feed_not_added', $feed->name()), $url_redirect); + } + $values = array( 'url' => $feed->url(), 'category' => $feed->category(), diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index c67b30431..52df5bf8b 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -259,10 +259,16 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $feed->_website($website); $feed->_description($description); - // addFeedObject checks if feed is already in DB so nothing else to - // check here - $id = $this->feedDAO->addFeedObject($feed); - $error = ($id === false); + // Call the extension hook + $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); + if (!is_null($feed)) { + // addFeedObject checks if feed is already in DB so nothing else to + // check here + $id = $this->feedDAO->addFeedObject($feed); + $error = ($id === false); + } else { + $error = true; + } } catch (FreshRSS_Feed_Exception $e) { Minz_Log::warning($e->getMessage()); $error = true; @@ -427,13 +433,17 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $feed->_name($name); $feed->_website($website); - // addFeedObject checks if feed is already in DB so nothing else to - // check here. - $id = $this->feedDAO->addFeedObject($feed); + // Call the extension hook + $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); + if (!is_null($feed)) { + // addFeedObject checks if feed is already in DB so nothing else to + // check here. + $id = $this->feedDAO->addFeedObject($feed); - if ($id !== false) { - $feed->_id($id); - $return = $feed; + if ($id !== false) { + $feed->_id($id); + $return = $feed; + } } } catch (FreshRSS_Feed_Exception $e) { Minz_Log::warning($e->getMessage()); diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index 5491c7cf6..9e6a3155a 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -17,6 +17,7 @@ class Minz_ExtensionManager { private static $hook_list = array( 'entry_before_display' => array(), // function($entry) -> Entry | null 'entry_before_insert' => array(), // function($entry) -> Entry | null + 'feed_before_insert' => array(), // function($feed) -> Feed | null ); private static $ext_to_hooks = array(); -- cgit v1.2.3 From 28c77f22900a10ac43c6d61b2b2d1a146feac42a Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 8 Dec 2014 13:12:12 +0100 Subject: Fix a bug with feed_before_insert hook $feed->name() was called on a null value. See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/feedController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 7dda3840e..379b8d8da 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -139,9 +139,10 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed->_httpAuth($http_auth); // Call the extension hook + $name = $feed->name(); $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed); if (is_null($feed)) { - Minz_Request::bad(_t('feed_not_added', $feed->name()), $url_redirect); + Minz_Request::bad(_t('feed_not_added', $name), $url_redirect); } $values = array( -- cgit v1.2.3 From 0543f96a97fa860fdec38d61b117e6b5addf94b6 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 8 Dec 2014 13:22:11 +0100 Subject: Update comments for ExtensionController See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index 73b8070cb..cd56de9eb 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -23,6 +23,16 @@ class FreshRSS_extension_Controller extends Minz_ActionController { $this->view->extension_list = Minz_ExtensionManager::list_extensions(); } + /** + * This action handles configuration of a given extension. + * + * Only administrator can configure a system extension. + * + * Parameters are: + * - e: the extension name (urlencoded) + * - additional parameters which should be handle by the extension + * handleConfigureAction() method (POST request). + */ public function configureAction() { if (Minz_Request::param('ajax')) { $this->view->_useLayout(false); @@ -49,6 +59,7 @@ class FreshRSS_extension_Controller extends Minz_ActionController { * This action enables a disabled extension for the current user. * * System extensions can only be enabled by an administrator. + * This action must be reached by a POST request. * * Parameter is: * - e: the extension name (urlencoded). @@ -99,6 +110,7 @@ class FreshRSS_extension_Controller extends Minz_ActionController { * This action disables an enabled extension for the current user. * * System extensions can only be disabled by an administrator. + * This action must be reached by a POST request. * * Parameter is: * - e: the extension name (urlencoded). @@ -145,6 +157,15 @@ class FreshRSS_extension_Controller extends Minz_ActionController { Minz_Request::forward($url_redirect, true); } + /** + * This action handles deletion of an extension. + * + * Only administrator can remove an extension. + * This action must be reached by a POST request. + * + * Parameter is: + * -e: extension name (urlencoded) + */ public function removeAction() { if (!FreshRSS_Auth::hasAccess('admin')) { Minz_Error::error(403); -- cgit v1.2.3 From 76358846abe2eba95668d66d3847cbdfe3f8bcdc Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 8 Dec 2014 13:36:08 +0100 Subject: Implement extension deletion See https://github.com/FreshRSS/FreshRSS/issues/252 --- app/Controllers/extensionController.php | 22 +++++++++++++++++++++- lib/lib_rss.php | 26 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'app/Controllers') diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php index cd56de9eb..adb3e1864 100644 --- a/app/Controllers/extensionController.php +++ b/app/Controllers/extensionController.php @@ -172,6 +172,26 @@ class FreshRSS_extension_Controller extends Minz_ActionController { } $url_redirect = array('c' => 'extension', 'a' => 'index'); - Minz_Request::bad('not implemented yet!', $url_redirect); + + if (Minz_Request::isPost()) { + $ext_name = urldecode(Minz_Request::param('e')); + $ext = Minz_ExtensionManager::find_extension($ext_name); + + if (is_null($ext)) { + Minz_Request::bad(_t('feedback.extensions.not_found', $ext_name), + $url_redirect); + } + + $res = recursive_unlink($ext->getPath()); + if ($res) { + Minz_Request::good(_t('feedback.extensions.removed', $ext_name), + $url_redirect); + } else { + Minz_Request::bad(_t('feedback.extensions.cannot_delete', $ext_name), + $url_redirect); + } + } + + Minz_Request::forward($url_redirect, true); } } diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 8170c7fd9..e466bcb15 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -319,3 +319,29 @@ function check_install_database() { return $status; } + +/** + * Remove a directory recursively. + * + * From http://php.net/rmdir#110489 + * + * @param $dir the directory to remove + */ +function recursive_unlink($dir) { + if (!is_dir($dir)) { + return true; + } + + $files = array_diff(scandir($dir), array('.', '..')); + foreach ($files as $filename) { + $filename = $dir . '/' . $filename; + if (is_dir($filename)) { + @chmod($filename, 0777); + recursive_unlink($filename); + } else { + unlink($filename); + } + } + + return rmdir($dir); +} -- cgit v1.2.3 From 70c1f0ebb08e2edf1721e2d3f8f98837c5910da4 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 9 Dec 2014 12:43:33 +0100 Subject: Fix redirection after feed refresh Fix https://github.com/FreshRSS/FreshRSS/issues/716 --- app/Controllers/feedController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 9990a852c..c8727c727 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -392,8 +392,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { // Redirect to the main page with correct notification. if ($updated_feeds === 1) { $feed = reset($feeds); - Minz_Request::good(_t('feed_actualized', $feed->name()), - array('get' => 'f_' . $feed->id())); + Minz_Request::good(_t('feed_actualized', $feed->name()), array( + 'params' => array('get' => 'f_' . $feed->id()) + )); } elseif ($updated_feeds > 1) { Minz_Request::good(_t('n_feeds_actualized', $updated_feeds), array()); } else { -- cgit v1.2.3 From 8a40a726575947c074216ad9084275e0195f9c30 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 10 Dec 2014 23:16:12 +0100 Subject: Fix i18n for logs, pagination and javascript vars Logs first to avoid annoying message when refreshing log page --- app/Controllers/indexController.php | 2 +- app/i18n/en/gen.php | 26 ++++++++++++++------------ app/i18n/en/index.php | 6 ++++++ app/i18n/fr/gen.php | 26 ++++++++++++++------------ app/i18n/fr/index.php | 6 ++++++ app/views/helpers/javascript_vars.phtml | 8 ++++---- app/views/helpers/logs_pagination.phtml | 8 ++++---- app/views/index/logs.phtml | 8 ++++---- 8 files changed, 53 insertions(+), 37 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 1cf618f7f..eff47ed58 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -217,7 +217,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(403); } - Minz_View::prependTitle(_t('logs') . ' · '); + Minz_View::prependTitle(_t('index.logs.title') . ' · '); if (Minz_Request::isPost()) { FreshRSS_LogDAO::truncate(); diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index eadc80360..28659cccb 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -2,6 +2,7 @@ return array( 'action' => array( + 'back_to_rss_feeds' => '← Go back to your RSS feeds', 'disable' => 'Disable', 'enable' => 'Enable', 'manage' => 'Manage', @@ -11,6 +12,13 @@ return array( 'login' => 'Login', 'logout' => 'Logout', ), + 'js' => array( + 'category_empty' => 'Empty category', + 'confirm_action' => 'Are you sure you want to perform this action? It cannot be cancelled!', + 'confirm_action_feed_cat' => 'Are you sure you want to perform this action? You will lose related favorites and user queries. It cannot be cancelled!', + 'notif_body_new_articles' => 'There are \\d new articles to read on FreshRSS.', + 'notif_title_new_articles' => 'FreshRSS: new articles!', + ), 'menu' => array( 'about' => 'About', 'admin' => 'Administration', @@ -29,6 +37,12 @@ return array( 'user_management' => 'Manage users', 'user_profile' => 'Profile', ), + 'pagination' => array( + 'first' => 'First', + 'last' => 'Last', + 'next' => 'Next', + 'previous' => 'Previous', + ), 'title' => array( '_' => 'Title', 'authentication' => 'Authentication', @@ -96,7 +110,6 @@ return array( 'auto_remove_article' => 'Hide articles after reading', 'auto_share' => 'Share', 'auto_share_help' => 'If there is only one sharing mode, it is used. Else modes are accessible by their number.', - 'back_to_rss_feeds' => '← Go back to your RSS feeds', 'bad_opml_file' => 'Your OPML file is invalid', 'base_url' => 'Base URL', 'bdd' => 'Database', @@ -125,7 +138,6 @@ return array( 'category_created' => 'Category %s has been created.', 'category_deleted' => 'Category has been deleted.', 'category_emptied' => 'Category has been emptied', - 'category_empty' => 'Empty category', 'category_name_exists' => 'Category name already exists.', 'category_no_id' => 'You must precise the id of the category.', 'category_no_name' => 'Category name cannot be empty.', @@ -136,11 +148,8 @@ return array( 'change_value' => 'You should change this value by any other', 'checks' => 'Checks', 'choose_language' => 'Choose a language for FreshRSS', - 'clear_logs' => 'Clear the logs', 'collapse_article' => 'Collapse', 'configuration_updated' => 'Configuration has been updated', - 'confirm_action' => 'Are you sure you want to perform this action? It cannot be cancelled!', - 'confirm_action_feed_cat' => 'Are you sure you want to perform this action? You will lose related favorites and user queries. It cannot be cancelled!', 'congratulations' => 'Congratulations!', 'content_width' => 'Content width', 'create' => 'Create', @@ -204,7 +213,6 @@ return array( 'file_to_import' => 'File to import
        (OPML, Json or Zip)', 'file_to_import_no_zip' => 'File to import
        (OPML or Json)', 'finish_installation' => 'Complete installation', - 'first' => 'First', 'first_article' => 'Skip to the first article', 'fix_errors_before' => 'Fix errors before skip to the next step.', 'focus_search' => 'Access search box', @@ -252,7 +260,6 @@ return array( 'keep_logged_in' => 'Keep me logged in (1 month)', 'language' => 'Language', 'language_defined' => 'Language has been defined.', - 'last' => 'Last', 'last_3_month' => 'Last three months', 'last_6_month' => 'Last six months', 'last_article' => 'Skip to the last article', @@ -267,7 +274,6 @@ return array( 'login_persona_problem' => 'Connection problem with Persona?', 'login_required' => 'Login required:', 'login_with_persona' => 'Login with Persona', - 'logs_empty' => 'Log file is empty', 'mar' => 'mar', 'march' => 'Mar', 'mark_cat_read' => 'Mark category as read', @@ -283,7 +289,6 @@ return array( 'n_feeds_actualized' => '%d feeds have been updated', 'new_article' => 'There are new available articles, click to refresh the page.', 'new_category' => 'New category', - 'next' => 'Next', 'next_article' => 'Skip to the next article', 'next_page' => 'Skip to the next page', 'next_step' => 'Go to the next step', @@ -301,8 +306,6 @@ return array( 'not_reads' => '%d unread', 'not_yet_implemented' => 'Not yet implemented', 'nothing_to_load' => 'There are no more articles', - 'notif_body_new_articles' => 'There are \\d new articles to read on FreshRSS.', - 'notif_title_new_articles' => 'FreshRSS: new articles!', 'nov' => 'nov', 'november' => 'Nov', 'number_articles' => '%d articles', @@ -329,7 +332,6 @@ return array( 'php_is_nok' => 'Your PHP version is %s but FreshRSS requires at least version %s', 'php_is_ok' => 'Your PHP version is %s, which is compatible with FreshRSS', 'prefix' => 'Table prefix', - 'previous' => 'Previous', 'previous_article' => 'Skip to the previous article', 'previous_page' => 'Skip to the previous page', 'print' => 'Print', diff --git a/app/i18n/en/index.php b/app/i18n/en/index.php index 5e05657d1..97df646c4 100644 --- a/app/i18n/en/index.php +++ b/app/i18n/en/index.php @@ -1,6 +1,12 @@ array( + '_' => 'Logs', + 'clear' => 'Clear the logs', + 'empty' => 'Log file is empty', + 'title' => 'Logs', + ), 'menu' => array( 'about' => 'About FreshRSS', 'actualize' => 'Actualize', diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index d22e51f2d..3d3878eb1 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -2,6 +2,7 @@ return array( 'action' => array( + 'back_to_rss_feeds' => '← Retour à vos flux RSS', 'disable' => 'Désactiver', 'enable' => 'Activer', 'manage' => 'Gérer', @@ -11,6 +12,13 @@ return array( 'login' => 'Connexion', 'logout' => 'Déconnexion', ), + 'js' => array( + 'category_empty' => 'Catégorie vide', + 'confirm_action' => 'Êtes-vous sûr(e) de vouloir continuer ? Cette action ne peut être annulée !', + 'confirm_action_feed_cat' => 'Êtes-vous sûr(e) de vouloir continuer ? Vous perdrez les favoris et les filtres associés. Cette action ne peut être annulée !', + 'notif_body_new_articles' => 'Il y a \\d nouveaux articles à lire sur FreshRSS.', + 'notif_title_new_articles' => 'FreshRSS : nouveaux articles !', + ), 'menu' => array( 'about' => 'À propos', 'admin' => 'Administration', @@ -29,6 +37,12 @@ return array( 'user_management' => 'Gestion des utilisateurs', 'user_profile' => 'Profil', ), + 'pagination' => array( + 'first' => 'Début', + 'last' => 'Fin', + 'next' => 'Suivant', + 'previous' => 'Précédent', + ), 'title' => array( '_' => 'Titre', 'authentication' => 'Authentification', @@ -96,7 +110,6 @@ return array( 'auto_remove_article' => 'Cacher les articles après lecture', 'auto_share' => 'Partager', 'auto_share_help' => 'S’il n’y a qu’un mode de partage, celui-ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.', - 'back_to_rss_feeds' => '← Retour à vos flux RSS', 'bad_opml_file' => 'Votre fichier OPML n’est pas valide.', 'base_url' => 'Base de l’URL', 'bdd' => 'Base de données', @@ -125,7 +138,6 @@ return array( 'category_created' => 'La catégorie %s a été créée.', 'category_deleted' => 'La catégorie a été supprimée.', 'category_emptied' => 'La catégorie a été vidée.', - 'category_empty' => 'Catégorie vide', 'category_name_exists' => 'Une catégorie possède déjà ce nom.', 'category_no_id' => 'Vous devez préciser l’id de la catégorie.', 'category_no_name' => 'Vous devez préciser un nom pour la catégorie.', @@ -136,11 +148,8 @@ return array( 'change_value' => 'Vous devriez changer cette valeur par n’importe quelle autre', 'checks' => 'Vérifications', 'choose_language' => 'Choisissez la langue pour FreshRSS', - 'clear_logs' => 'Effacer les logs', 'collapse_article' => 'Refermer', 'configuration_updated' => 'La configuration a été mise à jour.', - 'confirm_action' => 'Êtes-vous sûr(e) de vouloir continuer ? Cette action ne peut être annulée !', - 'confirm_action_feed_cat' => 'Êtes-vous sûr(e) de vouloir continuer ? Vous perdrez les favoris et les filtres associés. Cette action ne peut être annulée !', 'congratulations' => 'Félicitations !', 'content_width' => 'Largeur du contenu', 'create' => 'Créer', @@ -204,7 +213,6 @@ return array( 'file_to_import' => 'Fichier à importer
        (OPML, Json ou Zip)', 'file_to_import_no_zip' => 'Fichier à importer
        (OPML ou Json)', 'finish_installation' => 'Terminer l’installation', - 'first' => 'Début', 'first_article' => 'Passer au premier article', 'fix_errors_before' => 'Veuillez corriger les erreurs avant de passer à l’étape suivante.', 'focus_search' => 'Accéder à la recherche', @@ -252,7 +260,6 @@ return array( 'keep_logged_in' => 'Rester connecté (1 mois)', 'language' => 'Langue', 'language_defined' => 'La langue a bien été définie.', - 'last' => 'Fin', 'last_3_month' => 'Depuis les trois derniers mois', 'last_6_month' => 'Depuis les six derniers mois', 'last_article' => 'Passer au dernier article', @@ -267,7 +274,6 @@ return array( 'login_persona_problem' => 'Problème de connexion à Persona ?', 'login_required' => 'Accès protégé par mot de passe :', 'login_with_persona' => 'Connexion avec Persona', - 'logs_empty' => 'Les logs sont vides.', 'mar' => 'mar.', 'march' => 'mars', 'mark_cat_read' => 'Marquer la catégorie comme lue', @@ -283,7 +289,6 @@ return array( 'n_feeds_actualized' => '%d flux ont été mis à jour.', 'new_article' => 'Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.', 'new_category' => 'Nouvelle catégorie', - 'next' => 'Suivant', 'next_article' => 'Passer à l’article suivant', 'next_page' => 'Passer à la page suivante', 'next_step' => 'Passer à l’étape suivante', @@ -301,8 +306,6 @@ return array( 'not_reads' => '%d non lus', 'not_yet_implemented' => 'Pas encore implémenté', 'nothing_to_load' => 'Fin des articles', - 'notif_body_new_articles' => 'Il y a \\d nouveaux articles à lire sur FreshRSS.', - 'notif_title_new_articles' => 'FreshRSS : nouveaux articles !', 'nov' => 'nov.', 'november' => 'novembre', 'number_articles' => '%d articles', @@ -329,7 +332,6 @@ return array( 'php_is_nok' => 'Votre version de PHP est la %s mais FreshRSS requiert au moins la version %s', 'php_is_ok' => 'Votre version de PHP est la %s, qui est compatible avec FreshRSS', 'prefix' => 'Préfixe des tables', - 'previous' => 'Précédent', 'previous_article' => 'Passer à l’article précédent', 'previous_page' => 'Passer à la page précédente', 'print' => 'Imprimer', diff --git a/app/i18n/fr/index.php b/app/i18n/fr/index.php index 3fea1b879..4b8c85033 100644 --- a/app/i18n/fr/index.php +++ b/app/i18n/fr/index.php @@ -1,6 +1,12 @@ array( + '_' => 'Logs', + 'clear' => 'Effacer les logs', + 'empty' => 'Les logs sont vides.', + 'title' => 'Logs', + ), 'menu' => array( 'about' => 'À propos de FreshRSS', 'actualize' => 'Actualiser', diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml index 0961ac3fe..6577e0109 100644 --- a/app/views/helpers/javascript_vars.phtml +++ b/app/views/helpers/javascript_vars.phtml @@ -59,10 +59,10 @@ echo 'url={', "},\n"; echo 'i18n={', - 'confirmation_default:"', _t('confirm_action'), '",', - 'notif_title_articles:"', _t('notif_title_new_articles'), '",', - 'notif_body_articles:"', _t('notif_body_new_articles'), '",', - 'category_empty:"', _t('category_empty'), '"', + 'confirmation_default:"', _t('gen.js.confirm_action'), '",', + 'notif_title_articles:"', _t('gen.js.notif_title_new_articles'), '",', + 'notif_body_articles:"', _t('gen.js.notif_body_new_articles'), '",', + 'category_empty:"', _t('gen.js.category_empty'), '"', "},\n"; echo 'icons={', diff --git a/app/views/helpers/logs_pagination.phtml b/app/views/helpers/logs_pagination.phtml index ad46279c7..58b3c68f4 100755 --- a/app/views/helpers/logs_pagination.phtml +++ b/app/views/helpers/logs_pagination.phtml @@ -9,14 +9,14 @@
      • currentPage > 1) { ?> - « + «
      • currentPage - 1; ?>
      • currentPage > 1) { ?> - +
      • @@ -34,13 +34,13 @@ currentPage + 1; ?>
      • currentPage < $this->nbPage) { ?> - +
      • nbPage; ?>
      • currentPage < $this->nbPage) { ?> - » + »
      diff --git a/app/views/index/logs.phtml b/app/views/index/logs.phtml index 101692daf..0262325f5 100644 --- a/app/views/index/logs.phtml +++ b/app/views/index/logs.phtml @@ -1,10 +1,10 @@
      - + -

      +

      - +

      logsPaginator->items(); ?> @@ -20,6 +20,6 @@ logsPaginator->render('logs_pagination.phtml','page'); ?>
      -

      +

      -- cgit v1.2.3 From d455837c6d6e3ad3d64d06f40c947c93fc4e2086 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 11 Dec 2014 00:00:15 +0100 Subject: Fix i18n for normal view --- app/Controllers/indexController.php | 2 +- app/Models/Context.php | 4 +-- app/i18n/en/gen.php | 62 +++++++++++++++---------------------- app/i18n/en/index.php | 25 ++++++++++++++- app/i18n/fr/gen.php | 62 +++++++++++++++---------------------- app/i18n/fr/index.php | 25 ++++++++++++++- app/layout/header.phtml | 2 +- app/views/helpers/pagination.phtml | 8 ++--- app/views/index/logs.phtml | 6 ++-- app/views/index/normal.phtml | 16 +++++----- lib/lib_rss.php | 8 ++--- 11 files changed, 121 insertions(+), 99 deletions(-) (limited to 'app/Controllers') diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index eff47ed58..2759ab289 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -217,7 +217,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(403); } - Minz_View::prependTitle(_t('index.logs.title') . ' · '); + Minz_View::prependTitle(_t('index.log.title') . ' · '); if (Minz_Request::isPost()) { FreshRSS_LogDAO::truncate(); diff --git a/app/Models/Context.php b/app/Models/Context.php index 3dc5349ad..c8a65063a 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -138,12 +138,12 @@ class FreshRSS_Context { switch($type) { case 'a': self::$current_get['all'] = true; - self::$name = _t('your_rss_feeds'); + self::$name = _t('index.feed.title'); self::$get_unread = self::$total_unread; break; case 's': self::$current_get['starred'] = true; - self::$name = _t('your_favorites'); + self::$name = _t('index.feed.title_fav'); self::$get_unread = self::$total_starred['unread']; // Update state if favorite is not yet enabled. diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php index 28659cccb..a9045c299 100644 --- a/app/i18n/en/gen.php +++ b/app/i18n/en/gen.php @@ -12,10 +12,30 @@ return array( 'login' => 'Login', 'logout' => 'Logout', ), + 'date' => array( + 'Apr' => '\\A\\p\\r\\i\\l', + 'Aug' => '\\A\\u\\g\\u\\s\\t', + 'Dec' => '\\D\\e\\c\\e\\m\\b\\e\\r', + 'Feb' => '\\F\\e\\b\\r\\u\\a\\r\\y', + 'Jan' => '\\J\\a\\n\\u\\a\\r\\y', + 'Jul' => '\\J\\u\\l\\y', + 'Jun' => '\\J\\u\\n\\e', + 'Mar' => '\\M\\a\\r\\c\\h', + 'May' => '\\M\\a\\y', + 'Nov' => '\\N\\o\\v\\e\\m\\b\\e\\r', + 'Oct' => '\\O\\c\\t\\o\\b\\e\\r', + 'Sep' => '\\S\\e\\p\\t\\e\\m\\b\\e\\r', + 'before_yesterday' => 'Before yesterday', + 'format_date' => '%s j\\<\\s\\u\\p\\>S\\<\\/\\s\\u\\p\\> Y', + 'format_date_hour' => '%s j\\<\\s\\u\\p\\>S\\<\\/\\s\\u\\p\\> Y \\a\\t H\\:i', + 'today' => 'Today', + 'yesterday' => 'Yesterday', + ), 'js' => array( 'category_empty' => 'Empty category', 'confirm_action' => 'Are you sure you want to perform this action? It cannot be cancelled!', 'confirm_action_feed_cat' => 'Are you sure you want to perform this action? You will lose related favorites and user queries. It cannot be cancelled!', + 'new_article' => 'There are new available articles, click to refresh the page.', 'notif_body_new_articles' => 'There are \\d new articles to read on FreshRSS.', 'notif_title_new_articles' => 'FreshRSS: new articles!', ), @@ -30,6 +50,7 @@ return array( 'logs' => 'Logs', 'queries' => 'User queries', 'reading' => 'Reading', + 'search' => 'Search words or #tags', 'sharing' => 'Sharing', 'shortcuts' => 'Shortcuts', 'stats' => 'Statistics', @@ -40,7 +61,10 @@ return array( 'pagination' => array( 'first' => 'First', 'last' => 'Last', + 'load_more' => 'Load more articles', + 'mark_all_read' => 'Mark all as read', 'next' => 'Next', + 'nothing_to_load' => 'There are no more articles', 'previous' => 'Previous', ), 'title' => array( @@ -51,18 +75,7 @@ return array( 'user_management' => 'Manage users', 'user_profile' => 'Profile', ), - 'Apr' => '\\A\\p\\r\\i\\l', - 'Aug' => '\\A\\u\\g\\u\\s\\t', - 'Dec' => '\\D\\e\\c\\e\\m\\b\\e\\r', - 'Feb' => '\\F\\e\\b\\r\\u\\a\\r\\y', - 'Jan' => '\\J\\a\\n\\u\\a\\r\\y', - 'Jul' => '\\J\\u\\l\\y', - 'Jun' => '\\J\\u\\n\\e', - 'Mar' => '\\M\\a\\r\\c\\h', - 'May' => '\\M\\a\\y', - 'Nov' => '\\N\\o\\v\\e\\m\\b\\e\\r', - 'Oct' => '\\O\\c\\t\\o\\b\\e\\r', - 'Sep' => '\\S\\e\\p\\t\\e\\m\\b\\e\\r', + 'freshrss' => 'FreshRSS', 'access_denied' => 'You don’t have permission to access this page', 'access_protected_feeds' => 'Connection allows to access HTTP protected RSS feeds', 'activate_sharing' => 'Activate sharing', @@ -117,13 +130,10 @@ return array( 'bdd_conf_is_ok' => 'Database configuration has been saved.', 'bdd_configuration' => 'Database configuration', 'bdd_type' => 'Type of database', - 'before_yesterday' => 'Before yesterday', 'blank_to_disable' => 'Leave blank to disable', - 'blogotext' => 'Blogotext', 'bottom_line' => 'Bottom line', 'bugs_reports' => 'Bugs reports', 'by' => 'by', - 'by_author' => 'By %s', 'by_default' => 'By default', 'by_email' => 'By email', 'by_feed' => 'by feed', @@ -171,14 +181,12 @@ return array( 'default_view' => 'Default view', 'delete' => 'Delete', 'delete_articles_every' => 'Remove articles after', - 'diaspora' => 'Diaspora*', 'display_articles_unfolded' => 'Show articles unfolded by default', 'display_categories_unfolded' => 'Show categories folded by default', 'display_configuration' => 'Display', 'do_not_change_if_doubt' => 'Don’t change if you doubt about it', 'dom_is_nok' => 'You lack a required library to browse the DOM (php-xml package)', 'dom_is_ok' => 'You have the required library to browse the DOM', - 'email' => 'Email', 'error_occurred' => 'An error occurred', 'error_occurred_update' => 'Nothing was changed', 'explain_token' => 'Allows to access RSS output of the default user without authentication.
      %s?output=rss&token=%s', @@ -186,7 +194,6 @@ return array( 'export_no_zip_extension' => 'Zip extension is not present on your server. Please try to export files one by one.', 'export_opml' => 'Export list of feeds (OPML)', 'export_starred' => 'Export your favourites', - 'facebook' => 'Facebook', 'favicons_is_ok' => 'Permissions on favicons directory are good', 'feb' => 'feb', 'february' => 'Feb', @@ -216,13 +223,9 @@ return array( 'first_article' => 'Skip to the first article', 'fix_errors_before' => 'Fix errors before skip to the next step.', 'focus_search' => 'Access search box', - 'format_date' => '%s j\\<\\s\\u\\p\\>S\\<\\/\\s\\u\\p\\> Y', - 'format_date_hour' => '%s j\\<\\s\\u\\p\\>S\\<\\/\\s\\u\\p\\> Y \\a\\t H\\:i', - 'freshrss' => 'FreshRSS', 'freshrss_description' => 'FreshRSS is a RSS feeds aggregator to self-host like Kriss Feed or Leed. It is light and easy to take in hand while being powerful and configurable tool.', 'freshrss_installation' => 'Installation · FreshRSS', 'fri' => 'Fri', - 'g+' => 'Google+', 'general_conf_is_ok' => 'General configuration has been saved.', 'general_configuration' => 'General configuration', 'github_or_email' => 'on Github or by mail', @@ -268,7 +271,6 @@ return array( 'last_year' => 'Last year', 'lead_developer' => 'Lead developer', 'license' => 'License', - 'load_more' => 'Load more articles', 'log_is_ok' => 'Permissions on logs directory are good', 'login_configuration' => 'Login', 'login_persona_problem' => 'Connection problem with Persona?', @@ -287,7 +289,6 @@ return array( 'more_information' => 'More information', 'n_entries_deleted' => '%d articles have been deleted', 'n_feeds_actualized' => '%d feeds have been updated', - 'new_article' => 'There are new available articles, click to refresh the page.', 'new_category' => 'New category', 'next_article' => 'Skip to the next article', 'next_page' => 'Skip to the next page', @@ -305,7 +306,6 @@ return array( 'not_read' => '%d unread', 'not_reads' => '%d unread', 'not_yet_implemented' => 'Not yet implemented', - 'nothing_to_load' => 'There are no more articles', 'nov' => 'nov', 'november' => 'Nov', 'number_articles' => '%d articles', @@ -334,7 +334,6 @@ return array( 'prefix' => 'Table prefix', 'previous_article' => 'Skip to the previous article', 'previous_page' => 'Skip to the previous page', - 'print' => 'Print', 'project_website' => 'Project website', 'public' => 'Public', 'publication_date' => 'Date of publication', @@ -370,21 +369,16 @@ return array( 'random_string' => 'Random string', 'reading_confirm' => 'Display a confirmation dialog on “mark all as read” actions', 'refresh' => 'Refresh', - 'related_tags' => 'Related tags', 'retrieve_truncated_feeds' => 'Retrieves truncated RSS feeds (attention, requires more time!)', 'rss_feed_management' => 'RSS feeds management', 'rss_feeds_of' => 'RSS feed of %s', 'sat' => 'Sat', 'save' => 'Save', 'scroll' => 'while scrolling', - 'search' => 'Search words or #tags', - 'search_short' => 'Search', 'seconds_(0_means_no_timeout)' => 'seconds (0 means no timeout)', 'see_on_website' => 'See on original website', 'sep' => 'sep', 'september' => 'Sep', - 'shaarli' => 'Shaarli', - 'share' => 'Share', 'share_name' => 'Share name to display', 'share_url' => 'Share URL to use', 'sharing_management' => 'Sharing options management', @@ -422,12 +416,10 @@ return array( 'think_to_add' => 'You may add some feeds.', 'this_is_the_end' => 'This is the end', 'thu' => 'Thu', - 'today' => 'Today', 'top_line' => 'Top line', 'truncate' => 'Delete all articles', 'ttl' => 'Do not automatically refresh more often than', 'tue' => 'Tue', - 'twitter' => 'Twitter', 'unsafe_autologin' => 'Allow unsafe automatic login using the format: ', 'update_apply' => 'Apply', 'update_can_apply' => 'An update is available.', @@ -452,7 +444,6 @@ return array( 'users_list' => 'List of users', 'version' => 'Version', 'version_update' => 'Update', - 'wallabag' => 'wallabag', 'website' => 'Website', 'website_url' => 'Website URL', 'wed' => 'Wed', @@ -461,10 +452,7 @@ return array( 'width_no_limit' => 'No limit', 'width_thin' => 'Thin', 'yes' => 'Yes', - 'yesterday' => 'Yesterday', 'your_diaspora_pod' => 'Your Diaspora* pod', - 'your_favorites' => 'Your favourites', - 'your_rss_feeds' => 'Your RSS feeds', 'your_shaarli' => 'Your Shaarli', 'your_wallabag' => 'Your wallabag', 'zip_error' => 'An error occured during Zip import.', diff --git a/app/i18n/en/index.php b/app/i18n/en/index.php index 97df646c4..723feefd7 100644 --- a/app/i18n/en/index.php +++ b/app/i18n/en/index.php @@ -1,7 +1,14 @@ array( + 'entry' => array( + 'by_author' => 'By %s', + ), + 'feed' => array( + 'title' => 'Your RSS feeds', + 'title_fav' => 'Your favourites', + ), + 'log' => array( '_' => 'Logs', 'clear' => 'Clear the logs', 'empty' => 'Log file is empty', @@ -28,10 +35,26 @@ return array( 'read' => 'Show only unread', 'reader_view' => 'Reading view', 'rss_view' => 'RSS feed', + 'search_short' => 'Search', 'see_website' => 'See website', 'starred' => 'Show only favorites', 'stats' => 'Statistics', 'subscription' => 'Subscriptions management', 'unread' => 'Show only read', ), + 'share' => array( + '_' => 'Share', + 'blogotext' => 'Blogotext', + 'diaspora' => 'Diaspora*', + 'email' => 'Email', + 'facebook' => 'Facebook', + 'g+' => 'Google+', + 'print' => 'Print', + 'shaarli' => 'Shaarli', + 'twitter' => 'Twitter', + 'wallabag' => 'wallabag', + ), + 'tag' => array( + 'related' => 'Related tags', + ), ); diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php index 3d3878eb1..b999b130c 100644 --- a/app/i18n/fr/gen.php +++ b/app/i18n/fr/gen.php @@ -12,10 +12,30 @@ return array( 'login' => 'Connexion', 'logout' => 'Déconnexion', ), + 'date' => array( + 'Apr' => '\\a\\v\\r\\i\\l', + 'Aug' => '\\a\\o\\û\\t', + 'Dec' => '\\d\\é\\c\\e\\m\\b\\r\\e', + 'Feb' => '\\f\\é\\v\\r\\i\\e\\r', + 'Jan' => '\\j\\a\\n\\v\\i\\e\\r', + 'Jul' => '\\j\\u\\i\\l\\l\\e\\t', + 'Jun' => '\\j\\u\\i\\n', + 'Mar' => '\\m\\a\\r\\s', + 'May' => '\\m\\a\\i', + 'Nov' => '\\n\\o\\v\\e\\m\\b\\r\\e', + 'Oct' => '\\o\\c\\t\\o\\b\\r\\e', + 'Sep' => '\\s\\e\\p\\t\\e\\m\\b\\r\\e', + 'before_yesterday' => 'À partir d’avant-hier', + 'format_date' => 'j %s Y', + 'format_date_hour' => 'j %s Y \\à H\\:i', + 'today' => 'Aujourd’hui', + 'yesterday' => 'Hier', + ), 'js' => array( 'category_empty' => 'Catégorie vide', 'confirm_action' => 'Êtes-vous sûr(e) de vouloir continuer ? Cette action ne peut être annulée !', 'confirm_action_feed_cat' => 'Êtes-vous sûr(e) de vouloir continuer ? Vous perdrez les favoris et les filtres associés. Cette action ne peut être annulée !', + 'new_article' => 'Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.', 'notif_body_new_articles' => 'Il y a \\d nouveaux articles à lire sur FreshRSS.', 'notif_title_new_articles' => 'FreshRSS : nouveaux articles !', ), @@ -30,6 +50,7 @@ return array( 'logs' => 'Logs', 'queries' => 'Filtres utilisateurs', 'reading' => 'Lecture', + 'search' => 'Rechercher des mots ou des #tags', 'sharing' => 'Partage', 'shortcuts' => 'Raccourcis', 'stats' => 'Statistiques', @@ -40,7 +61,10 @@ return array( 'pagination' => array( 'first' => 'Début', 'last' => 'Fin', + 'load_more' => 'Charger plus d’articles', + 'mark_all_read' => 'Tout marquer comme lu', 'next' => 'Suivant', + 'nothing_to_load' => 'Fin des articles', 'previous' => 'Précédent', ), 'title' => array( @@ -51,18 +75,7 @@ return array( 'user_management' => 'Gestion des utilisateurs', 'user_profile' => 'Profil', ), - 'Apr' => '\\a\\v\\r\\i\\l', - 'Aug' => '\\a\\o\\û\\t', - 'Dec' => '\\d\\é\\c\\e\\m\\b\\r\\e', - 'Feb' => '\\f\\é\\v\\r\\i\\e\\r', - 'Jan' => '\\j\\a\\n\\v\\i\\e\\r', - 'Jul' => '\\j\\u\\i\\l\\l\\e\\t', - 'Jun' => '\\j\\u\\i\\n', - 'Mar' => '\\m\\a\\r\\s', - 'May' => '\\m\\a\\i', - 'Nov' => '\\n\\o\\v\\e\\m\\b\\r\\e', - 'Oct' => '\\o\\c\\t\\o\\b\\r\\e', - 'Sep' => '\\s\\e\\p\\t\\e\\m\\b\\r\\e', + 'freshrss' => 'FreshRSS', 'access_denied' => 'Vous n’avez pas le droit d’accéder à cette page !', 'access_protected_feeds' => 'La connexion permet d’accéder aux flux protégés par une authentification HTTP.', 'activate_sharing' => 'Activer le partage', @@ -117,13 +130,10 @@ return array( 'bdd_conf_is_ok' => 'La configuration de la base de données a été enregistrée.', 'bdd_configuration' => 'Base de données', 'bdd_type' => 'Type de base de données', - 'before_yesterday' => 'À partir d’avant-hier', 'blank_to_disable' => 'Laissez vide pour désactiver', - 'blogotext' => 'Blogotext', 'bottom_line' => 'Ligne du bas', 'bugs_reports' => 'Rapports de bugs', 'by' => 'par', - 'by_author' => 'Par %s', 'by_default' => 'Par défaut', 'by_email' => 'Par courriel', 'by_feed' => 'par flux', @@ -171,14 +181,12 @@ return array( 'default_view' => 'Vue par défaut', 'delete' => 'Supprimer', 'delete_articles_every' => 'Supprimer les articles après', - 'diaspora' => 'Diaspora*', 'display' => 'Affichage', 'display_articles_unfolded' => 'Afficher les articles dépliés par défaut', 'display_categories_unfolded' => 'Afficher les catégories pliées par défaut', 'do_not_change_if_doubt' => 'Laissez tel quel dans le doute', 'dom_is_nok' => 'Il manque une librairie pour parcourir le DOM (paquet php-xml)', 'dom_is_ok' => 'Vous disposez du nécessaire pour parcourir le DOM', - 'email' => 'Courriel', 'error_occurred' => 'Une erreur est survenue !', 'error_occurred_update' => 'Rien n’a été modifié !', 'explain_token' => 'Permet d’accéder à la sortie RSS de l’utilisateur par défaut sans besoin de s’authentifier.
      %s?output=rss&token=%s', @@ -186,7 +194,6 @@ return array( 'export_no_zip_extension' => 'L’extension Zip n’est pas présente sur votre serveur. Veuillez essayer d’exporter les fichiers un par un.', 'export_opml' => 'Exporter la liste des flux (OPML)', 'export_starred' => 'Exporter les favoris', - 'facebook' => 'Facebook', 'favicons_is_ok' => 'Les droits sur le répertoire des favicons sont bons', 'feb' => 'fév.', 'february' => 'février', @@ -216,13 +223,9 @@ return array( 'first_article' => 'Passer au premier article', 'fix_errors_before' => 'Veuillez corriger les erreurs avant de passer à l’étape suivante.', 'focus_search' => 'Accéder à la recherche', - 'format_date' => 'j %s Y', - 'format_date_hour' => 'j %s Y \\à H\\:i', - 'freshrss' => 'FreshRSS', 'freshrss_description' => 'FreshRSS est un agrégateur de flux RSS à auto-héberger à l’image de Kriss Feed ou Leed. Il se veut léger et facile à prendre en main tout en étant un outil puissant et paramétrable.', 'freshrss_installation' => 'Installation · FreshRSS', 'fri' => 'ven.', - 'g+' => 'Google+', 'general_conf_is_ok' => 'La configuration générale a été enregistrée.', 'general_configuration' => 'Configuration générale', 'github_or_email' => 'sur Github ou par courriel', @@ -268,7 +271,6 @@ return array( 'last_year' => 'Depuis l’année dernière', 'lead_developer' => 'Développeur principal', 'license' => 'Licence', - 'load_more' => 'Charger plus d’articles', 'log_is_ok' => 'Les droits sur le répertoire des logs sont bons', 'login_configuration' => 'Identification', 'login_persona_problem' => 'Problème de connexion à Persona ?', @@ -287,7 +289,6 @@ return array( 'more_information' => 'Plus d’informations', 'n_entries_deleted' => '%d articles ont été supprimés.', 'n_feeds_actualized' => '%d flux ont été mis à jour.', - 'new_article' => 'Il y a de nouveaux articles disponibles, cliquez pour rafraîchir la page.', 'new_category' => 'Nouvelle catégorie', 'next_article' => 'Passer à l’article suivant', 'next_page' => 'Passer à la page suivante', @@ -305,7 +306,6 @@ return array( 'not_read' => '%d non lu', 'not_reads' => '%d non lus', 'not_yet_implemented' => 'Pas encore implémenté', - 'nothing_to_load' => 'Fin des articles', 'nov' => 'nov.', 'november' => 'novembre', 'number_articles' => '%d articles', @@ -334,7 +334,6 @@ return array( 'prefix' => 'Préfixe des tables', 'previous_article' => 'Passer à l’article précédent', 'previous_page' => 'Passer à la page précédente', - 'print' => 'Imprimer', 'project_website' => 'Site du projet', 'public' => 'Public', 'publication_date' => 'Date de publication', @@ -370,21 +369,16 @@ return array( 'random_string' => 'Chaîne aléatoire', 'reading_confirm' => 'Afficher une confirmation lors des actions “marquer tout comme lu”', 'refresh' => 'Actualisation', - 'related_tags' => 'Tags associés', 'retrieve_truncated_feeds' => 'Permet de récupérer les flux tronqués (attention, demande plus de temps !)', 'rss_feed_management' => 'Gestion des flux RSS', 'rss_feeds_of' => 'Flux RSS de %s', 'sat' => 'sam.', 'save' => 'Enregistrer', 'scroll' => 'au défilement de la page', - 'search' => 'Rechercher des mots ou des #tags', - 'search_short' => 'Rechercher', 'seconds_(0_means_no_timeout)' => 'secondes (0 signifie aucun timeout ) ', 'see_on_website' => 'Voir sur le site d’origine', 'sep' => 'sep.', 'september' => 'septembre', - 'shaarli' => 'Shaarli', - 'share' => 'Partager', 'share_name' => 'Nom du partage à afficher', 'share_url' => 'URL du partage à utiliser', 'sharing_management' => 'Gestion des options de partage', @@ -422,12 +416,10 @@ return array( 'think_to_add' => 'Vous pouvez ajouter des flux.', 'this_is_the_end' => 'This is the end', 'thu' => 'jeu.', - 'today' => 'Aujourd’hui', 'top_line' => 'Ligne du haut', 'truncate' => 'Supprimer tous les articles', 'ttl' => 'Ne pas automatiquement rafraîchir plus souvent que', 'tue' => 'mar.', - 'twitter' => 'Twitter', 'unsafe_autologin' => 'Autoriser les connexions automatiques non-sûres au format : ', 'update_apply' => 'Appliquer la mise à jour', 'update_can_apply' => 'Une mise à jour est disponible.', @@ -452,7 +444,6 @@ return array( 'users_list' => 'Liste des utilisateurs', 'version' => 'Version', 'version_update' => 'Mise à jour', - 'wallabag' => 'wallabag', 'website' => 'Site Internet', 'website_url' => 'URL du site', 'wed' => 'mer.', @@ -461,10 +452,7 @@ return array( 'width_no_limit' => 'Pas de limite', 'width_thin' => 'Fine', 'yes' => 'Oui', - 'yesterday' => 'Hier', 'your_diaspora_pod' => 'Votre pod Diaspora*', - 'your_favorites' => 'Vos favoris', - 'your_rss_feeds' => 'Vos flux RSS', 'your_shaarli' => 'Votre Shaarli', 'your_wallabag' => 'Votre wallabag', 'zip_error' => 'Une erreur est survenue durant l’import du fichier Zip.', diff --git a/app/i18n/fr/index.php b/app/i18n/fr/index.php index 4b8c85033..e21cc4410 100644 --- a/app/i18n/fr/index.php +++ b/app/i18n/fr/index.php @@ -1,7 +1,14 @@ array( + 'entry' => array( + 'by_author' => 'Par %s', + ), + 'feed' => array( + 'title' => 'Vos flux RSS', + 'title_fav' => 'Vos favoris', + ), + 'log' => array( '_' => 'Logs', 'clear' => 'Effacer les logs', 'empty' => 'Les logs sont vides.', @@ -28,10 +35,26 @@ return array( 'read' => 'Afficher les non lus', 'reader_view' => 'Vue lecture', 'rss_view' => 'Flux RSS', + 'search_short' => 'Rechercher', 'see_website' => 'Voir le site', 'starred' => 'Afficher les favoris', 'stats' => 'Statistiques', 'subscription' => 'Gestion des abonnements', 'unread' => 'Afficher les lus', ), + 'share' => array( + '_' => 'Partager', + 'blogotext' => 'Blogotext', + 'diaspora' => 'Diaspora*', + 'email' => 'Courriel', + 'facebook' => 'Facebook', + 'g+' => 'Google+', + 'print' => 'Imprimer', + 'shaarli' => 'Shaarli', + 'twitter' => 'Twitter', + 'wallabag' => 'wallabag', + ), + 'tag' => array( + 'related' => 'Tags associés', + ), ); diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 429cfc1d2..ba13c2a45 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -25,7 +25,7 @@ if (Minz_Configuration::canLogIn()) {
      - + diff --git a/app/views/helpers/pagination.phtml b/app/views/helpers/pagination.phtml index 3ea6c3582..8b40e4336 100755 --- a/app/views/helpers/pagination.phtml +++ b/app/views/helpers/pagination.phtml @@ -20,7 +20,7 @@
    • - + -
      +
    • diff --git a/app/views/index/logs.phtml b/app/views/index/logs.phtml index 0262325f5..02256bd98 100644 --- a/app/views/index/logs.phtml +++ b/app/views/index/logs.phtml @@ -1,10 +1,10 @@
      -

      +

      - +

      logsPaginator->items(); ?> @@ -20,6 +20,6 @@ logsPaginator->render('logs_pagination.phtml','page'); ?>
      -

      +

      diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index 02d621bd0..62fb68931 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -32,12 +32,12 @@ if (!empty($this->entries)) {
      - +
      entries as $item) { if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $today)) { ?>
      entries)) { } if ($display_yesterday && $item->isDay(FreshRSS_Days::YESTERDAY, $today)) { ?>
      entries)) { } if ($display_others && $item->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) { ?>
      entries)) {

      title(); ?>

      author(); - echo $author != '' ? '
      ' . _t('by_author', $author) . '
      ' : '', + echo $author != '' ? '
      ' . _t('index.entry.by_author', $author) . '
      ' : '', $lazyload && $hidePosts ? lazyimg($item->content()) : $item->content(); ?>
      @@ -135,7 +135,7 @@ if (!empty($this->entries)) { - +