TYPO3 CMS  TYPO3_7-6
MailLinkHandler.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 
20 
25 {
31  protected $linkParts = [];
32 
38  protected $updateSupported = false;
39 
43  public function __construct()
44  {
45  parent::__construct();
46  // remove unsupported link attributes
47  foreach (['target', 'rel'] as $attribute) {
48  $position = array_search($attribute, $this->linkAttributes, true);
49  if ($position !== false) {
50  unset($this->linkAttributes[$position]);
51  }
52  }
53  }
54 
64  public function canHandleLink(array $linkParts)
65  {
66  if ($linkParts['url'] && strpos($linkParts['url'], '@')) {
67  $this->linkParts = $linkParts;
68  return true;
69  }
70  return false;
71  }
72 
78  public function formatCurrentUrl()
79  {
80  return $this->linkParts['url'];
81  }
82 
90  public function render(ServerRequestInterface $request)
91  {
92  GeneralUtility::makeInstance(PageRenderer::class)->loadRequireJsModule('TYPO3/CMS/Recordlist/MailLinkHandler');
93 
94  $lang = $this->getLanguageService();
95  $extUrl = '
96  <!--
97  Enter mail address:
98  -->
99  <form action="" id="lmailform">
100  <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkMail">
101  <tr>
102  <td style="width: 96px;">' . $lang->getLL('emailAddress', true) . ':</td>
103  <td>
104  <input type="text" name="lemail" size="20" value="'
105  . htmlspecialchars(!empty($this->linkParts) ? $this->linkParts['url'] : '')
106  . '" />
107  <input class="btn btn-default" type="submit" value="' . $lang->getLL('setLink', true) . '" />
108  </td>
109  </tr>
110  </table>
111  </form>';
112  return $extUrl;
113  }
114 
118  public function getBodyTagAttributes()
119  {
120  return [];
121  }
122 }