2 namespace TYPO3\CMS\Backend\Utility;
28 use TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException;
84 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'delete']) {
85 return ' AND ' . ($tableAlias ?: $table) .
'.' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'delete'] .
'=0';
105 public static function getRecord($table, $uid, $fields =
'*', $where =
'', $useDeleteClause =
true)
108 if ((
int)$uid && !empty(
$GLOBALS[
'TCA'][$table])) {
109 $where =
'uid=' . (int)$uid . ($useDeleteClause ? self::deleteClause($table) :
'') . $where;
110 $row = static::getDatabaseConnection()->exec_SELECTgetSingleRow($fields, $table, $where);
129 public static function getRecordWSOL($table, $uid, $fields =
'*', $where =
'', $useDeleteClause =
true, $unsetMovePointers =
false)
131 if ($fields !==
'*') {
133 $row = self::getRecord($table, $uid, $internalFields, $where, $useDeleteClause);
134 self::workspaceOL($table, $row, -99, $unsetMovePointers);
135 if (is_array($row)) {
136 foreach ($row as $key => $_) {
143 $row = self::getRecord($table, $uid, $fields, $where, $useDeleteClause);
144 self::workspaceOL($table, $row, -99, $unsetMovePointers);
161 public static function getRecordRaw($table, $where =
'', $fields =
'*')
164 $db = static::getDatabaseConnection();
165 if (
false !== ($res = $db->exec_SELECTquery($fields, $table, $where,
'',
'',
'1'))) {
166 $row = $db->sql_fetch_assoc($res);
167 $db->sql_free_result($res);
187 public static function getRecordsByField($theTable, $theField, $theValue, $whereClause =
'', $groupBy =
'', $orderBy =
'', $limit =
'', $useDeleteClause =
true)
189 if (is_array(
$GLOBALS[
'TCA'][$theTable])) {
190 $db = static::getDatabaseConnection();
191 $res = $db->exec_SELECTquery(
194 $theField .
'=' . $db->fullQuoteStr($theValue, $theTable) .
195 ($useDeleteClause ? self::deleteClause($theTable) .
' ' :
'') .
196 self::versioningPlaceholderClause($theTable) .
' ' .
203 while ($row = $db->sql_fetch_assoc($res)) {
206 $db->sql_free_result($res);
223 list($uid, $table) = explode(
'_', strrev($str), 2);
224 return array(strrev($table), strrev($uid));
239 if ((
string)trim($in_list) !=
'') {
240 $tempItemArray = explode(
',', trim($in_list));
241 foreach ($tempItemArray as $key => $val) {
243 $parts = explode(
'_', $val, 2);
244 if ((
string)trim($parts[0]) !=
'') {
245 $theID = (int)strrev($parts[0]);
246 $theTable = trim($parts[1]) ? strrev(trim($parts[1])) : $default_tablename;
247 if ($theTable == $tablename) {
253 return implode(
',',
$list);
268 $ctrl =
$GLOBALS[
'TCA'][$table][
'ctrl'];
271 if (is_array($ctrl)) {
272 if (is_array($ctrl[
'enablecolumns'])) {
273 if ($ctrl[
'enablecolumns'][
'disabled']) {
274 $field = $table .
'.' . $ctrl[
'enablecolumns'][
'disabled'];
275 $query[] = $field .
'=0';
276 $invQuery[] = $field .
'<>0';
278 if ($ctrl[
'enablecolumns'][
'starttime']) {
279 $field = $table .
'.' . $ctrl[
'enablecolumns'][
'starttime'];
280 $query[] =
'(' . $field .
'<=' .
$GLOBALS[
'SIM_ACCESS_TIME'] .
')';
281 $invQuery[] =
'(' . $field .
'<>0 AND ' . $field .
'>' .
$GLOBALS[
'SIM_ACCESS_TIME'] .
')';
283 if ($ctrl[
'enablecolumns'][
'endtime']) {
284 $field = $table .
'.' . $ctrl[
'enablecolumns'][
'endtime'];
285 $query[] =
'(' . $field .
'=0 OR ' . $field .
'>' .
$GLOBALS[
'SIM_ACCESS_TIME'] .
')';
286 $invQuery[] =
'(' . $field .
'<>0 AND ' . $field .
'<=' .
$GLOBALS[
'SIM_ACCESS_TIME'] .
')';
290 $outQ = $inv ?
'(' . implode(
' OR ', $invQuery) .
')' : implode(
' AND ', $query);
291 return $outQ ?
' AND ' . $outQ :
'';
305 $recordLocalization =
false;
308 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable'])) {
309 $table =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable'];
312 if (self::isTableLocalizable($table)) {
313 $tcaCtrl =
$GLOBALS[
'TCA'][$table][
'ctrl'];
314 $recordLocalization = self::getRecordsByField($table, $tcaCtrl[
'transOrigPointerField'], $uid,
'AND ' . $tcaCtrl[
'languageField'] .
'=' . (
int)$language . ($andWhereClause ?
' ' . $andWhereClause :
''),
'',
'',
'1');
316 return $recordLocalization;
334 public static function BEgetRootLine($uid, $clause =
'', $workspaceOL =
false)
336 static $BEgetRootLine_cache = array();
339 $ident = $pid .
'-' . $clause .
'-' . $workspaceOL;
340 if (is_array($BEgetRootLine_cache[$ident])) {
341 $output = $BEgetRootLine_cache[$ident];
344 $theRowArray = array();
345 while ($uid != 0 && $loopCheck) {
347 $row = self::getPageForRootline($uid, $clause, $workspaceOL);
348 if (is_array($row)) {
350 $theRowArray[] = $row;
356 $theRowArray[] = array(
'uid' => 0,
'title' =>
'');
358 $c = count($theRowArray);
359 foreach ($theRowArray as $val) {
362 'uid' => $val[
'uid'],
363 'pid' => $val[
'pid'],
364 'title' => $val[
'title'],
365 'doktype' => $val[
'doktype'],
366 'tsconfig_includes' => $val[
'tsconfig_includes'],
367 'TSconfig' => $val[
'TSconfig'],
368 'is_siteroot' => $val[
'is_siteroot'],
369 't3ver_oid' => $val[
't3ver_oid'],
370 't3ver_wsid' => $val[
't3ver_wsid'],
371 't3ver_state' => $val[
't3ver_state'],
372 't3ver_stage' => $val[
't3ver_stage'],
373 'backend_layout_next_level' => $val[
'backend_layout_next_level']
375 if (isset($val[
'_ORIG_pid'])) {
376 $output[$c][
'_ORIG_pid'] = $val[
'_ORIG_pid'];
379 $BEgetRootLine_cache[$ident] = $output;
395 static $getPageForRootline_cache = array();
396 $ident = $uid .
'-' . $clause .
'-' . $workspaceOL;
397 if (is_array($getPageForRootline_cache[$ident])) {
398 $row = $getPageForRootline_cache[$ident];
400 $db = static::getDatabaseConnection();
401 $res = $db->exec_SELECTquery(
'pid,uid,title,doktype,tsconfig_includes,TSconfig,is_siteroot,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_stage,backend_layout_next_level',
'pages',
'uid=' . (
int)$uid .
' ' . self::deleteClause(
'pages') .
' ' . $clause);
402 $row = $db->sql_fetch_assoc($res);
404 $newLocation =
false;
406 self::workspaceOL(
'pages', $row);
407 $newLocation = self::getMovePlaceholder(
'pages', $row[
'uid'],
'pid');
409 if (is_array($row)) {
410 if ($newLocation !==
false) {
411 $row[
'pid'] = $newLocation[
'pid'];
413 self::fixVersioningPid(
'pages', $row);
415 $getPageForRootline_cache[$ident] = $row;
418 $db->sql_free_result($res);
432 $beUser = static::getBackendUserAuthentication();
434 if ($clearExpansion) {
435 $expandedPages = array();
437 $expandedPages = unserialize($beUser->uc[
'browseTrees'][
'browsePages']);
440 $rL = self::BEgetRootLine($pid);
443 $mountKeys = array_flip($beUser->returnWebmounts());
444 foreach ($rL as $rLDat) {
445 if (isset($mountKeys[$rLDat[
'uid']])) {
446 $mountIndex = $mountKeys[$rLDat[
'uid']];
451 foreach ($rL as $rLDat) {
452 $expandedPages[$mountIndex][$rLDat[
'uid']] = 1;
455 $beUser->uc[
'browseTrees'][
'browsePages'] = serialize($expandedPages);
470 public static function getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit = 0)
475 $output = $fullOutput =
'/';
476 $clause = trim($clause);
477 if ($clause !==
'' && substr($clause, 0, 3) !==
'AND') {
478 $clause =
'AND ' . $clause;
480 $data = self::BEgetRootLine($uid, $clause);
481 foreach ($data as $record) {
482 if ($record[
'uid'] === 0) {
486 if ($fullTitleLimit) {
490 if ($fullTitleLimit) {
491 return array($output, $fullOutput);
507 $finalExcludeArray = array();
510 $tableToTranslation = array();
511 $lang = static::getLanguageService();
513 foreach (
$GLOBALS[
'TCA'] as $table => $conf) {
514 $tableToTranslation[$table] =
$lang->sl($conf[
'ctrl'][
'title']);
517 asort($tableToTranslation);
518 foreach ($tableToTranslation as $table => $translatedTable) {
519 $excludeArrayTable = array();
522 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'])
523 && empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'adminOnly'])
524 && (empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'rootLevel']) || !empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'security'][
'ignoreRootLevelRestriction']))
526 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $_) {
527 if (
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'exclude']) {
529 $translatedField =
$lang->sl(
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'label']);
531 $excludeArrayTable[] = array($translatedTable .
': ' . $translatedField, $table .
':' . $field);
536 $flexFormArray = static::getRegisteredFlexForms($table);
537 foreach ($flexFormArray as $tableField => $flexForms) {
540 if (!empty(
$GLOBALS[
'TCA'][$table][
'columns'][$tableField][
'label'])) {
541 $labelPrefix =
$lang->sl(
$GLOBALS[
'TCA'][$table][
'columns'][$tableField][
'label']);
544 foreach ($flexForms as $extIdent =>
$extConf) {
547 foreach (
$extConf[
'ds'][
'sheets'] as $sheetName => $sheet) {
548 if (empty($sheet[
'ROOT'][
'el']) || !is_array($sheet[
'ROOT'][
'el'])) {
551 foreach ($sheet[
'ROOT'][
'el'] as $fieldName => $field) {
553 if (empty($field[
'TCEforms'][
'exclude'])) {
556 $fieldLabel = !empty($field[
'TCEforms'][
'label']) ?
$lang->sl($field[
'TCEforms'][
'label']) : $fieldName;
557 $fieldIdent = $table .
':' . $tableField .
';' . $extIdent .
';' . $sheetName .
';' . $fieldName;
558 $excludeArrayTable[] = array(trim($labelPrefix .
' ' . $extTitle,
': ') .
': ' . $fieldLabel, $fieldIdent);
564 if (!empty($excludeArrayTable)) {
565 usort($excludeArrayTable,
function (array $array1, array $array2) {
566 $array1 = reset($array1);
567 $array2 = reset($array2);
568 if (is_string($array1) && is_string($array2)) {
569 return strcasecmp($array1, $array2);
573 $finalExcludeArray = array_merge($finalExcludeArray, $excludeArrayTable);
577 return $finalExcludeArray;
591 $lang = static::getLanguageService();
593 'ALLOW' =>
$lang->sl(
'LLL:EXT:lang/locallang_core.xlf:labels.allow'),
594 'DENY' =>
$lang->sl(
'LLL:EXT:lang/locallang_core.xlf:labels.deny')
597 $allowDenyOptions = array();
598 foreach (
$GLOBALS[
'TCA'] as $table => $_) {
600 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'])) {
601 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $field => $_) {
602 $fCfg =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
603 if ($fCfg[
'type'] ==
'select' && $fCfg[
'authMode']) {
605 if (is_array($fCfg[
'items'])) {
607 $allowDenyOptions[$table .
':' . $field][
'tableFieldLabel'] =
609 .
$lang->sl(
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'label']);
611 foreach ($fCfg[
'items'] as $iVal) {
613 if ((
string)$iVal[1] !==
'') {
616 switch ((
string)$fCfg[
'authMode']) {
617 case 'explicitAllow':
624 if ($iVal[4] ===
'EXPL_ALLOW') {
626 }
elseif ($iVal[4] ===
'EXPL_DENY') {
633 $allowDenyOptions[$table .
':' . $field][
'items'][$iVal[1]] = array($iMode,
$lang->sl($iVal[0]), $adLabel[$iMode]);
642 return $allowDenyOptions;
655 public static function getSystemLanguages()
659 $translationConfigurationProvider =
GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider::class);
660 $languages = $translationConfigurationProvider->getSystemLanguages();
661 $sysLanguages = array();
662 foreach ($languages as $language) {
663 if ($language[
'uid'] !== -1) {
664 $sysLanguages[] = array(
665 0 => htmlspecialchars($language[
'title']) .
' [' . $language[
'uid'] .
']',
666 1 => $language[
'uid'],
667 2 => $language[
'flagIcon']
671 return $sysLanguages;
683 if (!empty(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'])) {
684 $table =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable'];
698 $isLocalizable =
false;
699 if (isset(
$GLOBALS[
'TCA'][$table][
'ctrl']) && is_array(
$GLOBALS[
'TCA'][$table][
'ctrl'])) {
700 $tcaCtrl =
$GLOBALS[
'TCA'][$table][
'ctrl'];
701 $isLocalizable = isset($tcaCtrl[
'languageField']) && $tcaCtrl[
'languageField'] && isset($tcaCtrl[
'transOrigPointerField']) && $tcaCtrl[
'transOrigPointerField'];
703 return $isLocalizable;
717 $localizationMode =
false;
719 if (is_array($fieldOrConfig) && !empty($fieldOrConfig)) {
720 $config = $fieldOrConfig;
721 }
elseif (is_string($fieldOrConfig) && isset(
$GLOBALS[
'TCA'][$table][
'columns'][$fieldOrConfig][
'config'])) {
722 $config =
$GLOBALS[
'TCA'][$table][
'columns'][$fieldOrConfig][
'config'];
724 if (is_array($config) && isset($config[
'type']) && $config[
'type'] ===
'inline' && self::isTableLocalizable($table)) {
725 $localizationMode = isset($config[
'behaviour'][
'localizationMode']) && $config[
'behaviour'][
'localizationMode']
726 ? $config[
'behaviour'][
'localizationMode']
729 if ($localizationMode ===
'select' && !self::isTableLocalizable($config[
'foreign_table'])) {
730 $localizationMode =
false;
733 return $localizationMode;
747 if ((
string)$id !==
'') {
750 if (static::getBackendUserAuthentication()->isAdmin()) {
752 $pageinfo[
'_thePath'] = $path;
756 $pageinfo = self::getRecord(
'pages', $id,
'*', $perms_clause ?
' AND ' . $perms_clause :
'');
757 if ($pageinfo[
'uid'] && static::getBackendUserAuthentication()->isInWebMount($id, $perms_clause)) {
758 self::workspaceOL(
'pages', $pageinfo);
759 if (is_array($pageinfo)) {
760 self::fixVersioningPid(
'pages', $pageinfo);
761 list($pageinfo[
'_thePath'], $pageinfo[
'_thePathFull']) = self::getRecordPath((
int)$pageinfo[
'uid'], $perms_clause, 15, 1000);
778 public static function getTCAtypes($table, $rec, $useFieldNameAsKey =
false)
782 $fieldValue = self::getTCAtypeValue($table, $rec);
783 $cacheIdentifier = $table .
'-type-' . $fieldValue .
'-fnk-' . $useFieldNameAsKey;
786 if (isset(self::$tcaTableTypeConfigurationCache[$cacheIdentifier])) {
787 return self::$tcaTableTypeConfigurationCache[$cacheIdentifier];
791 $typesConf =
$GLOBALS[
'TCA'][$table][
'types'][$fieldValue];
793 $fieldList = explode(
',', $typesConf[
'showitem']);
797 if (isset($typesConf[
'subtype_value_field'])) {
798 $subType = $rec[$typesConf[
'subtype_value_field']];
799 if (isset($typesConf[
'subtypes_addlist'][$subType])) {
801 $fieldList = array_merge($fieldList, $subFields);
805 $altFieldList = array();
807 foreach ($fieldList as $k => $v) {
810 if (!empty($typesConf[
'columnsOverrides'][$pFieldName][
'defaultExtras'])) {
812 $defaultExtras = $typesConf[
'columnsOverrides'][$pFieldName][
'defaultExtras'];
813 }
elseif (!empty(
$GLOBALS[
'TCA'][$table][
'columns'][$pFieldName][
'defaultExtras'])) {
815 $defaultExtras =
$GLOBALS[
'TCA'][$table][
'columns'][$pFieldName][
'defaultExtras'];
817 $specConfParts = self::getSpecConfParts($defaultExtras);
818 $fieldList[$k] = array(
819 'field' => $pFieldName,
820 'title' => $pAltTitle,
821 'palette' => $pPalette,
822 'spec' => $specConfParts,
825 if ($useFieldNameAsKey) {
826 $altFieldList[$fieldList[$k][
'field']] = $fieldList[$k];
829 if ($useFieldNameAsKey) {
830 $fieldList = $altFieldList;
834 self::$tcaTableTypeConfigurationCache[$cacheIdentifier] = $fieldList;
863 $field =
$GLOBALS[
'TCA'][$table][
'ctrl'][
'type'];
864 if (strpos($field,
':') !==
false) {
865 list($pointerField, $foreignTableTypeField) = explode(
':', $field);
867 if (!isset($row[$pointerField])) {
868 $localRow = self::getRecord($table, $row[
'uid'], $pointerField);
869 $foreignUid = $localRow[$pointerField];
871 $foreignUid = $row[$pointerField];
874 $fieldConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$pointerField][
'config'];
875 $relationType = $fieldConfig[
'type'];
876 if ($relationType ===
'select') {
877 $foreignTable = $fieldConfig[
'foreign_table'];
878 }
elseif ($relationType ===
'group') {
879 $allowedTables = explode(
',', $fieldConfig[
'allowed']);
880 $foreignTable = $allowedTables[0];
882 throw new \RuntimeException(
'TCA foreign field pointer fields are only allowed to be used with group or select field types.', 1325862240);
884 $foreignRow = self::getRecord($foreignTable, $foreignUid, $foreignTableTypeField);
885 if ($foreignRow[$foreignTableTypeField]) {
886 $typeNum = $foreignRow[$foreignTableTypeField];
890 $typeNum = $row[$field];
893 if (empty($typeNum)) {
898 if (!
$GLOBALS[
'TCA'][$table][
'types'][$typeNum]) {
899 $typeNum =
$GLOBALS[
'TCA'][$table][
'types'][
'0'] ? 0 : 1;
902 $typeNum = (string)$typeNum;
921 $defaultExtrasString = $_ .
':' . $defaultExtrasString;
925 if (!empty($specConfParts)) {
926 foreach ($specConfParts as $k2 => $v2) {
927 unset($specConfParts[$k2]);
928 if (preg_match(
'/(.*)\\[(.*)\\]/', $v2, $reg)) {
929 $specConfParts[trim($reg[1])] = array(
933 $specConfParts[trim($v2)] = 1;
937 $specConfParts = array();
939 return $specConfParts;
952 if (is_array($pArr)) {
953 foreach ($pArr as $k => $v) {
954 $parts = explode(
'=', $v, 2);
955 if (count($parts) === 2) {
956 $out[trim($parts[0])] = trim($parts[1]);
993 public static function getFlexFormDS($conf, $row, $table, $fieldName =
'', $WSOL =
true, $newRecordPidValue = 0)
996 $ds_pointerField = $conf[
'ds_pointerField'];
997 $ds_array = $conf[
'ds'];
998 $ds_tableField = $conf[
'ds_tableField'];
999 $ds_searchParentField = $conf[
'ds_pointerField_searchParent'];
1001 if (is_array($ds_array)) {
1003 if ($ds_pointerField) {
1007 if (count($pointerFields) === 2) {
1008 if ($ds_array[$row[$pointerFields[0]] .
',' . $row[$pointerFields[1]]]) {
1010 $srcPointer = $row[$pointerFields[0]] .
',' . $row[$pointerFields[1]];
1011 }
elseif ($ds_array[$row[$pointerFields[1]] .
',*']) {
1013 $srcPointer = $row[$pointerFields[1]] .
',*';
1014 }
elseif ($ds_array[
'*,' . $row[$pointerFields[1]]]) {
1016 $srcPointer =
'*,' . $row[$pointerFields[1]];
1017 }
elseif ($ds_array[$row[$pointerFields[0]]]) {
1019 $srcPointer = $row[$pointerFields[0]];
1024 $srcPointer = $row[$pointerFields[0]];
1026 $srcPointer = $srcPointer !== null && isset($ds_array[$srcPointer]) ? $srcPointer :
'default';
1028 $srcPointer =
'default';
1031 if (substr($ds_array[$srcPointer], 0, 5) ==
'FILE:') {
1033 if ($file && @is_file($file)) {
1036 $dataStructArray =
'The file "' . substr($ds_array[$srcPointer], 5) .
'" in ds-array key "' . $srcPointer .
'" was not found ("' . $file .
'")';
1041 }
elseif ($ds_pointerField) {
1044 $srcPointer = $row[$ds_pointerField];
1046 if ($ds_searchParentField && !$srcPointer) {
1047 $rr = self::getRecord($table, $row[
'uid'],
'uid,' . $ds_searchParentField);
1050 self::workspaceOL($table, $rr);
1051 self::fixVersioningPid($table, $rr,
true);
1053 $db = static::getDatabaseConnection();
1056 $subFieldPointer = $conf[
'ds_pointerField_searchParent_subField'];
1057 while (!$srcPointer) {
1058 $res = $db->exec_SELECTquery(
'uid,' . $ds_pointerField .
',' . $ds_searchParentField . ($subFieldPointer ?
',' . $subFieldPointer :
''), $table,
'uid=' . (
int)($newRecordPidValue ?: $rr[$ds_searchParentField]) . self::deleteClause($table));
1059 $newRecordPidValue = 0;
1060 $rr = $db->sql_fetch_assoc($res);
1061 $db->sql_free_result($res);
1063 if (!is_array($rr) || isset($uidAcc[$rr[
'uid']])) {
1066 $uidAcc[$rr[
'uid']] = 1;
1068 self::workspaceOL($table, $rr);
1069 self::fixVersioningPid($table, $rr,
true);
1071 $srcPointer = $subFieldPointer && $rr[$subFieldPointer] ? $rr[$subFieldPointer] : $rr[$ds_pointerField];
1078 list($tName, $fName) = explode(
':', $ds_tableField, 2);
1079 if ($tName && $fName && is_array(
$GLOBALS[
'TCA'][$tName])) {
1080 $dataStructRec = self::getRecord($tName, $srcPointer);
1082 self::workspaceOL($tName, $dataStructRec);
1084 if (strpos($dataStructRec[$fName],
'<') ===
false) {
1085 if (is_file(PATH_site . $dataStructRec[$fName])) {
1089 $dataStructArray = sprintf(
'File \'%s\' was not found', $dataStructRec[$fName]);
1096 $dataStructArray =
'No tablename (' . $tName .
') or fieldname (' . $fName .
') was found an valid!';
1101 if ($file && @is_file($file)) {
1105 $dataStructArray =
'The file "' . $srcPointer .
'" was not found ("' . $file .
'")';
1110 $dataStructArray =
'No source value in fieldname "' . $ds_pointerField .
'"';
1113 $dataStructArray =
'No proper configuration!';
1116 if (is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'getFlexFormDSClass'])) {
1117 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'getFlexFormDSClass'] as $classRef) {
1119 if (method_exists($hookObj,
'getFlexFormDS_postProcessDS')) {
1120 $hookObj->getFlexFormDS_postProcessDS($dataStructArray, $conf, $row, $table, $fieldName);
1124 return $dataStructArray;
1138 if (empty($table) || empty(
$GLOBALS[
'TCA'][$table][
'columns'])) {
1141 $flexForms = array();
1142 foreach (
$GLOBALS[
'TCA'][$table][
'columns'] as $tableField => $fieldConf) {
1143 if (!empty($fieldConf[
'config'][
'type']) && !empty($fieldConf[
'config'][
'ds']) && $fieldConf[
'config'][
'type'] ==
'flex') {
1144 $flexForms[$tableField] = array();
1145 unset($fieldConf[
'config'][
'ds'][
'default']);
1147 $pointerFields = !empty($fieldConf[
'config'][
'ds_pointerField']) ? $fieldConf[
'config'][
'ds_pointerField'] :
'list_type,CType';
1150 foreach ($fieldConf[
'config'][
'ds'] as $flexFormKey => $dataStruct) {
1153 $extIdent = $identFields[0];
1154 if (!empty($identFields[1]) && $identFields[1] !=
'list' && $identFields[1] !=
'*') {
1155 $extIdent = $identFields[1];
1158 if (!is_array($dataStruct)) {
1160 if ($file && @is_file($file)) {
1164 if (!is_array($dataStruct)) {
1170 if (empty($dataStruct[
'sheets']) || !is_array($dataStruct[
'sheets'])) {
1176 foreach ($pointerFields as $pointerKey => $pointerName) {
1177 if (empty($keyFields[$pointerKey]) || $keyFields[$pointerKey] ==
'*' || $keyFields[$pointerKey] ==
'list') {
1180 if (!empty(
$GLOBALS[
'TCA'][$table][
'columns'][$pointerName][
'config'][
'items'])) {
1181 $items =
$GLOBALS[
'TCA'][$table][
'columns'][$pointerName][
'config'][
'items'];
1182 if (!is_array($items)) {
1185 foreach ($items as $itemConf) {
1186 if (!empty($itemConf[0]) && !empty($itemConf[1]) && $itemConf[1] == $keyFields[$pointerKey]) {
1187 $title = $itemConf[0];
1193 $flexForms[$tableField][$extIdent] = array(
1219 public static function storeHash($hash, $data, $ident)
1223 $cacheManager->getCache(
'cache_hash')->set($hash, $data, array(
'ident_' . $ident), 0);
1235 public static function getHash($hash)
1239 $cacheEntry = $cacheManager->getCache(
'cache_hash')->get($hash);
1240 $hashContent = null;
1242 $hashContent = $cacheEntry;
1244 return $hashContent;
1263 static $pagesTSconfig_cacheReference = array();
1264 static $combinedTSconfig_cache = array();
1267 if ($returnPartArray ===
false
1268 && $rootLine === null
1269 && isset($pagesTSconfig_cacheReference[$id])
1271 return $combinedTSconfig_cache[$pagesTSconfig_cacheReference[$id]];
1273 $TSconfig = array();
1274 if (!is_array($rootLine)) {
1275 $useCacheForCurrentPageId =
true;
1276 $rootLine = self::BEgetRootLine($id,
'',
true);
1278 $useCacheForCurrentPageId =
false;
1283 $TSdataArray = array();
1285 $TSdataArray[
'defaultPageTSconfig'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'defaultPageTSconfig'];
1286 foreach ($rootLine as $k => $v) {
1287 if (trim($v[
'tsconfig_includes'])) {
1290 foreach ($includeTsConfigFileList as $key => $includeTsConfigFile) {
1292 list($includeTsConfigFileExtensionKey, $includeTsConfigFilename) = explode(
1294 substr($includeTsConfigFile, 4),
1298 (
string)$includeTsConfigFileExtensionKey !==
''
1300 && (
string)$includeTsConfigFilename !==
''
1303 $includeTsConfigFilename;
1304 if (file_exists($includeTsConfigFileAndPath)) {
1305 $TSdataArray[
'uid_' . $v[
'uid'] .
'_static_' . $key] =
GeneralUtility::getUrl($includeTsConfigFileAndPath);
1311 $TSdataArray[
'uid_' . $v[
'uid']] = $v[
'TSconfig'];
1313 $TSdataArray = static::emitGetPagesTSconfigPreIncludeSignal($TSdataArray, $id, $rootLine, $returnPartArray);
1315 if ($returnPartArray) {
1316 return $TSdataArray;
1319 $pageTS = implode(LF .
'[GLOBAL]' . LF, $TSdataArray);
1322 $res = $parseObj->parseTSconfig($pageTS,
'PAGES', $id, $rootLine);
1324 $TSconfig = $res[
'TSconfig'];
1326 $cacheHash = $res[
'hash'];
1328 $userTSconfig = static::getBackendUserAuthentication()->userTS[
'page.'];
1329 if (is_array($userTSconfig)) {
1331 $cacheHash .=
'_user' .
$GLOBALS[
'BE_USER']->user[
'uid'];
1334 if ($useCacheForCurrentPageId) {
1335 if (!isset($combinedTSconfig_cache[$cacheHash])) {
1336 $combinedTSconfig_cache[$cacheHash] = $TSconfig;
1338 $pagesTSconfig_cacheReference[$id] = $cacheHash;
1355 $implodeParams = array();
1357 foreach ($p as $kb => $val) {
1358 if (is_array($val)) {
1359 $implodeParams = array_merge($implodeParams, self::implodeTSParams($val, $k . $kb));
1361 $implodeParams[$k . $kb] = $val;
1365 return $implodeParams;
1381 public static function getUserNames($fields =
'username,usergroup,usergroup_cached_list,uid', $where =
'')
1383 return self::getRecordsSortedByTitle(
1387 'AND pid=0 ' . $where
1400 return self::getRecordsSortedByTitle(
1404 'AND pid=0 ' . $where
1421 $fieldsIndex = array_flip($fields);
1423 $fieldsIndex[$titleField] = 1;
1426 $db = static::getDatabaseConnection();
1427 $res = $db->exec_SELECTquery(
'*', $table,
'1=1 ' . $where . self::deleteClause($table));
1428 while ($record = $db->sql_fetch_assoc($res)) {
1430 $recordId = $record[
'uid'];
1431 $record[$titleField] = self::getRecordTitle($table, $record);
1434 $result[$recordId] = array_intersect_key($record, $fieldsIndex);
1436 $db->sql_free_result($res);
1452 $beUser = static::getBackendUserAuthentication();
1453 $exQ =
' AND hide_in_lists=0';
1454 if (!$beUser->isAdmin()) {
1455 $exQ .=
' AND uid IN (' . ($beUser->user[
'usergroup_cached_list'] ?: 0) .
')';
1457 return self::getGroupNames($fields, $exQ);
1470 public static function blindUserNames($usernames, $groupArray, $excludeBlindedFlag =
false)
1472 if (is_array($usernames) && is_array($groupArray)) {
1473 foreach ($usernames as $uid => $row) {
1476 if ($row[
'uid'] != static::getBackendUserAuthentication()->user[
'uid']) {
1477 foreach ($groupArray as $v) {
1479 $userN = $row[
'username'];
1484 $userN = $row[
'username'];
1487 $usernames[$uid][
'username'] = $userN;
1488 if ($excludeBlindedFlag && !$set) {
1489 unset($usernames[$uid]);
1506 if (is_array($groups) && is_array($groupArray)) {
1507 foreach ($groups as $uid => $row) {
1511 $groupN = $row[
'title'];
1514 $groups[$uid][
'title'] = $groupN;
1515 if ($excludeBlindedFlag && !$set) {
1516 unset($groups[$uid]);
1536 $delta_t = $tstamp -
$GLOBALS[
'EXEC_TIME'];
1537 return ceil($delta_t / (3600 * 24));
1546 public static function date($tstamp)
1548 return date(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'], (
int)$tstamp);
1559 return date(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'ddmmyy'] .
' ' .
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'hhmm'], $value);
1570 public static function time($value, $withSeconds =
true)
1572 $hh = floor($value / 3600);
1573 $min = floor(($value - $hh * 3600) / 60);
1574 $sec = $value - $hh * 3600 - $min * 60;
1575 $l = sprintf(
'%02d', $hh) .
':' . sprintf(
'%02d', $min);
1577 $l .=
':' . sprintf(
'%02d', $sec);
1589 public static function calcAge($seconds, $labels =
' min| hrs| days| yrs| min| hour| day| year')
1591 $labelArr = explode(
'|', $labels);
1592 $absSeconds = abs($seconds);
1593 $sign = $seconds < 0 ? -1 : 1;
1594 if ($absSeconds < 3600) {
1595 $val = round($absSeconds / 60);
1596 $seconds = $sign * $val . ($val == 1 ? $labelArr[4] : $labelArr[0]);
1597 }
elseif ($absSeconds < 24 * 3600) {
1598 $val = round($absSeconds / 3600);
1599 $seconds = $sign * $val . ($val == 1 ? $labelArr[5] : $labelArr[1]);
1600 }
elseif ($absSeconds < 365 * 24 * 3600) {
1601 $val = round($absSeconds / (24 * 3600));
1602 $seconds = $sign * $val . ($val == 1 ? $labelArr[6] : $labelArr[2]);
1604 $val = round($absSeconds / (365 * 24 * 3600));
1605 $seconds = $sign * $val . ($val == 1 ? $labelArr[7] : $labelArr[3]);
1624 $label = static::getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
1625 $age =
' (' . self::calcAge($prefix * (
$GLOBALS[
'EXEC_TIME'] - $tstamp), $label) .
')';
1626 return $date ===
'date' ? self::date($tstamp) : self::datetime($tstamp) . $age;
1638 $out .=
' alt="' . htmlspecialchars($content) .
'"';
1639 $out .=
' title="' . htmlspecialchars($content) .
'"';
1652 public static function resolveFileReferences($tableName, $fieldName, $element, $workspaceId = null)
1654 if (empty(
$GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName][
'config'])) {
1657 $configuration =
$GLOBALS[
'TCA'][$tableName][
'columns'][$fieldName][
'config'];
1658 if (empty($configuration[
'type']) || $configuration[
'type'] !==
'inline'
1659 || empty($configuration[
'foreign_table']) || $configuration[
'foreign_table'] !==
'sys_file_reference') {
1663 $fileReferences = array();
1666 if ($workspaceId !== null) {
1667 $relationHandler->setWorkspaceId($workspaceId);
1669 $relationHandler->start($element[$fieldName], $configuration[
'foreign_table'], $configuration[
'MM'], $element[
'uid'], $tableName, $configuration);
1670 $relationHandler->processDeletePlaceholder();
1671 $referenceUids = $relationHandler->tableArray[$configuration[
'foreign_table']];
1673 foreach ($referenceUids as $referenceUid) {
1676 $fileReferences[$fileReference->getUid()] = $fileReference;
1677 }
catch (\TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException $e) {
1682 }
catch (\InvalidArgumentException $e) {
1687 $logMessage = $e->getMessage() .
' (table: "' . $tableName .
'", fieldName: "' . $fieldName .
'", referenceUid: ' . $referenceUid .
')';
1692 return $fileReferences;
1712 public static function thumbCode($row, $table, $field, $backPath =
'', $thumbScript =
'', $uploaddir = null, $abs = 0, $tparams =
'', $size =
'', $linkInfoPopup =
true)
1715 $size = trim($size);
1716 $sizeParts = array(64, 64);
1718 $sizeParts = explode(
'x', $size .
'x' . $size);
1721 $fileReferences = static::resolveFileReferences($table, $field, $row);
1724 if ($fileReferences !== null) {
1725 foreach ($fileReferences as $fileReferenceObject) {
1726 $fileObject = $fileReferenceObject->getOriginalFile();
1728 if ($fileObject->isMissing()) {
1729 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
1730 $thumbData .= $flashMessage->render();
1737 'width' => $sizeParts[0],
1738 'height' => $sizeParts[1] .
'c',
1739 'crop' => $fileReferenceObject->getProperty(
'crop')
1741 $imageUrl = $processedImage->getPublicUrl(
true);
1742 $imgTag =
'<img src="' . $imageUrl .
'" ' .
1743 'width="' . $processedImage->getProperty(
'width') .
'" ' .
1744 'height="' . $processedImage->getProperty(
'height') .
'" ' .
1745 'alt="' . htmlspecialchars($fileReferenceObject->getName()) .
'" />';
1748 $imgTag =
'<span title="' . htmlspecialchars($fileObject->getName()) .
'">' . $iconFactory->getIconForResource($fileObject,
Icon::SIZE_SMALL)->render() .
'</span>';
1750 if ($linkInfoPopup) {
1751 $onClick =
'top.launchView(\'_FILE\',\'' . (int)$fileObject->getUid() .
'\',
' . GeneralUtility::quoteJSvalue($backPath) . ');
return false;
';
1752 $thumbData .= '<a href=
"#" onclick=
"' . htmlspecialchars($onClick) . '">
' . $imgTag . '</a>
';
1754 $thumbData .= $imgTag;
1758 // Find uploaddir automatically
1759 if (is_null($uploaddir)) {
1760 $uploaddir = $GLOBALS['TCA
'][$table]['columns
'][$field]['config
']['uploadfolder
'];
1762 $uploaddir = rtrim($uploaddir, '/
');
1764 $thumbs = GeneralUtility::trimExplode(',
', $row[$field], true);
1766 foreach ($thumbs as $theFile) {
1768 $fileName = trim($uploaddir . '/
' . $theFile, '/
');
1771 $fileObject = ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileName);
1772 if ($fileObject->isMissing()) {
1773 $flashMessage = \TYPO3\CMS\Core\Resource\Utility\BackendUtility::getFlashMessageForMissingFile($fileObject);
1774 $thumbData .= $flashMessage->render();
1777 } catch (ResourceDoesNotExistException $exception) {
1779 $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class,
1780 htmlspecialchars($exception->getMessage()),
1781 static::getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:warning.file_missing
', true),
1784 $thumbData .= $flashMessage->render();
1788 $fileExtension = $fileObject->getExtension();
1789 if ($fileExtension == 'ttf
' || GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS
']['GFX
']['imagefile_ext
'], $fileExtension)) {
1790 $imageUrl = $fileObject->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, array(
1791 'width
' => $sizeParts[0],
1792 'height
' => $sizeParts[1]
1793 ))->getPublicUrl(true);
1794 $image = '<img src=
"' . htmlspecialchars($imageUrl) . '" hspace=
"2" border=
"0" title=
"' . htmlspecialchars($fileObject->getName()) . '"' . $tparams . ' alt=
"" />
';
1795 if ($linkInfoPopup) {
1797 $thumbData .=
'<a href="#" onclick="' . htmlspecialchars($onClick) .
'">' . $image .
'</a> ';
1799 $thumbData .= $image;
1803 $fileIcon =
'<span title="' . htmlspecialchars($fileObject->getName()) .
'">' . $iconFactory->getIconForResource($fileObject,
Icon::SIZE_SMALL)->render() .
'</span>';
1804 if ($linkInfoPopup) {
1806 $thumbData .=
'<a href="#" onclick="' . htmlspecialchars($onClick) .
'">' . $fileIcon .
'</a> ';
1808 $thumbData .= $fileIcon;
1827 public static function getThumbNail($thumbScript, $theFile, $tparams =
'', $size =
'')
1829 GeneralUtility::logDeprecatedFunction();
1830 $size = trim($size);
1831 $check = basename($theFile) .
':' . filemtime($theFile) .
':' . $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey'];
1832 $params =
'&file=' . rawurlencode($theFile);
1833 $params .= $size ?
'&size=' . $size :
'';
1834 $params .=
'&md5sum=' . md5($check);
1835 $url = $thumbScript .
'?' . $params;
1836 $th =
'<img src="' . htmlspecialchars(
$url) .
'" title="' . trim(basename($theFile)) .
'"' . ($tparams ?
' ' . $tparams :
'') .
' alt="" />';
1848 public static function titleAttribForPages($row, $perms_clause =
'', $includeAttrib =
true)
1850 $lang = static::getLanguageService();
1852 $parts[] =
'id=' . $row[
'uid'];
1853 if ($row[
'alias']) {
1854 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'alias'][
'label']) .
' ' . $row[
'alias'];
1856 if ($row[
'pid'] < 0) {
1857 $parts[] =
'v#1.' . $row[
't3ver_id'];
1859 switch (VersionState::cast($row[
't3ver_state'])) {
1861 $parts[] =
'PLH WSID#' . $row[
't3ver_wsid'];
1863 case new VersionState(VersionState::DELETE_PLACEHOLDER):
1864 $parts[] =
'Deleted element!';
1867 $parts[] =
'NEW LOCATION (PLH) WSID#' . $row[
't3ver_wsid'];
1870 $parts[] =
'OLD LOCATION (PNT) WSID#' . $row[
't3ver_wsid'];
1872 case new VersionState(VersionState::NEW_PLACEHOLDER_VERSION):
1873 $parts[] =
'New element!';
1876 if ($row[
'doktype'] == PageRepository::DOKTYPE_LINK) {
1877 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'url'][
'label']) .
' ' . $row[
'url'];
1878 }
elseif ($row[
'doktype'] == PageRepository::DOKTYPE_SHORTCUT) {
1879 if ($perms_clause) {
1880 $label = self::getRecordPath((
int)$row[
'shortcut'], $perms_clause, 20);
1882 $row[
'shortcut'] = (int)$row[
'shortcut'];
1883 $lRec = self::getRecordWSOL(
'pages', $row[
'shortcut'],
'title');
1884 $label = $lRec[
'title'] .
' (id=' . $row[
'shortcut'] .
')';
1886 if ($row[
'shortcut_mode'] != PageRepository::SHORTCUT_MODE_NONE) {
1887 $label .=
', ' .
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'shortcut_mode'][
'label']) .
' ' .
$lang->sL(self::getLabelFromItemlist(
'pages',
'shortcut_mode', $row[
'shortcut_mode']));
1889 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'shortcut'][
'label']) .
' ' . $label;
1890 }
elseif ($row[
'doktype'] == PageRepository::DOKTYPE_MOUNTPOINT) {
1891 if ($perms_clause) {
1892 $label = self::getRecordPath((
int)$row[
'mount_pid'], $perms_clause, 20);
1894 $lRec = self::getRecordWSOL(
'pages', (
int)$row[
'mount_pid'],
'title');
1895 $label = $lRec[
'title'] .
' (id=' . $row[
'mount_pid'] .
')';
1897 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'mount_pid'][
'label']) .
' ' . $label;
1898 if ($row[
'mount_pid_ol']) {
1899 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'mount_pid_ol'][
'label']);
1902 if ($row[
'nav_hide']) {
1903 $parts[] = rtrim(
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'nav_hide'][
'label']),
':');
1905 if ($row[
'hidden']) {
1906 $parts[] =
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.hidden');
1908 if ($row[
'starttime']) {
1909 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'starttime'][
'label']) .
' ' . self::dateTimeAge($row[
'starttime'], -1,
'date');
1911 if ($row[
'endtime']) {
1912 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'endtime'][
'label']) .
' ' . self::dateTimeAge($row[
'endtime'], -1,
'date');
1914 if ($row[
'fe_group']) {
1915 $fe_groups = array();
1916 foreach (GeneralUtility::intExplode(
',', $row[
'fe_group']) as $fe_group) {
1917 if ($fe_group < 0) {
1918 $fe_groups[] =
$lang->sL(self::getLabelFromItemlist(
'pages',
'fe_group', $fe_group));
1920 $lRec = self::getRecordWSOL(
'fe_groups', $fe_group,
'title');
1921 $fe_groups[] = $lRec[
'title'];
1924 $label = implode(
', ', $fe_groups);
1925 $parts[] =
$lang->sL($GLOBALS[
'TCA'][
'pages'][
'columns'][
'fe_group'][
'label']) .
' ' . $label;
1927 $out = htmlspecialchars(implode(
' - ', $parts));
1928 return $includeAttrib ?
'title="' . $out .
'"' : $out;
1938 public static function getRecordToolTip(array $row, $table =
'pages')
1940 $toolTipText = self::getRecordIconAltText($row, $table);
1941 $toolTipCode =
'data-toggle="tooltip" data-title=" ' . str_replace(
' - ',
'<br>', $toolTipText) .
'" data-html="true" data-placement="right"';
1942 return $toolTipCode;
1954 public static function getRecordIconAltText($row, $table =
'pages')
1956 if ($table ==
'pages') {
1957 $out = self::titleAttribForPages($row,
'', 0);
1959 $out = !empty(trim($GLOBALS[
'TCA'][$table][
'ctrl'][
'descriptionColumn'])) ? $row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'descriptionColumn']] .
' ' :
'';
1960 $ctrl = $GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'];
1962 $out .=
'id=' . $row[
'uid'];
1963 if ($table ==
'pages' && $row[
'alias']) {
1964 $out .=
' / ' . $row[
'alias'];
1966 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] && $row[
'pid'] < 0) {
1967 $out .=
' - v#1.' . $row[
't3ver_id'];
1969 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
1970 switch (VersionState::cast($row[
't3ver_state'])) {
1972 $out .=
' - PLH WSID#' . $row[
't3ver_wsid'];
1974 case new VersionState(VersionState::DELETE_PLACEHOLDER):
1975 $out .=
' - Deleted element!';
1978 $out .=
' - NEW LOCATION (PLH) WSID#' . $row[
't3ver_wsid'];
1981 $out .=
' - OLD LOCATION (PNT) WSID#' . $row[
't3ver_wsid'];
1983 case new VersionState(VersionState::NEW_PLACEHOLDER_VERSION):
1984 $out .=
' - New element!';
1989 $lang = static::getLanguageService();
1990 if ($ctrl[
'disabled']) {
1991 $out .= $row[$ctrl[
'disabled']] ?
' - ' .
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.hidden') :
'';
1993 if ($ctrl[
'starttime']) {
1994 if ($row[$ctrl[
'starttime']] > $GLOBALS[
'EXEC_TIME']) {
1995 $out .=
' - ' .
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.starttime') .
':' . self::date($row[$ctrl[
'starttime']]) .
' (' . self::daysUntil($row[$ctrl[
'starttime']]) .
' ' .
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.days') .
')';
1998 if ($row[$ctrl[
'endtime']]) {
1999 $out .=
' - ' .
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.endtime') .
': ' . self::date($row[$ctrl[
'endtime']]) .
' (' . self::daysUntil($row[$ctrl[
'endtime']]) .
' ' .
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.days') .
')';
2002 return htmlspecialchars($out);
2013 public static function getLabelFromItemlist($table, $col, $key)
2016 if (is_array($GLOBALS[
'TCA'][$table]) && is_array($GLOBALS[
'TCA'][$table][
'columns'][$col]) && is_array($GLOBALS[
'TCA'][$table][
'columns'][$col][
'config'][
'items'])) {
2018 foreach ($GLOBALS[
'TCA'][$table][
'columns'][$col][
'config'][
'items'] as $v) {
2020 if ((
string)$v[1] === (
string)$key) {
2037 public static function getLabelFromItemListMerged($pageId, $table, $column, $key)
2039 $pageTsConfig = static::getPagesTSconfig($pageId);
2041 if (is_array($pageTsConfig[
'TCEFORM.']) && is_array($pageTsConfig[
'TCEFORM.'][$table .
'.']) && is_array($pageTsConfig[
'TCEFORM.'][$table .
'.'][$column .
'.'])) {
2042 if (is_array($pageTsConfig[
'TCEFORM.'][$table .
'.'][$column .
'.'][
'addItems.']) && isset($pageTsConfig[
'TCEFORM.'][$table .
'.'][$column .
'.'][
'addItems.'][$key])) {
2043 $label = $pageTsConfig[
'TCEFORM.'][$table .
'.'][$column .
'.'][
'addItems.'][$key];
2044 }
elseif (is_array($pageTsConfig[
'TCEFORM.'][$table .
'.'][$column .
'.'][
'altLabels.']) && isset($pageTsConfig[
'TCEFORM.'][$table .
'.'][$column .
'.'][
'altLabels.'][$key])) {
2045 $label = $pageTsConfig[
'TCEFORM.'][$table .
'.'][$column .
'.'][
'altLabels.'][$key];
2048 if (empty($label)) {
2049 $tcaValue = self::getLabelFromItemlist($table, $column, $key);
2050 if (!empty($tcaValue)) {
2067 public static function getLabelsFromItemsList($table, $column, $keyList, array $columnTsConfig = array())
2071 !isset($GLOBALS[
'TCA'][$table][
'columns'][$column][
'config'][
'items'])
2072 || !is_array($GLOBALS[
'TCA'][$table][
'columns'][$column][
'config'][
'items'])
2078 $keys = GeneralUtility::trimExplode(
',', $keyList,
true);
2081 foreach ($keys as $key) {
2083 if ($columnTsConfig) {
2085 if (isset($columnTsConfig[
'addItems.'][$key])) {
2086 $label = $columnTsConfig[
'addItems.'][$key];
2087 }
elseif (isset($columnTsConfig[
'altLabels.'][$key])) {
2088 $label = $columnTsConfig[
'altLabels.'][$key];
2091 if ($label === null) {
2093 foreach ($GLOBALS[
'TCA'][$table][
'columns'][$column][
'config'][
'items'] as $itemConfiguration) {
2094 list($currentLabel, $currentKey) = $itemConfiguration;
2095 if ((
string)$key === (
string)$currentKey) {
2096 $label = $currentLabel;
2101 if ($label !== null) {
2102 $labels[] = static::getLanguageService()->sL($label);
2105 return implode(
', ', $labels);
2117 public static function getItemLabel($table, $col, $printAllWrap =
'')
2120 if (is_array($GLOBALS[
'TCA'][$table]) && is_array($GLOBALS[
'TCA'][$table][
'columns'][$col])) {
2121 return $GLOBALS[
'TCA'][$table][
'columns'][$col][
'label'];
2123 if ($printAllWrap) {
2124 GeneralUtility::deprecationLog(
'The third parameter of getItemLabel() is deprecated with TYPO3 CMS 6.2 and will be removed two versions later.');
2125 $parts = explode(
'|', $printAllWrap);
2126 return $parts[0] . $col . $parts[1];
2140 protected static function replaceL10nModeFields($table, array $row)
2142 $originalUidField = isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'])
2143 ? $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField']
2145 if (empty($row[$originalUidField])) {
2149 $originalTable = self::getOriginalTranslationTable($table);
2150 $originalRow = self::getRecord($originalTable, $row[$originalUidField]);
2151 foreach ($row as $field => $_) {
2152 $l10n_mode = isset($GLOBALS[
'TCA'][$originalTable][
'columns'][$field][
'l10n_mode'])
2153 ? $GLOBALS[
'TCA'][$originalTable][
'columns'][$field][
'l10n_mode']
2155 if ($l10n_mode ===
'exclude' || ($l10n_mode ===
'mergeIfNotBlank' && trim($row[$field]) ===
'')) {
2156 $row[$field] = $originalRow[$field];
2172 public static function getRecordTitle($table, $row, $prep =
false, $forceResult =
true)
2175 if (is_array($GLOBALS[
'TCA'][$table])) {
2177 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'label_userFunc']) {
2178 $params[
'table'] = $table;
2179 $params[
'row'] = $row;
2180 $params[
'title'] =
'';
2181 $params[
'options'] = isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'label_userFunc_options']) ? $GLOBALS[
'TCA'][$table][
'ctrl'][
'label_userFunc_options'] : array();
2185 GeneralUtility::callUserFunction($GLOBALS[
'TCA'][$table][
'ctrl'][
'label_userFunc'], $params, $null);
2186 $recordTitle = $params[
'title'];
2188 if (is_array($row)) {
2189 $row = self::replaceL10nModeFields($table, $row);
2193 $recordTitle = self::getProcessedValue($table, $GLOBALS[
'TCA'][$table][
'ctrl'][
'label'], $row[$GLOBALS[
'TCA'][$table][
'ctrl'][
'label']], 0, 0,
false, $row[
'uid'], $forceResult);
2194 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'label_alt'] && ($GLOBALS[
'TCA'][$table][
'ctrl'][
'label_alt_force'] || (
string)$recordTitle ===
'')) {
2195 $altFields = GeneralUtility::trimExplode(
',', $GLOBALS[
'TCA'][$table][
'ctrl'][
'label_alt'],
true);
2197 if (!empty($recordTitle)) {
2198 $tA[] = $recordTitle;
2200 foreach ($altFields as $fN) {
2201 $recordTitle = trim(strip_tags($row[$fN]));
2202 if ((
string)$recordTitle !==
'') {
2203 $recordTitle = self::getProcessedValue($table, $fN, $recordTitle, 0, 0,
false, $row[
'uid']);
2204 if (!$GLOBALS[
'TCA'][$table][
'ctrl'][
'label_alt_force']) {
2207 $tA[] = $recordTitle;
2210 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'label_alt_force']) {
2211 $recordTitle = implode(
', ', $tA);
2216 if ($prep || $forceResult) {
2218 $recordTitle = self::getRecordTitlePrep($recordTitle);
2220 if (trim($recordTitle) ===
'') {
2221 $recordTitle = self::getNoRecordTitle($prep);
2226 return $recordTitle;
2237 public static function getRecordTitlePrep($title, $titleLength = 0)
2240 if (!$titleLength || !MathUtility::canBeInterpretedAsInteger($titleLength) || $titleLength < 0) {
2241 $titleLength = static::getBackendUserAuthentication()->uc[
'titleLen'];
2243 $titleOrig = htmlspecialchars($title);
2244 $title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($title, $titleLength));
2246 if ($titleOrig != $title) {
2247 $title =
'<span title="' . $titleOrig .
'">' . $title .
'</span>';
2258 public static function getNoRecordTitle($prep =
false)
2260 $noTitle =
'[' . static::getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.no_title',
true) .
']';
2262 $noTitle =
'<em>' . $noTitle .
'</em>';
2285 public static function getProcessedValue($table, $col, $value, $fixed_lgd_chars = 0, $defaultPassthrough =
false, $noRecordLookup =
false, $uid = 0, $forceResult =
true, $pid = 0)
2287 if ($col ===
'uid') {
2292 if (!is_array($GLOBALS[
'TCA'][$table]) || !is_array($GLOBALS[
'TCA'][$table][
'columns'][$col])) {
2296 $theColConf = $GLOBALS[
'TCA'][$table][
'columns'][$col][
'config'];
2300 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'preProcessValue'])) {
2303 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'preProcessValue'] as $_funcRef) {
2304 GeneralUtility::callUserFunction($_funcRef, $theColConf, $null);
2308 $db = static::getDatabaseConnection();
2309 $lang = static::getLanguageService();
2310 switch ((
string)$theColConf[
'type']) {
2312 $l = self::getLabelFromItemlist($table, $col, $value);
2317 if ($theColConf[
'MM']) {
2320 if ($noRecordLookup) {
2321 $MMfield = $theColConf[
'foreign_table'] .
'.uid';
2323 $MMfields = array($theColConf[
'foreign_table'] .
'.' . $GLOBALS[
'TCA'][$theColConf[
'foreign_table']][
'ctrl'][
'label']);
2324 foreach (GeneralUtility::trimExplode(
',', $GLOBALS[
'TCA'][$theColConf[
'foreign_table']][
'ctrl'][
'label_alt'],
true) as $f) {
2325 $MMfields[] = $theColConf[
'foreign_table'] .
'.' . $f;
2327 $MMfield = join(
',', $MMfields);
2330 $dbGroup = GeneralUtility::makeInstance(RelationHandler::class);
2331 $dbGroup->start($value, $theColConf[
'foreign_table'], $theColConf[
'MM'], $uid, $table, $theColConf);
2332 $selectUids = $dbGroup->tableArray[$theColConf[
'foreign_table']];
2333 if (is_array($selectUids) && !empty($selectUids)) {
2334 $MMres = $db->exec_SELECTquery(
'uid, ' . $MMfield, $theColConf[
'foreign_table'],
'uid IN (' . implode(
',', $selectUids) .
')' . self::deleteClause($theColConf[
'foreign_table']));
2336 while ($MMrow = $db->sql_fetch_assoc($MMres)) {
2338 $mmlA[array_search($MMrow[
'uid'], $selectUids)] = $noRecordLookup ?
2340 static::getRecordTitle($theColConf[
'foreign_table'], $MMrow,
false, $forceResult);
2342 $db->sql_free_result($MMres);
2343 if (!empty($mmlA)) {
2345 $l = implode(
'; ', $mmlA);
2356 $columnTsConfig = array();
2358 $pageTsConfig = self::getPagesTSconfig($pid);
2359 if (isset($pageTsConfig[
'TCEFORM.'][$table .
'.'][$col .
'.']) && is_array($pageTsConfig[
'TCEFORM.'][$table .
'.'][$col .
'.'])) {
2360 $columnTsConfig = $pageTsConfig[
'TCEFORM.'][$table .
'.'][$col .
'.'];
2363 $l = self::getLabelsFromItemsList($table, $col, $value, $columnTsConfig);
2364 if ($theColConf[
'foreign_table'] && !$l && $GLOBALS[
'TCA'][$theColConf[
'foreign_table']]) {
2365 if ($noRecordLookup) {
2369 if ($uid && isset($theColConf[
'foreign_field']) && $theColConf[
'foreign_field'] !==
'') {
2371 if (!empty($theColConf[
'foreign_table_field'])) {
2372 $whereClause .=
' AND ' . $theColConf[
'foreign_table_field'] .
' = ' . static::getDatabaseConnection()->fullQuoteStr($table, $theColConf[
'foreign_table']);
2375 $foreignMatchFields = is_array($theColConf[
'foreign_match_fields']) ? $theColConf[
'foreign_match_fields'] : array();
2376 foreach ($foreignMatchFields as $matchField => $matchValue) {
2377 $whereClause .=
' AND ' . $matchField .
'=' . static::getDatabaseConnection()->fullQuoteStr($matchValue, $theColConf[
'foreign_table']);
2379 $records = self::getRecordsByField($theColConf[
'foreign_table'], $theColConf[
'foreign_field'], $uid, $whereClause);
2380 if (!empty($records)) {
2381 foreach ($records as $record) {
2382 $rParts[] = $record[
'uid'];
2386 if (empty($rParts)) {
2387 $rParts = GeneralUtility::trimExplode(
',', $value,
true);
2390 foreach ($rParts as $rVal) {
2392 $r = self::getRecordWSOL($theColConf[
'foreign_table'], $rVal);
2394 $lA[] =
$lang->sL($theColConf[
'foreign_table_prefix']) . self::getRecordTitle($theColConf[
'foreign_table'], $r,
false, $forceResult);
2396 $lA[] = $rVal ?
'[' . $rVal .
'!]' :
'';
2399 $l = implode(
', ', $lA);
2402 if (empty($l) && !empty($value)) {
2410 if ($theColConf[
'internal_type'] ===
'db') {
2411 if ($theColConf[
'MM']) {
2414 if ($noRecordLookup) {
2415 $MMfield = $theColConf[
'foreign_table'] .
'.uid';
2417 $MMfields = array($theColConf[
'foreign_table'] .
'.' . $GLOBALS[
'TCA'][$theColConf[
'foreign_table']][
'ctrl'][
'label']);
2418 $altLabelFields = explode(
',', $GLOBALS[
'TCA'][$theColConf[
'foreign_table']][
'ctrl'][
'label_alt']);
2419 foreach ($altLabelFields as $f) {
2422 $MMfields[] = $theColConf[
'foreign_table'] .
'.' . $f;
2425 $MMfield = join(
',', $MMfields);
2428 $dbGroup = GeneralUtility::makeInstance(RelationHandler::class);
2429 $dbGroup->start($value, $theColConf[
'foreign_table'], $theColConf[
'MM'], $uid, $table, $theColConf);
2430 $selectUids = $dbGroup->tableArray[$theColConf[
'foreign_table']];
2431 if (!empty($selectUids) && is_array($selectUids)) {
2432 $MMres = $db->exec_SELECTquery(
2434 $theColConf[
'foreign_table'],
2435 'uid IN (' . implode(
',', $selectUids) .
')' . static::deleteClause($theColConf[
'foreign_table'])
2438 while ($MMrow = $db->sql_fetch_assoc($MMres)) {
2440 $mmlA[array_search($MMrow[
'uid'], $selectUids)] = $noRecordLookup
2442 : static::getRecordTitle($theColConf[
'foreign_table'], $MMrow,
false, $forceResult);
2444 $db->sql_free_result($MMres);
2445 if (!empty($mmlA)) {
2447 $l = implode(
'; ', $mmlA);
2458 $finalValues = array();
2459 $relationTableName = $theColConf[
'allowed'];
2460 $explodedValues = GeneralUtility::trimExplode(
',', $value,
true);
2462 foreach ($explodedValues as $explodedValue) {
2463 if (MathUtility::canBeInterpretedAsInteger($explodedValue)) {
2464 $relationTableNameForField = $relationTableName;
2466 list($relationTableNameForField, $explodedValue) = self::splitTable_Uid($explodedValue);
2469 $relationRecord = static::getRecordWSOL($relationTableNameForField, $explodedValue);
2470 $finalValues[] = static::getRecordTitle($relationTableNameForField, $relationRecord);
2472 $l = implode(
', ', $finalValues);
2475 $l = implode(
', ', GeneralUtility::trimExplode(
',', $value,
true));
2479 if (!is_array($theColConf[
'items']) || count($theColConf[
'items']) === 1) {
2480 $l = $value ?
$lang->sL(
'LLL:EXT:lang/locallang_common.xlf:yes') :
$lang->sL(
'LLL:EXT:lang/locallang_common.xlf:no');
2483 foreach ($theColConf[
'items'] as $key => $val) {
2484 if ($value & pow(2, $key)) {
2485 $lA[] =
$lang->sL($val[0]);
2488 $l = implode(
', ', $lA);
2493 if (isset($value)) {
2494 if (GeneralUtility::inList($theColConf[
'eval'],
'date')) {
2496 if (isset($theColConf[
'dbType']) && $theColConf[
'dbType'] ===
'date') {
2497 $dateTimeFormats = $db->getDateTimeFormats($table);
2498 $emptyValue = $dateTimeFormats[
'date'][
'empty'];
2499 $value = $value !== $emptyValue ? strtotime($value) : 0;
2501 if (!empty($value)) {
2503 $dateColumnConfiguration = $GLOBALS[
'TCA'][$table][
'columns'][$col][
'config'];
2504 $ageDisplayKey =
'disableAgeDisplay';
2507 if (!isset($dateColumnConfiguration[$ageDisplayKey])
2509 || $dateColumnConfiguration[$ageDisplayKey] ==
false) {
2510 $ageSuffix =
' (' . ($GLOBALS[
'EXEC_TIME'] - $value > 0 ?
'-' :
'') . self::calcAge(abs(($GLOBALS[
'EXEC_TIME'] - $value)),
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears')) .
')';
2513 $l = self::date($value) . $ageSuffix;
2515 }
elseif (GeneralUtility::inList($theColConf[
'eval'],
'time')) {
2516 if (!empty($value)) {
2517 $l = self::time($value,
false);
2519 }
elseif (GeneralUtility::inList($theColConf[
'eval'],
'timesec')) {
2520 if (!empty($value)) {
2521 $l = self::time($value);
2523 }
elseif (GeneralUtility::inList($theColConf[
'eval'],
'datetime')) {
2525 if (isset($theColConf[
'dbType']) && $theColConf[
'dbType'] ===
'datetime') {
2526 $dateTimeFormats = $db->getDateTimeFormats($table);
2527 $emptyValue = $dateTimeFormats[
'datetime'][
'empty'];
2528 $value = $value !== $emptyValue ? strtotime($value) : 0;
2530 if (!empty($value)) {
2531 $l = self::datetime($value);
2539 $l = strip_tags($value);
2542 if ($defaultPassthrough) {
2544 }
elseif ($theColConf[
'MM']) {
2547 $l = GeneralUtility::fixed_lgd_cs(strip_tags($value), 200);
2551 if (stristr($theColConf[
'eval'],
'password')) {
2553 $randomNumber = rand(5, 12);
2554 for ($i = 0; $i < $randomNumber; $i++) {
2561 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'postProcessValue'])) {
2564 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'postProcessValue'] as $_funcRef) {
2567 'colConf' => $theColConf
2569 $l = GeneralUtility::callUserFunction($_funcRef, $params, $null);
2572 if ($fixed_lgd_chars) {
2573 return GeneralUtility::fixed_lgd_cs($l, $fixed_lgd_chars);
2592 public static function getProcessedValueExtra($table, $fN, $fV, $fixed_lgd_chars = 0, $uid = 0, $forceResult =
true, $pid = 0)
2594 $fVnew = self::getProcessedValue($table, $fN, $fV, $fixed_lgd_chars, 1, 0, $uid, $forceResult, $pid);
2595 if (!isset($fVnew)) {
2596 if (is_array($GLOBALS[
'TCA'][$table])) {
2597 if ($fN == $GLOBALS[
'TCA'][$table][
'ctrl'][
'tstamp'] || $fN == $GLOBALS[
'TCA'][$table][
'ctrl'][
'crdate']) {
2598 $fVnew = self::datetime($fV);
2599 }
elseif ($fN ==
'pid') {
2601 $fVnew = self::getRecordPath($fV,
'1=1', 20);
2620 public static function getCommonSelectFields($table, $prefix =
'', $fields = array())
2622 $fields[] = $prefix .
'uid';
2623 if (isset($GLOBALS[
'TCA'][$table][
'ctrl'][
'label']) && $GLOBALS[
'TCA'][$table][
'ctrl'][
'label'] !=
'') {
2624 $fields[] = $prefix . $GLOBALS[
'TCA'][$table][
'ctrl'][
'label'];
2626 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'label_alt']) {
2627 $secondFields = GeneralUtility::trimExplode(
',', $GLOBALS[
'TCA'][$table][
'ctrl'][
'label_alt'],
true);
2628 foreach ($secondFields as $fieldN) {
2629 $fields[] = $prefix . $fieldN;
2632 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
2633 $fields[] = $prefix .
't3ver_id';
2634 $fields[] = $prefix .
't3ver_state';
2635 $fields[] = $prefix .
't3ver_wsid';
2636 $fields[] = $prefix .
't3ver_count';
2638 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'selicon_field']) {
2639 $fields[] = $prefix . $GLOBALS[
'TCA'][$table][
'ctrl'][
'selicon_field'];
2641 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'typeicon_column']) {
2642 $fields[] = $prefix . $GLOBALS[
'TCA'][$table][
'ctrl'][
'typeicon_column'];
2644 if (is_array($GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'])) {
2645 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled']) {
2646 $fields[] = $prefix . $GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled'];
2648 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'starttime']) {
2649 $fields[] = $prefix . $GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'starttime'];
2651 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'endtime']) {
2652 $fields[] = $prefix . $GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'endtime'];
2654 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'fe_group']) {
2655 $fields[] = $prefix . $GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'fe_group'];
2658 return implode(
',', array_unique($fields));
2673 public static function makeConfigForm($configArray, $defaults, $dataPrefix)
2675 $params = $defaults;
2677 if (is_array($configArray)) {
2678 foreach ($configArray as $fname => $config) {
2679 if (is_array($config)) {
2680 $lines[$fname] =
'<strong>' . htmlspecialchars($config[1]) .
'</strong><br />';
2681 $lines[$fname] .= $config[2] .
'<br />';
2682 switch ($config[0]) {
2686 $formEl =
'<input type="text" name="' . $dataPrefix .
'[' . $fname .
']" value="' . $params[$fname] .
'"' . static::getDocumentTemplate()->formWidth(($config[0] ==
'short' ? 24 : 48)) .
' />';
2689 $formEl =
'<input type="hidden" name="' . $dataPrefix .
'[' . $fname .
']" value="0" /><input type="checkbox" name="' . $dataPrefix .
'[' . $fname .
']" value="1"' . ($params[$fname] ?
' checked="checked"' :
'') .
' />';
2696 foreach ($config[3] as $k => $v) {
2697 $opt[] =
'<option value="' . htmlspecialchars($k) .
'"' . ($params[$fname] == $k ?
' selected="selected"' :
'') .
'>' . htmlspecialchars($v) .
'</option>';
2699 $formEl =
'<select name="' . $dataPrefix .
'[' . $fname .
']">' . implode(
'', $opt) .
'</select>';
2702 $formEl =
'<strong>Should not happen. Bug in config.</strong>';
2704 $lines[$fname] .= $formEl;
2705 $lines[$fname] .=
'<br /><br />';
2707 $lines[$fname] =
'<hr />';
2709 $lines[$fname] .=
'<strong>' . strtoupper(htmlspecialchars($config)) .
'</strong><br />';
2712 $lines[$fname] .=
'<br />';
2717 $out = implode(
'', $lines);
2718 $out .=
'<input class="btn btn-default" type="submit" name="submit" value="Update configuration" />';
2743 public static function helpTextIcon($table, $field, $_ =
'', $force =
false)
2745 GeneralUtility::logDeprecatedFunction();
2746 if (is_array($GLOBALS[
'TCA_DESCR'][$table]) && is_array($GLOBALS[
'TCA_DESCR'][$table][
'columns'][$field])) {
2747 return self::wrapInHelp($table, $field);
2759 public static function helpTextArray($table, $field)
2761 if (!isset($GLOBALS[
'TCA_DESCR'][$table][
'columns'])) {
2762 static::getLanguageService()->loadSingleTableDescription($table);
2765 'description' => null,
2769 if (is_array($GLOBALS[
'TCA_DESCR'][$table]) && is_array($GLOBALS[
'TCA_DESCR'][$table][
'columns'][$field])) {
2770 $data = $GLOBALS[
'TCA_DESCR'][$table][
'columns'][$field];
2772 if ($data[
'alttitle']) {
2773 $output[
'title'] = $data[
'alttitle'];
2776 if ($data[
'image_descr'] || $data[
'seeAlso'] || $data[
'details'] || $data[
'syntax']) {
2777 $output[
'moreInfo'] =
true;
2780 if ($data[
'description']) {
2781 $output[
'description'] = $data[
'description'];
2795 public static function helpText($table, $field)
2797 $helpTextArray = self::helpTextArray($table, $field);
2801 if ($helpTextArray[
'title'] !== null) {
2802 $output .=
'<h2 class="t3-row-header">' . $helpTextArray[
'title'] .
'</h2>';
2805 if ($helpTextArray[
'moreInfo']) {
2807 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
2808 $arrow = $iconFactory->getIcon(
'actions-view-go-forward', Icon::SIZE_SMALL)->render();
2811 if ($helpTextArray[
'description'] !== null || $arrow) {
2812 $output .=
'<p class="t3-help-short">' . nl2br(htmlspecialchars($helpTextArray[
'description'])) . $arrow .
'</p>';
2829 public static function wrapInHelp($table, $field, $text =
'', array $overloadHelpText = array())
2834 $wrappedText = $text;
2835 $hasHelpTextOverload = !empty($overloadHelpText);
2837 if (!$hasHelpTextOverload) {
2838 $helpText = self::helpText($table, $field);
2844 if ((!empty($helpText) || $hasHelpTextOverload) && ExtensionManagementUtility::isLoaded(
'cshmanual')) {
2848 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
2849 $text = $iconFactory->getIcon(
'actions-system-help-open', Icon::SIZE_SMALL)->render();
2850 $abbrClassAdd =
'-icon';
2852 $text =
'<abbr class="t3-help-teaser' . $abbrClassAdd .
'">' . $text .
'</abbr>';
2853 $wrappedText =
'<span class="t3-help-link" href="#" data-table="' . $table .
'" data-field="' . $field .
'"';
2856 if ($hasHelpTextOverload) {
2857 if (isset($overloadHelpText[
'title'])) {
2858 $wrappedText .=
' data-title="' . htmlspecialchars($overloadHelpText[
'title']) .
'"';
2860 if (isset($overloadHelpText[
'description'])) {
2861 $wrappedText .=
' data-description="' . htmlspecialchars($overloadHelpText[
'description']) .
'"';
2864 $wrappedText .=
'>' . $text .
'</span>';
2865 return $wrappedText;
2881 public static function cshItem($table, $field, $_ =
'', $wrap =
'')
2883 static::getLanguageService()->loadSingleTableDescription($table);
2884 if (is_array($GLOBALS[
'TCA_DESCR'][$table])
2885 && is_array($GLOBALS[
'TCA_DESCR'][$table][
'columns'][$field])) {
2887 $output = self::wrapInHelp($table, $field);
2888 if ($output && $wrap) {
2889 $wrParts = explode(
'|', $wrap);
2890 $output = $wrParts[0] . $output . $wrParts[1];
2907 public static function editOnClick($params, $_ =
'', $requestUri =
'')
2909 if ($requestUri == -1) {
2910 $returnUrl =
'T3_THIS_LOCATION';
2912 $returnUrl = GeneralUtility::quoteJSvalue(rawurlencode($requestUri ?: GeneralUtility::getIndpEnv(
'REQUEST_URI')));
2914 return 'window.location.href=' . GeneralUtility::quoteJSvalue(self::getModuleUrl(
'record_edit') . $params .
'&returnUrl=') .
'+' . $returnUrl .
'; return false;';
2931 public static function viewOnClick($pageUid, $backPath =
'', $rootLine = null, $anchorSection =
'', $alternativeUrl =
'', $additionalGetVars =
'', $switchFocus =
true)
2933 $viewScript =
'/index.php?id=';
2934 if ($alternativeUrl) {
2935 $viewScript = $alternativeUrl;
2939 isset($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'viewOnClickClass'])
2940 && is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'viewOnClickClass'])
2942 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'viewOnClickClass'] as $funcRef) {
2943 $hookObj = GeneralUtility::getUserObj($funcRef);
2944 if (method_exists($hookObj,
'preProcess')) {
2945 $hookObj->preProcess($pageUid, $backPath, $rootLine, $anchorSection, $viewScript, $additionalGetVars, $switchFocus);
2950 if ($alternativeUrl) {
2951 $previewUrl = $viewScript;
2953 $previewUrl = self::createPreviewUrl($pageUid, $rootLine, $anchorSection, $additionalGetVars, $viewScript);
2956 $onclickCode =
'var previewWin = window.open(' . GeneralUtility::quoteJSvalue($previewUrl) .
',\'newTYPO3frontendWindow\');' . ($switchFocus ?
'previewWin.focus();' :
'');
2957 return $onclickCode;
2986 public static function wrapClickMenuOnIcon(
2993 $returnTagParameters =
false
2995 $tagParameters = array(
2996 'class' =>
't3-js-clickmenutrigger',
2997 'data-table' => $table,
2998 'data-uid' => (
int)$uid !== 0 ? (
int)$uid :
'',
2999 'data-listframe' => $listFrame,
3000 'data-iteminfo' => str_replace(
'+',
'%2B', $enDisItems),
3001 'data-parameters' => $addParams,
3004 if ($returnTagParameters) {
3005 return $tagParameters;
3007 return '<a href="#" ' . GeneralUtility::implodeAttributes($tagParameters,
true) .
'>' . $content .
'</a>';
3017 public static function getLinkToDataHandlerAction($parameters, $redirectUrl =
'')
3022 'vC' => static::getBackendUserAuthentication()->veriCode()
3024 $url = BackendUtility::getModuleUrl(
'tce_db', $urlParameters) . $parameters .
'&redirect=';
3025 if ((
int)$redirectUrl === -1) {
3026 $url = GeneralUtility::quoteJSvalue(
$url) .
'+T3_THIS_LOCATION';
3028 $url .= rawurlencode($redirectUrl ?: GeneralUtility::getIndpEnv(
'REQUEST_URI'));
3044 protected static function createPreviewUrl($pageUid, $rootLine, $anchorSection, $additionalGetVars, $viewScript)
3047 $beUser = static::getBackendUserAuthentication();
3048 $viewLanguageOrder = $beUser->getTSConfigVal(
'options.view.languageOrder');
3050 if ((
string)$viewLanguageOrder !==
'') {
3053 $allowedLanguages = null;
3054 if (!$beUser->user[
'admin'] && $beUser->groupData[
'allowed_languages'] !==
'') {
3055 $allowedLanguages = array_flip(explode(
',', $beUser->groupData[
'allowed_languages']));
3058 $languageOrder = GeneralUtility::intExplode(
',', $viewLanguageOrder);
3059 foreach ($languageOrder as $langUid) {
3060 if (is_array($allowedLanguages) && !empty($allowedLanguages)) {
3062 if (isset($allowedLanguages[$langUid])) {
3063 $suffix =
'&L=' . $langUid;
3068 $suffix =
'&L=' . $langUid;
3073 $additionalGetVars .= $suffix;
3077 $sys_page = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
3078 $sys_page->init(
false);
3079 $mountPointInfo = $sys_page->getMountPointInfo($pageUid);
3081 if ($mountPointInfo && $mountPointInfo[
'overlay']) {
3082 $pageUid = $mountPointInfo[
'mount_pid'];
3083 $additionalGetVars .=
'&MP=' . $mountPointInfo[
'MPvar'];
3085 $viewDomain = self::getViewDomain($pageUid, $rootLine);
3087 return $viewDomain . $viewScript . $pageUid . $additionalGetVars . $anchorSection;
3098 public static function getViewDomain($pageId, $rootLine = null)
3100 $domain = rtrim(GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL'),
'/');
3101 if (!is_array($rootLine)) {
3102 $rootLine = self::BEgetRootLine($pageId);
3105 if (!empty($rootLine)) {
3106 $urlParts = parse_url($domain);
3108 $sysPage = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
3109 $page = (array)$sysPage->getPage($pageId);
3111 if ($page[
'url_scheme'] == HttpUtility::SCHEME_HTTPS || $page[
'url_scheme'] == 0 && GeneralUtility::getIndpEnv(
'TYPO3_SSL')) {
3112 $protocol =
'https';
3114 $previewDomainConfig = static::getBackendUserAuthentication()->getTSConfig(
'TCEMAIN.previewDomain', self::getPagesTSconfig($pageId));
3115 if ($previewDomainConfig[
'value']) {
3116 if (strpos($previewDomainConfig[
'value'],
'://') !==
false) {
3117 list($protocol, $domainName) = explode(
'://', $previewDomainConfig[
'value']);
3119 $domainName = $previewDomainConfig[
'value'];
3122 $domainName = self::firstDomainRecord($rootLine);
3125 $domain = $domainName;
3127 $domainRecord = self::getDomainStartPage($urlParts[
'host'], $urlParts[
'path']);
3128 $domain = $domainRecord[
'domainName'];
3131 $domain = $protocol .
'://' . $domain;
3133 $domain = rtrim(GeneralUtility::getIndpEnv(
'TYPO3_SITE_URL'),
'/');
3136 $portNumber = (int)$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'lockSSLPort'];
3137 if ($portNumber > 0 && $portNumber !== 443 && $portNumber < 65536 && $protocol ===
'https') {
3138 $domain .=
':' . strval($portNumber);
3152 public static function getModTSconfig($id, $TSref)
3154 $beUser = static::getBackendUserAuthentication();
3155 $pageTS_modOptions = $beUser->getTSConfig($TSref, static::getPagesTSconfig($id));
3156 $BE_USER_modOptions = $beUser->getTSConfig($TSref);
3157 if (is_null($BE_USER_modOptions[
'value'])) {
3158 unset($BE_USER_modOptions[
'value']);
3160 ArrayUtility::mergeRecursiveWithOverrule($pageTS_modOptions, $BE_USER_modOptions);
3161 return $pageTS_modOptions;
3177 public static function getFuncMenu($mainParams, $elementName, $currentValue, $menuItems, $script =
'', $addParams =
'')
3179 if (!is_array($menuItems) || count($menuItems) <= 1) {
3182 $scriptUrl = self::buildScriptUrl($mainParams, $addParams, $script);
3184 foreach ($menuItems as $value => $label) {
3185 $options[] =
'<option value="' . htmlspecialchars($value) .
'"' . ((string)$currentValue === (
string)$value ?
' selected="selected"' :
'') .
'>' . htmlspecialchars($label, ENT_COMPAT,
'UTF-8',
false) .
'</option>';
3187 if (!empty($options)) {
3188 $onChange =
'jumpToUrl(' . GeneralUtility::quoteJSvalue($scriptUrl .
'&' . $elementName .
'=') .
'+this.options[this.selectedIndex].value,this);';
3191 <!-- Function Menu of module -->
3192 <select name="' . $elementName .
'" onchange="' . htmlspecialchars($onChange) .
'">
3215 public static function getDropdownMenu($mainParams, $elementName, $currentValue, $menuItems, $script =
'', $addParams =
'')
3217 if (!is_array($menuItems) || count($menuItems) <= 1) {
3220 $scriptUrl = self::buildScriptUrl($mainParams, $addParams, $script);
3222 foreach ($menuItems as $value => $label) {
3223 $options[] =
'<option value="' . htmlspecialchars($value) .
'"' . ((string)$currentValue === (
string)$value ?
' selected="selected"' :
'') .
'>' . htmlspecialchars($label, ENT_COMPAT,
'UTF-8',
false) .
'</option>';
3225 if (!empty($options)) {
3226 $onChange =
'jumpToUrl(' . GeneralUtility::quoteJSvalue($scriptUrl .
'&' . $elementName .
'=') .
'+this.options[this.selectedIndex].value,this);';
3228 <div class="form-group">
3229 <!-- Function Menu of module -->
3230 <select class="form-control input-sm" name="' . htmlspecialchars($elementName) .
'" onchange="' . htmlspecialchars($onChange) .
'">
3231 ' . implode(LF, $options) .
'
3252 public static function getFuncCheck($mainParams, $elementName, $currentValue, $script =
'', $addParams =
'', $tagParams =
'')
3254 $scriptUrl = self::buildScriptUrl($mainParams, $addParams, $script);
3255 $onClick =
'jumpToUrl(' . GeneralUtility::quoteJSvalue($scriptUrl .
'&' . $elementName .
'=') .
'+(this.checked?1:0),this);';
3259 ' type="checkbox"' .
3260 ' class="checkbox"' .
3261 ' name="' . $elementName .
'"' .
3262 ($currentValue ?
' checked="checked"' :
'') .
3263 ' onclick="' . htmlspecialchars($onClick) .
'"' .
3264 ($tagParams ?
' ' . $tagParams :
'') .
3282 public static function getFuncInput($mainParams, $elementName, $currentValue, $size = 10, $script =
'', $addParams =
'')
3284 $scriptUrl = self::buildScriptUrl($mainParams, $addParams, $script);
3285 $onChange =
'jumpToUrl(' . GeneralUtility::quoteJSvalue($scriptUrl .
'&' . $elementName .
'=') .
'+escape(this.value),this);';
3286 return '<input type="text"' . static::getDocumentTemplate()->formWidth($size) .
' name="' . $elementName .
'" value="' . htmlspecialchars($currentValue) .
'" onchange="' . htmlspecialchars($onChange) .
'" />';
3297 protected static function buildScriptUrl($mainParams, $addParams, $script =
'')
3299 if (!is_array($mainParams)) {
3300 $mainParams = array(
'id' => $mainParams);
3303 $script = basename(PATH_thisScript);
3306 if (GeneralUtility::_GP(
'route')) {
3307 $router = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\Router::class);
3308 $route = $router->match(GeneralUtility::_GP(
'route'));
3309 $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
3310 $scriptUrl = (string)$uriBuilder->buildUriFromRoute($route->getOption(
'_identifier'));
3311 $scriptUrl .= $addParams;
3312 }
elseif ($script ===
'index.php' && GeneralUtility::_GET(
'M')) {
3313 $scriptUrl = self::getModuleUrl(GeneralUtility::_GET(
'M'), $mainParams) . $addParams;
3315 $scriptUrl = $script .
'?' . GeneralUtility::implodeArrayForUrl(
'', $mainParams) . $addParams;
3330 public static function unsetMenuItems($modTSconfig, $itemArray, $TSref)
3333 $conf = static::getBackendUserAuthentication()->getTSConfig($TSref, $modTSconfig);
3334 if (is_array($conf[
'properties'])) {
3335 foreach ($conf[
'properties'] as $key => $val) {
3337 unset($itemArray[$key]);
3353 public static function setUpdateSignal($set =
'', $params =
'')
3355 $beUser = static::getBackendUserAuthentication();
3356 $modData = $beUser->getModuleData(\TYPO3\CMS\Backend\Utility\BackendUtility::class .
'::getUpdateSignal',
'ses');
3358 $modData[$set] = array(
3360 'parameter' => $params
3366 $beUser->pushModuleData(\TYPO3\CMS\Backend\Utility\BackendUtility::class .
'::getUpdateSignal', $modData);
3377 public static function getUpdateSignalCode()
3380 $modData = static::getBackendUserAuthentication()->getModuleData(\TYPO3\CMS\Backend\Utility\BackendUtility::class .
'::getUpdateSignal',
'ses');
3381 if (empty($modData)) {
3385 if (isset($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'updateSignalHook'])) {
3386 $updateSignals = $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'updateSignalHook'];
3388 $updateSignals = array();
3391 foreach ($modData as $set => $val) {
3392 if (isset($updateSignals[$set])) {
3393 $params = array(
'set' => $set,
'parameter' => $val[
'parameter'],
'JScode' =>
'');
3395 GeneralUtility::callUserFunction($updateSignals[$set], $params, $ref);
3396 $signals[] = $params[
'JScode'];
3399 case 'updatePageTree':
3401 if (top && top.TYPO3.Backend.NavigationContainer.PageTree) {
3402 top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
3406 case 'updateFolderTree':
3408 if (top && top.TYPO3.Backend.NavigationIframe) {
3409 top.TYPO3.Backend.NavigationIframe.refresh();
3412 case 'updateModuleMenu':
3414 if (top && top.TYPO3.ModuleMenu.App) {
3415 top.TYPO3.ModuleMenu.App.refreshMenu();
3420 $content = implode(LF, $signals);
3422 self::setUpdateSignal();
3440 public static function getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type =
'', $dontValidateList =
'', $setDefaultList =
'')
3442 if ($modName && is_string($modName)) {
3444 $beUser = static::getBackendUserAuthentication();
3445 $settings = $beUser->getModuleData($modName, $type);
3447 if (!is_array($settings)) {
3449 $settings = array();
3451 if (is_array($MOD_MENU)) {
3452 foreach ($MOD_MENU as $key => $var) {
3454 if (is_array($CHANGED_SETTINGS) && isset($CHANGED_SETTINGS[$key])) {
3455 if (is_array($CHANGED_SETTINGS[$key])) {
3456 $serializedSettings = serialize($CHANGED_SETTINGS[$key]);
3457 if ((
string)$settings[$key] !== $serializedSettings) {
3458 $settings[$key] = $serializedSettings;
3462 if ((
string)$settings[$key] !== (
string)$CHANGED_SETTINGS[$key]) {
3463 $settings[$key] = $CHANGED_SETTINGS[$key];
3469 if (is_array($var) && (!$dontValidateList || !GeneralUtility::inList($dontValidateList, $key))) {
3471 if (is_array($settings[$key]) || !isset($MOD_MENU[$key][$settings[$key]])) {
3472 $settings[$key] = (string)key($var);
3477 if ($setDefaultList && !is_array($var)) {
3478 if (GeneralUtility::inList($setDefaultList, $key) && !isset($settings[$key])) {
3479 $settings[$key] = (string)$var;
3487 $beUser->pushModuleData($modName, $settings);
3491 die(
'Wrong module name: "' . $modName .
'"');
3504 public static function getModuleUrl($moduleName, $urlParameters = array(), $backPathOverride =
false, $returnAbsoluteUrl =
false)
3507 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
3509 $uri = $uriBuilder->buildUriFromRoute($moduleName, $urlParameters, $returnAbsoluteUrl ? UriBuilder::ABSOLUTE_URL : UriBuilder::ABSOLUTE_PATH);
3510 }
catch (\TYPO3\CMS\Backend\Routing\
Exception\RouteNotFoundException $e) {
3512 $uri = $uriBuilder->buildUriFromModule($moduleName, $urlParameters, $returnAbsoluteUrl ? UriBuilder::ABSOLUTE_URL : UriBuilder::ABSOLUTE_PATH);
3514 return (
string)$uri;
3530 public static function getAjaxUrl($ajaxIdentifier, array $urlParameters = array(), $backPathOverride =
false, $returnAbsoluteUrl =
false)
3533 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
3535 $routeIdentifier =
'ajax_' . $ajaxIdentifier;
3536 $uri = $uriBuilder->buildUriFromRoute($routeIdentifier, $urlParameters, $returnAbsoluteUrl ? UriBuilder::ABSOLUTE_URL : UriBuilder::ABSOLUTE_PATH);
3537 }
catch (\TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException $e) {
3539 $uri = $uriBuilder->buildUriFromAjaxId($ajaxIdentifier, $urlParameters, $returnAbsoluteUrl ? UriBuilder::ABSOLUTE_URL : UriBuilder::ABSOLUTE_PATH);
3541 return (
string)$uri;
3552 public static function getListViewLink($urlParameters = array(), $linkTitle =
'', $linkText =
'')
3555 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
3556 return '<a href="' . htmlspecialchars(self::getModuleUrl(
'web_list', $urlParameters)) .
'" title="' . htmlspecialchars($linkTitle) .
'">' . $iconFactory->getIcon(
'actions-system-list-open', Icon::SIZE_SMALL)->render() . htmlspecialchars($linkText) .
'</a>';
3568 public static function getUrlToken($formName =
'securityToken', $tokenName =
'formToken')
3570 GeneralUtility::logDeprecatedFunction();
3571 $formProtection = FormProtectionFactory::get();
3572 return '&' . $tokenName .
'=' . $formProtection->generateToken($formName);
3590 public static function lockRecords($table =
'', $uid = 0, $pid = 0)
3592 $beUser = static::getBackendUserAuthentication();
3593 if (isset($beUser->user[
'uid'])) {
3594 $user_id = (int)$beUser->user[
'uid'];
3595 if ($table && $uid) {
3596 $fields_values = array(
3597 'userid' => $user_id,
3599 'tstamp' => $GLOBALS[
'EXEC_TIME'],
3600 'record_table' => $table,
3601 'record_uid' => $uid,
3602 'username' => $beUser->user[
'username'],
3603 'record_pid' => $pid
3605 static::getDatabaseConnection()->exec_INSERTquery(
'sys_lockedrecords', $fields_values);
3607 static::getDatabaseConnection()->exec_DELETEquery(
'sys_lockedrecords',
'userid=' . (
int)$user_id);
3624 public static function isRecordLocked($table, $uid)
3626 if (!is_array($GLOBALS[
'LOCKED_RECORDS'])) {
3627 $GLOBALS[
'LOCKED_RECORDS'] = array();
3628 $db = static::getDatabaseConnection();
3629 $res = $db->exec_SELECTquery(
3631 'sys_lockedrecords',
3632 'sys_lockedrecords.userid<>' . (
int)static::getBackendUserAuthentication()->user[
'uid']
3633 .
' AND sys_lockedrecords.tstamp > ' . ($GLOBALS[
'EXEC_TIME'] - 2 * 3600)
3635 while ($row = $db->sql_fetch_assoc($res)) {
3637 if ($row[
'userid']) {
3638 $userTypeLabel =
'beUser';
3639 }
elseif ($row[
'feuserid']) {
3640 $userTypeLabel =
'feUser';
3642 $userTypeLabel =
'user';
3644 $lang = static::getLanguageService();
3645 $userType =
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.' . $userTypeLabel);
3647 if ($row[
'username']) {
3648 $userName = $row[
'username'];
3650 $userName =
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.unknownUser');
3652 $GLOBALS[
'LOCKED_RECORDS'][$row[
'record_table'] .
':' . $row[
'record_uid']] = $row;
3653 $GLOBALS[
'LOCKED_RECORDS'][$row[
'record_table'] .
':' . $row[
'record_uid']][
'msg'] = sprintf(
3654 $lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.lockedRecordUser'),
3657 self::calcAge($GLOBALS[
'EXEC_TIME'] - $row[
'tstamp'],
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears'))
3659 if ($row[
'record_pid'] && !isset($GLOBALS[
'LOCKED_RECORDS'][($row[
'record_table'] .
':' . $row[
'record_pid'])])) {
3660 $GLOBALS[
'LOCKED_RECORDS'][
'pages:' . $row[
'record_pid']][
'msg'] = sprintf(
3661 $lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.lockedRecordUser_content'),
3664 self::calcAge($GLOBALS[
'EXEC_TIME'] - $row[
'tstamp'],
$lang->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears'))
3668 $db->sql_free_result($res);
3670 return $GLOBALS[
'LOCKED_RECORDS'][$table .
':' . $uid];
3683 public static function exec_foreign_table_where_query($fieldConfig, $field =
'', $TSconfig = array())
3685 GeneralUtility::logDeprecatedFunction();
3686 $foreign_table = $fieldConfig[
'config'][
'foreign_table'];
3687 $rootLevel = $GLOBALS[
'TCA'][$foreign_table][
'ctrl'][
'rootLevel'];
3688 $fTWHERE = $fieldConfig[
'config'][
'foreign_table_where'];
3689 $fTWHERE = static::replaceMarkersInWhereClause($fTWHERE, $foreign_table, $field, $TSconfig);
3690 $db = static::getDatabaseConnection();
3691 $wgolParts = $db->splitGroupOrderLimit($fTWHERE);
3695 if ($rootLevel == 1 || $rootLevel == -1) {
3696 $pidWhere = $foreign_table .
'.pid' . (($rootLevel == -1) ?
'<>-1' :
'=0');
3697 $queryParts = array(
3698 'SELECT' => self::getCommonSelectFields($foreign_table, $foreign_table .
'.'),
3699 'FROM' => $foreign_table,
3700 'WHERE' => $pidWhere .
' ' . self::deleteClause($foreign_table) .
' ' . $wgolParts[
'WHERE'],
3701 'GROUPBY' => $wgolParts[
'GROUPBY'],
3702 'ORDERBY' => $wgolParts[
'ORDERBY'],
3703 'LIMIT' => $wgolParts[
'LIMIT']
3706 $pageClause = static::getBackendUserAuthentication()->getPagePermsClause(1);
3707 if ($foreign_table !=
'pages') {
3708 $queryParts = array(
3709 'SELECT' => self::getCommonSelectFields($foreign_table, $foreign_table .
'.'),
3710 'FROM' => $foreign_table .
', pages',
3711 'WHERE' =>
'pages.uid=' . $foreign_table .
'.pid
3712 AND pages.deleted=0 ' . self::deleteClause($foreign_table) .
' AND ' . $pageClause .
' ' . $wgolParts[
'WHERE'],
3713 'GROUPBY' => $wgolParts[
'GROUPBY'],
3714 'ORDERBY' => $wgolParts[
'ORDERBY'],
3715 'LIMIT' => $wgolParts[
'LIMIT']
3718 $queryParts = array(
3719 'SELECT' => self::getCommonSelectFields($foreign_table, $foreign_table .
'.'),
3721 'WHERE' =>
'pages.deleted=0
3722 AND ' . $pageClause .
' ' . $wgolParts[
'WHERE'],
3723 'GROUPBY' => $wgolParts[
'GROUPBY'],
3724 'ORDERBY' => $wgolParts[
'ORDERBY'],
3725 'LIMIT' => $wgolParts[
'LIMIT']
3729 return $db->exec_SELECT_queryArray($queryParts);
3751 public static function replaceMarkersInWhereClause($whereClause, $table, $field =
'', $tsConfig = array())
3753 GeneralUtility::logDeprecatedFunction();
3754 $db = static::getDatabaseConnection();
3755 if (strstr($whereClause,
'###REC_FIELD_')) {
3756 $whereClauseParts = explode(
'###REC_FIELD_', $whereClause);
3757 foreach ($whereClauseParts as $key => $value) {
3759 $whereClauseSubarts = explode(
'###', $value, 2);
3760 if (substr($whereClauseParts[0], -1) ===
'\'' && $whereClauseSubarts[1][0] ===
'\'') {
3761 $whereClauseParts[$key] = $db->quoteStr($tsConfig[
'_THIS_ROW'][$whereClauseSubarts[0]], $table) . $whereClauseSubarts[1];
3763 $whereClauseParts[$key] = $db->fullQuoteStr($tsConfig[
'_THIS_ROW'][$whereClauseSubarts[0]], $table) . $whereClauseSubarts[1];
3767 $whereClause = implode(
'', $whereClauseParts);
3771 '###CURRENT_PID###',
3773 '###STORAGE_PID###',
3775 '###PAGE_TSCONFIG_ID###',
3776 '###PAGE_TSCONFIG_IDLIST###',
3777 '###PAGE_TSCONFIG_STR###'
3780 (
int)$tsConfig[
'_CURRENT_PID'],
3781 (
int)$tsConfig[
'_THIS_UID'],
3782 (
int)$tsConfig[
'_STORAGE_PID'],
3783 (
int)$tsConfig[
'_SITEROOT'],
3784 (
int)$tsConfig[$field][
'PAGE_TSCONFIG_ID'],
3785 $db->cleanIntList($tsConfig[$field][
'PAGE_TSCONFIG_IDLIST']),
3786 $db->quoteStr($tsConfig[$field][
'PAGE_TSCONFIG_STR'], $table)
3800 public static function getTCEFORM_TSconfig($table, $row)
3802 self::fixVersioningPid($table, $row);
3804 $typeVal = self::getTCAtypeValue($table, $row);
3806 list($TScID, $cPid) = self::getTSCpid($table, $row[
'uid'], $row[
'pid']);
3808 $tempConf = static::getBackendUserAuthentication()->getTSConfig(
'TCEFORM.' . $table, self::getPagesTSconfig($TScID));
3809 if (is_array($tempConf[
'properties'])) {
3810 foreach ($tempConf[
'properties'] as $key => $val) {
3811 if (is_array($val)) {
3812 $fieldN = substr($key, 0, -1);
3813 $res[$fieldN] = $val;
3814 unset($res[$fieldN][
'types.']);
3815 if ((
string)$typeVal !==
'' && is_array($val[
'types.'][$typeVal .
'.'])) {
3816 ArrayUtility::mergeRecursiveWithOverrule($res[$fieldN], $val[
'types.'][$typeVal .
'.']);
3822 $res[
'_CURRENT_PID'] = $cPid;
3823 $res[
'_THIS_UID'] = $row[
'uid'];
3825 $res[
'_THIS_ROW'] = $row;
3826 $rootLine = self::BEgetRootLine($TScID,
'',
true);
3827 foreach ($rootLine as $rC) {
3828 if (!$res[
'_STORAGE_PID']) {
3829 $res[
'_STORAGE_PID'] = (int)$rC[
'storage_pid'];
3831 if (!$res[
'_SITEROOT']) {
3832 $res[
'_SITEROOT'] = $rC[
'is_siteroot'] ? (int)$rC[
'uid'] : 0;
3851 public static function getTSconfig_pidValue($table, $uid, $pid)
3854 if (MathUtility::canBeInterpretedAsInteger($pid)) {
3855 $thePidValue = (int)$pid;
3857 if ($thePidValue < 0) {
3858 $pidRec = self::getRecord($table, abs($thePidValue),
'pid');
3859 $thePidValue = is_array($pidRec) ? $pidRec[
'pid'] : -2;
3863 $rr = self::getRecord($table, $uid);
3864 $thePidValue = null;
3865 if (is_array($rr)) {
3867 if ($rr[
'pid'] ==
'-1') {
3868 $rr = self::getRecord($table, $rr[
't3ver_oid'],
'pid');
3869 if (is_array($rr)) {
3870 $thePidValue = $rr[
'pid'];
3874 $thePidValue = $rr[
'pid'];
3877 if (!$thePidValue) {
3882 return $thePidValue;
3894 public static function getPidForModTSconfig($table, $uid, $pid)
3896 return $table ===
'pages' && MathUtility::canBeInterpretedAsInteger($uid) ? $uid : $pid;
3911 public static function getTSCpidCached($table, $uid, $pid)
3914 static $firstLevelCache;
3916 if (!is_array($firstLevelCache)) {
3917 $firstLevelCache = array();
3920 $key = $table .
':' . $uid .
':' . $pid;
3921 if (!isset($firstLevelCache[$key])) {
3922 $firstLevelCache[$key] = static::getTSCpid($table, $uid, $pid);
3924 return $firstLevelCache[$key];
3938 public static function getTSCpid($table, $uid, $pid)
3941 $cPid = self::getTSconfig_pidValue($table, $uid, $pid);
3943 $TScID = self::getPidForModTSconfig($table, $uid, $cPid);
3944 return array($TScID, $cPid);
3953 public static function firstDomainRecord($rootLine)
3955 foreach ($rootLine as $row) {
3956 $dRec = self::getRecordsByField(
'sys_domain',
'pid', $row[
'uid'],
' AND redirectTo=\'\' AND hidden=0',
'',
'sorting');
3957 if (is_array($dRec)) {
3958 $dRecord = reset($dRec);
3959 return rtrim($dRecord[
'domainName'],
'/');
3972 public static function getDomainStartPage($domain, $path =
'')
3974 $domain = explode(
':', $domain);
3975 $domain = strtolower(preg_replace(
'/\\.$/',
'', $domain[0]));
3977 $path = trim(preg_replace(
'/\\/[^\\/]*$/',
'', $path));
3980 $db = static::getDatabaseConnection();
3981 $res = $db->exec_SELECTquery(
'sys_domain.*',
'pages,sys_domain',
'
3982 pages.uid=sys_domain.pid
3983 AND sys_domain.hidden=0
3984 AND (sys_domain.domainName=' . $db->fullQuoteStr($domain,
'sys_domain') .
' OR sys_domain.domainName='
3985 . $db->fullQuoteStr(($domain .
'/'),
'sys_domain') .
')' . self::deleteClause(
'pages'),
'',
'',
'1');
3986 $result = $db->sql_fetch_assoc($res);
3987 $db->sql_free_result($res);
4002 public static function RTEsetup($RTEprop, $table, $field, $type =
'')
4004 $thisConfig = is_array($RTEprop[
'default.']) ? $RTEprop[
'default.'] : array();
4005 $thisFieldConf = $RTEprop[
'config.'][$table .
'.'][$field .
'.'];
4006 if (is_array($thisFieldConf)) {
4007 unset($thisFieldConf[
'types.']);
4008 ArrayUtility::mergeRecursiveWithOverrule($thisConfig, $thisFieldConf);
4010 if ($type && is_array($RTEprop[
'config.'][$table .
'.'][$field .
'.'][
'types.'][$type .
'.'])) {
4011 ArrayUtility::mergeRecursiveWithOverrule($thisConfig, $RTEprop[
'config.'][$table .
'.'][$field .
'.'][
'types.'][$type .
'.']);
4023 public static function RTEgetObj()
4025 GeneralUtility::logDeprecatedFunction();
4027 if (!isset($GLOBALS[
'T3_VAR'][
'RTEobj'])) {
4029 $GLOBALS[
'T3_VAR'][
'RTEobj'] = array();
4031 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'RTE_reg'])) {
4032 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'RTE_reg'] as $rteObjCfg) {
4033 $rteObj = GeneralUtility::getUserObj($rteObjCfg[
'objRef']);
4034 if (is_object($rteObj)) {
4035 if ($rteObj->isAvailable()) {
4036 $GLOBALS[
'T3_VAR'][
'RTEobj'] = $rteObj;
4039 $GLOBALS[
'T3_VAR'][
'RTEobj'] = array_merge($GLOBALS[
'T3_VAR'][
'RTEobj'], $rteObj->errorLog);
4044 if (empty($GLOBALS[
'T3_VAR'][
'RTEobj'])) {
4045 $GLOBALS[
'T3_VAR'][
'RTEobj'][] =
'No RTEs configured at all';
4049 return $GLOBALS[
'T3_VAR'][
'RTEobj'];
4059 public static function &softRefParserObj($spKey)
4062 if (!isset($GLOBALS[
'T3_VAR'][
'softRefParser'][$spKey])) {
4064 $GLOBALS[
'T3_VAR'][
'softRefParser'][$spKey] =
'';
4067 if (isset($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'softRefParser'][$spKey])) {
4068 $objRef = $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'softRefParser'][$spKey];
4069 }
elseif (isset($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'softRefParser_GL'][$spKey])) {
4070 GeneralUtility::deprecationLog(
'The hook softRefParser_GL (used with parser key "'
4071 . $spKey .
'") is deprecated since TYPO3 CMS 7 and will be removed in TYPO3 CMS 8');
4072 $objRef = $GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'softRefParser_GL'][$spKey];
4075 $softRefParserObj = GeneralUtility::getUserObj($objRef);
4076 if (is_object($softRefParserObj)) {
4077 $GLOBALS[
'T3_VAR'][
'softRefParser'][$spKey] = $softRefParserObj;
4082 return $GLOBALS[
'T3_VAR'][
'softRefParser'][$spKey];
4090 protected static function getRuntimeCache()
4092 return GeneralUtility::makeInstance(CacheManager::class)->getCache(
'cache_runtime');
4101 public static function explodeSoftRefParserList($parserList)
4103 $runtimeCache = self::getRuntimeCache();
4104 $cacheId =
'backend-softRefList-' . md5($parserList);
4105 if ($runtimeCache->has($cacheId)) {
4106 return $runtimeCache->get($cacheId);
4110 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'softRefParser_GL']) && !empty($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'softRefParser_GL'])) {
4111 GeneralUtility::deprecationLog(
'The hook softRefParser_GL is deprecated since TYPO3 CMS 7 and will be removed in TYPO3 CMS 8');
4112 $parserList = implode(
',', array_keys($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'softRefParser_GL'])) .
',' . $parserList;
4116 if ($parserList ===
'') {
4117 $runtimeCache->set($cacheId,
false);
4122 $keyList = GeneralUtility::trimExplode(
',', $parserList,
true);
4124 foreach ($keyList as $val) {
4126 if (preg_match(
'/^([[:alnum:]_-]+)\\[(.*)\\]$/', $val, $reg)) {
4127 $output[$reg[1]] = GeneralUtility::trimExplode(
';', $reg[2],
true);
4132 $runtimeCache->set($cacheId, $output);
4142 public static function isModuleSetInTBE_MODULES($modName)
4145 foreach ($GLOBALS[
'TBE_MODULES'] as $mkey =>
$list) {
4148 $subList = GeneralUtility::trimExplode(
',',
$list,
true);
4149 foreach ($subList as $skey) {
4150 $loaded[$mkey .
'_' . $skey] = 1;
4154 return $modName && isset($loaded[$modName]);
4166 public static function referenceCount($table, $ref, $msg =
'', $count = null)
4168 if ($count === null) {
4169 $db = static::getDatabaseConnection();
4171 if ($table ==
'_FILE') {
4172 if (GeneralUtility::isFirstPartOfStr($ref, PATH_site)) {
4173 $ref = PathUtility::stripPathSitePrefix($ref);
4174 $condition =
'ref_string=' . $db->fullQuoteStr($ref,
'sys_refindex');
4179 $condition =
'ref_uid=' . (int)$ref;
4181 $count = $db->exec_SELECTcountRows(
'*',
'sys_refindex',
'ref_table=' . $db->fullQuoteStr($table,
'sys_refindex') .
' AND ' . $condition .
' AND deleted=0');
4183 return $count ? ($msg ? sprintf($msg, $count) : $count) :
'';
4194 public static function translationCount($table, $ref, $msg =
'')
4197 if (empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'transForeignTable']) && $GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'] && !$GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerTable']) {
4198 $where = $GLOBALS[
'TCA'][$table][
'ctrl'][
'transOrigPointerField'] .
'=' . (int)$ref .
' AND ' . $GLOBALS[
'TCA'][$table][
'ctrl'][
'languageField'] .
'<>0';
4199 if (!empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'delete'])) {
4200 $where .=
' AND ' . $GLOBALS[
'TCA'][$table][
'ctrl'][
'delete'] .
'=0';
4202 $count = static::getDatabaseConnection()->exec_SELECTcountRows(
'*', $table, $where);
4204 return $count ? ($msg ? sprintf($msg, $count) : $count) :
'';
4223 public static function selectVersionsOfRecord($table, $uid, $fields =
'*', $workspace = 0, $includeDeletedRecords =
false, $row = null)
4226 $outputRows = array();
4227 if ($GLOBALS[
'TCA'][$table] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4228 if (is_array($row) && !$includeDeletedRecords) {
4229 $row[
'_CURRENT_VERSION'] =
true;
4230 $realPid = $row[
'pid'];
4231 $outputRows[] = $row;
4234 $row = BackendUtility::getRecord($table, $uid, $fields,
'', !$includeDeletedRecords);
4237 $row[
'_CURRENT_VERSION'] =
true;
4238 $realPid = $row[
'pid'];
4239 $outputRows[] = $row;
4242 $workspaceSqlPart =
'';
4243 if ($workspace === 0) {
4245 $workspaceSqlPart =
' AND t3ver_wsid=0';
4246 }
elseif ($workspace !== null) {
4248 $workspaceSqlPart =
' AND t3ver_wsid IN (0,' . (int)$workspace .
')';
4251 $rows = static::getDatabaseConnection()->exec_SELECTgetRows(
4254 'pid=-1 AND uid<>' . (
int)$uid .
' AND t3ver_oid=' . (
int)$uid
4256 . ($includeDeletedRecords ?
'' : self::deleteClause($table)),
4261 if (is_array($rows)) {
4262 $outputRows = array_merge($outputRows, $rows);
4265 foreach ($outputRows as $idx => $oRow) {
4266 $outputRows[$idx][
'_REAL_PID'] = $realPid;
4291 public static function fixVersioningPid($table, &$rr, $ignoreWorkspaceMatch =
false)
4293 if (!ExtensionManagementUtility::isLoaded(
'version')) {
4297 if (is_array($rr) && $rr[
'pid'] == -1 && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4299 if (isset($rr[
't3ver_oid']) && isset($rr[
't3ver_wsid'])) {
4301 $oid = $rr[
't3ver_oid'];
4302 $wsid = $rr[
't3ver_wsid'];
4307 $newPidRec = self::getRecord($table, $rr[
'uid'],
't3ver_oid,t3ver_wsid');
4308 if (is_array($newPidRec)) {
4309 $oid = $newPidRec[
't3ver_oid'];
4310 $wsid = $newPidRec[
't3ver_wsid'];
4314 if ($oid && ($ignoreWorkspaceMatch || (
int)$wsid === (
int)static::getBackendUserAuthentication()->workspace)) {
4315 $oidRec = self::getRecord($table, $oid,
'pid');
4316 if (is_array($oidRec)) {
4317 $rr[
'_ORIG_pid'] = $rr[
'pid'];
4318 $rr[
'pid'] = $oidRec[
'pid'];
4322 !isset($rr[
't3ver_state'])
4323 || VersionState::cast($rr[
't3ver_state'])->equals(VersionState::MOVE_POINTER)
4325 $movePlaceholder = self::getMovePlaceholder($table, $oid,
'pid');
4326 if ($movePlaceholder) {
4327 $rr[
'_ORIG_pid'] = $rr[
'pid'];
4328 $rr[
'pid'] = $movePlaceholder[
'pid'];
4352 public static function workspaceOL($table, &$row, $wsid = -99, $unsetMovePointers =
false)
4354 if (!ExtensionManagementUtility::isLoaded(
'version')) {
4359 $previewMovePlaceholders =
true;
4362 $wsid = static::getBackendUserAuthentication()->workspace;
4365 if ($wsid !== 0 && is_array($row)) {
4367 $movePldSwap = null;
4370 if ($previewMovePlaceholders) {
4371 $orig_uid = $row[
'uid'];
4372 $orig_pid = $row[
'pid'];
4373 $movePldSwap = self::movePlhOL($table, $row);
4375 $wsAlt = self::getWorkspaceVersionOfRecord($wsid, $table, $row[
'uid'], implode(
',', array_keys($row)));
4377 if (is_array($wsAlt)) {
4379 if ($previewMovePlaceholders && !$movePldSwap && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS'] && $unsetMovePointers) {
4382 if (!isset($wsAlt[
't3ver_state'])) {
4383 $stateRec = self::getRecord($table, $wsAlt[
'uid'],
't3ver_state');
4384 $versionState = VersionState::cast($stateRec[
't3ver_state']);
4386 $versionState = VersionState::cast($wsAlt[
't3ver_state']);
4388 if ($versionState->equals(VersionState::MOVE_POINTER)) {
4395 if (isset($wsAlt[
'pid'])) {
4397 $wsAlt[
'_ORIG_pid'] = $wsAlt[
'pid'];
4399 $wsAlt[
'pid'] = $row[
'pid'];
4402 $wsAlt[
'_ORIG_uid'] = $wsAlt[
'uid'];
4403 $wsAlt[
'uid'] = $row[
'uid'];
4405 $wsAlt[
'_CSSCLASS'] =
'ver-element';
4411 $row[
'_MOVE_PLH'] =
true;
4412 $row[
'_MOVE_PLH_uid'] = $orig_uid;
4413 $row[
'_MOVE_PLH_pid'] = $orig_pid;
4415 $row[
't3ver_state'] = (string)
new VersionState(VersionState::MOVE_PLACEHOLDER);
4429 public static function movePlhOL($table, &$row)
4431 if ($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4433 if (!isset($row[
't3ver_move_id']) || !isset($row[
't3ver_state'])) {
4434 $moveIDRec = self::getRecord($table, $row[
'uid'],
't3ver_move_id, t3ver_state');
4435 $moveID = $moveIDRec[
't3ver_move_id'];
4436 $versionState = VersionState::cast($moveIDRec[
't3ver_state']);
4438 $moveID = $row[
't3ver_move_id'];
4439 $versionState = VersionState::cast($row[
't3ver_state']);
4442 if ($versionState->equals(VersionState::MOVE_PLACEHOLDER) && $moveID) {
4443 if ($origRow = self::getRecord($table, $moveID, implode(
',', array_keys($row)))) {
4461 public static function getWorkspaceVersionOfRecord($workspace, $table, $uid, $fields =
'*')
4463 if (ExtensionManagementUtility::isLoaded(
'version')) {
4464 if ($workspace !== 0 && $GLOBALS[
'TCA'][$table] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4466 $row = static::getDatabaseConnection()->exec_SELECTgetSingleRow($fields, $table,
'pid=-1 AND ' .
't3ver_oid=' . (
int)$uid .
' AND ' .
't3ver_wsid=' . (
int)$workspace . self::deleteClause($table));
4467 if (is_array($row)) {
4483 public static function getLiveVersionOfRecord($table, $uid, $fields =
'*')
4485 $liveVersionId = self::getLiveVersionIdOfRecord($table, $uid);
4486 if (is_null($liveVersionId) ===
false) {
4487 return self::getRecord($table, $liveVersionId, $fields);
4499 public static function getLiveVersionIdOfRecord($table, $uid)
4501 $liveVersionId = null;
4502 if (self::isTableWorkspaceEnabled($table)) {
4503 $currentRecord = self::getRecord($table, $uid,
'pid,t3ver_oid');
4504 if (is_array($currentRecord) && $currentRecord[
'pid'] == -1) {
4505 $liveVersionId = $currentRecord[
't3ver_oid'];
4508 return $liveVersionId;
4518 public static function versioningPlaceholderClause($table)
4520 if ($GLOBALS[
'TCA'][$table] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4521 $currentWorkspace = (int)static::getBackendUserAuthentication()->workspace;
4522 return ' AND (' . $table .
'.t3ver_state <= ' .
new VersionState(VersionState::DEFAULT_STATE) .
' OR ' . $table .
'.t3ver_wsid = ' . $currentWorkspace .
')';
4534 public static function getWorkspaceWhereClause($table, $workspaceId = null)
4537 if (self::isTableWorkspaceEnabled($table)) {
4538 if (is_null($workspaceId)) {
4539 $workspaceId = static::getBackendUserAuthentication()->workspace;
4541 $workspaceId = (int)$workspaceId;
4542 $pidOperator = $workspaceId === 0 ?
'!=' :
'=';
4543 $whereClause =
' AND ' . $table .
'.t3ver_wsid=' . $workspaceId .
' AND ' . $table .
'.pid' . $pidOperator .
'-1';
4545 return $whereClause;
4556 public static function countVersionsOfRecordsOnPage($workspace, $pageId)
4558 GeneralUtility::logDeprecatedFunction();
4559 if ((
int)$workspace === 0) {
4563 foreach ($GLOBALS[
'TCA'] as $tableName => $cfg) {
4564 if ($tableName !=
'pages' && $cfg[
'ctrl'][
'versioningWS']) {
4565 $movePointer =
new VersionState(VersionState::MOVE_POINTER);
4566 $joinStatement =
'(A.t3ver_oid=B.uid AND A.t3ver_state<>' . $movePointer
4567 .
' OR A.t3ver_oid=B.t3ver_move_id AND A.t3ver_state=' . $movePointer .
')';
4571 $output[$tableName] = static::getDatabaseConnection()->exec_SELECTgetRows(
4572 'B.uid as live_uid, A.uid as offline_uid',
4573 $tableName .
' A,' . $tableName .
' B',
4574 'A.pid=-1' .
' AND B.pid=' . (
int)$pageId
4575 .
' AND A.t3ver_wsid=' . (
int)$workspace .
' AND ' . $joinStatement
4576 . self::deleteClause($tableName,
'A') . self::deleteClause($tableName,
'B')
4578 if (!is_array($output[$tableName]) || empty($output[$tableName])) {
4579 unset($output[$tableName]);
4583 if (is_array($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'countVersionsOfRecordsOnPage'])) {
4585 $parameters = array(
4586 'workspace' =>
'workspace',
4587 'pageId' => $pageId,
4588 'versions' => &$output,
4590 foreach ($GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_befunc.php'][
'countVersionsOfRecordsOnPage'] as $hookFunction) {
4591 GeneralUtility::callUserFunction($hookFunction, $parameters, $reference);
4604 public static function wsMapId($table, $uid)
4606 $wsRec = self::getWorkspaceVersionOfRecord(static::getBackendUserAuthentication()->workspace, $table, $uid,
'uid');
4607 return is_array($wsRec) ? $wsRec[
'uid'] : $uid;
4619 public static function getMovePlaceholder($table, $uid, $fields =
'*', $workspace = null)
4621 if ($workspace === null) {
4622 $workspace = static::getBackendUserAuthentication()->workspace;
4624 if ((
int)$workspace !== 0 && $GLOBALS[
'TCA'][$table] && $GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
4626 $row = static::getDatabaseConnection()->exec_SELECTgetSingleRow(
4629 'pid<>-1 AND t3ver_state=' .
new VersionState(VersionState::MOVE_PLACEHOLDER) .
' AND t3ver_move_id='
4630 . (
int)$uid .
' AND t3ver_wsid=' . (
int)$workspace . self::deleteClause($table)
4632 if (is_array($row)) {
4654 public static function TYPO3_copyRightNotice()
4657 $loginCopyrightWarrantyProvider = strip_tags(trim($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'loginCopyrightWarrantyProvider']));
4658 $loginCopyrightWarrantyURL = strip_tags(trim($GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'loginCopyrightWarrantyURL']));
4660 $lang = static::getLanguageService();
4662 if (strlen($loginCopyrightWarrantyProvider) >= 2 && strlen($loginCopyrightWarrantyURL) >= 10) {
4663 $warrantyNote = sprintf(
$lang->sL(
'LLL:EXT:lang/locallang_login.xlf:warranty.by'), htmlspecialchars($loginCopyrightWarrantyProvider),
'<a href="' . htmlspecialchars($loginCopyrightWarrantyURL) .
'" target="_blank">',
'</a>');
4665 $warrantyNote = sprintf(
$lang->sL(
'LLL:EXT:lang/locallang_login.xlf:no.warranty'),
'<a href="' . TYPO3_URL_LICENSE .
'" target="_blank">',
'</a>');
4667 $cNotice =
'<a href="' . TYPO3_URL_GENERAL .
'" target="_blank">' .
4668 $lang->sL(
'LLL:EXT:lang/locallang_login.xlf:typo3.cms') .
'</a>. ' .
4669 $lang->sL(
'LLL:EXT:lang/locallang_login.xlf:copyright') .
' © ' . htmlspecialchars(TYPO3_copyright_year) .
' Kasper Skårhøj. ' .
4670 $lang->sL(
'LLL:EXT:lang/locallang_login.xlf:extension.copyright') .
' ' .
4671 sprintf(
$lang->sL(
'LLL:EXT:lang/locallang_login.xlf:details.link'), (
'<a href="' . TYPO3_URL_GENERAL .
'" target="_blank">' . TYPO3_URL_GENERAL .
'</a>')) .
' ' .
4672 strip_tags($warrantyNote,
'<a>') .
' ' .
4673 sprintf(
$lang->sL(
'LLL:EXT:lang/locallang_login.xlf:free.software'), (
'<a href="' . TYPO3_URL_LICENSE .
'" target="_blank">'),
'</a> ') .
4674 $lang->sL(
'LLL:EXT:lang/locallang_login.xlf:keep.notice');
4685 public static function getPathType_web_nonweb($path)
4687 GeneralUtility::logDeprecatedFunction();
4688 return GeneralUtility::isFirstPartOfStr($path, GeneralUtility::getIndpEnv(
'TYPO3_DOCUMENT_ROOT')) ?
'web' :
'';
4698 public static function ADMCMD_previewCmds($pageInfo)
4702 if ($pageInfo[
'fe_group'] > 0) {
4703 $simUser =
'&ADMCMD_simUser=' . $pageInfo[
'fe_group'];
4704 }
elseif ((
int)$pageInfo[
'fe_group'] === -2) {
4707 $sysPage = GeneralUtility::makeInstance(PageRepository::class);
4708 $activeFeGroupRow = BackendUtility::getRecordRaw(
'fe_groups',
'1=1' . $sysPage->enableFields(
'fe_groups'),
'uid');
4709 if (!empty($activeFeGroupRow)) {
4710 $simUser =
'&ADMCMD_simUser=' . $activeFeGroupRow[
'uid'];
4713 if ($pageInfo[
'starttime'] > $GLOBALS[
'EXEC_TIME']) {
4714 $simTime =
'&ADMCMD_simTime=' . $pageInfo[
'starttime'];
4716 if ($pageInfo[
'endtime'] < $GLOBALS[
'EXEC_TIME'] && $pageInfo[
'endtime'] != 0) {
4717 $simTime =
'&ADMCMD_simTime=' . ($pageInfo[
'endtime'] - 1);
4719 return $simUser . $simTime;
4730 public static function processParams($params)
4732 $paramArr = array();
4733 $lines = explode(LF, $params);
4734 foreach ($lines as $val) {
4737 $pair = explode(
'=', $val, 2);
4738 $paramArr[trim($pair[0])] = trim($pair[1]);
4750 public static function getBackendScript($interface =
'')
4753 $interface = static::getBackendUserAuthentication()->uc[
'interfaceSetup'];
4755 switch ($interface) {
4761 $script = self::getModuleUrl(
'main');
4772 public static function isTableWorkspaceEnabled($table)
4774 return !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']);
4786 public static function isTableMovePlaceholderAware($table)
4788 return self::isTableWorkspaceEnabled($table);
4798 public static function getTcaFieldConfiguration($table, $field)
4800 $configuration = array();
4801 if (isset($GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'])) {
4802 $configuration = $GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
4804 return $configuration;
4815 public static function isWebMountRestrictionIgnored($table)
4817 return !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'security'][
'ignoreWebMountRestriction']);
4828 public static function isRootLevelRestrictionIgnored($table)
4830 return !empty($GLOBALS[
'TCA'][$table][
'ctrl'][
'security'][
'ignoreRootLevelRestriction']);
4840 public static function shortcutExists(
$url)
4842 $statement = self::getDatabaseConnection()->prepare_SELECTquery(
4845 'userid = :userid AND url = :url'
4848 $statement->bindValues([
4849 ':userid' => self::getBackendUserAuthentication()->user[
'uid'],
4854 $statement->execute();
4855 $rows = $statement->fetch(PreparedStatement::FETCH_ASSOC);
4858 return !empty($rows);
4866 protected static function getSignalSlotDispatcher()
4868 return GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
4880 protected static function emitGetPagesTSconfigPreIncludeSignal(array $TSdataArray, $id, array $rootLine, $returnPartArray)
4882 $signalArguments = static::getSignalSlotDispatcher()->dispatch(__CLASS__,
'getPagesTSconfigPreInclude', array($TSdataArray, $id, $rootLine, $returnPartArray));
4883 return $signalArguments[0];
4889 protected static function getDatabaseConnection()
4891 return $GLOBALS[
'TYPO3_DB'];
4897 protected static function getLanguageService()
4899 return $GLOBALS[
'LANG'];
4905 protected static function getBackendUserAuthentication()
4907 return $GLOBALS[
'BE_USER'];
4913 protected static function getDocumentTemplate()
4915 return $GLOBALS[
'TBE_TEMPLATE'];