aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Entry.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-09-15 13:06:29 +0200
committerGravatar GitHub <noreply@github.com> 2018-09-15 13:06:29 +0200
commitaf27b6d300723883f1110eee103eb892ddf1056d (patch)
tree2bf68be80d624723dedc78262105546f0bc0088d /app/Models/Entry.php
parent60cc39db25de4f70c9a78930f5901d49b081c1f5 (diff)
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
Diffstat (limited to 'app/Models/Entry.php')
-rw-r--r--app/Models/Entry.php17
1 files changed, 5 insertions, 12 deletions
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;
}