From 9e219cbf5014c8f4f52f3ca6722f7a20cdcc13dd Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 12 May 2013 19:21:39 +0200 Subject: Fix issue #70 : lorsqu'on rencontre un problème avec un flux, on l'indique à l'utilisateur (couleur rouge) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/Feed.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'app/models/Feed.php') diff --git a/app/models/Feed.php b/app/models/Feed.php index 51c409b69..0fc9640bc 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -12,6 +12,7 @@ class Feed extends Model { private $priority = 10; private $pathEntries = ''; private $httpAuth = ''; + private $error = false; public function __construct ($url) { $this->_url ($url); @@ -69,6 +70,9 @@ class Feed extends Model { ); } } + public function inError () { + return $this->error; + } public function nbEntries () { $feedDAO = new FeedDAO (); return $feedDAO->countEntries ($this->id ()); @@ -138,6 +142,14 @@ class Feed extends Model { public function _httpAuth ($value) { $this->httpAuth = $value; } + public function _error ($value) { + if ($value) { + $value = true; + } else { + $value = false; + } + $this->error = $value; + } public function load () { if (!is_null ($this->url)) { @@ -306,6 +318,23 @@ class FeedDAO extends Model_pdo { } } + public function isInError ($id) { + $sql = 'UPDATE feed SET error=1 WHERE id=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $id + ); + + if ($stm && $stm->execute ($values)) { + return true; + } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } + public function changeCategory ($idOldCat, $idNewCat) { $catDAO = new CategoryDAO (); $newCat = $catDAO->searchById ($idNewCat); @@ -470,6 +499,7 @@ class HelperFeed { $list[$key]->_priority ($dao['priority']); $list[$key]->_pathEntries ($dao['pathEntries']); $list[$key]->_httpAuth (base64_decode ($dao['httpAuth'])); + $list[$key]->_error ($dao['error']); if (isset ($dao['id'])) { $list[$key]->_id ($dao['id']); -- cgit v1.2.3 From 9e0af957d4eeb7bb9e2abdd7a45d1a21e0b3cfdb Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sat, 15 Jun 2013 13:02:36 +0200 Subject: Fix issue #85 : la récupération des flux tronqués vérifie d'abord si l'article n'est pas déjà en BDD pour éviter énormément de requêtes inutiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/Entry.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ app/models/Feed.php | 15 +++------------ 2 files changed, 47 insertions(+), 12 deletions(-) (limited to 'app/models/Feed.php') diff --git a/app/models/Entry.php b/app/models/Entry.php index 1d944b184..050407390 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -194,6 +194,29 @@ class Entry extends Model { } } + public function loadCompleteContent($pathEntries) { + // Gestion du contenu + // On cherche à récupérer les articles en entier... même si le flux ne le propose pas + if ($pathEntries) { + $entryDAO = new EntryDAO(); + $entry = $entryDAO->searchByGuid($this->feed, $this->guid); + + if($entry) { + // l'article existe déjà en BDD, en se contente de recharger ce contenu + $this->content = $entry->content(); + } else { + try { + // l'article n'est pas en BDD, on va le chercher sur le site + $this->content = get_content_by_parsing( + $this->link(), $pathEntries + ); + } catch (Exception $e) { + // rien à faire, on garde l'ancien contenu (requête a échoué) + } + } + } + } + public function toArray () { return array ( 'id' => $this->id (), @@ -360,6 +383,27 @@ class EntryDAO extends Model_pdo { } } + public function searchByGuid ($feed_id, $id) { + // un guid est unique pour un flux donné + $sql = 'SELECT * FROM entry WHERE id_feed=? AND guid=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ( + $feed_id, + $id + ); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + list ($entry, $next) = HelperEntry::daoToEntry ($res); + + if (isset ($entry[0])) { + return $entry[0]; + } else { + return false; + } + } + public function searchById ($id) { $sql = 'SELECT * FROM entry WHERE id=?'; $stm = $this->bd->prepare ($sql); diff --git a/app/models/Feed.php b/app/models/Feed.php index 0fc9640bc..15568d06a 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -216,18 +216,7 @@ class Feed extends Model { } } - // Gestion du contenu - // On cherche à récupérer les articles en entier... même si le flux ne le propose pas - $path = $this->pathEntries (); - if ($path) { - try { - $content = get_content_by_parsing ($item->get_permalink (), $path); - } catch (Exception $e) { - $content = $item->get_content (); - } - } else { - $content = $item->get_content (); - } + $content = $item->get_content (); $entry = new Entry ( $this->id (), @@ -239,6 +228,8 @@ class Feed extends Model { $date ? $date : time () ); $entry->_tags ($tags); + // permet de récupérer le contenu des flux tronqués + $entry->loadCompleteContent($this->pathEntries()); $entries[$entry->id ()] = $entry; } -- cgit v1.2.3 From 32499c0b3e519ef2fc255f5990448195256476ac Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 23 Jun 2013 12:45:27 +0200 Subject: Fix issue #91 : flux en erreur repasse normal Lorsqu'on actualise un flux en erreur, si celui-ci est de nouveau accessible, il repasse en normal Ajout d'un bouton pour actualiser les flux sur la page de gestion --- app/i18n/en.php | 2 +- app/i18n/fr.php | 2 +- app/models/Feed.php | 2 +- app/views/configure/feed.phtml | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) (limited to 'app/models/Feed.php') diff --git a/app/i18n/en.php b/app/i18n/en.php index 4dbfde715..209bbcd87 100644 --- a/app/i18n/en.php +++ b/app/i18n/en.php @@ -119,7 +119,7 @@ return array ( 'or' => 'or', 'informations' => 'Informations', - 'feed_in_error' => 'This feed has encountered a problem. Please verify that it is always reachable.', + 'feed_in_error' => 'This feed has encountered a problem. Please verify that it is always reachable then actualize it.', 'website_url' => 'Website URL', 'feed_url' => 'Feed URL', 'number_articles' => 'Number of articles', diff --git a/app/i18n/fr.php b/app/i18n/fr.php index 7a58b984c..172f06953 100644 --- a/app/i18n/fr.php +++ b/app/i18n/fr.php @@ -119,7 +119,7 @@ return array ( 'or' => 'ou', 'informations' => 'Informations', - 'feed_in_error' => 'Ce flux a rencontré un problème. Veuillez vérifier qu\'il est toujours accessible.', + 'feed_in_error' => 'Ce flux a rencontré un problème. Veuillez vérifier qu\'il est toujours accessible puis actualisez-le.', 'website_url' => 'URL du site', 'feed_url' => 'URL du flux', 'number_articles' => 'Nombre d\'articles', diff --git a/app/models/Feed.php b/app/models/Feed.php index 15568d06a..4c6a3d229 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -292,7 +292,7 @@ class FeedDAO extends Model_pdo { } public function updateLastUpdate ($id) { - $sql = 'UPDATE feed SET lastUpdate=? WHERE id=?'; + $sql = 'UPDATE feed SET lastUpdate=?, error=0 WHERE id=?'; $stm = $this->bd->prepare ($sql); $values = array ( diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 650da5641..ec2ff3bdb 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -31,6 +31,14 @@ flux->url (); ?> +
+ +
+ + + +
+
-- cgit v1.2.3