TYPO3 CMS  TYPO3_8-7
TableWizard.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
22 
28 {
34  public function render()
35  {
36  $options = $this->data['renderData']['fieldControlOptions'];
37  $parameterArray = $this->data['parameterArray'];
38  $itemName = $parameterArray['itemFormElName'];
39  $row = $this->data['databaseRow'];
40 
41  if (!MathUtility::canBeInterpretedAsInteger($row['uid'])) {
42  return [];
43  }
44 
45  // Handle options and fallback
46  $title = $options['title'] ?? 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.tableWizard';
47  $xmlOutput = isset($options['xmlOutput']) ? (int)$options['xmlOutput'] : 0;
48  $numNewRows = isset($options['numNewRows']) ? (int)$options['numNewRows'] : 5;
49 
50  $prefixOfFormElName = 'data[' . $this->data['tableName'] . '][' . $this->data['databaseRow']['uid'] . '][' . $this->data['fieldName'] . ']';
51  $flexFormPath = '';
52  if (GeneralUtility::isFirstPartOfStr($itemName, $prefixOfFormElName)) {
53  $flexFormPath = str_replace('][', '/', substr($itemName, strlen($prefixOfFormElName) + 1, -1));
54  }
55 
56  $urlParameters = [
57  'P' => [
58  'params' => [
59  'xmlOutput' => $xmlOutput,
60  'numNewRows' => $numNewRows,
61  ],
62  'table' => $this->data['tableName'],
63  'field' => $this->data['fieldName'],
64  'uid' => $this->data['databaseRow']['uid'],
65  'flexFormPath' => $flexFormPath,
66  'returnUrl' => $this->data['returnUrl'],
67  ],
68  ];
69 
70  $onClick = [];
71  $onClick[] = 'this.blur();';
72  $onClick[] = 'return !TBE_EDITOR.isFormChanged();';
73 
74  return [
75  'iconIdentifier' => 'content-table',
76  'title' => $title,
77  'linkAttributes' => [
78  'onClick' => implode('', $onClick),
79  'href' => BackendUtility::getModuleUrl('wizard_table', $urlParameters),
80  ],
81  ];
82  }
83 }
static isFirstPartOfStr($str, $partStr)