‪TYPO3CMS  11.5
EmailViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
24 
46 class ‪EmailViewHelper extends AbstractViewHelper
47 {
48  use CompileWithRenderStatic;
49 
53  public function ‪initializeArguments()
54  {
55  $this->registerArgument('email', 'string', 'The email address to be turned into a URI', true);
56  }
57 
65  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
66  {
67  trigger_error('f:uri.email view-helper is deprecated an will be removed in TYPO3 v12.0', E_USER_DEPRECATED);
68 
69  $email = $arguments['email'];
70  if (‪ApplicationType::fromRequest($renderingContext->getRequest())->isFrontend()) {
72  $frontend = ‪$GLOBALS['TSFE'];
73  [$linkHref, $linkText, $attributes] = $frontend->cObj->getMailTo($email, $email);
74  if (isset($attributes['data-mailto-token']) && isset($attributes['data-mailto-vector'])) {
75  $linkHref = sprintf(
76  'javascript:linkTo_UnCryptMailto(%s,%d);',
77  rawurlencode(GeneralUtility::quoteJSvalue($attributes['data-mailto-token'])),
78  -(int)$attributes['data-mailto-vector']
79  );
80  }
81  return $linkHref;
82  }
83  return 'mailto:' . $email;
84  }
85 }
‪TYPO3\CMS\Core\Http\ApplicationType\fromRequest
‪static static fromRequest(ServerRequestInterface $request)
Definition: ApplicationType.php:62
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\EmailViewHelper\initializeArguments
‪initializeArguments()
Definition: EmailViewHelper.php:52
‪TYPO3\CMS\Core\Http\ApplicationType
Definition: ApplicationType.php:52
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\EmailViewHelper
Definition: EmailViewHelper.php:47
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\EmailViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: EmailViewHelper.php:64
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:104
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Fluid\ViewHelpers\Uri
Definition: ActionViewHelper.php:16
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50