‪TYPO3CMS  10.4
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 
18 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
19 
55 class ‪EmailViewHelper extends AbstractTagBasedViewHelper
56 {
60  protected ‪$tagName = 'a';
61 
65  public function ‪initializeArguments()
66  {
67  parent::initializeArguments();
68  $this->registerArgument('email', 'string', 'The email address to be turned into a link', true);
69  $this->registerUniversalTagAttributes();
70  $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
71  $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
72  $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
73  $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
74  }
75 
79  public function ‪render()
80  {
81  $email = $this->arguments['email'];
82 
83  if ($this->‪isFrontendAvailable()) {
84  [$linkHref, $linkText] = ‪$GLOBALS['TSFE']->cObj->getMailTo($email, '');
85  $escapeSpecialCharacters = !isset(‪$GLOBALS['TSFE']->spamProtectEmailAddresses) || ‪$GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii';
86  } else {
87  $linkHref = 'mailto:' . $email;
88  $linkText = htmlspecialchars($email);
89  $escapeSpecialCharacters = true;
90  }
91  $tagContent = $this->renderChildren();
92  if ($tagContent !== null) {
93  $linkText = $tagContent;
94  }
95  $this->tag->setContent($linkText);
96  $this->tag->addAttribute('href', $linkHref, $escapeSpecialCharacters);
97  $this->tag->forceClosingTag(true);
98  return $this->tag->render();
99  }
100 
104  protected function ‪isFrontendAvailable()
105  {
106  return TYPO3_MODE === 'FE';
107  }
108 }
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5