From ab376c50ed3b536693b938ecf4fc191e4368fb2f Mon Sep 17 00:00:00 2001 From: Paavo Date: Wed, 31 May 2023 16:15:06 +0200 Subject: [PATCH 1/4] Create EEL Helpers to provide MailObfuscator functions in Fusion --- Classes/Eel/MailObfuscator.php | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Classes/Eel/MailObfuscator.php diff --git a/Classes/Eel/MailObfuscator.php b/Classes/Eel/MailObfuscator.php new file mode 100644 index 0000000..c05e3eb --- /dev/null +++ b/Classes/Eel/MailObfuscator.php @@ -0,0 +1,43 @@ +convert($email); + } + + /** + * Convert Mailto to Href + * + * @param $email string + * @return string + */ + public function convertMailto2Href($email = false) { + return (new Mailto2HrefObfuscatingConverter())->convert($email); + } + + /** + * All methods are considered safe + * + * @param string $methodName + * @return boolean + */ + public function allowsCallOfMethod($methodName) { + return true; + } +} From b3e6e6e8ec72175d5be584c7ca11be53ceb50aa8 Mon Sep 17 00:00:00 2001 From: Paavo Date: Wed, 31 May 2023 16:16:34 +0200 Subject: [PATCH 2/4] feat: Register EEL Helpers --- Configuration/Settings.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Configuration/Settings.yaml b/Configuration/Settings.yaml index 305accb..1ee6738 100644 --- a/Configuration/Settings.yaml +++ b/Configuration/Settings.yaml @@ -17,6 +17,10 @@ Neos: autoInclude: 'Networkteam.Neos.MailObfuscator': true + Fusion: + defaultContext: + Networkteam.Neos.MailObfuscator: 'Networkteam\Neos\MailObfuscator\Eel\MailObfuscator' + Networkteam: Neos: MailObfuscator: From 0b23a19a3179213028b6735dc0bc714ae002a6ff Mon Sep 17 00:00:00 2001 From: Paavo Date: Wed, 31 May 2023 16:21:58 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index faee837..2e4e1fa 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,23 @@ Networkteam: atCharReplacementString: 'at' ``` +## EEL Helpers +There are Eel helpers available to use MailObfuscator functions in Fusion + +``` +// Convert @ Character +${Networkteam.Neos.MailObfuscator.convertAtChar('foo@example.com')} +// returns: foo (at) example.com + +``` + +``` +// Convert Mail to Href +${Networkteam.Neos.MailObfuscator.convertMailto2Href('foo@example.com')} +// returns javascript:linkTo_UnCryptMailto('obfuscatedEmail', -randomNumber) +``` + + ## Acknowledgments Original email address obfuscation code by [TYPO3 CMS](http://www.typo3.org). From 567f1fb30e82916c1537b7533c3e7bc12ae213dd Mon Sep 17 00:00:00 2001 From: Paavo Schmid Date: Thu, 1 Jun 2023 13:29:04 +0200 Subject: [PATCH 4/4] feat: Updated PR with improvements --- Classes/Eel/MailObfuscator.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Classes/Eel/MailObfuscator.php b/Classes/Eel/MailObfuscator.php index c05e3eb..e5cf262 100644 --- a/Classes/Eel/MailObfuscator.php +++ b/Classes/Eel/MailObfuscator.php @@ -2,14 +2,27 @@ namespace Networkteam\Neos\MailObfuscator\Eel; +use Neos\Flow\Annotations as Flow; use Neos\Eel\ProtectedContextAwareInterface; -use Networkteam\Neos\MailObfuscator\Converter\Mailto2HrefObfuscatingConverter; -use Networkteam\Neos\MailObfuscator\Converter\RewriteAtCharConverter; +use Networkteam\Neos\MailObfuscator\Converter\EmailLinkNameConverterInterface; +use Networkteam\Neos\MailObfuscator\Converter\MailtoLinkConverterInterface; /** * Eel helpers to provide MailObfuscator functions */ -class MailObfuscator extends RewriteAtCharConverter implements ProtectedContextAwareInterface { +class MailObfuscator implements ProtectedContextAwareInterface { + + /** + * @var EmailLinkNameConverterInterface + * @Flow\Inject + */ + protected $emailLinkNameConverter; + + /** + * @var MailtoLinkConverterInterface + * @Flow\Inject + */ + protected $mailtoLinkConverter; /** * Convert at Character @@ -18,7 +31,7 @@ class MailObfuscator extends RewriteAtCharConverter implements ProtectedContextA * @return string */ public function convertAtChar($email = false) { - return $this->convert($email); + return $this->emailLinkNameConverter->convert($email); } /** @@ -28,7 +41,7 @@ public function convertAtChar($email = false) { * @return string */ public function convertMailto2Href($email = false) { - return (new Mailto2HrefObfuscatingConverter())->convert($email); + return $this->mailtoLinkConverter->convert($email); } /**