Sfoglia il codice sorgente

Merge branch 'onread_jump_next' of https://github.com/Alkarex/FreshRSS into Alkarex-onread_jump_next

Marien Fressinaud 12 anni fa
parent
commit
6967de0e64

+ 3 - 0
app/controllers/configureController.php

@@ -158,6 +158,7 @@ class configureController extends ActionController {
 			$view = Request::param ('default_view', 'all');
 			$view = Request::param ('default_view', 'all');
 			$auto_load_more = Request::param ('auto_load_more', 'no');
 			$auto_load_more = Request::param ('auto_load_more', 'no');
 			$display = Request::param ('display_posts', 'no');
 			$display = Request::param ('display_posts', 'no');
+			$onread_jump_next = Request::param ('onread_jump_next', 'yes');
 			$lazyload = Request::param ('lazyload', 'no');
 			$lazyload = Request::param ('lazyload', 'no');
 			$sort = Request::param ('sort_order', 'low_to_high');
 			$sort = Request::param ('sort_order', 'low_to_high');
 			$old = Request::param ('old_entries', 3);
 			$old = Request::param ('old_entries', 3);
@@ -176,6 +177,7 @@ class configureController extends ActionController {
 			$this->view->conf->_defaultView ($view);
 			$this->view->conf->_defaultView ($view);
 			$this->view->conf->_autoLoadMore ($auto_load_more);
 			$this->view->conf->_autoLoadMore ($auto_load_more);
 			$this->view->conf->_displayPosts ($display);
 			$this->view->conf->_displayPosts ($display);
+			$this->view->conf->_onread_jump_next ($onread_jump_next);
 			$this->view->conf->_lazyload ($lazyload);
 			$this->view->conf->_lazyload ($lazyload);
 			$this->view->conf->_sortOrder ($sort);
 			$this->view->conf->_sortOrder ($sort);
 			$this->view->conf->_oldEntries ($old);
 			$this->view->conf->_oldEntries ($old);
@@ -197,6 +199,7 @@ class configureController extends ActionController {
 				'default_view' => $this->view->conf->defaultView (),
 				'default_view' => $this->view->conf->defaultView (),
 				'auto_load_more' => $this->view->conf->autoLoadMore (),
 				'auto_load_more' => $this->view->conf->autoLoadMore (),
 				'display_posts' => $this->view->conf->displayPosts (),
 				'display_posts' => $this->view->conf->displayPosts (),
+				'onread_jump_next' => $this->view->conf->onread_jump_next (), 
 				'lazyload' => $this->view->conf->lazyload (),
 				'lazyload' => $this->view->conf->lazyload (),
 				'sort_order' => $this->view->conf->sortOrder (),
 				'sort_order' => $this->view->conf->sortOrder (),
 				'old_entries' => $this->view->conf->oldEntries (),
 				'old_entries' => $this->view->conf->oldEntries (),

+ 4 - 7
app/controllers/entryController.php

@@ -35,13 +35,10 @@ class entryController extends ActionController {
 		$id = Request::param ('id');
 		$id = Request::param ('id');
 		$is_read = Request::param ('is_read');
 		$is_read = Request::param ('is_read');
 		$get = Request::param ('get');
 		$get = Request::param ('get');
+		$nextGet = Request::param ('nextGet', $get); 
 		$dateMax = Request::param ('dateMax', time ());
 		$dateMax = Request::param ('dateMax', time ());
 
 
-		if ($is_read) {
-			$is_read = true;
-		} else {
-			$is_read = false;
-		}
+		$is_read = !!$is_read;
 
 
 		$entryDAO = new EntryDAO ();
 		$entryDAO = new EntryDAO ();
 		if ($id == false) {
 		if ($id == false) {
@@ -53,10 +50,10 @@ class entryController extends ActionController {
 
 
 				if ($typeGet == 'c') {
 				if ($typeGet == 'c') {
 					$entryDAO->markReadCat ($get, $is_read, $dateMax);
 					$entryDAO->markReadCat ($get, $is_read, $dateMax);
-					$this->params = array ('get' => 'c_' . $get);
+					$this->params = array ('get' => $nextGet); 
 				} elseif ($typeGet == 'f') {
 				} elseif ($typeGet == 'f') {
 					$entryDAO->markReadFeed ($get, $is_read, $dateMax);
 					$entryDAO->markReadFeed ($get, $is_read, $dateMax);
-					$this->params = array ('get' => 'f_' . $get);
+					$this->params = array ('get' => $nextGet);
 				}
 				}
 			}
 			}
 
 

+ 1 - 0
app/i18n/en.php

@@ -160,6 +160,7 @@ return array (
 	'sort_order'			=> 'Sort order',
 	'sort_order'			=> 'Sort order',
 	'auto_load_more'		=> 'Load next articles at the page bottom',
 	'auto_load_more'		=> 'Load next articles at the page bottom',
 	'display_articles_unfolded'	=> 'Show articles unfolded by default',
 	'display_articles_unfolded'	=> 'Show articles unfolded by default',
+	'onread_jump_next'    => 'On marked as read jump to next unread sibling',
 	'img_with_lazyload'		=> 'Use "lazy load" mode to load pictures',
 	'img_with_lazyload'		=> 'Use "lazy load" mode to load pictures',
 	'auto_read_when'		=> 'Mark as read when',
 	'auto_read_when'		=> 'Mark as read when',
 	'article_selected'		=> 'article is selected',
 	'article_selected'		=> 'article is selected',

+ 1 - 0
app/i18n/fr.php

@@ -160,6 +160,7 @@ return array (
 	'sort_order'			=> 'Ordre de tri',
 	'sort_order'			=> 'Ordre de tri',
 	'auto_load_more'		=> 'Charger les articles suivants en bas de page',
 	'auto_load_more'		=> 'Charger les articles suivants en bas de page',
 	'display_articles_unfolded'	=> 'Afficher les articles dépliés par défaut',
 	'display_articles_unfolded'	=> 'Afficher les articles dépliés par défaut',
+	'onread_jump_next'    => 'Après marqué comme lu, sauter au voisin non lu',
 	'img_with_lazyload'		=> 'Utiliser le mode "lazy load" pour charger les images',
 	'img_with_lazyload'		=> 'Utiliser le mode "lazy load" pour charger les images',
 	'auto_read_when'		=> 'Marquer comme lu lorsque',
 	'auto_read_when'		=> 'Marquer comme lu lorsque',
 	'article_selected'		=> 'l\'article est sélectionné',
 	'article_selected'		=> 'l\'article est sélectionné',

+ 38 - 2
app/layout/nav_menu.phtml

@@ -17,10 +17,46 @@
 			$get = 'c_' . $this->get_c;
 			$get = 'c_' . $this->get_c;
 			$string_mark = Translate::t ('mark_cat_read');
 			$string_mark = Translate::t ('mark_cat_read');
 		}
 		}
+		$nextGet = $get;
+		if (($this->conf->onread_jump_next () === 'yes') && (strlen ($get) > 2)) {
+			$anotherUnreadId = '';
+			$foundCurrent = false;
+			switch ($get[0]) {
+				case 'c':
+					foreach ($this->cat_aside as $cat) {
+						if ($cat->id () === $this->get_c) {
+							$foundCurrent = true;
+							continue;
+						}
+						if ($cat->nbNotRead () <= 0) continue;
+						$anotherUnreadId = $cat->id ();
+						if ($foundCurrent) break;
+					}
+					$nextGet = strlen ($anotherUnreadId) > 1 ? 'c_' . $anotherUnreadId : 'all';
+					break;
+				case 'f':
+					foreach ($this->cat_aside as $cat) {
+						if ($cat->id () === $this->get_c) {
+							foreach ($cat->feeds () as $feed) {
+								if ($feed->id () === $this->get_f) {
+									$foundCurrent = true;
+									continue;
+								}
+								if ($feed->nbNotRead () <= 0) continue;
+								$anotherUnreadId = $feed->id ();
+								if ($foundCurrent) break;
+							}
+							break;
+						}
+					}
+					$nextGet = strlen ($anotherUnreadId) > 1 ? 'f_' . $anotherUnreadId : 'c_' . $this->get_c;
+					break;
+			}
+		}
 	?>
 	?>
 
 
 	<div class="stick" id="nav_menu_read_all">
 	<div class="stick" id="nav_menu_read_all">
-		<a class="read_all btn" href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get); ?>"><?php echo Translate::t ('mark_read'); ?></a>
+		<a class="read_all btn" href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get, 'nextGet', $nextGet); ?>"><?php echo Translate::t ('mark_read'); ?></a>
 		<div class="dropdown">
 		<div class="dropdown">
 			<div id="dropdown-read" class="dropdown-target"></div>
 			<div id="dropdown-read" class="dropdown-target"></div>
 
 
@@ -28,7 +64,7 @@
 			<ul class="dropdown-menu">
 			<ul class="dropdown-menu">
 				<li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li>
 				<li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li>
 
 
-				<li class="item"><a href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get); ?>"><?php echo $string_mark; ?></a></li>
+				<li class="item"><a href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get, 'nextGet', $nextGet); ?>"><?php echo $string_mark; ?></a></li> 
 				<li class="separator"></li>
 				<li class="separator"></li>
 <?php
 <?php
 	$date = getdate ();
 	$date = getdate ();

+ 16 - 0
app/models/RSSConfiguration.php

@@ -10,6 +10,7 @@ class RSSConfiguration extends Model {
 	private $view_mode;
 	private $view_mode;
 	private $default_view;
 	private $default_view;
 	private $display_posts;
 	private $display_posts;
+	private $onread_jump_next; 
 	private $lazyload;
 	private $lazyload;
 	private $sort_order;
 	private $sort_order;
 	private $old_entries;
 	private $old_entries;
@@ -29,6 +30,7 @@ class RSSConfiguration extends Model {
 		$this->_viewMode ($confDAO->view_mode);
 		$this->_viewMode ($confDAO->view_mode);
 		$this->_defaultView ($confDAO->default_view);
 		$this->_defaultView ($confDAO->default_view);
 		$this->_displayPosts ($confDAO->display_posts);
 		$this->_displayPosts ($confDAO->display_posts);
+		$this->_onread_jump_next ($confDAO->onread_jump_next); 
 		$this->_lazyload ($confDAO->lazyload);
 		$this->_lazyload ($confDAO->lazyload);
 		$this->_sortOrder ($confDAO->sort_order);
 		$this->_sortOrder ($confDAO->sort_order);
 		$this->_oldEntries ($confDAO->old_entries);
 		$this->_oldEntries ($confDAO->old_entries);
@@ -60,6 +62,9 @@ class RSSConfiguration extends Model {
 	public function displayPosts () {
 	public function displayPosts () {
 		return $this->display_posts;
 		return $this->display_posts;
 	}
 	}
+	public function onread_jump_next () {
+		return $this->onread_jump_next;
+	}
 	public function lazyload () {
 	public function lazyload () {
 		return $this->lazyload;
 		return $this->lazyload;
 	}
 	}
@@ -137,6 +142,13 @@ class RSSConfiguration extends Model {
 			$this->display_posts = 'no';
 			$this->display_posts = 'no';
 		}
 		}
 	}
 	}
+	public function _onread_jump_next ($value) {
+		if ($value == 'no') {
+			$this->onread_jump_next = 'no';
+		} else {
+			$this->onread_jump_next = 'yes';
+		}
+	}
 	public function _lazyload ($value) {
 	public function _lazyload ($value) {
 		if ($value == 'no') {
 		if ($value == 'no') {
 			$this->lazyload = 'no';
 			$this->lazyload = 'no';
@@ -219,6 +231,7 @@ class RSSConfigurationDAO extends Model_array {
 	public $view_mode = 'normal';
 	public $view_mode = 'normal';
 	public $default_view = 'not_read';
 	public $default_view = 'not_read';
 	public $display_posts = 'no';
 	public $display_posts = 'no';
+	public $onread_jump_next = 'yes';
 	public $lazyload = 'yes';
 	public $lazyload = 'yes';
 	public $sort_order = 'low_to_high';
 	public $sort_order = 'low_to_high';
 	public $old_entries = 3;
 	public $old_entries = 3;
@@ -262,6 +275,9 @@ class RSSConfigurationDAO extends Model_array {
 		if (isset ($this->array['display_posts'])) {
 		if (isset ($this->array['display_posts'])) {
 			$this->display_posts = $this->array['display_posts'];
 			$this->display_posts = $this->array['display_posts'];
 		}
 		}
+		if (isset ($this->array['onread_jump_next'])) {
+			$this->onread_jump_next = $this->array['onread_jump_next'];
+		}
 		if (isset ($this->array['lazyload'])) {
 		if (isset ($this->array['lazyload'])) {
 			$this->lazyload = $this->array['lazyload'];
 			$this->lazyload = $this->array['lazyload'];
 		}
 		}

+ 14 - 0
app/views/configure/display.phtml

@@ -118,6 +118,20 @@
 			</div>
 			</div>
 		</div>
 		</div>
 
 
+		<div class="form-group">
+			<label class="group-name"><?php echo Translate::t ('onread_jump_next'); ?></label>
+			<div class="group-controls">
+				<label class="radio" for="onread_jump_next_yes">
+					<input type="radio" name="onread_jump_next" id="onread_jump_next_yes" value="yes"<?php echo $this->conf->onread_jump_next () == 'yes' ? ' checked="checked"' : ''; ?> />
+					<?php echo Translate::t ('yes'); ?><noscript> - <b><?php echo Translate::t ('javascript_should_be_activated'); ?></b></noscript>
+				</label>
+				<label class="radio" for="onread_jump_next_no">
+					<input type="radio" name="onread_jump_next" id="onread_jump_next_no" value="no"<?php echo $this->conf->onread_jump_next () == 'no' ? ' checked="checked"' : ''; ?> />
+					<?php echo Translate::t ('no'); ?>
+				</label>
+			</div>
+		</div>
+
 		<div class="form-group">
 		<div class="form-group">
 			<div class="group-controls">
 			<div class="group-controls">
 				<label class="checkbox" for="lazyload">
 				<label class="checkbox" for="lazyload">