diff options
| author | 2014-10-22 17:57:22 +0200 | |
|---|---|---|
| committer | 2014-10-22 17:57:22 +0200 | |
| commit | 98587d5d617f157ba57a260091c8e2c944f5163f (patch) | |
| tree | 24760d52ffc5d3411e986749054d08e3c63fc002 /app/Controllers/indexController.php | |
| parent | f1f9b2f5ff60f6dca05fad831b766ea7d63ff3a3 (diff) | |
Fix a set of TODO and bugs
- Context object raises correct Exception if get is invalid
- RSS feed is well-indicated on the home page
- State is better calculated
- Add some comments
See https://github.com/marienfressinaud/FreshRSS/issues/634
Diffstat (limited to 'app/Controllers/indexController.php')
| -rwxr-xr-x | app/Controllers/indexController.php | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index d711997be..f9af2d0bb 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -5,10 +5,10 @@ */ class FreshRSS_index_Controller extends Minz_ActionController { + /** + * This action only redirect on the default view mode (normal or global) + */ public function indexAction() { - // TODO: update the context with information from request. - // TODO: then, in dedicated action, get corresponding entries - $prefered_output = FreshRSS_Context::$conf->view_mode; Minz_Request::forward(array( 'c' => 'index', @@ -27,12 +27,12 @@ class FreshRSS_index_Controller extends Minz_ActionController { try { $this->updateContext(); - } catch (Minz_Exception $e) { + } catch (FreshRSS_Context_Exception $e) { Minz_Error::error(404); } try { - $entries = $this->listByContext(); + $entries = $this->listEntriesByContext(); if (count($entries) > FreshRSS_Context::$number) { // We have more elements for pagination @@ -48,6 +48,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { $this->view->categories = FreshRSS_Context::$categories; + $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); $title = FreshRSS_Context::$name; if (FreshRSS_Context::$get_unread > 0) { $title = '(' . FreshRSS_Context::$get_unread . ') · ' . $title; @@ -68,12 +69,13 @@ class FreshRSS_index_Controller extends Minz_ActionController { try { $this->updateContext(); - } catch (Minz_Exception $e) { + } catch (FreshRSS_Context_Exception $e) { Minz_Error::error(404); } $this->view->categories = FreshRSS_Context::$categories; + $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); Minz_View::prependTitle(_t('gen.title.global_view') . ' · '); } @@ -94,12 +96,12 @@ class FreshRSS_index_Controller extends Minz_ActionController { try { $this->updateContext(); - } catch (Minz_Exception $e) { + } catch (FreshRSS_Context_Exception $e) { Minz_Error::error(404); } try { - $this->view->entries = $this->listByContext(); + $this->view->entries = $this->listEntriesByContext(); } catch (FreshRSS_EntriesGetter_Exception $e) { Minz_Log::notice($e->getMessage()); Minz_Error::error(404); @@ -113,15 +115,25 @@ class FreshRSS_index_Controller extends Minz_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) */ private function updateContext() { FreshRSS_Context::_get(Minz_Request::param('get', 'a')); - FreshRSS_Context::$state |= Minz_Request::param( + // TODO: change default_view by default_state. + 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) { + $state_forced_by_user = Minz_Request::param('state', false) !== false; + if (FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) && + FreshRSS_Context::$get_unread <= 0 && + !$state_forced_by_user) { FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ; } @@ -135,7 +147,10 @@ class FreshRSS_index_Controller extends Minz_ActionController { FreshRSS_Context::$first_id = Minz_Request::param('next', ''); } - private function listByContext() { + /** + * This method returns a list of entries based on the Context object. + */ + private function listEntriesByContext() { $entryDAO = FreshRSS_Factory::createEntryDao(); $get = FreshRSS_Context::currentGet(true); |
