From 30890b3d15566dd087b8e6837b75d47b17ed93ed Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 10 Apr 2013 20:21:10 +0200 Subject: Fix bug #50 --- app/models/Entry.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/Entry.php') diff --git a/app/models/Entry.php b/app/models/Entry.php index 3e90db289..ae207069c 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -329,7 +329,7 @@ class EntryDAO extends Model_pdo { public function cleanOldEntries ($nb_month) { $date = 60 * 60 * 24 * 30 * $nb_month; - $sql = 'DELETE FROM entry WHERE date <= ? AND is_favorite = 0 AND notes != ""'; + $sql = 'DELETE FROM entry WHERE date <= ? AND is_favorite = 0 AND annotation = ""'; $stm = $this->bd->prepare ($sql); $values = array ( -- cgit v1.2.3 From e6436444db9e1bcc13c02c132f327e80d6584df0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 10 Apr 2013 20:55:12 +0200 Subject: Fix bug #49 : les flux sans auteur sont traités normalement désormais MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 2 ++ app/models/Category.php | 10 ++++++++++ app/models/Entry.php | 26 ++++++++++++++++++++++---- app/models/Feed.php | 10 ++++++++++ 4 files changed, 44 insertions(+), 4 deletions(-) (limited to 'app/models/Entry.php') diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index e16161842..812227f89 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -33,9 +33,11 @@ class feedController extends ActionController { 'description' => $feed->description (), 'lastUpdate' => time () ); + if ($feedDAO->addFeed ($values)) { $entryDAO = new EntryDAO (); $entries = $feed->entries (); + foreach ($entries as $entry) { $values = $entry->toArray (); $entryDAO->addEntry ($values); diff --git a/app/models/Category.php b/app/models/Category.php index d7db8ee65..a153b8838 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -77,6 +77,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -94,6 +96,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -107,6 +111,8 @@ class CategoryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -124,6 +130,8 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -140,6 +148,8 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } diff --git a/app/models/Entry.php b/app/models/Entry.php index ae207069c..4c672bcf3 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -49,7 +49,11 @@ class Entry extends Model { return $this->title; } public function author () { - return $this->author; + if (is_null ($this->author)) { + return ''; + } else { + return $this->author; + } } public function content () { return $this->content; @@ -212,7 +216,7 @@ class Entry extends Model { class EntryDAO extends Model_pdo { public function addEntry ($valuesTmp) { - $sql = 'INSERT INTO entry(id, guid, title, author, content, link, date, is_read, is_favorite, is_public, id_feed, annotation, tags, lastUpdate) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + $sql = 'INSERT INTO entry(id, guid, title, author, content, link, date, is_read, is_favorite, is_public, id_feed, lastUpdate) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $stm = $this->bd->prepare ($sql); $values = array ( @@ -227,14 +231,14 @@ class EntryDAO extends Model_pdo { $valuesTmp['is_favorite'], $valuesTmp['is_public'], $valuesTmp['id_feed'], - $valuesTmp['annotation'], - $valuesTmp['tags'], $valuesTmp['lastUpdate'], ); if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -261,6 +265,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -274,6 +280,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -286,6 +294,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -298,6 +308,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -323,6 +335,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -339,6 +353,8 @@ class EntryDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -356,6 +372,8 @@ class EntryDAO extends Model_pdo { if (isset ($entry[0])) { return $entry[0]; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } diff --git a/app/models/Feed.php b/app/models/Feed.php index 91c8d8022..b619aaa97 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -207,6 +207,8 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -229,6 +231,8 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -245,6 +249,8 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -258,6 +264,8 @@ class FeedDAO extends Model_pdo { if ($stm && $stm->execute ($values)) { return true; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -275,6 +283,8 @@ class FeedDAO extends Model_pdo { if (isset ($feed[$id])) { return $feed[$id]; } else { + $info = $stm->errorInfo(); + Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } -- cgit v1.2.3 From 61943f1661383bf8017b4c2a76fd11618e4adae0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 11 Apr 2013 20:32:10 +0200 Subject: Plus possible d'ajouter un flux déjà existant + meilleure gestion actualisation / import OPML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/feedController.php | 60 +++++++++++++++++++++++--------------- app/models/Category.php | 4 --- app/models/Entry.php | 2 -- app/models/Feed.php | 18 ++++++++++-- 4 files changed, 52 insertions(+), 32 deletions(-) (limited to 'app/models/Entry.php') diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php index 3fbb20835..d2a2f29f5 100755 --- a/app/controllers/feedController.php +++ b/app/controllers/feedController.php @@ -34,7 +34,13 @@ class feedController extends ActionController { 'lastUpdate' => time () ); - if ($feedDAO->addFeed ($values)) { + if ($feedDAO->searchByUrl ($values['url'])) { + $notif = array ( + 'type' => 'bad', + 'content' => 'Vous êtes déjà abonné à ' . $feed->name () . '' + ); + Session::_param ('notification', $notif); + } elseif ($feedDAO->addFeed ($values)) { $entryDAO = new EntryDAO (); $entries = $feed->entries (); @@ -101,19 +107,19 @@ class feedController extends ActionController { foreach ($feeds as $feed) { try { $feed->load (); - } catch (FeedException $e) { - Log::record ($e->getMessage (), Log::ERROR); - } - $entries = $feed->entries (); + $entries = $feed->entries (); - foreach ($entries as $entry) { - if ($entry->date (true) >= $date_min) { - $values = $entry->toArray (); - $entryDAO->addEntry ($values); + foreach ($entries as $entry) { + if ($entry->date (true) >= $date_min) { + $values = $entry->toArray (); + $entryDAO->addEntry ($values); + } } - } - $feedDAO->updateLastUpdate ($feed->id ()); + $feedDAO->updateLastUpdate ($feed->id ()); + } catch (FeedException $e) { + Log::record ($e->getMessage (), Log::ERROR); + } $i++; if ($i >= 10) { @@ -153,20 +159,26 @@ class feedController extends ActionController { $i = 0; foreach ($feeds as $feed) { - $feed->load (); + try { + $feed->load (); - // Enregistrement du flux - $values = array ( - 'id' => $feed->id (), - 'url' => $feed->url (), - 'category' => $feed->category (), - 'name' => $feed->name (), - 'website' => $feed->website (), - 'description' => $feed->description (), - 'lastUpdate' => 0 - ); + // Enregistrement du flux + $values = array ( + 'id' => $feed->id (), + 'url' => $feed->url (), + 'category' => $feed->category (), + 'name' => $feed->name (), + 'website' => $feed->website (), + 'description' => $feed->description (), + 'lastUpdate' => 0 + ); - $feedDAO->addFeed ($values); + if (!$feedDAO->searchByUrl ($values['url'])) { + $feedDAO->addFeed ($values); + } + } catch (FeedException $e) { + Log::record ($e->getMessage (), Log::ERROR); + } } Request::forward (array ( @@ -203,7 +215,7 @@ class feedController extends ActionController { $catDAO = new CategoryDAO (); foreach ($categories as $cat) { - if (!$catDAO->searchByName ()) { + if (!$catDAO->searchByName ($cat->name ())) { $values = array ( 'id' => $cat->id (), 'name' => $cat->name (), diff --git a/app/models/Category.php b/app/models/Category.php index a153b8838..ae803591f 100755 --- a/app/models/Category.php +++ b/app/models/Category.php @@ -130,8 +130,6 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } @@ -148,8 +146,6 @@ class CategoryDAO extends Model_pdo { if (isset ($cat[0])) { return $cat[0]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } diff --git a/app/models/Entry.php b/app/models/Entry.php index 4c672bcf3..c8d05c5eb 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -372,8 +372,6 @@ class EntryDAO extends Model_pdo { if (isset ($entry[0])) { return $entry[0]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); return false; } } diff --git a/app/models/Feed.php b/app/models/Feed.php index 056cbf626..2e6782921 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -287,8 +287,22 @@ class FeedDAO extends Model_pdo { if (isset ($feed[$id])) { return $feed[$id]; } else { - $info = $stm->errorInfo(); - Log::record ('SQL error : ' . $info[2], Log::ERROR); + return false; + } + } + public function searchByUrl ($url) { + $sql = 'SELECT * FROM feed WHERE url=?'; + $stm = $this->bd->prepare ($sql); + + $values = array ($url); + + $stm->execute ($values); + $res = $stm->fetchAll (PDO::FETCH_ASSOC); + $feed = current (HelperFeed::daoToFeed ($res)); + + if (isset ($feed)) { + return $feed; + } else { return false; } } -- cgit v1.2.3 From e2171de4e6b090fbbad07d8852a068ec7ca050c0 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 11 Apr 2013 21:27:29 +0200 Subject: Fix issue #37 : possibilité de sortir un site du flux principal (utile pour les sites qui publient beaucoup) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/configureController.php | 4 +++- app/controllers/indexController.php | 4 +--- app/models/Entry.php | 23 ++++++++++------------- app/models/Feed.php | 11 +++++++++++ app/views/configure/feed.phtml | 15 ++++++++++----- 5 files changed, 35 insertions(+), 22 deletions(-) (limited to 'app/models/Entry.php') diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php index 243c155f9..01ed4d414 100755 --- a/app/controllers/configureController.php +++ b/app/controllers/configureController.php @@ -88,10 +88,12 @@ class configureController extends ActionController { if (Request::isPost () && $this->view->flux) { $cat = Request::param ('category', 0); $path = Request::param ('path_entries', ''); + $priority = Request::param ('priority', 0); $values = array ( 'category' => $cat, - 'pathEntries' => $path + 'pathEntries' => $path, + 'priority' => $priority ); if ($feedDAO->updateFeed ($id, $values)) { diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index c83f7f1d2..1eba7231f 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -76,9 +76,7 @@ class indexController extends ActionController { try { $this->view->entryPaginator = $entryDAO->getPaginator ($entries); - } catch (CurrentPagePaginationException $e) { - - } + } catch (CurrentPagePaginationException $e) { } $this->view->cat_aside = $catDAO->listCategories (); $this->view->nb_favorites = $entryDAO->countFavorites (); diff --git a/app/models/Entry.php b/app/models/Entry.php index c8d05c5eb..770b27eed 100755 --- a/app/models/Entry.php +++ b/app/models/Entry.php @@ -272,7 +272,7 @@ class EntryDAO extends Model_pdo { } public function markReadEntries ($read, $dateMax) { - $sql = 'UPDATE entry SET is_read = ? WHERE date < ?'; + $sql = 'UPDATE entry e INNER JOIN feed f ON e.id_feed = f.id SET is_read = ? WHERE date < ? AND priority > 0'; $stm = $this->bd->prepare ($sql); $values = array ($read, $dateMax); @@ -377,19 +377,15 @@ class EntryDAO extends Model_pdo { } public function listEntries ($mode, $search = false, $order = 'high_to_low') { - $where = ''; + $where = ' WHERE priority > 0'; if ($mode == 'not_read') { - $where = ' WHERE is_read=0'; + $where .= ' AND is_read=0'; } $values = array(); if ($search) { $values[] = '%'.$search.'%'; - if ($mode == 'not_read') { - $where = ' AND title LIKE ?'; - } else { - $where = ' WHERE title LIKE ?'; - } + $where .= ' AND title LIKE ?'; } if ($order == 'low_to_high') { @@ -398,7 +394,7 @@ class EntryDAO extends Model_pdo { $order = ''; } - $sql = 'SELECT COUNT(*) AS count FROM entry' . $where; + $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id' . $where; $stm = $this->bd->prepare ($sql); $stm->execute ($values); $res = $stm->fetchAll (PDO::FETCH_ASSOC); @@ -407,7 +403,8 @@ class EntryDAO extends Model_pdo { $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; $fin = $this->nbItemsPerPage; - $sql = 'SELECT * FROM entry' . $where + $sql = 'SELECT * FROM entry e' + . ' INNER JOIN feed f ON e.id_feed = f.id' . $where . ' ORDER BY date' . $order . ' LIMIT ' . $deb . ', ' . $fin; $stm = $this->bd->prepare ($sql); @@ -553,7 +550,7 @@ class EntryDAO extends Model_pdo { } public function count () { - $sql = 'SELECT COUNT(*) AS count FROM entry'; + $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE priority > 0'; $stm = $this->bd->prepare ($sql); $stm->execute (); $res = $stm->fetchAll (PDO::FETCH_ASSOC); @@ -562,11 +559,11 @@ class EntryDAO extends Model_pdo { } public function countNotRead () { - $sql = 'SELECT COUNT(*) AS count FROM entry WHERE is_read=0'; + $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE is_read=0 AND priority > 0'; $stm = $this->bd->prepare ($sql); $stm->execute (); $res = $stm->fetchAll (PDO::FETCH_ASSOC); - + Log::record ('not read : ' . $res[0]['count'], Log::NOTICE); return $res[0]['count']; } diff --git a/app/models/Feed.php b/app/models/Feed.php index 2e6782921..50632f5a7 100644 --- a/app/models/Feed.php +++ b/app/models/Feed.php @@ -9,6 +9,7 @@ class Feed extends Model { private $website = ''; private $description = ''; private $lastUpdate = 0; + private $priority = 10; private $pathEntries = ''; private $httpAuth = ''; @@ -48,6 +49,9 @@ class Feed extends Model { public function lastUpdate () { return $this->lastUpdate; } + public function priority () { + return $this->priority; + } public function pathEntries () { return $this->pathEntries; } @@ -108,6 +112,12 @@ class Feed extends Model { public function _lastUpdate ($value) { $this->lastUpdate = $value; } + public function _priority ($value) { + if (!is_int (intval ($value))) { + $value = 10; + } + $this->priority = $value; + } public function _pathEntries ($value) { $this->pathEntries = $value; } @@ -382,6 +392,7 @@ class HelperFeed { $list[$key]->_website ($dao['website']); $list[$key]->_description ($dao['description']); $list[$key]->_lastUpdate ($dao['lastUpdate']); + $list[$key]->_priority ($dao['priority']); $list[$key]->_pathEntries ($dao['pathEntries']); $list[$key]->_httpAuth ($dao['httpAuth']); diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml index 2adc5c839..adea27e52 100644 --- a/app/views/configure/feed.phtml +++ b/app/views/configure/feed.phtml @@ -9,28 +9,25 @@
Informations -
-
-
flux->nbEntries (); ?>
- + Catégorie - gestion
@@ -45,6 +42,15 @@
Avancé +
+ +
+ +
+
@@ -52,7 +58,6 @@ Permet de récupérer les flux tronqués (attention, demande plus de temps !)
- + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + + + diff --git a/public/theme/icons/share.svg b/public/theme/icons/share.svg new file mode 100644 index 000000000..443321882 --- /dev/null +++ b/public/theme/icons/share.svg @@ -0,0 +1,34 @@ + + + + + + + + image/svg+xml + + Gnome Symbolic Icon Theme + + + + + + + Gnome Symbolic Icon Theme + + + + + + + + + + + + + + + + + -- cgit v1.2.3