Ver Fonte

Ajout d'options : possibilité de changer l'ordre des articles + possibilité de marquer comme lu au choix : tous, antérieurs à 1 jour, antérieurs à 1 semaine

Marien Fressinaud há 13 anos atrás
pai
commit
d63eddf0c5

+ 5 - 4
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));
 		}
 	}
 	

+ 22 - 5
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 {
 			}
 		}
 
-		$get = Request::param ('get');
-		$this->view->get_c = false;
-		$this->view->get_f = false;
-		$order = $this->view->conf->sortOrder ();
+		// ordre de listage des flux
+		$order = Session::param ('order', $this->view->conf->sortOrder ());
 
+		// recherche sur les titres (pour le moment)
 		$search = Request::param ('search');
 
-		$error = false;
+		// récupération de la catégorie/flux à filtrer
+		$get = Request::param ('get');
+		$this->view->get_c = false;
+		$this->view->get_f = 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);

+ 63 - 0
app/layout/nav_menu.phtml

@@ -0,0 +1,63 @@
+<div class="nav_menu">
+	<a class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><i class="icon i_refresh"></i></a>
+
+	<?php
+		$get = false;
+		$string_mark = 'Tout marquer comme lu';
+		if ($this->get_f) {
+			$get = 'f_' . $this->get_f;
+			$string_mark = 'Marquer le flux comme lu';
+		} elseif ($this->get_c) {
+			$get = 'c_' . $this->get_c;
+			$string_mark = 'Marquer la catégorie comme lue';
+		}
+	?>
+
+	<?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
+	<div class="stick">
+		<a class="read_all btn" href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get); ?>">Marquer comme lu</a>
+		<div class="dropdown">
+			<div id="dropdown-read" class="dropdown-target"></div>
+
+			<a class="dropdown-toggle btn" href="#dropdown-read"><i class="icon i_down"></i></a>
+			<ul class="dropdown-menu">
+				<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="separator"></li>
+<?php
+	$date = getdate ();
+	$today = mktime (0, 0, 0, $date['mon'], $date['mday'], $date['year']);
+	$one_week = $today - 604800;
+?>
+				<li class="item"><a href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get, 'dateMax', $today); ?>">Antérieurs à 1 jour</a></li>
+				<li class="item"><a href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get, 'dateMax', $one_week); ?>">Antérieurs à 1 semaine</a></li>
+			</ul>
+		</div>
+	</div>
+	<?php } ?>
+
+	<div class="dropdown">
+		<div id="dropdown-views" class="dropdown-target"></div>
+		<a class="dropdown-toggle btn" href="#dropdown-views">Affichage <i class="icon i_down"></i></a>
+		<ul class="dropdown-menu">
+			<li class="dropdown-close"><a href="#close"><i class="icon i_close"></i></a></li>
+
+			<li class="item">
+				<?php if ($this->mode == 'not_read') { ?>
+				<a class="print_all" href="<?php echo _url ('index', 'changeMode', 'mode', 'all'); ?>">Tout afficher</a>
+				<?php } else { ?>
+				<a class="print_non_read" href="<?php echo _url ('index', 'changeMode', 'mode', 'not_read'); ?>">Afficher les non lus</a>
+				<?php } ?>
+			</li>
+			<li class="separator"></li>
+			<li class="item">
+				<?php if ($this->order == 'low_to_high') { ?>
+				<a href="<?php echo _url ('index', 'changeOrder', 'order', 'high_to_low'); ?>">Plus anciens en premier</a>
+				<?php } else { ?>
+				<a href="<?php echo _url ('index', 'changeOrder', 'order', 'low_to_high'); ?>">Plus récents en premier</a>
+				<?php } ?>
+			</li>
+		</ul>
+	</div>
+</div>

+ 9 - 9
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;

+ 1 - 25
app/views/index/index.phtml

@@ -1,30 +1,6 @@
 <?php $this->partial ('aside_flux'); ?>
 
-<div class="nav_menu stick">
-	<a class="btn" href="<?php echo _url ('feed', 'actualize'); ?>"><i class="icon i_refresh"></i></a>
-
-	<?php
-		$get = false;
-		$string_mark = 'Tout marquer comme lu';
-		if ($this->get_f) {
-			$get = 'f_' . $this->get_f;
-			$string_mark = 'Marquer le flux comme lu';
-		} elseif ($this->get_c) {
-			$get = 'c_' . $this->get_c;
-			$string_mark = 'Marquer la catégorie comme lue';
-		}
-	?>
-
-	<?php if (!login_is_conf ($this->conf) || is_logged ()) { ?>
-	<a class="read_all btn" href="<?php echo _url ('entry', 'read', 'is_read', 1, 'get', $get); ?>"><?php echo $string_mark; ?></a>
-	<?php } ?>
-
-	<?php if ($this->mode == 'not_read') { ?>
-	<a class="print_all btn" href="<?php echo _url ('index', 'changeMode', 'mode', 'all'); ?>">Tout afficher</a>
-	<?php } else { ?>
-	<a class="print_non_read btn" href="<?php echo _url ('index', 'changeMode', 'mode', 'not_read'); ?>">Afficher les non lus</a>
-	<?php } ?>
-</div>
+<?php $this->partial ('nav_menu'); ?>
 
 <?php
 if (isset ($this->entryPaginator)) {

+ 15 - 6
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;