From 1c202b9364c766d1bd28a22a04b3f70077f23e84 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 2 May 2013 09:44:34 +0200 Subject: Correction code + ajout commentaires + à l'ajout d'un flux, on n'ajoute plus les trop vieux articles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 12 ++++++++---- app/controllers/indexController.php | 19 +++++++++---------- app/models/RSSPaginator.php | 2 ++ app/views/index/index.phtml | 24 ++++++++++++------------ 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 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 articles foreach ($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.php index 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 articles if ($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.php index 619b70380..7010291bc 100644 --- a/app/models/RSSPaginator.php +++ b/app/models/RSSPaginator.php @@ -1,5 +1,7 @@ renderHelper ('rss'); - return; -} -?> +$output = Request::param ('output', 'normal'); -partial ('aside_flux'); ?> - -partial ('nav_menu'); ?> +if ($output == 'rss') { + $this->renderHelper ('rss'); +} else { + $this->partial ('aside_flux'); + $this->partial ('nav_menu'); -entryPaginator) && !$this->entryPaginator->isEmpty ()) { - $items = $this->entryPaginator->items (); + if (isset ($this->entryPaginator) && !$this->entryPaginator->isEmpty ()) { + $items = $this->entryPaginator->items (); ?> +
entryPaginator) && !$this->entryPaginator->isEmpty ()) { entryPaginator->render ('pagination.phtml', 'next'); ?>
- + +
+ -- cgit v1.2.3