TYPO3  7.6
Link/EmailViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Link;
3 
4 /* *
5  * This script is part of the TYPO3 project - inspiring people to share! *
6  * *
7  * TYPO3 is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU General Public License version 2 as published by *
9  * the Free Software Foundation. *
10  * *
11  * This script is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
14  * Public License for more details. *
15  * */
38 {
42  protected $tagName = 'a';
43 
49  public function initializeArguments()
50  {
52  $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
53  $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
54  $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
55  $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
56  }
57 
62  public function render($email)
63  {
64  if (TYPO3_MODE === 'FE') {
65  list($linkHref, $linkText) = $GLOBALS['TSFE']->cObj->getMailTo($email, $email);
66  } else {
67  $linkHref = 'mailto:' . $email;
68  $linkText = $email;
69  }
70  $tagContent = $this->renderChildren();
71  if ($tagContent !== null) {
72  $linkText = $tagContent;
73  }
74  $this->tag->setContent($linkText);
75  $escapeSpecialCharacters = !isset($GLOBALS['TSFE']->spamProtectEmailAddresses) || $GLOBALS['TSFE']->spamProtectEmailAddresses !== 'ascii';
76  $this->tag->addAttribute('href', $linkHref, $escapeSpecialCharacters);
77  $this->tag->forceClosingTag(true);
78  return $this->tag->render();
79  }
80 }