ListOfFieldsContainer.php 2.85 KB
Newer Older
Christian Kuhn's avatar
Christian Kuhn committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
namespace TYPO3\CMS\Backend\Form\Container;

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Lang\LanguageService;
use TYPO3\CMS\Backend\Utility\BackendUtility;
20
use TYPO3\CMS\Backend\Form\NodeFactory;
Christian Kuhn's avatar
Christian Kuhn committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

/**
 * Render a given list of field of a TCA table.
 *
 * This is an entry container called from FormEngine to handle a
 * list of specific fields. Access rights are checked here and globalOption array
 * is prepared for further processing of single fields by PaletteAndSingleContainer.
 */
class ListOfFieldsContainer extends AbstractContainer {

	/**
	 * Entry method
	 *
	 * @return array As defined in initializeResultArray() of AbstractNode
	 */
	public function render() {
		$table = $this->globalOptions['table'];
		$row = $this->globalOptions['databaseRow'];
		$list = $this->globalOptions['fieldListToRender'];

		if (!$GLOBALS['TCA'][$table]) {
			return $this->initializeResultArray();
		}

		$languageService = $this->getLanguageService();
		// Load the description content for the table if requested
		if ($GLOBALS['TCA'][$table]['interface']['always_description']) {
			$languageService->loadSingleTableDescription($table);
		}

		// If this is a localized record, stuff data from original record to local registry, will then be given to child elements
		$this->registerDefaultLanguageData($table, $row);

		$list = array_unique(GeneralUtility::trimExplode(',', $list, TRUE));
		$typesFieldConfig = BackendUtility::getTCAtypes($table, $row, 1);
		$finalFieldsConfiguration = array();
		foreach ($list as $singleField) {
			if (!is_array($GLOBALS['TCA'][$table]['columns'][$singleField])) {
				continue;
			}
			if (isset($typesFieldConfig[$singleField]['origString'])) {
				$fieldConfiguration = $this->explodeSingleFieldShowItemConfiguration($typesFieldConfig[$singleField]['origString']);
				// Fields of sub palettes should not be rendered
				$fieldConfiguration['paletteName'] = '';
			} else {
				$fieldConfiguration = array(
					'fieldName' => $singleField,
				);
			}
			$finalFieldsConfiguration[] = implode(';', $fieldConfiguration);
		}

		$options = $this->globalOptions;
		$options['fieldsArray'] = $finalFieldsConfiguration;
75
		$options['renderType'] = 'paletteAndSingleContainer';
76
77
78
		/** @var NodeFactory $nodeFactory */
		$nodeFactory = $this->globalOptions['nodeFactory'];
		return $nodeFactory->create($options)->render();
Christian Kuhn's avatar
Christian Kuhn committed
79
80
81
82
83
84
85
86
87
88
	}

	/**
	 * @return LanguageService
	 */
	protected function getLanguageService() {
		return $GLOBALS['LANG'];
	}

}