361 'tt_content' => array(
363 'titleTexts' =>
'titleText',
364 'description' =>
'imagecaption',
365 'links' =>
'image_link',
366 'alternativeTexts' =>
'altText' 369 'description' =>
'imagecaption',
375 'pages_language_overlay' => array(
403 $this->compress = function_exists(
'gzcompress');
406 $this->fileadminFolderName = !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir']) ? rtrim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
'/') :
'fileadmin';
421 if (is_array($this->softrefCfg)) {
422 foreach ($this->softrefCfg as $key => $value) {
423 if (!strlen($value[
'mode'])) {
424 unset($this->softrefCfg[$key]);
430 $this->dat[
'header'][
'XMLversion'] =
'1.0';
432 $this->dat[
'header'][
'meta'] = array();
451 $this->dat[
'header'][
'charset'] = $charset;
466 public function setMetaData($title, $description, $notes, $packager_username, $packager_name, $packager_email) {
467 $this->dat[
'header'][
'meta'] = array(
469 'description' => $description,
471 'packager_username' => $packager_username,
472 'packager_name' => $packager_name,
473 'packager_email' => $packager_email,
474 'TYPO3_version' => TYPO3_version,
475 'created' => strftime(
'%A %e. %B %Y',
$GLOBALS[
'EXEC_TIME'])
487 if (@is_file($imgFilepath)) {
488 $imgInfo = @getimagesize($imgFilepath);
489 if (is_array($imgInfo)) {
491 $this->dat[
'header'][
'thumbnail'] = array(
492 'imgInfo' => $imgInfo,
493 'content' => $fileContent,
494 'filesize' => strlen($fileContent),
495 'filemtime' => filemtime($imgFilepath),
528 if (is_array($idH)) {
529 foreach ($idH as $k => $v) {
530 if ($this->excludeMap[
'pages:' . $idH[$k][
'uid']]) {
532 } elseif (is_array($idH[$k][
'subrow'])) {
550 if (is_array($idH)) {
551 $idH = array_reverse($idH);
552 foreach ($idH as $k => $v) {
553 $a[$v[
'uid']] = $v[
'uid'];
554 if (is_array($v[
'subrow'])) {
573 if (is_array($idH)) {
574 $idH = array_reverse($idH);
575 foreach ($idH as $k => $v) {
576 $a[$v[
'uid']] = $pid;
577 if (is_array($v[
'subrow'])) {
597 foreach ($recordTypesIncludeFields as $table => $fields) {
598 if (!is_array($fields)) {
599 throw new \TYPO3\CMS\Core\Exception(
'The include fields for record type ' . htmlspecialchars($table) .
' are not defined by an array.', 1391440658);
613 $this->recordTypesIncludeFields[$table] = $fields;
628 if ((
string)$table !==
'' && is_array($row) && $row[
'uid'] > 0 && !$this->excludeMap[($table .
':' . $row[
'uid'])]) {
629 if ($this->
checkPID($table ===
'pages' ? $row[
'uid'] : $row[
'pid'])) {
630 if (!isset($this->dat[
'records'][($table .
':' . $row[
'uid'])])) {
633 $headerInfo = array();
634 $headerInfo[
'uid'] = $row[
'uid'];
635 $headerInfo[
'pid'] = $row[
'pid'];
637 $headerInfo[
'size'] = strlen(serialize($row));
638 if ($relationLevel) {
639 $headerInfo[
'relationLevel'] = $relationLevel;
642 if ($headerInfo[
'size'] < $this->maxRecordSize) {
644 $this->dat[
'header'][
'records'][$table][$row[
'uid']] = $headerInfo;
646 $this->dat[
'header'][
'pid_lookup'][$row[
'pid']][$table][$row[
'uid']] = 1;
650 $refIndexObj->WSOL = TRUE;
651 $relations = $refIndexObj->getRelations($table, $row);
655 $this->dat[
'records'][$table .
':' . $row[
'uid']] = array();
656 $this->dat[
'records'][$table .
':' . $row[
'uid']][
'data'] = $row;
657 $this->dat[
'records'][$table .
':' . $row[
'uid']][
'rels'] = $relations;
658 $this->errorLog = array_merge($this->errorLog, $refIndexObj->errorLog);
661 $this->dat[
'header'][
'records'][$table][$row[
'uid']][
'rels'] = $this->
flatDBrels($this->dat[
'records'][$table .
':' . $row[
'uid']][
'rels']);
663 $this->dat[
'header'][
'records'][$table][$row[
'uid']][
'softrefs'] = $this->
flatSoftRefs($this->dat[
'records'][$table .
':' . $row[
'uid']][
'rels']);
668 $this->
error(
'Record ' . $table .
':' . $row[
'uid'] .
' already added.');
671 $this->
error(
'Record ' . $table .
':' . $row[
'uid'] .
' was outside your DB mounts!');
684 foreach ($relations as $field => $relation) {
685 if (isset($relation[
'type']) && $relation[
'type'] ===
'file') {
686 foreach ($relation[
'newValueFiles'] as $key => $fileRelationData) {
687 $absoluteFilePath = $fileRelationData[
'ID_absFile'];
690 $relations[$field][
'newValueFiles'][$key][
'ID'] = md5($relatedFilePath);
694 if ($relation[
'type'] ==
'flex') {
695 if (is_array($relation[
'flexFormRels'][
'file'])) {
696 foreach ($relation[
'flexFormRels'][
'file'] as $key => $subList) {
697 foreach ($subList as $subKey => $fileRelationData) {
698 $absoluteFilePath = $fileRelationData[
'ID_absFile'];
701 $relations[$field][
'flexFormRels'][
'file'][$key][$subKey][
'ID'] = md5($relatedFilePath);
721 $fixedRelations = array();
722 foreach ($relations as $field => $relation) {
723 $newRelation = $relation;
724 if (isset($newRelation[
'type']) && $newRelation[
'type'] ===
'db') {
725 foreach ($newRelation[
'itemArray'] as $key => $dbRelationData) {
726 if ($dbRelationData[
'table'] ===
'sys_file') {
727 if (isset($newRelation[
'softrefs'][
'keys'][
'typolink'])) {
728 foreach ($newRelation[
'softrefs'][
'keys'][
'typolink'] as $softrefKey => $softRefData) {
729 if ($softRefData[
'subst'][
'type'] ===
'file') {
731 if ($file instanceof \
TYPO3\CMS\Core\Resource\File) {
732 if ($file->getUid() == $dbRelationData[
'id']) {
733 unset($newRelation[
'softrefs'][
'keys'][
'typolink'][$softrefKey]);
738 if (empty($newRelation[
'softrefs'][
'keys'][
'typolink'])) {
739 unset($newRelation[
'softrefs']);
745 $fixedRelations[$field] = $newRelation;
747 return $fixedRelations;
765 if (is_array($this->dat[
'records'])) {
766 foreach ($this->dat[
'records'] as $k => $value) {
767 if (is_array($this->dat[
'records'][$k])) {
768 foreach ($this->dat[
'records'][$k][
'rels'] as $fieldname => $vR) {
770 if ($vR[
'type'] ==
'db') {
771 foreach ($vR[
'itemArray'] as $fI) {
776 if ($vR[
'type'] ==
'flex') {
778 if (is_array($vR[
'flexFormRels'][
'db'])) {
779 foreach ($vR[
'flexFormRels'][
'db'] as $subList) {
780 foreach ($subList as $fI) {
786 if (is_array($vR[
'flexFormRels'][
'softrefs'])) {
787 foreach ($vR[
'flexFormRels'][
'softrefs'] as $subList) {
788 foreach ($subList[
'keys'] as $spKey => $elements) {
789 foreach ($elements as $el) {
790 if ($el[
'subst'][
'type'] ===
'db' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
791 list($tempTable, $tempUid) = explode(
':', $el[
'subst'][
'recordRef']);
793 'table' => $tempTable,
804 if (is_array($vR[
'softrefs'][
'keys'])) {
805 foreach ($vR[
'softrefs'][
'keys'] as $spKey => $elements) {
806 foreach ($elements as $el) {
807 if ($el[
'subst'][
'type'] ===
'db' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
808 list($tempTable, $tempUid) = explode(
':', $el[
'subst'][
'recordRef']);
810 'table' => $tempTable,
822 $this->
error(
'There were no records available.');
826 foreach ($addR as $fI) {
828 $row = BackendUtility::getRecord($fI[
'table'], $fI[
'id']);
829 if (is_array($row)) {
835 $rId = $fI[
'table'] .
':' . $fI[
'id'];
836 if (!isset($this->dat[
'records'][$rId])) {
837 $this->dat[
'records'][$rId] =
'NOT_FOUND';
838 $this->
error(
'Relation record ' . $rId .
' was not found!');
858 $rId = $fI[
'table'] .
':' . $fI[
'id'];
860 if (!isset($this->dat[
'records'][$rId])) {
877 if (is_array($this->dat[
'records'])) {
878 foreach ($this->dat[
'records'] as $k => $value) {
879 if (isset($this->dat[
'records'][$k][
'rels']) && is_array($this->dat[
'records'][$k][
'rels'])) {
880 foreach ($this->dat[
'records'][$k][
'rels'] as $fieldname => $vR) {
882 if ($vR[
'type'] ==
'file') {
883 foreach ($vR[
'newValueFiles'] as $key => $fI) {
886 unset($this->dat[
'records'][$k][
'rels'][$fieldname][
'newValueFiles'][$key][
'ID_absFile']);
890 if ($vR[
'type'] ==
'flex') {
891 if (is_array($vR[
'flexFormRels'][
'file'])) {
892 foreach ($vR[
'flexFormRels'][
'file'] as $key => $subList) {
893 foreach ($subList as $subKey => $fI) {
896 unset($this->dat[
'records'][$k][
'rels'][$fieldname][
'flexFormRels'][
'file'][$key][$subKey][
'ID_absFile']);
901 if (is_array($vR[
'flexFormRels'][
'softrefs'])) {
902 foreach ($vR[
'flexFormRels'][
'softrefs'] as $key => $subList) {
903 foreach ($subList[
'keys'] as $spKey => $elements) {
904 foreach ($elements as $subKey => $el) {
905 if ($el[
'subst'][
'type'] ===
'file' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
908 $ID = md5($el[
'subst'][
'relFileName']);
910 if (!$this->dat[
'files'][$ID]) {
913 'ID_absFile' => $ID_absFile,
915 'relFileName' => $el[
'subst'][
'relFileName']
919 $this->dat[
'records'][$k][
'rels'][$fieldname][
'flexFormRels'][
'softrefs'][$key][
'keys'][$spKey][$subKey][
'file_ID'] = $ID;
928 if (is_array($vR[
'softrefs'][
'keys'])) {
929 foreach ($vR[
'softrefs'][
'keys'] as $spKey => $elements) {
930 foreach ($elements as $subKey => $el) {
931 if ($el[
'subst'][
'type'] ===
'file' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
934 $ID = md5($el[
'subst'][
'relFileName']);
936 if (!$this->dat[
'files'][$ID]) {
939 'ID_absFile' => $ID_absFile,
941 'relFileName' => $el[
'subst'][
'relFileName']
945 $this->dat[
'records'][$k][
'rels'][$fieldname][
'softrefs'][
'keys'][$spKey][$subKey][
'file_ID'] = $ID;
955 $this->
error(
'There were no records available.');
965 if (!isset($this->dat[
'header'][
'records'][
'sys_file']) || !is_array($this->dat[
'header'][
'records'][
'sys_file'])) {
968 foreach ($this->dat[
'header'][
'records'][
'sys_file'] as $sysFileUid => $_) {
969 $recordData = $this->dat[
'records'][
'sys_file:' . $sysFileUid][
'data'];
987 $fileContent = $file->getContents();
989 $this->
error(
'Error when trying to add file ' . $file->getCombinedIdentifier() .
': ' . $e->getMessage());
992 $fileUid = $file->getUid();
993 $fileInfo = $file->getStorage()->getFileInfo($file);
995 $fileSize = (string)$fileInfo[
'size'];
996 if ($fileSize !== $file->getProperty(
'size')) {
997 $this->
error(
'File size of ' . $file->getCombinedIdentifier() .
' is not up-to-date in index! File added with current size.');
998 $this->dat[
'records'][
'sys_file:' . $fileUid][
'data'][
'size'] = $fileSize;
1000 $fileSha1 = $file->getStorage()->hashFile($file,
'sha1');
1001 if ($fileSha1 !== $file->getProperty(
'sha1')) {
1002 $this->
error(
'File sha1 hash of ' . $file->getCombinedIdentifier() .
' is not up-to-date in index! File added on current sha1.');
1003 $this->dat[
'records'][
'sys_file:' . $fileUid][
'data'][
'sha1'] = $fileSha1;
1007 $fileRec[
'filesize'] = $fileSize;
1008 $fileRec[
'filename'] = $file->getProperty(
'name');
1009 $fileRec[
'filemtime'] = $file->getProperty(
'modification_date');
1012 $fileId = md5($file->getStorage()->getUid() .
':' . $file->getProperty(
'identifier_hash'));
1015 $this->dat[
'header'][
'files_fal'][$fileId] = $fileRec;
1018 $fileRec[
'content'] = $fileContent;
1019 $fileRec[
'content_sha1'] = $fileSha1;
1021 $this->dat[
'files_fal'][$fileId] = $fileRec;
1035 if (@is_file($fI[
'ID_absFile'])) {
1036 if (filesize($fI[
'ID_absFile']) < $this->maxFileSize) {
1037 $fileInfo = stat($fI[
'ID_absFile']);
1039 $fileRec[
'filesize'] = $fileInfo[
'size'];
1041 $fileRec[
'filemtime'] = $fileInfo[
'mtime'];
1045 $fileRec[
'record_ref'] = $recordRef .
'/' . $fieldname;
1047 if ($fI[
'relFileName']) {
1048 $fileRec[
'relFileName'] = $fI[
'relFileName'];
1051 $this->dat[
'header'][
'files'][$fI[
'ID']] = $fileRec;
1053 if ($recordRef && $recordRef !==
'_SOFTREF_') {
1054 $refParts = explode(
':', $recordRef, 2);
1055 if (!is_array($this->dat[
'header'][
'records'][$refParts[0]][$refParts[1]][
'filerefs'])) {
1056 $this->dat[
'header'][
'records'][$refParts[0]][$refParts[1]][
'filerefs'] = array();
1058 $this->dat[
'header'][
'records'][$refParts[0]][$refParts[1]][
'filerefs'][] = $fI[
'ID'];
1062 $fileRec[
'content_md5'] = md5($fileRec[
'content']);
1063 $this->dat[
'files'][$fI[
'ID']] = $fileRec;
1065 if ($recordRef ===
'_SOFTREF_') {
1069 if (@is_file($RTEoriginal_absPath)) {
1070 $RTEoriginal_ID = md5($RTEoriginal_absPath);
1071 $fileInfo = stat($RTEoriginal_absPath);
1073 $fileRec[
'filesize'] = $fileInfo[
'size'];
1075 $fileRec[
'filemtime'] = $fileInfo[
'mtime'];
1076 $fileRec[
'record_ref'] =
'_RTE_COPY_ID:' . $fI[
'ID'];
1077 $this->dat[
'header'][
'files'][$fI[
'ID']][
'RTE_ORIG_ID'] = $RTEoriginal_ID;
1079 $this->dat[
'header'][
'files'][$RTEoriginal_ID] = $fileRec;
1082 $fileRec[
'content_md5'] = md5($fileRec[
'content']);
1083 $this->dat[
'files'][$RTEoriginal_ID] = $fileRec;
1091 if ($this->includeExtFileResources &&
GeneralUtility::inList($this->extFileResourceExtensions, strtolower($html_fI[
'extension']))) {
1092 $uniquePrefix =
'###' . md5(
$GLOBALS[
'EXEC_TIME']) .
'###';
1093 if (strtolower($html_fI[
'extension']) ===
'css') {
1094 $prefixedMedias = explode($uniquePrefix, preg_replace(
'/(url[[:space:]]*\\([[:space:]]*["\']?)([^"\')]*)(["\']?[[:space:]]*\\))/i',
'\\1' . $uniquePrefix .
'\\2' . $uniquePrefix .
'\\3', $fileRec[
'content']));
1098 $prefixedMedias = explode($uniquePrefix, $htmlParser->prefixResourcePath($uniquePrefix, $fileRec[
'content'], array(), $uniquePrefix));
1100 $htmlResourceCaptured = FALSE;
1101 foreach ($prefixedMedias as $k => $v) {
1106 $htmlResourceCaptured = TRUE;
1107 $EXTres_ID = md5($EXTres_absPath);
1108 $this->dat[
'header'][
'files'][$fI[
'ID']][
'EXT_RES_ID'][] = $EXTres_ID;
1109 $prefixedMedias[$k] =
'{EXT_RES_ID:' . $EXTres_ID .
'}';
1111 if (!isset($this->dat[
'header'][
'files'][$EXTres_ID])) {
1112 $fileInfo = stat($EXTres_absPath);
1114 $fileRec[
'filesize'] = $fileInfo[
'size'];
1116 $fileRec[
'filemtime'] = $fileInfo[
'mtime'];
1117 $fileRec[
'record_ref'] =
'_EXT_PARENT_:' . $fI[
'ID'];
1119 $fileRec[
'parentRelFileName'] = $v;
1121 $this->dat[
'header'][
'files'][$EXTres_ID] = $fileRec;
1124 $fileRec[
'content_md5'] = md5($fileRec[
'content']);
1125 $this->dat[
'files'][$EXTres_ID] = $fileRec;
1130 if ($htmlResourceCaptured) {
1131 $this->dat[
'files'][$fI[
'ID']][
'tokenizedContent'] = implode(
'', $prefixedMedias);
1139 $this->
error($fI[
'ID_absFile'] .
' was not a file! Skipping.');
1153 foreach ($dbrels as
$dat) {
1154 if ($dat[
'type'] ==
'db') {
1155 foreach ($dat[
'itemArray'] as $i) {
1156 $list[$i[
'table'] .
':' . $i[
'id']] = $i;
1159 if ($dat[
'type'] ==
'flex' && is_array($dat[
'flexFormRels'][
'db'])) {
1160 foreach ($dat[
'flexFormRels'][
'db'] as $subList) {
1161 foreach ($subList as $i) {
1162 $list[$i[
'table'] .
':' . $i[
'id']] = $i;
1179 foreach ($dbrels as $field =>
$dat) {
1180 if (is_array(
$dat[
'softrefs'][
'keys'])) {
1181 foreach (
$dat[
'softrefs'][
'keys'] as $spKey => $elements) {
1182 if (is_array($elements)) {
1183 foreach ($elements as $subKey => $el) {
1184 $lKey = $field .
':' . $spKey .
':' . $subKey;
1185 $list[$lKey] = array_merge(array(
'field' => $field,
'spKey' => $spKey), $el);
1187 if ($el[
'subst'] && $el[
'subst'][
'relFileName']) {
1188 $list[$lKey][
'file_ID'] = md5(PATH_site . $el[
'subst'][
'relFileName']);
1194 if (
$dat[
'type'] ==
'flex' && is_array(
$dat[
'flexFormRels'][
'softrefs'])) {
1195 foreach (
$dat[
'flexFormRels'][
'softrefs'] as $structurePath => $subSoftrefs) {
1196 if (is_array($subSoftrefs[
'keys'])) {
1197 foreach ($subSoftrefs[
'keys'] as $spKey => $elements) {
1198 foreach ($elements as $subKey => $el) {
1199 $lKey = $field .
':' . $structurePath .
':' . $spKey .
':' . $subKey;
1200 $list[$lKey] = array_merge(array(
'field' => $field,
'spKey' => $spKey,
'structurePath' => $structurePath), $el);
1202 if ($el[
'subst'] && $el[
'subst'][
'relFileName']) {
1203 $list[$lKey][
'file_ID'] = md5(PATH_site . $el[
'subst'][
'relFileName']);
1223 if (isset($this->recordTypesIncludeFields[$table])) {
1224 $includeFields = array_unique(array_merge(
1225 $this->recordTypesIncludeFields[$table],
1226 $this->defaultRecordIncludeFields
1229 foreach ($row as $key => $value) {
1230 if (in_array($key, $includeFields)) {
1231 $newRow[$key] = $value;
1253 if ($type ==
'xml') {
1279 'alt_options' => array(
1281 'disableTypeAttrib' => TRUE,
1282 'clearStackPath' => TRUE,
1283 'parentTagMap' => array(
1285 'files_fal' =>
'file',
1286 'records' =>
'table',
1288 'rec:rels' =>
'relations',
1289 'relations' =>
'element',
1290 'filerefs' =>
'file',
1291 'pid_lookup' =>
'page_contents',
1292 'header:relStaticTables' =>
'static_tables',
1293 'static_tables' =>
'tablename',
1294 'excludeMap' =>
'item',
1295 'softrefCfg' =>
'softrefExportMode',
1296 'extensionDependencies' =>
'extkey',
1297 'softrefs' =>
'softref_element' 1299 'alt_options' => array(
1300 '/pagetree' => array(
1301 'disableTypeAttrib' => TRUE,
1302 'useIndexTagForNum' =>
'node',
1303 'parentTagMap' => array(
1304 'node:subrow' =>
'node' 1307 '/pid_lookup/page_contents' => array(
1308 'disableTypeAttrib' => TRUE,
1309 'parentTagMap' => array(
1310 'page_contents' =>
'table' 1312 'grandParentTagMap' => array(
1313 'page_contents/table' =>
'item' 1318 '/records' => array(
1319 'disableTypeAttrib' => TRUE,
1320 'parentTagMap' => array(
1321 'records' =>
'tablerow',
1322 'tablerow:data' =>
'fieldlist',
1323 'tablerow:rels' =>
'related',
1324 'related' =>
'field',
1325 'field:itemArray' =>
'relations',
1326 'field:newValueFiles' =>
'filerefs',
1327 'field:flexFormRels' =>
'flexform',
1328 'relations' =>
'element',
1329 'filerefs' =>
'file',
1330 'flexform:db' =>
'db_relations',
1331 'flexform:file' =>
'file_relations',
1332 'flexform:softrefs' =>
'softref_relations',
1333 'softref_relations' =>
'structurePath',
1334 'db_relations' =>
'path',
1335 'file_relations' =>
'path',
1336 'path' =>
'element',
1337 'keys' =>
'softref_key',
1338 'softref_key' =>
'softref_element' 1340 'alt_options' => array(
1341 '/records/tablerow/fieldlist' => array(
1342 'useIndexTagForAssoc' =>
'field' 1347 'disableTypeAttrib' => TRUE,
1348 'parentTagMap' => array(
1352 '/files_fal' => array(
1353 'disableTypeAttrib' => TRUE,
1354 'parentTagMap' => array(
1355 'files_fal' =>
'file' 1361 $charset = $this->dat[
'header'][
'charset'] ?:
'utf-8';
1362 $XML =
'<?xml version="1.0" encoding="' . $charset .
'" standalone="yes" ?>' . LF;
1387 $data = gzcompress($data);
1389 return md5($data) .
':' . (
$compress ?
'1' :
'0') .
':' . str_pad(strlen($data), 10,
'0', STR_PAD_LEFT) .
':' . $data .
':';
1403 $this->doesImport = 1;
1406 $this->import_mapId = array();
1407 $this->import_newId = array();
1408 $this->import_newId_pids = array();
1410 $this->unlinkFiles = array();
1411 $this->alternativeFileName = array();
1412 $this->alternativeFilePath = array();
1414 $this->initializeStorageObjects();
1422 protected function initializeStorageObjects() {
1425 $this->storageObjects = $storageRepository->findAll();
1440 $this->writeSysFileStorageRecords();
1442 $this->writeSysFileRecords();
1455 $this->processSoftReferences();
1457 if ($this->legacyImport) {
1467 protected function writeSysFileStorageRecords() {
1468 if (!isset($this->dat[
'header'][
'records'][
'sys_file_storage'])) {
1471 $sysFileStorageUidsToBeResetToDefaultStorage = array();
1472 foreach ($this->dat[
'header'][
'records'][
'sys_file_storage'] as $sysFileStorageUid => $_) {
1473 $storageRecord = $this->dat[
'records'][
'sys_file_storage:' . $sysFileStorageUid][
'data'];
1475 if ($storageRecord[
'driver'] ===
'Local' && $storageRecord[
'is_writable'] && $storageRecord[
'is_online']) {
1476 $useThisStorageUidInsteadOfTheOneInImport = 0;
1478 foreach ($this->storageObjects as $localStorage) {
1480 if ($localStorage->getDriverType() ===
'Local' && $localStorage->isWritable() && $localStorage->isOnline()) {
1483 $localStorageRecordConfiguration = $localStorage->getConfiguration();
1484 if ($storageRecordConfiguration[
'pathType'] == $localStorageRecordConfiguration[
'pathType'] && $storageRecordConfiguration[
'basePath'] == $localStorageRecordConfiguration[
'basePath']) {
1486 $useThisStorageUidInsteadOfTheOneInImport = $localStorage->getUid();
1491 if ($useThisStorageUidInsteadOfTheOneInImport > 0) {
1493 $this->import_mapId[
'sys_file_storage'][$sysFileStorageUid] = $useThisStorageUidInsteadOfTheOneInImport;
1496 $this->
addSingle(
'sys_file_storage', $sysFileStorageUid, 0);
1503 $this->
addSingle(
'sys_file_storage', $sysFileStorageUid, 0);
1504 $sysFileStorageUidsToBeResetToDefaultStorage[] = $sysFileStorageUid;
1512 $tce->reverseOrder = 1;
1513 $tce->isImporting = TRUE;
1514 $tce->start($this->import_data, array());
1515 $tce->process_datamap();
1518 $defaultStorageUid = NULL;
1521 if ($defaultStorage !== NULL) {
1522 $defaultStorageUid = $defaultStorage->getUid();
1524 foreach ($sysFileStorageUidsToBeResetToDefaultStorage as $sysFileStorageUidToBeResetToDefaultStorage) {
1525 $this->import_mapId[
'sys_file_storage'][$sysFileStorageUidToBeResetToDefaultStorage] = $defaultStorageUid;
1529 unset($this->dat[
'header'][
'records'][
'sys_file_storage']);
1537 protected function writeSysFileRecords() {
1538 if (!isset($this->dat[
'header'][
'records'][
'sys_file'])) {
1548 $sanitizedFolderMappings = array();
1550 foreach ($this->dat[
'header'][
'records'][
'sys_file'] as $sysFileUid => $_) {
1551 $fileRecord = $this->dat[
'records'][
'sys_file:' . $sysFileUid][
'data'];
1554 $fileId = md5($fileRecord[
'storage'] .
':' . $fileRecord[
'identifier_hash']);
1556 if ($temporaryFile === NULL) {
1561 $originalStorageUid = $fileRecord[
'storage'];
1562 $useStorageFromStorageRecords = FALSE;
1565 if (isset($this->import_mapId[
'sys_file_storage'][$fileRecord[
'storage']])) {
1566 $fileRecord[
'storage'] = $this->import_mapId[
'sys_file_storage'][$fileRecord[
'storage']];
1567 $useStorageFromStorageRecords = TRUE;
1570 if (empty($fileRecord[
'storage']) && !$this->
isFallbackStorage($fileRecord[
'storage'])) {
1572 $this->
error(
'Error: No storage for the file "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $originalStorageUid .
'"');
1578 if ($useStorageFromStorageRecords && isset($storageRecords[$fileRecord[
'storage']])) {
1583 } elseif ($defaultStorage !== NULL) {
1584 $storage = $defaultStorage;
1586 $this->
error(
'Error: No storage available for the file "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $fileRecord[
'storage'] .
'"');
1594 if ($storage->hasFile($fileRecord[
'identifier'])) {
1595 $file = $storage->getFile($fileRecord[
'identifier']);
1596 if ($file->getSha1() === $fileRecord[
'sha1']) {
1602 if ($newFile === NULL) {
1605 if (in_array($folderName, $sanitizedFolderMappings)) {
1606 $folderName = $sanitizedFolderMappings[$folderName];
1608 if (!$storage->hasFolder($folderName)) {
1610 $importFolder = $storage->createFolder($folderName);
1611 if ($importFolder->getIdentifier() !== $folderName && !in_array($folderName, $sanitizedFolderMappings)) {
1612 $sanitizedFolderMappings[$folderName] = $importFolder->getIdentifier();
1615 $this->
error(
'Error: Folder could not be created for file "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $fileRecord[
'storage'] .
'"');
1619 $importFolder = $storage->getFolder($folderName);
1624 $newFile = $storage->addFile($temporaryFile, $importFolder, $fileRecord[
'name']);
1626 $this->
error(
'Error: File could not be added to the storage: "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $fileRecord[
'storage'] .
'"');
1630 if ($newFile->getSha1() !== $fileRecord[
'sha1']) {
1631 $this->
error(
'Error: The hash of the written file is not identical to the import data! File could be corrupted! File: "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $fileRecord[
'storage'] .
'"');
1636 $this->import_mapId[
'sys_file'][$fileRecord[
'uid']] = $newFile->getUid();
1642 unset($this->dat[
'header'][
'records'][
'sys_file']);
1656 if (!isset($this->dat[
'header'][
'records'][
'sys_file_reference'])) {
1660 foreach ($this->dat[
'header'][
'records'][
'sys_file_reference'] as $sysFileReferenceUid => $_) {
1661 $fileReferenceRecord = $this->dat[
'records'][
'sys_file_reference:' . $sysFileReferenceUid][
'data'];
1662 if (!in_array($fileReferenceRecord[
'uid_local'], $this->import_mapId[
'sys_file'])) {
1663 unset($this->dat[
'header'][
'records'][
'sys_file_reference'][$sysFileReferenceUid]);
1664 unset($this->dat[
'records'][
'sys_file_reference:' . $sysFileReferenceUid]);
1665 $this->
error(
'Error: sys_file_reference record ' . (
int)$sysFileReferenceUid
1666 .
' with relation to sys_file record ' . (
int)$fileReferenceRecord[
'uid_local']
1667 .
', which is not part of the import data, was not imported.' 1680 return $storageId === 0 || $storageId ===
'0';
1700 if (!isset($this->dat[
'header'][
'records'][
'sys_file_reference'])) {
1704 foreach ($this->dat[
'header'][
'records'][
'sys_file_reference'] as $sysFileReferenceUid => $_) {
1705 $fileReferenceRecord = $this->dat[
'records'][
'sys_file_reference:' . $sysFileReferenceUid][
'data'];
1706 if ($fileReferenceRecord[
'uid_local'] == $oldFileUid) {
1707 $fileReferenceRecord[
'uid_local'] = $newFileUid;
1708 $this->dat[
'records'][
'sys_file_reference:' . $sysFileReferenceUid][
'data'] = $fileReferenceRecord;
1718 protected function initializeLegacyImportFolder() {
1720 $folder =
$GLOBALS[
'BE_USER']->getDefaultUploadFolder();
1721 if ($folder === FALSE) {
1722 $this->
error(
'Error: the backend users default upload folder is missing! No files will be imported!');
1724 if (!$folder->hasFolder($this->legacyImportTargetPath)) {
1726 $this->legacyImportFolder = $folder->createFolder($this->legacyImportTargetPath);
1728 $this->
error(
'Error: the import folder in the default upload folder could not be created! No files will be imported!');
1731 $this->legacyImportFolder = $folder->getSubfolder($this->legacyImportTargetPath);
1746 $rows =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
1749 '1=1' . $whereClause,
1767 $temporaryFilePath = NULL;
1768 if (is_array($this->dat[$dataKey][$fileId])) {
1772 if (@is_file($temporaryFilePathInternal)) {
1773 $this->unlinkFiles[] = $temporaryFilePathInternal;
1774 if (filesize($temporaryFilePathInternal) == $this->dat[$dataKey][$fileId][
'filesize']) {
1775 $temporaryFilePath = $temporaryFilePathInternal;
1777 $this->
error(
'Error: temporary file ' . $temporaryFilePathInternal .
' had a size (' . filesize($temporaryFilePathInternal) .
') different from the original (' . $this->dat[$dataKey][$fileId][
'filesize'] .
')', 1);
1780 $this->
error(
'Error: temporary file ' . $temporaryFilePathInternal .
' was not written as it should have been!', 1);
1783 $this->
error(
'Error: No file found for ID ' . $fileId, 1);
1785 return $temporaryFilePath;
1798 if (is_array($this->dat[
'header'][
'records'][
'pages'])) {
1801 $pageRecords = $this->dat[
'header'][
'records'][
'pages'];
1802 $this->import_data = array();
1804 if (is_array($this->dat[
'header'][
'pagetree'])) {
1806 foreach ($pagesFromTree as
$uid) {
1807 $thisRec = $this->dat[
'header'][
'records'][
'pages'][
$uid];
1809 $setPid = isset($this->import_newId_pids[$thisRec[
'pid']]) ? $this->import_newId_pids[$thisRec[
'pid']] : $pid;
1810 $this->
addSingle(
'pages', $uid, $setPid);
1811 unset($pageRecords[$uid]);
1815 if (count($pageRecords)) {
1816 $remainingPageUids = array_keys($pageRecords);
1817 foreach ($remainingPageUids as $pUid) {
1823 $tce->isImporting = TRUE;
1824 $this->
callHook(
'before_writeRecordsPages', array(
1826 'data' => &$this->import_data
1829 $tce->start($this->import_data, array());
1830 $tce->process_datamap();
1831 $this->
callHook(
'after_writeRecordsPages', array(
1837 if ($this->update && is_array($this->dat[
'header'][
'pagetree'])) {
1854 $cmd_data = array();
1857 foreach ($pidsFromTree as $origPid => $newPid) {
1858 if ($newPid >= 0 && $this->
dontIgnorePid(
'pages', $origPid)) {
1860 if (substr($this->import_newId_pids[$origPid], 0, 3) ===
'NEW') {
1861 if ($this->import_mapId[
'pages'][$origPid]) {
1862 $mappedPid = $this->import_mapId[
'pages'][$origPid];
1863 $cmd_data[
'pages'][$mappedPid][
'move'] = $newPid;
1866 $cmd_data[
'pages'][$origPid][
'move'] = $newPid;
1871 if (count($cmd_data)) {
1873 $this->
callHook(
'before_writeRecordsPagesOrder', array(
1875 'data' => &$cmd_data
1877 $tce->start(array(), $cmd_data);
1878 $tce->process_cmdmap();
1879 $this->
callHook(
'after_writeRecordsPagesOrder', array(
1895 $this->import_data = array();
1896 if (is_array($this->dat[
'header'][
'records'])) {
1897 foreach ($this->dat[
'header'][
'records'] as $table => $recs) {
1899 if ($table !=
'pages') {
1900 foreach ($recs as
$uid => $thisRec) {
1902 $setPid = isset($this->import_mapId[
'pages'][$thisRec[
'pid']])
1903 ? (int)$this->import_mapId[
'pages'][$thisRec[
'pid']]
1905 if (is_array(
$GLOBALS[
'TCA'][$table]) && isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'rootLevel'])) {
1906 $rootLevelSetting = (int)
$GLOBALS[
'TCA'][$table][
'ctrl'][
'rootLevel'];
1907 if ($rootLevelSetting === 1) {
1909 } elseif ($rootLevelSetting === 0 && $setPid === 0) {
1910 $this->
error(
'Error: Record type ' . $table .
' is not allowed on pid 0');
1920 $this->
error(
'Error: No records defined in internal data array.');
1924 $this->
callHook(
'before_writeRecordsRecords', array(
1926 'data' => &$this->import_data
1930 $tce->reverseOrder = 1;
1931 $tce->isImporting = TRUE;
1932 $tce->start($this->import_data, array());
1933 $tce->process_datamap();
1934 $this->
callHook(
'after_writeRecordsRecords', array(
1940 if ($this->update) {
1956 $cmd_data = array();
1957 if (is_array($this->dat[
'header'][
'pagetree'])) {
1960 $pagesFromTree = array();
1962 if (is_array($this->dat[
'header'][
'pid_lookup'])) {
1963 foreach ($this->dat[
'header'][
'pid_lookup'] as $pid => $recList) {
1964 $newPid = isset($this->import_mapId[
'pages'][$pid]) ? $this->import_mapId[
'pages'][$pid] : $mainPid;
1965 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($newPid)) {
1966 foreach ($recList as $tableName => $uidList) {
1969 if (($tableName !=
'pages' || !$pagesFromTree[$pid]) && is_array($uidList)) {
1970 $uidList = array_reverse(array_keys($uidList));
1971 foreach ($uidList as
$uid) {
1973 $cmd_data[$tableName][
$uid][
'move'] = $newPid;
1984 if (count($cmd_data)) {
1986 $this->
callHook(
'before_writeRecordsRecordsOrder', array(
1988 'data' => &$cmd_data
1990 $tce->start(array(), $cmd_data);
1991 $tce->process_cmdmap();
1992 $this->
callHook(
'after_writeRecordsRecordsOrder', array(
2010 if ($this->import_mode[$table .
':' .
$uid] !==
'exclude') {
2011 $record = $this->dat[
'records'][$table .
':' .
$uid][
'data'];
2012 if (is_array($record)) {
2013 if ($this->update && $this->
doesRecordExist($table,
$uid) && $this->import_mode[$table .
':' .
$uid] !==
'as_new') {
2015 } elseif ($table ===
'sys_file_metadata' && $record[
'sys_language_uid'] ==
'0' && $this->import_mapId[
'sys_file'][$record[
'file']]) {
2018 $recordInDatabase =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
2020 'sys_file_metadata',
2021 'file = ' . $this->import_mapId[
'sys_file'][$record[
'file']] .
' AND sys_language_uid = 0 AND pid = 0' 2025 if (is_array($recordInDatabase)) {
2026 $this->import_mapId[
'sys_file_metadata'][$record[
'uid']] = $recordInDatabase[
'uid'];
2027 $ID = $recordInDatabase[
'uid'];
2029 $ID = uniqid(
'NEW', TRUE);
2033 $ID = uniqid(
'NEW', TRUE);
2035 $this->import_newId[$table .
':' . $ID] = array(
'table' => $table,
'uid' =>
$uid);
2036 if ($table ==
'pages') {
2037 $this->import_newId_pids[
$uid] = $ID;
2040 $this->import_data[$table][$ID] = $record;
2041 $this->import_data[$table][$ID][
'tx_impexp_origuid'] = $this->import_data[$table][$ID][
'uid'];
2043 if ($table ===
'pages') {
2045 unset($this->import_data[$table][$ID][
'perms_userid']);
2046 unset($this->import_data[$table][$ID][
'perms_groupid']);
2049 unset($this->import_data[$table][$ID][
'uid']);
2051 if (\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($ID)) {
2052 unset($this->import_data[$table][$ID][
'pid']);
2055 $this->import_data[$table][$ID][
'pid'] = $pid;
2056 if (($this->import_mode[$table .
':' .
$uid] ===
'force_uid' && $this->update || $this->force_all_UIDS) &&
$GLOBALS[
'BE_USER']->isAdmin()) {
2057 $this->import_data[$table][$ID][
'uid'] =
$uid;
2058 $this->suggestedInsertUids[$table .
':' .
$uid] =
'DELETE';
2062 foreach ($this->dat[
'records'][$table .
':' .
$uid][
'rels'] as $field => $config) {
2063 switch ((
string) $config[
'type']) {
2075 if ($table !==
'sys_file_reference' && $field !==
'uid_local') {
2076 $this->import_data[$table][$ID][$field] =
'';
2082 $this->import_data[$table][$ID][$field] =
'';
2086 } elseif ($table .
':' .
$uid !=
'pages:0') {
2088 $this->
error(
'Error: no record was found in data array!', 1);
2102 foreach ($this->import_data as $table => $recs) {
2103 foreach ($recs as $id => $value) {
2104 $old_uid = $this->import_newId[$table .
':' . $id][
'uid'];
2105 if (isset($substNEWwithIDs[$id])) {
2106 $this->import_mapId[$table][$old_uid] = $substNEWwithIDs[$id];
2107 } elseif ($this->update) {
2109 $this->import_mapId[$table][$old_uid] = $id;
2112 if (!($table ===
'sys_file_metadata' && isset($this->import_mapId[$table][$old_uid]) && $this->import_mapId[$table][$old_uid] == $id)) {
2113 $this->
error(
'Possible error: ' . $table .
':' . $old_uid .
' had no new id assigned to it. This indicates that the record was not added to database during import. Please check changelog!', 1);
2129 $tce->stripslashes_values = 0;
2130 $tce->dontProcessTransformations = 1;
2132 $tce->alternativeFileName = $this->alternativeFileName;
2133 $tce->alternativeFilePath = $this->alternativeFilePath;
2144 foreach ($this->unlinkFiles as $fileName) {
2148 if (is_file($fileName)) {
2149 $this->
error(
'Error: ' . $fileName .
' was NOT unlinked as it should have been!', 1);
2152 $this->
error(
'Error: ' . $fileName .
' was not in temp-path. Not removed!', 1);
2155 $this->unlinkFiles = array();
2172 $updateData = array();
2174 foreach ($this->import_newId as $nId =>
$dat) {
2175 $table =
$dat[
'table'];
2179 if (is_array($this->import_mapId[$table]) && isset($this->import_mapId[$table][
$uid])) {
2181 if (is_array($this->dat[
'records'][$table .
':' . $uid][
'rels'])) {
2182 if ($this->legacyImport) {
2183 if ($table !=
'pages') {
2184 $oldPid = $this->dat[
'records'][$table .
':' .
$uid][
'data'][
'pid'];
2187 $thisNewPageUid = $thisNewUid;
2191 foreach ($this->dat[
'records'][$table .
':' . $uid][
'rels'] as $field => $config) {
2194 if ($table ===
'sys_file_reference' && $field ===
'uid_local') {
2197 switch ((
string) $config[
'type']) {
2199 if (is_array($config[
'itemArray']) && count($config[
'itemArray'])) {
2200 $itemConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
2201 $valArray = $this->
setRelations_db($config[
'itemArray'], $itemConfig);
2202 $updateData[$table][$thisNewUid][$field] = implode(
',', $valArray);
2206 if (is_array($config[
'newValueFiles']) && count($config[
'newValueFiles'])) {
2208 foreach ($config[
'newValueFiles'] as $fI) {
2211 if ($this->legacyImport && $this->legacyImportFolder === NULL && isset($this->legacyImportMigrationTables[$table][$field])) {
2213 } elseif ($this->legacyImport && $this->legacyImportFolder !== NULL && isset($this->legacyImportMigrationTables[$table][$field])) {
2215 foreach ($valArr as $tempFile) {
2216 $fileName = $this->alternativeFileName[$tempFile];
2221 if ($this->legacyImportFolder->hasFile($fileName)) {
2222 $fileStorage = $this->legacyImportFolder->getStorage();
2223 $file = $fileStorage->getFile($this->legacyImportFolder->getIdentifier() . $fileName);
2224 if ($file->getSha1() === sha1_file($tempFile)) {
2225 $fileObject = $file;
2230 if ($fileObject === NULL) {
2232 $fileObject = $this->legacyImportFolder->addFile($tempFile, $fileName,
'changeName');
2234 $this->
error(
'Error: no file could be added to the storage for file name' . $this->alternativeFileName[$tempFile]);
2237 if ($fileObject !== NULL) {
2238 $refId = uniqid(
'NEW', TRUE);
2240 $updateData[
'sys_file_reference'][$refId] = array(
2241 'uid_local' => $fileObject->getUid(),
2242 'uid_foreign' => $thisNewUid,
2243 'tablenames' => $table,
2244 'fieldname' => $field,
2245 'pid' => $thisNewPageUid,
2246 'table_local' =>
'sys_file',
2250 $updateData[$table][$thisNewUid][$field] = implode(
',', $refIds);
2251 if (!empty($this->legacyImportMigrationTables[$table][$field])) {
2252 $this->legacyImportMigrationRecords[$table][$thisNewUid][$field] = $refIds;
2255 $updateData[$table][$thisNewUid][$field] = implode(
',', $valArr);
2262 $this->
error(
'Error: no record was found in data array!', 1);
2265 $this->
error(
'Error: this records is NOT created it seems! (' . $table .
':' . $uid .
')', 1);
2268 if (count($updateData)) {
2270 $tce->isImporting = TRUE;
2271 $this->
callHook(
'before_setRelation', array(
2273 'data' => &$updateData
2275 $tce->start($updateData, array());
2276 $tce->process_datamap();
2278 foreach ($this->legacyImportMigrationRecords as $table => $records) {
2279 foreach ($records as
$uid => $fields) {
2280 foreach ($fields as $field => $referenceIds) {
2281 foreach ($referenceIds as $key => $referenceId) {
2282 $this->legacyImportMigrationRecords[$table][
$uid][$field][$key] = $tce->substNEWwithIDs[$referenceId];
2287 $this->
callHook(
'after_setRelations', array(
2302 $valArray = array();
2303 foreach ($itemArray as $relDat) {
2304 if (is_array($this->import_mapId[$relDat[
'table']]) && isset($this->import_mapId[$relDat[
'table']][$relDat[
'id']])) {
2307 if ($itemConfig[
'type'] ===
'group' && $itemConfig[
'internal_type'] ===
'file_reference') {
2308 $value = $this->import_mapId[$relDat[
'table']][$relDat[
'id']];
2309 } elseif ($itemConfig[
'type'] ===
'input' && isset($itemConfig[
'wizards'][
'link'])) {
2312 $fileUid = $this->import_mapId[$relDat[
'table']][$relDat[
'id']];
2314 $value =
'file:' . $fileUid;
2318 if ($file instanceof \
TYPO3\CMS\Core\Resource\FileInterface) {
2319 $value = $file->getPublicUrl();
2322 $value = $relDat[
'table'] .
'_' . $this->import_mapId[$relDat[
'table']][$relDat[
'id']];
2324 $valArray[] = $value;
2325 } elseif ($this->
isTableStatic($relDat[
'table']) || $this->
isExcluded($relDat[
'table'], $relDat[
'id']) || $relDat[
'id'] < 0) {
2327 $valArray[] = $relDat[
'table'] .
'_' . $relDat[
'id'];
2329 $this->
error(
'Lost relation: ' . $relDat[
'table'] .
':' . $relDat[
'id'], 1);
2343 if (is_array($this->dat[
'files'][$fI[
'ID']])) {
2347 if (@is_file($tmpFile)) {
2348 $this->unlinkFiles[] = $tmpFile;
2349 if (filesize($tmpFile) == $this->dat[
'files'][$fI[
'ID']][
'filesize']) {
2350 $this->alternativeFileName[$tmpFile] = $fI[
'filename'];
2351 $this->alternativeFilePath[$tmpFile] = $this->dat[
'files'][$fI[
'ID']][
'relFileRef'];
2354 $this->
error(
'Error: temporary file ' . $tmpFile .
' had a size (' . filesize($tmpFile) .
') different from the original (' . $this->dat[
'files'][$fI[
'ID']][
'filesize'] .
')', 1);
2357 $this->
error(
'Error: temporary file ' . $tmpFile .
' was not written as it should have been!', 1);
2360 $this->
error(
'Error: No file found for ID ' . $fI[
'ID'], 1);
2373 $updateData = array();
2375 foreach ($this->import_newId as $nId =>
$dat) {
2376 $table =
$dat[
'table'];
2380 if (is_array($this->import_mapId[$table]) && isset($this->import_mapId[$table][
$uid])) {
2382 if (is_array($this->dat[
'records'][$table .
':' . $uid][
'rels'])) {
2384 foreach ($this->dat[
'records'][$table .
':' . $uid][
'rels'] as $field => $config) {
2385 switch ((
string) $config[
'type']) {
2388 $updateData[$table][$thisNewUid][$field] = $this->dat[
'records'][$table .
':' .
$uid][
'data'][$field];
2390 if (count($config[
'flexFormRels'][
'db']) || count($config[
'flexFormRels'][
'file'])) {
2391 $origRecordRow = BackendUtility::getRecord($table, $thisNewUid,
'*');
2393 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
2394 if (is_array($origRecordRow) && is_array($conf) && $conf[
'type'] ===
'flex') {
2400 $iteratorObj->callBackObj = $this;
2401 $currentValueArray[
'data'] = $iteratorObj->checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $thisNewUid, $field, $config),
'remapListedDBRecords_flexFormCallBack');
2403 if (is_array($currentValueArray[
'data'])) {
2404 $updateData[$table][$thisNewUid][$field] = $currentValueArray;
2412 $this->
error(
'Error: no record was found in data array!', 1);
2415 $this->
error(
'Error: this records is NOT created it seems! (' . $table .
':' . $uid .
')', 1);
2418 if (count($updateData)) {
2420 $tce->isImporting = TRUE;
2421 $this->
callHook(
'before_setFlexFormRelations', array(
2423 'data' => &$updateData
2425 $tce->start($updateData, array());
2426 $tce->process_datamap();
2427 $this->
callHook(
'after_setFlexFormRelations', array(
2448 list($table,
$uid, $field, $config) = $pParams;
2450 if (!is_array($config[
'flexFormRels'][
'db'][$path]) && is_array($config[
'flexFormRels'][
'db'][rtrim($path,
'/')])) {
2451 $path = rtrim($path,
'/');
2453 if (is_array($config[
'flexFormRels'][
'db'][$path])) {
2454 $valArray = $this->
setRelations_db($config[
'flexFormRels'][
'db'][$path], $dsConf);
2455 $dataValue = implode(
',', $valArray);
2457 if (is_array($config[
'flexFormRels'][
'file'][$path])) {
2458 foreach ($config[
'flexFormRels'][
'file'][$path] as $fI) {
2461 $dataValue = implode(
',', $valArr);
2463 return array(
'value' => $dataValue);
2476 public function processSoftReferences() {
2480 if (is_array($this->dat[
'header'][
'records'])) {
2481 foreach ($this->dat[
'header'][
'records'] as $table => $recs) {
2482 foreach ($recs as
$uid => $thisRec) {
2484 if (isset(
$GLOBALS[
'TCA'][$table]) && is_array($thisRec[
'softrefs'])) {
2486 $fieldsIndex = array();
2487 foreach ($thisRec[
'softrefs'] as $softrefDef) {
2489 if ($softrefDef[
'field'] && is_array($softrefDef[
'subst']) && $softrefDef[
'subst'][
'tokenID']) {
2490 $fieldsIndex[$softrefDef[
'field']][$softrefDef[
'subst'][
'tokenID']] = $softrefDef;
2496 foreach ($fieldsIndex as $field => $softRefCfgs) {
2497 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'][$field])) {
2498 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
2499 if ($conf[
'type'] ===
'flex') {
2501 $origRecordRow = BackendUtility::getRecord($table, $thisNewUid,
'*');
2502 if (is_array($origRecordRow)) {
2509 $iteratorObj->callBackObj = $this;
2510 $currentValueArray[
'data'] = $iteratorObj->checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $uid, $field, $softRefCfgs),
'processSoftReferences_flexFormCallBack');
2512 if (is_array($currentValueArray[
'data'])) {
2513 $inData[$table][$thisNewUid][$field] = $currentValueArray;
2518 $tokenizedContent = $this->dat[
'records'][$table .
':' .
$uid][
'rels'][$field][
'softrefs'][
'tokenizedContent'];
2519 if (strlen($tokenizedContent) && is_array($softRefCfgs)) {
2531 $tce->isImporting = TRUE;
2532 $this->
callHook(
'before_processSoftReferences', array(
2536 $tce->enableLogging = TRUE;
2537 $tce->start($inData, array());
2538 $tce->process_datamap();
2539 $this->
callHook(
'after_processSoftReferences', array(
2559 list($table, $origUid, $field, $softRefCfgs) = $pParams;
2560 if (is_array($softRefCfgs)) {
2562 $thisSoftRefCfgList = array();
2563 foreach ($softRefCfgs as $sK => $sV) {
2564 if ($sV[
'structurePath'] === $path) {
2565 $thisSoftRefCfgList[$sK] = $sV;
2569 if (count($thisSoftRefCfgList)) {
2571 $tokenizedContent = $this->dat[
'records'][$table .
':' . $origUid][
'rels'][$field][
'flexFormRels'][
'softrefs'][$path][
'tokenizedContent'];
2572 if (strlen($tokenizedContent)) {
2578 return array(
'value' => $dataValue);
2593 foreach ($softRefCfgs as $cfg) {
2595 $tokenID = $cfg[
'subst'][
'tokenID'];
2597 $insertValue = $cfg[
'subst'][
'tokenValue'];
2599 switch ((
string) $this->softrefCfg[$tokenID][
'mode']) {
2605 $insertValue = $this->softrefInputValues[$tokenID];
2609 switch ((
string) $cfg[
'subst'][
'type']) {
2617 list($tempTable, $tempUid) = explode(
':', $cfg[
'subst'][
'recordRef']);
2618 if (isset($this->import_mapId[$tempTable][$tempUid])) {
2621 if ($tempTable ===
'pages' && !\
TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($cfg[
'subst'][
'tokenValue'])) {
2622 $recWithUniqueValue = BackendUtility::getRecord($tempTable, $insertValue,
'alias');
2623 if ($recWithUniqueValue[
'alias']) {
2624 $insertValue = $recWithUniqueValue[
'alias'];
2626 } elseif (strpos($cfg[
'subst'][
'tokenValue'],
':') !== FALSE) {
2627 list($tokenKey, $tokenId) = explode(
':', $cfg[
'subst'][
'tokenValue']);
2628 $insertValue = $tokenKey .
':' . $insertValue;
2634 $tokenizedContent = str_replace(
'{softref:' . $tokenID .
'}', $insertValue, $tokenizedContent);
2636 return $tokenizedContent;
2650 if ($fileHeaderInfo = $this->dat[
'header'][
'files'][$cfg[
'file_ID']]) {
2658 if (@is_dir((PATH_site . $dirPrefix))) {
2661 $origDestName =
$fileProcObj->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
2663 $pI = pathinfo($relFileName);
2666 if ($this->dat[
'header'][
'files'][$fileHeaderInfo[
'RTE_ORIG_ID']]) {
2667 if ($this->legacyImport) {
2670 $relFileName = $this->filePathMap[$cfg[
'file_ID']] .
'" data-htmlarea-file-uid="' . $fileName .
'" data-htmlarea-file-table="sys_file';
2677 $this->
writeFileVerify($origDestName, $fileHeaderInfo[
'RTE_ORIG_ID'], TRUE);
2679 return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($copyDestName);
2682 $this->
error(
'ERROR: Could not find original file ID');
2685 $this->
error(
'ERROR: The destination filenames "' . $copyDestName .
'" and "' . $origDestName .
'" either existed or have non-valid names');
2688 $this->
error(
'ERROR: "' . PATH_site . $dirPrefix .
'" was not a directory, so could not process file "' . $relFileName .
'"');
2694 if (strlen($newFileName)) {
2695 $relFileName = $newFileName;
2697 $this->
error(
'ERROR: No new file created for "' . $relFileName .
'"');
2700 $this->
error(
'ERROR: Sorry, cannot operate on non-RTE files which are outside the fileadmin folder.');
2703 $this->
error(
'ERROR: Could not find file ID in header.');
2706 return $relFileName;
2722 if (isset($this->fileIDMap[$fileID])) {
2723 return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$fileID]);
2725 if ($this->legacyImport) {
2727 $dirPrefix = $this->fileadminFolderName .
'/';
2732 if ($dirPrefix && (!$this->update || $origDirPrefix === $dirPrefix) && $this->
checkOrCreateDir($dirPrefix)) {
2733 $fileHeaderInfo = $this->dat[
'header'][
'files'][$fileID];
2734 $updMode = $this->update && $this->import_mapId[$table][
$uid] ===
$uid && $this->import_mode[$table .
':' .
$uid] !==
'as_new';
2739 if ($this->legacyImport) {
2742 $newName =
'file:' . $fileName;
2748 $newName = PATH_site . $dirPrefix . $fileName;
2752 $newName =
$fileProcObj->getUniqueName($fileName, PATH_site . $dirPrefix);
2756 if (is_array($fileHeaderInfo[
'EXT_RES_ID'])) {
2757 $tokenizedContent = $this->dat[
'files'][$fileID][
'tokenizedContent'];
2758 $tokenSubstituted = FALSE;
2761 foreach ($fileHeaderInfo[
'EXT_RES_ID'] as $res_fileID) {
2762 if ($this->dat[
'files'][$res_fileID][
'filename']) {
2764 $relResourceFileName = $this->dat[
'files'][$res_fileID][
'parentRelFileName'];
2772 $this->
error(
'ERROR: Could not create file in directory "' . $destDir .
'"');
2775 $this->
error(
'ERROR: Could not resolve path for "' . $relResourceFileName .
'"');
2777 $tokenizedContent = str_replace(
'{EXT_RES_ID:' . $res_fileID .
'}', $relResourceFileName, $tokenizedContent);
2778 $tokenSubstituted = TRUE;
2785 foreach ($fileHeaderInfo[
'EXT_RES_ID'] as $res_fileID) {
2786 if ($this->dat[
'files'][$res_fileID][
'filename']) {
2787 $absResourceFileName =
$fileProcObj->getUniqueName($this->dat[
'files'][$res_fileID][
'filename'], $resourceDir);
2788 $relResourceFileName = substr($absResourceFileName, strlen(
PathUtility::dirname($resourceDir)) + 1);
2790 $tokenizedContent = str_replace(
'{EXT_RES_ID:' . $res_fileID .
'}', $relResourceFileName, $tokenizedContent);
2791 $tokenSubstituted = TRUE;
2797 if ($tokenSubstituted) {
2801 return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($newName);
2820 if (
$fileProcObj->checkPathAgainstMounts($fileName) || $bypassMountCheck) {
2822 if (
$fileProcObj->checkIfAllowed($fI[
'fileext'], $fI[
'path'], $fI[
'file']) || $this->allowPHPScripts &&
$GLOBALS[
'BE_USER']->isAdmin()) {
2824 if ($this->dat[
'files'][$fileID]) {
2826 $this->fileIDMap[$fileID] = $fileName;
2830 $this->
error(
'ERROR: File content "' . $fileName .
'" was corrupted');
2833 $this->
error(
'ERROR: File ID "' . $fileID .
'" could not be found');
2836 $this->
error(
'ERROR: Filename "' . $fileName .
'" was not a valid relative file path!');
2839 $this->
error(
'ERROR: Filename "' . $fileName .
'" failed against extension check or deny-pattern!');
2842 $this->
error(
'ERROR: Filename "' . $fileName .
'" was not allowed in destination path!');
2845 $this->
error(
'ERROR: You did not have sufficient permissions to write the file "' . $fileName .
'"');
2860 if ($this->legacyImportFolder === NULL) {
2864 if (!isset($this->dat[
'files'][$fileId])) {
2865 $this->
error(
'ERROR: File ID "' . $fileId .
'" could not be found');
2870 if ($temporaryFile === NULL) {
2877 if (isset($this->dat[
'files'][$fileId][
'relFileName'])) {
2880 if (!$this->legacyImportFolder->hasFolder($relativeFilePath)) {
2881 $this->legacyImportFolder->createFolder($relativeFilePath);
2883 $importFolder = $this->legacyImportFolder->getSubfolder($relativeFilePath);
2890 if ($importFolder->hasFile($fileName)) {
2891 $fileStorage = $importFolder->getStorage();
2892 $file = $fileStorage->getFile($importFolder->getIdentifier() . $fileName);
2893 if ($file->getSha1() === sha1_file($temporaryFile)) {
2894 $fileObject = $file;
2899 if ($fileObject === NULL) {
2901 $fileObject = $importFolder->addFile($temporaryFile, $fileName,
'changeName');
2903 $this->
error(
'Error: no file could be added to the storage for file name ' . $this->alternativeFileName[$temporaryFile]);
2907 if (md5_file(PATH_site . $fileObject->getPublicUrl()) == $this->dat[
'files'][$fileId][
'content_md5']) {
2908 $fileName = $fileObject->getUid();
2909 $this->fileIDMap[$fileId] = $fileName;
2910 $this->filePathMap[$fileId] = $fileObject->getPublicUrl();
2913 $this->
error(
'ERROR: File content "' . $this->dat[
'files'][$fileId][
'relFileName'] .
'" was corrupted');
2925 $updateData= array();
2927 foreach ($this->legacyImportMigrationRecords as $table => $records) {
2928 foreach ($records as
$uid => $fields) {
2930 $row = BackendUtility::getRecord($table,
$uid);
2935 foreach ($fields as $field => $referenceIds) {
2937 $fieldConfiguration = $this->legacyImportMigrationTables[$table][$field];
2939 if (isset($fieldConfiguration[
'titleTexts'])) {
2940 $titleTextField = $fieldConfiguration[
'titleTexts'];
2941 if ($row[$titleTextField] !==
'') {
2942 $titleTextContents = explode(LF, $row[$titleTextField]);
2943 $updateData[$table][
$uid][$titleTextField] =
'';
2947 if (isset($fieldConfiguration[
'alternativeTexts'])) {
2948 $alternativeTextField = $fieldConfiguration[
'alternativeTexts'];
2949 if ($row[$alternativeTextField] !==
'') {
2950 $alternativeTextContents = explode(LF, $row[$alternativeTextField]);
2951 $updateData[$table][
$uid][$alternativeTextField] =
'';
2954 if (isset($fieldConfiguration[
'description'])) {
2955 $descriptionField = $fieldConfiguration[
'description'];
2956 if ($row[$descriptionField] !==
'') {
2957 $descriptionContents = explode(LF, $row[$descriptionField]);
2958 $updateData[$table][
$uid][$descriptionField] =
'';
2961 if (isset($fieldConfiguration[
'links'])) {
2962 $linkField = $fieldConfiguration[
'links'];
2963 if ($row[$linkField] !==
'') {
2964 $linkContents = explode(LF, $row[$linkField]);
2965 $updateData[$table][
$uid][$linkField] =
'';
2969 foreach ($referenceIds as $key => $referenceId) {
2970 if (isset($titleTextContents[$key])) {
2971 $updateData[
'sys_file_reference'][$referenceId][
'title'] = trim($titleTextContents[$key]);
2973 if (isset($alternativeTextContents[$key])) {
2974 $updateData[
'sys_file_reference'][$referenceId][
'alternative'] = trim($alternativeTextContents[$key]);
2976 if (isset($descriptionContents[$key])) {
2977 $updateData[
'sys_file_reference'][$referenceId][
'description'] = trim($descriptionContents[$key]);
2979 if (isset($linkContents[$key])) {
2980 $updateData[
'sys_file_reference'][$referenceId][
'link'] = trim($linkContents[$key]);
2989 $tce->isImporting = TRUE;
2990 $tce->start($updateData, array());
2991 $tce->process_datamap();
3004 $filePathParts = explode(
'/', $dirPrefix);
3005 $firstDir = array_shift($filePathParts);
3008 foreach ($filePathParts as $dirname) {
3009 $pathAcc .=
'/' . $dirname;
3010 if (strlen($dirname)) {
3011 if (!@is_dir((PATH_site . $this->fileadminFolderName . $pathAcc))) {
3013 $this->
error(
'ERROR: Directory could not be created....B');
3017 } elseif ($dirPrefix === $this->fileadminFolderName . $pathAcc) {
3020 $this->
error(
'ERROR: Directory could not be created....A');
3041 if ($noAlternative) {
3050 $dirPrefix = substr($dirPrefix, strlen($this->fileadminFolderName .
'/'));
3052 return \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix(
$fileProcObj->mounts[
$result][
'path'] . $dirPrefix);
3072 if (@is_file($filename)) {
3073 $fI = pathinfo($filename);
3074 if (strtolower($fI[
'extension']) ==
'xml') {
3077 if (strlen($xmlContent)) {
3079 if (is_array($this->dat)) {
3080 if ($this->dat[
'_DOCUMENT_TAG'] ===
'T3RecordDocument' && is_array($this->dat[
'header']) && is_array($this->dat[
'records'])) {
3084 $this->
error(
'XML file did not contain proper XML for TYPO3 Import');
3087 $this->
error(
'XML could not be parsed: ' . $this->dat);
3090 $this->
error(
'Error opening file: ' . $filename);
3094 if ($fd = fopen($filename,
'rb')) {
3099 $this->dat[
'files_fal'] = $this->
getNextFilePart($fd, 1,
'files_fal');
3104 $this->
error(
'Error opening file: ' . $filename);
3109 $this->
error(
'Filename not found: ' . $filename);
3126 $initStrLen = 32 + 1 + 1 + 1 + 10 + 1;
3128 $initStr = fread($fd, $initStrLen);
3129 if (empty($initStr)) {
3130 $this->
error(
'File does not contain data for "' . $name .
'"');
3133 $initStrDat = explode(
':', $initStr);
3134 if (strstr($initStrDat[0],
'Warning') == FALSE) {
3135 if ((
string)$initStrDat[3] ===
'') {
3136 $datString = fread($fd, (
int)$initStrDat[2]);
3138 if (md5($datString) === $initStrDat[0]) {
3139 if ($initStrDat[1]) {
3140 if ($this->compress) {
3141 $datString = gzuncompress($datString);
3143 $this->
error(
'Content read error: This file requires decompression, but this server does not offer gzcompress()/gzuncompress() functions.', 1);
3146 return $unserialize ? unserialize($datString) : $datString;
3148 $this->
error(
'MD5 check failed (' . $name .
')');
3151 $this->
error(
'File read error: InitString had a wrong length. (' . $name .
')');
3154 $this->
error(
'File read error: Warning message in file. (' . $initStr . fgets($fd) .
')');
3168 $this->dat[
'header'] = $this->
getNextContentPart($filecontent, $pointer, 1,
'header');
3169 $this->dat[
'records'] = $this->
getNextContentPart($filecontent, $pointer, 1,
'records');
3185 $initStrLen = 32 + 1 + 1 + 1 + 10 + 1;
3187 $initStr = substr($filecontent, $pointer, $initStrLen);
3188 $pointer += $initStrLen;
3189 $initStrDat = explode(
':', $initStr);
3190 if ((
string)$initStrDat[3] ===
'') {
3191 $datString = substr($filecontent, $pointer, (
int)$initStrDat[2]);
3192 $pointer += (int)$initStrDat[2] + 1;
3193 if (md5($datString) === $initStrDat[0]) {
3194 if ($initStrDat[1]) {
3195 if ($this->compress) {
3196 $datString = gzuncompress($datString);
3198 $this->
error(
'Content read error: This file requires decompression, but this server does not offer gzcompress()/gzuncompress() functions.', 1);
3201 return $unserialize ? unserialize($datString) : $datString;
3203 $this->
error(
'MD5 check failed (' . $name .
')');
3206 $this->
error(
'Content read error: InitString had a wrong length. (' . $name .
')');
3217 $this->relStaticTables = (array) $this->dat[
'header'][
'relStaticTables'];
3218 $this->excludeMap = (array) $this->dat[
'header'][
'excludeMap'];
3219 $this->softrefCfg = (array) $this->dat[
'header'][
'softrefCfg'];
3220 $this->extensionDependencies = (array) $this->dat[
'header'][
'extensionDependencies'];
3222 if (isset($this->dat[
'header'][
'meta'][
'TYPO3_version']) && \
TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($this->dat[
'header'][
'meta'][
'TYPO3_version']) < 6000000){
3223 $this->legacyImport = TRUE;
3224 $this->initializeLegacyImportFolder();
3237 $importCharset = $this->dat[
'header'][
'charset'];
3238 if ($importCharset) {
3239 if ($importCharset !== $LANG->charSet) {
3240 $this->
error(
'CHARSET: Converting charset of input file (' . $importCharset .
') to the system charset (' . $LANG->charSet .
')');
3242 if (is_array($this->dat[
'header'][
'meta'])) {
3243 $LANG->csConvObj->convArray($this->dat[
'header'][
'meta'], $importCharset, $LANG->charSet);
3246 if (is_array($this->dat[
'header'][
'records'])) {
3247 $LANG->csConvObj->convArray($this->dat[
'header'][
'records'], $importCharset, $LANG->charSet);
3250 if (is_array($this->dat[
'records'])) {
3251 $LANG->csConvObj->convArray($this->dat[
'records'], $importCharset, $LANG->charSet);
3255 $this->
error(
'CHARSET: No charset found in import file!');
3272 if (is_array($this->dat[
'header'][
'extensionDependencies'])) {
3273 foreach ($this->dat[
'header'][
'extensionDependencies'] as $extKey) {
3274 if (!empty($extKey) && !\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) {
3275 $this->
error(
'DEPENDENCY: The extension with key "' . $extKey .
'" must be installed!');
3280 unset($this->dat[
'files']);
3282 $this->remainHeader = $this->dat[
'header'];
3283 if (is_array($this->remainHeader)) {
3285 if (is_array($this->dat[
'header'][
'pagetree'])) {
3286 reset($this->dat[
'header'][
'pagetree']);
3291 <tr class="bgColor5 tableheader"> 3292 <td>' . $LANG->getLL(
'impexpcore_displaycon_controls', TRUE) .
'</td> 3293 <td>' . $LANG->getLL(
'impexpcore_displaycon_title', TRUE) .
'</td> 3294 <td>' . $LANG->getLL(
'impexpcore_displaycon_size', TRUE) .
'</td> 3295 <td>' . $LANG->getLL(
'impexpcore_displaycon_message', TRUE) .
'</td> 3296 ' . ($this->update ?
'<td>' . $LANG->getLL(
'impexpcore_displaycon_updateMode', TRUE) .
'</td>' :
'') .
' 3297 ' . ($this->update ?
'<td>' . $LANG->getLL(
'impexpcore_displaycon_currentPath', TRUE) .
'</td>' :
'') .
' 3298 ' . ($this->showDiff ?
'<td>' . $LANG->getLL(
'impexpcore_displaycon_result', TRUE) .
'</td>' :
'') .
' 3300 foreach ($lines as $r) {
3302 <tr class="' . $r[
'class'] .
'"> 3304 <td nowrap="nowrap">' . $r[
'preCode'] . $r[
'title'] .
'</td> 3306 <td nowrap="nowrap">' . ($r[
'msg'] && !$this->doesImport ?
'<span class="typo3-red">' . htmlspecialchars($r[
'msg']) .
'</span>' :
'') .
'</td> 3307 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updateMode'] .
'</td>' :
'') .
' 3308 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updatePath'] .
'</td>' :
'') .
' 3309 ' . ($this->showDiff ?
'<td>' . $r[
'showDiffContent'] .
'</td>' :
'') .
' 3313 <strong>' . $LANG->getLL(
'impexpcore_displaycon_insidePagetree', TRUE) .
'</strong> 3315 <table border="0" cellpadding="0" cellspacing="1">' . implode(
'', $rows) .
'</table> 3320 if (is_array($this->remainHeader[
'records'])) {
3321 if (is_array($this->remainHeader[
'records'][
'pages'])) {
3325 if (count($lines)) {
3328 <tr class="bgColor5 tableheader"> 3329 <td>' . $LANG->getLL(
'impexpcore_displaycon_controls', TRUE) .
'</td> 3330 <td>' . $LANG->getLL(
'impexpcore_displaycon_title', TRUE) .
'</td> 3331 <td>' . $LANG->getLL(
'impexpcore_displaycon_size', TRUE) .
'</td> 3332 <td>' . $LANG->getLL(
'impexpcore_displaycon_message', TRUE) .
'</td> 3333 ' . ($this->update ?
'<td>' . $LANG->getLL(
'impexpcore_displaycon_updateMode', TRUE) .
'</td>' :
'') .
' 3334 ' . ($this->update ?
'<td>' . $LANG->getLL(
'impexpcore_displaycon_currentPath', TRUE) .
'</td>' :
'') .
' 3335 ' . ($this->showDiff ?
'<td>' . $LANG->getLL(
'impexpcore_displaycon_result', TRUE) .
'</td>' :
'') .
' 3337 foreach ($lines as $r) {
3338 $rows[] =
'<tr class="' . $r[
'class'] .
'"> 3340 <td nowrap="nowrap">' . $r[
'preCode'] . $r[
'title'] .
'</td> 3342 <td nowrap="nowrap">' . ($r[
'msg'] && !$this->doesImport ?
'<span class="typo3-red">' . htmlspecialchars($r[
'msg']) .
'</span>' :
'') .
'</td> 3343 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updateMode'] .
'</td>' :
'') .
' 3344 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updatePath'] .
'</td>' :
'') .
' 3345 ' . ($this->showDiff ?
'<td>' . $r[
'showDiffContent'] .
'</td>' :
'') .
' 3349 <strong>' . $LANG->getLL(
'impexpcore_singlereco_outsidePagetree', TRUE) .
'</strong> 3351 <table border="0" cellpadding="0" cellspacing="1">' . implode(
'', $rows) .
'</table>';
3368 foreach ($pT as $k => $v) {
3372 if (is_array($this->dat[
'header'][
'pid_lookup'][$k])) {
3373 foreach ($this->dat[
'header'][
'pid_lookup'][$k] as $t => $recUidArr) {
3374 if ($t !=
'pages') {
3375 foreach ($recUidArr as $ruid => $value) {
3376 $this->
singleRecordLines($t, $ruid, $lines, $preCode .
' ');
3380 unset($this->remainHeader[
'pid_lookup'][$k]);
3383 if (is_array($v[
'subrow'])) {
3384 $this->
traversePageTree($v[
'subrow'], $lines, $preCode .
' ');
3398 foreach ($pT as $k => $rHeader) {
3401 if (is_array($this->dat[
'header'][
'pid_lookup'][$k])) {
3402 foreach ($this->dat[
'header'][
'pid_lookup'][$k] as $t => $recUidArr) {
3403 if ($t !=
'pages') {
3404 foreach ($recUidArr as $ruid => $value) {
3409 unset($this->remainHeader[
'pid_lookup'][$k]);
3423 foreach ($pT as $t => $recUidArr) {
3425 if ($t !=
'pages') {
3427 foreach ($recUidArr as $ruid => $value) {
3441 if ($this->update && $table ===
'sys_file') {
3442 $this->
error(
'Updating sys_file records is not supported! They will be imported as new records!');
3444 if ($this->force_all_UIDS && $table ===
'sys_file') {
3445 $this->
error(
'Forcing uids of sys_file records is not supported! They will be imported as new records!');
3463 $record = $this->dat[
'header'][
'records'][$table][
$uid];
3464 unset($this->remainHeader[
'records'][$table][
$uid]);
3465 if (!is_array($record) && !($table ===
'pages' && !$uid)) {
3466 $this->
error(
'MISSING RECORD: ' . $table .
':' . $uid, 1);
3470 $pInfo[
'ref'] = $table .
':' .
$uid;
3472 if ($table ===
'_SOFTREF_') {
3473 $pInfo[
'preCode'] = $preCode;
3474 $pInfo[
'title'] =
'<em>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_singlereco_softReferencesFiles', TRUE) .
'</em>';
3475 } elseif (!isset(
$GLOBALS[
'TCA'][$table])) {
3477 $pInfo[
'preCode'] = $preCode;
3478 $pInfo[
'msg'] =
'UNKNOWN TABLE \'' . $pInfo[
'ref'] .
'\'';
3479 $pInfo[
'title'] =
'<em>' . htmlspecialchars($record[
'title']) .
'</em>';
3483 if (is_array($this->display_import_pid_record)) {
3484 if ($checkImportInPidRecord) {
3485 if (!
$GLOBALS[
'BE_USER']->doesUserHaveAccess($this->display_import_pid_record, ($table ===
'pages' ? 8 : 16))) {
3486 $pInfo[
'msg'] .=
'\'' . $pInfo[
'ref'] .
'\' cannot be INSERTED on
this page!
'; 3488 if (!$this->checkDokType($table, $this->display_import_pid_record['doktype
']) && !$GLOBALS['TCA
'][$table]['ctrl
']['rootLevel
']) { 3489 $pInfo['msg
'] .= '\
'' . $table .
'\' cannot be INSERTED on
this page type (change page type to \
'Folder\'.) ';
3492 if (!
$GLOBALS[
'BE_USER']->check(
'tables_modify', $table)) {
3493 $pInfo[
'msg'] .=
'You are not allowed to CREATE \'' . $table .
'\' tables!
'; 3495 if ($GLOBALS['TCA
'][$table]['ctrl
']['readOnly
']) { 3496 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' is READ ONLY!
'; 3498 if ($GLOBALS['TCA
'][$table]['ctrl
']['adminOnly
'] && !$GLOBALS['BE_USER
']->isAdmin()) { 3499 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' is ADMIN ONLY!
'; 3501 if ($GLOBALS['TCA
'][$table]['ctrl
']['is_static
']) { 3502 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' is a STATIC TABLE!
'; 3504 if ((int)$GLOBALS['TCA
'][$table]['ctrl
']['rootLevel
'] === 1) { 3505 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' will be inserted on ROOT LEVEL!
'; 3507 $diffInverse = FALSE; 3508 if ($this->update) { 3509 // In case of update-PREVIEW we swap the diff-sources. 3510 $diffInverse = TRUE; 3511 $recInf = $this->doesRecordExist($table, $uid, $this->showDiff ? '*
' : ''); 3512 $pInfo['updatePath
'] = $recInf ? htmlspecialchars($this->getRecordPath($recInf['pid
'])) : '<strong>NEW!</strong>
'; 3514 $optValues = array(); 3515 $optValues[] = $recInf ? $LANG->getLL('impexpcore_singlereco_update
') : $LANG->getLL('impexpcore_singlereco_insert
'); 3517 $optValues['as_new
'] = $LANG->getLL('impexpcore_singlereco_importAsNew
'); 3520 if (!$this->global_ignore_pid) { 3521 $optValues['ignore_pid
'] = $LANG->getLL('impexpcore_singlereco_ignorePid
'); 3523 $optValues['respect_pid
'] = $LANG->getLL('impexpcore_singlereco_respectPid
'); 3526 if (!$recInf && $GLOBALS['BE_USER
']->isAdmin()) { 3527 $optValues['force_uid
'] = sprintf($LANG->getLL('impexpcore_singlereco_forceUidSAdmin
'), $uid); 3529 $optValues['exclude
'] = $LANG->getLL('impexpcore_singlereco_exclude
'); 3530 if ($table === 'sys_file
') { 3531 $pInfo['updateMode
'] = ''; 3533 $pInfo['updateMode
'] = $this->renderSelectBox('tx_impexp[import_mode][
' . $table . ':
' . $uid . ']
', $this->import_mode[$table . ':
' . $uid], $optValues); 3537 if ($this->showDiff) { 3538 // For IMPORTS, get new id: 3539 if ($newUid = $this->import_mapId[$table][$uid]) { 3540 $diffInverse = FALSE; 3541 $recInf = $this->doesRecordExist($table, $newUid, '*
'); 3542 BackendUtility::workspaceOL($table, $recInf); 3544 if (is_array($recInf)) { 3545 $pInfo['showDiffContent
'] = $this->compareRecords($recInf, $this->dat['records
'][$table . ':
' . $uid]['data
'], $table, $diffInverse); 3549 $pInfo['preCode
'] = $preCode . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($table, (array) $this->dat['records
'][($table . ':
' . $uid)]['data
'], array('title
' => htmlspecialchars(($table . ':
' . $uid)))); 3550 $pInfo['title
'] = htmlspecialchars($record['title
']); 3552 if ($table === 'pages
') { 3553 $viewID = $this->mode === 'export
' ? $uid : ($this->doesImport ? $this->import_mapId['pages
'][$uid] : 0); 3555 $pInfo['title
'] = '<a href=
"#" onclick=
"' . htmlspecialchars(BackendUtility::viewOnClick($viewID, $GLOBALS['BACK_PATH'])) . 'return false;">
' . $pInfo['title
'] . '</a>
'; 3559 $pInfo['class'] = $table == 'pages
' ? 'bgColor4-20
' : 'bgColor4
'; 3560 $pInfo['type
'] = 'record
'; 3561 $pInfo['size
'] = $record['size
']; 3564 if (is_array($record['filerefs
'])) { 3565 $this->addFiles($record['filerefs
'], $lines, $preCode); 3568 if (is_array($record['rels
'])) { 3569 $this->addRelations($record['rels
'], $lines, $preCode); 3572 if (count($record['softrefs
'])) { 3573 $preCode_A = $preCode . '
'; 3574 $preCode_B = $preCode . '
'; 3575 foreach ($record['softrefs
'] as $info) { 3577 $pInfo['preCode
'] = $preCode_A . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-reference-soft
'); 3578 $pInfo['title
'] = '<em>
' . $info['field
'] . ',
"' . $info['spKey'] . '" </em>: <span title=
"' . htmlspecialchars($info['matchString']) . '">
' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['matchString
'], 60)) . '</span>
'; 3579 if ($info['subst
']['type
']) { 3580 if (strlen($info['subst
']['title
'])) { 3581 $pInfo['title
'] .= '<br/>
' . $preCode_B . '<strong>
' . $LANG->getLL('impexpcore_singlereco_title
', TRUE) . '</strong>
' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst
']['title
'], 60)); 3583 if (strlen($info['subst
']['description
'])) { 3584 $pInfo['title
'] .= '<br/>
' . $preCode_B . '<strong>
' . $LANG->getLL('impexpcore_singlereco_descr
', TRUE) . '</strong>
' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst
']['description
'], 60)); 3586 $pInfo['title
'] .= '<br/>
' . $preCode_B . ($info['subst
']['type
'] == 'file
' ? $LANG->getLL('impexpcore_singlereco_filename
', TRUE) . ' <strong>
' . $info['subst
']['relFileName
'] . '</strong>
' : '') . ($info['subst
']['type
'] == 'string' ? $LANG->getLL('impexpcore_singlereco_value
', TRUE) . ' <strong>
' . $info['subst
']['tokenValue
'] . '</strong>
' : '') . ($info['subst
']['type
'] == 'db
' ? $LANG->getLL('impexpcore_softrefsel_record
', TRUE) . ' <strong>
' . $info['subst
']['recordRef
'] . '</strong>
' : ''); 3588 $pInfo['ref
'] = 'SOFTREF
'; 3589 $pInfo['size
'] = ''; 3590 $pInfo['class'] = 'bgColor3
'; 3591 $pInfo['type
'] = 'softref
'; 3592 $pInfo['_softRefInfo
'] = $info; 3593 $pInfo['type
'] = 'softref
'; 3594 if ($info['error'] && !GeneralUtility::inList('editable,exclude
', $this->softrefCfg[$info['subst
']['tokenID
']]['mode
'])) { 3595 $pInfo['msg
'] .= $info['error']; 3599 if ($info['subst
']['type
'] == 'db
') { 3600 list($tempTable, $tempUid) = explode(':
', $info['subst
']['recordRef
']); 3601 $this->addRelations(array(array('table
' => $tempTable, 'id' => $tempUid, 'tokenID
' => $info['subst
']['tokenID
'])), $lines, $preCode_B, array(), ''); 3604 if ($info['subst
']['type
'] == 'file
') { 3605 $this->addFiles(array($info['file_ID
']), $lines, $preCode_B, '', $info['subst
']['tokenID
']); 3624 public function addRelations($rels, &$lines, $preCode, $recurCheck = array(), $htmlColorClass = '') { 3625 foreach ($rels as $dat) { 3626 $table = $dat['table
']; 3629 $pInfo['ref
'] = $table . ':
' . $uid; 3630 if (in_array($pInfo['ref
'], $recurCheck)) { 3634 $staticFixed = FALSE; 3637 $record = $this->dat['header
']['records
'][$table][$uid]; 3638 if (!is_array($record)) { 3639 if ($this->isTableStatic($table) || $this->isExcluded($table, $uid) || $dat['tokenID
'] && !$this->includeSoftref($dat['tokenID
'])) { 3640 $pInfo['title
'] = htmlspecialchars('STATIC:
' . $pInfo['ref
']); 3641 $Iprepend = '_static
'; 3642 $staticFixed = TRUE; 3644 $doesRE = $this->doesRecordExist($table, $uid); 3645 $lostPath = $this->getRecordPath($table === 'pages
' ? $doesRE['uid
'] : $doesRE['pid
']); 3646 $pInfo['title
'] = htmlspecialchars($pInfo['ref
']); 3647 $pInfo['title
'] = '<span title=
"' . htmlspecialchars($lostPath) . '">
' . $pInfo['title
'] . '</span>
'; 3648 $pInfo['msg
'] = 'LOST RELATION
' . (!$doesRE ? ' (Record not found!)
' : ' (Path:
' . $lostPath . ')
'); 3649 $Iprepend = '_lost
'; 3652 $pInfo['title
'] = htmlspecialchars($record['title
']); 3653 $pInfo['title
'] = '<span title=
"' . htmlspecialchars($this->getRecordPath(($table === 'pages' ? $record['uid'] : $record['pid']))) . '">
' . $pInfo['title
'] . '</span>
'; 3656 // Negative values in relation fields. This is typically sys_language fields, fe_users fields etc. They are static values. They CAN theoretically be negative pointers to uids in other tables but this is so rarely used that it is not supported 3657 $pInfo['title
'] = htmlspecialchars('FIXED:
' . $pInfo['ref
']); 3658 $staticFixed = TRUE; 3660 $pInfo['preCode
'] = $preCode . ' <img
' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH
'], ('gfx/rel_db
' . $Iprepend . '.gif
'), 'width=
"13" height=
"12"') . ' align=
"top" title=
"' . htmlspecialchars($pInfo['ref']) . '" alt=
"" />
'; 3661 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
'; 3662 $pInfo['type
'] = 'rel
'; 3663 if (!$staticFixed || $this->showStaticRelations) { 3665 if (is_array($record) && is_array($record['rels
'])) { 3666 $this->addRelations($record['rels
'], $lines, $preCode . '
', array_merge($recurCheck, array($pInfo['ref
'])), $htmlColorClass); 3685 public function addFiles($rels, &$lines, $preCode, $htmlColorClass = '', $tokenID = '') { 3686 foreach ($rels as $ID) { 3689 $fI = $this->dat['header
']['files
'][$ID]; 3690 if (!is_array($fI)) { 3691 if (!$tokenID || $this->includeSoftref($tokenID)) { 3692 $pInfo['msg
'] = 'MISSING FILE:
' . $ID; 3693 $this->error('MISSING FILE:
' . $ID, 1); 3698 $pInfo['preCode
'] = $preCode . '
' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-reference-hard
'); 3699 $pInfo['title
'] = htmlspecialchars($fI['filename
']); 3700 $pInfo['ref
'] = 'FILE
'; 3701 $pInfo['size
'] = $fI['filesize
']; 3702 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
'; 3703 $pInfo['type
'] = 'file
'; 3704 // If import mode and there is a non-RTE softreference, check the destination directory: 3705 if ($this->mode === 'import' && $tokenID && !$fI['RTE_ORIG_ID
']) { 3706 if (isset($fI['parentRelFileName
'])) { 3707 $pInfo['msg
'] = 'Seems like
this file is already referenced from within an HTML/CSS file. That takes precedence.
'; 3709 $testDirPrefix = PathUtility::dirname($fI['relFileName
']) . '/
'; 3710 $testDirPrefix2 = $this->verifyFolderAccess($testDirPrefix); 3711 if (!$testDirPrefix2) { 3712 $pInfo['msg
'] = 'ERROR: There are no available filemounts to write file in!
'; 3713 } elseif ($testDirPrefix !== $testDirPrefix2) { 3714 $pInfo['msg
'] = 'File will be attempted written to
"' . $testDirPrefix2 . '".
'; 3717 // Check if file exists: 3718 if (file_exists(PATH_site . $fI['relFileName
'])) { 3719 if ($this->update) { 3720 $pInfo['updatePath
'] .= 'File exists.
'; 3722 $pInfo['msg
'] .= 'File already exists!
'; 3726 $fileProcObj = $this->getFileProcObj(); 3727 if ($fileProcObj->actionPerms['addFile
']) { 3728 $testFI = GeneralUtility::split_fileref(PATH_site . $fI['relFileName
']); 3729 if (!$this->allowPHPScripts && !$fileProcObj->checkIfAllowed($testFI['fileext
'], $testFI['path
'], $testFI['file
'])) { 3730 $pInfo['msg
'] .= 'File extension was not allowed!
'; 3733 $pInfo['msg
'] = 'You user profile does not allow you to create files on the server!
'; 3736 $pInfo['showDiffContent
'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]); 3738 unset($this->remainHeader['files
'][$ID]); 3740 if ($fI['RTE_ORIG_ID
']) { 3741 $ID = $fI['RTE_ORIG_ID
']; 3743 $fI = $this->dat['header
']['files
'][$ID]; 3744 if (!is_array($fI)) { 3745 $pInfo['msg
'] = 'MISSING RTE original FILE:
' . $ID; 3746 $this->error('MISSING RTE original FILE:
' . $ID, 1); 3748 $pInfo['showDiffContent
'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]); 3749 $pInfo['preCode
'] = $preCode . '
' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-reference-file
'); 3750 $pInfo['title
'] = htmlspecialchars($fI['filename
']) . ' <em>(Original)</em>
'; 3751 $pInfo['ref
'] = 'FILE
'; 3752 $pInfo['size
'] = $fI['filesize
']; 3753 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
'; 3754 $pInfo['type
'] = 'file
'; 3756 unset($this->remainHeader['files
'][$ID]); 3758 // External resources: 3759 if (is_array($fI['EXT_RES_ID
'])) { 3760 foreach ($fI['EXT_RES_ID
'] as $ID) { 3762 $fI = $this->dat['header
']['files
'][$ID]; 3763 if (!is_array($fI)) { 3764 $pInfo['msg
'] = 'MISSING External Resource FILE:
' . $ID; 3765 $this->error('MISSING External Resource FILE:
' . $ID, 1); 3767 $pInfo['updatePath
'] = $fI['parentRelFileName
']; 3769 $pInfo['showDiffContent
'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]); 3770 $pInfo['preCode
'] = $preCode . '
' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-insert-reference
'); 3771 $pInfo['title
'] = htmlspecialchars($fI['filename
']) . ' <em>(Resource)</em>
'; 3772 $pInfo['ref
'] = 'FILE
'; 3773 $pInfo['size
'] = $fI['filesize
']; 3774 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
'; 3775 $pInfo['type
'] = 'file
'; 3777 unset($this->remainHeader['files
'][$ID]); 3791 public function checkDokType($checkTable, $doktype) { 3792 global $PAGES_TYPES; 3793 $allowedTableList = isset($PAGES_TYPES[$doktype]['allowedTables
']) ? $PAGES_TYPES[$doktype]['allowedTables
'] : $PAGES_TYPES['default']['allowedTables
']; 3794 $allowedArray = GeneralUtility::trimExplode(',
', $allowedTableList, TRUE); 3795 // If all tables or the table is listed as a allowed type, return TRUE 3796 if (strstr($allowedTableList, '*
') || in_array($checkTable, $allowedArray)) { 3808 public function renderControls($r) { 3810 if ($this->mode === 'export
') { 3811 return $r['type
'] == 'record
' ? '<input type=
"checkbox" name=
"tx_impexp[exclude][' . $r['ref'] . ']" id=
"checkExclude' . $r['ref'] . '" value=
"1" /> <label
for=
"checkExclude' . $r['ref'] . '">
' . $LANG->getLL('impexpcore_singlereco_exclude
', TRUE) . '</label>
' : ($r['type
'] == 'softref
' ? $this->softrefSelector($r['_softRefInfo
']) : ''); 3814 // For softreferences with editable fields: 3815 if ($r['type
'] == 'softref
' && is_array($r['_softRefInfo
']['subst
']) && $r['_softRefInfo
']['subst
']['tokenID
']) { 3816 $tokenID = $r['_softRefInfo
']['subst
']['tokenID
']; 3817 $cfg = $this->softrefCfg[$tokenID]; 3818 if ($cfg['mode
'] === 'editable
') { 3819 return (strlen($cfg['title
']) ? '<strong>
' . htmlspecialchars($cfg['title
']) . '</strong><br/>
' : '') . htmlspecialchars($cfg['description
']) . '<br/>
3820 <input type=
"text" name=
"tx_impexp[softrefInputValues][' . $tokenID . ']" value=
"' . htmlspecialchars((isset($this->softrefInputValues[$tokenID]) ? $this->softrefInputValues[$tokenID] : $cfg['defValue'])) . '" />
'; 3833 public function softrefSelector($cfg) { 3835 // Looking for file ID if any: 3836 $fI = $cfg['file_ID
'] ? $this->dat['header
']['files
'][$cfg['file_ID
']] : array(); 3837 // Substitution scheme has to be around and RTE images MUST be exported. 3838 if (is_array($cfg['subst
']) && $cfg['subst
']['tokenID
'] && !$fI['RTE_ORIG_ID
']) { 3840 $optValues = array(); 3841 $optValues[''] = ''; 3842 $optValues['editable
'] = $LANG->getLL('impexpcore_softrefsel_editable
'); 3843 $optValues['exclude
'] = $LANG->getLL('impexpcore_softrefsel_exclude
'); 3844 // Get current value: 3845 $value = $this->softrefCfg[$cfg['subst
']['tokenID
']]['mode
']; 3846 // Render options selector: 3847 $selectorbox = $this->renderSelectBox(('tx_impexp[softrefCfg][
' . $cfg['subst
']['tokenID
'] . '][mode]
'), $value, $optValues) . '<br/>
'; 3848 if ($value === 'editable
') { 3849 $descriptionField = ''; 3851 if (strlen($cfg['subst
']['title
'])) { 3852 $descriptionField .= ' 3853 <input type=
"hidden" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][title]" value=
"' . htmlspecialchars($cfg['subst']['title']) . '" />
3854 <strong>
' . htmlspecialchars($cfg['subst
']['title
']) . '</strong><br/>
'; 3857 if (!strlen($cfg['subst
']['description
'])) { 3858 $descriptionField .= ' 3859 ' . $LANG->getLL('impexpcore_printerror_description
', TRUE) . '<br/>
3860 <input type=
"text" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][description]" value=
"' . htmlspecialchars($this->softrefCfg[$cfg['subst']['tokenID']]['description']) . '" />
'; 3862 $descriptionField .= ' 3864 <input type=
"hidden" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][description]" value=
"' . htmlspecialchars($cfg['subst']['description']) . '" />
' . htmlspecialchars($cfg['subst
']['description
']); 3867 $descriptionField .= '<input type=
"hidden" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][defValue]" value=
"' . htmlspecialchars($cfg['subst']['tokenValue']) . '" />
'; 3869 $descriptionField = ''; 3871 return $selectorbox . $descriptionField; 3875 /***************************** 3876 * Helper functions of kinds 3877 *****************************/ 3886 public function isTableStatic($table) { 3887 if (is_array($GLOBALS['TCA
'][$table])) { 3888 return $GLOBALS['TCA
'][$table]['ctrl
']['is_static
'] || in_array($table, $this->relStaticTables) || in_array('_ALL
', $this->relStaticTables); 3899 public function inclRelation($table) { 3900 if (is_array($GLOBALS['TCA
'][$table])) { 3901 return (in_array($table, $this->relOnlyTables) || in_array('_ALL
', $this->relOnlyTables)) && $GLOBALS['BE_USER
']->check('tables_select
', $table); 3913 public function isExcluded($table, $uid) { 3914 return $this->excludeMap[$table . ':
' . $uid] ? TRUE : FALSE; 3924 public function includeSoftref($tokenID) { 3925 return $tokenID && !GeneralUtility::inList('exclude,editable
', $this->softrefCfg[$tokenID]['mode
']); 3935 public function checkPID($pid) { 3936 if (!isset($this->checkPID_cache[$pid])) { 3937 $this->checkPID_cache[$pid] = (bool) $GLOBALS['BE_USER
']->isInWebMount($pid); 3939 return $this->checkPID_cache[$pid]; 3950 public function dontIgnorePid($table, $uid) { 3951 return $this->import_mode[$table . ':
' . $uid] !== 'ignore_pid
' && (!$this->global_ignore_pid || $this->import_mode[$table . ':
' . $uid] === 'respect_pid
'); 3963 public function doesRecordExist($table, $uid, $fields = '') { 3964 return BackendUtility::getRecord($table, $uid, $fields ? $fields : 'uid,pid
'); 3974 public function getRecordPath($pid) { 3975 if (!isset($this->cache_getRecordPath[$pid])) { 3976 $clause = $GLOBALS['BE_USER
']->getPagePermsClause(1); 3977 $this->cache_getRecordPath[$pid] = (string) BackendUtility::getRecordPath($pid, $clause, 20); 3979 return $this->cache_getRecordPath[$pid]; 3991 public function renderSelectBox($prefix, $value, $optValues) { 3994 foreach ($optValues as $k => $v) { 3995 $sel = (string)$k === (string)$value ? ' selected=
"selected"' : ''; 3999 $opt[] = '<option value=
"' . htmlspecialchars($k) . '"' . $sel . '>
' . htmlspecialchars($v) . '</option>
'; 4001 if (!$isSelFlag && (string)$value !== '') { 4002 $opt[] = '<option value=
"' . htmlspecialchars($value) . '" selected=
"selected">
' . htmlspecialchars(('[\
'' . $value .
'\']
')) . '</option>
'; 4004 return '<select name=
"' . $prefix . '">
' . implode('', $opt) . '</select>
'; 4017 public function compareRecords($databaseRecord, $importRecord, $table, $inverseDiff = FALSE) { 4021 $t3lib_diff_Obj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\DiffUtility
'); 4022 // Check if both inputs are records: 4023 if (is_array($databaseRecord) && is_array($importRecord)) { 4024 // Traverse based on database record 4025 foreach ($databaseRecord as $fN => $value) { 4026 if (is_array($GLOBALS['TCA
'][$table]['columns
'][$fN]) && $GLOBALS['TCA
'][$table]['columns
'][$fN]['config
']['type
'] != 'passthrough
') { 4027 if (isset($importRecord[$fN])) { 4028 if (trim($databaseRecord[$fN]) !== trim($importRecord[$fN])) { 4029 // Create diff-result: 4030 $output[$fN] = $t3lib_diff_Obj->makeDiffDisplay(BackendUtility::getProcessedValue($table, $fN, !$inverseDiff ? $importRecord[$fN] : $databaseRecord[$fN], 0, 1, 1), BackendUtility::getProcessedValue($table, $fN, !$inverseDiff ? $databaseRecord[$fN] : $importRecord[$fN], 0, 1, 1)); 4032 unset($importRecord[$fN]); 4036 // Traverse remaining in import record: 4037 foreach ($importRecord as $fN => $value) { 4038 if (is_array($GLOBALS['TCA
'][$table]['columns
'][$fN]) && $GLOBALS['TCA
'][$table]['columns
'][$fN]['config
']['type
'] !== 'passthrough
') { 4039 $output[$fN] = '<strong>Field missing</strong> in database
'; 4043 if (count($output)) { 4045 foreach ($output as $fN => $state) { 4048 <td
class=
"bgColor5">
' . $GLOBALS['LANG
']->sL($GLOBALS['TCA
'][$table]['columns
'][$fN]['label
'], TRUE) . ' (
' . htmlspecialchars($fN) . ')</td>
4049 <td
class=
"bgColor4">
' . $state . '</td>
4053 $output = '<table border=
"0" cellpadding=
"0" cellspacing=
"1">
' . implode('', $tRows) . '</table>
'; 4057 return '<strong
class=
"nobr">[
' . htmlspecialchars(($table . ':
' . $importRecord['uid
'] . ' =>
' . $databaseRecord['uid
'])) . ']:</strong>
' . $output; 4059 return 'ERROR: One of the inputs were not an array!
'; 4069 public function getRTEoriginalFilename($string) { 4070 // If "magic image": 4071 if (GeneralUtility::isFirstPartOfStr($string, 'RTEmagicC_
')) { 4072 // Find original file: 4073 $pI = pathinfo(substr($string, strlen('RTEmagicC_
'))); 4074 $filename = substr($pI['basename
'], 0, -strlen(('.
' . $pI['extension
']))); 4075 $origFilePath = 'RTEmagicP_
' . $filename; 4076 return $origFilePath; 4086 public function getFileProcObj() { 4087 if (!is_object($this->fileProcObj)) { 4088 $this->fileProcObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\ExtendedFileUtility
'); 4089 $this->fileProcObj->init(array(), $GLOBALS['TYPO3_CONF_VARS
']['BE
']['fileExtensions
']); 4090 $this->fileProcObj->setActionPermissions(); 4092 return $this->fileProcObj; 4102 public function callHook($name, $params) { 4103 if (is_array($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['ext/impexp/
class.tx_impexp.php
'][$name])) { 4104 foreach ($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['ext/impexp/
class.tx_impexp.php
'][$name] as $hook) { 4105 GeneralUtility::callUserFunction($hook, $params, $this); 4110 /***************************** 4112 *****************************/ 4121 public function error($msg) { 4122 $this->errorLog[] = $msg; 4131 public function printErrorLog() { 4132 return count($this->errorLog) ? \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($this->errorLog) : ''; addFilePart($data, $compress=FALSE)
loadFile($filename, $all=0)
$defaultRecordIncludeFields
writeRecords_pages_order($pid)
static unlink_tempfile($uploadedTempFileName)
export_addFile($fI, $recordRef='', $fieldname='')
setRecordTypesIncludeFields(array $recordTypesIncludeFields)
static writeFile($file, $content, $changePermissions=FALSE)
isFallbackStorage($storageId)
addSingle($table, $uid, $pid)
$extFileResourceExtensions
addGeneralErrorsByTable($table)
static isFirstPartOfStr($str, $partStr)
flatInversePageTree_pid($idH, $a=array(), $pid=-1)
static workspaceOL($table, &$row, $wsid=-99, $unsetMovePointers=FALSE)
fixFileIDsInRelations(array $relations)
writeRecords_records($pid)
$recordTypesIncludeFields
setRelations_db($itemArray, $itemConfig)
addThumbnail($imgFilepath)
traversePageRecords($pT, &$lines)
dontIgnorePid($table, $uid)
static makeInstance($className)
export_addSysFile(\TYPO3\CMS\Core\Resource\File $file)
fixUidLocalInSysFileReferenceRecords($oldFileUid, $newFileUid)
loadContent($filecontent)
$display_import_pid_record
export_addFilesFromSysFilesRecords()
verifyFolderAccess($dirPrefix, $noAlternative=FALSE)
getNextFilePart($fd, $unserialize=0, $name='')
static getFlexFormDS($conf, $row, $table, $fieldName='', $WSOL=TRUE, $newRecordPidValue=0)
getRTEoriginalFilename($string)
export_addFilesFromRelations()
static wsMapId($table, $uid)
export_addDBRelations_registerRelation($fI, &$addR, $tokenID='')
processSoftReferences_substTokens($tokenizedContent, $softRefCfgs, $table, $uid)
setMetaData($title, $description, $notes, $packager_username, $packager_name, $packager_email)
processSoftReferences_saveFile($relFileName, $cfg, $table, $uid)
static array2xml(array $array, $NSprefix='', $level=0, $docTag='phparray', $spaceInd=0, array $options=array(), array $stackData=array())
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
writeTemporaryFileFromData($fileId, $dataKey='files_fal')
export_addRecord($table, $row, $relationLevel=0)
writeRecords_records_order($mainPid)
static split_fileref($fileNameWithPath)
traverseAllRecords($pT, &$lines)
traversePageTree($pT, &$lines, $preCode='')
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static getUrl($url, $includeHeader=0, $requestHeaders=FALSE, &$report=NULL)
removeSoftrefsHavingTheSameDatabaseRelation($relations)
unsetExcludedSections($idH)
processSoftReferences_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
static tempnam($filePrefix, $fileSuffix='')
export_addDBRelations($relationLevel=0)
import_addFileNameToBeCopied($fI)
doesRecordExist($table, $uid, $fields='')
checkOrCreateDir($dirPrefix)
setRecordTypeIncludeFields($table, array $fields)
processSoftReferences_saveFile_createRelFile($origDirPrefix, $fileName, $fileID, $table, $uid)
$legacyImportMigrationTables
static formatSize($sizeInBytes, $labels='')
compileMemoryToFileContent($type='')
static fixed_lgd_cs($string, $chars, $appendString='...')
remapListedDBRecords_flexFormCallBack($pParams, $dsConf, $dataValue, $dataValue_ext1, $dataValue_ext2, $path)
flatInversePageTree($idH, $a=array())
writeSysFileResourceForLegacyImport(&$fileName, $fileId)
singleRecordLines($table, $uid, &$lines, $preCode, $checkImportInPidRecord=0)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
$legacyImportMigrationRecords
static inList($list, $item)
static xml2array($string, $NSprefix='', $reportDocTag=FALSE)
addToMapId($substNEWwithIDs)
static getFileAbsFileName($filename, $onlyRelative=TRUE, $relToTYPO3_mainDir=FALSE)
migrateLegacyImportRecords()
writeFileVerify($fileName, $fileID, $bypassMountCheck=FALSE)
init($dontCompress=0, $mode='')
static stripPathSitePrefix($path)
filterRecordFields($table, array $row)
removeSysFileReferenceRecordsFromImportDataWithRelationToMissingFile()
static resolveBackPath($pathStr)
static BEenableFields($table, $inv=0)
static deleteClause($table, $tableAlias='')
getNextContentPart($filecontent, &$pointer, $unserialize=0, $name='')