diff --git a/components/com_finder/src/View/Search/HtmlView.php b/components/com_finder/src/View/Search/HtmlView.php index dc9399be3dcee..9178f9deffa21 100644 --- a/components/com_finder/src/View/Search/HtmlView.php +++ b/components/com_finder/src/View/Search/HtmlView.php @@ -208,8 +208,9 @@ public function display($tpl = null) if (\is_array($this->results)) { $dispatcher = $this->getDispatcher(); - // Import Finder plugins + // Import Content and Finder plugins PluginHelper::importPlugin('finder', null, true, $dispatcher); + PluginHelper::importPlugin('content', null, true, $dispatcher); foreach ($this->results as $result) { $dispatcher->dispatch('onFinderResult', new ResultEvent('onFinderResult', [ diff --git a/plugins/content/emailcloak/src/Extension/EmailCloak.php b/plugins/content/emailcloak/src/Extension/EmailCloak.php index 3a4260e6f1257..67f8bc8b78644 100644 --- a/plugins/content/emailcloak/src/Extension/EmailCloak.php +++ b/plugins/content/emailcloak/src/Extension/EmailCloak.php @@ -11,6 +11,7 @@ namespace Joomla\Plugin\Content\EmailCloak\Extension; use Joomla\CMS\Event\Content\ContentPrepareEvent; +use Joomla\CMS\Event\Finder\ResultEvent; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\Event\SubscriberInterface; @@ -36,7 +37,33 @@ final class EmailCloak extends CMSPlugin implements SubscriberInterface */ public static function getSubscribedEvents(): array { - return ['onContentPrepare' => 'onContentPrepare']; + return [ + 'onContentPrepare' => 'onContentPrepare', + 'onFinderResult' => 'onFinderResult', + ]; + } + + /** + * Plugin that cloaks all emails in com_finder from spambots via Javascript. + * + * @param ResultEvent $event Event instance + * + * @return void + */ + public function onFinderResult(ResultEvent $event) + { + $item = $event->getItem(); + + // If the item does not have a text property there is nothing to do + if (!isset($item->description)) { + return; + } + + $text = $this->cloak($item->description); + + if ($text) { + $item->description = $text; + } } /**