‪TYPO3CMS  9.5
EmailViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
18 
54 class ‪EmailViewHelper extends AbstractTagBasedViewHelper
55 {
59  protected ‪$tagName = 'a';
60 
64  public function ‪initializeArguments()
65  {
66  parent::initializeArguments();
67  $this->registerArgument('email', 'string', 'The email address to be turned into a link', true);
68  $this->registerUniversalTagAttributes();
69  $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
70  $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
71  $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
72  $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
73  }
74 
78  public function ‪render()
79  {
80  $email = $this->arguments['email'];
81 
82  if ($this->‪isFrontendAvailable()) {
83  list($linkHref, $linkText) = ‪$GLOBALS['TSFE']->cObj->getMailTo($email, '');
84  $escapeSpecialCharacters = !isset(‪$GLOBALS['TSFE']->spamProtectEmailAddresses) || ‪$GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii';
85  } else {
86  $linkHref = 'mailto:' . $email;
87  $linkText = htmlspecialchars($email);
88  $escapeSpecialCharacters = true;
89  }
90  $tagContent = $this->renderChildren();
91  if ($tagContent !== null) {
92  $linkText = $tagContent;
93  }
94  $this->tag->setContent($linkText);
95  $this->tag->addAttribute('href', $linkHref, $escapeSpecialCharacters);
96  $this->tag->forceClosingTag(true);
97  return $this->tag->render();
98  }
99 
103  protected function ‪isFrontendAvailable()
104  {
105  return TYPO3_MODE === 'FE';
106  }
107 }
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5