2 namespace TYPO3\CMS\Backend\Form\Element;
53 $parameterArray = $this->data[
'parameterArray'];
54 $formElementId = md5($parameterArray[
'itemFormElName']);
57 $config = $parameterArray[
'fieldConf'][
'config'];
62 $html[] =
'<div class="typo3-tceforms-tree">';
63 $html[] =
' <input class="treeRecord" type="hidden"';
65 $html[] =
' data-formengine-input-name="' . htmlspecialchars($parameterArray[
'itemFormElName']) .
'"';
66 $html[] =
' data-relatedfieldname="' . htmlspecialchars($parameterArray[
'itemFormElName']) .
'"';
67 $html[] =
' name="' . htmlspecialchars($parameterArray[
'itemFormElName']) .
'"';
68 $html[] =
' id="treeinput' . $formElementId .
'"';
69 $html[] =
' value="' . htmlspecialchars(implode(
',', $config[
'treeData'][
'selectedNodes'])) .
'"';
72 $html[] =
'<div id="tree_' . $formElementId .
'"></div>';
74 $resultArray[
'html'] = implode(LF, $html);
77 if (empty($config[
'readOnly'])) {
78 $resultArray[
'html'] = $this->renderWizards(
79 [$resultArray[
'html']],
81 $this->data[
'tableName'],
82 $this->data[
'databaseRow'],
83 $this->data[
'fieldName'],
85 $parameterArray[
'itemFormElName'],
101 $table = $this->data[
'tableName'];
102 $field = $this->data[
'fieldName'];
103 $parameterArray = $this->data[
'parameterArray'];
104 $config = $parameterArray[
'fieldConf'][
'config'];
106 $disabled = !empty($config[
'readOnly']) ?
'true' :
'false';
107 $maxItems = $config[
'maxitems'] ? (int)$config[
'maxitems'] : 99999;
108 $exclusiveKeys = !empty($config[
'exclusiveKeys']) ? $config[
'exclusiveKeys'] :
'';
110 $appearance = !empty($config[
'treeConfig'][
'appearance']) ? $config[
'treeConfig'][
'appearance'] : [];
111 $width = isset($appearance[
'width']) ? (int)$appearance[
'width'] : static::DEFAULT_WIDTH;
112 if (isset($config[
'size']) && (int)$config[
'size'] > 0) {
113 $height = (int)$config[
'size'] * 20;
115 $height = static::DEFAULT_HEIGHT;
117 $showHeader = !empty($appearance[
'showHeader']);
118 $expanded = !empty($appearance[
'expandAll']);
119 $allowRecursiveMode = !empty($appearance[
'allowRecursiveMode']) ?
'true' :
'false';
122 if (isset($config[
'autoSizeMax']) && (
int)$config[
'autoSizeMax'] > 0) {
123 $autoSizeMax = (int)$config[
'autoSizeMax'] * 20;
126 $onChange = !empty($parameterArray[
'fieldChangeFunc'][
'TBE_EDITOR_fieldChanged']) ? $parameterArray[
'fieldChangeFunc'][
'TBE_EDITOR_fieldChanged'] :
'';
127 $onChange .= !empty($parameterArray[
'fieldChangeFunc'][
'alert']) ? $parameterArray[
'fieldChangeFunc'][
'alert'] :
'';
132 !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'type'])
133 && $field ===
$GLOBALS[
'TCA'][$table][
'ctrl'][
'type']
134 || !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'requestUpdate'])
138 $onChange =
'top.TYPO3.Modal.confirm(TBE_EDITOR.labels.refreshRequired.title, TBE_EDITOR.labels.refreshRequired.content).on("button.clicked", function(e) { if (e.target.name == "ok" && TBE_EDITOR.checkSubmit(-1)) { TBE_EDITOR.submitForm() } top.TYPO3.Modal.dismiss(); });';
140 $onChange .=
'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
145 $javascript[] =
'Ext.onReady(function() {';
146 $javascript[] =
' TYPO3.Components.Tree.StandardTreeItemData["' . $formElementId .
'"] = ' . json_encode($config[
'treeData'][
'items']) .
';';
147 $javascript[] =
' var tree' . $formElementId .
' = new TYPO3.Components.Tree.StandardTree({';
148 $javascript[] =
' id: "' . $formElementId .
'",';
149 $javascript[] =
' stateful: true,';
150 $javascript[] =
' stateId: "tcaTrees." + this.ucId,';
151 $javascript[] =
' stateEvents: [],';
152 $javascript[] =
' showHeader: ' . (int)$showHeader .
',';
154 $javascript[] =
' countSelectedNodes: ' . count($config[
'treeData'][
'selectedNodes']) .
',';
155 $javascript[] =
' width: ' . $width .
',';
156 $javascript[] =
' rendering: false,';
157 $javascript[] =
' listeners: {';
158 $javascript[] =
' click: function(node, event) {';
159 $javascript[] =
' if (typeof(node.attributes.checked) == "boolean") {';
160 $javascript[] =
' node.attributes.checked = ! node.attributes.checked;';
161 $javascript[] =
' node.getUI().toggleCheck(node.attributes.checked);';
162 $javascript[] =
' }';
163 $javascript[] =
' },';
164 $javascript[] =
' dblclick: function(node, event) {';
165 $javascript[] =
' if (typeof(node.attributes.checked) == "boolean") {';
166 $javascript[] =
' node.attributes.checked = ! node.attributes.checked;';
167 $javascript[] =
' node.getUI().toggleCheck(node.attributes.checked);';
168 $javascript[] =
' }';
169 $javascript[] =
' },';
170 $javascript[] =
' checkchange: TYPO3.Components.Tree.TcaCheckChangeHandler,';
171 $javascript[] =
' collapsenode: function(node) {';
172 $javascript[] =
' if (node.id !== "root" && !this.rendering) {';
173 $javascript[] =
' top.TYPO3.Storage.Persistent.removeFromList("tcaTrees." + this.ucId, node.attributes.uid);';
174 $javascript[] =
' }';
175 $javascript[] =
' },';
176 $javascript[] =
' expandnode: function(node) {';
177 $javascript[] =
' if (node.id !== "root" && !this.rendering) {';
178 $javascript[] =
' top.TYPO3.Storage.Persistent.addToList("tcaTrees." + this.ucId, node.attributes.uid);';
179 $javascript[] =
' }';
180 $javascript[] =
' },';
181 $javascript[] =
' beforerender: function(treeCmp) {';
182 $javascript[] =
' this.rendering = true';
183 $javascript[] =
' // Check if that tree element is already rendered. It is appended on the first tceforms_inline call.';
184 $javascript[] =
' if (Ext.fly(treeCmp.getId())) {';
185 $javascript[] =
' return false;';
186 $javascript[] =
' }';
187 $javascript[] =
' },';
188 $javascript[] =
' afterrender: function(treeCmp) {';
190 $javascript[] =
' treeCmp.expandAll();';
192 $javascript[] =
' this.rendering = false;';
193 $javascript[] =
' }';
194 $javascript[] =
' },';
195 $javascript[] =
' tcaMaxItems: ' . $maxItems .
',';
196 $javascript[] =
' tcaSelectRecursiveAllowed: ' . $allowRecursiveMode .
',';
197 $javascript[] =
' tcaSelectRecursive: false,';
198 $javascript[] =
' tcaExclusiveKeys: "' . $exclusiveKeys .
'",';
199 $javascript[] =
' ucId: "' . md5(($table .
'|' . $field)) .
'",';
200 $javascript[] =
' selModel: TYPO3.Components.Tree.EmptySelectionModel,';
201 $javascript[] =
' disabled: ' . $disabled;
202 $javascript[] =
' });';
205 $javascript[] =
' tree' . $formElementId .
'.bodyStyle = "max-height: ' . $autoSizeMax .
'px;min-height: ' . $height .
'px;";';
207 $javascript[] =
' tree' . $formElementId .
'.height = ' . $height .
';';
210 $javascript[] =
' window.setTimeout(function() {';
211 $javascript[] =
' tree' . $formElementId .
'.render("tree_' . $formElementId .
'");';
212 $javascript[] =
' }, 200);';
213 $javascript[] =
'});';
215 return implode(LF, $javascript);