| Total Complexity | 51 |
| Total Lines | 429 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Complex classes like InputLinkElement often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use InputLinkElement, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 38 | class InputLinkElement extends AbstractFormElement |
||
| 39 | { |
||
| 40 | /** |
||
| 41 | * Default field information enabled for this element. |
||
| 42 | * |
||
| 43 | * @var array |
||
| 44 | */ |
||
| 45 | protected $defaultFieldInformation = [ |
||
| 46 | 'tcaDescription' => [ |
||
| 47 | 'renderType' => 'tcaDescription', |
||
| 48 | ], |
||
| 49 | ]; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Default field controls render the link icon |
||
| 53 | * |
||
| 54 | * @var array |
||
| 55 | */ |
||
| 56 | protected $defaultFieldControl = [ |
||
| 57 | 'linkPopup' => [ |
||
| 58 | 'renderType' => 'linkPopup', |
||
| 59 | 'options' => [] |
||
| 60 | ], |
||
| 61 | ]; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Default field wizards enabled for this element. |
||
| 65 | * |
||
| 66 | * @var array |
||
| 67 | */ |
||
| 68 | protected $defaultFieldWizard = [ |
||
| 69 | 'localizationStateSelector' => [ |
||
| 70 | 'renderType' => 'localizationStateSelector', |
||
| 71 | ], |
||
| 72 | 'otherLanguageContent' => [ |
||
| 73 | 'renderType' => 'otherLanguageContent', |
||
| 74 | 'after' => [ |
||
| 75 | 'localizationStateSelector' |
||
| 76 | ], |
||
| 77 | ], |
||
| 78 | 'defaultLanguageDifferences' => [ |
||
| 79 | 'renderType' => 'defaultLanguageDifferences', |
||
| 80 | 'after' => [ |
||
| 81 | 'otherLanguageContent', |
||
| 82 | ], |
||
| 83 | ], |
||
| 84 | ]; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * This will render a single-line input form field, possibly with various control/validation features |
||
| 88 | * |
||
| 89 | * @return array As defined in initializeResultArray() of AbstractNode |
||
| 90 | */ |
||
| 91 | public function render() |
||
| 92 | { |
||
| 93 | $languageService = $this->getLanguageService(); |
||
| 94 | |||
| 95 | $table = $this->data['tableName']; |
||
| 96 | $fieldName = $this->data['fieldName']; |
||
| 97 | $row = $this->data['databaseRow']; |
||
| 98 | $parameterArray = $this->data['parameterArray']; |
||
| 99 | $resultArray = $this->initializeResultArray(); |
||
| 100 | $config = $parameterArray['fieldConf']['config']; |
||
| 101 | |||
| 102 | $itemValue = $parameterArray['itemFormElValue']; |
||
| 103 | $evalList = GeneralUtility::trimExplode(',', $config['eval'], true); |
||
| 104 | $size = MathUtility::forceIntegerInRange($config['size'] ?? $this->defaultInputWidth, $this->minimumInputWidth, $this->maxInputWidth); |
||
| 105 | $width = (int)$this->formMaxWidth($size); |
||
| 106 | $nullControlNameEscaped = htmlspecialchars('control[active][' . $table . '][' . $row['uid'] . '][' . $fieldName . ']'); |
||
| 107 | |||
| 108 | $fieldInformationResult = $this->renderFieldInformation(); |
||
| 109 | $fieldInformationHtml = $fieldInformationResult['html']; |
||
| 110 | $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false); |
||
| 111 | |||
| 112 | if ($config['readOnly']) { |
||
| 113 | // Early return for read only fields |
||
| 114 | $html = []; |
||
| 115 | $html[] = '<div class="formengine-field-item t3js-formengine-field-item">'; |
||
| 116 | $html[] = $fieldInformationHtml; |
||
| 117 | $html[] = '<div class="form-wizards-wrap">'; |
||
| 118 | $html[] = '<div class="form-wizards-element">'; |
||
| 119 | $html[] = '<div class="form-control-wrap" style="max-width: ' . $width . 'px">'; |
||
| 120 | $html[] = '<input class="form-control" value="' . htmlspecialchars($itemValue) . '" type="text" disabled>'; |
||
| 121 | $html[] = '</div>'; |
||
| 122 | $html[] = '</div>'; |
||
| 123 | $html[] = '</div>'; |
||
| 124 | $html[] = '</div>'; |
||
| 125 | $resultArray['html'] = implode(LF, $html); |
||
| 126 | return $resultArray; |
||
| 127 | } |
||
| 128 | |||
| 129 | // @todo: The whole eval handling is a mess and needs refactoring |
||
| 130 | foreach ($evalList as $func) { |
||
| 131 | // @todo: This is ugly: The code should find out on it's own whether an eval definition is a |
||
| 132 | // @todo: keyword like "date", or a class reference. The global registration could be dropped then |
||
| 133 | // Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval() |
||
| 134 | if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) { |
||
| 135 | if (class_exists($func)) { |
||
| 136 | $evalObj = GeneralUtility::makeInstance($func); |
||
| 137 | if (method_exists($evalObj, 'deevaluateFieldValue')) { |
||
| 138 | $_params = [ |
||
| 139 | 'value' => $itemValue |
||
| 140 | ]; |
||
| 141 | $itemValue = $evalObj->deevaluateFieldValue($_params); |
||
| 142 | } |
||
| 143 | if (method_exists($evalObj, 'returnFieldJS')) { |
||
| 144 | $resultArray['additionalJavaScriptPost'][] = 'TBE_EDITOR.customEvalFunctions[' . GeneralUtility::quoteJSvalue($func) . ']' |
||
| 145 | . ' = function(value) {' . $evalObj->returnFieldJS() . '};'; |
||
| 146 | } |
||
| 147 | } |
||
| 148 | } |
||
| 149 | } |
||
| 150 | |||
| 151 | $fieldId = StringUtility::getUniqueId('formengine-input-'); |
||
| 152 | |||
| 153 | $attributes = [ |
||
| 154 | 'value' => '', |
||
| 155 | 'id' => $fieldId, |
||
| 156 | 'class' => implode(' ', [ |
||
| 157 | 'form-control', |
||
| 158 | 't3js-clearable', |
||
| 159 | 't3js-form-field-inputlink-input', |
||
| 160 | 'hidden', |
||
| 161 | 'hasDefaultValue', |
||
| 162 | ]), |
||
| 163 | 'data-formengine-validation-rules' => $this->getValidationDataAsJsonString($config), |
||
| 164 | 'data-formengine-input-params' => (string)json_encode([ |
||
| 165 | 'field' => $parameterArray['itemFormElName'], |
||
| 166 | 'evalList' => implode(',', $evalList) |
||
| 167 | ]), |
||
| 168 | 'data-formengine-input-name' => (string)($parameterArray['itemFormElName'] ?? ''), |
||
| 169 | ]; |
||
| 170 | |||
| 171 | $maxLength = $config['max'] ?? 0; |
||
| 172 | if ((int)$maxLength > 0) { |
||
| 173 | $attributes['maxlength'] = (string)(int)$maxLength; |
||
| 174 | } |
||
| 175 | if (!empty($config['placeholder'])) { |
||
| 176 | $attributes['placeholder'] = trim($config['placeholder']); |
||
| 177 | } |
||
| 178 | if (isset($config['autocomplete'])) { |
||
| 179 | $attributes['autocomplete'] = empty($config['autocomplete']) ? 'new-' . $fieldName : 'on'; |
||
| 180 | } |
||
| 181 | |||
| 182 | $valuePickerHtml = []; |
||
| 183 | if (isset($config['valuePicker']['items']) && is_array($config['valuePicker']['items'])) { |
||
| 184 | $valuePickerConfiguration = [ |
||
| 185 | 'mode' => $config['valuePicker']['mode'] ?? 'replace', |
||
| 186 | 'linked-field' => '[data-formengine-input-name="' . $parameterArray['itemFormElName'] . '"]' |
||
| 187 | ]; |
||
| 188 | $valuePickerAttributes = [ |
||
| 189 | 'class' => 'form-select form-control-adapt', |
||
| 190 | 'onchange' => implode('', $parameterArray['fieldChangeFunc']), |
||
| 191 | ]; |
||
| 192 | |||
| 193 | $valuePickerHtml[] = '<typo3-formengine-valuepicker ' . GeneralUtility::implodeAttributes($valuePickerConfiguration, true) . '>'; |
||
| 194 | $valuePickerHtml[] = '<select ' . GeneralUtility::implodeAttributes($valuePickerAttributes, true) . '>'; |
||
| 195 | $valuePickerHtml[] = '<option></option>'; |
||
| 196 | foreach ($config['valuePicker']['items'] as $item) { |
||
| 197 | $valuePickerHtml[] = '<option value="' . htmlspecialchars($item[1]) . '">' . htmlspecialchars($languageService->sL($item[0])) . '</option>'; |
||
| 198 | } |
||
| 199 | $valuePickerHtml[] = '</select>'; |
||
| 200 | $valuePickerHtml[] = '</typo3-formengine-valuepicker>'; |
||
| 201 | |||
| 202 | $resultArray['requireJsModules'][] = ['TYPO3/CMS/Backend/FormEngine/FieldWizard/ValuePicker' => null]; |
||
| 203 | } |
||
| 204 | |||
| 205 | $fieldWizardResult = $this->renderFieldWizard(); |
||
| 206 | $fieldWizardHtml = $fieldWizardResult['html']; |
||
| 207 | $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false); |
||
| 208 | |||
| 209 | $fieldControlResult = $this->renderFieldControl(); |
||
| 210 | $fieldControlHtml = $fieldControlResult['html']; |
||
| 211 | $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldControlResult, false); |
||
| 212 | |||
| 213 | $linkExplanation = $this->getLinkExplanation($itemValue ?: ''); |
||
| 214 | $explanation = htmlspecialchars($linkExplanation['text']); |
||
| 215 | $toggleButtonTitle = $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:buttons.toggleLinkExplanation'); |
||
| 216 | |||
| 217 | $expansionHtml = []; |
||
| 218 | $expansionHtml[] = '<div class="form-control-wrap" style="max-width: ' . $width . 'px">'; |
||
| 219 | $expansionHtml[] = '<div class="form-wizards-wrap">'; |
||
| 220 | $expansionHtml[] = '<div class="form-wizards-element">'; |
||
| 221 | $expansionHtml[] = '<div class="input-group t3js-form-field-inputlink">'; |
||
| 222 | $expansionHtml[] = '<span class="t3js-form-field-inputlink-icon input-group-addon">' . $linkExplanation['icon'] . '</span>'; |
||
| 223 | $expansionHtml[] = '<input class="form-control t3js-form-field-inputlink-explanation" data-bs-toggle="tooltip" title="' . $explanation . '" value="' . $explanation . '" readonly>'; |
||
| 224 | $expansionHtml[] = '<input type="text" ' . GeneralUtility::implodeAttributes($attributes, true) . ' />'; |
||
| 225 | $expansionHtml[] = '<button class="btn btn-default t3js-form-field-inputlink-explanation-toggle" type="button" title="' . htmlspecialchars($toggleButtonTitle) . '">'; |
||
| 226 | $expansionHtml[] = $this->iconFactory->getIcon('actions-version-workspaces-preview-link', Icon::SIZE_SMALL)->render(); |
||
| 227 | $expansionHtml[] = '</button>'; |
||
| 228 | $expansionHtml[] = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($itemValue) . '" />'; |
||
| 229 | $expansionHtml[] = '</div>'; |
||
| 230 | $expansionHtml[] = '</div>'; |
||
| 231 | if (!empty($valuePickerHtml) || !empty($fieldControlHtml)) { |
||
| 232 | $expansionHtml[] = '<div class="form-wizards-items-aside">'; |
||
| 233 | $expansionHtml[] = '<div class="btn-group">'; |
||
| 234 | $expansionHtml[] = implode(LF, $valuePickerHtml); |
||
| 235 | $expansionHtml[] = $fieldControlHtml; |
||
| 236 | $expansionHtml[] = '</div>'; |
||
| 237 | $expansionHtml[] = '</div>'; |
||
| 238 | } |
||
| 239 | $expansionHtml[] = '<div class="form-wizards-items-bottom">'; |
||
| 240 | $expansionHtml[] = $linkExplanation['additionalAttributes']; |
||
| 241 | $expansionHtml[] = $fieldWizardHtml; |
||
| 242 | $expansionHtml[] = '</div>'; |
||
| 243 | $expansionHtml[] = '</div>'; |
||
| 244 | $expansionHtml[] = '</div>'; |
||
| 245 | $expansionHtml = implode(LF, $expansionHtml); |
||
| 246 | |||
| 247 | $fullElement = $expansionHtml; |
||
| 248 | if ($this->hasNullCheckboxButNoPlaceholder()) { |
||
| 249 | $checked = $itemValue !== null ? ' checked="checked"' : ''; |
||
| 250 | $fullElement = []; |
||
| 251 | $fullElement[] = '<div class="t3-form-field-disable"></div>'; |
||
| 252 | $fullElement[] = '<div class="form-check t3-form-field-eval-null-checkbox">'; |
||
| 253 | $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="0" />'; |
||
| 254 | $fullElement[] = '<input type="checkbox" class="form-check-input" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . ' />'; |
||
| 255 | $fullElement[] = '<label class="form-check-label" for="' . $nullControlNameEscaped . '">'; |
||
| 256 | $fullElement[] = $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.nullCheckbox'); |
||
| 257 | $fullElement[] = '</label>'; |
||
| 258 | $fullElement[] = '</div>'; |
||
| 259 | $fullElement[] = $expansionHtml; |
||
| 260 | $fullElement = implode(LF, $fullElement); |
||
| 261 | } elseif ($this->hasNullCheckboxWithPlaceholder()) { |
||
| 262 | $checked = $itemValue !== null ? ' checked="checked"' : ''; |
||
| 263 | $placeholder = $shortenedPlaceholder = $config['placeholder'] ?? ''; |
||
| 264 | $disabled = ''; |
||
| 265 | $fallbackValue = 0; |
||
| 266 | if (strlen($placeholder) > 0) { |
||
| 267 | $shortenedPlaceholder = GeneralUtility::fixed_lgd_cs($placeholder, 20); |
||
| 268 | if ($placeholder !== $shortenedPlaceholder) { |
||
| 269 | $overrideLabel = sprintf( |
||
| 270 | $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.placeholder.override'), |
||
| 271 | '<span title="' . htmlspecialchars($placeholder) . '">' . htmlspecialchars($shortenedPlaceholder) . '</span>' |
||
| 272 | ); |
||
| 273 | } else { |
||
| 274 | $overrideLabel = sprintf( |
||
| 275 | $languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.placeholder.override'), |
||
| 276 | htmlspecialchars($placeholder) |
||
| 277 | ); |
||
| 278 | } |
||
| 279 | } else { |
||
| 280 | $overrideLabel = $languageService->sL( |
||
| 281 | 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.placeholder.override_not_available' |
||
| 282 | ); |
||
| 283 | } |
||
| 284 | $fullElement = []; |
||
| 285 | $fullElement[] = '<div class="form-check t3js-form-field-eval-null-placeholder-checkbox">'; |
||
| 286 | $fullElement[] = '<input type="hidden" name="' . $nullControlNameEscaped . '" value="' . $fallbackValue . '" />'; |
||
| 287 | $fullElement[] = '<input type="checkbox" class="form-check-input" name="' . $nullControlNameEscaped . '" id="' . $nullControlNameEscaped . '" value="1"' . $checked . $disabled . ' />'; |
||
| 288 | $fullElement[] = '<label class="form-check-label" for="' . $nullControlNameEscaped . '">'; |
||
| 289 | $fullElement[] = $overrideLabel; |
||
| 290 | $fullElement[] = '</label>'; |
||
| 291 | $fullElement[] = '</div>'; |
||
| 292 | $fullElement[] = '<div class="t3js-formengine-placeholder-placeholder">'; |
||
| 293 | $fullElement[] = '<div class="form-control-wrap" style="max-width:' . $width . 'px">'; |
||
| 294 | $fullElement[] = '<input type="text" class="form-control" disabled="disabled" value="' . htmlspecialchars($shortenedPlaceholder) . '" />'; |
||
| 295 | $fullElement[] = '</div>'; |
||
| 296 | $fullElement[] = '</div>'; |
||
| 297 | $fullElement[] = '<div class="t3js-formengine-placeholder-formfield">'; |
||
| 298 | $fullElement[] = $expansionHtml; |
||
| 299 | $fullElement[] = '</div>'; |
||
| 300 | $fullElement = implode(LF, $fullElement); |
||
| 301 | } |
||
| 302 | |||
| 303 | $resultArray['requireJsModules'][] = ['TYPO3/CMS/Backend/FormEngine/Element/InputLinkElement' => ' |
||
| 304 | function(InputLinkElement) { |
||
| 305 | new InputLinkElement(' . GeneralUtility::quoteJSvalue($fieldId) . '); |
||
| 306 | }' |
||
| 307 | ]; |
||
| 308 | $resultArray['html'] = '<div class="formengine-field-item t3js-formengine-field-item">' . $fieldInformationHtml . $fullElement . '</div>'; |
||
| 309 | return $resultArray; |
||
| 310 | } |
||
| 311 | |||
| 312 | /** |
||
| 313 | * @param string $itemValue |
||
| 314 | * @return array |
||
| 315 | */ |
||
| 316 | protected function getLinkExplanation(string $itemValue): array |
||
| 317 | { |
||
| 318 | if (empty($itemValue)) { |
||
| 319 | return []; |
||
| 320 | } |
||
| 321 | $data = ['text' => '', 'icon' => '']; |
||
| 322 | $typolinkService = GeneralUtility::makeInstance(TypoLinkCodecService::class); |
||
| 323 | $linkParts = $typolinkService->decode($itemValue); |
||
| 324 | $linkService = GeneralUtility::makeInstance(LinkService::class); |
||
| 325 | |||
| 326 | try { |
||
| 327 | $linkData = $linkService->resolve($linkParts['url']); |
||
| 328 | } catch (FileDoesNotExistException|FolderDoesNotExistException|UnknownLinkHandlerException|InvalidPathException $e) { |
||
| 329 | return $data; |
||
| 330 | } |
||
| 331 | |||
| 332 | // Resolving the TypoLink parts (class, title, params) |
||
| 333 | $additionalAttributes = []; |
||
| 334 | foreach ($linkParts as $key => $value) { |
||
| 335 | if ($key === 'url') { |
||
| 336 | continue; |
||
| 337 | } |
||
| 338 | if ($value) { |
||
| 339 | switch ($key) { |
||
| 340 | case 'class': |
||
| 341 | $label = $this->getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang_browse_links.xlf:class'); |
||
| 342 | break; |
||
| 343 | case 'title': |
||
| 344 | $label = $this->getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang_browse_links.xlf:title'); |
||
| 345 | break; |
||
| 346 | case 'additionalParams': |
||
| 347 | $label = $this->getLanguageService()->sL('LLL:EXT:recordlist/Resources/Private/Language/locallang_browse_links.xlf:params'); |
||
| 348 | break; |
||
| 349 | default: |
||
| 350 | $label = (string)$key; |
||
| 351 | } |
||
| 352 | |||
| 353 | $additionalAttributes[] = '<span><strong>' . htmlspecialchars($label) . ': </strong> ' . htmlspecialchars($value) . '</span>'; |
||
| 354 | } |
||
| 355 | } |
||
| 356 | |||
| 357 | // Resolve the actual link |
||
| 358 | switch ($linkData['type']) { |
||
| 359 | case LinkService::TYPE_PAGE: |
||
| 360 | $pageRecord = BackendUtility::readPageAccess($linkData['pageuid'], '1=1'); |
||
| 361 | // Is this a real page |
||
| 362 | if ($pageRecord['uid']) { |
||
| 363 | $fragmentTitle = ''; |
||
| 364 | if (isset($linkData['fragment'])) { |
||
| 365 | if (MathUtility::canBeInterpretedAsInteger($linkData['fragment'])) { |
||
| 366 | $contentElement = BackendUtility::getRecord('tt_content', (int)$linkData['fragment'], '*', 'pid=' . $pageRecord['uid']); |
||
| 367 | if ($contentElement) { |
||
| 368 | $fragmentTitle = BackendUtility::getRecordTitle('tt_content', $contentElement, false, false); |
||
| 369 | } |
||
| 370 | } |
||
| 371 | $fragmentTitle = ' #' . ($fragmentTitle ?: $linkData['fragment']); |
||
| 372 | } |
||
| 373 | $data = [ |
||
| 374 | 'text' => $pageRecord['_thePathFull'] . '[' . $pageRecord['uid'] . ']' . $fragmentTitle, |
||
| 375 | 'icon' => $this->iconFactory->getIconForRecord('pages', $pageRecord, Icon::SIZE_SMALL)->render() |
||
|
|
|||
| 376 | ]; |
||
| 377 | } |
||
| 378 | break; |
||
| 379 | case LinkService::TYPE_EMAIL: |
||
| 380 | $data = [ |
||
| 381 | 'text' => $linkData['email'], |
||
| 382 | 'icon' => $this->iconFactory->getIcon('content-elements-mailform', Icon::SIZE_SMALL)->render() |
||
| 383 | ]; |
||
| 384 | break; |
||
| 385 | case LinkService::TYPE_URL: |
||
| 386 | $data = [ |
||
| 387 | 'text' => $linkData['url'], |
||
| 388 | 'icon' => $this->iconFactory->getIcon('apps-pagetree-page-shortcut-external', Icon::SIZE_SMALL)->render() |
||
| 389 | |||
| 390 | ]; |
||
| 391 | break; |
||
| 392 | case LinkService::TYPE_FILE: |
||
| 393 | /** @var File $file */ |
||
| 394 | $file = $linkData['file']; |
||
| 395 | if ($file) { |
||
| 396 | $data = [ |
||
| 397 | 'text' => $file->getPublicUrl(), |
||
| 398 | 'icon' => $this->iconFactory->getIconForFileExtension($file->getExtension(), Icon::SIZE_SMALL)->render() |
||
| 399 | ]; |
||
| 400 | } |
||
| 401 | break; |
||
| 402 | case LinkService::TYPE_FOLDER: |
||
| 403 | /** @var Folder $folder */ |
||
| 404 | $folder = $linkData['folder']; |
||
| 405 | if ($folder) { |
||
| 406 | $data = [ |
||
| 407 | 'text' => $folder->getPublicUrl(), |
||
| 408 | 'icon' => $this->iconFactory->getIcon('apps-filetree-folder-default', Icon::SIZE_SMALL)->render() |
||
| 409 | ]; |
||
| 410 | } |
||
| 411 | break; |
||
| 412 | case LinkService::TYPE_RECORD: |
||
| 413 | $table = $this->data['pageTsConfig']['TCEMAIN.']['linkHandler.'][$linkData['identifier'] . '.']['configuration.']['table']; |
||
| 414 | $record = BackendUtility::getRecord($table, $linkData['uid']); |
||
| 415 | if ($record) { |
||
| 416 | $recordTitle = BackendUtility::getRecordTitle($table, $record); |
||
| 417 | $tableTitle = $this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title']); |
||
| 418 | $data = [ |
||
| 419 | 'text' => sprintf('%s [%s:%d]', $recordTitle, $tableTitle, $linkData['uid']), |
||
| 420 | 'icon' => $this->iconFactory->getIconForRecord($table, $record, Icon::SIZE_SMALL)->render(), |
||
| 421 | ]; |
||
| 422 | } else { |
||
| 423 | $data = [ |
||
| 424 | 'text' => sprintf('%s', $linkData['uid']), |
||
| 425 | 'icon' => $this->iconFactory->getIcon('tcarecords-' . $table . '-default', Icon::SIZE_SMALL, 'overlay-missing')->render(), |
||
| 426 | ]; |
||
| 427 | } |
||
| 428 | break; |
||
| 429 | case LinkService::TYPE_TELEPHONE: |
||
| 430 | $telephone = $linkData['telephone']; |
||
| 431 | if ($telephone) { |
||
| 432 | $data = [ |
||
| 433 | 'text' => $telephone, |
||
| 434 | 'icon' => $this->iconFactory->getIcon('actions-device-mobile', Icon::SIZE_SMALL)->render() |
||
| 435 | ]; |
||
| 436 | } |
||
| 437 | break; |
||
| 438 | default: |
||
| 439 | // Please note that this hook is preliminary and might change, as this element could become its own |
||
| 440 | // TCA type in the future |
||
| 441 | if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['linkHandler'][$linkData['type']])) { |
||
| 442 | $linkBuilder = GeneralUtility::makeInstance($GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['linkHandler'][$linkData['type']]); |
||
| 443 | $data = $linkBuilder->getFormData($linkData, $linkParts, $this->data, $this); |
||
| 444 | } elseif ($linkData['type'] === LinkService::TYPE_UNKNOWN) { |
||
| 445 | $data = [ |
||
| 446 | 'text' => $linkData['file'], |
||
| 447 | 'icon' => $this->iconFactory->getIcon('actions-link', Icon::SIZE_SMALL)->render() |
||
| 448 | ]; |
||
| 449 | } else { |
||
| 450 | $data = [ |
||
| 451 | 'text' => 'not implemented type ' . $linkData['type'], |
||
| 452 | 'icon' => '' |
||
| 453 | ]; |
||
| 454 | } |
||
| 455 | } |
||
| 456 | |||
| 457 | $data['additionalAttributes'] = '<div class="help-block">' . implode(' - ', $additionalAttributes) . '</div>'; |
||
| 458 | return $data; |
||
| 459 | } |
||
| 460 | |||
| 461 | /** |
||
| 462 | * @return LanguageService |
||
| 463 | */ |
||
| 464 | protected function getLanguageService() |
||
| 467 | } |
||
| 468 | } |
||
| 469 |