TYPO3 CMS  TYPO3_7-6
InlineRecordContainer.php
Go to the documentation of this file.
1 <?php
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/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  $markup[] = '<div class="alert alert-warning">';
255  $markup[] = ' <div class="media">';
256  $markup[] = ' <div class="media-left">';
257  $markup[] = ' <span class="fa-stack fa-lg">';
258  $markup[] = ' <i class="fa fa-circle fa-stack-2x"></i>';
259  $markup[] = ' <i class="fa fa-exclamation fa-stack-1x"></i>';
260  $markup[] = ' </span>';
261  $markup[] = ' </div>';
262  $markup[] = ' <div class="media-body">';
263  $markup[] = ' <div class="alert-message">' . htmlspecialchars($message) . '</div>';
264  $markup[] = ' </div>';
265  $markup[] = ' </div>';
266  $markup[] = '</div>';
267  $resultArray['html'] = implode(LF, $markup);
268  }
269 
270  $childArray = $this->renderChild($childData);
271  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childArray);
272 
273  // If this is a new record, add a pid value to store this record and the pointer value for the intermediate table
274  if ($childData['command'] === 'new') {
275  $comboFormFieldName = 'data[' . $childData['tableName'] . '][' . $childData['databaseRow']['uid'] . '][pid]';
276  $resultArray['html'] .= '<input type="hidden" name="' . htmlspecialchars($comboFormFieldName) . '" value="' . htmlspecialchars($childData['databaseRow']['pid']) . '" />';
277  }
278  // If the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation
279  if ($childData['command'] === 'new' || $parentConfig['foreign_unique'] === $parentConfig['foreign_selector']) {
280  $parentFormFieldName = 'data' . $appendFormFieldNames . '[' . $parentConfig['foreign_selector'] . ']';
281  $resultArray['html'] .= '<input type="hidden" name="' . htmlspecialchars($parentFormFieldName) . '" value="' . htmlspecialchars($childData['databaseRow']['uid']) . '" />';
282  }
283 
284  return $resultArray;
285  }
286 
294  protected function renderForeignRecordHeader(array $data)
295  {
296  $languageService = $this->getLanguageService();
297  $inlineConfig = $data['inlineParentConfig'];
298  $foreignTable = $inlineConfig['foreign_table'];
299  $rec = $data['databaseRow'];
300  // Init:
301  $domObjectId = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']);
302  $objectId = $domObjectId . '-' . $foreignTable . '-' . $rec['uid'];
303 
304  $recordTitle = $data['recordTitle'];
305  if (!empty($recordTitle)) {
306  // The user function may return HTML, therefore we can't escape it
307  if (empty($data['processedTca']['ctrl']['formattedLabel_userFunc'])) {
308  $recordTitle = BackendUtility::getRecordTitlePrep($recordTitle);
309  }
310  } else {
311  $recordTitle = '<em>[' . htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title')) . ']</em>';
312  }
313 
314  $altText = BackendUtility::getRecordIconAltText($rec, $foreignTable);
315 
316  $iconImg = '<span title="' . $altText . '" id="' . htmlspecialchars($objectId) . '_icon' . '">' . $this->iconFactory->getIconForRecord($foreignTable, $rec, Icon::SIZE_SMALL)->render() . '</span>';
317  $label = '<span id="' . $objectId . '_label">' . $recordTitle . '</span>';
318  $ctrl = $this->renderForeignRecordHeaderControl($data);
319  $thumbnail = false;
320 
321  // Renders a thumbnail for the header
322  if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] && !empty($inlineConfig['appearance']['headerThumbnail']['field'])) {
323  $fieldValue = $rec[$inlineConfig['appearance']['headerThumbnail']['field']];
324  $firstElement = array_shift(GeneralUtility::trimExplode('|', array_shift(GeneralUtility::trimExplode(',', $fieldValue))));
325  $fileUid = array_pop(BackendUtility::splitTable_Uid($firstElement));
326 
327  if (!empty($fileUid)) {
328  try {
329  $fileObject = ResourceFactory::getInstance()->getFileObject($fileUid);
330  } catch (\InvalidArgumentException $e) {
331  $fileObject = null;
332  }
333  if ($fileObject && $fileObject->isMissing()) {
334  $thumbnail .= '<span class="label label-danger">'
335  . htmlspecialchars(static::getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing'))
336  . '</span>&nbsp;' . htmlspecialchars($fileObject->getName()) . '<br />';
337  } elseif ($fileObject) {
338  $imageSetup = $inlineConfig['appearance']['headerThumbnail'];
339  unset($imageSetup['field']);
340  if (!empty($rec['crop'])) {
341  $imageSetup['crop'] = $rec['crop'];
342  }
343  $imageSetup = array_merge(['width' => '45', 'height' => '45c'], $imageSetup);
344  $processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, $imageSetup);
345  // Only use a thumbnail if the processing process was successful by checking if image width is set
346  if ($processedImage->getProperty('width')) {
347  $imageUrl = $processedImage->getPublicUrl(true);
348  $thumbnail = '<img src="' . $imageUrl . '" ' .
349  'width="' . $processedImage->getProperty('width') . '" ' .
350  'height="' . $processedImage->getProperty('height') . '" ' .
351  'alt="' . htmlspecialchars($altText) . '" ' .
352  'title="' . htmlspecialchars($altText) . '">';
353  }
354  }
355  }
356  }
357 
358  if (!empty($inlineConfig['appearance']['headerThumbnail']['field']) && $thumbnail) {
359  $mediaContainer = '<div class="form-irre-header-cell form-irre-header-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</div>';
360  } else {
361  $mediaContainer = '<div class="form-irre-header-cell form-irre-header-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</div>';
362  }
363  $header = $mediaContainer . '
364  <div class="form-irre-header-cell form-irre-header-body">' . $label . '</div>
365  <div class="form-irre-header-cell form-irre-header-control t3js-formengine-irre-control">' . $ctrl . '</div>';
366 
367  return $header;
368  }
369 
378  protected function renderForeignRecordHeaderControl(array $data)
379  {
380  $rec = $data['databaseRow'];
381  $inlineConfig = $data['inlineParentConfig'];
382  $foreignTable = $inlineConfig['foreign_table'];
383  $languageService = $this->getLanguageService();
384  $backendUser = $this->getBackendUserAuthentication();
385  // Initialize:
386  $cells = [];
387  $additionalCells = [];
388  $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
389  $isParentExisting = MathUtility::canBeInterpretedAsInteger($data['inlineParentUid']);
390  $tcaTableCtrl = $GLOBALS['TCA'][$foreignTable]['ctrl'];
391  $tcaTableCols = $GLOBALS['TCA'][$foreignTable]['columns'];
392  $isPagesTable = $foreignTable === 'pages';
393  $isSysFileReferenceTable = $foreignTable === 'sys_file_reference';
394  $enableManualSorting = $tcaTableCtrl['sortby'] || $inlineConfig['MM'] || !$data['isOnSymmetricSide']
395  && $inlineConfig['foreign_sortby'] || $data['isOnSymmetricSide'] && $inlineConfig['symmetric_sortby'];
396  $nameObject = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($data['inlineFirstPid']);
397  $nameObjectFt = $nameObject . '-' . $foreignTable;
398  $nameObjectFtId = $nameObjectFt . '-' . $rec['uid'];
399  $calcPerms = $backendUser->calcPerms(BackendUtility::readPageAccess($rec['pid'], $backendUser->getPagePermsClause(1)));
400  // If the listed table is 'pages' we have to request the permission settings for each page:
401  $localCalcPerms = false;
402  if ($isPagesTable) {
403  $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $rec['uid']));
404  }
405  // This expresses the edit permissions for this particular element:
406  $permsEdit = $isPagesTable && $localCalcPerms & Permission::PAGE_EDIT || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT;
407  // Controls: Defines which controls should be shown
408  $enabledControls = $inlineConfig['appearance']['enabledControls'];
409  // Hook: Can disable/enable single controls for specific child records:
410  foreach ($this->hookObjects as $hookObj) {
412  $hookObj->renderForeignRecordHeaderControl_preProcess($data['inlineParentUid'], $foreignTable, $rec, $inlineConfig, $data['isInlineDefaultLanguageRecordInLocalizedParentContext'], $enabledControls);
413  }
414  if ($data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
415  $cells['localize.isLocalizable'] = '<span title="' . $languageService->sL('LLL:EXT:lang/locallang_misc.xlf:localize.isLocalizable', true) . '">'
416  . $this->iconFactory->getIcon('actions-edit-localize-status-low', Icon::SIZE_SMALL)->render()
417  . '</span>';
418  }
419  // "Info": (All records)
420  if ($enabledControls['info'] && !$isNewItem) {
421  if ($rec['table_local'] === 'sys_file') {
422  $uid = (int)substr($rec['uid_local'], 9);
423  $table = '_FILE';
424  } else {
425  $uid = $rec['uid'];
426  $table = $foreignTable;
427  }
428  $cells['info'] = '
429  <a class="btn btn-default" href="#" onclick="' . htmlspecialchars(('top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', ' . GeneralUtility::quoteJSvalue($uid) . '); return false;')) . '" title="' . $languageService->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:showInfo', true) . '">
430  ' . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '
431  </a>';
432  }
433  // If the table is NOT a read-only table, then show these links:
434  if (!$tcaTableCtrl['readOnly'] && !$data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
435  // "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):
436  if ($enabledControls['new'] && ($enableManualSorting || $tcaTableCtrl['useColumnsForDefaultValues'])) {
437  if (!$isPagesTable && $calcPerms & Permission::CONTENT_EDIT || $isPagesTable && $calcPerms & Permission::PAGE_NEW) {
438  $onClick = 'return inline.createNewRecord(' . GeneralUtility::quoteJSvalue($nameObjectFt) . ',' . GeneralUtility::quoteJSvalue($rec['uid']) . ')';
439  $style = '';
440  if ($inlineConfig['inline']['inlineNewButtonStyle']) {
441  $style = ' style="' . $inlineConfig['inline']['inlineNewButtonStyle'] . '"';
442  }
443  $cells['new'] = '
444  <a class="btn btn-default inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'] . '" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $languageService->sL(('LLL:EXT:lang/locallang_mod_web_list.xlf:new' . ($isPagesTable ? 'Page' : 'Record')), true) . '" ' . $style . '>
445  ' . $this->iconFactory->getIcon('actions-' . ($isPagesTable ? 'page' : 'document') . '-new', Icon::SIZE_SMALL)->render() . '
446  </a>';
447  }
448  }
449  // "Up/Down" links
450  if ($enabledControls['sort'] && $permsEdit && $enableManualSorting) {
451  // Up
452  $onClick = 'return inline.changeSorting(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ', \'1\')';
453  $style = $inlineConfig['inline']['first'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
454  $cells['sort.up'] = '
455  <a class="btn btn-default sortingUp" href="#" onclick="' . htmlspecialchars($onClick) . '" ' . $style . ' title="' . $languageService->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:moveUp', true) . '">
456  ' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '
457  </a>';
458  // Down
459  $onClick = 'return inline.changeSorting(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ', \'-1\')';
460  $style = $inlineConfig['inline']['last'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
461  $cells['sort.down'] = '
462  <a class="btn btn-default sortingDown" href="#" onclick="' . htmlspecialchars($onClick) . '" ' . $style . ' title="' . $languageService->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:moveDown', true) . '">
463  ' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '
464  </a>';
465  }
466  // "Edit" link:
467  if (($rec['table_local'] === 'sys_file') && !$isNewItem && $backendUser->check('tables_modify', 'sys_file_metadata')) {
468  $sys_language_uid = 0;
469  if (!empty($rec['sys_language_uid'])) {
470  $sys_language_uid = $rec['sys_language_uid'][0];
471  }
472  $recordInDatabase = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
473  'uid',
474  'sys_file_metadata',
475  'file = ' . (int)substr($rec['uid_local'], 9) . ' AND sys_language_uid = ' . $sys_language_uid
476  );
477  if (!empty($recordInDatabase)) {
478  $url = BackendUtility::getModuleUrl('record_edit', [
479  'edit[sys_file_metadata][' . (int)$recordInDatabase['uid'] . ']' => 'edit',
480  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
481  ]);
482  $title = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:cm.editMetadata');
483  $cells['editmetadata'] = '
484  <a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($title) . '">
485  ' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '
486  </a>';
487  }
488  }
489  // "Delete" link:
490  if ($enabledControls['delete'] && ($isPagesTable && $localCalcPerms & Permission::PAGE_DELETE
491  || !$isPagesTable && $calcPerms & Permission::CONTENT_EDIT
492  || $isSysFileReferenceTable && $calcPerms & Permission::PAGE_EDIT)
493  ) {
494  $title = $languageService->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:delete', true);
495  $icon = $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render();
496  $cells['delete'] = '<a href="#" class="btn btn-default t3js-editform-delete-inline-record" data-objectid="' . htmlspecialchars($nameObjectFtId) . '" title="' . $title . '">' . $icon . '</a>';
497  }
498 
499  // "Hide/Unhide" links:
500  $hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
501  if ($enabledControls['hide'] && $permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $backendUser->check('non_exclude_fields', $foreignTable . ':' . $hiddenField))) {
502  $onClick = 'return inline.enableDisableRecord(' . GeneralUtility::quoteJSvalue($nameObjectFtId) . ',' .
503  GeneralUtility::quoteJSvalue($hiddenField) . ')';
504  $className = 't3js-' . $nameObjectFtId . '_disabled';
505  if ($rec[$hiddenField]) {
506  $title = $languageService->sL(('LLL:EXT:lang/locallang_mod_web_list.xlf:unHide' . ($isPagesTable ? 'Page' : '')), true);
507  $cells['hide.unhide'] = '
508  <a class="btn btn-default hiddenHandle ' . $className . '" href="#" onclick="'
509  . htmlspecialchars($onClick) . '"' . 'title="' . $title . '">' .
510  $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '
511  </a>';
512  } else {
513  $title = $languageService->sL(('LLL:EXT:lang/locallang_mod_web_list.xlf:hide' . ($isPagesTable ? 'Page' : '')), true);
514  $cells['hide.hide'] = '
515  <a class="btn btn-default hiddenHandle ' . $className . '" href="#" onclick="'
516  . htmlspecialchars($onClick) . '"' . 'title="' . $title . '">' .
517  $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '
518  </a>';
519  }
520  }
521  // Drag&Drop Sorting: Sortable handler for script.aculo.us
522  if ($enabledControls['dragdrop'] && $permsEdit && $enableManualSorting && $inlineConfig['appearance']['useSortable']) {
523  $additionalCells['dragdrop'] = '
524  <span class="btn btn-default sortableHandle" data-id="' . htmlspecialchars($rec['uid']) . '" title="' . $languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.move', true) . '">
525  ' . $this->iconFactory->getIcon('actions-move-move', Icon::SIZE_SMALL)->render() . '
526  </span>';
527  }
528  } elseif ($data['isInlineDefaultLanguageRecordInLocalizedParentContext'] && $isParentExisting) {
529  if ($enabledControls['localize'] && $data['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
530  $onClick = 'inline.synchronizeLocalizeRecords(' . GeneralUtility::quoteJSvalue($nameObjectFt) . ', ' . GeneralUtility::quoteJSvalue($rec['uid']) . ');';
531  $cells['localize'] = '
532  <a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $languageService->sL('LLL:EXT:lang/locallang_misc.xlf:localize', true) . '">
533  ' . $this->iconFactory->getIcon('actions-document-localize', Icon::SIZE_SMALL)->render() . '
534  </a>';
535  }
536  }
537  // If the record is edit-locked by another user, we will show a little warning sign:
538  if ($lockInfo = BackendUtility::isRecordLocked($foreignTable, $rec['uid'])) {
539  $cells['locked'] = '
540  <a class="btn btn-default" href="#" onclick="alert(' . GeneralUtility::quoteJSvalue($lockInfo['msg']) . ');return false;">
541  ' . '<span title="' . htmlspecialchars($lockInfo['msg']) . '">' . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</span>' . '
542  </a>';
543  }
544  // Hook: Post-processing of single controls for specific child records:
545  foreach ($this->hookObjects as $hookObj) {
546  $hookObj->renderForeignRecordHeaderControl_postProcess($data['inlineParentUid'], $foreignTable, $rec, $inlineConfig, $data['isInlineDefaultLanguageRecordInLocalizedParentContext'], $cells);
547  }
548 
549  $out = '';
550  if (!empty($cells)) {
551  $out .= ' <div class="btn-group btn-group-sm" role="group">' . implode('', $cells) . '</div>';
552  }
553  if (!empty($additionalCells)) {
554  $out .= ' <div class="btn-group btn-group-sm" role="group">' . implode('', $additionalCells) . '</div>';
555  }
556  return $out;
557  }
558 
565  protected function normalizeUid($string)
566  {
567  $parts = explode('|', $string);
568  return $parts[0];
569  }
570 
579  protected function initHookObjects()
580  {
581  $this->hookObjects = [];
582  if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'])) {
583  $tceformsInlineHook = &$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'];
584  if (is_array($tceformsInlineHook)) {
585  foreach ($tceformsInlineHook as $classData) {
586  $processObject = GeneralUtility::getUserObj($classData);
587  if (!$processObject instanceof InlineElementHookInterface) {
588  throw new \UnexpectedValueException($classData . ' must implement interface ' . InlineElementHookInterface::class, 1202072000);
589  }
590  $this->hookObjects[] = $processObject;
591  }
592  }
593  }
594  }
595 
599  protected function getBackendUserAuthentication()
600  {
601  return $GLOBALS['BE_USER'];
602  }
603 
607  protected function getDatabaseConnection()
608  {
609  return $GLOBALS['TYPO3_DB'];
610  }
611 
615  protected function getLanguageService()
616  {
617  return $GLOBALS['LANG'];
618  }
619 }
static readPageAccess($id, $perms_clause)
mergeChildReturnIntoExistingResult(array $existing, array $childReturn)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static getRecordIconAltText($row, $table='pages')
$uid
Definition: server.php:38
static getRecordTitlePrep($title, $titleLength=0)
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']