diff options
Diffstat (limited to 'app/Models/Entry.php')
| -rw-r--r-- | app/Models/Entry.php | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php index ccbad5724..985276734 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -10,7 +10,7 @@ class FreshRSS_Entry extends Minz_Model { private $id = 0; private $guid; private $title; - private $author; + private $authors; private $content; private $link; private $date; @@ -21,18 +21,17 @@ class FreshRSS_Entry extends Minz_Model { private $feed; private $tags; - public function __construct($feedId = '', $guid = '', $title = '', $author = '', $content = '', + public function __construct($feedId = '', $guid = '', $title = '', $authors = '', $content = '', $link = '', $pubdate = 0, $is_read = false, $is_favorite = false, $tags = '') { $this->_title($title); - $this->_author($author); + $this->_authors($authors); $this->_content($content); $this->_link($link); $this->_date($pubdate); $this->_isRead($is_read); $this->_isFavorite($is_favorite); $this->_feedId($feedId); - $tags = mb_strcut($tags, 0, 1023, 'UTF-8'); - $this->_tags(preg_split('/[\s#]/', $tags)); + $this->_tags($tags); $this->_guid($guid); } @@ -46,7 +45,15 @@ class FreshRSS_Entry extends Minz_Model { return $this->title; } public function author() { - return $this->author === null ? '' : $this->author; + //Deprecated + return $this->authors(true); + } + public function authors($asString = false) { + if ($asString) { + return $this->authors == null ? '' : ';' . implode('; ', $this->authors); + } else { + return $this->authors; + } } public function content() { return $this->content; @@ -86,9 +93,9 @@ class FreshRSS_Entry extends Minz_Model { return $this->feedId; } } - public function tags($inString = false) { - if ($inString) { - return empty($this->tags) ? '' : '#' . implode(' #', $this->tags); + public function tags($asString = false) { + if ($asString) { + return $this->tags == null ? '' : '#' . implode(' #', $this->tags); } else { return $this->tags; } @@ -97,7 +104,7 @@ class FreshRSS_Entry extends Minz_Model { public function hash() { if ($this->hash === null) { //Do not include $this->date because it may be automatically generated when lacking - $this->hash = md5($this->link . $this->title . $this->author . $this->content . $this->tags(true)); + $this->hash = md5($this->link . $this->title . $this->authors(true) . $this->content . $this->tags(true)); } return $this->hash; } @@ -124,11 +131,22 @@ class FreshRSS_Entry extends Minz_Model { } public function _title($value) { $this->hash = null; - $this->title = mb_strcut($value, 0, 255, 'UTF-8'); + $this->title = $value; } public function _author($value) { + //Deprecated + $this->_authors($value); + } + public function _authors($value) { $this->hash = null; - $this->author = mb_strcut($value, 0, 255, 'UTF-8'); + if (!is_array($value)) { + if (strpos($value, ';') !== false) { + $value = preg_split('/\s*[;]\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); + } else { + $value = preg_split('/\s*[,]\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); + } + } + $this->authors = $value; } public function _content($value) { $this->hash = null; @@ -162,15 +180,8 @@ class FreshRSS_Entry extends Minz_Model { public function _tags($value) { $this->hash = null; if (!is_array($value)) { - $value = array($value); - } - - foreach ($value as $key => $t) { - if (!$t) { - unset($value[$key]); - } + $value = preg_split('/\s*[#,]\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); } - $this->tags = $value; } @@ -287,7 +298,7 @@ class FreshRSS_Entry extends Minz_Model { 'id' => $this->id(), 'guid' => $this->guid(), 'title' => $this->title(), - 'author' => $this->author(), + 'author' => $this->authors(true), 'content' => $this->content(), 'link' => $this->link(), 'date' => $this->date(true), |
