aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Entry.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-09-16 10:46:27 +0200
committerGravatar GitHub <noreply@github.com> 2018-09-16 10:46:27 +0200
commitb323ed084620cac2222fe1c93ec05b9773eb81e6 (patch)
treeec1057810fd3a1971f99d1ebb60b936e0c543094 /app/Models/Entry.php
parent9fa2122d4a27de7d9a207cea3dee911541b63420 (diff)
Improve authors (#2025)
* Links for authors and multiple authors Favour ';' as a separator instead of ',' to better cope with multi-author scientific articles. Follow-up of https://github.com/FreshRSS/FreshRSS/pull/1997 , https://github.com/FreshRSS/FreshRSS/issues/1968, https://github.com/FreshRSS/FreshRSS/pull/2023 * Change i18n authors * Update layout * Unicode-compatible search Example for `author:Loïc` * author <em> styling * Final details * Minor spacing
Diffstat (limited to 'app/Models/Entry.php')
-rw-r--r--app/Models/Entry.php34
1 files changed, 22 insertions, 12 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php
index 48a0b1bed..09c5d8bcf 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,17 +21,16 @@ 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($tags);
$this->_guid($guid);
}
@@ -45,8 +44,12 @@ class FreshRSS_Entry extends Minz_Model {
public function title() {
return $this->title;
}
- public function author() {
- return $this->author === null ? '' : $this->author;
+ public function authors($asString = false) {
+ if ($asString) {
+ return $this->authors == null ? '' : ';' . implode('; ', $this->authors);
+ } else {
+ return $this->authors;
+ }
}
public function content() {
return $this->content;
@@ -88,7 +91,7 @@ class FreshRSS_Entry extends Minz_Model {
}
public function tags($asString = false) {
if ($asString) {
- return $this->tags == '' ? '' : '#' . implode(' #', $this->tags);
+ return $this->tags == null ? '' : '#' . implode(' #', $this->tags);
} else {
return $this->tags;
}
@@ -97,7 +100,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 +127,18 @@ 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) {
+ 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;
@@ -280,7 +290,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),