[BUGFIX] Fix backpath for add wizards in IRRE records (Backport fix from master)
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tceforms_inline.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2006-2011 Oliver Hader <oliver@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * The Inline-Relational-Record-Editing (IRRE) functions as part of the TCEforms.
29 *
30 * $Id$
31 *
32 * @author Oliver Hader <oliver@typo3.org>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 88: class t3lib_TCEforms_inline
40 * 109: function init(&$tceForms)
41 * 127: function getSingleField_typeInline($table,$field,$row,&$PA)
42 *
43 * SECTION: Regular rendering of forms, fields, etc.
44 * 263: function renderForeignRecord($parentUid, $rec, $config = array())
45 * 319: function renderForeignRecordHeader($parentUid, $foreign_table,$rec,$config = array())
46 * 375: function renderForeignRecordHeaderControl($table,$row,$config = array())
47 * 506: function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array())
48 * 560: function renderPossibleRecordsSelector($selItems, $conf, $uniqueIds=array())
49 * 627: function addJavaScript()
50 * 643: function addJavaScriptSortable($objectId)
51 *
52 * SECTION: Handling of AJAX calls
53 * 665: function createNewRecord($domObjectId, $foreignUid = 0)
54 * 755: function getJSON($jsonArray)
55 * 770: function getNewRecordLink($objectPrefix, $conf = array())
56 *
57 * SECTION: Get data from database and handle relations
58 * 807: function getRelatedRecords($table,$field,$row,&$PA,$config)
59 * 839: function getPossibleRecords($table,$field,$row,$conf,$checkForConfField='foreign_selector')
60 * 885: function getUniqueIds($records, $conf=array())
61 * 905: function getRecord($pid, $table, $uid, $cmd='')
62 * 929: function getNewRecord($pid, $table)
63 *
64 * SECTION: Structure stack for handling inline objects/levels
65 * 951: function pushStructure($table, $uid, $field = '', $config = array())
66 * 967: function popStructure()
67 * 984: function updateStructureNames()
68 * 1000: function getStructureItemName($levelData)
69 * 1015: function getStructureLevel($level)
70 * 1032: function getStructurePath($structureDepth = -1)
71 * 1057: function parseStructureString($string, $loadConfig = false)
72 *
73 * SECTION: Helper functions
74 * 1098: function checkConfiguration(&$config)
75 * 1123: function checkAccess($cmd, $table, $theUid)
76 * 1185: function compareStructureConfiguration($compare)
77 * 1199: function normalizeUid($string)
78 * 1213: function wrapFormsSection($section, $styleAttrs = array(), $tableAttrs = array())
79 * 1242: function isInlineChildAndLabelField($table, $field)
80 * 1258: function getStructureDepth()
81 * 1295: function arrayCompareComplex($subjectArray, $searchArray, $type = '')
82 * 1349: function isAssociativeArray($object)
83 * 1364: function getPossibleRecordsFlat($possibleRecords)
84 * 1383: function skipField($table, $field, $row, $config)
85 *
86 * TOTAL FUNCTIONS: 35
87 * (This index is automatically created/updated by the extension "extdeveval")
88 *
89 */
90
91
92 class t3lib_TCEforms_inline {
93 const Structure_Separator = '-';
94 const Disposal_AttributeName = 'Disposal_AttributeName';
95 const Disposal_AttributeId = 'Disposal_AttributeId';
96
97 /**
98 * Reference to the calling TCEforms instance
99 *
100 * @var t3lib_TCEforms
101 */
102 var $fObj;
103 var $backPath; // Reference to $fObj->backPath
104
105 var $isAjaxCall = FALSE; // Indicates if a field is rendered upon an AJAX call
106 var $inlineStructure = array(); // the structure/hierarchy where working in, e.g. cascading inline tables
107 var $inlineFirstPid; // the first call of an inline type appeared on this page (pid of record)
108 var $inlineNames = array(); // keys: form, object -> hold the name/id for each of them
109 var $inlineData = array(); // inline data array used for JSON output
110 var $inlineView = array(); // expanded/collapsed states for the current BE user
111 var $inlineCount = 0; // count the number of inline types used
112 var $inlineStyles = array();
113
114 var $prependNaming = 'data'; // how the $this->fObj->prependFormFieldNames should be set ('data' is default)
115 var $prependFormFieldNames; // reference to $this->fObj->prependFormFieldNames
116 var $prependCmdFieldNames; // reference to $this->fObj->prependCmdFieldNames
117
118 protected $hookObjects = array(); // array containing instances of hook classes called once for IRRE objects
119
120
121 /**
122 * Intialize an instance of t3lib_TCEforms_inline
123 *
124 * @param t3lib_TCEforms $tceForms: Reference to an TCEforms instance
125 * @return void
126 */
127 function init(&$tceForms) {
128 $this->fObj = $tceForms;
129 $this->backPath =& $tceForms->backPath;
130 $this->prependFormFieldNames =& $this->fObj->prependFormFieldNames;
131 $this->prependCmdFieldNames =& $this->fObj->prependCmdFieldNames;
132 $this->inlineStyles['margin-right'] = '5';
133 $this->initHookObjects();
134 }
135
136
137 /**
138 * Initialized the hook objects for this class.
139 * Each hook object has to implement the interface t3lib_tceformsInlineHook.
140 *
141 * @return void
142 */
143 protected function initHookObjects() {
144 $this->hookObjects = array();
145 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'])) {
146 $tceformsInlineHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'];
147 if (is_array($tceformsInlineHook)) {
148 foreach ($tceformsInlineHook as $classData) {
149 $processObject = t3lib_div::getUserObj($classData);
150
151 if (!($processObject instanceof t3lib_tceformsInlineHook)) {
152 throw new UnexpectedValueException('$processObject must implement interface t3lib_tceformsInlineHook', 1202072000);
153 }
154
155 $processObject->init($this);
156 $this->hookObjects[] = $processObject;
157 }
158 }
159 }
160 }
161
162
163 /**
164 * Generation of TCEform elements of the type "inline"
165 * This will render inline-relational-record sets. Relations.
166 *
167 * @param string $table: The table name of the record
168 * @param string $field: The field name which this element is supposed to edit
169 * @param array $row: The record data array where the value(s) for the field can be found
170 * @param array $PA: An array with additional configuration options.
171 * @return string The HTML code for the TCEform field
172 */
173 function getSingleField_typeInline($table, $field, $row, &$PA) {
174 // check the TCA configuration - if false is returned, something was wrong
175 if ($this->checkConfiguration($PA['fieldConf']['config']) === FALSE) {
176 return FALSE;
177 }
178
179 $item = '';
180
181 // count the number of processed inline elements
182 $this->inlineCount++;
183
184 // Init:
185 $config = $PA['fieldConf']['config'];
186 $foreign_table = $config['foreign_table'];
187 t3lib_div::loadTCA($foreign_table);
188
189 if (t3lib_BEfunc::isTableLocalizable($table)) {
190 $language = intval($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
191 }
192 $minitems = t3lib_div::intInRange($config['minitems'], 0);
193 $maxitems = t3lib_div::intInRange($config['maxitems'], 0);
194 if (!$maxitems) {
195 $maxitems = 100000;
196 }
197
198 // Register the required number of elements:
199 $this->fObj->requiredElements[$PA['itemFormElName']] = array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field);
200
201 // remember the page id (pid of record) where inline editing started first
202 // we need that pid for ajax calls, so that they would know where the action takes place on the page structure
203 if (!isset($this->inlineFirstPid)) {
204 // if this record is not new, try to fetch the inlineView states
205 // @TODO: Add checking/cleaning for unused tables, records, etc. to save space in uc-field
206 if (t3lib_div::testInt($row['uid'])) {
207 $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
208 $this->inlineView = $inlineView[$table][$row['uid']];
209 }
210 // If the parent is a page, use the uid(!) of the (new?) page as pid for the child records:
211 if ($table == 'pages') {
212 $liveVersionId = t3lib_BEfunc::getLiveVersionIdOfRecord('pages', $row['uid']);
213 $this->inlineFirstPid = (is_null($liveVersionId) ? $row['uid'] : $liveVersionId);
214 // If pid is negative, fetch the previous record and take its pid:
215 } elseif ($row['pid'] < 0) {
216 $prevRec = t3lib_BEfunc::getRecord($table, abs($row['pid']));
217 $this->inlineFirstPid = $prevRec['pid'];
218 // Take the pid as it is:
219 } else {
220 $this->inlineFirstPid = $row['pid'];
221 }
222 }
223 // add the current inline job to the structure stack
224 $this->pushStructure($table, $row['uid'], $field, $config);
225 // e.g. data[<table>][<uid>][<field>]
226 $nameForm = $this->inlineNames['form'];
227 // e.g. data-<pid>-<table1>-<uid1>-<field1>-<table2>-<uid2>-<field2>
228 $nameObject = $this->inlineNames['object'];
229 // get the records related to this inline record
230 $relatedRecords = $this->getRelatedRecords($table, $field, $row, $PA, $config);
231 // set the first and last record to the config array
232 $relatedRecordsUids = array_keys($relatedRecords['records']);
233 $config['inline']['first'] = reset($relatedRecordsUids);
234 $config['inline']['last'] = end($relatedRecordsUids);
235
236 // Tell the browser what we have (using JSON later):
237 $top = $this->getStructureLevel(0);
238 $this->inlineData['config'][$nameObject] = array(
239 'table' => $foreign_table,
240 'md5' => md5($nameObject),
241 );
242 $this->inlineData['config'][$nameObject . self::Structure_Separator . $foreign_table] = array(
243 'min' => $minitems,
244 'max' => $maxitems,
245 'sortable' => $config['appearance']['useSortable'],
246 'top' => array(
247 'table' => $top['table'],
248 'uid' => $top['uid'],
249 ),
250 );
251 // Set a hint for nested IRRE and tab elements:
252 $this->inlineData['nested'][$nameObject] = $this->fObj->getDynNestedStack(FALSE, $this->isAjaxCall);
253
254 // if relations are required to be unique, get the uids that have already been used on the foreign side of the relation
255 if ($config['foreign_unique']) {
256 // If uniqueness *and* selector are set, they should point to the same field - so, get the configuration of one:
257 $selConfig = $this->getPossibleRecordsSelectorConfig($config, $config['foreign_unique']);
258 // Get the used unique ids:
259 $uniqueIds = $this->getUniqueIds($relatedRecords['records'], $config, $selConfig['type'] == 'groupdb');
260 $possibleRecords = $this->getPossibleRecords($table, $field, $row, $config, 'foreign_unique');
261 $uniqueMax = $config['appearance']['useCombination'] || $possibleRecords === FALSE ? -1 : count($possibleRecords);
262 $this->inlineData['unique'][$nameObject . self::Structure_Separator . $foreign_table] = array(
263 'max' => $uniqueMax,
264 'used' => $uniqueIds,
265 'type' => $selConfig['type'],
266 'table' => $config['foreign_table'],
267 'elTable' => $selConfig['table'], // element/record table (one step down in hierarchy)
268 'field' => $config['foreign_unique'],
269 'selector' => $selConfig['selector'],
270 'possible' => $this->getPossibleRecordsFlat($possibleRecords),
271 );
272 }
273
274 // if it's required to select from possible child records (reusable children), add a selector box
275 if ($config['foreign_selector']) {
276 // if not already set by the foreign_unique, set the possibleRecords here and the uniqueIds to an empty array
277 if (!$config['foreign_unique']) {
278 $possibleRecords = $this->getPossibleRecords($table, $field, $row, $config);
279 $uniqueIds = array();
280 }
281 $selectorBox = $this->renderPossibleRecordsSelector($possibleRecords, $config, $uniqueIds);
282 $item .= $selectorBox;
283 }
284
285 // wrap all inline fields of a record with a <div> (like a container)
286 $item .= '<div id="' . $nameObject . '">';
287
288 // define how to show the "Create new record" link - if there are more than maxitems, hide it
289 if ($relatedRecords['count'] >= $maxitems || ($uniqueMax > 0 && $relatedRecords['count'] >= $uniqueMax)) {
290 $config['inline']['inlineNewButtonStyle'] = 'display: none;';
291 }
292
293 // Render the level links (create new record, localize all, synchronize):
294 if ($config['appearance']['levelLinksPosition'] != 'none') {
295 $levelLinks = $this->getLevelInteractionLink('newRecord', $nameObject . self::Structure_Separator . $foreign_table, $config);
296 if ($language > 0) {
297 // Add the "Localize all records" link before all child records:
298 if (isset($config['appearance']['showAllLocalizationLink']) && $config['appearance']['showAllLocalizationLink']) {
299 $levelLinks .= $this->getLevelInteractionLink('localize', $nameObject . self::Structure_Separator . $foreign_table, $config);
300 }
301 // Add the "Synchronize with default language" link before all child records:
302 if (isset($config['appearance']['showSynchronizationLink']) && $config['appearance']['showSynchronizationLink']) {
303 $levelLinks .= $this->getLevelInteractionLink('synchronize', $nameObject . self::Structure_Separator . $foreign_table, $config);
304 }
305 }
306 }
307 // Add the level links before all child records:
308 if (in_array($config['appearance']['levelLinksPosition'], array('both', 'top'))) {
309 $item .= $levelLinks;
310 }
311
312 $item .= '<div id="' . $nameObject . '_records">';
313 $relationList = array();
314 if (count($relatedRecords['records'])) {
315 foreach ($relatedRecords['records'] as $rec) {
316 $item .= $this->renderForeignRecord($row['uid'], $rec, $config);
317 if (!isset($rec['__virtual']) || !$rec['__virtual']) {
318 $relationList[] = $rec['uid'];
319 }
320 }
321 }
322 $item .= '</div>';
323
324 // Add the level links after all child records:
325 if (in_array($config['appearance']['levelLinksPosition'], array('both', 'bottom'))) {
326 $item .= $levelLinks;
327 }
328
329 // add Drag&Drop functions for sorting to TCEforms::$additionalJS_post
330 if (count($relationList) > 1 && $config['appearance']['useSortable']) {
331 $this->addJavaScriptSortable($nameObject . '_records');
332 }
333 // publish the uids of the child records in the given order to the browser
334 $item .= '<input type="hidden" name="' . $nameForm . '" value="' . implode(',', $relationList) . '" class="inlineRecord" />';
335 // close the wrap for all inline fields (container)
336 $item .= '</div>';
337
338 // on finishing this section, remove the last item from the structure stack
339 $this->popStructure();
340
341 // if this was the first call to the inline type, restore the values
342 if (!$this->getStructureDepth()) {
343 unset($this->inlineFirstPid);
344 }
345
346 return $item;
347 }
348
349
350 /*******************************************************
351 *
352 * Regular rendering of forms, fields, etc.
353 *
354 *******************************************************/
355
356
357 /**
358 * Render the form-fields of a related (foreign) record.
359 *
360 * @param string $parentUid: The uid of the parent (embedding) record (uid or NEW...)
361 * @param array $rec: The table record of the child/embedded table (normaly post-processed by t3lib_transferData)
362 * @param array $config: content of $PA['fieldConf']['config']
363 * @return string The HTML code for this "foreign record"
364 */
365 function renderForeignRecord($parentUid, $rec, $config = array()) {
366 $foreign_table = $config['foreign_table'];
367 $foreign_field = $config['foreign_field'];
368 $foreign_selector = $config['foreign_selector'];
369
370 // Register default localization content:
371 $parent = $this->getStructureLevel(-1);
372 if (isset($parent['localizationMode']) && $parent['localizationMode'] != FALSE) {
373 $this->fObj->registerDefaultLanguageData($foreign_table, $rec);
374 }
375 // Send a mapping information to the browser via JSON:
376 // e.g. data[<curTable>][<curId>][<curField>] => data-<pid>-<parentTable>-<parentId>-<parentField>-<curTable>-<curId>-<curField>
377 $this->inlineData['map'][$this->inlineNames['form']] = $this->inlineNames['object'];
378
379 // Set this variable if we handle a brand new unsaved record:
380 $isNewRecord = t3lib_div::testInt($rec['uid']) ? FALSE : TRUE;
381 // Set this variable if the record is virtual and only show with header and not editable fields:
382 $isVirtualRecord = (isset($rec['__virtual']) && $rec['__virtual']);
383 // If there is a selector field, normalize it:
384 if ($foreign_selector) {
385 $rec[$foreign_selector] = $this->normalizeUid($rec[$foreign_selector]);
386 }
387
388 if (!$this->checkAccess(($isNewRecord ? 'new' : 'edit'), $foreign_table, $rec['uid'])) {
389 return FALSE;
390 }
391
392 // Get the current naming scheme for DOM name/id attributes:
393 $nameObject = $this->inlineNames['object'];
394 $appendFormFieldNames = '[' . $foreign_table . '][' . $rec['uid'] . ']';
395 $objectId = $nameObject . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
396 // Put the current level also to the dynNestedStack of TCEforms:
397 $this->fObj->pushToDynNestedStack('inline', $objectId);
398
399 if (!$isVirtualRecord) {
400 // Get configuration:
401 $collapseAll = (isset($config['appearance']['collapseAll']) && $config['appearance']['collapseAll']);
402 $expandAll = (isset($config['appearance']['collapseAll']) && !$config['appearance']['collapseAll']);
403 $ajaxLoad = (isset($config['appearance']['ajaxLoad']) && !$config['appearance']['ajaxLoad']) ? FALSE : TRUE;
404
405 if ($isNewRecord) {
406 // show this record expanded or collapsed
407 $isExpanded = ($expandAll || (!$collapseAll ? 1 : 0));
408 } else {
409 $isExpanded = ($config['renderFieldsOnly'] || (!$collapseAll && $this->getExpandedCollapsedState($foreign_table, $rec['uid'])) || $expandAll);
410 }
411 // Render full content ONLY IF this is a AJAX-request, a new record, the record is not collapsed or AJAX-loading is explicitly turned off
412 if ($isNewRecord || $isExpanded || !$ajaxLoad) {
413 $combination = $this->renderCombinationTable($rec, $appendFormFieldNames, $config);
414 $fields = $this->renderMainFields($foreign_table, $rec);
415 $fields = $this->wrapFormsSection($fields);
416 // Replace returnUrl in Wizard-Code, if this is an AJAX call
417 $ajaxArguments = t3lib_div::_GP('ajax');
418 if (isset($ajaxArguments[2]) && trim($ajaxArguments[2]) != '') {
419 $fields = str_replace('P[returnUrl]=%2F' . rawurlencode(TYPO3_mainDir) . 'ajax.php', 'P[returnUrl]=' . rawurlencode($ajaxArguments[2]), $fields);
420 }
421 } else {
422 $combination = '';
423 // This string is the marker for the JS-function to check if the full content has already been loaded
424 $fields = '<!--notloaded-->';
425 }
426 if ($isNewRecord) {
427 // get the top parent table
428 $top = $this->getStructureLevel(0);
429 $ucFieldName = 'uc[inlineView][' . $top['table'] . '][' . $top['uid'] . ']' . $appendFormFieldNames;
430 // set additional fields for processing for saving
431 $fields .= '<input type="hidden" name="' . $this->prependFormFieldNames . $appendFormFieldNames . '[pid]" value="' . $rec['pid'] . '"/>';
432 $fields .= '<input type="hidden" name="' . $ucFieldName . '" value="' . $isExpanded . '" />';
433 } else {
434 // set additional field for processing for saving
435 $fields .= '<input type="hidden" name="' . $this->prependCmdFieldNames . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />';
436 }
437 // if this record should be shown collapsed
438 if (!$isExpanded) {
439 $appearanceStyleFields = ' style="display: none;"';
440 }
441 }
442
443 if ($config['renderFieldsOnly']) {
444 $out = $fields . $combination;
445 } else {
446 // set the record container with data for output
447 $out = '<div class="t3-form-field-record-inline" id="' . $objectId . '_fields"' . $appearanceStyleFields . '>' . $fields . $combination . '</div>';
448 $header = $this->renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
449 $out = '<div class="t3-form-field-header-inline" id="' . $objectId . '_header">' . $header . '</div>' . $out;
450 // wrap the header, fields and combination part of a child record with a div container
451 $classMSIE = ($this->fObj->clientInfo['BROWSER'] == 'msie' && $this->fObj->clientInfo['VERSION'] < 8 ? 'MSIE' : '');
452 $class = 'inlineDiv' . $classMSIE . ($isNewRecord ? ' inlineIsNewRecord' : '');
453 $out = '<div id="' . $objectId . '_div" class="t3-form-field-container-inline ' . $class . '">' . $out . '</div>';
454 }
455 // Remove the current level also from the dynNestedStack of TCEforms:
456 $this->fObj->popFromDynNestedStack();
457
458 return $out;
459 }
460
461
462 /**
463 * Wrapper for TCEforms::getMainFields().
464 *
465 * @param string $table: The table name
466 * @param array $row: The record to be rendered
467 * @return string The rendered form
468 */
469 protected function renderMainFields($table, $row) {
470 // The current render depth of t3lib_TCEforms:
471 $depth = $this->fObj->renderDepth;
472 // If there is some information about already rendered palettes of our parent, store this info:
473 if (isset($this->fObj->palettesRendered[$depth][$table])) {
474 $palettesRendered = $this->fObj->palettesRendered[$depth][$table];
475 }
476 // Render the form:
477 $content = $this->fObj->getMainFields($table, $row, $depth);
478 // If there was some info about rendered palettes stored, write it back for our parent:
479 if (isset($palettesRendered)) {
480 $this->fObj->palettesRendered[$depth][$table] = $palettesRendered;
481 }
482 return $content;
483 }
484
485
486 /**
487 * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
488 * Later on the command-icons are inserted here.
489 *
490 * @param string $parentUid: The uid of the parent (embedding) record (uid or NEW...)
491 * @param string $foreign_table: The foreign_table we create a header for
492 * @param array $rec: The current record of that foreign_table
493 * @param array $config: content of $PA['fieldConf']['config']
494 * @param boolean $isVirtualRecord:
495 * @return string The HTML code of the header
496 */
497 function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE) {
498 // Init:
499 $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
500 $expandSingle = $config['appearance']['expandSingle'] ? 1 : 0;
501 // we need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
502 $onClick = "return inline.expandCollapseRecord('" . htmlspecialchars($objectId) . "', $expandSingle, '" . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "')";
503
504 // Pre-Processing:
505 $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
506 $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
507 $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
508 // Get the record title/label for a record:
509 // render using a self-defined user function
510 if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
511 $params = array(
512 'table' => $foreign_table,
513 'row' => $rec,
514 'title' => '',
515 'isOnSymmetricSide' => $isOnSymmetricSide,
516 'parent' => array(
517 'uid' => $parentUid,
518 'config' => $config,
519 ),
520 );
521 $null = NULL; // callUserFunction requires a third parameter, but we don't want to give $this as reference!
522 t3lib_div::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
523 $recTitle = $params['title'];
524 // render the special alternative title
525 } elseif ($hasForeignLabel || $hasSymmetricLabel) {
526 $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
527 $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
528 // Render title for everything else than group/db:
529 if ($foreignConfig['type'] != 'groupdb') {
530 $recTitle = t3lib_BEfunc::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
531 // Render title for group/db:
532 } else {
533 // $recTitle could be something like: "tx_table_123|...",
534 $valueParts = t3lib_div::trimExplode('|', $rec[$titleCol]);
535 $itemParts = t3lib_div::revExplode('_', $valueParts[0], 2);
536 $recTemp = t3lib_befunc::getRecordWSOL($itemParts[0], $itemParts[1]);
537 $recTitle = t3lib_BEfunc::getRecordTitle($itemParts[0], $recTemp, FALSE);
538 }
539 $recTitle = t3lib_BEfunc::getRecordTitlePrep($recTitle);
540 if (!strcmp(trim($recTitle), '')) {
541 $recTitle = t3lib_BEfunc::getNoRecordTitle(TRUE);
542 }
543 // render the standard
544 } else {
545 $recTitle = t3lib_BEfunc::getRecordTitle($foreign_table, $rec, TRUE);
546 }
547
548 $altText = t3lib_BEfunc::getRecordIconAltText($rec, $foreign_table);
549 $iconImg = t3lib_iconWorks::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
550 $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
551 if (!$isVirtualRecord) {
552 $iconImg = $this->wrapWithAnchor($iconImg, '#', array('onclick' => $onClick));
553 $label = $this->wrapWithAnchor($label, '#', array('onclick' => $onClick, 'style' => 'display: block;'));
554 }
555
556 $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
557
558 // @TODO: Check the table wrapping and the CSS definitions
559 $header =
560 '<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-right: ' . $this->inlineStyles['margin-right'] . 'px;"' .
561 ($this->fObj->borderStyle[2] ? ' background="' . htmlspecialchars($this->backPath . $this->fObj->borderStyle[2]) . '"' : '') .
562 ($this->fObj->borderStyle[3] ? ' class="' . htmlspecialchars($this->fObj->borderStyle[3]) . '"' : '') . '>' .
563 '<tr class="class-main12"><td width="18" id="' . $objectId . '_iconcontainer">' . $iconImg . '</td><td align="left"><strong>' . $label . '</strong></td><td align="right">' . $ctrl . '</td></tr></table>';
564
565 return $header;
566 }
567
568
569 /**
570 * Render the control-icons for a record header (create new, sorting, delete, disable/enable).
571 * Most of the parts are copy&paste from class.db_list_extra.inc and modified for the JavaScript calls here
572 *
573 * @param string $parentUid: The uid of the parent (embedding) record (uid or NEW...)
574 * @param string $foreign_table: The table (foreign_table) we create control-icons for
575 * @param array $rec: The current record of that foreign_table
576 * @param array $config: (modified) TCA configuration of the field
577 * @return string The HTML code with the control-icons
578 */
579 function renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config = array(), $isVirtualRecord = FALSE) {
580 // Initialize:
581 $cells = array();
582 $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
583
584 $tcaTableCtrl =& $GLOBALS['TCA'][$foreign_table]['ctrl'];
585 $tcaTableCols =& $GLOBALS['TCA'][$foreign_table]['columns'];
586
587 $isPagesTable = $foreign_table == 'pages' ? TRUE : FALSE;
588 $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
589 $enableManualSorting = $tcaTableCtrl['sortby'] || $config['MM'] || (!$isOnSymmetricSide && $config['foreign_sortby']) || ($isOnSymmetricSide && $config['symmetric_sortby']) ? TRUE : FALSE;
590
591 $nameObject = $this->inlineNames['object'];
592 $nameObjectFt = $nameObject . self::Structure_Separator . $foreign_table;
593 $nameObjectFtId = $nameObjectFt . self::Structure_Separator . $rec['uid'];
594
595 $calcPerms = $GLOBALS['BE_USER']->calcPerms(
596 t3lib_BEfunc::readPageAccess($rec['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1))
597 );
598
599 // If the listed table is 'pages' we have to request the permission settings for each page:
600 if ($isPagesTable) {
601 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $rec['uid']));
602 }
603
604 // This expresses the edit permissions for this particular element:
605 $permsEdit = ($isPagesTable && ($localCalcPerms & 2)) || (!$isPagesTable && ($calcPerms & 16));
606
607 // Controls: Defines which controls should be shown
608 $enabledControls = $config['appearance']['enabledControls'];
609 // Hook: Can disable/enable single controls for specific child records:
610 foreach ($this->hookObjects as $hookObj) {
611 $hookObj->renderForeignRecordHeaderControl_preProcess($parentUid, $foreign_table, $rec, $config, $isVirtualRecord, $enabledControls);
612 }
613
614 // Icon to visualize that a required field is nested in this inline level:
615 $cells['required'] = '<img name="' . $nameObjectFtId . '_req" src="clear.gif" width="10" height="10" hspace="4" vspace="3" alt="" />';
616
617 if (isset($rec['__create'])) {
618 $cells['localize.isLocalizable'] = t3lib_iconWorks::getSpriteIcon('actions-edit-localize-status-low', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:localize.isLocalizable', TRUE)));
619 } elseif (isset($rec['__remove'])) {
620 $cells['localize.wasRemovedInOriginal'] = t3lib_iconWorks::getSpriteIcon('actions-edit-localize-status-high', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:localize.wasRemovedInOriginal', 1)));
621 }
622
623 // "Info": (All records)
624 if ($enabledControls['info'] && !$isNewItem) {
625 $cells['info'] = '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $foreign_table . '\', \'' . $rec['uid'] . '\'); return false;') . '">' .
626 t3lib_iconWorks::getSpriteIcon('status-dialog-information', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:showInfo', TRUE))) .
627 '</a>';
628 }
629 // If the table is NOT a read-only table, then show these links:
630 if (!$tcaTableCtrl['readOnly'] && !$isVirtualRecord) {
631
632 // "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):
633 if ($enabledControls['new'] && ($enableManualSorting || $tcaTableCtrl['useColumnsForDefaultValues'])) {
634 if (
635 (!$isPagesTable && ($calcPerms & 16)) || // For NON-pages, must have permission to edit content on this parent page
636 ($isPagesTable && ($calcPerms & 8)) // For pages, must have permission to create new pages here.
637 ) {
638 $onClick = "return inline.createNewRecord('" . $nameObjectFt . "','" . $rec['uid'] . "')";
639 $class = ' class="inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'] . '"';
640 if ($config['inline']['inlineNewButtonStyle']) {
641 $style = ' style="' . $config['inline']['inlineNewButtonStyle'] . '"';
642 }
643 $cells['new'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $class . $style . '>' .
644 t3lib_iconWorks::getSpriteIcon('actions-' . ($isPagesTable ? 'page' : 'document') . '-new',
645 array(
646 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:new' . ($isPagesTable ? 'Page' : 'Record'), 1)
647 )
648 ) .
649 '</a>';
650 }
651 }
652
653 // Drag&Drop Sorting: Sortable handler for script.aculo.us
654 if ($enabledControls['dragdrop'] && $permsEdit && $enableManualSorting && $config['appearance']['useSortable']) {
655 $cells['dragdrop'] = t3lib_iconWorks::getSpriteIcon('actions-move-move', array('class' => 'sortableHandle', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.move', TRUE)));
656 }
657
658 // "Up/Down" links
659 if ($enabledControls['sort'] && $permsEdit && $enableManualSorting) {
660 $onClick = "return inline.changeSorting('" . $nameObjectFtId . "', '1')"; // Up
661 $style = $config['inline']['first'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
662 $cells['sort.up'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" class="sortingUp" ' . $style . '>' .
663 t3lib_iconWorks::getSpriteIcon('actions-move-up', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveUp', TRUE))) .
664 '</a>';
665
666 $onClick = "return inline.changeSorting('" . $nameObjectFtId . "', '-1')"; // Down
667 $style = $config['inline']['last'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
668 $cells['sort.down'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" class="sortingDown" ' . $style . '>' .
669 t3lib_iconWorks::getSpriteIcon('actions-move-down', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveDown', TRUE))) .
670 '</a>';
671 }
672
673 // "Hide/Unhide" links:
674 $hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
675 if ($enabledControls['hide'] && $permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $foreign_table . ':' . $hiddenField))) {
676 $onClick = "return inline.enableDisableRecord('" . $nameObjectFtId . "')";
677 if ($rec[$hiddenField]) {
678 $cells['hide.unhide'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
679 t3lib_iconWorks::getSpriteIcon(
680 'actions-edit-unhide',
681 array(
682 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:unHide' . ($isPagesTable ? 'Page' : ''), 1),
683 'id' => $nameObjectFtId . '_disabled'
684 )
685 ) .
686 '</a>';
687 } else {
688 $cells['hide.hide'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
689 t3lib_iconWorks::getSpriteIcon(
690 'actions-edit-hide',
691 array(
692 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:hide' . ($isPagesTable ? 'Page' : ''), 1),
693 'id' => $nameObjectFtId . '_disabled'
694 )
695 ) .
696 '</a>';
697 }
698 }
699
700 // "Delete" link:
701 if ($enabledControls['delete'] && ($isPagesTable && $localCalcPerms & 4 || !$isPagesTable && $calcPerms & 16)) {
702 $onClick = "inline.deleteRecord('" . $nameObjectFtId . "');";
703 $cells['delete'] = '<a href="#" onclick="' . htmlspecialchars('if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')) . ')) { ' . $onClick . ' } return false;') . '">' .
704 t3lib_iconWorks::getSpriteIcon('actions-edit-delete', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:delete', TRUE))) .
705 '</a>';
706 }
707 // If this is a virtual record offer a minimized set of icons for user interaction:
708 } elseif ($isVirtualRecord) {
709 if ($enabledControls['localize'] && isset($rec['__create'])) {
710 $onClick = "inline.synchronizeLocalizeRecords('" . $nameObjectFt . "', " . $rec['uid'] . ");";
711 $cells['localize'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
712 t3lib_iconWorks::getSpriteIcon('actions-document-localize', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:localize', TRUE))) .
713 '</a>';
714 }
715 }
716
717 // If the record is edit-locked by another user, we will show a little warning sign:
718 if ($lockInfo = t3lib_BEfunc::isRecordLocked($foreign_table, $rec['uid'])) {
719 $cells['locked'] = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . ');return false;') . '">' .
720 t3lib_iconWorks::getSpriteIcon('status-warning-in-use', array('title' => htmlspecialchars($lockInfo['msg']))) .
721 '</a>';
722 }
723
724 // Hook: Post-processing of single controls for specific child records:
725 foreach ($this->hookObjects as $hookObj) {
726 $hookObj->renderForeignRecordHeaderControl_postProcess($parentUid, $foreign_table, $rec, $config, $isVirtualRecord, $cells);
727 }
728 // Compile items into a DIV-element:
729 return '
730 <!-- CONTROL PANEL: ' . $foreign_table . ':' . $rec['uid'] . ' -->
731 <div class="typo3-DBctrl">' . implode('', $cells) . '</div>';
732 }
733
734
735 /**
736 * Render a table with TCEforms, that occurs on a intermediate table but should be editable directly,
737 * so two tables are combined (the intermediate table with attributes and the sub-embedded table).
738 * -> This is a direct embedding over two levels!
739 *
740 * @param array $rec: The table record of the child/embedded table (normaly post-processed by t3lib_transferData)
741 * @param string $appendFormFieldNames: The [<table>][<uid>] of the parent record (the intermediate table)
742 * @param array $config: content of $PA['fieldConf']['config']
743 * @return string A HTML string with <table> tag around.
744 */
745 function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array()) {
746 $foreign_table = $config['foreign_table'];
747 $foreign_selector = $config['foreign_selector'];
748
749 if ($foreign_selector && $config['appearance']['useCombination']) {
750 $comboConfig = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector]['config'];
751 $comboRecord = array();
752
753 // If record does already exist, load it:
754 if ($rec[$foreign_selector] && t3lib_div::testInt($rec[$foreign_selector])) {
755 $comboRecord = $this->getRecord(
756 $this->inlineFirstPid,
757 $comboConfig['foreign_table'],
758 $rec[$foreign_selector]
759 );
760 $isNewRecord = FALSE;
761 // It is a new record, create a new record virtually:
762 } else {
763 $comboRecord = $this->getNewRecord(
764 $this->inlineFirstPid,
765 $comboConfig['foreign_table']
766 );
767 $isNewRecord = TRUE;
768 }
769
770 // get the TCEforms interpretation of the TCA of the child table
771 $out = $this->renderMainFields($comboConfig['foreign_table'], $comboRecord);
772 $out = $this->wrapFormsSection($out, array(), array('class' => 'wrapperAttention'));
773
774 // if this is a new record, add a pid value to store this record and the pointer value for the intermediate table
775 if ($isNewRecord) {
776 $comboFormFieldName = $this->prependFormFieldNames . '[' . $comboConfig['foreign_table'] . '][' . $comboRecord['uid'] . '][pid]';
777 $out .= '<input type="hidden" name="' . $comboFormFieldName . '" value="' . $comboRecord['pid'] . '" />';
778 }
779
780 // if the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation
781 if ($isNewRecord || $config['foreign_unique'] == $foreign_selector) {
782 $parentFormFieldName = $this->prependFormFieldNames . $appendFormFieldNames . '[' . $foreign_selector . ']';
783 $out .= '<input type="hidden" name="' . $parentFormFieldName . '" value="' . $comboRecord['uid'] . '" />';
784 }
785 }
786
787 return $out;
788 }
789
790
791 /**
792 * Get a selector as used for the select type, to select from all available
793 * records and to create a relation to the embedding record (e.g. like MM).
794 *
795 * @param array $selItems: Array of all possible records
796 * @param array $conf: TCA configuration of the parent(!) field
797 * @param array $uniqueIds: The uids that have already been used and should be unique
798 * @return string A HTML <select> box with all possible records
799 */
800 function renderPossibleRecordsSelector($selItems, $conf, $uniqueIds = array()) {
801 $foreign_table = $conf['foreign_table'];
802 $foreign_selector = $conf['foreign_selector'];
803
804 $selConfig = $this->getPossibleRecordsSelectorConfig($conf, $foreign_selector);
805 $config = $selConfig['PA']['fieldConf']['config'];
806
807 if ($selConfig['type'] == 'select') {
808 $item = $this->renderPossibleRecordsSelectorTypeSelect($selItems, $conf, $selConfig['PA'], $uniqueIds);
809 } elseif ($selConfig['type'] == 'groupdb') {
810 $item = $this->renderPossibleRecordsSelectorTypeGroupDB($conf, $selConfig['PA']);
811 }
812
813 return $item;
814 }
815
816
817 /**
818 * Get a selector as used for the select type, to select from all available
819 * records and to create a relation to the embedding record (e.g. like MM).
820 *
821 * @param array $selItems: Array of all possible records
822 * @param array $conf: TCA configuration of the parent(!) field
823 * @param array $PA: An array with additional configuration options
824 * @param array $uniqueIds: The uids that have already been used and should be unique
825 * @return string A HTML <select> box with all possible records
826 */
827 function renderPossibleRecordsSelectorTypeSelect($selItems, $conf, &$PA, $uniqueIds = array()) {
828 $foreign_table = $conf['foreign_table'];
829 $foreign_selector = $conf['foreign_selector'];
830
831 $PA = array();
832 $PA['fieldConf'] = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector];
833 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
834 $PA['fieldTSConfig'] = $this->fObj->setTSconfig($foreign_table, array(), $foreign_selector);
835 $config = $PA['fieldConf']['config'];
836
837 //TODO: $disabled is not present - should be read from config?
838 $disabled = FALSE;
839 if (!$disabled) {
840 // Create option tags:
841 $opt = array();
842 $styleAttrValue = '';
843 foreach ($selItems as $p) {
844 if ($config['iconsInOptionTags']) {
845 $styleAttrValue = $this->fObj->optionTagStyle($p[2]);
846 }
847 if (!in_array($p[1], $uniqueIds)) {
848 $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
849 ' style="' . (in_array($p[1], $uniqueIds) ? '' : '') .
850 ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) : '') . '">' .
851 htmlspecialchars($p[0]) . '</option>';
852 }
853 }
854
855 // Put together the selector box:
856 $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->fObj->defaultMultipleSelectorStyle . '"';
857 $size = intval($conf['size']);
858 $size = $conf['autoSizeMax'] ? t3lib_div::intInRange(count($selItems) + 1, t3lib_div::intInRange($size, 1), $conf['autoSizeMax']) : $size;
859 $onChange = "return inline.importNewRecord('" . $this->inlineNames['object'] . self::Structure_Separator . $conf['foreign_table'] . "')";
860 $item = '
861 <select id="' . $this->inlineNames['object'] . self::Structure_Separator . $conf['foreign_table'] . '_selector"' .
862 $this->fObj->insertDefStyle('select') .
863 ($size ? ' size="' . $size . '"' : '') .
864 ' onchange="' . htmlspecialchars($onChange) . '"' .
865 $PA['onFocus'] .
866 $selector_itemListStyle .
867 ($conf['foreign_unique'] ? ' isunique="isunique"' : '') . '>
868 ' . implode('
869 ', $opt) . '
870 </select>';
871
872 // add a "Create new relation" link for adding new relations
873 // this is neccessary, if the size of the selector is "1" or if
874 // there is only one record item in the select-box, that is selected by default
875 // the selector-box creates a new relation on using a onChange event (see some line above)
876 $createNewRelationText = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createNewRelation', 1);
877 $item .=
878 '<a href="#" onclick="' . htmlspecialchars($onChange) . '" align="abstop">' .
879 t3lib_iconWorks::getSpriteIcon('actions-document-new', array('title' => $createNewRelationText)) . $createNewRelationText .
880 '</a>';
881 // wrap the selector and add a spacer to the bottom
882 $item = '<div style="margin-bottom: 20px;">' . $item . '</div>';
883 }
884
885 return $item;
886 }
887
888
889 /**
890 * Generate a link that opens an element browser in a new window.
891 * For group/db there is no way o use a "selector" like a <select>|</select>-box.
892 *
893 * @param array $conf: TCA configuration of the parent(!) field
894 * @param array $PA: An array with additional configuration options
895 * @return string A HTML link that opens an element browser in a new window
896 */
897 function renderPossibleRecordsSelectorTypeGroupDB($conf, &$PA) {
898 $foreign_table = $conf['foreign_table'];
899
900 $config = $PA['fieldConf']['config'];
901 $allowed = $config['allowed'];
902 $objectPrefix = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table;
903
904 $createNewRelationText = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createNewRelation', 1);
905 $onClick = "setFormValueOpenBrowser('db','" . ('|||' . $allowed . '|' . $objectPrefix . '|inline.checkUniqueElement||inline.importElement') . "'); return false;";
906 $item =
907 '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
908 t3lib_iconWorks::getSpriteIcon('actions-insert-record', array('title' => $createNewRelationText)) . $createNewRelationText .
909 '</a>';
910
911 return $item;
912 }
913
914
915 /**
916 * Creates the HTML code of a general link to be used on a level of inline children.
917 * The possible keys for the parameter $type are 'newRecord', 'localize' and 'synchronize'.
918 *
919 * @param string $type: The link type, values are 'newRecord', 'localize' and 'synchronize'.
920 * @param string $objectPrefix: The "path" to the child record to create (e.g. 'data-parentPageId-partenTable-parentUid-parentField-childTable]')
921 * @param array $conf: TCA configuration of the parent(!) field
922 * @return string The HTML code of the new link, wrapped in a div
923 */
924 protected function getLevelInteractionLink($type, $objectPrefix, $conf = array()) {
925 $nameObject = $this->inlineNames['object'];
926 $attributes = array();
927 switch ($type) {
928 case 'newRecord':
929 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.createnew', 1);
930 $icon = 'actions-document-new';
931 $className = 'typo3-newRecordLink';
932 $attributes['class'] = 'inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'];
933 $attributes['onclick'] = "return inline.createNewRecord('$objectPrefix')";
934 if (isset($conf['inline']['inlineNewButtonStyle']) && $conf['inline']['inlineNewButtonStyle']) {
935 $attributes['style'] = $conf['inline']['inlineNewButtonStyle'];
936 }
937 if (isset($conf['appearance']['newRecordLinkAddTitle']) && $conf['appearance']['newRecordLinkAddTitle']) {
938 $titleAddon = ' ' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$conf['foreign_table']]['ctrl']['title'], 1);
939 }
940 break;
941 case 'localize':
942 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:localizeAllRecords', 1);
943 $icon = 'actions-document-localize';
944 $className = 'typo3-localizationLink';
945 $attributes['onclick'] = "return inline.synchronizeLocalizeRecords('$objectPrefix', 'localize')";
946 break;
947 case 'synchronize':
948 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:synchronizeWithOriginalLanguage', 1);
949 $icon = 'actions-document-synchronize';
950 $className = 'typo3-synchronizationLink';
951 $attributes['class'] = 'inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'];
952 $attributes['onclick'] = "return inline.synchronizeLocalizeRecords('$objectPrefix', 'synchronize')";
953 break;
954 }
955 // Create the link:
956 $icon = ($icon ? t3lib_iconWorks::getSpriteIcon($icon, array('title' => htmlspecialchars($title . $titleAddon))) : '');
957 $link = $this->wrapWithAnchor($icon . $title . $titleAddon, '#', $attributes);
958 return '<div' . ($className ? ' class="' . $className . '"' : '') . '>' . $link . '</div>';
959 }
960
961
962 /**
963 * Creates a link/button to create new records
964 *
965 * @param string $objectPrefix: The "path" to the child record to create (e.g. 'data-parentPageId-partenTable-parentUid-parentField-childTable')
966 * @param array $conf: TCA configuration of the parent(!) field
967 * @return string The HTML code for the new record link
968 * @deprecated since TYPO3 4.2.0-beta1, this function will be removed in TYPO3 4.6.
969 */
970 function getNewRecordLink($objectPrefix, $conf = array()) {
971 t3lib_div::logDeprecatedFunction();
972
973 return $this->getLevelInteractionLink('newRecord', $objectPrefix, $conf);
974 }
975
976
977 /**
978 * Add Sortable functionality using script.acolo.us "Sortable".
979 *
980 * @param string $objectId: The container id of the object - elements inside will be sortable
981 * @return void
982 */
983 function addJavaScriptSortable($objectId) {
984 $this->fObj->additionalJS_post[] = '
985 inline.createDragAndDropSorting("' . $objectId . '");
986 ';
987 }
988
989
990 /*******************************************************
991 *
992 * Handling of AJAX calls
993 *
994 *******************************************************/
995
996
997 /**
998 * General processor for AJAX requests concerning IRRE.
999 * (called by typo3/ajax.php)
1000 *
1001 * @param array $params: additional parameters (not used here)
1002 * @param TYPO3AJAX $ajaxObj: the TYPO3AJAX object of this request
1003 * @return void
1004 */
1005 public function processAjaxRequest($params, $ajaxObj) {
1006
1007 $ajaxArguments = t3lib_div::_GP('ajax');
1008 $ajaxIdParts = explode('::', $GLOBALS['ajaxID'], 2);
1009
1010 if (isset($ajaxArguments) && is_array($ajaxArguments) && count($ajaxArguments)) {
1011 $ajaxMethod = $ajaxIdParts[1];
1012 switch ($ajaxMethod) {
1013 case 'createNewRecord':
1014 case 'synchronizeLocalizeRecords':
1015 case 'getRecordDetails':
1016 $this->isAjaxCall = TRUE;
1017 // Construct runtime environment for Inline Relational Record Editing:
1018 $this->processAjaxRequestConstruct($ajaxArguments);
1019 // Parse the DOM identifier (string), add the levels to the structure stack (array) and load the TCA config:
1020 $this->parseStructureString($ajaxArguments[0], TRUE);
1021 // Render content:
1022 $ajaxObj->setContentFormat('jsonbody');
1023 $ajaxObj->setContent(
1024 call_user_func_array(array(&$this, $ajaxMethod), $ajaxArguments)
1025 );
1026 break;
1027 case 'setExpandedCollapsedState':
1028 $ajaxObj->setContentFormat('jsonbody');
1029 call_user_func_array(array(&$this, $ajaxMethod), $ajaxArguments);
1030 break;
1031 }
1032 }
1033 }
1034
1035
1036 /**
1037 * Construct runtime environment for Inline Relational Record Editing.
1038 * - creates an anoymous SC_alt_doc in $GLOBALS['SOBE']
1039 * - creates a t3lib_TCEforms in $GLOBALS['SOBE']->tceforms
1040 * - sets ourself as reference to $GLOBALS['SOBE']->tceforms->inline
1041 * - sets $GLOBALS['SOBE']->tceforms->RTEcounter to the current situation on client-side
1042 *
1043 * @param array &$ajaxArguments: The arguments to be processed by the AJAX request
1044 * @return void
1045 */
1046 protected function processAjaxRequestConstruct(&$ajaxArguments) {
1047 global $SOBE, $BE_USER, $TYPO3_CONF_VARS;
1048
1049 require_once(PATH_typo3 . 'template.php');
1050
1051 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_alt_doc.xml');
1052
1053 // Create a new anonymous object:
1054 $SOBE = new stdClass();
1055 $SOBE->MOD_MENU = array(
1056 'showPalettes' => '',
1057 'showDescriptions' => '',
1058 'disableRTE' => ''
1059 );
1060 // Setting virtual document name
1061 $SOBE->MCONF['name'] = 'xMOD_alt_doc.php';
1062 // CLEANSE SETTINGS
1063 $SOBE->MOD_SETTINGS = t3lib_BEfunc::getModuleData(
1064 $SOBE->MOD_MENU,
1065 t3lib_div::_GP('SET'),
1066 $SOBE->MCONF['name']
1067 );
1068 // Create an instance of the document template object
1069 $SOBE->doc = t3lib_div::makeInstance('template');
1070 $SOBE->doc->backPath = $GLOBALS['BACK_PATH'];
1071 // Initialize TCEforms (rendering the forms)
1072 $SOBE->tceforms = t3lib_div::makeInstance('t3lib_TCEforms');
1073 $SOBE->tceforms->inline = $this;
1074 $SOBE->tceforms->RTEcounter = intval(array_shift($ajaxArguments));
1075 $SOBE->tceforms->initDefaultBEMode();
1076 $SOBE->tceforms->palettesCollapsed = !$SOBE->MOD_SETTINGS['showPalettes'];
1077 $SOBE->tceforms->disableRTE = $SOBE->MOD_SETTINGS['disableRTE'];
1078 $SOBE->tceforms->enableClickMenu = TRUE;
1079 $SOBE->tceforms->enableTabMenu = TRUE;
1080 // Clipboard is initialized:
1081 $SOBE->tceforms->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); // Start clipboard
1082 $SOBE->tceforms->clipObj->initializeClipboard(); // Initialize - reads the clipboard content from the user session
1083 // Setting external variables:
1084 if ($BE_USER->uc['edit_showFieldHelp'] != 'text' && $SOBE->MOD_SETTINGS['showDescriptions']) {
1085 $SOBE->tceforms->edit_showFieldHelp = 'text';
1086 }
1087 }
1088
1089
1090 /**
1091 * Determines and sets several script calls to a JSON array, that would have been executed if processed in non-AJAX mode.
1092 *
1093 * @param array &$jsonArray: Reference of the array to be used for JSON
1094 * @param array $config: The configuration of the IRRE field of the parent record
1095 * @return void
1096 */
1097 protected function getCommonScriptCalls(&$jsonArray, $config) {
1098 // Add data that would have been added at the top of a regular TCEforms call:
1099 if ($headTags = $this->getHeadTags()) {
1100 $jsonArray['headData'] = $headTags;
1101 }
1102 // Add the JavaScript data that would have been added at the bottom of a regular TCEforms call:
1103 $jsonArray['scriptCall'][] = $this->fObj->JSbottom($this->fObj->formName, TRUE);
1104 // If script.aculo.us Sortable is used, update the Observer to know the record:
1105 if ($config['appearance']['useSortable']) {
1106 $jsonArray['scriptCall'][] = "inline.createDragAndDropSorting('" . $this->inlineNames['object'] . "_records');";
1107 }
1108 // if TCEforms has some JavaScript code to be executed, just do it
1109 if ($this->fObj->extJSCODE) {
1110 $jsonArray['scriptCall'][] = $this->fObj->extJSCODE;
1111 }
1112 }
1113
1114
1115 /**
1116 * Initialize environment for AJAX calls
1117 *
1118 * @param string $method: Name of the method to be called
1119 * @param array $arguments: Arguments to be delivered to the method
1120 * @return void
1121 * @deprecated since TYPO3 4.2.0-alpha3, this function will be removed in TYPO3 4.6.
1122 */
1123 function initForAJAX($method, &$arguments) {
1124 t3lib_div::logDeprecatedFunction();
1125
1126 // Set t3lib_TCEforms::$RTEcounter to the given value:
1127 if ($method == 'createNewRecord') {
1128 $this->fObj->RTEcounter = intval(array_shift($arguments));
1129 }
1130 }
1131
1132
1133 /**
1134 * Generates an error message that transferred as JSON for AJAX calls
1135 *
1136 * @param string $message: The error message to be shown
1137 * @return array The error message in a JSON array
1138 */
1139 protected function getErrorMessageForAJAX($message) {
1140 $jsonArray = array(
1141 'data' => $message,
1142 'scriptCall' => array(
1143 'alert("' . $message . '");'
1144 )
1145 );
1146 return $jsonArray;
1147 }
1148
1149
1150 /**
1151 * Handle AJAX calls to show a new inline-record of the given table.
1152 * Normally this method is never called from inside TYPO3. Always from outside by AJAX.
1153 *
1154 * @param string $domObjectId: The calling object in hierarchy, that requested a new record.
1155 * @param string $foreignUid: If set, the new record should be inserted after that one.
1156 * @return array An array to be used for JSON
1157 */
1158 function createNewRecord($domObjectId, $foreignUid = 0) {
1159 // the current table - for this table we should add/import records
1160 $current = $this->inlineStructure['unstable'];
1161 // the parent table - this table embeds the current table
1162 $parent = $this->getStructureLevel(-1);
1163 // get TCA 'config' of the parent table
1164 if (!$this->checkConfiguration($parent['config'])) {
1165 return $this->getErrorMessageForAJAX('Wrong configuration in table ' . $parent['table']);
1166 }
1167 $config = $parent['config'];
1168
1169 $collapseAll = (isset($config['appearance']['collapseAll']) && $config['appearance']['collapseAll']);
1170 $expandSingle = (isset($config['appearance']['expandSingle']) && $config['appearance']['expandSingle']);
1171
1172 // Put the current level also to the dynNestedStack of TCEforms:
1173 $this->fObj->pushToDynNestedStack('inline', $this->inlineNames['object']);
1174
1175 // dynamically create a new record using t3lib_transferData
1176 if (!$foreignUid || !t3lib_div::testInt($foreignUid) || $config['foreign_selector']) {
1177 $record = $this->getNewRecord($this->inlineFirstPid, $current['table']);
1178 // Set language of new child record to the language of the parent record:
1179 if ($config['localizationMode'] == 'select') {
1180 $parentRecord = $this->getRecord(0, $parent['table'], $parent['uid']);
1181 $parentLanguageField = $GLOBALS['TCA'][$parent['table']]['ctrl']['languageField'];
1182 $childLanguageField = $GLOBALS['TCA'][$current['table']]['ctrl']['languageField'];
1183 if ($parentRecord[$parentLanguageField] > 0) {
1184 $record[$childLanguageField] = $parentRecord[$parentLanguageField];
1185 }
1186 }
1187
1188 // dynamically import an existing record (this could be a call from a select box)
1189 } else {
1190 $record = $this->getRecord($this->inlineFirstPid, $current['table'], $foreignUid);
1191 }
1192
1193 // now there is a foreign_selector, so there is a new record on the intermediate table, but
1194 // this intermediate table holds a field, which is responsible for the foreign_selector, so
1195 // we have to set this field to the uid we get - or if none, to a new uid
1196 if ($config['foreign_selector'] && $foreignUid) {
1197 $selConfig = $this->getPossibleRecordsSelectorConfig($config, $config['foreign_selector']);
1198 // For a selector of type group/db, prepend the tablename (<tablename>_<uid>):
1199 $record[$config['foreign_selector']] = $selConfig['type'] != 'groupdb' ? '' : $selConfig['table'] . '_';
1200 $record[$config['foreign_selector']] .= $foreignUid;
1201 }
1202
1203 // the HTML-object-id's prefix of the dynamically created record
1204 $objectPrefix = $this->inlineNames['object'] . self::Structure_Separator . $current['table'];
1205 $objectId = $objectPrefix . self::Structure_Separator . $record['uid'];
1206
1207 // render the foreign record that should passed back to browser
1208 $item = $this->renderForeignRecord($parent['uid'], $record, $config);
1209 if ($item === FALSE) {
1210 return $this->getErrorMessageForAJAX('Access denied');
1211 }
1212
1213 if (!$current['uid']) {
1214 $jsonArray = array(
1215 'data' => $item,
1216 'scriptCall' => array(
1217 "inline.domAddNewRecord('bottom','" . $this->inlineNames['object'] . "_records','$objectPrefix',json.data);",
1218 "inline.memorizeAddRecord('$objectPrefix','" . $record['uid'] . "',null,'$foreignUid');"
1219 )
1220 );
1221
1222 // append the HTML data after an existing record in the container
1223 } else {
1224 $jsonArray = array(
1225 'data' => $item,
1226 'scriptCall' => array(
1227 "inline.domAddNewRecord('after','" . $domObjectId . '_div' . "','$objectPrefix',json.data);",
1228 "inline.memorizeAddRecord('$objectPrefix','" . $record['uid'] . "','" . $current['uid'] . "','$foreignUid');"
1229 )
1230 );
1231 }
1232 $this->getCommonScriptCalls($jsonArray, $config);
1233 // Collapse all other records if requested:
1234 if (!$collapseAll && $expandSingle) {
1235 $jsonArray['scriptCall'][] = "inline.collapseAllRecords('$objectId', '$objectPrefix', '" . $record['uid'] . "');";
1236 }
1237 // tell the browser to scroll to the newly created record
1238 $jsonArray['scriptCall'][] = "Element.scrollTo('" . $objectId . "_div');";
1239 // fade out and fade in the new record in the browser view to catch the user's eye
1240 $jsonArray['scriptCall'][] = "inline.fadeOutFadeIn('" . $objectId . "_div');";
1241
1242 // Remove the current level also from the dynNestedStack of TCEforms:
1243 $this->fObj->popFromDynNestedStack();
1244
1245 // Return the JSON array:
1246 return $jsonArray;
1247 }
1248
1249
1250 /**
1251 * Handle AJAX calls to localize all records of a parent, localize a single record or to synchronize with the original language parent.
1252 *
1253 * @param string $domObjectId: The calling object in hierarchy, that requested a new record.
1254 * @param mixed $type: Defines the type 'localize' or 'synchronize' (string) or a single uid to be localized (integer)
1255 * @return array An array to be used for JSON
1256 */
1257 protected function synchronizeLocalizeRecords($domObjectId, $type) {
1258 $jsonArray = FALSE;
1259 if (t3lib_div::inList('localize,synchronize', $type) || t3lib_div::testInt($type)) {
1260 // The current level:
1261 $current = $this->inlineStructure['unstable'];
1262 // The parent level:
1263 $parent = $this->getStructureLevel(-1);
1264 $parentRecord = $this->getRecord(0, $parent['table'], $parent['uid']);
1265
1266 $cmd = array();
1267 $cmd[$parent['table']][$parent['uid']]['inlineLocalizeSynchronize'] = $parent['field'] . ',' . $type;
1268
1269 /* @var t3lib_TCEmain */
1270 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
1271 $tce->stripslashes_values = FALSE;
1272 $tce->start(array(), $cmd);
1273 $tce->process_cmdmap();
1274 $newItemList = $tce->registerDBList[$parent['table']][$parent['uid']][$parent['field']];
1275 unset($tce);
1276
1277 $jsonArray = $this->getExecuteChangesJsonArray($parentRecord[$parent['field']], $newItemList);
1278 $this->getCommonScriptCalls($jsonArray, $parent['config']);
1279 }
1280 return $jsonArray;
1281 }
1282
1283 /**
1284 * Handle AJAX calls to dynamically load the form fields of a given record.
1285 * (basically a copy of "createNewRecord")
1286 * Normally this method is never called from inside TYPO3. Always from outside by AJAX.
1287 *
1288 * @param string $domObjectId: The calling object in hierarchy, that requested a new record.
1289 * @return array An array to be used for JSON
1290 */
1291 function getRecordDetails($domObjectId) {
1292 // the current table - for this table we should add/import records
1293 $current = $this->inlineStructure['unstable'];
1294 // the parent table - this table embeds the current table
1295 $parent = $this->getStructureLevel(-1);
1296 // get TCA 'config' of the parent table
1297 if (!$this->checkConfiguration($parent['config'])) {
1298 return $this->getErrorMessageForAJAX('Wrong configuration in table ' . $parent['table']);
1299 }
1300 $config = $parent['config'];
1301 // set flag in config so that only the fields are rendered
1302 $config['renderFieldsOnly'] = TRUE;
1303
1304 $collapseAll = (isset($config['appearance']['collapseAll']) && $config['appearance']['collapseAll']);
1305 $expandSingle = (isset($config['appearance']['expandSingle']) && $config['appearance']['expandSingle']);
1306
1307 // Put the current level also to the dynNestedStack of TCEforms:
1308 $this->fObj->pushToDynNestedStack('inline', $this->inlineNames['object']);
1309
1310 $record = $this->getRecord($this->inlineFirstPid, $current['table'], $current['uid']);
1311
1312 // the HTML-object-id's prefix of the dynamically created record
1313 $objectPrefix = $this->inlineNames['object'] . self::Structure_Separator . $current['table'];
1314 $objectId = $objectPrefix . self::Structure_Separator . $record['uid'];
1315
1316 $item = $this->renderForeignRecord($parent['uid'], $record, $config);
1317 if ($item === FALSE) {
1318 return $this->getErrorMessageForAJAX('Access denied');
1319 }
1320
1321 $jsonArray = array(
1322 'data' => $item,
1323 'scriptCall' => array(
1324 'inline.domAddRecordDetails(\'' . $domObjectId . '\',\'' . $objectPrefix . '\',' . ($expandSingle ? '1' : '0') . ',json.data);',
1325 )
1326 );
1327
1328 $this->getCommonScriptCalls($jsonArray, $config);
1329 // Collapse all other records if requested:
1330 if (!$collapseAll && $expandSingle) {
1331 $jsonArray['scriptCall'][] = 'inline.collapseAllRecords(\'' . $objectId . '\',\'' . $objectPrefix . '\',\'' . $record['uid'] . '\');';
1332 }
1333
1334 // Remove the current level also from the dynNestedStack of TCEforms:
1335 $this->fObj->popFromDynNestedStack();
1336
1337 // Return the JSON array:
1338 return $jsonArray;
1339 }
1340
1341
1342 /**
1343 * Generates a JSON array which executes the changes and thus updates the forms view.
1344 *
1345 * @param string $oldItemList: List of related child reocrds before changes were made (old)
1346 * @param string $newItemList: List of related child records after changes where made (new)
1347 * @return array An array to be used for JSON
1348 */
1349 protected function getExecuteChangesJsonArray($oldItemList, $newItemList) {
1350 $data = '';
1351 $parent = $this->getStructureLevel(-1);
1352 $current = $this->inlineStructure['unstable'];
1353
1354 $jsonArray = array('scriptCall' => array());
1355 $jsonArrayScriptCall =& $jsonArray['scriptCall'];
1356
1357 $nameObject = $this->inlineNames['object'];
1358 $nameObjectForeignTable = $nameObject . self::Structure_Separator . $current['table'];
1359 // Get the name of the field pointing to the original record:
1360 $transOrigPointerField = $GLOBALS['TCA'][$current['table']]['ctrl']['transOrigPointerField'];
1361 // Get the name of the field used as foreign selector (if any):
1362 $foreignSelector = (isset($parent['config']['foreign_selector']) && $parent['config']['foreign_selector'] ? $parent['config']['foreign_selector'] : FALSE);
1363 // Convert lists to array with uids of child records:
1364 $oldItems = $this->getRelatedRecordsUidArray($oldItemList);
1365 $newItems = $this->getRelatedRecordsUidArray($newItemList);
1366 // Determine the items that were localized or localized:
1367 $removedItems = array_diff($oldItems, $newItems);
1368 $localizedItems = array_diff($newItems, $oldItems);
1369 // Set the items that should be removed in the forms view:
1370 foreach ($removedItems as $item) {
1371 $jsonArrayScriptCall[] = "inline.deleteRecord('" . $nameObjectForeignTable . self::Structure_Separator . $item . "', {forceDirectRemoval: true});";
1372 }
1373 // Set the items that should be added in the forms view:
1374 foreach ($localizedItems as $item) {
1375 $row = $this->getRecord($this->inlineFirstPid, $current['table'], $item);
1376 $selectedValue = ($foreignSelector ? "'" . $row[$foreignSelector] . "'" : 'null');
1377 $data .= $this->renderForeignRecord($parent['uid'], $row, $parent['config']);
1378 $jsonArrayScriptCall[] = "inline.memorizeAddRecord('$nameObjectForeignTable', '" . $item . "', null, $selectedValue);";
1379 // Remove possible virtual records in the form which showed that a child records could be localized:
1380 if (isset($row[$transOrigPointerField]) && $row[$transOrigPointerField]) {
1381 $jsonArrayScriptCall[] = "inline.fadeAndRemove('" . $nameObjectForeignTable . self::Structure_Separator . $row[$transOrigPointerField] . '_div' . "');";
1382 }
1383 }
1384 if ($data) {
1385 $data = $GLOBALS['LANG']->csConvObj->utf8_encode($data, $GLOBALS['LANG']->charSet);
1386 $jsonArray['data'] = $data;
1387 array_unshift(
1388 $jsonArrayScriptCall,
1389 "inline.domAddNewRecord('bottom', '" . $nameObject . "_records', '$nameObjectForeignTable', json.data);"
1390 );
1391 }
1392
1393 return $jsonArray;
1394 }
1395
1396
1397 /**
1398 * Save the expanded/collapsed state of a child record in the BE_USER->uc.
1399 *
1400 * @param string $domObjectId: The calling object in hierarchy, that requested a new record.
1401 * @param string $expand: Whether this record is expanded.
1402 * @param string $collapse: Whether this record is collapsed.
1403 * @return void
1404 */
1405 function setExpandedCollapsedState($domObjectId, $expand, $collapse) {
1406 // parse the DOM identifier (string), add the levels to the structure stack (array), but don't load TCA config
1407 $this->parseStructureString($domObjectId, FALSE);
1408 // the current table - for this table we should add/import records
1409 $current = $this->inlineStructure['unstable'];
1410 // the top parent table - this table embeds the current table
1411 $top = $this->getStructureLevel(0);
1412
1413 // only do some action if the top record and the current record were saved before
1414 if (t3lib_div::testInt($top['uid'])) {
1415 $inlineView = (array) unserialize($GLOBALS['BE_USER']->uc['inlineView']);
1416 $inlineViewCurrent =& $inlineView[$top['table']][$top['uid']];
1417
1418 $expandUids = t3lib_div::trimExplode(',', $expand);
1419 $collapseUids = t3lib_div::trimExplode(',', $collapse);
1420
1421 // set records to be expanded
1422 foreach ($expandUids as $uid) {
1423 $inlineViewCurrent[$current['table']][] = $uid;
1424 }
1425 // set records to be collapsed
1426 foreach ($collapseUids as $uid) {
1427 $inlineViewCurrent[$current['table']] = $this->removeFromArray($uid, $inlineViewCurrent[$current['table']]);
1428 }
1429
1430 // save states back to database
1431 if (is_array($inlineViewCurrent[$current['table']])) {
1432 $inlineViewCurrent[$current['table']] = array_unique($inlineViewCurrent[$current['table']]);
1433 $GLOBALS['BE_USER']->uc['inlineView'] = serialize($inlineView);
1434 $GLOBALS['BE_USER']->writeUC();
1435 }
1436 }
1437 }
1438
1439
1440 /*******************************************************
1441 *
1442 * Get data from database and handle relations
1443 *
1444 *******************************************************/
1445
1446
1447 /**
1448 * Get the related records of the embedding item, this could be 1:n, m:n.
1449 * Returns an associative array with the keys records and count. 'count' contains only real existing records on the current parent record.
1450 *
1451 * @param string $table: The table name of the record
1452 * @param string $field: The field name which this element is supposed to edit
1453 * @param array $row: The record data array where the value(s) for the field can be found
1454 * @param array $PA: An array with additional configuration options.
1455 * @param array $config: (Redundant) content of $PA['fieldConf']['config'] (for convenience)
1456 * @return array The records related to the parent item as associative array.
1457 */
1458 function getRelatedRecords($table, $field, $row, &$PA, $config) {
1459 $records = array();
1460 $pid = $row['pid'];
1461 $elements = $PA['itemFormElValue'];
1462 $foreignTable = $config['foreign_table'];
1463
1464 $localizationMode = t3lib_BEfunc::getInlineLocalizationMode($table, $config);
1465
1466 if ($localizationMode != FALSE) {
1467 $language = intval($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
1468 $transOrigPointer = intval($row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']]);
1469 if ($language > 0 && $transOrigPointer) {
1470 // Localization in mode 'keep', isn't a real localization, but keeps the children of the original parent record:
1471 if ($localizationMode == 'keep') {
1472 $transOrigRec = $this->getRecord(0, $table, $transOrigPointer);
1473 $elements = $transOrigRec[$field];
1474 $pid = $transOrigRec['pid'];
1475 // Localization in modes 'select', 'all' or 'sync' offer a dynamic localization and synchronization with the original language record:
1476 } elseif ($localizationMode == 'select') {
1477 $transOrigRec = $this->getRecord(0, $table, $transOrigPointer);
1478 $pid = $transOrigRec['pid'];
1479 $recordsOriginal = $this->getRelatedRecordsArray($pid, $foreignTable, $transOrigRec[$field]);
1480 }
1481 }
1482 }
1483
1484 $records = $this->getRelatedRecordsArray($pid, $foreignTable, $elements);
1485 $relatedRecords = array('records' => $records, 'count' => count($records));
1486
1487 // Merge original language with current localization and show differences:
1488 if (is_array($recordsOriginal)) {
1489 $options = array(
1490 'showPossible' => (isset($config['appearance']['showPossibleLocalizationRecords']) && $config['appearance']['showPossibleLocalizationRecords']),
1491 'showRemoved' => (isset($config['appearance']['showRemovedLocalizationRecords']) && $config['appearance']['showRemovedLocalizationRecords']),
1492 );
1493 if ($options['showPossible'] || $options['showRemoved']) {
1494 $relatedRecords['records'] = $this->getLocalizationDifferences($foreignTable, $options, $recordsOriginal, $records);
1495 }
1496 }
1497
1498 return $relatedRecords;
1499 }
1500
1501
1502 /**
1503 * Gets the related records of the embedding item, this could be 1:n, m:n.
1504 *
1505 * @param integer $pid: The pid of the parent record
1506 * @param string $table: The table name of the record
1507 * @param string $itemList: The list of related child records
1508 * @return array The records related to the parent item
1509 */
1510 protected function getRelatedRecordsArray($pid, $table, $itemList) {
1511 $records = array();
1512 $itemArray = $this->getRelatedRecordsUidArray($itemList);
1513 // Perform modification of the selected items array:
1514 foreach ($itemArray as $uid) {
1515 // Get the records for this uid using t3lib_transferdata:
1516 if ($record = $this->getRecord($pid, $table, $uid)) {
1517 $records[$uid] = $record;
1518 }
1519 }
1520 return $records;
1521 }
1522
1523
1524 /**
1525 * Gets an array with the uids of related records out of a list of items.
1526 * This list could contain more information than required. This methods just
1527 * extracts the uids.
1528 *
1529 * @param string $itemList: The list of related child records
1530 * @return array An array with uids
1531 */
1532 protected function getRelatedRecordsUidArray($itemList) {
1533 $itemArray = t3lib_div::trimExplode(',', $itemList, 1);
1534 // Perform modification of the selected items array:
1535 foreach ($itemArray as $key => &$value) {
1536 $parts = explode('|', $value, 2);
1537 $value = $parts[0];
1538 }
1539 return $itemArray;
1540 }
1541
1542
1543 /**
1544 * Gets the difference between current localized structure and the original language structure.
1545 * If there are records which once were localized but don't exist in the original version anymore, the record row is marked with '__remove'.
1546 * If there are records which can be localized and exist only in the original version, the record row is marked with '__create' and '__virtual'.
1547 *
1548 * @param string $table: The table name of the parent records
1549 * @param array $options: Options defining what kind of records to display
1550 * @param array $recordsOriginal: The uids of the child records of the original language
1551 * @param array $recordsLocalization: The uids of the child records of the current localization
1552 * @return array Merged array of uids of the child records of both versions
1553 */
1554 protected function getLocalizationDifferences($table, array $options, array $recordsOriginal, array $recordsLocalization) {
1555 $records = array();
1556 $transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
1557 // Compare original to localized version of the records:
1558 foreach ($recordsLocalization as $uid => $row) {
1559 // If the record points to a original translation which doesn't exist anymore, it could be removed:
1560 if (isset($row[$transOrigPointerField]) && $row[$transOrigPointerField] > 0) {
1561 $transOrigPointer = $row[$transOrigPointerField];
1562 if (isset($recordsOriginal[$transOrigPointer])) {
1563 unset($recordsOriginal[$transOrigPointer]);
1564 } elseif ($options['showRemoved']) {
1565 $row['__remove'] = TRUE;
1566 }
1567 }
1568 $records[$uid] = $row;
1569 }
1570 // Process the remaining records in the original unlocalized parent:
1571 if ($options['showPossible']) {
1572 foreach ($recordsOriginal as $uid => $row) {
1573 $row['__create'] = TRUE;
1574 $row['__virtual'] = TRUE;
1575 $records[$uid] = $row;
1576 }
1577 }
1578 return $records;
1579 }
1580
1581
1582 /**
1583 * Get possible records.
1584 * Copied from TCEform and modified.
1585 *
1586 * @param string The table name of the record
1587 * @param string The field name which this element is supposed to edit
1588 * @param array The record data array where the value(s) for the field can be found
1589 * @param array An array with additional configuration options.
1590 * @param string $checkForConfField: For which field in the foreign_table the possible records should be fetched
1591 * @return mixed Array of possible record items; false if type is "group/db", then everything could be "possible"
1592 */
1593 function getPossibleRecords($table, $field, $row, $conf, $checkForConfField = 'foreign_selector') {
1594 // ctrl configuration from TCA:
1595 $tcaTableCtrl = $GLOBALS['TCA'][$table]['ctrl'];
1596 // Field configuration from TCA:
1597 $foreign_table = $conf['foreign_table'];
1598 $foreign_check = $conf[$checkForConfField];
1599
1600 $foreignConfig = $this->getPossibleRecordsSelectorConfig($conf, $foreign_check);
1601 $PA = $foreignConfig['PA'];
1602 $config = $PA['fieldConf']['config'];
1603
1604 if ($foreignConfig['type'] == 'select') {
1605 // Getting the selector box items from the system
1606 $selItems = $this->fObj->addSelectOptionsToItemArray(
1607 $this->fObj->initItemArray($PA['fieldConf']),
1608 $PA['fieldConf'],
1609 $this->fObj->setTSconfig($table, $row),
1610 $field
1611 );
1612 // Possibly filter some items:
1613 $keepItemsFunc = create_function('$value', 'return $value[1];');
1614 $selItems = t3lib_div::keepItemsInArray($selItems, $PA['fieldTSConfig']['keepItems'], $keepItemsFunc);
1615 // Possibly add some items:
1616 $selItems = $this->fObj->addItems($selItems, $PA['fieldTSConfig']['addItems.']);
1617 if (isset($config['itemsProcFunc']) && $config['itemsProcFunc']) {
1618 $selItems = $this->fObj->procItems($selItems, $PA['fieldTSConfig']['itemsProcFunc.'], $config, $table, $row, $field);
1619 }
1620
1621 // Possibly remove some items:
1622 $removeItems = t3lib_div::trimExplode(',', $PA['fieldTSConfig']['removeItems'], 1);
1623 foreach ($selItems as $tk => $p) {
1624
1625 // Checking languages and authMode:
1626 $languageDeny = $tcaTableCtrl['languageField'] && !strcmp($tcaTableCtrl['languageField'], $field) && !$GLOBALS['BE_USER']->checkLanguageAccess($p[1]);
1627 $authModeDeny = $config['form_type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode($table, $field, $p[1], $config['authMode']);
1628 if (in_array($p[1], $removeItems) || $languageDeny || $authModeDeny) {
1629 unset($selItems[$tk]);
1630 } elseif (isset($PA['fieldTSConfig']['altLabels.'][$p[1]])) {
1631 $selItems[$tk][0] = $this->fObj->sL($PA['fieldTSConfig']['altLabels.'][$p[1]]);
1632 }
1633
1634 // Removing doktypes with no access:
1635 if (($table === 'pages' || $table === 'pages_language_overlay') && $field === 'doktype') {
1636 if (!($GLOBALS['BE_USER']->isAdmin() || t3lib_div::inList($GLOBALS['BE_USER']->groupData['pagetypes_select'], $p[1]))) {
1637 unset($selItems[$tk]);
1638 }
1639 }
1640 }
1641 } else {
1642 $selItems = FALSE;
1643 }
1644
1645 return $selItems;
1646 }
1647
1648 /**
1649 * Gets the uids of a select/selector that should be unique an have already been used.
1650 *
1651 * @param array $records: All inline records on this level
1652 * @param array $conf: The TCA field configuration of the inline field to be rendered
1653 * @param boolean $splitValue: for usage with group/db, values come like "tx_table_123|Title%20abc", but we need "tx_table" and "123"
1654 * @return array The uids, that have been used already and should be used unique
1655 */
1656 function getUniqueIds($records, $conf = array(), $splitValue = FALSE) {
1657 $uniqueIds = array();
1658
1659 if (isset($conf['foreign_unique']) && $conf['foreign_unique'] && count($records)) {
1660 foreach ($records as $rec) {
1661 // Skip virtual records (e.g. shown in localization mode):
1662 if (!isset($rec['__virtual']) || !$rec['__virtual']) {
1663 $value = $rec[$conf['foreign_unique']];
1664 // Split the value and extract the table and uid:
1665 if ($splitValue) {
1666 $valueParts = t3lib_div::trimExplode('|', $value);
1667 $itemParts = explode('_', $valueParts[0]);
1668 $value = array(
1669 'uid' => array_pop($itemParts),
1670 'table' => implode('_', $itemParts)
1671 );
1672 }
1673 $uniqueIds[$rec['uid']] = $value;
1674 }
1675 }
1676 }
1677
1678 return $uniqueIds;
1679 }
1680
1681
1682 /**
1683 * Determines the corrected pid to be used for a new record.
1684 * The pid to be used can be defined by a Page TSconfig.
1685 *
1686 * @param string $table: The table name
1687 * @param integer $parentPid: The pid of the parent record
1688 * @return integer The corrected pid to be used for a new record
1689 */
1690 protected function getNewRecordPid($table, $parentPid = NULL) {
1691 $newRecordPid = $this->inlineFirstPid;
1692 $pageTS = t3lib_beFunc::getPagesTSconfig($parentPid, TRUE);
1693 if (isset($pageTS['TCAdefaults.'][$table . '.']['pid']) && t3lib_div::testInt($pageTS['TCAdefaults.'][$table . '.']['pid'])) {
1694 $newRecordPid = $pageTS['TCAdefaults.'][$table . '.']['pid'];
1695 } elseif (isset($parentPid) && t3lib_div::testInt($parentPid)) {
1696 $newRecordPid = $parentPid;
1697 }
1698 return $newRecordPid;
1699 }
1700
1701
1702 /**
1703 * Get a single record row for a TCA table from the database.
1704 * t3lib_transferData is used for "upgrading" the values, especially the relations.
1705 *
1706 * @param integer $pid: The pid of the page the record should be stored (only relevant for NEW records)
1707 * @param string $table: The table to fetch data from (= foreign_table)
1708 * @param string $uid: The uid of the record to fetch, or the pid if a new record should be created
1709 * @param string $cmd: The command to perform, empty or 'new'
1710 * @return array A record row from the database post-processed by t3lib_transferData
1711 */
1712 function getRecord($pid, $table, $uid, $cmd = '') {
1713 // Fetch workspace version of a record (if any):
1714 if ($cmd !== 'new' && $GLOBALS['BE_USER']->workspace !== 0) {
1715 $workspaceVersion = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $table, $uid, 'uid');
1716 if ($workspaceVersion !== FALSE) {
1717 $uid = $workspaceVersion['uid'];
1718 }
1719 }
1720
1721 $trData = t3lib_div::makeInstance('t3lib_transferData');
1722 $trData->addRawData = TRUE;
1723 $trData->lockRecords = 1;
1724 $trData->disableRTE = $GLOBALS['SOBE']->MOD_SETTINGS['disableRTE'];
1725 // if a new record should be created
1726 $trData->fetchRecord($table, $uid, ($cmd === 'new' ? 'new' : ''));
1727 reset($trData->regTableItems_data);
1728 $rec = current($trData->regTableItems_data);
1729
1730 return $rec;
1731 }
1732
1733
1734 /**
1735 * Wrapper. Calls getRecord in case of a new record should be created.
1736 *
1737 * @param integer $pid: The pid of the page the record should be stored (only relevant for NEW records)
1738 * @param string $table: The table to fetch data from (= foreign_table)
1739 * @return array A record row from the database post-processed by t3lib_transferData
1740 */
1741 function getNewRecord($pid, $table) {
1742 $rec = $this->getRecord($pid, $table, $pid, 'new');
1743 $rec['uid'] = uniqid('NEW');
1744 $rec['pid'] = $this->getNewRecordPid($table, $pid);
1745 return $rec;
1746 }
1747
1748
1749 /*******************************************************
1750 *
1751 * Structure stack for handling inline objects/levels
1752 *
1753 *******************************************************/
1754
1755
1756 /**
1757 * Add a new level on top of the structure stack. Other functions can access the
1758 * stack and determine, if there's possibly a endless loop.
1759 *
1760 * @param string $table: The table name of the record
1761 * @param string $uid: The uid of the record that embeds the inline data
1762 * @param string $field: The field name which this element is supposed to edit
1763 * @param array $config: The TCA-configuration of the inline field
1764 * @return void
1765 */
1766 function pushStructure($table, $uid, $field = '', $config = array()) {
1767 $this->inlineStructure['stable'][] = array(
1768 'table' => $table,
1769 'uid' => $uid,
1770 'field' => $field,
1771 'config' => $config,
1772 'localizationMode' => t3lib_BEfunc::getInlineLocalizationMode($table, $config),
1773 );
1774 $this->updateStructureNames();
1775 }
1776
1777
1778 /**
1779 * Remove the item on top of the structure stack and return it.
1780 *
1781 * @return array The top item of the structure stack - array(<table>,<uid>,<field>,<config>)
1782 */
1783 function popStructure() {
1784 if (count($this->inlineStructure['stable'])) {
1785 $popItem = array_pop($this->inlineStructure['stable']);
1786 $this->updateStructureNames();
1787 }
1788 return $popItem;
1789 }
1790
1791
1792 /**
1793 * For common use of DOM object-ids and form field names of a several inline-level,
1794 * these names/identifiers are preprocessed and set to $this->inlineNames.
1795 * This function is automatically called if a level is pushed to or removed from the
1796 * inline structure stack.
1797 *
1798 * @return void
1799 */
1800 function updateStructureNames() {
1801 $current = $this->getStructureLevel(-1);
1802 // if there are still more inline levels available
1803 if ($current !== FALSE) {
1804 $this->inlineNames = array(
1805 'form' => $this->prependFormFieldNames . $this->getStructureItemName($current, self::Disposal_AttributeName),
1806 'object' => $this->prependNaming . self::Structure_Separator . $this->inlineFirstPid . self::Structure_Separator . $this->getStructurePath(),
1807 );
1808 // if there are no more inline levels available
1809 } else {
1810 $this->inlineNames = array();
1811 }
1812 }
1813
1814
1815 /**
1816 * Create a name/id for usage in HTML output of a level of the structure stack to be used in form names.
1817 *
1818 * @param array $levelData: Array of a level of the structure stack (containing the keys table, uid and field)
1819 * @param string $disposal: How the structure name is used (e.g. as <div id="..."> or <input name="..." />)
1820 * @return string The name/id of that level, to be used for HTML output
1821 */
1822 function getStructureItemName($levelData, $disposal = self::Disposal_AttributeId) {
1823 if (is_array($levelData)) {
1824 $parts = array($levelData['table'], $levelData['uid']);
1825 if (isset($levelData['field'])) {
1826 $parts[] = $levelData['field'];
1827 }
1828
1829 // Use in name attributes:
1830 if ($disposal === self::Disposal_AttributeName) {
1831 $name = '[' . implode('][', $parts) . ']';
1832 // Use in id attributes:
1833 } else {
1834 $name = implode(self::Structure_Separator, $parts);
1835 }
1836 }
1837 return $name;
1838 }
1839
1840
1841 /**
1842 * Get a level from the stack and return the data.
1843 * If the $level value is negative, this function works top-down,
1844 * if the $level value is positive, this function works bottom-up.
1845 *
1846 * @param integer $level: Which level to return
1847 * @return array The item of the stack at the requested level
1848 */
1849 function getStructureLevel($level) {
1850 $inlineStructureCount = count($this->inlineStructure['stable']);
1851 if ($level < 0) {
1852 $level = $inlineStructureCount + $level;
1853 }
1854 if ($level >= 0 && $level < $inlineStructureCount) {
1855 return $this->inlineStructure['stable'][$level];
1856 }
1857 else
1858 {
1859 return FALSE;
1860 }
1861 }
1862
1863
1864 /**
1865 * Get the identifiers of a given depth of level, from the top of the stack to the bottom.
1866 * An identifier looks like "<table>-<uid>-<field>".
1867 *
1868 * @param integer $structureDepth: How much levels to output, beginning from the top of the stack
1869 * @return string The path of identifiers
1870 */
1871 function getStructurePath($structureDepth = -1) {
1872 $structureLevels = array();
1873 $structureCount = count($this->inlineStructure['stable']);
1874
1875 if ($structureDepth < 0 || $structureDepth > $structureCount) {
1876 $structureDepth = $structureCount;
1877 }
1878
1879 for ($i = 1; $i <= $structureDepth; $i++) {
1880 array_unshift(
1881 $structureLevels,
1882 $this->getStructureItemName(
1883 $this->getStructureLevel(-$i),
1884 self::Disposal_AttributeId
1885 )
1886 );
1887 }
1888
1889 return implode(self::Structure_Separator, $structureLevels);
1890 }
1891
1892
1893 /**
1894 * Convert the DOM object-id of an inline container to an array.
1895 * The object-id could look like 'data-parentPageId-tx_mmftest_company-1-employees'.
1896 * The result is written to $this->inlineStructure.
1897 * There are two keys:
1898 * - 'stable': Containing full qualified identifiers (table, uid and field)
1899 * - 'unstable': Containting partly filled data (e.g. only table and possibly field)
1900 *
1901 * @param string $domObjectId: The DOM object-id
1902 * @param boolean $loadConfig: Load the TCA configuration for that level (default: true)
1903 * @return void
1904 */
1905 function parseStructureString($string, $loadConfig = TRUE) {
1906 $unstable = array();
1907 $vector = array('table', 'uid', 'field');
1908 $pattern = '/^' . $this->prependNaming . self::Structure_Separator . '(.+?)' . self::Structure_Separator . '(.+)$/';
1909 if (preg_match($pattern, $string, $match)) {
1910 $this->inlineFirstPid = $match[1];
1911 $parts = explode(self::Structure_Separator, $match[2]);
1912 $partsCnt = count($parts);
1913 for ($i = 0; $i < $partsCnt; $i++) {
1914 if ($i > 0 && $i % 3 == 0) {
1915 // load the TCA configuration of the table field and store it in the stack
1916 if ($loadConfig) {
1917 t3lib_div::loadTCA($unstable['table']);
1918 $unstable['config'] = $GLOBALS['TCA'][$unstable['table']]['columns'][$unstable['field']]['config'];
1919 // Fetch TSconfig:
1920 $TSconfig = $this->fObj->setTSconfig(
1921 $unstable['table'],
1922 array('uid' => $unstable['uid'], 'pid' => $this->inlineFirstPid),
1923 $unstable['field']
1924 );
1925 // Override TCA field config by TSconfig:
1926 if (!$TSconfig['disabled']) {
1927 $unstable['config'] = $this->fObj->overrideFieldConf($unstable['config'], $TSconfig);
1928 }
1929 $unstable['localizationMode'] = t3lib_BEfunc::getInlineLocalizationMode($unstable['table'], $unstable['config']);
1930 }
1931 $this->inlineStructure['stable'][] = $unstable;
1932 $unstable = array();
1933 }
1934 $unstable[$vector[$i % 3]] = $parts[$i];
1935 }
1936 $this->updateStructureNames();
1937 if (count($unstable)) {
1938 $this->inlineStructure['unstable'] = $unstable;
1939 }
1940 }
1941 }
1942
1943
1944 /*******************************************************
1945 *
1946 * Helper functions
1947 *
1948 *******************************************************/
1949
1950
1951 /**
1952 * Does some checks on the TCA configuration of the inline field to render.
1953 *
1954 * @param array $config: Reference to the TCA field configuration
1955 * @param string $table: The table name of the record
1956 * @param string $field: The field name which this element is supposed to edit
1957 * @param array $row: The record data array of the parent
1958 * @return boolean If critical configuration errors were found, false is returned
1959 */
1960 function checkConfiguration(&$config) {
1961 $foreign_table = $config['foreign_table'];
1962
1963 // An inline field must have a foreign_table, if not, stop all further inline actions for this field:
1964 if (!$foreign_table || !is_array($GLOBALS['TCA'][$foreign_table])) {
1965 return FALSE;
1966 }
1967 // Init appearance if not set:
1968 if (!isset($config['appearance']) || !is_array($config['appearance'])) {
1969 $config['appearance'] = array();
1970 }
1971 // 'newRecordLinkPosition' is deprecated since TYPO3 4.2.0-beta1, this is for backward compatibility:
1972 if (!isset($config['appearance']['levelLinksPosition']) && isset($config['appearance']['newRecordLinkPosition']) && $config['appearance']['newRecordLinkPosition']) {
1973 t3lib_div::deprecationLog('TCA contains a deprecated definition using "newRecordLinkPosition"');
1974 $config['appearance']['levelLinksPosition'] = $config['appearance']['newRecordLinkPosition'];
1975 }
1976 // Set the position/appearance of the "Create new record" link:
1977 if (isset($config['foreign_selector']) && $config['foreign_selector'] && (!isset($config['appearance']['useCombination']) || !$config['appearance']['useCombination'])) {
1978 $config['appearance']['levelLinksPosition'] = 'none';
1979 } elseif (!isset($config['appearance']['levelLinksPosition']) || !in_array($config['appearance']['levelLinksPosition'], array('top', 'bottom', 'both', 'none'))) {
1980 $config['appearance']['levelLinksPosition'] = 'top';
1981 }
1982 // Defines which controls should be shown in header of each record:
1983 $enabledControls = array(
1984 'info' => TRUE,
1985 'new' => TRUE,
1986 'dragdrop' => TRUE,
1987 'sort' => TRUE,
1988 'hide' => TRUE,
1989 'delete' => TRUE,
1990 'localize' => TRUE,
1991 );
1992 if (isset($config['appearance']['enabledControls']) && is_array($config['appearance']['enabledControls'])) {
1993 $config['appearance']['enabledControls'] = array_merge($enabledControls, $config['appearance']['enabledControls']);
1994 } else {
1995 $config['appearance']['enabledControls'] = $enabledControls;
1996 }
1997
1998 return TRUE;
1999 }
2000
2001
2002 /**
2003 * Checks the page access rights (Code for access check mostly taken from alt_doc.php)
2004 * as well as the table access rights of the user.
2005 *
2006 * @param string $cmd: The command that sould be performed ('new' or 'edit')
2007 * @param string $table: The table to check access for
2008 * @param string $theUid: The record uid of the table
2009 * @return boolean Returns true is the user has access, or false if not
2010 */
2011 function checkAccess($cmd, $table, $theUid) {
2012 // Checking if the user has permissions? (Only working as a precaution, because the final permission check is always down in TCE. But it's good to notify the user on beforehand...)
2013 // First, resetting flags.
2014 $hasAccess = 0;
2015 $deniedAccessReason = '';
2016
2017 // Admin users always have acces:
2018 if ($GLOBALS['BE_USER']->isAdmin()) {
2019 return TRUE;
2020 }
2021 // If the command is to create a NEW record...:
2022 if ($cmd == 'new') {
2023 // If the pid is numerical, check if it's possible to write to this page:
2024 if (t3lib_div::testInt($this->inlineFirstPid)) {
2025 $calcPRec = t3lib_BEfunc::getRecord('pages', $this->inlineFirstPid);
2026 if (!is_array($calcPRec)) {
2027 return FALSE;
2028 }
2029 $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec); // Permissions for the parent page
2030 if ($table == 'pages') { // If pages:
2031 $hasAccess = $CALC_PERMS & 8 ? 1 : 0; // Are we allowed to create new subpages?
2032 } else {
2033 $hasAccess = $CALC_PERMS & 16 ? 1 : 0; // Are we allowed to edit content on this page?
2034 }
2035 // If the pid is a NEW... value, the access will be checked on creating the page:
2036 // (if the page with the same NEW... value could be created in TCEmain, this child record can neither)
2037 } else {
2038 $hasAccess = 1;
2039 }
2040 } else { // Edit:
2041 $calcPRec = t3lib_BEfunc::getRecord($table, $theUid);
2042 t3lib_BEfunc::fixVersioningPid($table, $calcPRec);
2043 if (is_array($calcPRec)) {
2044 if ($table == 'pages') { // If pages:
2045 $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms($calcPRec);
2046 $hasAccess = $CALC_PERMS & 2 ? 1 : 0;
2047 } else {
2048 $CALC_PERMS = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $calcPRec['pid'])); // Fetching pid-record first.
2049 $hasAccess = $CALC_PERMS & 16 ? 1 : 0;
2050 }
2051
2052 // Check internals regarding access:
2053 if ($hasAccess) {
2054 $hasAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($table, $calcPRec);
2055 }
2056 }
2057 }
2058
2059 if (!$GLOBALS['BE_USER']->check('tables_modify', $table)) {
2060 $hasAccess = 0;
2061 }
2062
2063 if (!$hasAccess) {
2064 $deniedAccessReason = $GLOBALS['BE_USER']->errorMsg;
2065 if ($deniedAccessReason) {
2066 debug($deniedAccessReason);
2067 }
2068 }
2069
2070 return $hasAccess ? TRUE : FALSE;
2071 }
2072
2073
2074 /**
2075 * Check the keys and values in the $compare array against the ['config'] part of the top level of the stack.
2076 * A boolean value is return depending on how the comparison was successful.
2077 *
2078 * @param array $compare: keys and values to compare to the ['config'] part of the top level of the stack
2079 * @return boolean Whether the comparison was successful
2080 * @see arrayCompareComplex
2081 */
2082 function compareStructureConfiguration($compare) {
2083 $level = $this->getStructureLevel(-1);
2084 $result = $this->arrayCompareComplex($level, $compare);
2085
2086 return $result;
2087 }
2088
2089
2090 /**
2091 * Normalize a relation "uid" published by transferData, like "1|Company%201"
2092 *
2093 * @param string $string: A transferData reference string, containing the uid
2094 * @return string The normalized uid
2095 */
2096 function normalizeUid($string) {
2097 $parts = explode('|', $string);
2098 return $parts[0];
2099 }
2100
2101
2102 /**
2103 * Wrap the HTML code of a section with a table tag.
2104 *
2105 * @param string $section: The HTML code to be wrapped
2106 * @param array $styleAttrs: Attributes for the style argument in the table tag
2107 * @param array $tableAttrs: Attributes for the table tag (like width, border, etc.)
2108 * @return string The wrapped HTML code
2109 */
2110 function wrapFormsSection($section, $styleAttrs = array(), $tableAttrs = array()) {
2111 $style = '';
2112 $table = '';
2113 if (!$styleAttrs['margin-right']) {
2114 $styleAttrs['margin-right'] = $this->inlineStyles['margin-right'] . 'px';
2115 }
2116
2117 foreach ($styleAttrs as $key => $value) {
2118 $style .= ($style ? ' ' : '') . $key . ': ' . htmlspecialchars($value) . '; ';
2119 }
2120 if ($style) {
2121 $style = ' style="' . $style . '"';
2122 }
2123
2124 if (!$tableAttrs['background'] && $this->fObj->borderStyle[2]) {
2125 $tableAttrs['background'] = $this->backPath . $this->borderStyle[2];
2126 }
2127 if (!$tableAttrs['cellspacing']) {
2128 $tableAttrs['cellspacing'] = '0';
2129 }
2130 if (!$tableAttrs['cellpadding']) {
2131 $tableAttrs['cellpadding'] = '0';
2132 }
2133 if (!$tableAttrs['border']) {
2134 $tableAttrs['border'] = '0';
2135 }
2136 if (!$tableAttrs['width']) {
2137 $tableAttrs['width'] = '100%';
2138 }
2139 if (!$tableAttrs['class'] && $this->borderStyle[3]) {
2140 $tableAttrs['class'] = $this->borderStyle[3];
2141 }
2142
2143 foreach ($tableAttrs as $key => $value) {
2144 $table .= ($table ? ' ' : '') . $key . '="' . htmlspecialchars($value) . '"';
2145 }
2146
2147 $out = '<table ' . $table . $style . '>' . $section . '</table>';
2148 return $out;
2149 }
2150
2151
2152 /**
2153 * Checks if the $table is the child of a inline type AND the $field is the label field of this table.
2154 * This function is used to dynamically update the label while editing. This has no effect on labels,
2155 * that were processed by a TCEmain-hook on saving.
2156 *
2157 * @param string $table: The table to check
2158 * @param string $field: The field on this table to check
2159 * @return boolean is inline child and field is responsible for the label
2160 */
2161 function isInlineChildAndLabelField($table, $field) {
2162 $level = $this->getStructureLevel(-1);
2163 if ($level['config']['foreign_label']) {
2164 $label = $level['config']['foreign_label'];
2165 }
2166 else
2167 {
2168 $label = $GLOBALS['TCA'][$table]['ctrl']['label'];
2169 }
2170 return $level['config']['foreign_table'] === $table && $label == $field ? TRUE : FALSE;
2171 }
2172
2173
2174 /**
2175 * Get the depth of the stable structure stack.
2176 * (count($this->inlineStructure['stable'])
2177 *
2178 * @return integer The depth of the structure stack
2179 */
2180 function getStructureDepth() {
2181 return count($this->inlineStructure['stable']);
2182 }
2183
2184
2185 /**
2186 * Handles complex comparison requests on an array.
2187 * A request could look like the following:
2188 *
2189 * $searchArray = array(
2190 * '%AND' => array(
2191 * 'key1' => 'value1',
2192 * 'key2' => 'value2',
2193 * '%OR' => array(
2194 * 'subarray' => array(
2195 * 'subkey' => 'subvalue'
2196 * ),
2197 * 'key3' => 'value3',
2198 * 'key4' => 'value4'
2199 * )
2200 * )
2201 * );
2202 *
2203 * It is possible to use the array keys '%AND.1', '%AND.2', etc. to prevent
2204 * overwriting the sub-array. It could be neccessary, if you use complex comparisons.
2205 *
2206 * The example above means, key1 *AND* key2 (and their values) have to match with
2207 * the $subjectArray and additional one *OR* key3 or key4 have to meet the same
2208 * condition.
2209 * It is also possible to compare parts of a sub-array (e.g. "subarray"), so this
2210 * function recurses down one level in that sub-array.
2211 *
2212 * @param array $subjectArray: The array to search in
2213 * @param array $searchArray: The array with keys and values to search for
2214 * @param string $type: Use '%AND' or '%OR' for comparision
2215 * @return boolean The result of the comparison
2216 */
2217 function arrayCompareComplex($subjectArray, $searchArray, $type = '') {
2218 $localMatches = 0;
2219 $localEntries = 0;
2220
2221 if (is_array($searchArray) && count($searchArray)) {
2222 // if no type was passed, try to determine
2223 if (!$type) {
2224 reset($searchArray);
2225 $type = key($searchArray);
2226 $searchArray = current($searchArray);
2227 }
2228
2229 // we use '%AND' and '%OR' in uppercase
2230 $type = strtoupper($type);
2231
2232 // split regular elements from sub elements
2233 foreach ($searchArray as $key => $value) {
2234 $localEntries++;
2235
2236 // process a sub-group of OR-conditions
2237 if ($key == '%OR') {
2238 $localMatches += $this->arrayCompareComplex($subjectArray, $value, '%OR') ? 1 : 0;
2239 // process a sub-group of AND-conditions
2240 } elseif ($key == '%AND') {
2241 $localMatches += $this->arrayCompareComplex($subjectArray, $value, '%AND') ? 1 : 0;
2242 // a part of an associative array should be compared, so step down in the array hierarchy
2243 } elseif (is_array($value) && $this->isAssociativeArray($searchArray)) {
2244 $localMatches += $this->arrayCompareComplex($subjectArray[$key], $value, $type) ? 1 : 0;
2245 // it is a normal array that is only used for grouping and indexing
2246 } elseif (is_array($value)) {
2247 $localMatches += $this->arrayCompareComplex($subjectArray, $value, $type) ? 1 : 0;
2248 // directly compare a value
2249 } else {
2250 if (isset($subjectArray[$key]) && isset($value)) {
2251 // Boolean match:
2252 if (is_bool($value)) {
2253 $localMatches += (!($subjectArray[$key] xor $value) ? 1 : 0);
2254 // Value match for numbers:
2255 } elseif (is_numeric($subjectArray[$key]) && is_numeric($value)) {
2256 $localMatches += ($subjectArray[$key] == $value ? 1 : 0);
2257 // Value and type match:
2258 } else {
2259 $localMatches += ($subjectArray[$key] === $value ? 1 : 0);
2260 }
2261 }
2262 }
2263
2264 // if one or more matches are required ('OR'), return true after the first successful match
2265 if ($type == '%OR' && $localMatches > 0) {
2266 return TRUE;
2267 }
2268 // if all matches are required ('AND') and we have no result after the first run, return false
2269 if ($type == '%AND' && $localMatches == 0) {
2270 return FALSE;
2271 }
2272 }
2273 }
2274
2275 // return the result for '%AND' (if nothing was checked, true is returned)
2276 return $localEntries == $localMatches ? TRUE : FALSE;
2277 }
2278
2279
2280 /**
2281 * Checks whether an object is an associative array.
2282 *
2283 * @param mixed $object: The object to be checked
2284 * @return boolean Returns true, if the object is an associative array
2285 */
2286 function isAssociativeArray($object) {
2287 return is_array($object) && count($object) && (array_keys($object) !== range(0, sizeof($object) - 1))
2288 ? TRUE
2289 : FALSE;
2290 }
2291
2292
2293 /**
2294 * Remove an element from an array.
2295 *
2296 * @param mixed $needle: The element to be removed.
2297 * @param array $haystack: The array the element should be removed from.
2298 * @param mixed $strict: Search elements strictly.
2299 * @return array The array $haystack without the $needle
2300 */
2301 function removeFromArray($needle, $haystack, $strict = NULL) {
2302 $pos = array_search($needle, $haystack, $strict);
2303 if ($pos !== FALSE) {
2304 unset($haystack[$pos]);
2305 }
2306 return $haystack;
2307 }
2308
2309
2310 /**
2311 * Makes a flat array from the $possibleRecords array.
2312 * The key of the flat array is the value of the record,
2313 * the value of the flat array is the label of the record.
2314 *
2315 * @param array $possibleRecords: The possibleRecords array (for select fields)
2316 * @return mixed A flat array with key=uid, value=label; if $possibleRecords isn't an array, false is returned.
2317 */
2318 function getPossibleRecordsFlat($possibleRecords) {
2319 $flat = FALSE;
2320 if (is_array($possibleRecords)) {
2321 $flat = array();
2322 foreach ($possibleRecords as $record) $flat[$record[1]] = $record[0];
2323 }
2324 return $flat;
2325 }
2326
2327
2328 /**
2329 * Determine the configuration and the type of a record selector.
2330 *
2331 * @param array $conf: TCA configuration of the parent(!) field
2332 * @return array Associative array with the keys 'PA' and 'type', both are false if the selector was not valid.
2333 */
2334 function getPossibleRecordsSelectorConfig($conf, $field = '') {
2335 $foreign_table = $conf['foreign_table'];
2336 $foreign_selector = $conf['foreign_selector'];
2337
2338 $PA = FALSE;
2339 $type = FALSE;
2340 $table = FALSE;
2341 $selector = FALSE;
2342
2343 if ($field) {
2344 $PA = array();
2345 $PA['fieldConf'] = $GLOBALS['TCA'][$foreign_table]['columns'][$field];
2346 $PA['fieldConf']['config']['form_type'] = $PA['fieldConf']['config']['form_type'] ? $PA['fieldConf']['config']['form_type'] : $PA['fieldConf']['config']['type']; // Using "form_type" locally in this script
2347 $PA['fieldTSConfig'] = $this->fObj->setTSconfig($foreign_table, array(), $field);
2348 $config = $PA['fieldConf']['config'];
2349 // Determine type of Selector:
2350 $type = $this->getPossibleRecordsSelectorType($config);
2351 // Return table on this level:
2352 $table = $type == 'select' ? $config['foreign_table'] : $config['allowed'];
2353 // Return type of the selector if foreign_selector is defined and points to the same field as in $field:
2354 if ($foreign_selector && $foreign_selector == $field && $type) {
2355 $selector = $type;
2356 }
2357 }
2358
2359 return array(
2360 'PA' => $PA,
2361 'type' => $type,
2362 'table' => $table,
2363 'selector' => $selector,
2364 );
2365 }
2366
2367
2368 /**
2369 * Determine the type of a record selector, e.g. select or group/db.
2370 *
2371 * @param array $config: TCE configuration of the selector
2372 * @return mixed The type of the selector, 'select' or 'groupdb' - false not valid
2373 */
2374 function getPossibleRecordsSelectorType($config) {
2375 $type = FALSE;
2376 if ($config['type'] == 'select') {
2377 $type = 'select';
2378 } elseif ($config['type'] == 'group' && $config['internal_type'] == 'db') {
2379 $type = 'groupdb';
2380 }
2381 return $type;
2382 }
2383
2384
2385 /**
2386 * Check, if a field should be skipped, that was defined to be handled as foreign_field or foreign_sortby of
2387 * the parent record of the "inline"-type - if so, we have to skip this field - the rendering is done via "inline" as hidden field
2388 *
2389 * @param string $table: The table name
2390 * @param string $field: The field name
2391 * @param array $row: The record row from the database
2392 * @param array $config: TCA configuration of the field
2393 * @return boolean Determines whether the field should be skipped.
2394 */
2395 function skipField($table, $field, $row, $config) {
2396 $skipThisField = FALSE;
2397
2398 if ($this->getStructureDepth()) {
2399 $searchArray = array(
2400 '%OR' => array(
2401 'config' => array(
2402 0 => array(
2403 '%AND' => array(
2404 'foreign_table' => $table,
2405 '%OR' => array(
2406 '%AND' => array(
2407 'appearance' => array('useCombination' => TRUE),
2408 'foreign_selector' => $field,
2409 ),
2410 'MM' => $config['MM']
2411 ),
2412 ),
2413 ),
2414 1 => array(
2415 '%AND' => array(
2416 'foreign_table' => $config['foreign_table'],
2417 'foreign_selector' => $config['foreign_field'],
2418 ),
2419 ),
2420 ),
2421 ),
2422 );
2423
2424 // get the parent record from structure stack
2425 $level = $this->getStructureLevel(-1);
2426
2427 // If we have symmetric fields, check on which side we are and hide fields, that are set automatically:
2428 if (t3lib_loadDBGroup::isOnSymmetricSide($level['uid'], $level['config'], $row)) {
2429 $searchArray['%OR']['config'][0]['%AND']['%OR']['symmetric_field'] = $field;
2430 $searchArray['%OR']['config'][0]['%AND']['%OR']['symmetric_sortby'] = $field;
2431 // Hide fields, that are set automatically:
2432 } else {
2433 $searchArray['%OR']['config'][0]['%AND']['%OR']['foreign_field'] = $field;
2434 $searchArray['%OR']['config'][0]['%AND']['%OR']['foreign_sortby'] = $field;
2435 }
2436
2437 $skipThisField = $this->compareStructureConfiguration($searchArray, TRUE);
2438 }
2439
2440 return $skipThisField;
2441 }
2442
2443
2444 /**
2445 * Creates recursively a JSON literal from a mulidimensional associative array.
2446 * Uses Services_JSON (http://mike.teczno.com/JSON/doc/)
2447 *
2448 * @param array $jsonArray: The array (or part of) to be transformed to JSON
2449 * @return string If $level>0: part of JSON literal; if $level==0: whole JSON literal wrapped with <script> tags
2450 * @deprecated Since TYPO3 4.2: Moved to t3lib_div::array2json, will be removed in TYPO3 4.6
2451 */
2452 function getJSON($jsonArray) {
2453 t3lib_div::logDeprecatedFunction();
2454
2455 return json_encode($jsonArray);
2456 }
2457
2458
2459 /**
2460 * Checks if a uid of a child table is in the inline view settings.
2461 *
2462 * @param string $table: Name of the child table
2463 * @param integer $uid: uid of the the child record
2464 * @return boolean true=expand, false=collapse
2465 */
2466 function getExpandedCollapsedState($table, $uid) {
2467 if (isset($this->inlineView[$table]) && is_array($this->inlineView[$table])) {
2468 if (in_array($uid, $this->inlineView[$table]) !== FALSE) {
2469 return TRUE;
2470 }
2471 }
2472 return FALSE;
2473 }
2474
2475
2476 /**
2477 * Update expanded/collapsed states on new inline records if any.
2478 *
2479 * @param array $uc: The uc array to be processed and saved (by reference)
2480 * @param t3lib_TCEmain $tce: Instance of TCEmain that saved data before
2481 * @return void
2482 */
2483 function updateInlineView(&$uc, $tce) {
2484 if (isset($uc['inlineView']) && is_array($uc['inlineView'])) {
2485 $inlineView = (array) unserialize($GLOBALS['BE_USER']->uc['inlineView']);
2486
2487 foreach ($uc['inlineView'] as $topTable => $topRecords) {
2488 foreach ($topRecords as $topUid => $childElements) {
2489 foreach ($childElements as $childTable => $childRecords) {
2490 $uids = array_keys($tce->substNEWwithIDs_table, $childTable);
2491 if (count($uids)) {
2492 $newExpandedChildren = array();
2493 foreach ($childRecords as $childUid => $state) {
2494 if ($state && in_array($childUid, $uids)) {
2495 $newChildUid = $tce->substNEWwithIDs[$childUid];
2496 $newExpandedChildren[] = $newChildUid;
2497 }
2498 }
2499 // Add new expanded child records to UC (if any):
2500 if (count($newExpandedChildren)) {
2501 $inlineViewCurrent =& $inlineView[$topTable][$topUid][$childTable];
2502 if (is_array($inlineViewCurrent)) {
2503 $inlineViewCurrent = array_unique(array_merge($inlineViewCurrent, $newExpandedChildren));
2504 } else {
2505 $inlineViewCurrent = $newExpandedChildren;
2506 }
2507 }
2508 }
2509 }
2510 }
2511 }
2512
2513 $GLOBALS['BE_USER']->uc['inlineView'] = serialize($inlineView);
2514 $GLOBALS['BE_USER']->writeUC();
2515 }
2516 }
2517
2518
2519 /**
2520 * Returns the the margin in pixels, that is used for each new inline level.
2521 *
2522 * @return integer A pixel value for the margin of each new inline level.
2523 */
2524 function getLevelMargin() {
2525 $margin = ($this->inlineStyles['margin-right'] + 1) * 2;
2526 return $margin;
2527 }
2528
2529 /**
2530 * Parses the HTML tags that would have been inserted to the <head> of a HTML document and returns the found tags as multidimensional array.
2531 *
2532 * @return array The parsed tags with their attributes and innerHTML parts
2533 */
2534 protected function getHeadTags() {
2535 $headTags = array();
2536 $headDataRaw = $this->fObj->JStop() . $this->getJavaScriptAndStyleSheetsOfPageRenderer();
2537
2538 if ($headDataRaw) {
2539 // Create instance of the HTML parser:
2540 $parseObj = t3lib_div::makeInstance('t3lib_parsehtml');
2541 // Removes script wraps:
2542 $headDataRaw = str_replace(array('/*<![CDATA[*/', '/*]]>*/'), '', $headDataRaw);
2543 // Removes leading spaces of a multiline string:
2544 $headDataRaw = trim(preg_replace('/(^|\r|\n)( |\t)+/', '$1', $headDataRaw));
2545 // Get script and link tags:
2546 $tags = array_merge(
2547 $parseObj->getAllParts($parseObj->splitTags('link', $headDataRaw)),
2548 $parseObj->getAllParts($parseObj->splitIntoBlock('script', $headDataRaw))
2549 );
2550
2551 foreach ($tags as $tagData) {
2552 $tagAttributes = $parseObj->get_tag_attributes($parseObj->getFirstTag($tagData), TRUE);
2553 $headTags[] = array(
2554 'name' => $parseObj->getFirstTagName($tagData),
2555 'attributes' => $tagAttributes[0],
2556 'innerHTML' => $parseObj->removeFirstAndLastTag($tagData),
2557 );
2558 }
2559 }
2560
2561 return $headTags;
2562 }
2563
2564 /**
2565 * Gets the JavaScript of the pageRenderer.
2566 * This can be used to extract newly added files which have been added
2567 * during an AJAX request. Due to the spread possibilities of the pageRenderer
2568 * to add JavaScript rendering and extracting seems to be the easiest way.
2569 *
2570 * @return string
2571 */
2572 protected function getJavaScriptAndStyleSheetsOfPageRenderer() {
2573 /** @var $pageRenderer t3lib_PageRenderer */
2574 $pageRenderer = clone $GLOBALS['SOBE']->doc->getPageRenderer();
2575
2576 $pageRenderer->setTemplateFile(TYPO3_mainDir . 'templates/helper_javascript_css.html');
2577 $javaScriptAndStyleSheets = $pageRenderer->render();
2578
2579 return $javaScriptAndStyleSheets;
2580 }
2581
2582
2583 /**
2584 * Wraps a text with an anchor and returns the HTML representation.
2585 *
2586 * @param string $text: The text to be wrapped by an anchor
2587 * @param string $link: The link to be used in the anchor
2588 * @param array $attributes: Array of attributes to be used in the anchor
2589 * @return string The wrapped texted as HTML representation
2590 */
2591 protected function wrapWithAnchor($text, $link, $attributes = array()) {
2592 $link = trim($link);
2593 $result = '<a href="' . ($link ? $link : '#') . '"';
2594 foreach ($attributes as $key => $value) {
2595 $result .= ' ' . $key . '="' . htmlspecialchars(trim($value)) . '"';
2596 }
2597 $result .= '>' . $text . '</a>';
2598 return $result;
2599 }
2600 }
2601
2602
2603 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_inline.php'])) {
2604 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_inline.php']);
2605 }
2606
2607 ?>