2 declare(strict_types = 1);
39 'renderType' =>
'tcaDescription',
49 'localizationStateSelector' => [
50 'renderType' =>
'localizationStateSelector',
52 'otherLanguageContent' => [
53 'renderType' =>
'otherLanguageContent',
55 'localizationStateSelector'
58 'defaultLanguageDifferences' => [
59 'renderType' =>
'defaultLanguageDifferences',
61 'otherLanguageContent',
73 $table = $this->data[
'tableName'];
74 $row = $this->data[
'databaseRow'];
75 $parameterArray = $this->data[
'parameterArray'];
79 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField']) && !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'])) {
80 $languageField =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'];
81 $languageId = (int)((is_array($row[$languageField]) ? $row[$languageField][0] : $row[$languageField]) ?? 0);
83 $baseUrl = $this->
getPrefix($this->data[
'site'], $languageId);
85 $itemValue = $parameterArray[
'itemFormElValue'];
86 $config = $parameterArray[
'fieldConf'][
'config'];
87 $evalList = GeneralUtility::trimExplode(
',', $config[
'eval'],
true);
92 $itemValue = rawurldecode($itemValue);
95 $fieldInformationHtml = $fieldInformationResult[
'html'];
99 $fieldControlHtml = $fieldControlResult[
'html'];
103 $fieldWizardHtml = $fieldWizardResult[
'html'];
105 $toggleButtonTitle = $this->
getLanguageService()->
sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:buttons.toggleSlugExplanation');
106 $recreateButtonTitle = $this->
getLanguageService()->
sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:buttons.recreateSlugExplanation');
108 $successMessage = sprintf($this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:slugCreation.success.' . ($table ===
'pages' ?
'page' :
'record')), $baseUrl);
109 $errorMessage = sprintf($this->
getLanguageService()->sL(
'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:slugCreation.error'), $baseUrl);
113 $mainFieldHtml[] =
'<div class="formengine-field-item t3js-formengine-field-item">';
114 $mainFieldHtml[] = $fieldInformationHtml;
115 $mainFieldHtml[] =
'<div class="form-control-wrap" style="max-width: ' . $width .
'px" id="' . htmlspecialchars($thisSlugId) .
'">';
116 $mainFieldHtml[] =
'<div class="form-wizards-wrap">';
117 $mainFieldHtml[] =
'<div class="form-wizards-element">';
118 $mainFieldHtml[] =
'<div class="input-group">';
119 $mainFieldHtml[] = ($baseUrl ?
'<span class="input-group-addon">' . htmlspecialchars($baseUrl) .
'</span>' :
'');
122 $mainFieldHtml[] =
'<input';
123 $mainFieldHtml[] =
' class="form-control t3js-form-field-slug-readonly"';
124 $mainFieldHtml[] =
' data-toggle="tooltip"';
125 $mainFieldHtml[] =
' data-title="' . htmlspecialchars($itemValue) .
'"';
126 $mainFieldHtml[] =
' value="' . htmlspecialchars($itemValue) .
'"';
127 $mainFieldHtml[] =
' readonly';
128 $mainFieldHtml[] =
' />';
129 $mainFieldHtml[] =
'<input type="text"';
131 $mainFieldHtml[] =
' class="form-control t3js-form-field-slug-input hidden"';
132 $mainFieldHtml[] =
' placeholder="' . htmlspecialchars($row[
'slug'] ??
'/') .
'"';
134 $mainFieldHtml[] =
' data-formengine-input-params="' . htmlspecialchars(json_encode([
'field' => $parameterArray[
'itemFormElName'],
'evalList' => implode(
',', $evalList)])) .
'"';
135 $mainFieldHtml[] =
' data-formengine-input-name="' . htmlspecialchars($parameterArray[
'itemFormElName']) .
'"';
136 $mainFieldHtml[] =
' />';
137 $mainFieldHtml[] =
'<span class="input-group-btn">';
138 $mainFieldHtml[] =
'<button class="btn btn-default t3js-form-field-slug-toggle" type="button" title="' . htmlspecialchars($toggleButtonTitle) .
'">';
139 $mainFieldHtml[] = $this->iconFactory->getIcon(
'actions-version-workspaces-preview-link',
Icon::SIZE_SMALL)->render();
140 $mainFieldHtml[] =
'</button>';
141 $mainFieldHtml[] =
'<button class="btn btn-default t3js-form-field-slug-recreate" type="button" title="' . htmlspecialchars($recreateButtonTitle) .
'">';
142 $mainFieldHtml[] = $this->iconFactory->getIcon(
'actions-refresh',
Icon::SIZE_SMALL)->render();
143 $mainFieldHtml[] =
'</button>';
144 $mainFieldHtml[] =
'</span>';
145 $mainFieldHtml[] =
'<input type="hidden"';
146 $mainFieldHtml[] =
' class="t3js-form-field-slug-hidden"';
147 $mainFieldHtml[] =
' name="' . htmlspecialchars($parameterArray[
'itemFormElName']) .
'"';
148 $mainFieldHtml[] =
' value="' . htmlspecialchars($itemValue) .
'"';
149 $mainFieldHtml[] =
' />';
150 $mainFieldHtml[] =
'</div>';
151 $mainFieldHtml[] =
'</div>';
152 if (!empty($fieldControlHtml)) {
153 $mainFieldHtml[] =
'<div class="form-wizards-items-aside">';
154 $mainFieldHtml[] =
'<div class="btn-group">';
155 $mainFieldHtml[] = $fieldControlHtml;
156 $mainFieldHtml[] =
'</div>';
157 $mainFieldHtml[] =
'</div>';
159 $mainFieldHtml[] =
'<div class="form-wizards-items-bottom">';
160 $mainFieldHtml[] =
'<span class="t3js-form-proposal-accepted hidden label label-success">' . htmlspecialchars($successMessage) .
'<span>/abc/</span></span>';
161 $mainFieldHtml[] =
'<span class="t3js-form-proposal-different hidden label label-warning">' . htmlspecialchars($errorMessage) .
'<span>/abc/</span></span>';
162 $mainFieldHtml[] = $fieldWizardHtml;
163 $mainFieldHtml[] =
'</div>';
164 $mainFieldHtml[] =
'</div>';
165 $mainFieldHtml[] =
'</div>';
166 $mainFieldHtml[] =
'</div>';
168 $resultArray[
'html'] = implode(LF, $mainFieldHtml);
170 [$commonElementPrefix] = GeneralUtility::revExplode(
'[', $parameterArray[
'itemFormElName'], 2);
171 $validInputNamesToListenTo = [];
172 $includeUidInValues =
false;
173 foreach ($config[
'generatorOptions'][
'fields'] ?? [] as $fieldNameParts) {
174 if (is_string($fieldNameParts)) {
175 $fieldNameParts = GeneralUtility::trimExplode(
',', $fieldNameParts);
177 foreach ($fieldNameParts as $listenerFieldName) {
178 if ($listenerFieldName ===
'uid') {
179 $includeUidInValues =
true;
182 $validInputNamesToListenTo[$listenerFieldName] = $commonElementPrefix .
'[' . htmlspecialchars($listenerFieldName) .
']';
185 $parentPageId = $this->data[
'parentPageRow'][
'uid'] ?? 0;
186 $signature = GeneralUtility::hmac(
191 $this->data[
'effectivePid'],
194 $this->data[
'fieldName'],
195 $this->data[
'command'],
199 FormSlugAjaxController::class
201 $optionsForModule = [
202 'pageId' => $this->data[
'effectivePid'],
203 'recordId' => $row[
'uid'],
204 'tableName' => $table,
205 'fieldName' => $this->data[
'fieldName'],
207 'listenerFieldNames' => $validInputNamesToListenTo,
208 'language' => $languageId,
209 'originalValue' => $itemValue,
210 'signature' => $signature,
211 'command' => $this->data[
'command'],
212 'parentPageId' => $parentPageId,
213 'includeUidInValues' => $includeUidInValues,
215 $resultArray[
'requireJsModules'][] = [
'TYPO3/CMS/Backend/FormEngine/Element/SlugElement' =>
'
216 function(SlugElement) {
217 new SlugElement(' . GeneralUtility::quoteJSvalue(
'#' . $thisSlugId) .
', ' . json_encode($optionsForModule) .
');
235 $baseUrl = (string)$base;
236 $baseUrl = rtrim($baseUrl,
'/');
237 if (!empty($baseUrl) && empty($base->getScheme()) && $base->getHost() !==
'') {
238 $baseUrl =
'http:' . $baseUrl;
240 }
catch (\InvalidArgumentException $e) {