From b780a2329b5f4b37ad7fb0453544a410d0f48416 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 25 Aug 2013 13:25:27 +0200 Subject: New option onread_jump_next Added a new option to automatically jump to the next sibling (category or feed) when hitting the button "mark as read". --- app/controllers/configureController.php | 3 +++ app/controllers/entryController.php | 11 ++++----- app/i18n/en.php | 1 + app/i18n/fr.php | 1 + app/layout/nav_menu.phtml | 40 +++++++++++++++++++++++++++++++-- app/models/RSSConfiguration.php | 16 +++++++++++++ app/views/configure/display.phtml | 14 ++++++++++++ 7 files changed, 77 insertions(+), 9 deletions(-) diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 6396dbfeb..02a20365c 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -155,6 +155,7 @@ class configureController extends ActionController { $view = Request::param ('default_view', 'all'); $auto_load_more = Request::param ('auto_load_more', 'no'); $display = Request::param ('display_posts', 'no'); + $onread_jump_next = Request::param ('onread_jump_next', 'yes'); $lazyload = Request::param ('lazyload', 'no'); $sort = Request::param ('sort_order', 'low_to_high'); $old = Request::param ('old_entries', 3); @@ -173,6 +174,7 @@ class configureController extends ActionController { $this->view->conf->_defaultView ($view); $this->view->conf->_autoLoadMore ($auto_load_more); $this->view->conf->_displayPosts ($display); + $this->view->conf->_onread_jump_next ($onread_jump_next); $this->view->conf->_lazyload ($lazyload); $this->view->conf->_sortOrder ($sort); $this->view->conf->_oldEntries ($old); @@ -194,6 +196,7 @@ class configureController extends ActionController { 'default_view' => $this->view->conf->defaultView (), 'auto_load_more' => $this->view->conf->autoLoadMore (), 'display_posts' => $this->view->conf->displayPosts (), + 'onread_jump_next' => $this->view->conf->onread_jump_next (), 'lazyload' => $this->view->conf->lazyload (), 'sort_order' => $this->view->conf->sortOrder (), 'old_entries' => $this->view->conf->oldEntries (), diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index c7e13f471..cb9e24757 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -35,13 +35,10 @@ class entryController extends ActionController { $id = Request::param ('id'); $is_read = Request::param ('is_read'); $get = Request::param ('get'); + $nextGet = Request::param ('nextGet', $get); $dateMax = Request::param ('dateMax', time ()); - if ($is_read) { - $is_read = true; - } else { - $is_read = false; - } + $is_read = !!$is_read; $entryDAO = new EntryDAO (); if ($id == false) { @@ -53,10 +50,10 @@ class entryController extends ActionController { if ($typeGet == 'c') { $entryDAO->markReadCat ($get, $is_read, $dateMax); - $this->params = array ('get' => 'c_' . $get); + $this->params = array ('get' => $nextGet); } elseif ($typeGet == 'f') { $entryDAO->markReadFeed ($get, $is_read, $dateMax); - $this->params = array ('get' => 'f_' . $get); + $this->params = array ('get' => $nextGet); } } diff --git a/app/i18n/en.php b/app/i18n/en.php index 341e14ca7..9e671a386 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -160,6 +160,7 @@ return array ( 'sort_order' => 'Sort order', 'auto_load_more' => 'Load next articles at the page bottom', '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', 'auto_read_when' => 'Mark as read when', 'article_selected' => 'article is selected', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 394c86f6e..a62f26a8e 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -160,6 +160,7 @@ return array ( 'sort_order' => 'Ordre de tri', 'auto_load_more' => 'Charger les articles suivants en bas de page', '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', 'auto_read_when' => 'Marquer comme lu lorsque', 'article_selected' => 'l\'article est sélectionné', diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index d64b68765..59ddc57ea 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -17,10 +17,46 @@ $get = 'c_' . $this->get_c; $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; + } + } ?> +
+ +
+ + +
+
+