2 declare(strict_types = 1);
18 use Psr\Http\Message\ServerRequestInterface;
39 'renderLinkAttributeFields' =>
'Using BrowseLinksController::renderLinkAttributeFields() is deprecated and will not be possible anymore in TYPO3 v10.0.',
40 'getPageConfigLabel' =>
'Using BrowseLinksController::getPageConfigLabel() is deprecated and will not be possible anymore in TYPO3 v10.0.',
41 'getDisplayedLinkHandlerId' =>
'Using BrowseLinksController::getDisplayedLinkHandlerId() is deprecated and will not be possible anymore in TYPO3 v10.0.',
116 protected function init()
120 $this->contentLanguageService = GeneralUtility::makeInstance(LanguageService::class);
126 protected function initVariables(ServerRequestInterface $request)
128 parent::initVariables($request);
130 $queryParameters = $request->getQueryParams();
132 $this->siteUrl = GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL');
134 $this->currentLinkParts = $queryParameters[
'P'][
'curUrl'] ?? [];
135 $this->editorId = $queryParameters[
'editorId'];
136 $this->contentsLanguage = $queryParameters[
'contentsLanguage'];
137 $this->RTEtsConfigParams = $queryParameters[
'RTEtsConfigParams'] ??
null;
139 $this->contentLanguageService->init($this->contentsLanguage);
141 $tcaFieldConf = [
'enableRichtext' =>
true];
142 if (!empty($queryParameters[
'P'][
'richtextConfigurationName'])) {
143 $tcaFieldConf[
'richtextConfiguration'] = $queryParameters[
'P'][
'richtextConfigurationName'];
147 $richtextConfigurationProvider = GeneralUtility::makeInstance(Richtext::class);
148 $this->thisConfig = $richtextConfigurationProvider->getConfiguration(
149 $this->parameters[
'table'],
150 $this->parameters[
'fieldName'],
151 (
int)$this->parameters[
'pid'],
152 $this->parameters[
'recordType'],
155 $this->buttonConfig = $this->thisConfig[
'buttons'][
'link'] ?? [];
163 parent::initDocumentTemplate();
165 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
166 $pageRenderer->loadRequireJsModule(
167 'TYPO3/CMS/RteCkeditor/RteLinkBrowser',
168 'function(RteLinkBrowser) {
169 RteLinkBrowser.initialize(' . GeneralUtility::quoteJSvalue($this->editorId) .
');
179 if (empty($this->currentLinkParts)) {
183 if (!empty($this->currentLinkParts[
'url'])) {
184 $linkService = GeneralUtility::makeInstance(LinkService::class);
185 $data = $linkService->resolve($this->currentLinkParts[
'url']);
186 $this->currentLinkParts[
'type'] = $data[
'type'];
187 unset($data[
'type']);
188 $this->currentLinkParts[
'url'] = $data;
189 if (!empty($this->currentLinkParts[
'url'][
'parameters'])) {
190 $this->currentLinkParts[
'params'] =
'&' . $this->currentLinkParts[
'url'][
'parameters'];
194 parent::initCurrentUrl();
205 if (!empty($this->buttonConfig[
'properties'][
'class'][
'allowedClasses'])) {
206 $classesAnchorArray = is_array($this->buttonConfig[
'properties'][
'class'][
'allowedClasses']) ? $this->buttonConfig[
'properties'][
'class'][
'allowedClasses'] : GeneralUtility::trimExplode(
',', $this->buttonConfig[
'properties'][
'class'][
'allowedClasses'],
true);
212 if (is_array($this->thisConfig[
'classesAnchor'])) {
214 foreach ($this->thisConfig[
'classesAnchor'] as $label => $conf) {
215 if (in_array($conf[
'class'], $classesAnchorArray,
true)) {
216 $classesAnchor[
'all'][] = $conf[
'class'];
217 if ($conf[
'type'] === $this->displayedLinkHandlerId) {
218 $classesAnchor[$conf[
'type']][] = $conf[
'class'];
219 if ($this->buttonConfig[$conf[
'type']][
'properties'][
'class'][
'default'] == $conf[
'class']) {
220 $this->classesAnchorDefault[$conf[
'type']] = $conf[
'class'];
221 if ($conf[
'titleText']) {
222 $this->classesAnchorDefaultTitle[$conf[
'type']] = $this->contentLanguageService->sL(trim($conf[
'titleText']));
224 if (isset($conf[
'target'])) {
225 $this->classesAnchorDefaultTarget[$conf[
'type']] = trim($conf[
'target']);
229 if ($readOnlyTitle && $conf[
'titleText']) {
230 $this->classesAnchorClassTitle[$conf[
'class']] = ($this->classesAnchorDefaultTitle[$conf[
'type']] = $this->contentLanguageService->sL(trim($conf[
'titleText'])));
235 if (isset($this->linkAttributeValues[
'class'])
236 && isset($classesAnchor[$this->displayedLinkHandlerId])
237 && !in_array($this->linkAttributeValues[
'class'], $classesAnchor[$this->displayedLinkHandlerId],
true)
239 unset($this->linkAttributeValues[
'class']);
242 foreach ($classesAnchorArray as $class) {
243 if (!in_array($class, $classesAnchor[
'all']) || in_array($class, $classesAnchor[
'all']) && is_array($classesAnchor[$this->displayedLinkHandlerId]) && in_array($class, $classesAnchor[$this->displayedLinkHandlerId])) {
245 if ($this->linkAttributeValues[
'class'] === $class || !$this->linkAttributeValues[
'class'] && $this->classesAnchorDefault[$this->displayedLinkHandlerId] == $class) {
246 $selected =
'selected="selected"';
248 $classLabel = !empty($this->thisConfig[
'classes'][$class][
'name'])
251 $classStyle = !empty($this->thisConfig[
'classes'][$class][
'value'])
252 ? $this->thisConfig[
'classes'][$class][
'value']
254 $title = $this->classesAnchorClassTitle[$class] ?? $this->classesAnchorDefaultTitle[$class] ??
'';
256 . ($classStyle ?
' style="' . htmlspecialchars($classStyle) .
'"' :
'')
257 .
'data-link-title="' . htmlspecialchars($title) .
'"'
258 .
'>' . htmlspecialchars($classLabel)
262 if ($this->classesAnchorJSOptions[$this->displayedLinkHandlerId] && !($this->buttonConfig[
'properties'][
'class'][
'required'] || $this->buttonConfig[$this->displayedLinkHandlerId][
'properties'][
'class'][
'required'])) {
264 if (!$this->linkAttributeValues[
'class'] && !$this->classesAnchorDefault[$this->displayedLinkHandlerId]) {
265 $selected =
'selected="selected"';
273 : ($this->buttonConfig[
$this->displayedLinkHandlerId][
'properties'][
'target'][
'default'] ?? $this->buttonConfig[
'properties'][
'target'][
'default'] ??
'');
277 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'rte_ckeditor'][
'plugins'][
'TYPO3Link'][
'additionalAttributes']) {
278 $addAttributes = GeneralUtility::trimExplode(
',',
$GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'rte_ckeditor'][
'plugins'][
'TYPO3Link'][
'additionalAttributes'],
true);
279 foreach ($addAttributes as $attribute) {
280 $this->additionalAttributes[$attribute] = $this->linkAttributeValues[$attribute] ??
'';
283 return parent::renderLinkAttributeFields();
295 if (strpos($string,
'LLL:') !== 0) {
300 $label = str_replace([
'\\\'',
'"'], [
'\'',
'\\"'], $label);
301 return $JScharCode ? GeneralUtility::quoteJSvalue($label) : $label;
309 $removeLink =
' <a href="#" class="t3js-removeCurrentLink">' . htmlspecialchars($this->
getLanguageService()->getLL(
'removeLink')) .
'</a>';
311 <div class="element-browser-panel element-browser-title">' .
314 htmlspecialchars($this->currentLinkHandler->formatCurrentUrl()) .
315 '<span class="pull-right">' . $removeLink .
'</span>' .
326 $allowedItems = parent::getAllowedItems();
328 $blindLinkOptions = isset($this->thisConfig[
'blindLinkOptions'])
329 ? GeneralUtility::trimExplode(
',', $this->thisConfig[
'blindLinkOptions'],
true)
331 $allowedItems = array_diff($allowedItems, $blindLinkOptions);
333 if (is_array($this->buttonConfig[
'options']) && $this->buttonConfig[
'options'][
'removeItems']) {
334 $allowedItems = array_diff($allowedItems, GeneralUtility::trimExplode(
',', $this->buttonConfig[
'options'][
'removeItems'],
true));
337 return $allowedItems;
347 $allowedLinkAttributes = parent::getAllowedLinkAttributes();
349 $blindLinkFields = isset($this->thisConfig[
'blindLinkFields'])
350 ? GeneralUtility::trimExplode(
',', $this->thisConfig[
'blindLinkFields'],
true)
352 $allowedLinkAttributes = array_diff($allowedLinkAttributes, $blindLinkFields);
354 return $allowedLinkAttributes;
364 $fieldRenderingDefinitions = parent::getLinkAttributeFieldDefinitions();
368 $fieldRenderingDefinitions[
'rel'] = $this->
getRelField();
369 if (empty($this->buttonConfig[
'queryParametersSelector'][
'enabled'])) {
370 unset($fieldRenderingDefinitions[
'params']);
372 return $fieldRenderingDefinitions;
382 if (empty($this->buttonConfig[
'relAttribute'][
'enabled'])) {
387 if ($this->displayedLinkHandler === $this->currentLinkHandler
388 && !empty($this->currentLinkParts)
389 && isset($this->linkAttributeValues[
'rel'])
390 && is_string($this->linkAttributeValues[
'rel'])
392 $currentRel = $this->linkAttributeValues[
'rel'];
396 <form action="" name="lrelform" id="lrelform" class="t3js-dummyform form-horizontal">
397 <div class="form-group form-group-sm">
398 <label class="col-xs-4 control-label">' .
401 <div class="col-xs-8">
402 <input type="text" name="lrel" class="form-control" value="' . htmlspecialchars($currentRel) .
'" />
416 $targetSelectorConfig = [];
417 if (is_array($this->buttonConfig[
'targetSelector'])) {
418 $targetSelectorConfig = $this->buttonConfig[
'targetSelector'];
422 $targetSelector =
'';
424 if (!$targetSelectorConfig[
'disabled']) {
426 <select name="ltarget_type" class="t3js-targetPreselect form-control">
427 <option value=""></option>
428 <option value="_top">' . htmlspecialchars($lang->getLL(
'top')) .
'</option>
429 <option value="_blank">' . htmlspecialchars($lang->getLL(
'newWindow')) .
'</option>
435 <form action="" name="ltargetform" id="ltargetform" class="t3js-dummyform form-horizontal">
436 <div class="form-group form-group-sm" ' . ($targetSelectorConfig[
'disabled'] ?
' style="display: none;"' :
'') .
'>
437 <label class="col-xs-4 control-label">' . htmlspecialchars($lang->getLL(
'target')) .
'</label>
438 <div class="col-xs-4">
439 <input type="text" name="ltarget" class="t3js-linkTarget form-control"
440 value="' . htmlspecialchars($target) .
'" />
442 <div class="col-xs-4">
443 ' . $targetSelector .
'
457 if ($this->linkAttributeValues[
'title']) {
458 $title = $this->linkAttributeValues[
'title'];
464 if ($readOnlyTitle) {
465 $currentClass = $this->linkAttributeFields[
'class'];
466 if (!$currentClass) {
467 $currentClass = empty($this->classesAnchorDefault[$this->displayedLinkHandlerId]) ?
'' : $this->classesAnchorDefault[
$this->displayedLinkHandlerId];
472 <form action="" name="ltitleform" id="ltitleform" class="t3js-dummyform form-horizontal">
473 <div class="form-group form-group-sm">
474 <label class="col-xs-4 control-label">
477 <div class="col-xs-8">
478 <input ' . ($readOnlyTitle ?
'disabled' :
'') .
' type="text" name="ltitle" class="form-control t3js-linkTitle"
479 value="' . htmlspecialchars($title) .
'" />
494 if ($this->classesAnchorJSOptions[$this->displayedLinkHandlerId]) {
496 <form action="" name="lclassform" id="lclassform" class="t3js-dummyform form-horizontal">
497 <div class="form-group form-group-sm">
498 <label class="col-xs-4 control-label">
501 <div class="col-xs-8">
502 <select name="lclass" class="t3js-class-selector form-control">
520 return (
int)$this->parameters[
'pid'];
565 if (isset($this->buttonConfig[$this->displayedLinkHandlerId][
'properties'][
'title'][
'readOnly'])) {
569 return (
bool)($this->buttonConfig[
'properties'][
'title'][
'readOnly'] ??
false);