2 namespace TYPO3\CMS\Recordlist\Controller;
142 isset(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'LinkBrowser'][
'hooks'])
143 && is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'LinkBrowser'][
'hooks'])
146 $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'LinkBrowser'][
'hooks']
148 foreach ($hooks as $key => $hook) {
166 $this->loadLinkHandlers();
167 $this->initCurrentUrl();
169 $menuData = $this->buildMenuArray();
171 $browserContent = $this->displayedLinkHandler->render($request);
174 $content = $this->doc->startPage(
'Link Browser');
175 $content .= $this->doc->getFlashMessages();
177 if (!empty($this->currentLinkParts)) {
180 $content .= $this->doc->getTabMenuRaw($menuData);
181 $content .= $renderLinkAttributeFields;
183 $content .=
'<div class="linkBrowser-tabContent">' . $browserContent .
'</div>';
184 $content .= $this->doc->endPage();
186 $response->
getBody()->write($this->doc->insertStylesAndJS($content));
202 $route = $router->match($routePath);
204 $this->thisScript = (string)$uriBuilder->buildUriFromRoute($route->getOption(
'_identifier'));
206 $this->thisScript = BackendUtility::getModuleUrl($moduleName);
218 $act = isset($queryParams[
'act']) ? $queryParams[
'act'] :
'';
220 if (strpos($act,
'|')) {
221 GeneralUtility::deprecationLog(
'Using multiple values for the "act" parameter in the link wizard is deprecated. Only a single value is allowed. Values were: ' . $act);
222 $act = array_shift(explode(
'|', $act));
224 $this->displayedLinkHandlerId = $act;
225 $this->parameters = isset($queryParams[
'P']) ? $queryParams[
'P'] : [];
226 $this->linkAttributeValues = isset($queryParams[
'linkAttributes']) ? $queryParams[
'linkAttributes'] : [];
233 protected function loadLinkHandlers()
237 throw new \UnexpectedValueException(
'No link handlers are configured. Check page TSconfig TCEMAIN.linkHandlers.', 1442787911);
242 $identifier = rtrim($identifier,
'.');
245 $handler->initialize(
248 isset($configuration[
'configuration.']) ? $configuration[
'configuration.'] : []
251 $this->linkHandlers[$identifier] = [
252 'handlerInstance' => $handler,
253 'label' =>
$lang->sL($configuration[
'label'],
true),
254 'displayBefore' => isset($configuration[
'displayBefore']) ?
GeneralUtility::trimExplode(
',', $configuration[
'displayBefore']) : [],
255 'displayAfter' => isset($configuration[
'displayAfter']) ?
GeneralUtility::trimExplode(
',', $configuration[
'displayAfter']) : [],
256 'scanBefore' => isset($configuration[
'scanBefore']) ?
GeneralUtility::trimExplode(
',', $configuration[
'scanBefore']) : [],
257 'scanAfter' => isset($configuration[
'scanAfter']) ?
GeneralUtility::trimExplode(
',', $configuration[
'scanAfter']) : [],
258 'addParams' => isset($configuration[
'addParams']) ? $configuration[
'addParams'] :
'',
271 $pageTSconfig = $this->
getBackendUser()->getTSConfig(
'TCEMAIN.linkHandler.', $pageTSconfig);
274 foreach ($this->hookObjects as $hookObject) {
275 if (method_exists($hookObject,
'modifyLinkHandlers')) {
288 protected function initCurrentUrl()
290 if (empty($this->currentLinkParts)) {
294 $orderedHandlers =
GeneralUtility::makeInstance(DependencyOrderingService::class)->orderByDependencies($this->linkHandlers,
'scanBefore',
'scanAfter');
297 foreach ($orderedHandlers as $key => $configuration) {
299 $handler = $configuration[
'handlerInstance'];
300 if ($handler->canHandleLink($this->currentLinkParts)) {
301 $this->currentLinkHandler = $handler;
302 $this->currentLinkHandlerId = $key;
307 if (!$this->currentLinkHandler) {
308 $this->currentLinkParts = [];
312 foreach ($this->currentLinkParts as $key => $part) {
313 if ($key !==
'url') {
314 $this->linkAttributeValues[$key] = $part;
327 $this->doc->bodyTagId =
'typo3-browse-links-php';
330 $this->doc->bodyTagAdditions .=
' ' . $attributeName .
'="' . htmlspecialchars($value) .
'"';
335 unset($this->doc->JScodeArray[
'jumpToUrl']);
345 return '<!-- Print current URL -->
346 <table border="0" cellpadding="0" cellspacing="0" id="typo3-curUrl">
348 <td>' . $this->
getLanguageService()->getLL(
'currentLink',
true) .
': ' . htmlspecialchars($this->currentLinkHandler->formatCurrentUrl()) .
'</td>
358 protected function buildMenuArray()
361 if ($this->displayedLinkHandlerId && !in_array($this->displayedLinkHandlerId, $allowedItems,
true)) {
362 $this->displayedLinkHandlerId =
'';
365 $allowedHandlers = array_flip($allowedItems);
367 foreach ($this->linkHandlers as $identifier => $configuration) {
368 if (!isset($allowedHandlers[$identifier])) {
373 $handlerInstance = $configuration[
'handlerInstance'];
374 $isActive = $this->displayedLinkHandlerId === $identifier || !$this->displayedLinkHandlerId && $handlerInstance ===
$this->currentLinkHandler;
376 $this->displayedLinkHandler = $handlerInstance;
377 if (!$this->displayedLinkHandlerId) {
382 if ($configuration[
'addParams']) {
383 $addParams = $configuration[
'addParams'];
388 $menuDef[$identifier] = [
389 'isActive' => $isActive,
390 'label' => $configuration[
'label'],
392 'addParams' => $addParams,
393 'before' => $configuration[
'displayBefore'],
394 'after' => $configuration[
'displayAfter']
401 if (!$this->displayedLinkHandler) {
403 $this->currentLinkParts = [];
404 $this->currentLinkHandler = null;
405 $this->currentLinkHandler =
'';
408 $this->displayedLinkHandlerId = key($menuDef);
423 $allowedItems = array_keys($this->linkHandlers);
425 foreach ($this->hookObjects as $hookObject) {
426 if (method_exists($hookObject,
'modifyAllowedItems')) {
427 $allowedItems = $hookObject->modifyAllowedItems($allowedItems, $this->currentLinkParts);
432 $blindLinkOptions = isset($this->parameters[
'params'][
'blindLinkOptions'])
435 $allowedItems = array_diff($allowedItems, $blindLinkOptions);
437 return $allowedItems;
447 $allowedLinkAttributes = $this->displayedLinkHandler->getLinkAttributes();
450 $blindLinkFields = isset($this->parameters[
'params'][
'blindLinkFields'])
453 $allowedLinkAttributes = array_diff($allowedLinkAttributes, $blindLinkFields);
455 return $allowedLinkAttributes;
467 $fieldRenderingDefinitions = $this->displayedLinkHandler->modifyLinkAttributes($fieldRenderingDefinitions);
472 foreach ($this->linkAttributeFields as $attribute) {
473 $content .= $fieldRenderingDefinitions[$attribute];
477 if (!empty($this->currentLinkParts) && $this->displayedLinkHandler === $this->currentLinkHandler && $this->currentLinkHandler->isUpdateSupported()) {
479 <form action="" name="lparamsform" id="lparamsform">
480 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
482 <input class="btn btn-default t3js-linkCurrent" type="submit" value="' . $this->
getLanguageService()->getLL(
'update',
true) .
'" />
485 </form><br /><br />';
500 $fieldRenderingDefinitions = [];
501 $fieldRenderingDefinitions[
'target'] =
'
503 Selecting target for link:
505 <form action="" name="ltargetform" id="ltargetform">
506 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTarget">
508 <td style="width: 96px;">' .
$lang->getLL(
'target',
true) .
':</td>
510 <input type="text" name="ltarget" class="t3js-linkTarget" value="' . htmlspecialchars($this->linkAttributeValues[
'target']) .
'" />
511 <select name="ltarget_type" class="t3js-targetPreselect">
512 <option value=""></option>
513 <option value="_top">' .
$lang->getLL(
'top',
true) .
'</option>
514 <option value="_blank">' .
$lang->getLL(
'newWindow',
true) .
'</option>
521 $fieldRenderingDefinitions[
'title'] =
'
523 Selecting title for link:
525 <form action="" name="ltitleform" id="ltitleform">
526 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkTitle">
528 <td style="width: 96px;">' .
$lang->getLL(
'title',
true) .
'</td>
529 <td><input type="text" name="ltitle" class="typo3-link-input" value="' . htmlspecialchars($this->linkAttributeValues[
'title']) .
'" /></td>
535 $fieldRenderingDefinitions[
'class'] =
'
537 Selecting class for link:
539 <form action="" name="lclassform" id="lclassform">
540 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkClass">
542 <td style="width: 96px;">' .
$lang->getLL(
'class',
true) .
'</td>
543 <td><input type="text" name="lclass" class="typo3-link-input" value="' . htmlspecialchars($this->linkAttributeValues[
'class']) .
'" /></td>
549 $fieldRenderingDefinitions[
'params'] =
'
551 Selecting params for link:
553 <form action="" name="lparamsform" id="lparamsform">
554 <table border="0" cellpadding="2" cellspacing="1" id="typo3-linkParams">
556 <td style="width: 96px;">' .
$lang->getLL(
'params',
true) .
'</td>
557 <td><input type="text" name="lparams" class="typo3-link-input" value="' . htmlspecialchars($this->linkAttributeValues[
'params']) .
'" /></td>
563 return $fieldRenderingDefinitions;
588 $parameters[
'itemName'] = $this->parameters[
'itemName'];
589 $parameters[
'formName'] = $this->parameters[
'formName'];
590 $parameters[
'params'][
'allowedExtensions'] = isset($this->parameters[
'params'][
'allowedExtensions']) ? $this->parameters[
'params'][
'allowedExtensions'] :
'';
591 $parameters[
'params'][
'blindLinkOptions'] = isset($this->parameters[
'params'][
'blindLinkOptions']) ? $this->parameters[
'params'][
'blindLinkOptions'] :
'';
592 $parameters[
'params'][
'blindLinkFields'] = isset($this->parameters[
'params'][
'blindLinkFields']) ? $this->parameters[
'params'][
'blindLinkFields']:
'';
595 $attributes = $this->displayedLinkHandler->getBodyTagAttributes();
599 'data-this-script-url' => strpos($this->thisScript,
'?') ===
false ? $this->thisScript .
'?' : $this->thisScript .
'&',
601 'data-parameters' => json_encode($this->parameters),
602 'data-add-on-params' => $addPassOnParams,
603 'data-link-attribute-fields' => json_encode($this->linkAttributeFields)