From 039ad7e7c5cb66017430c1885dfc1201f7b3223e Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 6 May 2017 15:25:59 +0200 Subject: * Emoji-replacing filter --- providers/Provider.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'providers') diff --git a/providers/Provider.php b/providers/Provider.php index 2e14d2b..bf85f12 100644 --- a/providers/Provider.php +++ b/providers/Provider.php @@ -41,12 +41,29 @@ abstract class Provider { } } + protected function _filterItemContent($items) { + if (in_array('noemoji', $this->_options)) { + $dictionary = json_decode(file_get_contents('../config/emoji.json'), TRUE); + $filtered = []; + foreach ($items as $item) { + foreach (['Title', 'Text'] as $field) { + $item->{$field} = strtr($item->{$field}, $dictionary); + } + } + } + return $items; + } + public function get() { $items = $this->_getItems(); if (isset($this->_options['spamfilter'])) { $items = $this->_spamFilter($items); } - return $this->_sortContent($this->_mapItems($items)); + return $this->_sortContent( + $this->_filterItemContent( + $this->_mapItems($items) + ) + ); } public function cacheTime() { -- cgit v1.2.3