Browse Source

Ajout de la fonction pour cacher les flux trop verbeux.
RAF : ajout de la fonctionnalité dans les settings pour paramétrage

cobalt74 7 years ago
parent
commit
fdb3038414
7 changed files with 78 additions and 7 deletions
  1. 27 0
      Event.class.php
  2. 11 2
      Feed.class.php
  3. 1 1
      MysqlEntity.class.php
  4. 17 0
      Update-2.0.sql
  5. 8 2
      article.php
  6. 12 2
      index.php
  7. 2 0
      install.php

+ 27 - 0
Event.class.php

@@ -59,6 +59,33 @@ class Event extends MysqlEntity{
         return $events;
     }
 
+    function getEventCountNotVerboseFeed(){
+        $results = $this->customQuery('SELECT COUNT(1) FROM '.MYSQL_PREFIX.$this->TABLE_NAME.' INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.$this->TABLE_NAME.'.unread=1 AND '.MYSQL_PREFIX.'feed.isverbose=0');
+        while($item = mysql_fetch_array($results)){
+            $nbitem =  $item[0];
+        }
+
+        return $nbitem;
+    }
+
+    function getEventsNotVerboseFeed($start=0,$limit=10000,$order,$columns='*'){
+        $eventManager = new Event();
+        $objects = array();
+        $results = $this->customQuery('SELECT '.$columns.' FROM '.MYSQL_PREFIX.'event INNER JOIN '.MYSQL_PREFIX.'feed ON ('.MYSQL_PREFIX.'event.feed = '.MYSQL_PREFIX.'feed.id) WHERE '.MYSQL_PREFIX.'event.unread=1 AND '.MYSQL_PREFIX.'feed.isverbose = 0 ORDER BY '.$order.' LIMIT '.$start.','.$limit);
+        if($results!=false){
+            while($item = mysql_fetch_array($results)){
+                $object = new Event();
+                foreach($object->getObject_fields() as $field=>$type){
+                    $setter = 'set'.ucFirst($field);
+                    if(isset($item[$field])) $object->$setter($item[$field]);
+                }
+                $objects[] = $object;
+                unset($object);
+            }
+        }
+        return $objects;
+    }
+
     function setId($id){
         $this->id = $id;
     }

+ 11 - 2
Feed.class.php

@@ -8,7 +8,7 @@
 
 class Feed extends MysqlEntity{
 
-    protected $id,$name,$url,$events=array(),$description,$website,$folder,$lastupdate;
+    protected $id,$name,$url,$events=array(),$description,$website,$folder,$lastupdate,$isverbose;
     protected $TABLE_NAME = 'feed';
     protected $CLASS_NAME = 'Feed';
     protected $object_fields =
@@ -19,7 +19,8 @@ class Feed extends MysqlEntity{
         'website'=>'longstring',
         'url'=>'longstring',
         'lastupdate'=>'string',
-        'folder'=>'integer'
+        'folder'=>'integer',
+        'isverbose'=>'boolean',
     );
 
     protected $object_fields_index =
@@ -285,6 +286,14 @@ class Feed extends MysqlEntity{
         $this->lastupdate = $lastupdate;
     }
 
+    function getIsverbose(){
+        return $this->isverbose;
+    }
+
+    function setIsverbose($isverbose){
+        $this->isverbose = $isverbose;
+    }
+
     /** @returns vrai si l'url n'est pas déjà connue .*/
     function notRegistered() {
         return $this->rowCount(array('url' => $this->url)) == 0;

+ 1 - 1
MysqlEntity.class.php

@@ -299,7 +299,7 @@ class MysqlEntity
             return $objects;
     }
 
-        public function loadAllOnlyColumn($selColumn,$columns,$order=null,$limit=null,$operation="=",$debug=false){
+    public function loadAllOnlyColumn($selColumn,$columns,$order=null,$limit=null,$operation="=",$debug=false){
         $objects = $this->loadAll($columns,$order,$limit,$operation,$debug,$selColumn);
         if(count($objects)==0)$objects = array();
         return $objects;

+ 17 - 0
Update-2.0.sql

@@ -0,0 +1,17 @@
+/* #############
+###  MISE À JOUR Base de données de Leed pour fonctionnement en v2.0
+
+Conseils :
+- Avant d'effectuer la mise à jour, sauvegardez votre BDD et exportez vos flux en OPML.
+- Attention : "leed_" est à remplacer par votre préfix de table.
+- Ce fichier est à supprimer après installation.
+
+Description :
+- Les requêtes suivantes sont a exécuter sur votre Base de données Leed avec phpMyAdmin par exemple
+
+############### */
+-- Mise à jour table FOLDER (Obligatoire)
+ALTER TABLE `leed_feed` ADD `isverbose` INT(1) NOT NULL;
+
+-- évolution pour les flux RSS défini verbeux qu'il faut ou ne faut pas afficher sur la page d'accueil.
+INSERT INTO `leed_configuration` (key,value) VALUES ('displayFolderIsVerbose',1);

+ 8 - 2
article.php

@@ -21,6 +21,7 @@ $articleDisplayDate = $configurationManager->get('articleDisplayDate');
 $articleDisplayAuthor = $configurationManager->get('articleDisplayAuthor');
 $articleDisplayHomeSort = $configurationManager->get('articleDisplayHomeSort');
 $articleDisplayFolderSort = $configurationManager->get('articleDisplayFolderSort');
+$displayFolderIsVerbose = $configurationManager->get('displayFolderIsVerbose');
 
 $tpl->assign('articleView',$articleView);
 $tpl->assign('articleDisplayLink',$articleDisplayLink);
@@ -73,9 +74,14 @@ switch($action){
     /* AFFICHAGE DES EVENEMENTS NON LUS (COMPORTEMENT PAR DEFAUT) */
     case 'unreadEvents':
     default:
+        $filter = array('unread'=>1);
         if($articleDisplayHomeSort) {$order = 'pubdate desc';} else {$order = 'pubdate asc';}
-        $events = $eventManager->loadAllOnlyColumn($target,array('unread'=>1),$order,$startArticle.','.$articlePerPages);
-    break;
+        if($displayFolderIsVerbose) {
+            $events = $eventManager->loadAllOnlyColumn($target,$filter,$order,$startArticle.','.$articlePerPages);
+        } else {
+            $events = $eventManager->getEventsNotVerboseFeed($startArticle,$articlePerPages,$order,$target);
+        }
+        break;
 }
 $tpl->assign('events',$events);
 $tpl->assign('scroll',$_['scroll']);

+ 12 - 2
index.php

@@ -38,6 +38,7 @@ $articleDisplayFolderSort = $configurationManager->get('articleDisplayFolderSort
 $displayOnlyUnreadFeedFolder = $configurationManager->get('displayOnlyUnreadFeedFolder');
 if (!isset($displayOnlyUnreadFeedFolder)) $displayOnlyUnreadFeedFolder=false;
 ($displayOnlyUnreadFeedFolder=='true')?$displayOnlyUnreadFeedFolder_reverse='false':$displayOnlyUnreadFeedFolder_reverse='true';
+$displayFolderIsVerbose = $configurationManager->get('displayFolderIsVerbose');
 
 $tpl->assign('articleDisplayContent',$configurationManager->get('articleDisplayContent'));
 $tpl->assign('articleView',$configurationManager->get('articleView'));
@@ -119,12 +120,21 @@ switch($action){
     /* AFFICHAGE DES EVENEMENTS NON LUS (COMPORTEMENT PAR DEFAUT) */
     case 'unreadEvents':
     default:
-        $numberOfItem = $eventManager->rowCount(array('unread'=>1));
+        $filter = array('unread'=>1);
+        if($displayFolderIsVerbose) {
+            $numberOfItem = $eventManager->rowCount($filter);
+        } else {
+            $numberOfItem = $eventManager->getEventCountNotVerboseFeed();
+        }
         $page = (isset($_['page'])?$_['page']:1);
         $pages = ($articlePerPages>0?ceil($numberOfItem/$articlePerPages):1);
         $startArticle = ($page-1)*$articlePerPages;
         if($articleDisplayHomeSort) {$order = 'pubdate desc';} else {$order = 'pubdate asc';}
-        $events = $eventManager->loadAllOnlyColumn($target,array('unread'=>1),$order,$startArticle.','.$articlePerPages);
+        if($displayFolderIsVerbose) {
+            $events = $eventManager->loadAllOnlyColumn($target,$filter,$order,$startArticle.','.$articlePerPages);
+        } else {
+            $events = $eventManager->getEventsNotVerboseFeed($startArticle,$articlePerPages,$order,$target);
+        }
         $tpl->assign('numberOfItem',$numberOfItem);
 
     break;

+ 2 - 0
install.php

@@ -183,6 +183,8 @@ if (isset($_['installButton']) && empty($test['Erreur'])) { // Pas d'erreur, l'i
     $configurationManager->add('articleDisplayAuthor','1');
     $configurationManager->add('articleDisplayHomeSort','1');
     $configurationManager->add('articleDisplayFolderSort','1');
+    $configurationManager->add('displayOnlyUnreadFeedFolder','false');
+    $configurationManager->add('displayFolderIsVerbose',1);
     $configurationManager->add('synchronisationType','auto');
     $configurationManager->add('feedMaxEvents','50');
     $configurationManager->add('synchronisationCode',$synchronisationCode);