/t3lib/class.t3lib_tceforms_inline.php
PHP | 2550 lines | 1431 code | 285 blank | 834 comment | 355 complexity | fa1d9ef6d86be102ccb11bf272ba9809 MD5 | raw file
Possible License(s): Apache-2.0, BSD-2-Clause, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /***************************************************************
- * Copyright notice
- *
- * (c) 2006-2011 Oliver Hader <oliver@typo3.org>
- * All rights reserved
- *
- * This script is part of the TYPO3 project. The TYPO3 project is
- * free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * The GNU General Public License can be found at
- * http://www.gnu.org/copyleft/gpl.html.
- * A copy is found in the textfile GPL.txt and important notices to the license
- * from the author is found in LICENSE.txt distributed with these scripts.
- *
- *
- * This script is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * This copyright notice MUST APPEAR in all copies of the script!
- ***************************************************************/
- /**
- * The Inline-Relational-Record-Editing (IRRE) functions as part of the TCEforms.
- *
- * $Id$
- *
- * @author Oliver Hader <oliver@typo3.org>
- */
- /**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- * 88: class t3lib_TCEforms_inline
- * 109: function init(&$tceForms)
- * 127: function getSingleField_typeInline($table,$field,$row,&$PA)
- *
- * SECTION: Regular rendering of forms, fields, etc.
- * 263: function renderForeignRecord($parentUid, $rec, $config = array())
- * 319: function renderForeignRecordHeader($parentUid, $foreign_table,$rec,$config = array())
- * 375: function renderForeignRecordHeaderControl($table,$row,$config = array())
- * 506: function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array())
- * 560: function renderPossibleRecordsSelector($selItems, $conf, $uniqueIds=array())
- * 627: function addJavaScript()
- * 643: function addJavaScriptSortable($objectId)
- *
- * SECTION: Handling of AJAX calls
- * 665: function createNewRecord($domObjectId, $foreignUid = 0)
- * 755: function getJSON($jsonArray)
- * 770: function getNewRecordLink($objectPrefix, $conf = array())
- *
- * SECTION: Get data from database and handle relations
- * 807: function getRelatedRecords($table,$field,$row,&$PA,$config)
- * 839: function getPossibleRecords($table,$field,$row,$conf,$checkForConfField='foreign_selector')
- * 885: function getUniqueIds($records, $conf=array())
- * 905: function getRecord($pid, $table, $uid, $cmd='')
- * 929: function getNewRecord($pid, $table)
- *
- * SECTION: Structure stack for handling inline objects/levels
- * 951: function pushStructure($table, $uid, $field = '', $config = array())
- * 967: function popStructure()
- * 984: function updateStructureNames()
- * 1000: function getStructureItemName($levelData)
- * 1015: function getStructureLevel($level)
- * 1032: function getStructurePath($structureDepth = -1)
- * 1057: function parseStructureString($string, $loadConfig = false)
- *
- * SECTION: Helper functions
- * 1098: function checkConfiguration(&$config)
- * 1123: function checkAccess($cmd, $table, $theUid)
- * 1185: function compareStructureConfiguration($compare)
- * 1199: function normalizeUid($string)
- * 1213: function wrapFormsSection($section, $styleAttrs = array(), $tableAttrs = array())
- * 1242: function isInlineChildAndLabelField($table, $field)
- * 1258: function getStructureDepth()
- * 1295: function arrayCompareComplex($subjectArray, $searchArray, $type = '')
- * 1349: function isAssociativeArray($object)
- * 1364: function getPossibleRecordsFlat($possibleRecords)
- * 1383: function skipField($table, $field, $row, $config)
- *
- * TOTAL FUNCTIONS: 35
- * (This index is automatically created/updated by the extension "extdeveval")
- *
- */
- class t3lib_TCEforms_inline {
- const Structure_Separator = '-';
- const Disposal_AttributeName = 'Disposal_AttributeName';
- const Disposal_AttributeId = 'Disposal_AttributeId';
- /**
- * Reference to the calling TCEforms instance
- *
- * @var t3lib_TCEforms
- */
- var $fObj;
- var $backPath; // Reference to $fObj->backPath
- var $isAjaxCall = FALSE; // Indicates if a field is rendered upon an AJAX call
- var $inlineStructure = array(); // the structure/hierarchy where working in, e.g. cascading inline tables
- var $inlineFirstPid; // the first call of an inline type appeared on this page (pid of record)
- var $inlineNames = array(); // keys: form, object -> hold the name/id for each of them
- var $inlineData = array(); // inline data array used for JSON output
- var $inlineView = array(); // expanded/collapsed states for the current BE user
- var $inlineCount = 0; // count the number of inline types used
- var $inlineStyles = array();
- var $prependNaming = 'data'; // how the $this->fObj->prependFormFieldNames should be set ('data' is default)
- var $prependFormFieldNames; // reference to $this->fObj->prependFormFieldNames
- var $prependCmdFieldNames; // reference to $this->fObj->prependCmdFieldNames
- protected $hookObjects = array(); // array containing instances of hook classes called once for IRRE objects
- /**
- * Intialize an instance of t3lib_TCEforms_inline
- *
- * @param t3lib_TCEforms $tceForms: Reference to an TCEforms instance
- * @return void
- */
- function init(&$tceForms) {
- $this->fObj = $tceForms;
- $this->backPath =& $tceForms->backPath;
- $this->prependFormFieldNames =& $this->fObj->prependFormFieldNames;
- $this->prependCmdFieldNames =& $this->fObj->prependCmdFieldNames;
- $this->inlineStyles['margin-right'] = '5';
- $this->initHookObjects();
- }
- /**
- * Initialized the hook objects for this class.
- * Each hook object has to implement the interface t3lib_tceformsInlineHook.
- *
- * @return void
- */
- protected function initHookObjects() {
- $this->hookObjects = array();
- if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'])) {
- $tceformsInlineHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['tceformsInlineHook'];
- if (is_array($tceformsInlineHook)) {
- foreach ($tceformsInlineHook as $classData) {
- $processObject = t3lib_div::getUserObj($classData);
- if (!($processObject instanceof t3lib_tceformsInlineHook)) {
- throw new UnexpectedValueException('$processObject must implement interface t3lib_tceformsInlineHook', 1202072000);
- }
- $processObject->init($this);
- $this->hookObjects[] = $processObject;
- }
- }
- }
- }
- /**
- * Generation of TCEform elements of the type "inline"
- * This will render inline-relational-record sets. Relations.
- *
- * @param string $table: The table name of the record
- * @param string $field: The field name which this element is supposed to edit
- * @param array $row: The record data array where the value(s) for the field can be found
- * @param array $PA: An array with additional configuration options.
- * @return string The HTML code for the TCEform field
- */
- function getSingleField_typeInline($table, $field, $row, &$PA) {
- // check the TCA configuration - if false is returned, something was wrong
- if ($this->checkConfiguration($PA['fieldConf']['config']) === FALSE) {
- return FALSE;
- }
- // count the number of processed inline elements
- $this->inlineCount++;
- // Init:
- $config = $PA['fieldConf']['config'];
- $foreign_table = $config['foreign_table'];
- t3lib_div::loadTCA($foreign_table);
- if (t3lib_BEfunc::isTableLocalizable($table)) {
- $language = intval($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
- }
- $minitems = t3lib_div::intInRange($config['minitems'], 0);
- $maxitems = t3lib_div::intInRange($config['maxitems'], 0);
- if (!$maxitems) {
- $maxitems = 100000;
- }
- // Register the required number of elements:
- $this->fObj->requiredElements[$PA['itemFormElName']] = array($minitems, $maxitems, 'imgName' => $table . '_' . $row['uid'] . '_' . $field);
- // remember the page id (pid of record) where inline editing started first
- // we need that pid for ajax calls, so that they would know where the action takes place on the page structure
- if (!isset($this->inlineFirstPid)) {
- // if this record is not new, try to fetch the inlineView states
- // @TODO: Add checking/cleaning for unused tables, records, etc. to save space in uc-field
- if (t3lib_div::testInt($row['uid'])) {
- $inlineView = unserialize($GLOBALS['BE_USER']->uc['inlineView']);
- $this->inlineView = $inlineView[$table][$row['uid']];
- }
- // If the parent is a page, use the uid(!) of the (new?) page as pid for the child records:
- if ($table == 'pages') {
- $liveVersionId = t3lib_BEfunc::getLiveVersionIdOfRecord('pages', $row['uid']);
- $this->inlineFirstPid = (is_null($liveVersionId) ? $row['uid'] : $liveVersionId);
- // If pid is negative, fetch the previous record and take its pid:
- } elseif ($row['pid'] < 0) {
- $prevRec = t3lib_BEfunc::getRecord($table, abs($row['pid']));
- $this->inlineFirstPid = $prevRec['pid'];
- // Take the pid as it is:
- } else {
- $this->inlineFirstPid = $row['pid'];
- }
- }
- // add the current inline job to the structure stack
- $this->pushStructure($table, $row['uid'], $field, $config);
- // e.g. data[<table>][<uid>][<field>]
- $nameForm = $this->inlineNames['form'];
- // e.g. data-<pid>-<table1>-<uid1>-<field1>-<table2>-<uid2>-<field2>
- $nameObject = $this->inlineNames['object'];
- // get the records related to this inline record
- $relatedRecords = $this->getRelatedRecords($table, $field, $row, $PA, $config);
- // set the first and last record to the config array
- $relatedRecordsUids = array_keys($relatedRecords['records']);
- $config['inline']['first'] = reset($relatedRecordsUids);
- $config['inline']['last'] = end($relatedRecordsUids);
- // Tell the browser what we have (using JSON later):
- $top = $this->getStructureLevel(0);
- $this->inlineData['config'][$nameObject] = array(
- 'table' => $foreign_table,
- 'md5' => md5($nameObject),
- );
- $this->inlineData['config'][$nameObject . self::Structure_Separator . $foreign_table] = array(
- 'min' => $minitems,
- 'max' => $maxitems,
- 'sortable' => $config['appearance']['useSortable'],
- 'top' => array(
- 'table' => $top['table'],
- 'uid' => $top['uid'],
- ),
- );
- // Set a hint for nested IRRE and tab elements:
- $this->inlineData['nested'][$nameObject] = $this->fObj->getDynNestedStack(FALSE, $this->isAjaxCall);
- // if relations are required to be unique, get the uids that have already been used on the foreign side of the relation
- if ($config['foreign_unique']) {
- // If uniqueness *and* selector are set, they should point to the same field - so, get the configuration of one:
- $selConfig = $this->getPossibleRecordsSelectorConfig($config, $config['foreign_unique']);
- // Get the used unique ids:
- $uniqueIds = $this->getUniqueIds($relatedRecords['records'], $config, $selConfig['type'] == 'groupdb');
- $possibleRecords = $this->getPossibleRecords($table, $field, $row, $config, 'foreign_unique');
- $uniqueMax = $config['appearance']['useCombination'] || $possibleRecords === FALSE ? -1 : count($possibleRecords);
- $this->inlineData['unique'][$nameObject . self::Structure_Separator . $foreign_table] = array(
- 'max' => $uniqueMax,
- 'used' => $uniqueIds,
- 'type' => $selConfig['type'],
- 'table' => $config['foreign_table'],
- 'elTable' => $selConfig['table'], // element/record table (one step down in hierarchy)
- 'field' => $config['foreign_unique'],
- 'selector' => $selConfig['selector'],
- 'possible' => $this->getPossibleRecordsFlat($possibleRecords),
- );
- }
- // if it's required to select from possible child records (reusable children), add a selector box
- if ($config['foreign_selector']) {
- // if not already set by the foreign_unique, set the possibleRecords here and the uniqueIds to an empty array
- if (!$config['foreign_unique']) {
- $possibleRecords = $this->getPossibleRecords($table, $field, $row, $config);
- $uniqueIds = array();
- }
- $selectorBox = $this->renderPossibleRecordsSelector($possibleRecords, $config, $uniqueIds);
- $item .= $selectorBox;
- }
- // wrap all inline fields of a record with a <div> (like a container)
- $item .= '<div id="' . $nameObject . '">';
- // define how to show the "Create new record" link - if there are more than maxitems, hide it
- if ($relatedRecords['count'] >= $maxitems || ($uniqueMax > 0 && $relatedRecords['count'] >= $uniqueMax)) {
- $config['inline']['inlineNewButtonStyle'] = 'display: none;';
- }
- // Render the level links (create new record, localize all, synchronize):
- if ($config['appearance']['levelLinksPosition'] != 'none') {
- $levelLinks = $this->getLevelInteractionLink('newRecord', $nameObject . self::Structure_Separator . $foreign_table, $config);
- if ($language > 0) {
- // Add the "Localize all records" link before all child records:
- if (isset($config['appearance']['showAllLocalizationLink']) && $config['appearance']['showAllLocalizationLink']) {
- $levelLinks .= $this->getLevelInteractionLink('localize', $nameObject . self::Structure_Separator . $foreign_table, $config);
- }
- // Add the "Synchronize with default language" link before all child records:
- if (isset($config['appearance']['showSynchronizationLink']) && $config['appearance']['showSynchronizationLink']) {
- $levelLinks .= $this->getLevelInteractionLink('synchronize', $nameObject . self::Structure_Separator . $foreign_table, $config);
- }
- }
- }
- // Add the level links before all child records:
- if (in_array($config['appearance']['levelLinksPosition'], array('both', 'top'))) {
- $item .= $levelLinks;
- }
- $item .= '<div id="' . $nameObject . '_records">';
- $relationList = array();
- if (count($relatedRecords['records'])) {
- foreach ($relatedRecords['records'] as $rec) {
- $item .= $this->renderForeignRecord($row['uid'], $rec, $config);
- if (!isset($rec['__virtual']) || !$rec['__virtual']) {
- $relationList[] = $rec['uid'];
- }
- }
- }
- $item .= '</div>';
- // Add the level links after all child records:
- if (in_array($config['appearance']['levelLinksPosition'], array('both', 'bottom'))) {
- $item .= $levelLinks;
- }
- // add Drag&Drop functions for sorting to TCEforms::$additionalJS_post
- if (count($relationList) > 1 && $config['appearance']['useSortable']) {
- $this->addJavaScriptSortable($nameObject . '_records');
- }
- // publish the uids of the child records in the given order to the browser
- $item .= '<input type="hidden" name="' . $nameForm . '" value="' . implode(',', $relationList) . '" class="inlineRecord" />';
- // close the wrap for all inline fields (container)
- $item .= '</div>';
- // on finishing this section, remove the last item from the structure stack
- $this->popStructure();
- // if this was the first call to the inline type, restore the values
- if (!$this->getStructureDepth()) {
- unset($this->inlineFirstPid);
- }
- return $item;
- }
- /*******************************************************
- *
- * Regular rendering of forms, fields, etc.
- *
- *******************************************************/
- /**
- * Render the form-fields of a related (foreign) record.
- *
- * @param string $parentUid: The uid of the parent (embedding) record (uid or NEW...)
- * @param array $rec: The table record of the child/embedded table (normaly post-processed by t3lib_transferData)
- * @param array $config: content of $PA['fieldConf']['config']
- * @return string The HTML code for this "foreign record"
- */
- function renderForeignRecord($parentUid, $rec, $config = array()) {
- $foreign_table = $config['foreign_table'];
- $foreign_field = $config['foreign_field'];
- $foreign_selector = $config['foreign_selector'];
- // Register default localization content:
- $parent = $this->getStructureLevel(-1);
- if (isset($parent['localizationMode']) && $parent['localizationMode'] != FALSE) {
- $this->fObj->registerDefaultLanguageData($foreign_table, $rec);
- }
- // Send a mapping information to the browser via JSON:
- // e.g. data[<curTable>][<curId>][<curField>] => data-<pid>-<parentTable>-<parentId>-<parentField>-<curTable>-<curId>-<curField>
- $this->inlineData['map'][$this->inlineNames['form']] = $this->inlineNames['object'];
- // Set this variable if we handle a brand new unsaved record:
- $isNewRecord = t3lib_div::testInt($rec['uid']) ? FALSE : TRUE;
- // Set this variable if the record is virtual and only show with header and not editable fields:
- $isVirtualRecord = (isset($rec['__virtual']) && $rec['__virtual']);
- // If there is a selector field, normalize it:
- if ($foreign_selector) {
- $rec[$foreign_selector] = $this->normalizeUid($rec[$foreign_selector]);
- }
- if (!$this->checkAccess(($isNewRecord ? 'new' : 'edit'), $foreign_table, $rec['uid'])) {
- return FALSE;
- }
- // Get the current naming scheme for DOM name/id attributes:
- $nameObject = $this->inlineNames['object'];
- $appendFormFieldNames = '[' . $foreign_table . '][' . $rec['uid'] . ']';
- $objectId = $nameObject . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
- // Put the current level also to the dynNestedStack of TCEforms:
- $this->fObj->pushToDynNestedStack('inline', $objectId);
- if (!$isVirtualRecord) {
- // Get configuration:
- $collapseAll = (isset($config['appearance']['collapseAll']) && $config['appearance']['collapseAll']);
- $expandAll = (isset($config['appearance']['collapseAll']) && !$config['appearance']['collapseAll']);
- $ajaxLoad = (isset($config['appearance']['ajaxLoad']) && !$config['appearance']['ajaxLoad']) ? FALSE : TRUE;
- if ($isNewRecord) {
- // show this record expanded or collapsed
- $isExpanded = ($expandAll || (!$collapseAll ? 1 : 0));
- } else {
- $isExpanded = ($config['renderFieldsOnly'] || (!$collapseAll && $this->getExpandedCollapsedState($foreign_table, $rec['uid'])) || $expandAll);
- }
- // 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
- if ($isNewRecord || $isExpanded || !$ajaxLoad) {
- $combination = $this->renderCombinationTable($rec, $appendFormFieldNames, $config);
- $fields = $this->renderMainFields($foreign_table, $rec);
- $fields = $this->wrapFormsSection($fields);
- // Replace returnUrl in Wizard-Code, if this is an AJAX call
- $ajaxArguments = t3lib_div::_GP('ajax');
- if (isset($ajaxArguments[2]) && trim($ajaxArguments[2]) != '') {
- $fields = str_replace('P[returnUrl]=%2F' . rawurlencode(TYPO3_mainDir) . '%2Fajax.php', 'P[returnUrl]=' . rawurlencode($ajaxArguments[2]), $fields);
- }
- } else {
- $combination = '';
- // This string is the marker for the JS-function to check if the full content has already been loaded
- $fields = '<!--notloaded-->';
- }
- if ($isNewRecord) {
- // get the top parent table
- $top = $this->getStructureLevel(0);
- $ucFieldName = 'uc[inlineView][' . $top['table'] . '][' . $top['uid'] . ']' . $appendFormFieldNames;
- // set additional fields for processing for saving
- $fields .= '<input type="hidden" name="' . $this->prependFormFieldNames . $appendFormFieldNames . '[pid]" value="' . $rec['pid'] . '"/>';
- $fields .= '<input type="hidden" name="' . $ucFieldName . '" value="' . $isExpanded . '" />';
- } else {
- // set additional field for processing for saving
- $fields .= '<input type="hidden" name="' . $this->prependCmdFieldNames . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />';
- }
- // if this record should be shown collapsed
- if (!$isExpanded) {
- $appearanceStyleFields = ' style="display: none;"';
- }
- }
- if ($config['renderFieldsOnly']) {
- $out = $fields . $combination;
- } else {
- // set the record container with data for output
- $out = '<div class="t3-form-field-record-inline" id="' . $objectId . '_fields"' . $appearanceStyleFields . '>' . $fields . $combination . '</div>';
- $header = $this->renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
- $out = '<div class="t3-form-field-header-inline" id="' . $objectId . '_header">' . $header . '</div>' . $out;
- // wrap the header, fields and combination part of a child record with a div container
- $classMSIE = ($this->fObj->clientInfo['BROWSER'] == 'msie' && $this->fObj->clientInfo['VERSION'] < 8 ? 'MSIE' : '');
- $class = 'inlineDiv' . $classMSIE . ($isNewRecord ? ' inlineIsNewRecord' : '');
- $out = '<div id="' . $objectId . '_div" class="t3-form-field-container-inline ' . $class . '">' . $out . '</div>';
- }
- // Remove the current level also from the dynNestedStack of TCEforms:
- $this->fObj->popFromDynNestedStack();
- return $out;
- }
- /**
- * Wrapper for TCEforms::getMainFields().
- *
- * @param string $table: The table name
- * @param array $row: The record to be rendered
- * @return string The rendered form
- */
- protected function renderMainFields($table, $row) {
- // The current render depth of t3lib_TCEforms:
- $depth = $this->fObj->renderDepth;
- // If there is some information about already rendered palettes of our parent, store this info:
- if (isset($this->fObj->palettesRendered[$depth][$table])) {
- $palettesRendered = $this->fObj->palettesRendered[$depth][$table];
- }
- // Render the form:
- $content = $this->fObj->getMainFields($table, $row, $depth);
- // If there was some info about rendered palettes stored, write it back for our parent:
- if (isset($palettesRendered)) {
- $this->fObj->palettesRendered[$depth][$table] = $palettesRendered;
- }
- return $content;
- }
- /**
- * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
- * Later on the command-icons are inserted here.
- *
- * @param string $parentUid: The uid of the parent (embedding) record (uid or NEW...)
- * @param string $foreign_table: The foreign_table we create a header for
- * @param array $rec: The current record of that foreign_table
- * @param array $config: content of $PA['fieldConf']['config']
- * @param boolean $isVirtualRecord:
- * @return string The HTML code of the header
- */
- function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE) {
- // Init:
- $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
- $expandSingle = $config['appearance']['expandSingle'] ? 1 : 0;
- // 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)
- $onClick = "return inline.expandCollapseRecord('" . htmlspecialchars($objectId) . "', $expandSingle, '" . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "')";
- // Pre-Processing:
- $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
- $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
- $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
- // Get the record title/label for a record:
- // render using a self-defined user function
- if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
- $params = array(
- 'table' => $foreign_table,
- 'row' => $rec,
- 'title' => '',
- 'isOnSymmetricSide' => $isOnSymmetricSide,
- 'parent' => array(
- 'uid' => $parentUid,
- 'config' => $config,
- ),
- );
- $null = NULL; // callUserFunction requires a third parameter, but we don't want to give $this as reference!
- t3lib_div::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
- $recTitle = $params['title'];
- // render the special alternative title
- } elseif ($hasForeignLabel || $hasSymmetricLabel) {
- $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
- $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
- // Render title for everything else than group/db:
- if ($foreignConfig['type'] != 'groupdb') {
- $recTitle = t3lib_BEfunc::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
- // Render title for group/db:
- } else {
- // $recTitle could be something like: "tx_table_123|...",
- $valueParts = t3lib_div::trimExplode('|', $rec[$titleCol]);
- $itemParts = t3lib_div::revExplode('_', $valueParts[0], 2);
- $recTemp = t3lib_befunc::getRecordWSOL($itemParts[0], $itemParts[1]);
- $recTitle = t3lib_BEfunc::getRecordTitle($itemParts[0], $recTemp, FALSE);
- }
- $recTitle = t3lib_BEfunc::getRecordTitlePrep($recTitle);
- if (!strcmp(trim($recTitle), '')) {
- $recTitle = t3lib_BEfunc::getNoRecordTitle(TRUE);
- }
- // render the standard
- } else {
- $recTitle = t3lib_BEfunc::getRecordTitle($foreign_table, $rec, TRUE);
- }
- $altText = t3lib_BEfunc::getRecordIconAltText($rec, $foreign_table);
- $iconImg = t3lib_iconWorks::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
- $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
- if (!$isVirtualRecord) {
- $iconImg = $this->wrapWithAnchor($iconImg, '#', array('onclick' => $onClick));
- $label = $this->wrapWithAnchor($label, '#', array('onclick' => $onClick, 'style' => 'display: block;'));
- }
- $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
- // @TODO: Check the table wrapping and the CSS definitions
- $header =
- '<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-right: ' . $this->inlineStyles['margin-right'] . 'px;"' .
- ($this->fObj->borderStyle[2] ? ' background="' . htmlspecialchars($this->backPath . $this->fObj->borderStyle[2]) . '"' : '') .
- ($this->fObj->borderStyle[3] ? ' class="' . htmlspecialchars($this->fObj->borderStyle[3]) . '"' : '') . '>' .
- '<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>';
- return $header;
- }
- /**
- * Render the control-icons for a record header (create new, sorting, delete, disable/enable).
- * Most of the parts are copy&paste from class.db_list_extra.inc and modified for the JavaScript calls here
- *
- * @param string $parentUid: The uid of the parent (embedding) record (uid or NEW...)
- * @param string $foreign_table: The table (foreign_table) we create control-icons for
- * @param array $rec: The current record of that foreign_table
- * @param array $config: (modified) TCA configuration of the field
- * @return string The HTML code with the control-icons
- */
- function renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config = array(), $isVirtualRecord = FALSE) {
- // Initialize:
- $cells = array();
- $isNewItem = substr($rec['uid'], 0, 3) == 'NEW';
- $tcaTableCtrl =& $GLOBALS['TCA'][$foreign_table]['ctrl'];
- $tcaTableCols =& $GLOBALS['TCA'][$foreign_table]['columns'];
- $isPagesTable = $foreign_table == 'pages' ? TRUE : FALSE;
- $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
- $enableManualSorting = $tcaTableCtrl['sortby'] || $config['MM'] || (!$isOnSymmetricSide && $config['foreign_sortby']) || ($isOnSymmetricSide && $config['symmetric_sortby']) ? TRUE : FALSE;
- $nameObject = $this->inlineNames['object'];
- $nameObjectFt = $nameObject . self::Structure_Separator . $foreign_table;
- $nameObjectFtId = $nameObjectFt . self::Structure_Separator . $rec['uid'];
- $calcPerms = $GLOBALS['BE_USER']->calcPerms(
- t3lib_BEfunc::readPageAccess($rec['pid'], $GLOBALS['BE_USER']->getPagePermsClause(1))
- );
- // If the listed table is 'pages' we have to request the permission settings for each page:
- if ($isPagesTable) {
- $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages', $rec['uid']));
- }
- // This expresses the edit permissions for this particular element:
- $permsEdit = ($isPagesTable && ($localCalcPerms & 2)) || (!$isPagesTable && ($calcPerms & 16));
- // Controls: Defines which controls should be shown
- $enabledControls = $config['appearance']['enabledControls'];
- // Hook: Can disable/enable single controls for specific child records:
- foreach ($this->hookObjects as $hookObj) {
- $hookObj->renderForeignRecordHeaderControl_preProcess($parentUid, $foreign_table, $rec, $config, $isVirtualRecord, $enabledControls);
- }
- // Icon to visualize that a required field is nested in this inline level:
- $cells['required'] = '<img name="' . $nameObjectFtId . '_req" src="clear.gif" width="10" height="10" hspace="4" vspace="3" alt="" />';
- if (isset($rec['__create'])) {
- $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)));
- } elseif (isset($rec['__remove'])) {
- $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)));
- }
- // "Info": (All records)
- if ($enabledControls['info'] && !$isNewItem) {
- $cells['info'] = '<a href="#" onclick="' . htmlspecialchars('top.launchView(\'' . $foreign_table . '\', \'' . $rec['uid'] . '\'); return false;') . '">' .
- t3lib_iconWorks::getSpriteIcon('status-dialog-information', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:showInfo', TRUE))) .
- '</a>';
- }
- // If the table is NOT a read-only table, then show these links:
- if (!$tcaTableCtrl['readOnly'] && !$isVirtualRecord) {
- // "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):
- if ($enabledControls['new'] && ($enableManualSorting || $tcaTableCtrl['useColumnsForDefaultValues'])) {
- if (
- (!$isPagesTable && ($calcPerms & 16)) || // For NON-pages, must have permission to edit content on this parent page
- ($isPagesTable && ($calcPerms & 8)) // For pages, must have permission to create new pages here.
- ) {
- $onClick = "return inline.createNewRecord('" . $nameObjectFt . "','" . $rec['uid'] . "')";
- $class = ' class="inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'] . '"';
- if ($config['inline']['inlineNewButtonStyle']) {
- $style = ' style="' . $config['inline']['inlineNewButtonStyle'] . '"';
- }
- $cells['new'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '"' . $class . $style . '>' .
- t3lib_iconWorks::getSpriteIcon('actions-' . ($isPagesTable ? 'page' : 'document') . '-new',
- array(
- 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:new' . ($isPagesTable ? 'Page' : 'Record'), 1)
- )
- ) .
- '</a>';
- }
- }
- // Drag&Drop Sorting: Sortable handler for script.aculo.us
- if ($enabledControls['dragdrop'] && $permsEdit && $enableManualSorting && $config['appearance']['useSortable']) {
- $cells['dragdrop'] = t3lib_iconWorks::getSpriteIcon('actions-move-move', array('class' => 'sortableHandle', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.move', TRUE)));
- }
- // "Up/Down" links
- if ($enabledControls['sort'] && $permsEdit && $enableManualSorting) {
- $onClick = "return inline.changeSorting('" . $nameObjectFtId . "', '1')"; // Up
- $style = $config['inline']['first'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
- $cells['sort.up'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" class="sortingUp" ' . $style . '>' .
- t3lib_iconWorks::getSpriteIcon('actions-move-up', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveUp', TRUE))) .
- '</a>';
- $onClick = "return inline.changeSorting('" . $nameObjectFtId . "', '-1')"; // Down
- $style = $config['inline']['last'] == $rec['uid'] ? 'style="visibility: hidden;"' : '';
- $cells['sort.down'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" class="sortingDown" ' . $style . '>' .
- t3lib_iconWorks::getSpriteIcon('actions-move-down', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:moveDown', TRUE))) .
- '</a>';
- }
- // "Hide/Unhide" links:
- $hiddenField = $tcaTableCtrl['enablecolumns']['disabled'];
- if ($enabledControls['hide'] && $permsEdit && $hiddenField && $tcaTableCols[$hiddenField] && (!$tcaTableCols[$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $foreign_table . ':' . $hiddenField))) {
- $onClick = "return inline.enableDisableRecord('" . $nameObjectFtId . "')";
- if ($rec[$hiddenField]) {
- $cells['hide.unhide'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
- t3lib_iconWorks::getSpriteIcon(
- 'actions-edit-unhide',
- array(
- 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:unHide' . ($isPagesTable ? 'Page' : ''), 1),
- 'id' => $nameObjectFtId . '_disabled'
- )
- ) .
- '</a>';
- } else {
- $cells['hide.hide'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
- t3lib_iconWorks::getSpriteIcon(
- 'actions-edit-hide',
- array(
- 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:hide' . ($isPagesTable ? 'Page' : ''), 1),
- 'id' => $nameObjectFtId . '_disabled'
- )
- ) .
- '</a>';
- }
- }
- // "Delete" link:
- if ($enabledControls['delete'] && ($isPagesTable && $localCalcPerms & 4 || !$isPagesTable && $calcPerms & 16)) {
- $onClick = "inline.deleteRecord('" . $nameObjectFtId . "');";
- $cells['delete'] = '<a href="#" onclick="' . htmlspecialchars('if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')) . ')) { ' . $onClick . ' } return false;') . '">' .
- t3lib_iconWorks::getSpriteIcon('actions-edit-delete', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:delete', TRUE))) .
- '</a>';
- }
- // If this is a virtual record offer a minimized set of icons for user interaction:
- } elseif ($isVirtualRecord) {
- if ($enabledControls['localize'] && isset($rec['__create'])) {
- $onClick = "inline.synchronizeLocalizeRecords('" . $nameObjectFt . "', " . $rec['uid'] . ");";
- $cells['localize'] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
- t3lib_iconWorks::getSpriteIcon('actions-document-localize', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:localize', TRUE))) .
- '</a>';
- }
- }
- // If the record is edit-locked by another user, we will show a little warning sign:
- if ($lockInfo = t3lib_BEfunc::isRecordLocked($foreign_table, $rec['uid'])) {
- $cells['locked'] = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . ');return false;') . '">' .
- t3lib_iconWorks::getSpriteIcon('status-warning-in-use', array('title' => htmlspecialchars($lockInfo['msg']))) .
- '</a>';
- }
- // Hook: Post-processing of single controls for specific child records:
- foreach ($this->hookObjects as $hookObj) {
- $hookObj->renderForeignRecordHeaderControl_postProcess($parentUid, $foreign_table, $rec, $config, $isVirtualRecord, $cells);
- }
- // Compile items into a DIV-element:
- return '
- <!-- CONTROL PANEL: ' . $foreign_table . ':' . $rec['uid'] . ' -->
- <div class="typo3-DBctrl">' . implode('', $cells) . '</div>';
- }
- /**
- * Render a table with TCEforms, that occurs on a intermediate table but should be editable directly,
- * so two tables are combined (the intermediate table with attributes and the sub-embedded table).
- * -> This is a direct embedding over two levels!
- *
- * @param array $rec: The table record of the child/embedded table (normaly post-processed by t3lib_transferData)
- * @param string $appendFormFieldNames: The [<table>][<uid>] of the parent record (the intermediate table)
- * @param array $config: content of $PA['fieldConf']['config']
- * @return string A HTML string with <table> tag around.
- */
- function renderCombinationTable(&$rec, $appendFormFieldNames, $config = array()) {
- $foreign_table = $config['foreign_table'];
- $foreign_selector = $config['foreign_selector'];
- if ($foreign_selector && $config['appearance']['useCombination']) {
- $comboConfig = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector]['config'];
- $comboRecord = array();
- // If record does already exist, load it:
- if ($rec[$foreign_selector] && t3lib_div::testInt($rec[$foreign_selector])) {
- $comboRecord = $this->getRecord(
- $this->inlineFirstPid,
- $comboConfig['foreign_table'],
- $rec[$foreign_selector]
- );
- $isNewRecord = FALSE;
- // It is a new record, create a new record virtually:
- } else {
- $comboRecord = $this->getNewRecord(
- $this->inlineFirstPid,
- $comboConfig['foreign_table']
- );
- $isNewRecord = TRUE;
- }
- // get the TCEforms interpretation of the TCA of the child table
- $out = $this->renderMainFields($comboConfig['foreign_table'], $comboRecord);
- $out = $this->wrapFormsSection($out, array(), array('class' => 'wrapperAttention'));
- // if this is a new record, add a pid value to store this record and the pointer value for the intermediate table
- if ($isNewRecord) {
- $comboFormFieldName = $this->prependFormFieldNames . '[' . $comboConfig['foreign_table'] . '][' . $comboRecord['uid'] . '][pid]';
- $out .= '<input type="hidden" name="' . $comboFormFieldName . '" value="' . $comboRecord['pid'] . '" />';
- }
- // if the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation
- if ($isNewRecord || $config['foreign_unique'] == $foreign_selector) {
- $parentFormFieldName = $this->prependFormFieldNames . $appendFormFieldNames . '[' . $foreign_selector . ']';
- $out .= '<input type="hidden" name="' . $parentFormFieldName . '" value="' . $comboRecord['uid'] . '" />';
- }
- }
- return $out;
- }
- /**
- * Get a selector as used for the select type, to select from all available
- * records and to create a relation to the embedding record (e.g. like MM).
- *
- * @param array $selItems: Array of all possible records
- * @param array $conf: TCA configuration of the parent(!) field
- * @param array $uniqueIds: The uids that have already been used and should be unique
- * @return string A HTML <select> box with all possible records
- */
- function renderPossibleRecordsSelector($selItems, $conf, $uniqueIds = array()) {
- $foreign_table = $conf['foreign_table'];
- $foreign_selector = $conf['foreign_selector'];
- $selConfig = $this->getPossibleRecordsSelectorConfig($conf, $foreign_selector);
- $config = $selConfig['PA']['fieldConf']['config'];
- if ($selConfig['type'] == 'select') {
- $item = $this->renderPossibleRecordsSelectorTypeSelect($selItems, $conf, $selConfig['PA'], $uniqueIds);
- } elseif ($selConfig['type'] == 'groupdb') {
- $item = $this->renderPossibleRecordsSelectorTypeGroupDB($conf, $selConfig['PA']);
- }
- return $item;
- }
- /**
- * Get a selector as used for the select type, to select from all available
- * records and to create a relation to the embedding record (e.g. like MM).
- *
- * @param array $selItems: Array of all possible records
- * @param array $conf: TCA configuration of the parent(!) field
- * @param array $PA: An array with additional configuration options
- * @param array $uniqueIds: The uids that have already been used and should be unique
- * @return string A HTML <select> box with all possible records
- */
- function renderPossibleRecordsSelectorTypeSelect($selItems, $conf, &$PA, $uniqueIds = array()) {
- $foreign_table = $conf['foreign_table'];
- $foreign_selector = $conf['foreign_selector'];
- $PA = array();
- $PA['fieldConf'] = $GLOBALS['TCA'][$foreign_table]['columns'][$foreign_selector];
- $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
- $PA['fieldTSConfig'] = $this->fObj->setTSconfig($foreign_table, array(), $foreign_selector);
- $config = $PA['fieldConf']['config'];
- //TODO: $disabled is not present - should be read from config?
- $disabled = FALSE;
- if (!$disabled) {
- // Create option tags:
- $opt = array();
- $styleAttrValue = '';
- foreach ($selItems as $p) {
- if ($config['iconsInOptionTags']) {
- $styleAttrValue = $this->fObj->optionTagStyle($p[2]);
- }
- if (!in_array($p[1], $uniqueIds)) {
- $opt[] = '<option value="' . htmlspecialchars($p[1]) . '"' .
- ' style="' . (in_array($p[1], $uniqueIds) ? '' : '') .
- ($styleAttrValue ? ' style="' . htmlspecialchars($styleAttrValue) : '') . '">' .
- htmlspecialchars($p[0]) . '</option>';
- }
- }
- // Put together the selector box:
- $selector_itemListStyle = isset($config['itemListStyle']) ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"' : ' style="' . $this->fObj->defaultMultipleSelectorStyle . '"';
- $size = intval($conf['size']);
- $size = $conf['autoSizeMax'] ? t3lib_div::intInRange(count($selItems) + 1, t3lib_div::intInRange($size, 1), $conf['autoSizeMax']) : $size;
- $onChange = "return inline.importNewRecord('" . $this->inlineNames['object'] . self::Structure_Separator . $conf['foreign_table'] . "')";
- $item = '
- <select id="' . $this->inlineNames['object'] . self::Structure_Separator . $conf['foreign_table'] . '_selector"' .
- $this->fObj->insertDefStyle('select') .
- ($size ? ' size="' . $size . '"' : '') .
- ' onchange="' . htmlspecialchars($onChange) . '"' .
- $PA['onFocus'] .
- $selector_itemListStyle .
- ($conf['foreign_unique'] ? ' isunique="isunique"' : '') . '>
- ' . implode('
- ', $opt) . '
- </select>';
- // add a "Create new relation" link for adding new relations
- // this is neccessary, if the size of the selector is "1" or if
- // there is only one record item in the select-box, that is selected by default
- // the selector-box creates a new relation on using a onChange event (see some line above)
- $createNewRelationText = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createNewRelation', 1);
- $item .=
- '<a href="#" onclick="' . htmlspecialchars($onChange) . '" align="abstop">' .
- t3lib_iconWorks::getSpriteIcon('actions-document-new', array('title' => $createNewRelationText)) . $createNewRelationText .
- '</a>';
- // wrap the selector and add a spacer to the bottom
- $item = '<div style="margin-bottom: 20px;">' . $item . '</div>';
- }
- return $item;
- }
- /**
- * Generate a link that opens an element browser in a new window.
- * For group/db there is no way o use a "selector" like a <select>|</select>-box.
- *
- * @param array $conf: TCA configuration of the parent(!) field
- * @param array $PA: An array with additional configuration options
- * @return string A HTML link that opens an element browser in a new window
- */
- function renderPossibleRecordsSelectorTypeGroupDB($conf, &$PA) {
- $foreign_table = $conf['foreign_table'];
- $config = $PA['fieldConf']['config'];
- $allowed = $config['allowed'];
- $objectPrefix = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table;
- $createNewRelationText = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.createNewRelation', 1);
- $onClick = "setFormValueOpenBrowser('db','" . ('|||' . $allowed . '|' . $objectPrefix . '|inline.checkUniqueElement||inline.importElement') . "'); return false;";
- $item =
- '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' .
- t3lib_iconWorks::getSpriteIcon('actions-insert-record', array('title' => $createNewRelationText)) . $createNewRelationText .
- '</a>';
- return $item;
- }
- /**
- * Creates the HTML code of a general link to be used on a level of inline children.
- * The possible keys for the parameter $type are 'newRecord', 'localize' and 'synchronize'.
- *
- * @param string $type: The link type, values are 'newRecord', 'localize' and 'synchronize'.
- * @param string $objectPrefix: The "path" to the child record to create (e.g. 'data-parentPageId-partenTable-parentUid-parentField-childTable]')
- * @param array $conf: TCA configuration of the parent(!) field
- * @return string The HTML code of the new link, wrapped in a div
- */
- protected function getLevelInteractionLink($type, $objectPrefix, $conf = array()) {
- $nameObject = $this->inlineNames['object'];
- $attributes = array();
- switch ($type) {
- case 'newRecord':
- $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.createnew', 1);
- $icon = 'actions-document-new';
- $className = 'typo3-newRecordLink';
- $attributes['class'] = 'inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'];
- $attributes['onclick'] = "return inline.createNewRecord('$objectPrefix')";
- if (isset($conf['inline']['inlineNewButtonStyle']) && $conf['inline']['inlineNewButtonStyle']) {
- $attributes['style'] = $conf['inline']['inlineNewButtonStyle'];
- }
- if (isset($conf['appearance']['newRecordLinkAddTitle']) && $conf['appearance']['newRecordLinkAddTitle']) {
- $titleAddon = ' ' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$conf['foreign_table']]['ctrl']['title'], 1);
- }
- break;
- case 'localize':
- $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:localizeAllRecords', 1);
- $icon = 'actions-document-localize';
- $className = 'typo3-localizationLink';
- $attributes['onclick'] = "return inline.synchronizeLocalizeRecords('$objectPrefix', 'localize')";
- break;
- case 'synchronize':
- $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:synchronizeWithOriginalLanguage', 1);
- $icon = 'actions-document-synchronize';
- $className = 'typo3-synchronizationLink';
- $attributes['class'] = 'inlineNewButton ' . $this->inlineData['config'][$nameObject]['md5'];
- $attributes['onclick'] = "return inline.synchronizeLocalizeRecords('$objectPrefix', 'synchronize')";
- break;
- }
- // Create the link:
- $icon = ($icon ? t3lib_iconWorks::getSpriteIcon($icon, array('title' => htmlspecialchars($title . $titleAddon))) : '');
- $link = $this->wrapWithAnchor($icon . $title . $titleAddon, '#', $attributes);
- return '<div' . ($className ? ' class="' . $className . '"' : '') . '>' . $link . '</div>';
- }
- /**
- * Add Sortable functionality using script.acolo.us "Sortable".
- *
- * @param string $objectId: The container id of the object - elements inside will be sortable
- * @return void
- */
- function addJavaScriptSortable($objectId) {
- $this->fObj->additionalJS_post[] = '
- inline.createDragAndDropSorting("' . $objectId . '");
- ';
- }
- /*******************************************************
- *
- * Handling of AJAX calls
- *
- *******************************************************/
- /**
- * General processor for AJAX requests concerning IRRE.
- * (called by typo3/ajax.php)
- *
- * @param array $params: additional parameters (not used here)
- * @param TYPO3AJAX $ajaxObj: the TYPO3AJAX object of this request
- * @return void
- */
- public function processAjaxRequest($params, $ajaxObj) {
- $ajaxArguments = t3lib_div::_GP('ajax');
- $ajaxIdParts = explode('::', $GLOBALS['ajaxID'], 2);
- if (isset($ajaxArguments) && is_array($ajaxArguments) && count($ajaxArguments)) {
- $ajaxMethod = $ajaxIdParts[1];
- switch ($ajaxMethod) {
- case 'createNewRecord':
- case 'synchronizeLocalizeRecords':
- case 'getRecordDetails':
- $this->isAjaxCall = TRUE;
- // Construct runtime environment for Inline Relational Record Editing:
- $this->processAjaxRequestConstruct($ajaxArguments);
- // Parse the DOM identifier (string), add the levels to the structure stack (array) and load the TCA config:
- $this->parseStructureString($ajaxArguments[0], TRUE);
- // Render content:
- $ajaxObj->setContentFormat('jsonbody');
- $ajaxObj->setContent(
- call_user_func_array(array(&$this, $ajaxMethod), $ajaxArguments)
- );
- break;
- case 'setExpandedCollapsedState':
- $ajaxObj->setContentFormat('jsonbody');
- call_user_func_array(array(&$this, $ajaxMethod), $ajaxArguments);
- break;
- }
- }
- }
- /**
- * Construct runtime environment for Inline Relational Record Editing.
- * - creates an anoymous SC_alt_doc in $GLOBALS['SOBE']
- * - creates a t3lib_TCEforms in $GLOBALS['SOBE']->tceforms
- * - sets ourself as reference to $GLOBALS['SOBE']->tceforms->inline
- * - sets $GLOBALS['SOBE']->tceforms->RTEcounter to the current situation on client-side
- *
- * @param array &$ajaxArguments: The arguments to be processed by the AJAX request
- * @return void
- */
- protected function processAjaxRequestConstruct(&$ajaxArguments) {
- global $SOBE, $BE_USER, $TYPO3_CONF_VARS;
- require_once(PATH_typo3 . 'template.php');
- $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_alt_doc.xml');
- // Create a new anonymous object:
- $SOBE = new stdClass();
- $SOBE->MOD_MENU = array(
- 'showPalettes' => '',
- 'showDescriptions' => '',
- 'disableRTE' => ''
- );
- // Setting virtual document name
- $SOBE->MCONF['name'] = 'xMOD_alt_doc.php';
- // CLEANSE SETTINGS
- $SOBE->MOD_SETTINGS = t3lib_BEfunc::getModuleData(
- $SOBE->MOD_MENU,
- t3lib_div::_GP('SET'),
- $SOBE->MCONF['…
Large files files are truncated, but you can click here to view the full file