aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/indexController.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-08-10 09:37:11 +0200
committerGravatar GitHub <noreply@github.com> 2022-08-10 09:37:11 +0200
commit09aeeeb3254b2b7ad6d588bc21223d567390ae58 (patch)
tree1682ba448e8ad309ffacc99d1cdb45f6365c5785 /app/Controllers/indexController.php
parente86c10e2f554ba60e95f745b3b062262b37c7188 (diff)
Refactor updateContext into its own FreshRSS_Context class (#4496)
So that it is both cleaner and easier to call from other controllers and extensions
Diffstat (limited to 'app/Controllers/indexController.php')
-rwxr-xr-xapp/Controllers/indexController.php62
1 files changed, 4 insertions, 58 deletions
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index ad9a9a3ee..7fced48af 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -35,7 +35,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
try {
- $this->updateContext();
+ FreshRSS_Context::updateUsingRequest();
} catch (FreshRSS_Context_Exception $e) {
Minz_Error::error(404);
}
@@ -116,7 +116,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
FreshRSS_View::appendScript(Minz_Url::display('/scripts/global_view.js?' . @filemtime(PUBLIC_PATH . '/scripts/global_view.js')));
try {
- $this->updateContext();
+ FreshRSS_Context::updateUsingRequest();
} catch (FreshRSS_Context_Exception $e) {
Minz_Error::error(404);
}
@@ -155,7 +155,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
try {
- $this->updateContext();
+ FreshRSS_Context::updateUsingRequest();
} catch (FreshRSS_Context_Exception $e) {
Minz_Error::error(404);
}
@@ -186,7 +186,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
try {
- $this->updateContext();
+ FreshRSS_Context::updateUsingRequest();
} catch (FreshRSS_Context_Exception $e) {
Minz_Error::error(404);
}
@@ -245,60 +245,6 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
}
/**
- * This action updates the Context object by using request parameters.
- *
- * Parameters are:
- * - state (default: conf->default_view)
- * - search (default: empty string)
- * - order (default: conf->sort_order)
- * - nb (default: conf->posts_per_page)
- * - next (default: empty string)
- * - hours (default: 0)
- */
- private function updateContext() {
- if (empty(FreshRSS_Context::$categories)) {
- $catDAO = FreshRSS_Factory::createCategoryDao();
- FreshRSS_Context::$categories = $catDAO->listSortedCategories();
- }
-
- // Update number of read / unread variables.
- $entryDAO = FreshRSS_Factory::createEntryDao();
- FreshRSS_Context::$total_starred = $entryDAO->countUnreadReadFavorites();
- FreshRSS_Context::$total_unread = FreshRSS_CategoryDAO::CountUnreads(
- FreshRSS_Context::$categories, 1
- );
-
- FreshRSS_Context::_get(Minz_Request::param('get', 'a'));
-
- FreshRSS_Context::$state = Minz_Request::param(
- 'state', FreshRSS_Context::$user_conf->default_state
- );
- $state_forced_by_user = Minz_Request::param('state', false) !== false;
- if (!$state_forced_by_user && !FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ)) {
- if (FreshRSS_Context::$user_conf->default_view === 'adaptive' && FreshRSS_Context::$get_unread <= 0) {
- FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
- }
- if (FreshRSS_Context::$user_conf->show_fav_unread &&
- (FreshRSS_Context::isCurrentGet('s') || FreshRSS_Context::isCurrentGet('T') || FreshRSS_Context::isTag())) {
- FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
- }
- }
-
- FreshRSS_Context::$search = new FreshRSS_BooleanSearch(Minz_Request::param('search', ''));
- FreshRSS_Context::$order = Minz_Request::param(
- 'order', FreshRSS_Context::$user_conf->sort_order
- );
- FreshRSS_Context::$number = intval(Minz_Request::param('nb', FreshRSS_Context::$user_conf->posts_per_page));
- if (FreshRSS_Context::$number > FreshRSS_Context::$user_conf->max_posts_per_rss) {
- FreshRSS_Context::$number = max(
- FreshRSS_Context::$user_conf->max_posts_per_rss,
- FreshRSS_Context::$user_conf->posts_per_page);
- }
- FreshRSS_Context::$first_id = Minz_Request::param('next', '');
- FreshRSS_Context::$sinceHours = intval(Minz_Request::param('hours', 0));
- }
-
- /**
* This method returns a list of entries based on the Context object.
*/
public static function listEntriesByContext() {