A free, self-hostable news aggregator…
Fix issue #67 : différentes vues implémentées + possibilité de choisir la vue par défaut
Marien Fressinaud48cfe1571ece
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.phpindex 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.phpindex 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.phpindex 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.phtmlindex c46a02143..8484a7116 100644--- a/app/views/configure/display.phtml+++ b/app/views/configure/display.phtml@@ -46,6 +46,11 @@<div class="form-group"><label class="group-name"><?php echo Translate::t ('default_view'); ?></label><div class="group-controls">+ <select name="view_mode" id="view_mode">+ <option value="normal"<?php echo $this->conf->viewMode () == 'normal' ? ' selected="selected"' : ''; ?>><?php echo Translate::t ('normal_view'); ?></option>+ <option value="reader"<?php echo $this->conf->viewMode () == 'reader' ? ' selected="selected"' : ''; ?>><?php echo Translate::t ('reader_view'); ?></option>+ <option value="global"<?php echo $this->conf->viewMode () == 'global' ? ' selected="selected"' : ''; ?>><?php echo Translate::t ('global_view'); ?></option>+ </select><label class="radio" for="radio_all"><input type="radio" name="default_view" id="radio_all" value="all"<?php echo $this->conf->defaultView () == 'all' ? ' checked="checked"' : ''; ?> /><?php echo Translate::t ('show_all_articles'); ?>diff --git a/app/views/helpers/global_view.phtml b/app/views/helpers/global_view.phtmlindex 8e5e363f8..fff391cba 100644--- a/app/views/helpers/global_view.phtml+++ b/app/views/helpers/global_view.phtml@@ -8,7 +8,11 @@if (!empty ($feeds)) {?><div class="category">- <div class="cat_header"><a href="<?php echo _url ('index', 'index', 'get', 'c_' . $cat->id ()); ?>"><?php echo $cat->name(); ?><?php echo $catNotRead > 0 ? ' (' . $catNotRead . ')' : ''; ?></a></div>+ <div class="cat_header">+ <a href="<?php echo _url ('index', 'index', 'get', 'c_' . $cat->id ()); ?>">+ <?php echo $cat->name(); ?><?php echo $catNotRead > 0 ? ' (' . $catNotRead . ')' : ''; ?>+ </a>+ </div><ul class="feeds"><?php foreach ($feeds as $feed) { ?>