File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
components/com_finder/src/View/Search
plugins/content/emailcloak/src/Extension Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -208,8 +208,9 @@ public function display($tpl = null)
208208 if (\is_array ($ this ->results )) {
209209 $ dispatcher = $ this ->getDispatcher ();
210210
211- // Import Finder plugins
211+ // Import Content and Finder plugins
212212 PluginHelper::importPlugin ('finder ' , null , true , $ dispatcher );
213+ PluginHelper::importPlugin ('content ' , null , true , $ dispatcher );
213214
214215 foreach ($ this ->results as $ result ) {
215216 $ dispatcher ->dispatch ('onFinderResult ' , new ResultEvent ('onFinderResult ' , [
Original file line number Diff line number Diff line change 1111namespace Joomla \Plugin \Content \EmailCloak \Extension ;
1212
1313use Joomla \CMS \Event \Content \ContentPrepareEvent ;
14+ use Joomla \CMS \Event \Finder \ResultEvent ;
1415use Joomla \CMS \HTML \HTMLHelper ;
1516use Joomla \CMS \Plugin \CMSPlugin ;
1617use Joomla \Event \SubscriberInterface ;
@@ -36,7 +37,33 @@ final class EmailCloak extends CMSPlugin implements SubscriberInterface
3637 */
3738 public static function getSubscribedEvents (): array
3839 {
39- return ['onContentPrepare ' => 'onContentPrepare ' ];
40+ return [
41+ 'onContentPrepare ' => 'onContentPrepare ' ,
42+ 'onFinderResult ' => 'onFinderResult ' ,
43+ ];
44+ }
45+
46+ /**
47+ * Plugin that cloaks all emails in com_finder from spambots via Javascript.
48+ *
49+ * @param ResultEvent $event Event instance
50+ *
51+ * @return void
52+ */
53+ public function onFinderResult (ResultEvent $ event )
54+ {
55+ $ item = $ event ->getItem ();
56+
57+ // If the item does not have a text property there is nothing to do
58+ if (!isset ($ item ->description )) {
59+ return ;
60+ }
61+
62+ $ text = $ this ->cloak ($ item ->description );
63+
64+ if ($ text ) {
65+ $ item ->description = $ text ;
66+ }
4067 }
4168
4269 /**
You can’t perform that action at this time.
0 commit comments