diff options
| author | 2014-10-22 13:35:30 +0200 | |
|---|---|---|
| committer | 2014-10-22 13:35:30 +0200 | |
| commit | b446a510ebacddd1437d907e795c83b3d05a9b98 (patch) | |
| tree | ce5f131b80b1ed69b969e1d0451264c3a95f06cb /app/Controllers/indexController.php | |
| parent | fcae4157539306e90299e7f0e90740320a2833d7 (diff) | |
Finish to update context object
See See https://github.com/marienfressinaud/FreshRSS/issues/634
Diffstat (limited to 'app/Controllers/indexController.php')
| -rwxr-xr-x | app/Controllers/indexController.php | 82 |
1 files changed, 21 insertions, 61 deletions
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index f163da53d..be85aa68d 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -17,70 +17,13 @@ class FreshRSS_index_Controller extends Minz_ActionController { return; - // On récupère les différents éléments de filtrage - $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', 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); - if ($output === 'reader') { - $nb = max(1, round($nb / 2)); - } - - 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; - } - if (!$hasUnread && ($state_param === null)) { - $this->view->state = FreshRSS_Entry::STATE_ALL; - } - } - - $this->view->today = @strtotime('today'); - try { $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 - if ($this->view->state === FreshRSS_Entry::STATE_NOT_READ && empty($entries) && ($state_param === null) && ($filter == '')) { - Minz_Log::debug('Conflicting information about nbNotRead!'); - $feedDAO = FreshRSS_Factory::createFeedDao(); - try { - $feedDAO->updateCachedValues(); - } catch (Exception $ex) { - 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); - } - Minz_Request::_param('state', $this->view->state); - - if (count($entries) <= $nb) { - $this->view->nextId = ''; - } else { //We have more elements for pagination - $lastEntry = array_pop($entries); - $this->view->nextId = $lastEntry->id(); + if (count($entries) > $nb) { + // We have more elements for pagination + $last_entry = array_pop($entries); + FreshRSS_Context::$next_id = $last_entry->id(); } $this->view->entries = $entries; @@ -168,6 +111,23 @@ class FreshRSS_index_Controller extends Minz_ActionController { */ private function updateContext() { FreshRSS_Context::_get(Minz_Request::param('get', 'a')); + + FreshRSS_Context::$state |= Minz_Request::param( + 'state', FreshRSS_Context::$conf->default_view + ); + if (FreshRSS_Context::$state & FreshRSS_Entry::STATE_NOT_READ && + FreshRSS_Context::$get_unread <= 0) { + FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; + } + + FreshRSS_Context::$search = Minz_Request::param('search', ''); + FreshRSS_Context::$order = Minz_Request::param( + 'order', FreshRSS_Context::$conf->sort_order + ); + FreshRSS_Context::$number = Minz_Request::param( + 'nb', FreshRSS_Context::$conf->posts_per_page + ); + FreshRSS_Context::$first_id = Minz_Request::param('next', ''); } /** |
