From d63eddf0c5a563d11c880bb700dafc889ee87a3d Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 17 Mar 2013 00:01:40 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d'options=20:=20possibilit=C3=A9=20de?= =?UTF-8?q?=20changer=20l'ordre=20des=20articles=20+=20possibilit=C3=A9=20?= =?UTF-8?q?de=20marquer=20comme=20lu=20au=20choix=20:=20tous,=20ant=C3=A9r?= =?UTF-8?q?ieurs=20=C3=A0=201=20jour,=20ant=C3=A9rieurs=20=C3=A0=201=20sem?= =?UTF-8?q?aine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/entryController.php | 9 +++-- app/controllers/indexController.php | 27 ++++++++++--- app/layout/nav_menu.phtml | 63 +++++++++++++++++++++++++++++ app/models/Entry.php | 18 ++++----- app/views/index/index.phtml | 26 +----------- public/theme/base.css | 21 +++++++--- 6 files changed, 115 insertions(+), 49 deletions(-) create mode 100644 app/layout/nav_menu.phtml diff --git a/app/controllers/entryController.php b/app/controllers/entryController.php index cb309c567..b772e1703 100755 --- a/app/controllers/entryController.php +++ b/app/controllers/entryController.php @@ -31,6 +31,7 @@ class entryController extends ActionController { $id = Request::param ('id'); $is_read = Request::param ('is_read'); $get = Request::param ('get'); + $dateMax = Request::param ('dateMax', time ()); if ($is_read) { $is_read = true; @@ -41,16 +42,16 @@ class entryController extends ActionController { $entryDAO = new EntryDAO (); if ($id == false) { if (!$get) { - $entryDAO->markReadEntries ($is_read); + $entryDAO->markReadEntries ($is_read, $dateMax); } else { $typeGet = $get[0]; $get = substr ($get, 2); if ($typeGet == 'c') { - $entryDAO->markReadCat ($get, $is_read); + $entryDAO->markReadCat ($get, $is_read, $dateMax); $this->params = array ('get' => 'c_' . $get); } elseif ($typeGet == 'f') { - $entryDAO->markReadFeed ($get, $is_read); + $entryDAO->markReadFeed ($get, $is_read, $dateMax); $this->params = array ('get' => 'f_' . $get); } } @@ -62,7 +63,7 @@ class entryController extends ActionController { ); Session::_param ('notification', $notif); } else { - $entryDAO->updateEntry ($id, $values); + $entryDAO->updateEntry ($id, array ('is_read' => $is_read)); } } diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index 79d430f99..04c74028c 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -10,11 +10,14 @@ class indexController extends ActionController { $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); + $error = false; + // pour optimiser $page = Request::param ('page', 1); $entryDAO->_nbItemsPerPage ($this->view->conf->postsPerPage ()); $entryDAO->_currentPage ($page); + // mode de vue (tout ou seulement non lus) $default_view = $this->view->conf->defaultView (); $mode = Session::param ('mode'); if ($mode == false) { @@ -25,14 +28,16 @@ class indexController extends ActionController { } } + // ordre de listage des flux + $order = Session::param ('order', $this->view->conf->sortOrder ()); + + // recherche sur les titres (pour le moment) + $search = Request::param ('search'); + + // récupération de la catégorie/flux à filtrer $get = Request::param ('get'); $this->view->get_c = false; $this->view->get_f = false; - $order = $this->view->conf->sortOrder (); - - $search = Request::param ('search'); - - $error = false; // Récupère les flux par catégorie, favoris ou tous if ($get == 'favoris') { @@ -72,6 +77,7 @@ class indexController extends ActionController { } $this->view->mode = $mode; + $this->view->order = $order; // Cas où on ne choisie ni catégorie ni les favoris // ou si la catégorie ne correspond à aucune @@ -110,6 +116,17 @@ class indexController extends ActionController { Request::forward (array (), true); } + public function changeOrderAction () { + $order = Request::param ('order'); + + if ($order == 'low_to_high') { + Session::_param ('order', 'low_to_high'); + } else { + Session::_param ('order', 'high_to_low'); + } + + Request::forward (array (), true); + } public function loginAction () { $this->view->_useLayout (false); diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml new file mode 100644 index 000000000..4962c3aa5 --- /dev/null +++ b/app/layout/nav_menu.phtml @@ -0,0 +1,63 @@ + diff --git a/app/models/Entry.php b/app/models/Entry.php index 001f76b5a..245fea2f6 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -171,11 +171,11 @@ class EntryDAO extends Model_pdo { } } - public function markReadEntries ($read) { - $sql = 'UPDATE entry SET is_read = ?'; + public function markReadEntries ($read, $dateMax) { + $sql = 'UPDATE entry SET is_read = ? WHERE date < ?'; $stm = $this->bd->prepare ($sql); - $values = array ($read); + $values = array ($read, $dateMax); if ($stm && $stm->execute ($values)) { return true; @@ -183,11 +183,11 @@ class EntryDAO extends Model_pdo { return false; } } - public function markReadCat ($id, $read) { - $sql = 'UPDATE entry e INNER JOIN feed f ON e.id_feed = f.id SET is_read = ? WHERE category = ?'; + public function markReadCat ($id, $read, $dateMax) { + $sql = 'UPDATE entry e INNER JOIN feed f ON e.id_feed = f.id SET is_read = ? WHERE category = ? AND date < ?'; $stm = $this->bd->prepare ($sql); - $values = array ($read, $id); + $values = array ($read, $id, $dateMax); if ($stm && $stm->execute ($values)) { return true; @@ -195,11 +195,11 @@ class EntryDAO extends Model_pdo { return false; } } - public function markReadFeed ($id, $read) { - $sql = 'UPDATE entry SET is_read = ? WHERE id_feed = ?'; + public function markReadFeed ($id, $read, $dateMax) { + $sql = 'UPDATE entry SET is_read = ? WHERE id_feed = ? AND date < ?'; $stm = $this->bd->prepare ($sql); - $values = array ($read, $id); + $values = array ($read, $id, $dateMax); if ($stm && $stm->execute ($values)) { return true; diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 3e213d076..7734630ef 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -1,30 +1,6 @@ partial ('aside_flux'); ?> - +partial ('nav_menu'); ?> entryPaginator)) { diff --git a/public/theme/base.css b/public/theme/base.css index 4011ee523..b3295cdd4 100644 --- a/public/theme/base.css +++ b/public/theme/base.css @@ -117,6 +117,7 @@ input { } .stick { + display: inline-block; white-space: nowrap; font-size: 0px; vertical-align: middle; @@ -137,15 +138,23 @@ input { .stick input:last-child { border-radius: 0 3px 3px 0; } - .stick .btn+.btn, - .stick .btn+input, - .stick input+.btn, - .stick input+input { + .stick .btn + .btn, + .stick .btn + input, + .stick input + .btn, + .stick input + input { border-left: none; } - .stick input+.btn { + .stick input + .btn { border-top: 1px solid #bbb; } + .stick .btn + .dropdown > .btn { + border-left: none; + border-radius: 0 3px 3px 0; + font-size: 0px; + } + .stick .btn + .dropdown a { + font-size: 12px; + } .btn { display: inline-block; @@ -284,7 +293,7 @@ input { .dropdown .dropdown-menu { display: none; min-width: 200px; - margin: -1px 0 0; + margin: 5px 0 0; padding: 5px 0; position: absolute; right: 0px;