From af27b6d300723883f1110eee103eb892ddf1056d Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 15 Sep 2018 13:06:29 +0200 Subject: Tags split improvement (#2023) * Tags split improvement Some feeds use a single category with comma-separated tags. Better handling of tags containing a space * Handle spaces in searches with + Can now search in tags containing spaces * Fix searches with spaces for title and author --- app/Models/Entry.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'app/Models/Entry.php') diff --git a/app/Models/Entry.php b/app/Models/Entry.php index ccbad5724..48a0b1bed 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -32,7 +32,7 @@ class FreshRSS_Entry extends Minz_Model { $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); } @@ -86,9 +86,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 == '' ? '' : '#' . implode(' #', $this->tags); } else { return $this->tags; } @@ -162,15 +162,8 @@ class FreshRSS_Entry extends Minz_Model { public function _tags($value) { $this->hash = null; if (!is_array($value)) { - $value = array($value); + $value = preg_split('/\s*[#,]\s*/', $value, -1, PREG_SPLIT_NO_EMPTY); } - - foreach ($value as $key => $t) { - if (!$t) { - unset($value[$key]); - } - } - $this->tags = $value; } -- cgit v1.2.3