TYPO3 CMS  TYPO3_8-7
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 
39 {
43  protected $tagName = 'a';
44 
48  public function initializeArguments()
49  {
50  parent::initializeArguments();
51  $this->registerArgument('email', 'string', 'The email address to be turned into a link', true);
53  $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
54  $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
55  $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
56  $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
57  }
58 
62  public function render()
63  {
64  $email = $this->arguments['email'];
65 
66  if ($this->isFrontendAvailable()) {
67  list($linkHref, $linkText) = $GLOBALS['TSFE']->cObj->getMailTo($email, '');
68  $escapeSpecialCharacters = !isset($GLOBALS['TSFE']->spamProtectEmailAddresses) || $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii';
69  } else {
70  $linkHref = 'mailto:' . $email;
71  $linkText = htmlspecialchars($email);
72  $escapeSpecialCharacters = true;
73  }
74  $tagContent = $this->renderChildren();
75  if ($tagContent !== null) {
76  $linkText = $tagContent;
77  }
78  $this->tag->setContent($linkText);
79  $this->tag->addAttribute('href', $linkHref, $escapeSpecialCharacters);
80  $this->tag->forceClosingTag(true);
81  return $this->tag->render();
82  }
83 
87  protected function isFrontendAvailable()
88  {
89  return TYPO3_MODE === 'FE';
90  }
91 }
registerTagAttribute($name, $type, $description, $required=false, $default=null)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']