A free, self-hostable news aggregator…
Correction code + ajout commentaires + à l'ajout d'un flux, on n'ajoute plus les trop vieux articles
Marien Fressinaud1c202b9364c7
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.phpindex ebbf3259f..5173c3a2d 100755--- a/app/controllers/feedController.php+++ b/app/controllers/feedController.php@@ -63,11 +63,16 @@ class feedController extends ActionController {$entryDAO = new EntryDAO ();$entries = $feed->entries ();+ // on calcule la date des articles les plus anciens qu'on accepte+ $nb_month_old = $this->view->conf->oldEntries ();+ $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);+// on ajoute les articles en masse sans vérification- // TODO vérification de la date pour ne pas ajouter de vieux articlesforeach ($entries as $entry) {- $values = $entry->toArray ();- $entryDAO->addEntry ($values);+ if ($entry->date (true) >= $date_min) {+ $values = $entry->toArray ();+ $entryDAO->addEntry ($values);+ }}// ok, ajout terminé@@ -164,7 +169,6 @@ class feedController extends ActionController {}}- // TODO on peut peut-être trouver une meilleure place pour cette fonction ?$entryDAO->cleanOldEntries ($nb_month_old);$url = array ();diff --git a/app/controllers/indexController.php b/app/controllers/indexController.phpindex 15cbd7edc..f4f0b98b3 100755--- a/app/controllers/indexController.php+++ b/app/controllers/indexController.php@@ -6,14 +6,14 @@ class indexController extends ActionController {private $mode = 'all';public function indexAction () {- if (Request::param ('output', '') == 'rss') {+ if (Request::param ('output') == 'rss') {$this->view->_useLayout (false);+ } else {+ View::appendScript (Url::display ('/scripts/shortcut.js'));+ View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main')));+ View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize')));}- View::appendScript (Url::display ('/scripts/shortcut.js'));- View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main')));- View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'actualize')));-$entryDAO = new EntryDAO ();$feedDAO = new FeedDAO ();$catDAO = new CategoryDAO ();@@ -28,6 +28,7 @@ class indexController extends ActionController {$type = $this->getType ();$error = $this->checkAndProcessType ($type);if (!$error) {+ // On récupère les différents éléments de filtrage$this->view->state = $state = Request::param ('state', $this->view->conf->defaultView ());$filter = Request::param ('search', '');$this->view->order = $order = Request::param ('order', $this->view->conf->sortOrder ());@@ -35,10 +36,13 @@ class indexController extends ActionController {$first = Request::param ('next', '');try {+ // EntriesGetter permet de déporter la complexité du filtrage$getter = new EntriesGetter ($type, $state, $filter, $order, $nb, $first);$getter->execute ();$entries = $getter->getPaginator ();+ // Si on a récupéré aucun article "non lus"+ // on essaye de récupérer tous les articlesif ($state == 'not_read' && $entries->isEmpty ()) {$this->view->state = 'all';$getter->_state ('all');@@ -53,11 +57,6 @@ class indexController extends ActionController {404,array ('error' => array (Translate::t ('page_not_found'))));- } catch(CurrentPagePaginationException $e) {- Error::error (- 404,- array ('error' => array (Translate::t ('page_not_found')))- );}} else {Error::error (diff --git a/app/models/RSSPaginator.php b/app/models/RSSPaginator.phpindex 619b70380..7010291bc 100644--- a/app/models/RSSPaginator.php+++ b/app/models/RSSPaginator.php@@ -1,5 +1,7 @@<?php+// Un système de pagination beaucoup plus simple que Paginator+// mais mieux adapté à nos besoinsclass RSSPaginator {private $items = array ();private $next = '';diff --git a/app/views/index/index.phtml b/app/views/index/index.phtmlindex c39775fd7..0e09f84df 100644--- a/app/views/index/index.phtml+++ b/app/views/index/index.phtml@@ -1,18 +1,16 @@<?php-if (Request::param ('output', '') == 'rss') {- $this->renderHelper ('rss');- return;-}-?>+$output = Request::param ('output', 'normal');-<?php $this->partial ('aside_flux'); ?>--<?php $this->partial ('nav_menu'); ?>+if ($output == 'rss') {+ $this->renderHelper ('rss');+} else {+ $this->partial ('aside_flux');+ $this->partial ('nav_menu');-<?php-if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {- $items = $this->entryPaginator->items ();+ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {+ $items = $this->entryPaginator->items ();?>+<div id="stream"><?php$display_today = true;@@ -113,8 +111,10 @@ if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) {<?php $this->entryPaginator->render ('pagination.phtml', 'next'); ?></div>-<?php } else { ?>++ <?php } else { ?><div class="alert alert-warn"><span class="alert-head"><?php echo Translate::t ('no_feed_to_display'); ?></span></div>+ <?php } ?><?php } ?>