/** * Returns select statement for MM relations (as used by TCEFORMs etc) . Code borrowed from class.t3lib_befunc.php * Usage: 3 * * @param array Configuration array for the field, taken from $TCA * @param string Field name * @param array TSconfig array from which to get further configuration settings for the field name * @param string Prefix string for the key "*foreign_table_where" from $fieldValue array * @return string resulting where string with accomplished marker substitution * @internal * @see t3lib_transferData::renderRecord(), t3lib_TCEforms::foreignTable() */ public static function foreign_table_where_query($fieldValue, $field = '', $TSconfig = array(), $prefix = '') { global $TCA; $foreign_table = $fieldValue['config'][$prefix . 'foreign_table']; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($foreign_table); $rootLevel = $TCA[$foreign_table]['ctrl']['rootLevel']; $fTWHERE = $fieldValue['config'][$prefix . 'foreign_table_where']; if (strstr($fTWHERE, '###REC_FIELD_')) { $fTWHERE_parts = explode('###REC_FIELD_', $fTWHERE); foreach ($fTWHERE_parts as $kk => $vv) { if ($kk) { $fTWHERE_subpart = explode('###', $vv, 2); $fTWHERE_parts[$kk] = $TSconfig['_THIS_ROW'][$fTWHERE_subpart[0]] . $fTWHERE_subpart[1]; } } $fTWHERE = implode('', $fTWHERE_parts); } $fTWHERE = str_replace('###CURRENT_PID###', intval($TSconfig['_CURRENT_PID']), $fTWHERE); $fTWHERE = str_replace('###THIS_UID###', intval($TSconfig['_THIS_UID']), $fTWHERE); $fTWHERE = str_replace('###THIS_CID###', intval($TSconfig['_THIS_CID']), $fTWHERE); $fTWHERE = str_replace('###STORAGE_PID###', intval($TSconfig['_STORAGE_PID']), $fTWHERE); $fTWHERE = str_replace('###SITEROOT###', intval($TSconfig['_SITEROOT']), $fTWHERE); if (isset($TSconfig[$field]) && is_array($TSconfig[$field])) { $fTWHERE = str_replace('###PAGE_TSCONFIG_ID###', intval($TSconfig[$field]['PAGE_TSCONFIG_ID']), $fTWHERE); $fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###', $GLOBALS['TYPO3_DB']->cleanIntList($TSconfig[$field]['PAGE_TSCONFIG_IDLIST']), $fTWHERE); $fTWHERE = str_replace('###PAGE_TSCONFIG_STR###', $GLOBALS['TYPO3_DB']->quoteStr($TSconfig[$field]['PAGE_TSCONFIG_STR'], $foreign_table), $fTWHERE); } else { $fTWHERE = str_replace('###PAGE_TSCONFIG_ID###', 0, $fTWHERE); $fTWHERE = str_replace('###PAGE_TSCONFIG_IDLIST###', 0, $fTWHERE); $fTWHERE = str_replace('###PAGE_TSCONFIG_STR###', 0, $fTWHERE); } return $fTWHERE; }
/** * Manipulating the input array, $params, adding new selectorbox items. * * @param array array of select field options (reference) * @param object parent object (reference) * @return void */ function main(&$params, &$pObj) { if (version_compare(TYPO3_branch, '6.1', '<')) { GeneralUtility::loadTCA('tt_address'); } // TODO consolidate with list in pi1 $coreSortFields = 'gender, first_name, middle_name, last_name, title, company, ' . 'address, building, room, birthday, zip, city, region, country, email, www, phone, mobile, ' . 'fax'; $sortFields = GeneralUtility::trimExplode(',', $coreSortFields); $selectOptions = array(); foreach ($sortFields as $field) { $label = $GLOBALS['LANG']->sL($GLOBALS['TCA']['tt_address']['columns'][$field]['label']); $label = substr($label, 0, -1); $selectOptions[] = array('field' => $field, 'label' => $label); } // add sorting by order of single selection $selectOptions[] = array('field' => 'singleSelection', 'label' => $GLOBALS['LANG']->sL('LLL:EXT:tt_address/pi1/locallang_ff.xml:pi1_flexform.sortBy.singleSelection')); // sort by labels $labels = array(); foreach ($selectOptions as $key => $v) { $labels[$key] = $v['label']; } $labels = array_map('strtolower', $labels); array_multisort($labels, SORT_ASC, $selectOptions); // add fields to <select> foreach ($selectOptions as $option) { $params['items'][] = array($option['label'], $option['field']); } }
/** * Add metadata configuration * * @access protected * * @return void */ protected function cmdAddMetadata() { // Include metadata definition file. include_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey) . 'modules/' . $this->modPath . 'metadata.inc.php'; // Load table configuration array to get default field values. \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tx_dlf_metadata'); $i = 0; // Build data array. foreach ($metadata as $index_name => $values) { $formatIds = array(); foreach ($values['format'] as $format) { $formatIds[] = uniqid('NEW'); $data['tx_dlf_metadataformat'][end($formatIds)] = $format; $data['tx_dlf_metadataformat'][end($formatIds)]['pid'] = intval($this->id); $i++; } $data['tx_dlf_metadata'][uniqid('NEW')] = array('pid' => intval($this->id), 'hidden' => $values['hidden'], 'label' => $GLOBALS['LANG']->getLL($index_name), 'index_name' => $index_name, 'format' => implode(',', $formatIds), 'default_value' => $values['default_value'], 'wrap' => !empty($values['wrap']) ? $values['wrap'] : $GLOBALS['TCA']['tx_dlf_metadata']['columns']['wrap']['config']['default'], 'tokenized' => 0, 'stored' => 0, 'indexed' => 0, 'boost' => 0.0, 'is_sortable' => 0, 'is_facet' => 0, 'is_listed' => $values['is_listed'], 'autocomplete' => 0); $i++; } $_ids = tx_dlf_helper::processDBasAdmin($data); // Check for failed inserts. if (count($_ids) == $i) { // Fine. $_message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('flash.metadataAddedMsg'), $GLOBALS['LANG']->getLL('flash.metadataAdded', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::OK, FALSE); } else { // Something went wrong. $_message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('flash.metadataNotAddedMsg'), $GLOBALS['LANG']->getLL('flash.metadataNotAdded', TRUE), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, FALSE); } tx_dlf_helper::addMessage($_message); }
/** * Load the configuration of a table and additional configuration by language packs * * @param string $tableName: the name of the table * @return void */ public static function loadTca($tableName) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName); // Get all extending TCA's if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['extendingTCA'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['extendingTCA'] as $extensionKey) { if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extensionKey)) { include \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extensionKey) . 'ext_tables.php'; } } } }
/** * Register item function. * * @param string $table Table name * @param integer $id Record uid * @param string $field Field name * @param string $content Content string. * @return void * @todo Define visibility */ public function regItem($table, $id, $field, $content) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); $config = $GLOBALS['TCA'][$table]['columns'][$field]['config']; switch ($config['type']) { case 'input': if (isset($config['checkbox']) && $content == $config['checkbox']) { $content = ''; break; } if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($config['eval'], 'date')) { $content = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $content); } break; case 'group': case 'select': break; } $this->theRecord[$field] = $content; }
/** * Main function * Makes a header-location redirect to an edit form IF POSSIBLE from the passed data - otherwise the window will just close. * * @return void * @todo Define visibility */ public function main() { if ($this->doClose) { $this->closeWindow(); } else { // Initialize: $table = $this->P['table']; $field = $this->P['field']; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); $config = $GLOBALS['TCA'][$table]['columns'][$field]['config']; $fTable = $this->P['currentValue'] < 0 ? $config['neg_foreign_table'] : $config['foreign_table']; // Detecting the various allowed field type setups and acting accordingly. if (is_array($config) && $config['type'] == 'select' && !$config['MM'] && $config['maxitems'] <= 1 && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->P['currentValue']) && $this->P['currentValue'] && $fTable) { // SINGLE value: $redirectUrl = 'alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . '&edit[' . $fTable . '][' . $this->P['currentValue'] . ']=edit'; \TYPO3\CMS\Core\Utility\HttpUtility::redirect($redirectUrl); } elseif (is_array($config) && $this->P['currentSelectedValues'] && ($config['type'] == 'select' && $config['foreign_table'] || $config['type'] == 'group' && $config['internal_type'] == 'db')) { // MULTIPLE VALUES: // Init settings: $allowedTables = $config['type'] == 'group' ? $config['allowed'] : $config['foreign_table'] . ',' . $config['neg_foreign_table']; $prependName = 1; $params = ''; // Selecting selected values into an array: $dbAnalysis = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler'); $dbAnalysis->start($this->P['currentSelectedValues'], $allowedTables); $value = $dbAnalysis->getValueArray($prependName); // Traverse that array and make parameters for alt_doc.php: foreach ($value as $rec) { $recTableUidParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $rec, 2); $params .= '&edit[' . $recTableUidParts[0] . '][' . $recTableUidParts[1] . ']=edit'; } // Redirect to alt_doc.php: \TYPO3\CMS\Core\Utility\HttpUtility::redirect('alt_doc.php?returnUrl=' . rawurlencode('wizard_edit.php?doClose=1') . $params); } else { $this->closeWindow(); } } }
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/FlexFormPi1.xml'); /** * Load UserFunc for FlexForm Field selection */ if (TYPO3_MODE == 'BE') { require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Classes/Utility/FlexFormFieldSelection.php'; } /** * Table configuration fe_users */ $tempColumns = array('gender' => array('exclude' => 0, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:tx_femanager_domain_model_user.gender', 'config' => array('type' => 'radio', 'items' => array(array('LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:tx_femanager_domain_model_user.gender.item0', '0'), array('LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:tx_femanager_domain_model_user.gender.item1', '1')))), 'date_of_birth' => array('exclude' => 0, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:tx_femanager_domain_model_user.dateOfBirth', 'config' => array('type' => 'input', 'size' => 10, 'max' => 20, 'eval' => 'date', 'checkbox' => '0', 'default' => '')), 'crdate' => array('exclude' => 1, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:fe_users.crdate', 'config' => array('type' => 'input', 'size' => 30, 'eval' => 'datetime', 'readOnly' => 1, 'default' => time())), 'tstamp' => array('exclude' => 1, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:fe_users.tstamp', 'config' => array('type' => 'input', 'size' => 30, 'eval' => 'datetime', 'readOnly' => 1, 'default' => time())), 'tx_femanager_confirmedbyuser' => array('exclude' => 1, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:fe_users.registrationconfirmedbyuser', 'config' => array('type' => 'check', 'default' => 0)), 'tx_femanager_confirmedbyadmin' => array('exclude' => 1, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:fe_users.registrationconfirmedbyadmin', 'config' => array('type' => 'check', 'default' => 0))); $fields = 'crdate, tstamp, tx_femanager_confirmedbyuser, tx_femanager_confirmedbyadmin'; if (empty($confArr['disableLog'])) { $tempColumns['tx_femanager_log'] = array('exclude' => 1, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:fe_users.log', 'config' => array('type' => 'inline', 'foreign_table' => 'tx_femanager_domain_model_log', 'foreign_field' => 'user', 'maxitems' => 1000, 'minitems' => 0, 'appearance' => array('collapseAll' => 1, 'expandSingle' => 1))); $fields .= ', tx_femanager_log'; } $tempColumns['tx_femanager_changerequest'] = array('exclude' => 1, 'label' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:fe_users.changerequest', 'config' => array('type' => 'text', 'cols' => '40', 'rows' => '15', 'wrap' => 'off', 'readOnly' => 1)); $fields .= ', tx_femanager_changerequest'; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('fe_users'); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('fe_users', 'gender, date_of_birth', '', 'after:name'); if (version_compare(TYPO3_branch, '6.2', '<')) { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('fe_users', $tempColumns, 1); } else { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('fe_users', $tempColumns); } \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('fe_users', '--div--;LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:fe_users.tab;;;;1-1-1, ' . $fields); /** * Table configuration tx_femanager_domain_model_log */ \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_femanager_domain_model_log'); $TCA['tx_femanager_domain_model_log'] = array('ctrl' => array('title' => 'LLL:EXT:femanager/Resources/Private/Language/locallang_db.xlf:tx_femanager_domain_model_log', 'label' => 'title', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => TRUE, 'versioningWS' => 2, 'versioning_followPages' => TRUE, 'origUid' => 't3_origuid', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'default_sortby' => 'ORDER BY crdate DESC', 'enablecolumns' => array('disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime'), 'searchFields' => 'title', 'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Log.php', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/Log.gif'));
/** * Processing of soft references * * @return void * @todo Define visibility */ public function processSoftReferences() { // Initialize: $inData = array(); // Traverse records: if (is_array($this->dat['header']['records'])) { foreach ($this->dat['header']['records'] as $table => $recs) { foreach ($recs as $uid => $thisRec) { // If there are soft references defined, traverse those: if (isset($GLOBALS['TCA'][$table]) && is_array($thisRec['softrefs'])) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); // First traversal is to collect softref configuration and split them up based on fields. This could probably also have been done with the "records" key instead of the header. $fieldsIndex = array(); foreach ($thisRec['softrefs'] as $softrefDef) { // If a substitution token is set: if ($softrefDef['field'] && is_array($softrefDef['subst']) && $softrefDef['subst']['tokenID']) { $fieldsIndex[$softrefDef['field']][$softrefDef['subst']['tokenID']] = $softrefDef; } } // The new id: $thisNewUid = \TYPO3\CMS\Backend\Utility\BackendUtility::wsMapId($table, $this->import_mapId[$table][$uid]); // Now, if there are any fields that require substitution to be done, lets go for that: foreach ($fieldsIndex as $field => $softRefCfgs) { if (is_array($GLOBALS['TCA'][$table]['columns'][$field])) { $conf = $GLOBALS['TCA'][$table]['columns'][$field]['config']; if ($conf['type'] === 'flex') { // This will fetch the new row for the element (which should be updated with any references to data structures etc.) $origRecordRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $thisNewUid, '*'); if (is_array($origRecordRow)) { // Get current data structure and value array: $dataStructArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getFlexFormDS($conf, $origRecordRow, $table); $currentValueArray = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($origRecordRow[$field]); // Do recursive processing of the XML data: /** @var $iteratorObj \TYPO3\CMS\Core\DataHandling\DataHandler */ $iteratorObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $iteratorObj->callBackObj = $this; $currentValueArray['data'] = $iteratorObj->checkValue_flex_procInData($currentValueArray['data'], array(), array(), $dataStructArray, array($table, $uid, $field, $softRefCfgs), 'processSoftReferences_flexFormCallBack'); // The return value is set as an array which means it will be processed by tcemain for file and DB references! if (is_array($currentValueArray['data'])) { $inData[$table][$thisNewUid][$field] = $currentValueArray; } } } else { // Get tokenizedContent string and proceed only if that is not blank: $tokenizedContent = $this->dat['records'][$table . ':' . $uid]['rels'][$field]['softrefs']['tokenizedContent']; if (strlen($tokenizedContent) && is_array($softRefCfgs)) { $inData[$table][$thisNewUid][$field] = $this->processSoftReferences_substTokens($tokenizedContent, $softRefCfgs, $table, $uid); } } } } } } } } // Now write to database: $tce = $this->getNewTCE(); $this->callHook('before_processSoftReferences', array('tce' => &$tce, 'data' => &$inData)); $tce->enableLogging = TRUE; $tce->start($inData, array()); $tce->process_datamap(); $this->callHook('after_processSoftReferences', array('tce' => &$tce)); }
/** * Gets the related items of the current record's configured field. * * @param array $configuration for the content object * @param tslib_cObj $parentContentObject parent content object * @return array Array of related items, values already resolved from related records */ protected function getRelatedItems(tslib_cObj $parentContentObject) { $relatedItems = array(); list($localTableName, $localRecordUid) = explode(':', $parentContentObject->currentRecord); $GLOBALS['TSFE']->includeTCA(); if (version_compare(TYPO3_version, '6.0.0', '>=')) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($localTableName); } else { t3lib_div::loadTCA($localTableName); } $localTableTca = $GLOBALS['TCA'][$localTableName]; $localFieldName = $this->configuration['localField']; $localFieldTca = $localTableTca['columns'][$localFieldName]; if (isset($localFieldTca['config']['MM']) && trim($localFieldTca['config']['MM']) !== '') { $relatedItems = $this->getRelatedItemsFromMMTable($localTableName, $localRecordUid, $localFieldTca); } else { $relatedItems = $this->getRelatedItemsFromForeignTable($localFieldName, $localRecordUid, $localFieldTca, $parentContentObject); } return $relatedItems; }
/** * Checks the array for elements which might contain unallowed default values and will unset them! * Looks for the "tt_content_defValues" key in each element and if found it will traverse that array as fieldname / value pairs and check. The values will be added to the "params" key of the array (which should probably be unset or empty by default). * * @param array $wizardItems Wizard items, passed by reference * @return void * @todo Define visibility */ public function removeInvalidElements(&$wizardItems) { // Load full table definition: \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tt_content'); // Get TCEFORM from TSconfig of current page $row = array('pid' => $this->id); $TCEFORM_TSconfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getTCEFORM_TSconfig('tt_content', $row); $removeItems = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $TCEFORM_TSconfig['CType']['removeItems'], 1); $keepItems = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $TCEFORM_TSconfig['CType']['keepItems'], 1); $headersUsed = array(); // Traverse wizard items: foreach ($wizardItems as $key => $cfg) { // Exploding parameter string, if any (old style) if ($wizardItems[$key]['params']) { // Explode GET vars recursively $tempGetVars = \TYPO3\CMS\Core\Utility\GeneralUtility::explodeUrl2Array($wizardItems[$key]['params'], TRUE); // If tt_content values are set, merge them into the tt_content_defValues array, unset them from $tempGetVars and re-implode $tempGetVars into the param string (in case remaining parameters are around). if (is_array($tempGetVars['defVals']['tt_content'])) { $wizardItems[$key]['tt_content_defValues'] = array_merge(is_array($wizardItems[$key]['tt_content_defValues']) ? $wizardItems[$key]['tt_content_defValues'] : array(), $tempGetVars['defVals']['tt_content']); unset($tempGetVars['defVals']['tt_content']); $wizardItems[$key]['params'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $tempGetVars); } } // If tt_content_defValues are defined...: if (is_array($wizardItems[$key]['tt_content_defValues'])) { // Traverse field values: foreach ($wizardItems[$key]['tt_content_defValues'] as $fN => $fV) { if (is_array($GLOBALS['TCA']['tt_content']['columns'][$fN])) { // Get information about if the field value is OK: $config =& $GLOBALS['TCA']['tt_content']['columns'][$fN]['config']; $authModeDeny = $config['type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode('tt_content', $fN, $fV, $config['authMode']); $isNotInKeepItems = count($keepItems) && !in_array($fV, $keepItems); if ($authModeDeny || $fN == 'CType' && in_array($fV, $removeItems) || $isNotInKeepItems) { // Remove element all together: unset($wizardItems[$key]); break; } else { // Add the parameter: $wizardItems[$key]['params'] .= '&defVals[tt_content][' . $fN . ']=' . rawurlencode($fV); $tmp = explode('_', $key); $headersUsed[$tmp[0]] = $tmp[0]; } } } } } // remove headers without elements foreach ($wizardItems as $key => $cfg) { $tmp = explode('_', $key); if ($tmp[0] && !$tmp[1] && !in_array($tmp[0], $headersUsed)) { unset($wizardItems[$key]); } } }
/** * The main processing method if this class * * @return string Information of the template status or the taken actions as HTML string * @todo Define visibility */ public function main() { global $BACK_PATH; global $tmpl, $tplRow, $theConstants; $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = TRUE; $edit = $this->pObj->edit; $e = $this->pObj->e; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('sys_template'); // Checking for more than one template an if, set a menu... $manyTemplatesMenu = $this->pObj->templateMenu(); $template_uid = 0; if ($manyTemplatesMenu) { $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage']; } // Initialize $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); if ($existTemplate) { $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; } // Create extension template $newId = $this->pObj->createTemplate($this->pObj->id, $saveId); if ($newId) { // Switch to new template $urlParameters = array('id' => $this->pObj->id, 'SET[templatesOnPage]' => $newId); $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters); \TYPO3\CMS\Core\Utility\HttpUtility::redirect($aHref); } if ($existTemplate) { // Update template ? $POST = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST(); if ($POST['submit'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['submit_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['submit_y']) || $POST['saveclose'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_y'])) { // Set the data to be saved $recData = array(); $alternativeFileName = array(); $tmp_upload_name = ''; // Set this to blank $tmp_newresource_name = ''; if (is_array($POST['data'])) { foreach ($POST['data'] as $field => $val) { switch ($field) { case 'constants': case 'config': case 'title': case 'sitetitle': case 'description': $recData['sys_template'][$saveId][$field] = $val; break; } } } if (count($recData)) { $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]); // Create new tce-object $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $tce->stripslashes_values = 0; $tce->alternativeFileName = $alternativeFileName; // Initialize $tce->start($recData, array()); // Saved the stuff $tce->process_datamap(); // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php) $tce->clear_cacheCmd('all'); // tce were processed successfully $this->tce_processed = TRUE; // re-read the template ... $this->initialize_editor($this->pObj->id, $template_uid); } // If files has been edited: if (is_array($edit)) { if ($edit['filename'] && $tplRow['resources'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($tplRow['resources'], $edit['filename'])) { // Check if there are resources, and that the file is in the resourcelist. $path = PATH_site . $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename']; $fI = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($edit['filename']); if (@is_file($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->pObj->textExtensions, $fI['fileext'])) { // checks that have already been done.. Just to make sure // @TODO: Check if the hardcorded value already has a config member, otherwise create one // Checks that have already been done.. Just to make sure if (filesize($path) < 30720) { \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile($path, $edit['file']); $theOutput .= $this->pObj->doc->spacer(10); $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1); // Clear cache - the file has probably affected the template setup // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible! /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */ $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler'); $tce->stripslashes_values = 0; $tce->start(array(), array()); $tce->clear_cacheCmd('all'); } } } } } // Hook post updating template/TCE processing if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) { $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook']; if (is_array($postTCEProcessingHook)) { $hookParameters = array('POST' => $POST, 'tce' => $tce); foreach ($postTCEProcessingHook as $hookFunction) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } $content = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' (' . $tplRow['sitetitle'] . ')' : ''); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), $content, 0, 1); if ($manyTemplatesMenu) { $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu); } $theOutput .= $this->pObj->doc->spacer(10); $numberOfRows = 35; // If abort pressed, nothing should be edited: if ($POST['abort'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['abort_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['abort_y']) || $POST['saveclose'] || \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_x']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($POST['saveclose_y'])) { unset($e); } if ($e['title']) { $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>'; $outCode .= '<input type="Hidden" name="e[title]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode, TRUE); } if ($e['sitetitle']) { $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>'; $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode, TRUE); } if ($e['description']) { $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($tplRow['description']) . '</textarea>'; $outCode .= '<input type="Hidden" name="e[description]" value="1">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode, TRUE); } if ($e['constants']) { $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($tplRow['constants']) . '</textarea>'; $outCode .= '<input type="Hidden" name="e[constants]" value="1">'; // Display "Include TypoScript file content?" checkbox $outCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[constants]=1', 'id="checkIncludeTypoScriptFileContent"'); $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '', TRUE); $theOutput .= $this->pObj->doc->sectionEnd() . $outCode; } if ($e['file']) { $path = PATH_site . $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file]; $fI = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($e[file]); if (@is_file($path) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->pObj->textExtensions, $fI['fileext'])) { if (filesize($path) < $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['max_size'] * 1024) { $fileContent = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl($path); $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>'; $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($fileContent) . '</textarea>'; $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">'; $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">'; $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), ''); $theOutput .= $this->pObj->doc->sectionEnd() . $outCode; } else { $theOutput .= $this->pObj->doc->spacer(15); $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['max_size']); $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['max_size']); $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1); } } } if ($e['config']) { $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . \TYPO3\CMS\Core\Utility\GeneralUtility::formatForTextarea($tplRow['config']) . '</textarea>'; $outCode .= '<input type="Hidden" name="e[config]" value="1">'; // Display "Include TypoScript file content?" checkbox $outCode .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[includeTypoScriptFileContent]', $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'], '', '&e[config]=1', 'id="checkIncludeTypoScriptFileContent"'); $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />'; if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('tsconfig_help')) { $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref'; $params = array('formName' => 'editForm', 'itemName' => 'data[config]'); $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', TRUE))) . '</a>'; } $theOutput .= $this->pObj->doc->spacer(15); $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '', TRUE); $theOutput .= $this->pObj->doc->sectionEnd() . $outCode; } // Processing: $outCode = ''; $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants'); $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config'); $outCode = '<table class="t3-table-info">' . $outCode . '</table>'; // Edit all icon: $outCode .= '<br /><a href="#" onClick="' . \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick(rawurlencode('&createExtension=0') . '&edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>'; $theOutput .= $this->pObj->doc->section('', $outCode); // hook after compiling the output if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) { $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook']; if (is_array($postOutputProcessingHook)) { $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows); foreach ($postOutputProcessingHook as $hookFunction) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this); } } } } else { $theOutput .= $this->pObj->noTemplate(1); } return $theOutput; }
/** * Set which pointing field (in the TCEForm) we are currently rendering the element browser for * * @param string $tableName Table name * @param string $fieldName Field name */ public function setRelatingTableAndField($tableName, $fieldName) { global $TCA; // Check validity of the input data and load TCA if (isset($TCA[$tableName])) { $this->relatingTable = $tableName; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName); if ($fieldName && isset($TCA[$tableName]['columns'][$fieldName])) { $this->relatingField = $fieldName; } } }
/** * Rendering all other listings than QuickEdit * * @return void * @todo Define visibility */ public function renderListContent() { // Initialize list object (see "class.db_layout.inc"): /** @var $dblist \TYPO3\CMS\Backend\View\PageLayoutView */ $dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageLayoutView'); $dblist->backPath = $GLOBALS['BACK_PATH']; $dblist->thumbs = $this->imagemode; $dblist->no_noWrap = 1; $dblist->descrTable = $this->descrTable; $this->pointer = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->pointer, 0, 100000); $dblist->script = 'db_layout.php'; $dblist->showIcon = 0; $dblist->setLMargin = 0; $dblist->doEdit = $this->EDIT_CONTENT; $dblist->ext_CALC_PERMS = $this->CALC_PERMS; $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears'); $dblist->id = $this->id; $dblist->nextThree = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->modTSconfig['properties']['editFieldsAtATime'], 0, 10); $dblist->option_showBigButtons = $this->modTSconfig['properties']['disableBigButtons'] === '0'; $dblist->option_newWizard = $this->modTSconfig['properties']['disableNewContentElementWizard'] ? 0 : 1; $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0; if (!$dblist->nextThree) { $dblist->nextThree = 1; } $dblist->externalTables = $this->externalTables; // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!) $h_menu = $dblist->getTableMenu($this->id); // Initialize other variables: $h_func = ''; $tableOutput = array(); $tableJSOutput = array(); $CMcounter = 0; // Traverse the list of table names which has records on this page (that array is populated // by the $dblist object during the function getTableMenu()): foreach ($dblist->activeTables as $table => $value) { // Load full table definitions: \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); if (!isset($dblist->externalTables[$table])) { $q_count = $this->getNumberOfHiddenElements(); $h_func_b = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], 'db_layout.php', '', 'id="checkTt_content_showHidden"') . '<label for="checkTt_content_showHidden">' . (!$q_count ? $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('hiddenCE')) : $GLOBALS['LANG']->getLL('hiddenCE') . ' (' . $q_count . ')') . '</label>'; // Boolean: Display up/down arrows and edit icons for tt_content records $dblist->tt_contentConfig['showCommands'] = 1; // Boolean: Display info-marks or not $dblist->tt_contentConfig['showInfo'] = 1; // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown // in the total width of the page $dblist->tt_contentConfig['single'] = 0; if ($this->MOD_SETTINGS['function'] == 4) { // Grid view $dblist->tt_contentConfig['showAsGrid'] = 1; } // Setting up the tt_content columns to show: if (is_array($GLOBALS['TCA']['tt_content']['columns']['colPos']['config']['items'])) { $colList = array(); $tcaItems = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction('EXT:cms/classes/class.tx_cms_backendlayout.php:TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $this->id, $this); foreach ($tcaItems as $temp) { $colList[] = $temp[1]; } } else { // ... should be impossible that colPos has no array. But this is the fallback should it make any sense: $colList = array('1', '0', '2', '3'); } if (strcmp($this->colPosList, '')) { $colList = array_intersect(\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->colPosList), $colList); } // If only one column found, display the single-column view. if (count($colList) === 1 && !$this->MOD_SETTINGS['function'] === 4) { // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] // is shown in the total width of the page $dblist->tt_contentConfig['single'] = 1; // The column(s) to show if single mode (under each other) $dblist->tt_contentConfig['showSingleCol'] = current($colList); } // The order of the rows: Default is left(1), Normal(0), right(2), margin(3) $dblist->tt_contentConfig['cols'] = implode(',', $colList); $dblist->tt_contentConfig['showHidden'] = $this->MOD_SETTINGS['tt_content_showHidden']; $dblist->tt_contentConfig['sys_language_uid'] = intval($this->current_sys_language); // If the function menu is set to "Language": if ($this->MOD_SETTINGS['function'] == 2) { $dblist->tt_contentConfig['single'] = 0; $dblist->tt_contentConfig['languageMode'] = 1; $dblist->tt_contentConfig['languageCols'] = $this->MOD_MENU['language']; $dblist->tt_contentConfig['languageColsPointer'] = $this->current_sys_language; } } else { if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) { $h_func = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', ''); } else { $h_func = ''; } } // Start the dblist object: $dblist->itemsLimitSingleTable = 1000; $dblist->start($this->id, $table, $this->pointer, $this->search_field, $this->search_levels, $this->showLimit); $dblist->counter = $CMcounter; $dblist->ext_function = $this->MOD_SETTINGS['function']; // Render versioning selector: $dblist->HTMLcode .= $this->doc->getVersionSelector($this->id); // Generate the list of elements here: $dblist->generateList(); // Adding the list content to the tableOutput variable: $tableOutput[$table] = ($h_func ? $h_func . '<br /><img src="clear.gif" width="1" height="4" alt="" /><br />' : '') . $dblist->HTMLcode . ($h_func_b ? '<img src="clear.gif" width="1" height="10" alt="" /><br />' . $h_func_b : ''); // ... and any accumulated JavaScript goes the same way! $tableJSOutput[$table] = $dblist->JScode; // Increase global counter: $CMcounter += $dblist->counter; // Reset variables after operation: $dblist->HTMLcode = ''; $dblist->JScode = ''; $h_func = ''; $h_func_b = ''; } // END: traverse tables // For Context Sensitive Menus: $this->doc->getContextMenuCode(); // Add the content for each table we have rendered (traversing $tableOutput variable) foreach ($tableOutput as $table => $output) { $content .= $this->doc->section('', $output, TRUE, TRUE, 0, TRUE); $content .= $this->doc->spacer(15); $content .= $this->doc->sectionEnd(); } // Making search form: if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) { $sectionTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp('xMOD_csh_corebe', 'list_searchbox', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.search', TRUE)); $content .= $this->doc->section($sectionTitle, $dblist->getSearchBox(0), FALSE, TRUE, FALSE, TRUE); } // Additional footer content $footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawFooterHook']; if (is_array($footerContentHook)) { foreach ($footerContentHook as $hook) { $params = array(); $content .= \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hook, $params, $this); } } return $content; }
/** * Makes the list of fields to select for a table * * @param string $table Table name * @param boolean $dontCheckUser If set, users access to the field (non-exclude-fields) is NOT checked. * @param boolean $addDateFields If set, also adds crdate and tstamp fields (note: they will also be added if user is admin or dontCheckUser is set) * @return array Array, where values are fieldnames to include in query * @todo Define visibility */ public function makeFieldList($table, $dontCheckUser = 0, $addDateFields = 0) { // Init fieldlist array: $fieldListArr = array(); // Check table: if (is_array($GLOBALS['TCA'][$table]) && isset($GLOBALS['TCA'][$table]['columns']) && is_array($GLOBALS['TCA'][$table]['columns'])) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); if (isset($GLOBALS['TCA'][$table]['columns']) && is_array($GLOBALS['TCA'][$table]['columns'])) { // Traverse configured columns and add them to field array, if available for user. foreach ($GLOBALS['TCA'][$table]['columns'] as $fN => $fieldValue) { if ($dontCheckUser || (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $table . ':' . $fN)) && $fieldValue['config']['type'] != 'passthrough') { $fieldListArr[] = $fN; } } // Add special fields: if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) { $fieldListArr[] = 'uid'; $fieldListArr[] = 'pid'; } // Add date fields if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin() || $addDateFields) { if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) { $fieldListArr[] = $GLOBALS['TCA'][$table]['ctrl']['tstamp']; } if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) { $fieldListArr[] = $GLOBALS['TCA'][$table]['ctrl']['crdate']; } } // Add more special fields: if ($dontCheckUser || $GLOBALS['BE_USER']->isAdmin()) { if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) { $fieldListArr[] = $GLOBALS['TCA'][$table]['ctrl']['cruser_id']; } if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) { $fieldListArr[] = $GLOBALS['TCA'][$table]['ctrl']['sortby']; } if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) { $fieldListArr[] = 't3ver_id'; $fieldListArr[] = 't3ver_state'; $fieldListArr[] = 't3ver_wsid'; } } } else { \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog(sprintf('$TCA is broken for the table "%s": no required "columns" entry in $TCA.', $table), 'core', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR); } } return $fieldListArr; }
/** * Rendering the "Filelinks" type content element, called from TypoScript (tt_content.uploads.20) * * @param string $content Content input. Not used, ignore. * @param array $conf TypoScript configuration * @return string HTML output. * @access private * @todo Define visibility */ public function render_uploads($content, $conf) { // Look for hook before running default code for function if ($hookObj = $this->hookRequest('render_uploads')) { return $hookObj->render_uploads($content, $conf); } else { // Loading language-labels $this->pi_loadLL(); $out = ''; // Set layout type: $type = intval($this->cObj->data['layout']); // See if the file path variable is set, this takes precedence $filePathConf = $this->cObj->stdWrap($conf['filePath'], $conf['filePath.']); if ($filePathConf) { $fileList = $this->cObj->filelist($filePathConf); list($path) = explode('|', $filePathConf); } else { // Get the list of files from the field $field = trim($conf['field']) ? trim($conf['field']) : 'media'; $fileList = $this->cObj->data[$field]; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tt_content'); $path = 'uploads/media/'; if (is_array($GLOBALS['TCA']['tt_content']['columns'][$field]) && !empty($GLOBALS['TCA']['tt_content']['columns'][$field]['config']['uploadfolder'])) { // In TCA-Array folders are saved without trailing slash, so $path.$fileName won't work $path = $GLOBALS['TCA']['tt_content']['columns'][$field]['config']['uploadfolder'] . '/'; } } $path = trim($path); // Explode into an array: $fileArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $fileList, 1); // If there were files to list...: if (count($fileArray)) { // Get the descriptions for the files (if any): $descriptions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->cObj->data['imagecaption']); // Get the titles for the files (if any) $titles = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->cObj->data['titleText']); // Get the alternative text for icons/thumbnails $altTexts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $this->cObj->data['altText']); // Add the target to linkProc when explicitly set if ($this->cObj->data['target']) { $conf['linkProc.']['target'] = $this->cObj->data['target']; unset($conf['linkProc.']['target.']); } // Adding hardcoded TS to linkProc configuration: $conf['linkProc.']['path.']['current'] = 1; if ($conf['linkProc.']['combinedLink']) { $conf['linkProc.']['icon'] = $type > 0 ? 1 : 0; } else { // Always render icon - is inserted by PHP if needed. $conf['linkProc.']['icon'] = 1; // Temporary, internal split-token! $conf['linkProc.']['icon.']['wrap'] = ' | //**//'; // ALways link the icon $conf['linkProc.']['icon_link'] = 1; } $conf['linkProc.']['icon_image_ext_list'] = $type == 2 || $type == 3 ? $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] : ''; // If the layout is type 2 or 3 we will render an image based icon if possible. if ($conf['labelStdWrap.']) { $conf['linkProc.']['labelStdWrap.'] = $conf['labelStdWrap.']; } if ($conf['useSpacesInLinkText'] || $conf['stripFileExtensionFromLinkText']) { $conf['linkProc.']['removePrependedNumbers'] = 0; } // Traverse the files found: $filesData = array(); foreach ($fileArray as $key => $fileName) { $absPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName(\TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($path . $fileName)); if (@is_file($absPath)) { $fI = pathinfo($fileName); $filesData[$key] = array(); $currentPath = $path; if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($fileName, '../../')) { $currentPath = ''; $fileName = substr($fileName, 6); } $filesData[$key]['filename'] = $fileName; $filesData[$key]['path'] = $currentPath; $filesData[$key]['filesize'] = filesize($absPath); $filesData[$key]['fileextension'] = strtolower($fI['extension']); $filesData[$key]['description'] = trim($descriptions[$key]); $conf['linkProc.']['title'] = trim($titles[$key]); if (isset($altTexts[$key]) && !empty($altTexts[$key])) { $altText = trim($altTexts[$key]); } else { $altText = sprintf($this->pi_getLL('uploads.icon'), $fileName); } $conf['linkProc.']['altText'] = $conf['linkProc.']['iconCObject.']['altText'] = $altText; $this->cObj->setCurrentVal($currentPath); $GLOBALS['TSFE']->register['ICON_REL_PATH'] = $currentPath . $fileName; $GLOBALS['TSFE']->register['filename'] = $filesData[$key]['filename']; $GLOBALS['TSFE']->register['path'] = $filesData[$key]['path']; $GLOBALS['TSFE']->register['fileSize'] = $filesData[$key]['filesize']; $GLOBALS['TSFE']->register['fileExtension'] = $filesData[$key]['fileextension']; $GLOBALS['TSFE']->register['description'] = $filesData[$key]['description']; $filesData[$key]['linkedFilenameParts'] = $this->beautifyFileLink(explode('//**//', $this->cObj->filelink($fileName, $conf['linkProc.'])), $fileName, $conf['useSpacesInLinkText'], $conf['stripFileExtensionFromLinkText']); } } // optionSplit applied to conf to allow differnt settings per file $splitConf = $GLOBALS['TSFE']->tmpl->splitConfArray($conf, count($filesData)); // Now, lets render the list! $outputEntries = array(); foreach ($filesData as $key => $fileData) { $GLOBALS['TSFE']->register['linkedIcon'] = $fileData['linkedFilenameParts'][0]; $GLOBALS['TSFE']->register['linkedLabel'] = $fileData['linkedFilenameParts'][1]; $GLOBALS['TSFE']->register['filename'] = $fileData['filename']; $GLOBALS['TSFE']->register['path'] = $fileData['path']; $GLOBALS['TSFE']->register['description'] = $fileData['description']; $GLOBALS['TSFE']->register['fileSize'] = $fileData['filesize']; $GLOBALS['TSFE']->register['fileExtension'] = $fileData['fileextension']; $outputEntries[] = $this->cObj->cObjGetSingle($splitConf[$key]['itemRendering'], $splitConf[$key]['itemRendering.']); } if (isset($conf['outerWrap'])) { // Wrap around the whole content $outerWrap = $this->cObj->stdWrap($conf['outerWrap'], $conf['outerWrap.']); } else { // Table tag params $tableTagParams = $this->getTableAttributes($conf, $type); $tableTagParams['class'] = 'csc-uploads csc-uploads-' . $type; $outerWrap = '<table ' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes($tableTagParams) . '>|</table>'; } // Compile it all into table tags: $out = $this->cObj->wrap(implode('', $outputEntries), $outerWrap); } // Calling stdWrap: if ($conf['stdWrap.']) { $out = $this->cObj->stdWrap($out, $conf['stdWrap.']); } // Return value return $out; } }
/** * @test * @dataProvider getLabelFromItemListMergedReturnsCorrectFieldsDataProvider */ public function getLabelFromItemListMergedReturnsCorrectFields($pageId, $table, $column = '', $key = '', array $tca, $expectedLabel = '') { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); $tcaBackup = $GLOBALS['TCA'][$table]; unset($GLOBALS['TCA'][$table]); $GLOBALS['TCA'][$table] = $tca; $label = $this->fixture->getLabelFromItemListMerged($pageId, $table, $column, $key); unset($GLOBALS['TCA'][$table]); $GLOBALS['TCA'][$table] = $tcaBackup; $this->assertEquals($label, $expectedLabel); }
/** * Gets the TCA configuration of a field. * * @param string $table Name of the table * @param string $field Name of the field * @return array */ public static function getTcaFieldConfiguration($table, $field) { $configuration = array(); \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); if (isset($GLOBALS['TCA'][$table]['columns'][$field]['config'])) { $configuration = $GLOBALS['TCA'][$table]['columns'][$field]['config']; } return $configuration; }
// Country reference data from ISO 3166-1 $GLOBALS['TCA']['static_countries'] = array('ctrl' => array('label' => 'cn_short_en', 'label_alt' => 'cn_iso_2', 'label_alt_force' => 1, 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel', 'adminOnly' => 1, 'rootLevel' => 1, 'is_static' => 1, 'readOnly' => 1, 'default_sortby' => 'ORDER BY cn_short_en', 'delete' => 'deleted', 'title' => $extensionResourcesLanguagePath . 'static_countries.title', 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Country.php', 'iconfile' => $extensionResourcesIconsPath . 'icon_static_countries.gif', 'searchFields' => 'cn_short_en,cn_official_name_local,cn_official_name_en'), 'interface' => array('showRecordFieldList' => 'cn_iso_2,cn_iso_3,cn_iso_nr,cn_official_name_local,cn_official_name_en,cn_capital,cn_tldomain,cn_currency_iso_3,cn_currency_iso_nr,cn_phone,cn_uno_member,cn_eu_member,cn_address_format,cn_short_en')); // Country subdivision reference data from ISO 3166-2 $GLOBALS['TCA']['static_country_zones'] = array('ctrl' => array('label' => 'zn_name_local', 'label_alt' => 'zn_name_local,zn_code', 'adminOnly' => 1, 'rootLevel' => 1, 'is_static' => 1, 'readOnly' => 1, 'default_sortby' => 'ORDER BY zn_name_local', 'delete' => 'deleted', 'title' => $extensionResourcesLanguagePath . 'static_country_zones.title', 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'CountryZone.php', 'iconfile' => $extensionResourcesIconsPath . 'icon_static_countries.gif', 'searchFields' => 'zn_name_en,zn_name_local'), 'interface' => array('showRecordFieldList' => 'zn_country_iso_nr,zn_country_iso_3,zn_code,zn_name_local,zn_name_en')); // Currency reference data from ISO 4217 $GLOBALS['TCA']['static_currencies'] = array('ctrl' => array('label' => 'cu_name_en', 'label_alt' => 'cu_iso_3', 'label_alt_force' => 1, 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel', 'adminOnly' => 1, 'rootLevel' => 1, 'is_static' => 1, 'readOnly' => 1, 'default_sortby' => 'ORDER BY cu_name_en', 'delete' => 'deleted', 'title' => $extensionResourcesLanguagePath . 'static_currencies.title', 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Currency.php', 'iconfile' => $extensionResourcesIconsPath . 'icon_static_currencies.gif', 'searchFields' => 'cu_name_en'), 'interface' => array('showRecordFieldList' => 'cu_iso_3,cu_iso_nr,cu_name_en,cu_symbol_left,cu_symbol_right,cu_thousands_point,cu_decimal_point,cu_decimal_digits,cu_sub_name_en,cu_sub_divisor,cu_sub_symbol_left,cu_sub_symbol_right')); // Language reference data from ISO 639-1 $GLOBALS['TCA']['static_languages'] = array('ctrl' => array('label' => 'lg_name_en', 'label_alt' => 'lg_iso_2', 'label_alt_force' => 1, 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel', 'adminOnly' => 1, 'rootLevel' => 1, 'is_static' => 1, 'readOnly' => 1, 'default_sortby' => 'ORDER BY lg_name_en', 'delete' => 'deleted', 'title' => $extensionResourcesLanguagePath . 'static_languages.title', 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Language.php', 'iconfile' => $extensionResourcesIconsPath . 'icon_static_languages.gif', 'searchFields' => 'lg_name_en,lg_name_local'), 'interface' => array('showRecordFieldList' => 'lg_name_local,lg_name_en,lg_iso_2,lg_typo3,lg_country_iso_2,lg_collate_locale,lg_sacred,lg_constructed')); // UN Territory reference data $GLOBALS['TCA']['static_territories'] = array('ctrl' => array('label' => 'tr_name_en', 'label_alt' => 'tr_iso_nr', 'label_alt_force' => 1, 'label_userFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->addIsoCodeToLabel', 'adminOnly' => 1, 'rootLevel' => 1, 'is_static' => 1, 'readOnly' => 1, 'default_sortby' => 'ORDER BY tr_name_en', 'delete' => 'deleted', 'title' => $extensionResourcesLanguagePath . 'static_territories.title', 'dynamicConfigFile' => $extensionConfigurationTcaPath . 'Territory.php', 'iconfile' => $extensionResourcesIconsPath . 'icon_static_territories.gif', 'searchFields' => 'tr_name_en'), 'interface' => array('showRecordFieldList' => 'tr_name_en,tr_iso_nr')); unset($extensionResourcesLanguagePath); unset($extensionConfigurationTcaPath); unset($extensionResourcesIconsPath); // Configure static language field of sys_language table if ($typo3Version < 6001000) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('sys_language'); } $GLOBALS['TCA']['sys_language']['columns']['static_lang_isocode']['config'] = array('type' => 'select', 'items' => array(array('', 0)), 'foreign_table' => 'static_languages', 'foreign_table_where' => 'AND static_languages.pid=0 ORDER BY static_languages.lg_name_en', 'itemsProcFunc' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\ElementRenderingHelper->translateLanguagesSelector', 'size' => '1', 'minitems' => '0', 'maxitems' => '1', 'wizards' => array('suggest' => array('type' => 'suggest', 'default' => array('receiverClass' => 'SJBR\\StaticInfoTables\\Hook\\Backend\\Form\\SuggestReceiver')))); if (TYPO3_MODE == 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) { /** * Registers the Static Info Tables Manager backend module, if enabled */ if ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['enableManager']) { \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule($_EXTKEY, 'tools', 'Manager', '', array('Manager' => 'information,newLanguagePack,createLanguagePack,testForm,testFormResult,sqlDumpNonLocalizedData'), array('access' => 'user,group', 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Images/Icons/moduleicon.gif', 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_mod.xlf')); // Add module configuration setup \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $_EXTKEY . '/Configuration/TypoScript/Manager/setup.txt">'); // Enable editing Static Info Tables if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['tables'])) { $tableNames = array_keys($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['tables']); foreach ($tableNames as $tableName) { if ($typo3Version < 6001000) {
/** * get all images as an array * * @return array<Tx_CzEwlSponsor_Domain_Model_File> */ public function getImages() { if (is_null($this->_cache_images)) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('tt_address'); $this->_cache_images = Tx_CzSimpleCal_Utility_FileArrayBuilder::build($this->image, $GLOBALS['TCA']['tt_address']['columns']['image']['config']['uploadfolder']); } return $this->_cache_images; }
<?php $ajax = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('request'); $ajax['vendor'] = 'Nng'; $ajax['extensionName'] = 'Nnfesubmit'; $TSFE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $TYPO3_CONF_VARS, 0, 0); tslib_eidtools::connectDB(); tslib_eidtools::initLanguage(); // Get FE User Information $TSFE->initFEuser(); // Important: no Cache for Ajax stuff $TSFE->set_no_cache(); // TCA laden für extensions $TSFE->includeTCA(); \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA('nnfesubmit'); $TSFE->checkAlternativeIdMethods(); $TSFE->determineId(); //$TSFE->id = 2060; $TSFE->initTemplate(); $TSFE->getConfigArray(); \TYPO3\CMS\Core\Core\Bootstrap::getInstance(); $TSFE->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $TSFE->settingLanguage(); $TSFE->settingLocale(); if (!$TSFE->baseUrl) { $baseUrl = $GLOBALS['TSFE']->config['config']['baseURL']; $TSFE->baseUrl = $baseUrl ? $baseUrl : $_SERVER['HTTP_HOST']; } $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\\TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); /** * Initialize Extbase bootstap
/** * Includes TCA * * @return void * @todo Define visibility */ public function includeTCA() { \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadExtensionTables(FALSE); foreach ($GLOBALS['TCA'] as $table => $conf) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); } }
* Register Plugin as Page Content and register flexform */ $extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($_EXTKEY); $pluginSignature = strtolower($extensionName) . '_pi1'; $TCA['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform'; \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/Flexform.xml'); /** * Register static Typoscript Template */ \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Promotionshop'); /* * Extend fe_user table */ $tempColumns = array('mobile' => array('exclude' => 1, 'label' => 'LLL:EXT:promoshop/Resources/Private/Language/locallang_db.xml:tx_promoshop_domain_model_customer.mobile:', 'config' => array('type' => 'input', 'eval' => 'trim', 'size' => '20', 'max' => '20')), 'gender' => array('exclude' => 1, 'label' => 'LLL:EXT:promoshop/Resources/Private/Language/locallang_db.xml:tx_promoshop_domain_model_customer.gender:', 'config' => array('type' => 'select', 'items' => array(array('LLL:EXT:promoshop/Resources/Private/Language/locallang_db.xml:tx_promoshop_domain_model_customer.gender.1', 1), array('LLL:EXT:promoshop/Resources/Private/Language/locallang_db.xml:tx_promoshop_domain_model_customer.gender.2', 2))))); // Add new fields to fe_users \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA("fe_users"); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns("fe_users", $tempColumns, 1); $TCA['fe_users']['types']['Tx_Promoshop_Domain_Model_Customer'] = array('showitem' => ' disable,username;;;;1-1-1, password, usergroup, lastlogin;;;;1-1-1, --div--;LLL:EXT:cms/locallang_tca.xml:fe_users.tabs.personelData, company;;;;1-1-1, gender;;2;;2-2-2, address;;3;;2-2-2, telephone;;4;;2-2-2, email, --div--;LLL:EXT:cms/locallang_tca.xml:fe_users.tabs.access, starttime, endtime, --div--;LLL:EXT:cms/locallang_tca.xml:fe_users.tabs.extended, tx_extbase_type '); $TCA['fe_users']['palettes']['2'] = array('showitem' => 'first_name,last_name'); $TCA['fe_users']['palettes']['3'] = array('showitem' => 'zip,city'); $TCA['fe_users']['palettes']['4'] = array('showitem' => 'mobile,fax'); array_push($TCA['fe_users']['columns']['tx_extbase_type']['config']['items'], array('LLL:EXT:promoshop/Resources/Private/Language/locallang_db.xml:fe_users.tx_extbase_type.Tx_Promoshop_Domain_Model_Customer', 'Tx_Promoshop_Domain_Model_Customer')); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_promoshop_domain_model_booking', 'EXT:promoshop/Resources/Private/Language/locallang_csh_tx_promoshop_domain_model_booking.xml'); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_promoshop_domain_model_booking'); $TCA['tx_promoshop_domain_model_booking'] = array('ctrl' => array('title' => 'LLL:EXT:promoshop/Resources/Private/Language/locallang_db.xml:tx_promoshop_domain_model_booking', 'label' => 'customer', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => TRUE, 'origUid' => 't3_origuid', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'enablecolumns' => array('disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime'), 'searchFields' => 'first_name,last_name,address,city,telephone,fax,mobile,email,vbname,vbphone', 'dynamicConfigFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Configuration/TCA/Booking.php', 'iconfile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($_EXTKEY) . 'Resources/Public/Icons/tx_promoshop_domain_model_booking.gif')); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_promoshop_domain_model_product', 'EXT:promoshop/Resources/Private/Language/locallang_csh_tx_promoshop_domain_model_product.xml');
/** * Create the selector box for selecting fields to display from a table: * * @param string $table Table name * @param boolean $formFields If TRUE, form-fields will be wrapped around the table. * @return string HTML table with the selector box (name: displayFields['.$table.'][]) * @todo Define visibility */ public function fieldSelectBox($table, $formFields = 1) { // Init: \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); $formElements = array('', ''); if ($formFields) { $formElements = array('<form action="' . htmlspecialchars($this->listURL()) . '" method="post">', '</form>'); } // Load already selected fields, if any: $setFields = is_array($this->setFields[$table]) ? $this->setFields[$table] : array(); // Request fields from table: $fields = $this->makeFieldList($table, FALSE, TRUE); // Add pseudo "control" fields $fields[] = '_PATH_'; $fields[] = '_REF_'; $fields[] = '_LOCALIZATION_'; $fields[] = '_CONTROL_'; $fields[] = '_CLIPBOARD_'; // Create an option for each field: $opt = array(); $opt[] = '<option value=""></option>'; foreach ($fields as $fN) { // Field label $fL = is_array($GLOBALS['TCA'][$table]['columns'][$fN]) ? rtrim($GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$fN]['label']), ':') : '[' . $fN . ']'; $opt[] = ' <option value="' . $fN . '"' . (in_array($fN, $setFields) ? ' selected="selected"' : '') . '>' . htmlspecialchars($fL) . '</option>'; } // Compile the options into a multiple selector box: $lMenu = ' <select size="' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(count($fields) + 1, 3, 20) . '" multiple="multiple" name="displayFields[' . $table . '][]">' . implode('', $opt) . ' </select> '; // Table with the field selector:: $content = $formElements[0] . ' <!-- Field selector for extended table view: --> <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-fieldSelect"> <tr> <td>' . $lMenu . '</td> <td><input type="submit" name="search" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.setFields', 1) . '" /></td> </tr> </table> ' . $formElements[1]; return '<div class="db_list-fieldSelect">' . $content . '</div>'; }
/** * Call back function for page tree traversal! * * @param string $tableName Table name * @param integer $uid UID of record in processing * @param integer $echoLevel Echo level (see calling function * @param string $versionSwapmode Version swap mode on that level (see calling function * @param integer $rootIsVersion Is root version (see calling function * @return void * @todo Define visibility */ public function main_parseTreeCallBack($tableName, $uid, $echoLevel, $versionSwapmode, $rootIsVersion) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName); foreach ($GLOBALS['TCA'][$tableName]['columns'] as $colName => $config) { if ($config['config']['type'] == 'flex') { if ($echoLevel > 2) { echo LF . ' [cleanflexform:] Field "' . $colName . '" in ' . $tableName . ':' . $uid . ' was a flexform and...'; } $recRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($tableName, 'uid=' . intval($uid)); $flexObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\FlexForm\\FlexFormTools'); if ($recRow[$colName]) { // Clean XML: $newXML = $flexObj->cleanFlexFormXML($tableName, $colName, $recRow); if (md5($recRow[$colName]) != md5($newXML)) { if ($echoLevel > 2) { echo ' was DIRTY, needs cleanup!'; } $this->cleanFlexForm_dirtyFields[\TYPO3\CMS\Core\Utility\GeneralUtility::shortMd5($tableName . ':' . $uid . ':' . $colName)] = $tableName . ':' . $uid . ':' . $colName; } else { if ($echoLevel > 2) { echo ' was CLEAN'; } } } elseif ($echoLevel > 2) { echo ' was EMPTY'; } } } }
/** * Get the compressed $GLOBALS['TCA'] array for use in the front-end * A compressed $GLOBALS['TCA'] array holds only the ctrl- and feInterface-part for each table. But the column-definitions are omitted in order to save some memory and be more efficient. * Operates on the global variable, $TCA * * @return void * @see includeTCA() * @todo Define visibility */ public function getCompressedTCarray() { $GLOBALS['TT']->push('Get Compressed TC array'); if (!$this->TCAloaded) { // Create hash string for storage / retrieval of cached content: $tempHash = md5('tables.php:' . filemtime(TYPO3_extTableDef_script ? PATH_typo3conf . TYPO3_extTableDef_script : PATH_t3lib . 'stddb/tables.php') . (TYPO3_extTableDef_script ? filemtime(PATH_typo3conf . TYPO3_extTableDef_script) : '')); list($GLOBALS['TCA'], $this->TCAcachedExtras) = unserialize($this->sys_page->getHash($tempHash)); // If no result, create it: if (!is_array($GLOBALS['TCA'])) { $this->includeTCA(0); $newTc = array(); // Collects other information $this->TCAcachedExtras = array(); foreach ($GLOBALS['TCA'] as $key => $val) { $newTc[$key]['ctrl'] = $val['ctrl']; $newTc[$key]['feInterface'] = $val['feInterface']; // Collect information about localization exclusion of fields: \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($key); if (is_array($GLOBALS['TCA'][$key]['columns'])) { $this->TCAcachedExtras[$key]['l10n_mode'] = array(); foreach ($GLOBALS['TCA'][$key]['columns'] as $fN => $fV) { if ($fV['l10n_mode']) { $this->TCAcachedExtras[$key]['l10n_mode'][$fN] = $fV['l10n_mode']; } } } } $GLOBALS['TCA'] = $newTc; $this->sys_page->storeHash($tempHash, serialize(array($newTc, $this->TCAcachedExtras)), 'SHORT_TC'); } } $GLOBALS['TT']->pull(); }
/** * Finding all references to record based on table/uid * * @param string $searchTable Table name * @param integer $id Uid of database record * @return array Array with other arrays containing information about where references was found * @todo Define visibility */ public function whereIsRecordReferenced($searchTable, $id) { // Gets tables / Fields that reference to files $fileFields = $this->getDBFields($searchTable); $theRecordList = array(); foreach ($fileFields as $info) { $table = $info[0]; $field = $info[1]; \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,' . $GLOBALS['TCA'][$table]['ctrl']['label'] . ',' . $field, $table, $field . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($id, $table) . '%\''); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) { // Now this is the field, where the reference COULD come from. But we're not garanteed, so we must carefully examine the data. $fieldConf = $GLOBALS['TCA'][$table]['columns'][$field]['config']; $allowedTables = $fieldConf['type'] == 'group' ? $fieldConf['allowed'] : $fieldConf['foreign_table']; /** @var $dbAnalysis \TYPO3\CMS\Core\Database\RelationHandler */ $dbAnalysis = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\RelationHandler'); $dbAnalysis->start($row[$field], $allowedTables, $fieldConf['MM'], $row['uid'], $table, $fieldConf); foreach ($dbAnalysis->itemArray as $tempArr) { if ($tempArr['table'] == $searchTable && $tempArr['id'] == $id) { $theRecordList[] = array('table' => $table, 'uid' => $row['uid'], 'field' => $field, 'pid' => $row['pid']); } } } $GLOBALS['TYPO3_DB']->sql_free_result($mres); } return $theRecordList; }
/** * Build the MySql where clause by table. * * @param string $tableName Record table name * @param array $fieldsToSearchWithin User right based visible fields where we can search within. * @return string */ protected function makeQuerySearchByTable($tableName, array $fieldsToSearchWithin) { $queryPart = ''; $whereParts = array(); // Load the full TCA for the table, as we need to access column configuration \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($tableName); // If the search string is a simple integer, assemble an equality comparison if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->queryString)) { foreach ($fieldsToSearchWithin as $fieldName) { if ($fieldName == 'uid' || $fieldName == 'pid' || isset($GLOBALS['TCA'][$tableName]['columns'][$fieldName])) { $fieldConfig =& $GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config']; // Assemble the search condition only if the field is an integer, or is uid or pid if ($fieldName == 'uid' || $fieldName == 'pid' || $fieldConfig['type'] == 'input' && $fieldConfig['eval'] && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($fieldConfig['eval'], 'int')) { $whereParts[] = $fieldName . '=' . $this->queryString; } } } } else { $like = '\'%' . $GLOBALS['TYPO3_DB']->escapeStrForLike($GLOBALS['TYPO3_DB']->quoteStr($this->queryString, $tableName), $tableName) . '%\''; foreach ($fieldsToSearchWithin as $fieldName) { if (isset($GLOBALS['TCA'][$tableName]['columns'][$fieldName])) { $fieldConfig =& $GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config']; // Check whether search should be case-sensitive or not $format = 'LCASE(%s) LIKE LCASE(%s)'; if (is_array($fieldConfig['search'])) { if (in_array('case', $fieldConfig['search'])) { $format = '%s LIKE %s'; } // Apply additional condition, if any if ($fieldConfig['search']['andWhere']) { $format = '((' . $fieldConfig['search']['andWhere'] . ') AND (' . $format . '))'; } } // Assemble the search condition only if the field makes sense to be searched if ($fieldConfig['type'] == 'text' || $fieldConfig['type'] == 'flex' || $fieldConfig['type'] == 'input' && (!$fieldConfig['eval'] || !preg_match('/date|time|int/', $fieldConfig['eval']))) { $whereParts[] = sprintf($format, $fieldName, $like); } } } } // If at least one condition was defined, create the search query if (count($whereParts) > 0) { $queryPart = ' AND (' . implode(' OR ', $whereParts) . ')'; // And the relevant conditions for deleted and versioned records $queryPart .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableName); $queryPart .= \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause($tableName); } else { $queryPart = ' AND 0 = 1'; } return $queryPart; }
/** * [Describe function...] * * @return void * @todo Define visibility */ public function main() { $arrayBrowser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Lowlevel\\Utility\\ArrayBrowser'); $this->content = $this->doc->header($GLOBALS['LANG']->getLL('configuration', TRUE)); $this->content .= '<div id="lowlevel-config"> <label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', TRUE) . '</label> <input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' /> <input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', TRUE) . '" />'; $this->content .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"') . '<label for="checkRegexsearch">' . $GLOBALS['LANG']->getLL('useRegExp', TRUE) . '</label>'; $this->content .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') . '<label for="checkFixedLgd">' . $GLOBALS['LANG']->getLL('cropLines', TRUE) . '</label> </div>'; $this->content .= $this->doc->spacer(5); switch ($this->MOD_SETTINGS['function']) { case 0: $theVar = $GLOBALS['TYPO3_CONF_VARS']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TYPO3_CONF_VARS'; break; case 1: foreach ($GLOBALS['TCA'] as $table => $config) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table); } $theVar = $GLOBALS['TCA']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TCA'; break; case 2: $theVar = $GLOBALS['TCA_DESCR']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TCA_DESCR'; break; case 3: $theVar = $GLOBALS['TYPO3_LOADED_EXT']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TYPO3_LOADED_EXT'; break; case 4: $theVar = $GLOBALS['T3_SERVICES']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$T3_SERVICES'; break; case 5: $theVar = $GLOBALS['TBE_MODULES']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TBE_MODULES'; break; case 6: $theVar = $GLOBALS['TBE_MODULES_EXT']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TBE_MODULES_EXT'; break; case 7: $theVar = $GLOBALS['TBE_STYLES']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TBE_STYLES'; break; case 8: $theVar = $GLOBALS['BE_USER']->uc; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$BE_USER->uc'; break; case 9: $theVar = $GLOBALS['TYPO3_USER_SETTINGS']; \TYPO3\CMS\Core\Utility\GeneralUtility::naturalKeySortRecursive($theVar); $arrayBrowser->varName = '$TYPO3_USER_SETTINGS'; break; default: $theVar = array(); break; } // Update node: $update = 0; $node = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('node'); // If any plus-signs were clicked, it's registred. if (is_array($node)) { $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]); $update = 1; } if ($update) { $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'], $this->MOD_SETTINGS); } $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]; $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch']; $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd']; $arrayBrowser->searchKeysToo = TRUE; $search_field = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('search_field'); // If any POST-vars are send, update the condition array if (\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('search') && trim($search_field)) { $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array()); } // mask the encryption key to not show it as plaintext in the configuration module if ($theVar == $GLOBALS['TYPO3_CONF_VARS']) { $theVar['SYS']['encryptionKey'] = '***** (length: ' . strlen($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . ' characters)'; } $tree = $arrayBrowser->tree($theVar, '', ''); $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']]; $this->content .= $this->doc->sectionEnd(); // Variable name: if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('varname')) { $line = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_') ? \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_') : \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('varname'); // Write the line to extTables.php if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('writetoexttables')) { // change value to $GLOBALS $length = strpos($line, '['); $var = substr($line, 0, $length); $changedLine = '$GLOBALS[\'' . substr($line, 1, $length - 1) . '\']' . substr($line, $length); // load current extTables.php $extTables = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(PATH_typo3conf . TYPO3_extTableDef_script); if ($var === '$TCA') { // check if we are editing the TCA preg_match_all('/\\[\'([^\']+)\'\\]/', $line, $parts); if ($parts[1][1] !== 'ctrl') { // anything else than ctrl section requires to load TCA $loadTCA = 'TYPO3\\CMS\\Core\\Utility\\GeneralUtility::loadTCA(\'' . $parts[1][0] . '\');'; if (strpos($extTables, $loadTCA) === FALSE) { // check if the loadTCA statement is not already present in the file $changedLine = $loadTCA . LF . $changedLine; } } } // insert line in extTables.php $extTables = preg_replace('/<\\?php|\\?>/is', '', $extTables); $extTables = '<?php' . (empty($extTables) ? LF : '') . $extTables . $changedLine . LF . '?>'; $success = \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables); if ($success) { // show flash message $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script, '<br />', '<strong>' . nl2br($changedLine) . '</strong>'), \TYPO3\CMS\Core\Messaging\FlashMessage::OK); } else { // Error: show flash message $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', '', sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); } $this->content .= $flashMessage->render(); } $this->content .= '<div id="lowlevel-config-var"> <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br /> <input type="text" name="_" value="' . trim(htmlspecialchars($line)) . '" size="120" /><br/>'; if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) { // write only for $TCA and TBE_STYLES if TYPO3_extTableDef_script is defined $this->content .= '<br /><input type="submit" name="writetoexttables" value="' . $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>'; } else { $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>'; } } $this->content .= '<br /><table border="0" cellpadding="0" cellspacing="0" class="t3-tree t3-tree-config">'; $this->content .= '<tr> <th class="t3-row-header t3-tree-config-header">' . $label . '</th> </tr> <tr> <td>' . $tree . '</td> </tr> </table> '; // Setting up the buttons and markers for docheader $docHeaderButtons = $this->getButtons(); $markers = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => $this->getFuncMenu(), 'CONTENT' => $this->content); // Build the <body> for the module $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers); // Renders the module page $this->content = $this->doc->render('Configuration', $this->content); }
/** * @test * @expectedException \RuntimeException */ public function loadTCAIncludesConfiguredDynamicConfigFile() { $dynamicConfigurationAbsoluteFilePath = PATH_site . 'typo3temp/' . uniqid('testLoadTca_'); file_put_contents($dynamicConfigurationAbsoluteFilePath, '<?php throw new \\RuntimeException(\'foo\', 1310203814); ?>'); $this->testFilesToDelete[] = $dynamicConfigurationAbsoluteFilePath; $testTableName = uniqid('testTable_'); $GLOBALS['TCA'][$testTableName] = array('ctrl' => array('dynamicConfigFile' => $dynamicConfigurationAbsoluteFilePath)); Utility\GeneralUtility::loadTCA($testTableName); }
/** * [Describe function...] * * @param [type] $codeArr: ... * @param [type] $l: ... * @param [type] $table: ... * @return [type] ... * @todo Define visibility */ public function makeOptionList($fN, $conf, $table) { $out = ''; $fieldSetup = $this->fields[$fN]; if ($fieldSetup['type'] == 'files') { if ($conf['comparison'] == 66 || $conf['comparison'] == 67) { $fileExtArray = explode(',', $fieldSetup['allowed']); natcasesort($fileExtArray); foreach ($fileExtArray as $fileExt) { if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($conf['inputValue'], $fileExt)) { $out .= '<option value="' . $fileExt . '" selected>.' . $fileExt . '</option>'; } else { $out .= '<option value="' . $fileExt . '">.' . $fileExt . '</option>'; } } } $d = dir(PATH_site . $fieldSetup['uploadfolder']); while (FALSE !== ($entry = $d->read())) { if ($entry == '.' || $entry == '..') { continue; } $fileArray[] = $entry; } $d->close(); natcasesort($fileArray); foreach ($fileArray as $fileName) { if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($conf['inputValue'], $fileName)) { $out .= '<option value="' . $fileName . '" selected>' . $fileName . '</option>'; } else { $out .= '<option value="' . $fileName . '">' . $fileName . '</option>'; } } } if ($fieldSetup['type'] == 'multiple') { foreach ($fieldSetup['items'] as $key => $val) { if (substr($val[0], 0, 4) == 'LLL:') { $value = $GLOBALS['LANG']->sL($val[0]); } else { $value = $val[0]; } if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($conf['inputValue'], $val[1])) { $out .= '<option value="' . $val[1] . '" selected>' . $value . '</option>'; } else { $out .= '<option value="' . $val[1] . '">' . $value . '</option>'; } } } if ($fieldSetup['type'] == 'binary') { foreach ($fieldSetup['items'] as $key => $val) { if (substr($val[0], 0, 4) == 'LLL:') { $value = $GLOBALS['LANG']->sL($val[0]); } else { $value = $val[0]; } if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($conf['inputValue'], pow(2, $key))) { $out .= '<option value="' . pow(2, $key) . '" selected>' . $value . '</option>'; } else { $out .= '<option value="' . pow(2, $key) . '">' . $value . '</option>'; } } } if ($fieldSetup['type'] == 'relation') { if ($fieldSetup['items']) { foreach ($fieldSetup['items'] as $key => $val) { if (substr($val[0], 0, 4) == 'LLL:') { $value = $GLOBALS['LANG']->sL($val[0]); } else { $value = $val[0]; } if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($conf['inputValue'], $val[1])) { $out .= '<option value="' . $val[1] . '" selected>' . $value . '</option>'; } else { $out .= '<option value="' . $val[1] . '">' . $value . '</option>'; } } } if (stristr($fieldSetup['allowed'], ',')) { $from_table_Arr = explode(',', $fieldSetup['allowed']); $useTablePrefix = 1; if (!$fieldSetup['prepend_tname']) { $checkres = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fN, $table, \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table), $groupBy = '', $orderBy = '', $limit = ''); if ($checkres) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($checkres)) { if (stristr($row[$fN], ',')) { $checkContent = explode(',', $row[$fN]); foreach ($checkContent as $singleValue) { if (!stristr($singleValue, '_')) { $dontPrefixFirstTable = 1; } } } else { $singleValue = $row[$fN]; if (strlen($singleValue) && !stristr($singleValue, '_')) { $dontPrefixFirstTable = 1; } } } $GLOBALS['TYPO3_DB']->sql_free_result($checkres); } } } else { $from_table_Arr[0] = $fieldSetup['allowed']; } if ($fieldSetup['prepend_tname']) { $useTablePrefix = 1; } if ($fieldSetup['foreign_table']) { $from_table_Arr[0] = $fieldSetup['foreign_table']; } $counter = 0; $webMountPageTree = ''; while (list(, $from_table) = each($from_table_Arr)) { if ($useTablePrefix && !$dontPrefixFirstTable && $counter != 1 || $counter == 1) { $tablePrefix = $from_table . '_'; } $counter = 1; if (is_array($GLOBALS['TCA'][$from_table])) { \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($from_table); $labelField = $GLOBALS['TCA'][$from_table]['ctrl']['label']; $altLabelField = $GLOBALS['TCA'][$from_table]['ctrl']['label_alt']; if ($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items']) { foreach ($GLOBALS['TCA'][$from_table]['columns'][$labelField]['config']['items'] as $labelArray) { if (substr($labelArray[0], 0, 4) == 'LLL:') { $labelFieldSelect[$labelArray[1]] = $GLOBALS['LANG']->sL($labelArray[0]); } else { $labelFieldSelect[$labelArray[1]] = $labelArray[0]; } } $useSelectLabels = 1; } if ($GLOBALS['TCA'][$from_table]['columns'][$altLabelField]['config']['items']) { foreach ($GLOBALS['TCA'][$from_table]['columns'][$altLabelField]['config']['items'] as $altLabelArray) { if (substr($altLabelArray[0], 0, 4) == 'LLL:') { $altLabelFieldSelect[$altLabelArray[1]] = $GLOBALS['LANG']->sL($altLabelArray[0]); } else { $altLabelFieldSelect[$altLabelArray[1]] = $altLabelArray[0]; } } $useAltSelectLabels = 1; } $altLabelFieldSelect = $altLabelField ? ',' . $altLabelField : ''; $select_fields = 'uid,' . $labelField . $altLabelFieldSelect; if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts']) { $webMounts = $GLOBALS['BE_USER']->returnWebmounts(); $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); foreach ($webMounts as $key => $val) { if ($webMountPageTree) { $webMountPageTreePrefix = ','; } $webMountPageTree .= $webMountPageTreePrefix . $this->getTreeList($val, 999, $begin = 0, $perms_clause); } if ($from_table == 'pages') { $where_clause = 'uid IN (' . $webMountPageTree . ') '; if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted']) { $where_clause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($from_table) . ' AND' . $perms_clause; } } else { $where_clause = 'pid IN (' . $webMountPageTree . ') '; if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted']) { $where_clause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($from_table); } } } else { $where_clause = 'uid'; if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted']) { $where_clause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($from_table); } } $orderBy = 'uid'; if (!$this->tableArray[$from_table]) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy, $limit = ''); } if ($res) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->tableArray[$from_table][] = $row; } $GLOBALS['TYPO3_DB']->sql_free_result($res); } foreach ($this->tableArray[$from_table] as $key => $val) { if ($useSelectLabels) { $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($labelFieldSelect[$val[$labelField]]); } elseif ($val[$labelField]) { $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($val[$labelField]); } elseif ($useAltSelectLabels) { $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($altLabelFieldSelect[$val[$altLabelField]]); } else { $outArray[$tablePrefix . $val['uid']] = htmlspecialchars($val[$altLabelField]); } } if ($GLOBALS['SOBE']->MOD_SETTINGS['options_sortlabel'] && is_array($outArray)) { natcasesort($outArray); } } } foreach ($outArray as $key2 => $val2) { if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($conf['inputValue'], $key2)) { $out .= '<option value="' . $key2 . '" selected>[' . $key2 . '] ' . $val2 . '</option>'; } else { $out .= '<option value="' . $key2 . '">[' . $key2 . '] ' . $val2 . '</option>'; } } } return $out; }