summaryrefslogtreecommitdiff
path: root/app/models/Feed.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-07-04 19:38:29 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-07-04 19:38:29 +0200
commiteb5f05304c253df90873b94ba52d7093115f3850 (patch)
tree1152ab618aa5cf884a1f2f2e2d1926da4167a6be /app/models/Feed.php
parent8dd5fd51f74a47e5c80052f27a74cdcd5dd044b9 (diff)
parentb5f233f6d524ca9f74e9d33bf5692a1a678d7fec (diff)
Merge branch 'dev'0.4.0
Diffstat (limited to 'app/models/Feed.php')
-rw-r--r--app/models/Feed.php47
1 files changed, 34 insertions, 13 deletions
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 51c409b69..4c6a3d229 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)) {
@@ -204,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 (),
@@ -227,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;
}
@@ -289,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 (
@@ -306,6 +309,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 +490,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']);