-
Notifications
You must be signed in to change notification settings - Fork 0
/
tomba.php
72 lines (61 loc) · 2.03 KB
/
tomba.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* @license GNU General Public License version 2
*/
defined('_JEXEC') or die;
/**
* Tomba Plugin.
*/
class plgContentTomba extends JPlugin
{
/**
* Constructor.
*
* @param object &$subject The object to observe
* @param array $config An optional associative array of configuration settings.
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
}
/**
* Displays the disposable email blocker when viewing an content is displayed before the content.
*
* @see https://docs.joomla.org/Plugin/Events/Content#onContentBeforeDisplay
* @return string HTML string containing code for the disposable email blocker.
*/
public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
{
return $this->Tomba();
}
/**
* Displays the disposable email blocker when viewing an content is displayed after the content.
*
* @see https://docs.joomla.org/Plugin/Events/Content#onContentAfterDisplay
* @return string HTML string containing code for the disposable email blocker.
*/
public function onContentAfterDisplay($context, &$row, &$params, $page = 0)
{
return $this->Tomba();
}
public function onContentPrepareForm($form, $data)
{
return $this->Tomba();
}
/**
* Displays the disposable email blocker.
*
* @return string HTML string containing code for the disposable email blocker.
*/
private function Tomba()
{
JFactory::getDocument()->addScript('https://cdn.jsdelivr.net/npm/disposable-email-blocker/disposable-email-blocker.min.js');
$message_disposable = $this->params->get('message_disposable');
$webmail_message = $this->params->get('webmail_message');
$webmail_block = $this->params->get('webmail_block');
JFactory::getDocument()->addScriptDeclaration('
const defaults = { disposable: { message: "' . $message_disposable . '", }, webmail: { message: "' . $webmail_message . '", block: "' . $webmail_block . '", }};
new Disposable.Blocker(defaults);
');
}
}