TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
InlineRecordContainer.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Form\Container;
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 
33 
45 {
51  protected $inlineData = [];
52 
57 
63  protected $hookObjects = [];
64 
68  protected $iconFactory;
69 
76  public function __construct(NodeFactory $nodeFactory, array $data)
77  {
78  parent::__construct($nodeFactory, $data);
79  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
80  $this->inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
81  $this->initHookObjects();
82  }
83 
90  public function render()
91  {
93  $this->inlineData = $data['inlineData'];
94 
96  $inlineStackProcessor->initializeByGivenStructure($data['inlineStructure']);
97 
98  $record = $data['databaseRow'];
99  $inlineConfig = $data['inlineParentConfig'];
100  $foreignTable = $inlineConfig['foreign_table'];
101 
102  $resultArray = $this->initializeResultArray();
103 
104  // Send a mapping information to the browser via JSON:
105  // e.g. data[<curTable>][<curId>][<curField>] => data-<pid>-<parentTable>-<parentId>-<parentField>-<curTable>-<curId>-<curField>
106  $formPrefix = $inlineStackProcessor->getCurrentStructureFormPrefix();
107  $domObjectId = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']);
108  $this->inlineData['map'][$formPrefix] = $domObjectId;
109 
110  $resultArray['inlineData'] = $this->inlineData;
111 
112  // If there is a selector field, normalize it:
113  if (!empty($inlineConfig['foreign_selector'])) {
114  $foreign_selector = $inlineConfig['foreign_selector'];
115  $valueToNormalize = $record[$foreign_selector];
116  if (is_array($record[$foreign_selector])) {
117  // @todo: this can be kicked again if always prepared rows are handled here
118  $valueToNormalize = implode(',', $record[$foreign_selector]);
119  }
120  $record[$foreign_selector] = $this->normalizeUid($valueToNormalize);
121  }
122 
123  // Get the current naming scheme for DOM name/id attributes:
124  $appendFormFieldNames = '[' . $foreignTable . '][' . $record['uid'] . ']';
125  $objectId = $domObjectId . '-' . $foreignTable . '-' . $record['uid'];
126  $class = '';
127  $html = '';
128  $combinationHtml = '';
129  $isNewRecord = $data['command'] === 'new';
130  $hiddenField = '';
131  if (isset($data['processedTca']['ctrl']['enablecolumns']['disabled'])) {
132  $hiddenField = $data['processedTca']['ctrl']['enablecolumns']['disabled'];
133  }
134  if (!$data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
135  if ($isNewRecord || $data['isInlineChildExpanded']) {
136  // Render full content ONLY IF this is an AJAX request, a new record, or the record is not collapsed
137  $combinationHtml = '';
138  if (isset($data['combinationChild'])) {
139  $combinationChild = $this->renderCombinationChild($data, $appendFormFieldNames);
140  $combinationHtml = $combinationChild['html'];
141  $combinationChild['html'] = '';
142  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $combinationChild);
143  }
144  $childArray = $this->renderChild($data);
145  $html = $childArray['html'];
146  $childArray['html'] = '';
147  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childArray);
148  } else {
149  // This string is the marker for the JS-function to check if the full content has already been loaded
150  $html = '<!--notloaded-->';
151  }
152  if ($isNewRecord) {
153  // Add pid of record as hidden field
154  $html .= '<input type="hidden" name="data' . htmlspecialchars($appendFormFieldNames)
155  . '[pid]" value="' . htmlspecialchars($record['pid']) . '"/>';
156  // Tell DataHandler this record is expanded
157  $ucFieldName = 'uc[inlineView]'
158  . '[' . $data['inlineTopMostParentTableName'] . ']'
159  . '[' . $data['inlineTopMostParentUid'] . ']'
160  . $appendFormFieldNames;
161  $html .= '<input type="hidden" name="' . htmlspecialchars($ucFieldName)
162  . '" value="' . (int)$data['isInlineChildExpanded'] . '" />';
163  } else {
164  // Set additional field for processing for saving
165  $html .= '<input type="hidden" name="cmd' . htmlspecialchars($appendFormFieldNames)
166  . '[delete]" value="1" disabled="disabled" />';
167  if (!$data['isInlineChildExpanded'] && !empty($hiddenField)) {
168  $checked = !empty($record[$hiddenField]) ? ' checked="checked"' : '';
169  $html .= '<input type="checkbox" data-formengine-input-name="data'
170  . htmlspecialchars($appendFormFieldNames)
171  . '[' . htmlspecialchars($hiddenField) . ']" value="1"' . $checked . ' />';
172  $html .= '<input type="input" name="data' . htmlspecialchars($appendFormFieldNames)
173  . '[' . htmlspecialchars($hiddenField) . ']" value="' . htmlspecialchars($record[$hiddenField]) . '" />';
174  }
175  }
176  // If this record should be shown collapsed
177  $class = $data['isInlineChildExpanded'] ? 'panel-visible' : 'panel-collapsed';
178  }
179  if ($inlineConfig['renderFieldsOnly']) {
180  // Render "body" part only
181  $html = $html . $combinationHtml;
182  } else {
183  // Render header row and content (if expanded)
184  if ($data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
185  $class .= ' t3-form-field-container-inline-placeHolder';
186  }
187  if (!empty($hiddenField) && isset($record[$hiddenField]) && (int)$record[$hiddenField]) {
188  $class .= ' t3-form-field-container-inline-hidden';
189  }
190  $class .= ($isNewRecord ? ' inlineIsNewRecord' : '');
191  $html = '
192  <div class="panel panel-default panel-condensed ' . trim($class) . '" id="' . htmlspecialchars($objectId) . '_div">
193  <div class="panel-heading" data-toggle="formengine-inline" id="' . htmlspecialchars($objectId) . '_header" data-expandSingle="' . ($inlineConfig['appearance']['expandSingle'] ? 1 : 0) . '">
194  <div class="form-irre-header">
195  <div class="form-irre-header-cell form-irre-header-icon">
196  <span class="caret"></span>
197  </div>
198  ' . $this->renderForeignRecordHeader($data) . '
199  </div>
200  </div>
201  <div class="panel-collapse" id="' . htmlspecialchars($objectId) . '_fields" data-expandSingle="' . ($inlineConfig['appearance']['expandSingle'] ? 1 : 0) . '" data-returnURL="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '">' . $html . $combinationHtml . '</div>
202  </div>';
203  }
204 
205  $resultArray['html'] = $html;
206  return $resultArray;
207  }
208 
215  protected function renderChild(array $data)
216  {
217  $domObjectId = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']);
218  $data['tabAndInlineStack'][] = [
219  'inline',
220  $domObjectId . '-' . $data['tableName'] . '-' . $data['databaseRow']['uid'],
221  ];
222  // @todo: ugly construct ...
223  $data['inlineData'] = $this->inlineData;
224  $data['renderType'] = 'fullRecordContainer';
225  return $this->nodeFactory->create($data)->render();
226  }
227 
239  protected function renderCombinationChild(array $data, $appendFormFieldNames)
240  {
241  $childData = $data['combinationChild'];
242  $parentConfig = $data['inlineParentConfig'];
243 
244  $resultArray = $this->initializeResultArray();
245 
246  // Display Warning FlashMessage if it is not suppressed
247  if (!isset($parentConfig['appearance']['suppressCombinationWarning']) || empty($parentConfig['appearance']['suppressCombinationWarning'])) {
248  $combinationWarningMessage = 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.inline_use_combination';
249  if (!empty($parentConfig['appearance']['overwriteCombinationWarningMessage'])) {
250  $combinationWarningMessage = $parentConfig['appearance']['overwriteCombinationWarningMessage'];
251  }
252  $message = $this->getLanguageService()->sL($combinationWarningMessage);
253  $markup = [];
254  // @TODO: This is not a FlashMessage! The markup must be changed and special CSS
255  // @TODO: should be created, in order to prevent confusion.
256  $markup[] = '<div class="alert alert-warning">';
257  $markup[] = ' <div class="media">';
258  $markup[] = ' <div class="media-left">';
259  $markup[] = ' <span class="fa-stack fa-lg">';
260  $markup[] = ' <i class="fa fa-circle fa-stack-2x"></i>';
261  $markup[] = ' <i class="fa fa-exclamation fa-stack-1x"></i>';
262  $markup[] = ' </span>';
263  $markup[] = ' </div>';
264  $markup[] = ' <div class="media-body">';
265  $markup[] = ' <div class="alert-message">' . htmlspecialchars($message) . '</div>';
266  $markup[] = ' </div>';
267  $markup[] = ' </div>';
268  $markup[] = '</div>';
269  $resultArray['html'] = implode(LF, $markup);
270  }
271 
272  $childArray = $this->renderChild($childData);
273  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childArray);
274 
275  // If this is a new record, add a pid value to store this record and the pointer value for the intermediate table
276  if ($childData['command'] === 'new') {
277  $comboFormFieldName = 'data[' . $childData['tableName'] . '][' . $childData['databaseRow']['uid'] . '][pid]';
278  $resultArray['html'] .= '<input type="hidden" name="' . htmlspecialchars($comboFormFieldName) . '" value="' . htmlspecialchars($childData['databaseRow']['pid']) . '" />';
279  }
280  // If the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation
281  if ($childData['command'] === 'new' || $parentConfig['foreign_unique'] === $parentConfig['foreign_selector']) {
282  $parentFormFieldName = 'data' . $appendFormFieldNames . '[' . $parentConfig['foreign_selector'] . ']';
283  $resultArray['html'] .= '<input type="hidden" name="' . htmlspecialchars($parentFormFieldName) . '" value="' . htmlspecialchars($childData['databaseRow']['uid']) . '" />';
284  }
285 
286  return $resultArray;
287  }
288 
296  protected function renderForeignRecordHeader(array $data)
297  {
298  $languageService = $this->getLanguageService();
299  $inlineConfig = $data['inlineParentConfig'];
300  $foreignTable = $inlineConfig['foreign_table'];
301  $rec = $data['databaseRow'];
302  // Init:
303  $domObjectId = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']);
304  $objectId = $domObjectId . '-' . $foreignTable . '-' . $rec['uid'];
305 
306  $recordTitle = $data['recordTitle'];
307  if (!empty($recordTitle)) {
308  // The user function may return HTML, therefore we can't escape it
309  if (empty($data['processedTca']['ctrl']['formattedLabel_userFunc'])) {
310  $recordTitle = BackendUtility::getRecordTitlePrep($recordTitle);
311  }
312  } else {
313  $recordTitle = '<em>[' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.no_title')) . ']</em>';
314  }
315 
316  $altText = BackendUtility::getRecordIconAltText($rec, $foreignTable);
317 
318  $iconImg = '<span title="' . $altText . '" id="' . htmlspecialchars($objectId) . '_icon' . '">' . $this->iconFactory->getIconForRecord($foreignTable, $rec, Icon::SIZE_SMALL)->render() . '</span>';
319  $label = '<span id="' . $objectId . '_label">' . $recordTitle . '</span>';
320  $ctrl = $this->renderForeignRecordHeaderControl($data);
321  $thumbnail = false;
322 
323  // Renders a thumbnail for the header
324  if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && !empty($inlineConfig['appearance']['headerThumbnail']['field'])) {
325  $fieldValue = $rec[$inlineConfig['appearance']['headerThumbnail']['field']];
326  $firstElement = array_shift(GeneralUtility::trimExplode('|', array_shift(GeneralUtility::trimExplode(',', $fieldValue))));
327  $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement));
328 
329  if (!empty($fileUid)) {
330  try {
331  $fileObject = ResourceFactory::getInstance()->getFileObject($fileUid);
332  } catch (\InvalidArgumentException $e) {
333  $fileObject = null;
334  }
335  if ($fileObject && $fileObject->isMissing()) {
336  $thumbnail .= '<span class="label label-danger">'
337  . htmlspecialchars(static::getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:warning.file_missing'))
338  . '</span>&nbsp;' . htmlspecialchars($fileObject->getName()) . '<br />';
339  } elseif ($fileObject) {
340  $imageSetup = $inlineConfig['appearance']['headerThumbnail'];
341  unset($imageSetup['field']);
342  if (!empty($rec['crop'])) {
343  $imageSetup['crop'] = $rec['crop'];
344  }
345  $imageSetup = array_merge(['width' => '45', 'height' => '45c'], $imageSetup);
346  $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, $imageSetup);
347  // Only use a thumbnail if the processing process was successful by checking if image width is set
348  if ($processedImage->getProperty('width')) {
349  $imageUrl = $processedImage->getPublicUrl(true);
350  $thumbnail = '<img src="' . $imageUrl . '" ' .
351  'width="' . $processedImage->getProperty('width') . '" ' .
352  'height="' . $processedImage->getProperty('height') . '" ' .
353  'alt="' . htmlspecialchars($altText) . '" ' .
354  'title="' . htmlspecialchars($altText) . '">';
355  }
356  }
357  }
358  }
359 
360  if (!empty($inlineConfig['appearance']['headerThumbnail']['field']) && $thumbnail) {
361  $mediaContainer = '<div class="form-irre-header-cell form-irre-header-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>';
362  } else {
363  $mediaContainer = '<div class="form-irre-header-cell form-irre-header-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>';
364  }
365  $header = $mediaContainer . '
366  <div class="form-irre-header-cell form-irre-header-body">' . $label . '</div>
367  <div class="form-irre-header-cell form-irre-header-control t3js-formengine-irre-control">' . $ctrl . '</div>';
368 
369  return $header;
370  }
371 
380  protected function renderForeignRecordHeaderControl(array $data)
381  {
382  $rec = $data['databaseRow'];
383  $inlineConfig = $data['inlineParentConfig'];
384  $foreignTable = $inlineConfig['foreign_table'];
385  $languageService = $this->getLanguageService();
386  $backendUser = $this->getBackendUserAuthentication();
387  // Initialize:
388  $cells = [];
389  $additionalCells = [];
390  $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
391  $isParentExisting = MathUtility::canBeInterpretedAsInteger($data['inlineParentUid']);
392  $tcaTableCtrl = $GLOBALS['TCA'][$foreignTable]['ctrl'];
393  $tcaTableCols = $GLOBALS['TCA'][$foreignTable]['columns'];
394  $isPagesTable = $foreignTable === 'pages';
395  $isSysFileReferenceTable = $foreignTable === 'sys_file_reference';
396  $enableManualSorting = $tcaTableCtrl['sortby'] || $inlineConfig['MM'] || !$data['isOnSymmetricSide']
397  && $inlineConfig['foreign_sortby'] || $data['isOnSymmetricSide'] && $inlineConfig['symmetric_sortby'];
398  $nameObject = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']);
399  $nameObjectFt = $nameObject . '-' . $foreignTable;
400  $nameObjectFtId = $nameObjectFt . '-' . $rec['uid'];
401  $calcPerms = $backendUser->calcPerms(BackendUtility::readPageAccess($rec['pid'], $backendUser->getPagePermsClause(1)));
402  // If the listed table is 'pages' we have to request the permission settings for each page:
403  $localCalcPerms = false;
404  if ($isPagesTable) {
405  $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $rec['uid']));
406  }
407  // This expresses the edit permissions for this particular element:
408  $permsEdit = $isPagesTable && $localCalcPerms & Permission::PAGE_EDIT || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT;
409  // Controls: Defines which controls should be shown
410  $enabledControls = $inlineConfig['appearance']['enabledControls'];
411  // Hook: Can disable/enable single controls for specific child records:
412  foreach ($this->hookObjects as $hookObj) {
414  $hookObj->renderForeignRecordHeaderControl_preProcess($data['inlineParentUid'], $foreignTable, $rec, $inlineConfig, $data['isInlineDefaultLanguageRecordInLocalizedParentContext'], $enabledControls);
415  }
416  if ($data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
417  $cells['localize.isLocalizable'] = '<span title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:localize.isLocalizable')) . '">'
418  . $this->iconFactory->getIcon('actions-edit-localize-status-low', Icon::SIZE_SMALL)->render()
419  . '</span>';
420  }
421  // "Info": (All records)
422  if ($enabledControls['info'] && !$isNewItem) {
423  if ($rec['table_local'] === 'sys_file') {
424  $uid = (int)substr($rec['uid_local'], 9);
425  $table = '_FILE';
426  } else {
427  $uid = $rec['uid'];
428  $table = $foreignTable;
429  }
430  $cells['info'] = '
431  <a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', ' . GeneralUtility::quoteJSvalue($uid) . '); return false;')) . '" title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:showInfo')) . '">
432  ' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '
433  </a>';
434  }
435  // If the table is NOT a read-only table, then show these links:
436  if (!$tcaTableCtrl['readOnly'] && !$data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
437  // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record):
438  if ($enabledControls['new'] && ($enableManualSorting || $tcaTableCtrl['useColumnsForDefaultValues'])) {
439  if (!$isPagesTable && $calcPerms & Permission::CONTENT_EDIT || $isPagesTable && $calcPerms & Permission::PAGE_NEW) {
440  $onClick = 'return inline.createNewRecord(' . GeneralUtility::quoteJSvalue($nameObjectFt) . ',' . GeneralUtility::quoteJSvalue($rec['uid']) . ')';
441  $style = '';
442  if ($inlineConfig['inline']['inlineNewButtonStyle']) {
443  $style = ' style="' . $inlineConfig['inline']['inlineNewButtonStyle'] . '"';
444  }
445  $cells['new'] = '
446  <a class="btn btn-default inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'] . '" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($languageService->sL(('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:new' . ($isPagesTable ? 'Page' : 'Record')))) . '" ' . $style . '>
447  ' . $this->iconFactory->getIcon('actions-' . ($isPagesTable ? 'page' : 'document') . '-new', Icon::SIZE_SMALL)->render() . '
448  </a>';
449  }
450  }
451  // "Up/Down" links
452  if ($enabledControls['sort'] && $permsEdit && $enableManualSorting) {
453  // Up
454  $onClick = 'return inline.changeSorting(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ', \'1\')';
455  $style = $inlineConfig['inline']['first'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
456  $cells['sort.up'] = '
457  <a class="btn btn-default sortingUp" href="#" onclick="' . htmlspecialchars($onClick) . '" ' . $style . ' title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:moveUp')) . '">
458  ' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '
459  </a>';
460  // Down
461  $onClick = 'return inline.changeSorting(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ', \'-1\')';
462  $style = $inlineConfig['inline']['last'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
463  $cells['sort.down'] = '
464  <a class="btn btn-default sortingDown" href="#" onclick="' . htmlspecialchars($onClick) . '" ' . $style . ' title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:moveDown')) . '">
465  ' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '
466  </a>';
467  }
468  // "Edit" link:
469  if (($rec['table_local'] === 'sys_file') && !$isNewItem) {
470  $sys_language_uid = 0;
471  if (!empty($rec['sys_language_uid'])) {
472  $sys_language_uid = $rec['sys_language_uid'][0];
473  }
474  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
475  ->getQueryBuilderForTable('sys_file_metadata');
476  $recordInDatabase = $queryBuilder
477  ->select('uid')
478  ->from('sys_file_metadata')
479  ->where(
480  $queryBuilder->expr()->eq(
481  'file',
482  $queryBuilder->createNamedParameter(substr($rec['uid_local'], 9), \PDO::PARAM_INT)
483  ),
484  $queryBuilder->expr()->eq(
485  'sys_language_uid',
486  $queryBuilder->createNamedParameter($sys_language_uid, \PDO::PARAM_INT)
487  )
488  )
489  ->setMaxResults(1)
490  ->execute()
491  ->fetch();
492  if ($backendUser->check('tables_modify', 'sys_file_metadata')) {
493  $url = BackendUtility::getModuleUrl('record_edit', [
494  'edit[sys_file_metadata][' . (int)$recordInDatabase['uid'] . ']' => 'edit',
495  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
496  ]);
497  $title = $languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.editMetadata');
498  $cells['editmetadata'] = '
499  <a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($title) . '">
500  ' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '
501  </a>';
502  }
503  }
504  // "Delete" link:
505  if ($enabledControls['delete'] && ($isPagesTable && $localCalcPerms & Permission::PAGE_DELETE
506  || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT
507  || $isSysFileReferenceTable && $calcPerms & Permission::PAGE_EDIT)
508  ) {
509  $title = htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:delete'));
510  $icon = $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render();
511  $cells['delete'] = '<a href="#" class="btn btn-default t3js-editform-delete-inline-record" data-objectid="' . htmlspecialchars($nameObjectFtId) . '" title="' . $title . '">' . $icon . '</a>';
512  }
513 
514  // "Hide/Unhide" links:
515  $hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
516  if ($enabledControls['hide'] && $permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $backendUser->check('non_exclude_fields', $foreignTable . ':' . $hiddenField))) {
517  $onClick = 'return inline.enableDisableRecord(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ',' .
518  GeneralUtility::quoteJSvalue($hiddenField) . ')';
519  $className = 't3js-' . $nameObjectFtId . '_disabled';
520  if ($rec[$hiddenField]) {
521  $title = htmlspecialchars($languageService->sL(('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:unHide' . ($isPagesTable ? 'Page' : ''))));
522  $cells['hide.unhide'] = '
523  <a class="btn btn-default hiddenHandle ' . $className . '" href="#" onclick="'
524  . htmlspecialchars($onClick) . '"' . 'title="' . $title . '">' .
525  $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '
526  </a>';
527  } else {
528  $title = htmlspecialchars($languageService->sL(('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:hide' . ($isPagesTable ? 'Page' : ''))));
529  $cells['hide.hide'] = '
530  <a class="btn btn-default hiddenHandle ' . $className . '" href="#" onclick="'
531  . htmlspecialchars($onClick) . '"' . 'title="' . $title . '">' .
532  $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '
533  </a>';
534  }
535  }
536  // Drag&Drop Sorting: Sortable handler for script.aculo.us
537  if ($enabledControls['dragdrop'] && $permsEdit && $enableManualSorting && $inlineConfig['appearance']['useSortable']) {
538  $additionalCells['dragdrop'] = '
539  <span class="btn btn-default sortableHandle" data-id="' . htmlspecialchars($rec['uid']) . '" title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move')) . '">
540  ' . $this->iconFactory->getIcon('actions-move-move', Icon::SIZE_SMALL)->render() . '
541  </span>';
542  }
543  } elseif ($data['isInlineDefaultLanguageRecordInLocalizedParentContext'] && $isParentExisting) {
544  if ($enabledControls['localize'] && $data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
545  $onClick = 'inline.synchronizeLocalizeRecords(' . GeneralUtility::quoteJSvalue($nameObjectFt) . ', ' . GeneralUtility::quoteJSvalue($rec['uid']) . ');';
546  $cells['localize'] = '
547  <a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_misc.xlf:localize')) . '">
548  ' . $this->iconFactory->getIcon('actions-document-localize', Icon::SIZE_SMALL)->render() . '
549  </a>';
550  }
551  }
552  // If the record is edit-locked by another user, we will show a little warning sign:
553  if ($lockInfo = BackendUtility::isRecordLocked($foreignTable, $rec['uid'])) {
554  $cells['locked'] = '
555  <a class="btn btn-default" href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . ');return false;">
556  ' . '<span title="' . htmlspecialchars($lockInfo['msg']) . '">' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</span>' . '
557  </a>';
558  }
559  // Hook: Post-processing of single controls for specific child records:
560  foreach ($this->hookObjects as $hookObj) {
561  $hookObj->renderForeignRecordHeaderControl_postProcess($data['inlineParentUid'], $foreignTable, $rec, $inlineConfig, $data['isInlineDefaultLanguageRecordInLocalizedParentContext'], $cells);
562  }
563 
564  $out = '';
565  if (!empty($cells)) {
566  $out .= ' <div class="btn-group btn-group-sm" role="group">' . implode('', $cells) . '</div>';
567  }
568  if (!empty($additionalCells)) {
569  $out .= ' <div class="btn-group btn-group-sm" role="group">' . implode('', $additionalCells) . '</div>';
570  }
571  return $out;
572  }
573 
580  protected function normalizeUid($string)
581  {
582  $parts = explode('|', $string);
583  return $parts[0];
584  }
585 
594  protected function initHookObjects()
595  {
596  $this->hookObjects = [];
597  if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'])) {
598  $tceformsInlineHook = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'];
599  if (is_array($tceformsInlineHook)) {
600  foreach ($tceformsInlineHook as $classData) {
601  $processObject = GeneralUtility::getUserObj($classData);
602  if (!$processObject instanceof InlineElementHookInterface) {
603  throw new \UnexpectedValueException($classData . ' must implement interface ' . InlineElementHookInterface::class, 1202072000);
604  }
605  $this->hookObjects[] = $processObject;
606  }
607  }
608  }
609  }
610 
614  protected function getBackendUserAuthentication()
615  {
616  return $GLOBALS['BE_USER'];
617  }
618 
622  protected function getLanguageService()
623  {
624  return $GLOBALS['LANG'];
625  }
626 }
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static getRecord($table, $uid, $fields= '*', $where= '', $useDeleteClause=true)
mergeChildReturnIntoExistingResult(array $existing, array $childReturn)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)