Browse Source

Permet la configuration du tri en page d'accueil.
Option supplémentaire dans les préférences : Affichage des articles les plus récents en premier ?

la mise à jour de la class Configuration permet l'insertion de paramètre si inexistant en base. (Utile pour les futurs évolutions nécessitant des paramètres. Utile pour les futurs plugins)

cobalt74 6 years ago
parent
commit
c3a807252b
6 changed files with 19 additions and 3 deletions
  1. 5 1
      Configuration.class.php
  2. 2 1
      action.php
  3. 4 1
      index.php
  4. 2 0
      install.php
  5. 1 0
      settings.php
  6. 5 0
      templates/marigolds/settings.html

+ 5 - 1
Configuration.class.php

@@ -49,7 +49,11 @@ class Configuration extends MysqlEntity{
 
 	public function put($key,$value){
 		$configurationManager = new Configuration();
-		$configurationManager->change(array('value'=>$value),array('key'=>$key));
+		if (isset($this->confTab[$key])){
+			$configurationManager->change(array('value'=>$value),array('key'=>$key));
+		} else {
+			$configurationManager->add($key,$value);	
+		}
 		$this->confTab[$key] = $value;
 		unset($_SESSION['configuration']);
 	}

+ 2 - 1
action.php

@@ -197,7 +197,8 @@ switch ($action){
 			$configurationManager->put('articlePerPages',$_['articlePerPages']);
 			$configurationManager->put('articleDisplayLink',$_['articleDisplayLink']);
 			$configurationManager->put('articleDisplayDate',$_['articleDisplayDate']);
-			$configurationManager->put('articleDisplayAuthor',$_['articleDisplayAuthor']);
+			$configurationManager->put('articleDisplayAuthor',$_['articleDisplayAuthor']);			
+			$configurationManager->put('articleDisplaySort',$_['articleDisplaySort']);
 			$configurationManager->put('synchronisationType',$_['synchronisationType']);
 			$configurationManager->put('feedMaxEvents',$_['feedMaxEvents']);
 

+ 4 - 1
index.php

@@ -33,6 +33,7 @@ $articlePerPages = $configurationManager->get('articlePerPages');
 $articleDisplayLink = $configurationManager->get('articleDisplayLink');
 $articleDisplayDate = $configurationManager->get('articleDisplayDate');
 $articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
+$articleDisplaySort = $configurationManager->get('articleDisplaySort');
  
 $tpl->assign('articleDisplayContent',$configurationManager->get('articleDisplayContent'));
 $tpl->assign('articleView',$configurationManager->get('articleView'));
@@ -40,6 +41,7 @@ $tpl->assign('articlePerPages',$configurationManager->get('articlePerPages'));
 $tpl->assign('articleDisplayLink',$configurationManager->get('articleDisplayLink'));
 $tpl->assign('articleDisplayDate',$configurationManager->get('articleDisplayDate'));
 $tpl->assign('articleDisplayAuthor',$configurationManager->get('articleDisplayAuthor'));
+$tpl->assign('articleDisplaySort',$configurationManager->get('articleDisplaySort'));
 
 $target = MYSQL_PREFIX.'event.title,'.MYSQL_PREFIX.'event.unread,'.MYSQL_PREFIX.'event.favorite,'.MYSQL_PREFIX.'event.feed,';
 if($articleDisplayContent && $articleView=='partial') $target .= MYSQL_PREFIX.'event.description,';
@@ -102,7 +104,8 @@ $pagesArray = array();
 						$page = (isset($_['page'])?$_['page']:1);
 						$pages = ceil($numberOfItem/$articlePerPages); 
 						$startArticle = ($page-1)*$articlePerPages;
-						$events = $eventManager->loadAllOnlyColumn($target,array('unread'=>1),'pubDate DESC',$startArticle.','.$articlePerPages);
+						if($articleDisplaySort) {$order = 'pubdate desc';} else {$order = 'pubdate asc';}
+						$events = $eventManager->loadAllOnlyColumn($target,array('unread'=>1),$order,$startArticle.','.$articlePerPages);
 						$tpl->assign('numberOfItem',$numberOfItem);
 
 					break;

+ 2 - 0
install.php

@@ -150,6 +150,7 @@ if(isset($_['installButton'])){
 	$configurationManager->add('articleDisplayLink',$_['articleDisplayLink']);
 	$configurationManager->add('articleDisplayDate',$_['articleDisplayDate']);
 	$configurationManager->add('articleDisplayAuthor',$_['articleDisplayAuthor']);
+	$configurationManager->add('articleDisplaySort',$_['articleDisplaySort']);
 	$configurationManager->add('synchronisationType',$_['synchronisationType']);
 	$configurationManager->add('feedMaxEvents',$_['feedMaxEvents']);
 	
@@ -291,6 +292,7 @@ if(isset($_['installButton'])){
 					<p>Autoriser la lecture anonyme: <input type="radio" checked="checked" value="1" name="articleDisplayAnonymous">Oui <input type="radio" value="0" name="articleDisplayAnonymous">Non</p>
 					<h3 class="articleDetails">Nb: si vous choisissez cette option, les utilisateurs non authentifiés pourront consulter vos flux (sans pouvoir les marquer comme lu/non lu).</h3>
 					<p>Nombre d'articles par pages: <input type="text" value="5" name="articlePerPages"></p>
+					<p>Affichage des articles les plus récents en premier : <input type="radio" checked="checked" value="1" name="articleDisplaySort">Oui <input type="radio" value="0" name="articleDisplaySort">Non</p>
 					<p>Affichage du lien direct de l'article: <input type="radio" checked="checked" value="1" name="articleDisplayLink">Oui <input type="radio" value="0" name="articleDisplayLink">Non</p>
 					<p>Affichage de la date de l'article: <input type="radio" checked="checked" value="1" name="articleDisplayDate">Oui <input type="radio" value="0" name="articleDisplayDate">Non</p>
 					<p>Affichage de l'auteur de l'article: <input type="radio" checked="checked" value="1" name="articleDisplayAuthor">Oui <input type="radio" value="0" name="articleDisplayAuthor">Non</p>

+ 1 - 0
settings.php

@@ -17,6 +17,7 @@ $tpl->assign('articleDisplayAnonymous', $configurationManager->get('articleDispl
 $tpl->assign('articleDisplayLink', $configurationManager->get('articleDisplayLink')); 
 $tpl->assign('articleDisplayDate', $configurationManager->get('articleDisplayDate')); 
 $tpl->assign('articleDisplayAuthor', $configurationManager->get('articleDisplayAuthor'));
+$tpl->assign('articleDisplaySort', $configurationManager->get('articleDisplaySort'));
 $tpl->assign('articleDisplayContent', $configurationManager->get('articleDisplayContent')); 
 $tpl->assign('articleView', $configurationManager->get('articleView'));
 //Récuperation des plugins  

+ 5 - 0
templates/marigolds/settings.html

@@ -158,6 +158,11 @@
 							<input type="radio" {if="$articleDisplayAuthor=='0'"} checked="checked" {/if} value="0" id="articleDisplayAuthorNo" name="articleDisplayAuthor" /><label for="articleDisplayAuthorNo">Non</label>
 						</fieldset>
 						<fieldset>
+							<legend>Afficher les articles les plus récent en premier</legend>
+							<input type="radio" {if="$articleDisplaySort"} checked="checked" {/if} value="1" id="articleDisplaySortYes" name="articleDisplaySort" /><label for="articleDisplaySortYes">Oui</label>
+							<input type="radio" {if="!$articleDisplaySort"} checked="checked" {/if} value="0" id="articleDisplaySortNo" name="articleDisplaySort" /><label for="articleDisplaySortNo">Non</label>
+						</fieldset>
+						<fieldset>
 							<legend>Affichage du contenu de l'article</legend>
 							<input type="radio" onchange="$('.articleView').slideToggle(200);" {if="$articleDisplayContent=='1'"} checked="checked" {/if} value="1" id="articleDisplayContentYes" name="articleDisplayContent" /><label for="articleDisplayContentYes">Oui</label>
 							<input type="radio" onchange="$('.articleView').slideToggle(200);" {if="$articleDisplayContent=='0'"} checked="checked" {/if} value="0" id="articleDisplayContentNo" name="articleDisplayContent" /><label for="articleDisplayContentNo">Non</label>