Просмотр исходного кода

Correction bug gestion de l'id pour Feed et Entry

Marien Fressinaud 13 лет назад
Родитель
Сommit
3d3618d97c
2 измененных файлов с 28 добавлено и 4 удалено
  1. 14 2
      app/models/Entry.php
  2. 14 2
      app/models/Feed.php

+ 14 - 2
app/models/Entry.php

@@ -1,6 +1,7 @@
 <?php
 
 class Entry extends Model {
+	private $id = null;
 	private $guid;
 	private $title;
 	private $author;
@@ -25,7 +26,11 @@ class Entry extends Model {
 	}
 	
 	public function id () {
-		return small_hash ($this->guid . Configuration::selApplication ());
+		if(is_null($this->id)) {
+			return small_hash ($this->guid . Configuration::selApplication ());
+		} else {
+			return $this->id;
+		}
 	}
 	public function guid () {
 		return $this->guid;
@@ -63,7 +68,10 @@ class Entry extends Model {
 			return $this->feed;
 		}
 	}
-	
+
+	public function _id ($value) {
+		$this->id = $value;
+	}
 	public function _guid ($value) {
 		$this->guid = $value;
 	}
@@ -370,6 +378,10 @@ class HelperEntry {
 				$dao['is_read'],
 				$dao['is_favorite']
 			);
+
+			if (isset ($dao['id'])) {
+				$list[$key]->_id ($dao['id']);
+			}
 		}
 
 		return $list;

+ 14 - 2
app/models/Feed.php

@@ -1,6 +1,7 @@
 <?php
 
 class Feed extends Model {
+	private $id = null;
 	private $url;
 	private $category = '';
 	private $entries = null;
@@ -14,7 +15,11 @@ class Feed extends Model {
 	}
 	
 	public function id () {
-		return small_hash ($this->url . Configuration::selApplication ());
+		if(is_null($this->id)) {
+			return small_hash ($this->url . Configuration::selApplication ());
+		} else {
+			return $this->id;
+		}
 	}
 	public function url () {
 		return $this->url;
@@ -45,7 +50,10 @@ class Feed extends Model {
 		$feedDAO = new FeedDAO ();
 		return $feedDAO->countEntries ($this->id ());
 	}
-	
+
+	public function _id ($value) {
+		$this->id = $value;
+	}
 	public function _url ($value) {
 		if (!is_null ($value) && !preg_match ('#^https?://#', $value)) {
 			$value = 'http://' . $value;
@@ -294,6 +302,10 @@ class HelperFeed {
 			$list[$key]->_website ($dao['website']);
 			$list[$key]->_description ($dao['description']);
 			$list[$key]->_lastUpdate ($dao['lastUpdate']);
+
+			if (isset ($dao['id'])) {
+				$list[$key]->_id ($dao['id']);
+			}
 		}
 
 		return $list;