Просмотр исходного кода

Fix issue #67 : différentes vues implémentées + possibilité de choisir la vue par défaut

Marien Fressinaud 12 лет назад
Родитель
Сommit
48cfe1571e

+ 3 - 0
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 (),

+ 7 - 1
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 ();

+ 16 - 0
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'];
 		}

+ 5 - 0
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'); ?>

+ 5 - 1
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) { ?>