aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Entry.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Models/Entry.php')
-rw-r--r--app/Models/Entry.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index fb17268b3..72e59e38c 100644
--- a/app/Models/Entry.php
+++ b/app/Models/Entry.php
@@ -44,6 +44,7 @@ class FreshRSS_Entry extends Minz_Model {
private $feed;
private $tags;
+ private $attributes = [];
public function __construct(int $feedId = 0, string $guid = '', string $title = '', string $authors = '', string $content = '',
string $link = '', $pubdate = 0, bool $is_read = false, bool $is_favorite = false, string $tags = '') {
@@ -88,6 +89,9 @@ class FreshRSS_Entry extends Minz_Model {
if (!empty($dao['categories'])) {
$entry->_tags($dao['categories']);
}
+ if (!empty($dao['attributes'])) {
+ $entry->_attributes('', $dao['attributes']);
+ }
return $entry;
}
@@ -228,6 +232,29 @@ class FreshRSS_Entry extends Minz_Model {
}
}
+ public function attributes($key = '') {
+ if ($key == '') {
+ return $this->attributes;
+ } else {
+ return isset($this->attributes[$key]) ? $this->attributes[$key] : null;
+ }
+ }
+
+ public function _attributes(string $key, $value) {
+ if ($key == '') {
+ if (is_string($value)) {
+ $value = json_decode($value, true);
+ }
+ if (is_array($value)) {
+ $this->attributes = $value;
+ }
+ } elseif ($value === null) {
+ unset($this->attributes[$key]);
+ } else {
+ $this->attributes[$key] = $value;
+ }
+ }
+
public function hash(): string {
if ($this->hash == '') {
//Do not include $this->date because it may be automatically generated when lacking
@@ -588,6 +615,7 @@ class FreshRSS_Entry extends Minz_Model {
'is_favorite' => $this->isFavorite(),
'id_feed' => $this->feed(),
'tags' => $this->tags(true),
+ 'attributes' => $this->attributes(),
);
}
}