From 48cfe1571ececb9fae0c361d9147690b04d310e0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 16 Jun 2013 20:48:56 +0200 Subject: Fix issue #67 : différentes vues implémentées + possibilité de choisir la vue par défaut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/configureController.php | 3 +++ app/controllers/indexController.php | 8 +++++++- app/models/RSSConfiguration.php | 16 ++++++++++++++++ app/views/configure/display.phtml | 5 +++++ app/views/helpers/global_view.phtml | 6 +++++- 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 4cfc1c085..9ed0ad1eb 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -140,6 +140,7 @@ class configureController extends ActionController { if (Request::isPost ()) { $language = Request::param ('language', 'en'); $nb = Request::param ('posts_per_page', 10); + $mode = Request::param ('view_mode', 'normal'); $view = Request::param ('default_view', 'all'); $display = Request::param ('display_posts', 'no'); $lazyload = Request::param ('lazyload', 'yes'); @@ -153,6 +154,7 @@ class configureController extends ActionController { $this->view->conf->_language ($language); $this->view->conf->_postsPerPage (intval ($nb)); + $this->view->conf->_viewMode ($mode); $this->view->conf->_defaultView ($view); $this->view->conf->_displayPosts ($display); $this->view->conf->_lazyload ($lazyload); @@ -169,6 +171,7 @@ class configureController extends ActionController { $values = array ( 'language' => $this->view->conf->language (), 'posts_per_page' => $this->view->conf->postsPerPage (), + 'view_mode' => $this->view->conf->viewMode (), 'default_view' => $this->view->conf->defaultView (), 'display_posts' => $this->view->conf->displayPosts (), 'lazyload' => $this->view->conf->lazyload (), diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 3f10720c2..a5a5501e7 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -6,13 +6,19 @@ class indexController extends ActionController { private $mode = 'all'; public function indexAction () { - if (Request::param ('output') == 'rss') { + $output = Request::param ('output'); + + if ($output == 'rss') { $this->view->_useLayout (false); } else { View::appendScript (Url::display ('/scripts/shortcut.js')); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize'))); View::appendScript (Url::display ('/scripts/endless_mode.js')); + + if(!$output) { + Request::_param ('output', $this->view->conf->viewMode()); + } } $entryDAO = new EntryDAO (); diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php index 6ebc30e8e..b188c0e65 100755 --- a/app/models/RSSConfiguration.php +++ b/app/models/RSSConfiguration.php @@ -7,6 +7,7 @@ class RSSConfiguration extends Model { ); private $language; private $posts_per_page; + private $view_mode; private $default_view; private $display_posts; private $lazyload; @@ -21,6 +22,7 @@ class RSSConfiguration extends Model { $confDAO = new RSSConfigurationDAO (); $this->_language ($confDAO->language); $this->_postsPerPage ($confDAO->posts_per_page); + $this->_viewMode ($confDAO->view_mode); $this->_defaultView ($confDAO->default_view); $this->_displayPosts ($confDAO->display_posts); $this->_lazyload ($confDAO->lazyload); @@ -41,6 +43,9 @@ class RSSConfiguration extends Model { public function postsPerPage () { return $this->posts_per_page; } + public function viewMode () { + return $this->view_mode; + } public function defaultView () { return $this->default_view; } @@ -91,6 +96,13 @@ class RSSConfiguration extends Model { $this->posts_per_page = 10; } } + public function _viewMode ($value) { + if ($value == 'global' || $value == 'reader') { + $this->view_mode = $value; + } else { + $this->view_mode = 'normal'; + } + } public function _defaultView ($value) { if ($value == 'not_read') { $this->default_view = 'not_read'; @@ -154,6 +166,7 @@ class RSSConfiguration extends Model { class RSSConfigurationDAO extends Model_array { public $language = 'en'; public $posts_per_page = 20; + public $view_mode = 'normal'; public $default_view = 'not_read'; public $display_posts = 'no'; public $lazyload = 'yes'; @@ -185,6 +198,9 @@ class RSSConfigurationDAO extends Model_array { if (isset ($this->array['posts_per_page'])) { $this->posts_per_page = $this->array['posts_per_page']; } + if (isset ($this->array['view_mode'])) { + $this->view_mode = $this->array['view_mode']; + } if (isset ($this->array['default_view'])) { $this->default_view = $this->array['default_view']; } diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml index c46a02143..8484a7116 100644 --- a/app/views/configure/display.phtml +++ b/app/views/configure/display.phtml @@ -46,6 +46,11 @@
+