2 namespace TYPO3\CMS\Backend\Controller\Wizard;
112 parent::__construct();
130 $this->xmlStorage = $this->P[
'params'][
'xmlOutput'];
133 $this->inputStyle = isset($this->TABLECFG[
'textFields']) ? (bool)$this->TABLECFG[
'textFields'] :
true;
136 $this->tableParsing_delimiter =
'|';
137 $this->tableParsing_quote =
'';
151 $response->
getBody()->write($this->moduleTemplate->renderContent());
162 $this->content .=
'<form action="' . htmlspecialchars($rUri) .
'" method="post" id="TableController" name="wizardForm">';
163 if ($this->P[
'table'] && $this->P[
'field'] && $this->P[
'uid']) {
164 $this->content .=
'<h2>' . $this->
getLanguageService()->getLL(
'table_title',
true) .
'</h2>'
167 $this->content .=
'<h2>' . $this->
getLanguageService()->getLL(
'table_title',
true) .
'</h2>'
168 .
'<div><span class="text-danger">' . $this->
getLanguageService()->getLL(
'table_noData',
true) .
'</span></div>';;
170 $this->content .=
'</form>';
174 $this->moduleTemplate->setContent($this->content);
194 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
195 if ($this->P[
'table'] && $this->P[
'field'] && $this->P[
'uid']) {
197 $cshButton = $buttonBar->makeHelpButton()
198 ->setModuleName(
'xMOD_csh_corebe')
199 ->setFieldName(
'wizard_table_wiz');
200 $buttonBar->addButton($cshButton);
202 $closeButton = $buttonBar->makeLinkButton()
203 ->setHref($this->P[
'returnUrl'])
204 ->setTitle($this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:rm.closeDoc',
true))
205 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-document-close',
Icon::SIZE_SMALL));
206 $buttonBar->addButton($closeButton);
208 $saveButton = $buttonBar->makeInputButton()
209 ->setName(
'_savedok')
211 ->setForm(
'TableController')
212 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-document-save',
Icon::SIZE_SMALL))
213 ->setTitle($this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:rm.saveDoc',
true));
215 $saveAndCloseButton = $buttonBar->makeInputButton()
216 ->setName(
'_saveandclosedok')
218 ->setForm(
'TableController')
219 ->setTitle($this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc',
true))
220 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
221 'actions-document-save-close',
224 $splitButtonElement = $buttonBar->makeSplitButton()
225 ->addItem($saveButton)
226 ->addItem($saveAndCloseButton);
230 $reloadButton = $buttonBar->makeInputButton()
231 ->setName(
'_refresh')
233 ->setForm(
'TableController')
235 ->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-refresh',
Icon::SIZE_SMALL));
236 $buttonBar->addButton($reloadButton);
249 throw new \RuntimeException(
'Wizard Error: No access', 1349692692);
253 if (!is_array($row)) {
254 throw new \RuntimeException(
'Wizard Error: No reference to record', 1294587125);
258 $tableCfgArray = $this->getConfigCode($row);
279 public function getConfigCode($row)
283 if (is_array($flexForm)) {
284 $this->tableParsing_quote = $flexForm[
'data'][
's_parsing'][
'lDEF'][
'tableparsing_quote'][
'vDEF'] ? chr((
int)$flexForm[
'data'][
's_parsing'][
'lDEF'][
'tableparsing_quote'][
'vDEF']) :
'';
285 $this->tableParsing_delimiter = $flexForm[
'data'][
's_parsing'][
'lDEF'][
'tableparsing_delimiter'][
'vDEF'] ? chr((
int)$flexForm[
'data'][
's_parsing'][
'lDEF'][
'tableparsing_delimiter'][
'vDEF']) :
'|';
288 if (isset($this->TABLECFG[
'c'])) {
292 if ($this->xmlStorage) {
296 $configuration = $this->TABLECFG[
'c'];
305 if ($_POST[
'_savedok'] || $_POST[
'_saveandclosedok']) {
309 $dataHandler->stripslashes_values =
false;
312 if ($this->P[
'flexFormPath']) {
317 $flexFormTools->setArrayValueByPath($this->P[
'flexFormPath'], $currentFlexFormData, $bodyText);
318 $data[$this->P[
'table']][$this->P[
'uid']][$this->P[
'field']] = $currentFlexFormData;
320 $data[$this->P[
'table']][$this->P[
'uid']][$this->P[
'field']] = $bodyText;
323 $dataHandler->start($data, array());
324 $dataHandler->process_datamap();
326 if ($_POST[
'_saveandclosedok']) {
332 if ($this->xmlStorage) {
335 if ($this->P[
'flexFormPath']) {
340 $configuration = $flexFormTools->getArrayValueByPath(
341 $this->P[
'flexFormPath'],
347 $configuration = $this->
cfgString2CfgArray($row[$this->P[
'field']], $row[$this->colsFieldName]);
350 $configuration = is_array($configuration) ? $configuration : array();
352 return $configuration;
367 $countLines = count($configuration);
368 foreach ($configuration as $cellArr) {
369 if (is_array($cellArr)) {
374 foreach ($cellArr as $cellContent) {
375 if ($this->inputStyle) {
376 $cells[] =
'<input class="form-control" type="text" name="TABLE[c][' . ($k + 1) * 2 .
'][' . ($a + 1) * 2 .
']" value="' . htmlspecialchars($cellContent) .
'" />';
378 $cellContent = preg_replace(
'/<br[ ]?[\\/]?>/i', LF, $cellContent);
379 $cells[] =
'<textarea class="form-control" rows="6" name="TABLE[c][' . ($k + 1) * 2 .
'][' . ($a + 1) * 2 .
']">' . htmlspecialchars($cellContent) .
'</textarea>';
386 $onClick =
' onclick="' . htmlspecialchars($onClick) .
'"';
389 $ctrl .=
'<button class="btn btn-default" name="TABLE[row_up][' . ($k + 1) * 2 .
']" title="' . $this->
getLanguageService()->getLL(
'table_up',
true) .
'"' . $onClick .
'><span class="t3-icon fa fa-fw fa-angle-up"></span></button>';
391 $ctrl .=
'<button class="btn btn-default" name="TABLE[row_bottom][' . ($k + 1) * 2 .
']" title="' . $this->
getLanguageService()->getLL(
'table_bottom',
true) .
'"' . $onClick .
'><span class="t3-icon fa fa-fw fa-angle-double-down"></span></button>';
393 if ($k + 1 !== $countLines) {
394 $ctrl .=
'<button class="btn btn-default" name="TABLE[row_down][' . ($k + 1) * 2 .
']" title="' . $this->
getLanguageService()->getLL(
'table_down',
true) .
'"' . $onClick .
'><span class="t3-icon fa fa-fw fa-angle-down"></span></button>';
396 $ctrl .=
'<button class="btn btn-default" name="TABLE[row_top][' . ($k + 1) * 2 .
']" title="' . $this->
getLanguageService()->getLL(
'table_top',
true) .
'"' . $onClick .
'><span class="t3-icon fa fa-fw fa-angle-double-up"></span></button>';
398 $ctrl .=
'<button class="btn btn-default" name="TABLE[row_remove][' . ($k + 1) * 2 .
']" title="' . $this->
getLanguageService()->getLL(
'table_removeRow',
true) .
'"' . $onClick .
'><span class="t3-icon fa fa-fw fa-trash"></span></button>';
399 $ctrl .=
'<button class="btn btn-default" name="TABLE[row_add][' . ($k + 1) * 2 .
']" title="' . $this->
getLanguageService()->getLL(
'table_addRow',
true) .
'"' . $onClick .
'><span class="t3-icon fa fa-fw fa-plus"></span></button>';
403 <a name="ANC_' . ($k + 1) * 2 .
'"></a>
404 <span class="btn-group' . ($this->inputStyle ?
'' :
'-vertical') .
'">' . $ctrl .
'</span>
406 <td>' . implode(
'</td>
407 <td>', $cells) .
'</td>
417 $firstRow = reset($configuration);
418 if (is_array($firstRow)) {
419 $cols = count($firstRow);
420 for ($a = 1; $a <= $cols; $a++) {
424 $ctrl .=
'<button class="btn btn-default" name="TABLE[col_left][' . $b .
']" title="' . $this->
getLanguageService()->getLL(
'table_left',
true) .
'"><span class="t3-icon fa fa-fw fa-angle-left"></span></button>';
426 $ctrl .=
'<button class="btn btn-default" name="TABLE[col_end][' . $b .
']" title="' . $this->
getLanguageService()->getLL(
'table_end',
true) .
'"><span class="t3-icon fa fa-fw fa-angle-double-right"></span></button>';
429 $ctrl .=
'<button class="btn btn-default" name="TABLE[col_right][' . $b .
']" title="' . $this->
getLanguageService()->getLL(
'table_right',
true) .
'"><span class="t3-icon fa fa-fw fa-angle-right"></span></button>';
431 $ctrl .=
'<button class="btn btn-default" name="TABLE[col_start][' . $b .
']" title="' . $this->
getLanguageService()->getLL(
'table_start',
true) .
'"><span class="t3-icon fa fa-fw fa-angle-double-left"></span></button>';
433 $ctrl .=
'<button class="btn btn-default" name="TABLE[col_remove][' . $b .
']" title="' . $this->
getLanguageService()->getLL(
'table_removeColumn',
true) .
'"><span class="t3-icon fa fa-fw fa-trash"></span></button>';
434 $ctrl .=
'<button class="btn btn-default" name="TABLE[col_add][' . $b .
']" title="' . $this->
getLanguageService()->getLL(
'table_addColumn',
true) .
'"><span class="t3-icon fa fa-fw fa-plus"></span></button>';
435 $cells[] =
'<span class="btn-group">' . $ctrl .
'</span>';
440 <td>' . implode(
'</td>
441 <td>', $cells) .
'</td>
446 $addSubmitOnClick =
'onclick="document.getElementById(\'TableController\').submit();"';
450 <!-- Table wizard -->
451 <div class="table-fit table-fit-inline-block">
452 <table id="typo3-tablewizard" class="table table-center">
453 ' . implode(
'', $tRows) .
'
459 <!-- Input mode check box: -->
460 <div class="checkbox">
461 <input type="hidden" name="TABLE[textFields]" value="0" />
462 <label for="textFields">
463 <input type="checkbox" ' . $addSubmitOnClick .
' name="TABLE[textFields]" id="textFields" value="1"' . ($this->inputStyle ?
' checked="checked"' :
'') .
' />
479 if ($this->TABLECFG[
'col_remove']) {
480 $kk = key($this->TABLECFG[
'col_remove']);
482 }
elseif ($this->TABLECFG[
'col_add']) {
483 $kk = key($this->TABLECFG[
'col_add']);
485 }
elseif ($this->TABLECFG[
'col_start']) {
486 $kk = key($this->TABLECFG[
'col_start']);
488 }
elseif ($this->TABLECFG[
'col_end']) {
489 $kk = key($this->TABLECFG[
'col_end']);
491 }
elseif ($this->TABLECFG[
'col_left']) {
492 $kk = key($this->TABLECFG[
'col_left']);
494 }
elseif ($this->TABLECFG[
'col_right']) {
495 $kk = key($this->TABLECFG[
'col_right']);
497 }
elseif ($this->TABLECFG[
'row_remove']) {
498 $kk = key($this->TABLECFG[
'row_remove']);
500 }
elseif ($this->TABLECFG[
'row_add']) {
501 $kk = key($this->TABLECFG[
'row_add']);
503 }
elseif ($this->TABLECFG[
'row_top']) {
504 $kk = key($this->TABLECFG[
'row_top']);
506 }
elseif ($this->TABLECFG[
'row_bottom']) {
507 $kk = key($this->TABLECFG[
'row_bottom']);
509 }
elseif ($this->TABLECFG[
'row_up']) {
510 $kk = key($this->TABLECFG[
'row_up']);
512 }
elseif ($this->TABLECFG[
'row_down']) {
513 $kk = key($this->TABLECFG[
'row_down']);
523 unset($this->TABLECFG[
'c'][$kk]);
531 if (!isset($this->TABLECFG[
'c'][($kk + $a)])) {
532 $this->TABLECFG[
'c'][$kk + $a] = array();
539 $this->TABLECFG[
'c'][1] = $this->TABLECFG[
'c'][$kk];
540 unset($this->TABLECFG[
'c'][$kk]);
543 $this->TABLECFG[
'c'][10000000] = $this->TABLECFG[
'c'][$kk];
544 unset($this->TABLECFG[
'c'][$kk]);
547 $this->TABLECFG[
'c'][$kk - 3] = $this->TABLECFG[
'c'][$kk];
548 unset($this->TABLECFG[
'c'][$kk]);
551 $this->TABLECFG[
'c'][$kk + 3] = $this->TABLECFG[
'c'][$kk];
552 unset($this->TABLECFG[
'c'][$kk]);
555 ksort($this->TABLECFG[
'c']);
558 foreach ($this->TABLECFG[
'c'] as $cAK => $value) {
561 unset($this->TABLECFG[
'c'][$cAK][$kk]);
564 $this->TABLECFG[
'c'][$cAK][$kk + 1] =
'';
567 $this->TABLECFG[
'c'][$cAK][1] = $this->TABLECFG[
'c'][$cAK][$kk];
568 unset($this->TABLECFG[
'c'][$cAK][$kk]);
571 $this->TABLECFG[
'c'][$cAK][1000000] = $this->TABLECFG[
'c'][$cAK][$kk];
572 unset($this->TABLECFG[
'c'][$cAK][$kk]);
575 $this->TABLECFG[
'c'][$cAK][$kk - 3] = $this->TABLECFG[
'c'][$cAK][$kk];
576 unset($this->TABLECFG[
'c'][$cAK][$kk]);
579 $this->TABLECFG[
'c'][$cAK][$kk + 3] = $this->TABLECFG[
'c'][$cAK][$kk];
580 unset($this->TABLECFG[
'c'][$cAK][$kk]);
583 ksort($this->TABLECFG[
'c'][$cAK]);
588 foreach ($this->TABLECFG[
'c'] as $a => $value) {
589 foreach ($this->TABLECFG[
'c'][$a] as $b => $value2) {
590 $this->TABLECFG[
'c'][$a][$b] = str_replace(
593 str_replace(CR,
'', $this->TABLECFG[
'c'][$a][$b])
610 foreach ($cfgArr as $valueA) {
612 foreach ($valueA as $valueB) {
613 $thisLine[] = $this->tableParsing_quote
616 $inLines[] = implode($this->tableParsing_delimiter, $thisLine);
619 return implode(LF, $inLines);
633 $tableLines = explode(LF, $configurationCode);
636 if (!$columns && trim($tableLines[0])) {
637 $columns = count(explode($this->tableParsing_delimiter, $tableLines[0]));
639 $columns = $columns ?: 4;
641 $configurationArray = array();
642 foreach ($tableLines as $key => $value) {
644 $valueParts = explode($this->tableParsing_delimiter, $value);
646 for ($a = 0; $a < $columns; $a++) {
647 if ($this->tableParsing_quote
648 && $valueParts[$a][0] === $this->tableParsing_quote
649 && substr($valueParts[$a], -1, 1) === $this->tableParsing_quote
651 $valueParts[$a] = substr(trim($valueParts[$a]), 1, -1);
653 $configurationArray[$key][$a] = $valueParts[$a];
656 return $configurationArray;