diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-22 16:21:03 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-11-05 17:54:42 +0100 |
commit | b3bd8c3e8d367975980043e772f7cd78b7f96bc6 (patch) | |
tree | ec79899ea564c093d8b0578f3e614881a4ea7c3d /application/formatter | |
parent | 48df9f45b8c4b2995c1e04146071628668531b37 (diff) | |
download | Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.tar.gz Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.tar.zst Shaarli-b3bd8c3e8d367975980043e772f7cd78b7f96bc6.zip |
Feature: support any tag separator
So it allows to have multiple words tags.
Breaking change: commas ',' are no longer a default separator.
Fixes #594
Diffstat (limited to 'application/formatter')
-rw-r--r-- | application/formatter/BookmarkDefaultFormatter.php | 7 | ||||
-rw-r--r-- | application/formatter/BookmarkFormatter.php | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/application/formatter/BookmarkDefaultFormatter.php b/application/formatter/BookmarkDefaultFormatter.php index 149a3eb9..51bea0f1 100644 --- a/application/formatter/BookmarkDefaultFormatter.php +++ b/application/formatter/BookmarkDefaultFormatter.php | |||
@@ -68,15 +68,16 @@ class BookmarkDefaultFormatter extends BookmarkFormatter | |||
68 | */ | 68 | */ |
69 | protected function formatTagListHtml($bookmark) | 69 | protected function formatTagListHtml($bookmark) |
70 | { | 70 | { |
71 | $tagsSeparator = $this->conf->get('general.tags_separator', ' '); | ||
71 | if (empty($bookmark->getAdditionalContentEntry('search_highlight')['tags'])) { | 72 | if (empty($bookmark->getAdditionalContentEntry('search_highlight')['tags'])) { |
72 | return $this->formatTagList($bookmark); | 73 | return $this->formatTagList($bookmark); |
73 | } | 74 | } |
74 | 75 | ||
75 | $tags = $this->tokenizeSearchHighlightField( | 76 | $tags = $this->tokenizeSearchHighlightField( |
76 | $bookmark->getTagsString(), | 77 | $bookmark->getTagsString($tagsSeparator), |
77 | $bookmark->getAdditionalContentEntry('search_highlight')['tags'] | 78 | $bookmark->getAdditionalContentEntry('search_highlight')['tags'] |
78 | ); | 79 | ); |
79 | $tags = $this->filterTagList(explode(' ', $tags)); | 80 | $tags = $this->filterTagList(tags_str2array($tags, $tagsSeparator)); |
80 | $tags = escape($tags); | 81 | $tags = escape($tags); |
81 | $tags = $this->replaceTokensArray($tags); | 82 | $tags = $this->replaceTokensArray($tags); |
82 | 83 | ||
@@ -88,7 +89,7 @@ class BookmarkDefaultFormatter extends BookmarkFormatter | |||
88 | */ | 89 | */ |
89 | protected function formatTagString($bookmark) | 90 | protected function formatTagString($bookmark) |
90 | { | 91 | { |
91 | return implode(' ', $this->formatTagList($bookmark)); | 92 | return implode($this->conf->get('general.tags_separator'), $this->formatTagList($bookmark)); |
92 | } | 93 | } |
93 | 94 | ||
94 | /** | 95 | /** |
diff --git a/application/formatter/BookmarkFormatter.php b/application/formatter/BookmarkFormatter.php index e1b7f705..124ce78b 100644 --- a/application/formatter/BookmarkFormatter.php +++ b/application/formatter/BookmarkFormatter.php | |||
@@ -267,7 +267,7 @@ abstract class BookmarkFormatter | |||
267 | */ | 267 | */ |
268 | protected function formatTagString($bookmark) | 268 | protected function formatTagString($bookmark) |
269 | { | 269 | { |
270 | return implode(' ', $this->formatTagList($bookmark)); | 270 | return implode($this->conf->get('general.tags_separator', ' '), $this->formatTagList($bookmark)); |
271 | } | 271 | } |
272 | 272 | ||
273 | /** | 273 | /** |
@@ -351,6 +351,7 @@ abstract class BookmarkFormatter | |||
351 | 351 | ||
352 | /** | 352 | /** |
353 | * Format tag list, e.g. remove private tags if the user is not logged in. | 353 | * Format tag list, e.g. remove private tags if the user is not logged in. |
354 | * TODO: this method is called multiple time to format tags, the result should be cached. | ||
354 | * | 355 | * |
355 | * @param array $tags | 356 | * @param array $tags |
356 | * | 357 | * |