TYPO3 CMS  TYPO3_7-6
UrlLinkHandler.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 attribute
47  unset($this->linkAttributes[array_search('params', $this->linkAttributes, true)]);
48  }
49 
59  public function canHandleLink(array $linkParts)
60  {
61  if (!$linkParts['url']) {
62  return false;
63  }
64  if (strpos($linkParts['url'], '://') === false) {
65  $linkParts['url'] = 'http://' . $linkParts['url'];
66  }
67  $this->linkParts = $linkParts;
68 
69  return true;
70  }
71 
77  public function formatCurrentUrl()
78  {
79  return $this->linkParts['url'];
80  }
81 
89  public function render(ServerRequestInterface $request)
90  {
91  GeneralUtility::makeInstance(PageRenderer::class)->loadRequireJsModule('TYPO3/CMS/Recordlist/UrlLinkHandler');
92 
93  $extUrl = '
94  <!--
95  Enter External URL:
96  -->
97  <form action="" id="lurlform">
98  <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkURL">
99  <tr>
100  <td style="width: 96px;">URL:</td>
101  <td>
102  <input type="text" name="lurl" size="30" value="'
103  . htmlspecialchars(!empty($this->linkParts) ? $this->linkParts['url'] : 'http://')
104  . '" /> '
105  . '<input class="btn btn-default" type="submit" value="' . $this->getLanguageService()->getLL('setLink', true) . '" />
106  </td>
107  </tr>
108  </table>
109  </form>';
110  return $extUrl;
111  }
112 
116  public function getBodyTagAttributes()
117  {
118  return [];
119  }
120 }