2 namespace TYPO3\CMS\Impexp;
371 'tt_content' => array(
373 'titleTexts' =>
'titleText',
374 'description' =>
'imagecaption',
375 'links' =>
'image_link',
376 'alternativeTexts' =>
'altText'
379 'description' =>
'imagecaption',
385 'pages_language_overlay' => array(
465 $this->compress = function_exists(
'gzcompress');
468 $this->fileadminFolderName = !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir']) ? rtrim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
'/') :
'fileadmin';
483 if (is_array($this->softrefCfg)) {
484 foreach ($this->softrefCfg as $key => $value) {
485 if (!strlen($value[
'mode'])) {
486 unset($this->softrefCfg[$key]);
492 $this->dat[
'header'][
'XMLversion'] =
'1.0';
494 $this->dat[
'header'][
'meta'] = array();
513 $this->dat[
'header'][
'charset'] = $charset;
527 public function setMetaData($title, $description, $notes, $packager_username, $packager_name, $packager_email)
529 $this->dat[
'header'][
'meta'] = array(
531 'description' => $description,
533 'packager_username' => $packager_username,
534 'packager_name' => $packager_name,
535 'packager_email' => $packager_email,
536 'TYPO3_version' => TYPO3_version,
537 'created' => strftime(
'%A %e. %B %Y',
$GLOBALS[
'EXEC_TIME'])
561 if (@is_file($imgFilepath)) {
562 $imgInfo = @getimagesize($imgFilepath);
563 if (is_array($imgInfo)) {
565 $this->dat[
'header'][
'thumbnail'] = array(
566 'imgInfo' => $imgInfo,
567 'content' => $fileContent,
568 'filesize' => strlen($fileContent),
569 'filemtime' => filemtime($imgFilepath),
602 if (is_array($idH)) {
603 foreach ($idH as $k => $v) {
604 if ($this->excludeMap[
'pages:' . $idH[$k][
'uid']]) {
606 }
elseif (is_array($idH[$k][
'subrow'])) {
624 if (is_array($idH)) {
625 $idH = array_reverse($idH);
626 foreach ($idH as $k => $v) {
627 $a[$v[
'uid']] = $v[
'uid'];
628 if (is_array($v[
'subrow'])) {
647 if (is_array($idH)) {
648 $idH = array_reverse($idH);
649 foreach ($idH as $v) {
650 $a[$v[
'uid']] = $pid;
651 if (is_array($v[
'subrow'])) {
672 foreach ($recordTypesIncludeFields as $table => $fields) {
673 if (!is_array($fields)) {
674 throw new \TYPO3\CMS\Core\Exception(
'The include fields for record type ' . htmlspecialchars($table) .
' are not defined by an array.', 1391440658);
689 $this->recordTypesIncludeFields[$table] = $fields;
704 if ((
string)$table !==
'' && is_array($row) && $row[
'uid'] > 0 && !$this->excludeMap[($table .
':' . $row[
'uid'])]) {
705 if ($this->
checkPID($table ===
'pages' ? $row[
'uid'] : $row[
'pid'])) {
706 if (!isset($this->dat[
'records'][($table .
':' . $row[
'uid'])])) {
709 $headerInfo = array();
710 $headerInfo[
'uid'] = $row[
'uid'];
711 $headerInfo[
'pid'] = $row[
'pid'];
713 $headerInfo[
'size'] = strlen(serialize($row));
714 if ($relationLevel) {
715 $headerInfo[
'relationLevel'] = $relationLevel;
718 if ($headerInfo[
'size'] < $this->maxRecordSize) {
720 $this->dat[
'header'][
'records'][$table][$row[
'uid']] = $headerInfo;
722 $this->dat[
'header'][
'pid_lookup'][$row[
'pid']][$table][$row[
'uid']] = 1;
726 $refIndexObj->WSOL =
true;
727 $relations = $refIndexObj->getRelations($table, $row);
731 $this->dat[
'records'][$table .
':' . $row[
'uid']] = array();
732 $this->dat[
'records'][$table .
':' . $row[
'uid']][
'data'] = $row;
733 $this->dat[
'records'][$table .
':' . $row[
'uid']][
'rels'] = $relations;
734 $this->errorLog = array_merge($this->errorLog, $refIndexObj->errorLog);
737 $this->dat[
'header'][
'records'][$table][$row[
'uid']][
'rels'] = $this->
flatDBrels($this->dat[
'records'][$table .
':' . $row[
'uid']][
'rels']);
739 $this->dat[
'header'][
'records'][$table][$row[
'uid']][
'softrefs'] = $this->
flatSoftRefs($this->dat[
'records'][$table .
':' . $row[
'uid']][
'rels']);
744 $this->
error(
'Record ' . $table .
':' . $row[
'uid'] .
' already added.');
747 $this->
error(
'Record ' . $table .
':' . $row[
'uid'] .
' was outside your DB mounts!');
761 foreach ($relations as $field => $relation) {
762 if (isset($relation[
'type']) && $relation[
'type'] ===
'file') {
763 foreach ($relation[
'newValueFiles'] as $key => $fileRelationData) {
764 $absoluteFilePath = $fileRelationData[
'ID_absFile'];
767 $relations[$field][
'newValueFiles'][$key][
'ID'] = md5($relatedFilePath);
771 if ($relation[
'type'] ===
'flex') {
772 if (is_array($relation[
'flexFormRels'][
'file'])) {
773 foreach ($relation[
'flexFormRels'][
'file'] as $key => $subList) {
774 foreach ($subList as $subKey => $fileRelationData) {
775 $absoluteFilePath = $fileRelationData[
'ID_absFile'];
778 $relations[$field][
'flexFormRels'][
'file'][$key][$subKey][
'ID'] = md5($relatedFilePath);
799 $fixedRelations = array();
800 foreach ($relations as $field => $relation) {
801 $newRelation = $relation;
802 if (isset($newRelation[
'type']) && $newRelation[
'type'] ===
'db') {
803 foreach ($newRelation[
'itemArray'] as $key => $dbRelationData) {
804 if ($dbRelationData[
'table'] ===
'sys_file') {
805 if (isset($newRelation[
'softrefs'][
'keys'][
'typolink'])) {
806 foreach ($newRelation[
'softrefs'][
'keys'][
'typolink'] as $softrefKey => $softRefData) {
807 if ($softRefData[
'subst'][
'type'] ===
'file') {
808 $file = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($softRefData[
'subst'][
'relFileName']);
809 if ($file instanceof \TYPO3\CMS\Core\Resource\File) {
810 if ($file->getUid() == $dbRelationData[
'id']) {
811 unset($newRelation[
'softrefs'][
'keys'][
'typolink'][$softrefKey]);
816 if (empty($newRelation[
'softrefs'][
'keys'][
'typolink'])) {
817 unset($newRelation[
'softrefs']);
823 $fixedRelations[$field] = $newRelation;
825 return $fixedRelations;
842 if (!is_array($this->dat[
'records'])) {
843 $this->
error(
'There were no records available.');
847 foreach ($this->dat[
'records'] as $k => $value) {
848 if (!is_array($this->dat[
'records'][$k])) {
851 foreach ($this->dat[
'records'][$k][
'rels'] as $fieldname => $vR) {
853 if ($vR[
'type'] ==
'db') {
854 foreach ($vR[
'itemArray'] as $fI) {
859 if ($vR[
'type'] ==
'flex') {
861 if (is_array($vR[
'flexFormRels'][
'db'])) {
862 foreach ($vR[
'flexFormRels'][
'db'] as $subList) {
863 foreach ($subList as $fI) {
869 if (is_array($vR[
'flexFormRels'][
'softrefs'])) {
870 foreach ($vR[
'flexFormRels'][
'softrefs'] as $subList) {
871 foreach ($subList[
'keys'] as $spKey => $elements) {
872 foreach ($elements as $el) {
873 if ($el[
'subst'][
'type'] ===
'db' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
874 list($tempTable, $tempUid) = explode(
':', $el[
'subst'][
'recordRef']);
876 'table' => $tempTable,
887 if (is_array($vR[
'softrefs'][
'keys'])) {
888 foreach ($vR[
'softrefs'][
'keys'] as $spKey => $elements) {
889 foreach ($elements as $el) {
890 if ($el[
'subst'][
'type'] ===
'db' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
891 list($tempTable, $tempUid) = explode(
':', $el[
'subst'][
'recordRef']);
893 'table' => $tempTable,
906 foreach ($addR as $fI) {
909 if (is_array($row)) {
916 $rId = $fI[
'table'] .
':' . $fI[
'id'];
917 if (!isset($this->dat[
'records'][$rId])) {
918 $this->dat[
'records'][$rId] =
'NOT_FOUND';
919 $this->
error(
'Relation record ' . $rId .
' was not found!');
939 $rId = $fI[
'table'] .
':' . $fI[
'id'];
944 if (!isset($this->dat[
'records'][$rId])) {
961 if (!is_array($this->dat[
'records'])) {
962 $this->
error(
'There were no records available.');
965 foreach ($this->dat[
'records'] as $k => $value) {
966 if (!isset($this->dat[
'records'][$k][
'rels']) || !is_array($this->dat[
'records'][$k][
'rels'])) {
969 foreach ($this->dat[
'records'][$k][
'rels'] as $fieldname => $vR) {
971 if ($vR[
'type'] ==
'file') {
972 foreach ($vR[
'newValueFiles'] as $key => $fI) {
975 unset($this->dat[
'records'][$k][
'rels'][$fieldname][
'newValueFiles'][$key][
'ID_absFile']);
979 if ($vR[
'type'] ==
'flex') {
980 if (is_array($vR[
'flexFormRels'][
'file'])) {
981 foreach ($vR[
'flexFormRels'][
'file'] as $key => $subList) {
982 foreach ($subList as $subKey => $fI) {
985 unset($this->dat[
'records'][$k][
'rels'][$fieldname][
'flexFormRels'][
'file'][$key][$subKey][
'ID_absFile']);
990 if (is_array($vR[
'flexFormRels'][
'softrefs'])) {
991 foreach ($vR[
'flexFormRels'][
'softrefs'] as $key => $subList) {
992 foreach ($subList[
'keys'] as $spKey => $elements) {
993 foreach ($elements as $subKey => $el) {
994 if ($el[
'subst'][
'type'] ===
'file' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
997 $ID = md5($el[
'subst'][
'relFileName']);
999 if (!$this->dat[
'files'][$ID]) {
1002 'ID_absFile' => $ID_absFile,
1004 'relFileName' => $el[
'subst'][
'relFileName']
1008 $this->dat[
'records'][$k][
'rels'][$fieldname][
'flexFormRels'][
'softrefs'][$key][
'keys'][$spKey][$subKey][
'file_ID'] = $ID;
1017 if (is_array($vR[
'softrefs'][
'keys'])) {
1018 foreach ($vR[
'softrefs'][
'keys'] as $spKey => $elements) {
1019 foreach ($elements as $subKey => $el) {
1020 if ($el[
'subst'][
'type'] ===
'file' && $this->
includeSoftref($el[
'subst'][
'tokenID'])) {
1023 $ID = md5($el[
'subst'][
'relFileName']);
1025 if (!$this->dat[
'files'][$ID]) {
1028 'ID_absFile' => $ID_absFile,
1030 'relFileName' => $el[
'subst'][
'relFileName']
1034 $this->dat[
'records'][$k][
'rels'][$fieldname][
'softrefs'][
'keys'][$spKey][$subKey][
'file_ID'] = $ID;
1051 if (!isset($this->dat[
'header'][
'records'][
'sys_file']) || !is_array($this->dat[
'header'][
'records'][
'sys_file'])) {
1054 foreach ($this->dat[
'header'][
'records'][
'sys_file'] as $sysFileUid => $_) {
1055 $recordData = $this->dat[
'records'][
'sys_file:' . $sysFileUid][
'data'];
1075 if (!$this->saveFilesOutsideExportFile) {
1076 $fileContent = $file->getContents();
1078 $file->checkActionPermission(
'read');
1081 $this->
error(
'Error when trying to add file ' . $file->getCombinedIdentifier() .
': ' . $e->getMessage());
1084 $fileUid = $file->getUid();
1085 $fileInfo = $file->getStorage()->getFileInfo($file);
1087 $fileSize = (string)$fileInfo[
'size'];
1088 if ($fileSize !== $file->getProperty(
'size')) {
1089 $this->
error(
'File size of ' . $file->getCombinedIdentifier() .
' is not up-to-date in index! File added with current size.');
1090 $this->dat[
'records'][
'sys_file:' . $fileUid][
'data'][
'size'] = $fileSize;
1092 $fileSha1 = $file->getStorage()->hashFile($file,
'sha1');
1093 if ($fileSha1 !== $file->getProperty(
'sha1')) {
1094 $this->
error(
'File sha1 hash of ' . $file->getCombinedIdentifier() .
' is not up-to-date in index! File added on current sha1.');
1095 $this->dat[
'records'][
'sys_file:' . $fileUid][
'data'][
'sha1'] = $fileSha1;
1099 $fileRec[
'filesize'] = $fileSize;
1100 $fileRec[
'filename'] = $file->getProperty(
'name');
1101 $fileRec[
'filemtime'] = $file->getProperty(
'modification_date');
1104 $fileId = md5($file->getStorage()->getUid() .
':' . $file->getProperty(
'identifier_hash'));
1107 $this->dat[
'header'][
'files_fal'][$fileId] = $fileRec;
1109 if (!$this->saveFilesOutsideExportFile) {
1111 $fileRec[
'content'] = $fileContent;
1115 $fileRec[
'content_sha1'] = $fileSha1;
1117 $this->dat[
'files_fal'][$fileId] = $fileRec;
1131 if (!@is_file($fI[
'ID_absFile'])) {
1132 $this->
error($fI[
'ID_absFile'] .
' was not a file! Skipping.');
1135 if (filesize($fI[
'ID_absFile']) >= $this->maxFileSize) {
1139 $fileInfo = stat($fI[
'ID_absFile']);
1141 $fileRec[
'filesize'] = $fileInfo[
'size'];
1143 $fileRec[
'filemtime'] = $fileInfo[
'mtime'];
1147 $fileRec[
'record_ref'] = $recordRef .
'/' . $fieldname;
1149 if ($fI[
'relFileName']) {
1150 $fileRec[
'relFileName'] = $fI[
'relFileName'];
1153 $this->dat[
'header'][
'files'][$fI[
'ID']] = $fileRec;
1155 if ($recordRef && $recordRef !==
'_SOFTREF_') {
1156 $refParts = explode(
':', $recordRef, 2);
1157 if (!is_array($this->dat[
'header'][
'records'][$refParts[0]][$refParts[1]][
'filerefs'])) {
1158 $this->dat[
'header'][
'records'][$refParts[0]][$refParts[1]][
'filerefs'] = array();
1160 $this->dat[
'header'][
'records'][$refParts[0]][$refParts[1]][
'filerefs'][] = $fI[
'ID'];
1162 $fileMd5 = md5_file($fI[
'ID_absFile']);
1163 if (!$this->saveFilesOutsideExportFile) {
1169 $fileRec[
'content_md5'] = $fileMd5;
1170 $this->dat[
'files'][$fI[
'ID']] = $fileRec;
1172 if ($recordRef ===
'_SOFTREF_') {
1176 if (@is_file($RTEoriginal_absPath)) {
1177 $RTEoriginal_ID = md5($RTEoriginal_absPath);
1178 $fileInfo = stat($RTEoriginal_absPath);
1180 $fileRec[
'filesize'] = $fileInfo[
'size'];
1182 $fileRec[
'filemtime'] = $fileInfo[
'mtime'];
1183 $fileRec[
'record_ref'] =
'_RTE_COPY_ID:' . $fI[
'ID'];
1184 $this->dat[
'header'][
'files'][$fI[
'ID']][
'RTE_ORIG_ID'] = $RTEoriginal_ID;
1186 $this->dat[
'header'][
'files'][$RTEoriginal_ID] = $fileRec;
1187 $fileMd5 = md5_file($RTEoriginal_absPath);
1188 if (!$this->saveFilesOutsideExportFile) {
1194 $fileRec[
'content_md5'] = $fileMd5;
1195 $this->dat[
'files'][$RTEoriginal_ID] = $fileRec;
1203 if ($this->includeExtFileResources &&
GeneralUtility::inList($this->extFileResourceExtensions, strtolower($html_fI[
'extension']))) {
1204 $uniquePrefix =
'###' . md5(
$GLOBALS[
'EXEC_TIME']) .
'###';
1205 if (strtolower($html_fI[
'extension']) ===
'css') {
1206 $prefixedMedias = explode($uniquePrefix, preg_replace(
'/(url[[:space:]]*\\([[:space:]]*["\']?)([^"\')]*)(["\']?[[:space:]]*\\))/i',
'\\1' . $uniquePrefix .
'\\2' . $uniquePrefix .
'\\3', $fileRec[
'content']));
1210 $prefixedMedias = explode($uniquePrefix, $htmlParser->prefixResourcePath($uniquePrefix, $fileRec[
'content'], array(), $uniquePrefix));
1212 $htmlResourceCaptured =
false;
1213 foreach ($prefixedMedias as $k => $v) {
1218 $htmlResourceCaptured =
true;
1219 $EXTres_ID = md5($EXTres_absPath);
1220 $this->dat[
'header'][
'files'][$fI[
'ID']][
'EXT_RES_ID'][] = $EXTres_ID;
1221 $prefixedMedias[$k] =
'{EXT_RES_ID:' . $EXTres_ID .
'}';
1223 if (!isset($this->dat[
'header'][
'files'][$EXTres_ID])) {
1224 $fileInfo = stat($EXTres_absPath);
1226 $fileRec[
'filesize'] = $fileInfo[
'size'];
1228 $fileRec[
'filemtime'] = $fileInfo[
'mtime'];
1229 $fileRec[
'record_ref'] =
'_EXT_PARENT_:' . $fI[
'ID'];
1231 $fileRec[
'parentRelFileName'] = $v;
1233 $this->dat[
'header'][
'files'][$EXTres_ID] = $fileRec;
1236 $fileRec[
'content_md5'] = md5($fileRec[
'content']);
1237 $this->dat[
'files'][$EXTres_ID] = $fileRec;
1242 if ($htmlResourceCaptured) {
1243 $this->dat[
'files'][$fI[
'ID']][
'tokenizedContent'] = implode(
'', $prefixedMedias);
1259 if (!$this->saveFilesOutsideExportFile) {
1260 throw new \RuntimeException(
'You need to set saveFilesOutsideExportFile to TRUE before you want to get the temporary files path for export.', 1401205213);
1262 if ($this->temporaryFilesPathForExport === null) {
1264 $this->temporaryFilesPathForExport = $temporaryFolderName .
'/';
1275 $temporaryPath = PATH_site .
'typo3temp/';
1277 $temporaryFolderName = $temporaryPath .
'export_temp_files_' . mt_rand(1, PHP_INT_MAX);
1278 }
while (is_dir($temporaryFolderName));
1280 return $temporaryFolderName;
1293 foreach ($dbrels as
$dat) {
1294 if ($dat[
'type'] ==
'db') {
1295 foreach ($dat[
'itemArray'] as $i) {
1296 $list[$i[
'table'] .
':' . $i[
'id']] = $i;
1299 if ($dat[
'type'] ==
'flex' && is_array($dat[
'flexFormRels'][
'db'])) {
1300 foreach ($dat[
'flexFormRels'][
'db'] as $subList) {
1301 foreach ($subList as $i) {
1302 $list[$i[
'table'] .
':' . $i[
'id']] = $i;
1319 foreach ($dbrels as $field =>
$dat) {
1320 if (is_array(
$dat[
'softrefs'][
'keys'])) {
1321 foreach (
$dat[
'softrefs'][
'keys'] as $spKey => $elements) {
1322 if (is_array($elements)) {
1323 foreach ($elements as $subKey => $el) {
1324 $lKey = $field .
':' . $spKey .
':' . $subKey;
1325 $list[$lKey] = array_merge(array(
'field' => $field,
'spKey' => $spKey), $el);
1328 if ($el[
'subst'] && $el[
'subst'][
'relFileName']) {
1329 $list[$lKey][
'file_ID'] = md5(PATH_site . $el[
'subst'][
'relFileName']);
1335 if (
$dat[
'type'] ==
'flex' && is_array(
$dat[
'flexFormRels'][
'softrefs'])) {
1336 foreach (
$dat[
'flexFormRels'][
'softrefs'] as $structurePath => $subSoftrefs) {
1337 if (is_array($subSoftrefs[
'keys'])) {
1338 foreach ($subSoftrefs[
'keys'] as $spKey => $elements) {
1339 foreach ($elements as $subKey => $el) {
1340 $lKey = $field .
':' . $structurePath .
':' . $spKey .
':' . $subKey;
1341 $list[$lKey] = array_merge(array(
'field' => $field,
'spKey' => $spKey,
'structurePath' => $structurePath), $el);
1344 if ($el[
'subst'] && $el[
'subst'][
'relFileName']) {
1345 $list[$lKey][
'file_ID'] = md5(PATH_site . $el[
'subst'][
'relFileName']);
1366 if (isset($this->recordTypesIncludeFields[$table])) {
1367 $includeFields = array_unique(array_merge(
1368 $this->recordTypesIncludeFields[$table],
1369 $this->defaultRecordIncludeFields
1372 foreach ($row as $key => $value) {
1373 if (in_array($key, $includeFields)) {
1374 $newRow[$key] = $value;
1396 if ($type ==
'xml') {
1422 'alt_options' => array(
1424 'disableTypeAttrib' =>
true,
1425 'clearStackPath' =>
true,
1426 'parentTagMap' => array(
1428 'files_fal' =>
'file',
1429 'records' =>
'table',
1431 'rec:rels' =>
'relations',
1432 'relations' =>
'element',
1433 'filerefs' =>
'file',
1434 'pid_lookup' =>
'page_contents',
1435 'header:relStaticTables' =>
'static_tables',
1436 'static_tables' =>
'tablename',
1437 'excludeMap' =>
'item',
1438 'softrefCfg' =>
'softrefExportMode',
1439 'extensionDependencies' =>
'extkey',
1440 'softrefs' =>
'softref_element'
1442 'alt_options' => array(
1443 '/pagetree' => array(
1444 'disableTypeAttrib' =>
true,
1445 'useIndexTagForNum' =>
'node',
1446 'parentTagMap' => array(
1447 'node:subrow' =>
'node'
1450 '/pid_lookup/page_contents' => array(
1451 'disableTypeAttrib' =>
true,
1452 'parentTagMap' => array(
1453 'page_contents' =>
'table'
1455 'grandParentTagMap' => array(
1456 'page_contents/table' =>
'item'
1461 '/records' => array(
1462 'disableTypeAttrib' =>
true,
1463 'parentTagMap' => array(
1464 'records' =>
'tablerow',
1465 'tablerow:data' =>
'fieldlist',
1466 'tablerow:rels' =>
'related',
1467 'related' =>
'field',
1468 'field:itemArray' =>
'relations',
1469 'field:newValueFiles' =>
'filerefs',
1470 'field:flexFormRels' =>
'flexform',
1471 'relations' =>
'element',
1472 'filerefs' =>
'file',
1473 'flexform:db' =>
'db_relations',
1474 'flexform:file' =>
'file_relations',
1475 'flexform:softrefs' =>
'softref_relations',
1476 'softref_relations' =>
'structurePath',
1477 'db_relations' =>
'path',
1478 'file_relations' =>
'path',
1479 'path' =>
'element',
1480 'keys' =>
'softref_key',
1481 'softref_key' =>
'softref_element'
1483 'alt_options' => array(
1484 '/records/tablerow/fieldlist' => array(
1485 'useIndexTagForAssoc' =>
'field'
1490 'disableTypeAttrib' =>
true,
1491 'parentTagMap' => array(
1495 '/files_fal' => array(
1496 'disableTypeAttrib' =>
true,
1497 'parentTagMap' => array(
1498 'files_fal' =>
'file'
1504 $charset = $this->dat[
'header'][
'charset'] ?:
'utf-8';
1505 $XML =
'<?xml version="1.0" encoding="' . $charset .
'" standalone="yes" ?>' . LF;
1530 $data = gzcompress($data);
1532 return md5($data) .
':' . (
$compress ?
'1' :
'0') .
':' . str_pad(strlen($data), 10,
'0', STR_PAD_LEFT) .
':' . $data .
':';
1547 $this->doesImport = 1;
1550 $this->import_mapId = array();
1551 $this->import_newId = array();
1552 $this->import_newId_pids = array();
1554 $this->unlinkFiles = array();
1555 $this->alternativeFileName = array();
1556 $this->alternativeFilePath = array();
1558 $this->initializeStorageObjects();
1566 protected function initializeStorageObjects()
1570 $this->storageObjects = $storageRepository->findAll();
1584 $this->writeSysFileStorageRecords();
1586 $this->writeSysFileRecords();
1599 $this->processSoftReferences();
1601 if ($this->legacyImport) {
1611 protected function writeSysFileStorageRecords()
1613 if (!isset($this->dat[
'header'][
'records'][
'sys_file_storage'])) {
1616 $sysFileStorageUidsToBeResetToDefaultStorage = array();
1617 foreach ($this->dat[
'header'][
'records'][
'sys_file_storage'] as $sysFileStorageUid => $_) {
1618 $storageRecord = $this->dat[
'records'][
'sys_file_storage:' . $sysFileStorageUid][
'data'];
1620 if ($storageRecord[
'driver'] ===
'Local' && $storageRecord[
'is_writable'] && $storageRecord[
'is_online']) {
1621 $useThisStorageUidInsteadOfTheOneInImport = 0;
1623 foreach ($this->storageObjects as $localStorage) {
1625 if ($localStorage->getDriverType() ===
'Local' && $localStorage->isWritable() && $localStorage->isOnline()) {
1627 $storageRecordConfiguration =
ResourceFactory::getInstance()->convertFlexFormDataToConfigurationArray($storageRecord[
'configuration']);
1628 $localStorageRecordConfiguration = $localStorage->getConfiguration();
1630 $storageRecordConfiguration[
'pathType'] === $localStorageRecordConfiguration[
'pathType']
1631 && $storageRecordConfiguration[
'basePath'] === $localStorageRecordConfiguration[
'basePath']
1634 $useThisStorageUidInsteadOfTheOneInImport = $localStorage->getUid();
1639 if ($useThisStorageUidInsteadOfTheOneInImport > 0) {
1641 $this->import_mapId[
'sys_file_storage'][$sysFileStorageUid] = $useThisStorageUidInsteadOfTheOneInImport;
1644 $this->
addSingle(
'sys_file_storage', $sysFileStorageUid, 0);
1651 $this->
addSingle(
'sys_file_storage', $sysFileStorageUid, 0);
1652 $sysFileStorageUidsToBeResetToDefaultStorage[] = $sysFileStorageUid;
1659 $tce->reverseOrder = 1;
1660 $tce->isImporting =
true;
1661 $tce->start($this->import_data, array());
1662 $tce->process_datamap();
1665 $defaultStorageUid = null;
1668 if ($defaultStorage !== null) {
1669 $defaultStorageUid = $defaultStorage->getUid();
1671 foreach ($sysFileStorageUidsToBeResetToDefaultStorage as $sysFileStorageUidToBeResetToDefaultStorage) {
1672 $this->import_mapId[
'sys_file_storage'][$sysFileStorageUidToBeResetToDefaultStorage] = $defaultStorageUid;
1676 unset($this->dat[
'header'][
'records'][
'sys_file_storage']);
1684 protected function writeSysFileRecords()
1686 if (!isset($this->dat[
'header'][
'records'][
'sys_file'])) {
1696 $sanitizedFolderMappings = array();
1698 foreach ($this->dat[
'header'][
'records'][
'sys_file'] as $sysFileUid => $_) {
1699 $fileRecord = $this->dat[
'records'][
'sys_file:' . $sysFileUid][
'data'];
1701 $temporaryFile = null;
1703 if ($this->filesPathForImport !== null) {
1704 if (is_file($this->filesPathForImport .
'/' . $fileRecord[
'sha1']) && sha1_file($this->filesPathForImport .
'/' . $fileRecord[
'sha1']) === $fileRecord[
'sha1']) {
1705 $temporaryFile = $this->filesPathForImport .
'/' . $fileRecord[
'sha1'];
1710 if ($temporaryFile === null) {
1711 $fileId = md5($fileRecord[
'storage'] .
':' . $fileRecord[
'identifier_hash']);
1713 if ($temporaryFile === null) {
1719 $originalStorageUid = $fileRecord[
'storage'];
1720 $useStorageFromStorageRecords =
false;
1723 if (isset($this->import_mapId[
'sys_file_storage'][$fileRecord[
'storage']])) {
1724 $fileRecord[
'storage'] = $this->import_mapId[
'sys_file_storage'][$fileRecord[
'storage']];
1725 $useStorageFromStorageRecords =
true;
1728 if (empty($fileRecord[
'storage']) && !$this->
isFallbackStorage($fileRecord[
'storage'])) {
1730 $this->
error(
'Error: No storage for the file "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $originalStorageUid .
'"');
1736 if ($useStorageFromStorageRecords && isset($storageRecords[$fileRecord[
'storage']])) {
1741 }
elseif ($defaultStorage !== null) {
1742 $storage = $defaultStorage;
1744 $this->
error(
'Error: No storage available for the file "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $fileRecord[
'storage'] .
'"');
1752 if ($storage->hasFile($fileRecord[
'identifier'])) {
1753 $file = $storage->getFile($fileRecord[
'identifier']);
1754 if ($file->getSha1() === $fileRecord[
'sha1']) {
1758 }
catch (Exception $e) {
1761 if ($newFile === null) {
1763 if (in_array($folderName, $sanitizedFolderMappings)) {
1764 $folderName = $sanitizedFolderMappings[$folderName];
1766 if (!$storage->hasFolder($folderName)) {
1768 $importFolder = $storage->createFolder($folderName);
1769 if ($importFolder->getIdentifier() !== $folderName && !in_array($folderName, $sanitizedFolderMappings)) {
1770 $sanitizedFolderMappings[$folderName] = $importFolder->getIdentifier();
1772 }
catch (Exception $e) {
1773 $this->
error(
'Error: Folder could not be created for file "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $fileRecord[
'storage'] .
'"');
1777 $importFolder = $storage->getFolder($folderName);
1782 $newFile = $storage->addFile($temporaryFile, $importFolder, $fileRecord[
'name']);
1783 }
catch (Exception $e) {
1784 $this->
error(
'Error: File could not be added to the storage: "' . $fileRecord[
'identifier'] .
'" with storage uid "' . $fileRecord[
'storage'] .
'"');
1788 if ($newFile->getSha1() !== $fileRecord[
'sha1']) {
1789 $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'] .
'"');
1794 $this->import_mapId[
'sys_file'][$fileRecord[
'uid']] = $newFile->getUid();
1799 unset($this->dat[
'header'][
'records'][
'sys_file']);
1810 return $storageId === 0 || $storageId ===
'0';
1831 if (!isset($this->dat[
'header'][
'records'][
'sys_file_reference'])) {
1835 foreach ($this->dat[
'header'][
'records'][
'sys_file_reference'] as $sysFileReferenceUid => $_) {
1836 $fileReferenceRecord = $this->dat[
'records'][
'sys_file_reference:' . $sysFileReferenceUid][
'data'];
1837 if ($fileReferenceRecord[
'uid_local'] == $oldFileUid) {
1838 $fileReferenceRecord[
'uid_local'] = $newFileUid;
1839 $this->dat[
'records'][
'sys_file_reference:' . $sysFileReferenceUid][
'data'] = $fileReferenceRecord;
1849 protected function initializeLegacyImportFolder()
1852 $folder =
$GLOBALS[
'BE_USER']->getDefaultUploadFolder();
1853 if ($folder ===
false) {
1854 $this->
error(
'Error: the backend users default upload folder is missing! No files will be imported!');
1856 if (!$folder->hasFolder($this->legacyImportTargetPath)) {
1858 $this->legacyImportFolder = $folder->createFolder($this->legacyImportTargetPath);
1859 }
catch (\TYPO3\CMS\Core\Exception $e) {
1860 $this->
error(
'Error: the import folder in the default upload folder could not be created! No files will be imported!');
1863 $this->legacyImportFolder = $folder->getSubFolder($this->legacyImportTargetPath);
1878 $rows =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetRows(
1881 '1=1' . $whereClause,
1900 $temporaryFilePath = null;
1901 if (is_array($this->dat[$dataKey][$fileId])) {
1905 if (@is_file($temporaryFilePathInternal)) {
1906 $this->unlinkFiles[] = $temporaryFilePathInternal;
1907 if (filesize($temporaryFilePathInternal) == $this->dat[$dataKey][$fileId][
'filesize']) {
1908 $temporaryFilePath = $temporaryFilePathInternal;
1910 $this->
error(
'Error: temporary file ' . $temporaryFilePathInternal .
' had a size (' . filesize($temporaryFilePathInternal) .
') different from the original (' . $this->dat[$dataKey][$fileId][
'filesize'] .
')', 1);
1913 $this->
error(
'Error: temporary file ' . $temporaryFilePathInternal .
' was not written as it should have been!', 1);
1916 $this->
error(
'Error: No file found for ID ' . $fileId, 1);
1918 return $temporaryFilePath;
1931 if (is_array($this->dat[
'header'][
'records'][
'pages'])) {
1934 $pageRecords = $this->dat[
'header'][
'records'][
'pages'];
1935 $this->import_data = array();
1937 if (is_array($this->dat[
'header'][
'pagetree'])) {
1939 foreach ($pagesFromTree as $uid) {
1940 $thisRec = $this->dat[
'header'][
'records'][
'pages'][$uid];
1942 $setPid = isset($this->import_newId_pids[$thisRec[
'pid']]) ? $this->import_newId_pids[$thisRec[
'pid']] : $pid;
1943 $this->
addSingle(
'pages', $uid, $setPid);
1944 unset($pageRecords[$uid]);
1948 if (!empty($pageRecords)) {
1949 $remainingPageUids = array_keys($pageRecords);
1950 foreach ($remainingPageUids as $pUid) {
1956 $tce->isImporting =
true;
1957 $this->
callHook(
'before_writeRecordsPages', array(
1959 'data' => &$this->import_data
1962 $tce->start($this->import_data, array());
1963 $tce->process_datamap();
1964 $this->
callHook(
'after_writeRecordsPages', array(
1970 if ($this->update && is_array($this->dat[
'header'][
'pagetree'])) {
1987 $cmd_data = array();
1990 foreach ($pidsFromTree as $origPid => $newPid) {
1991 if ($newPid >= 0 && $this->
dontIgnorePid(
'pages', $origPid)) {
1993 if (substr($this->import_newId_pids[$origPid], 0, 3) ===
'NEW') {
1994 if ($this->import_mapId[
'pages'][$origPid]) {
1995 $mappedPid = $this->import_mapId[
'pages'][$origPid];
1996 $cmd_data[
'pages'][$mappedPid][
'move'] = $newPid;
1999 $cmd_data[
'pages'][$origPid][
'move'] = $newPid;
2004 if (!empty($cmd_data)) {
2006 $this->
callHook(
'before_writeRecordsPagesOrder', array(
2008 'data' => &$cmd_data
2010 $tce->start(array(), $cmd_data);
2011 $tce->process_cmdmap();
2012 $this->
callHook(
'after_writeRecordsPagesOrder', array(
2028 $this->import_data = array();
2029 if (is_array($this->dat[
'header'][
'records'])) {
2030 foreach ($this->dat[
'header'][
'records'] as $table => $recs) {
2032 if ($table !=
'pages') {
2033 foreach ($recs as $uid => $thisRec) {
2035 $setPid = isset($this->import_mapId[
'pages'][$thisRec[
'pid']])
2036 ? (int)$this->import_mapId[
'pages'][$thisRec[
'pid']]
2038 if (is_array(
$GLOBALS[
'TCA'][$table]) && isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'rootLevel'])) {
2039 $rootLevelSetting = (int)
$GLOBALS[
'TCA'][$table][
'ctrl'][
'rootLevel'];
2040 if ($rootLevelSetting === 1) {
2042 }
elseif ($rootLevelSetting === 0 && $setPid === 0) {
2043 $this->
error(
'Error: Record type ' . $table .
' is not allowed on pid 0');
2048 $this->
addSingle($table, $uid, $setPid);
2053 $this->
error(
'Error: No records defined in internal data array.');
2057 $this->
callHook(
'before_writeRecordsRecords', array(
2059 'data' => &$this->import_data
2063 $tce->reverseOrder = 1;
2064 $tce->isImporting =
true;
2065 $tce->start($this->import_data, array());
2066 $tce->process_datamap();
2067 $this->
callHook(
'after_writeRecordsRecords', array(
2073 if ($this->update) {
2089 $cmd_data = array();
2090 if (is_array($this->dat[
'header'][
'pagetree'])) {
2093 $pagesFromTree = array();
2095 if (is_array($this->dat[
'header'][
'pid_lookup'])) {
2096 foreach ($this->dat[
'header'][
'pid_lookup'] as $pid => $recList) {
2097 $newPid = isset($this->import_mapId[
'pages'][$pid]) ? $this->import_mapId[
'pages'][$pid] : $mainPid;
2098 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($newPid)) {
2099 foreach ($recList as $tableName => $uidList) {
2102 if (($tableName !=
'pages' || !$pagesFromTree[$pid]) && is_array($uidList)) {
2103 $uidList = array_reverse(array_keys($uidList));
2104 foreach ($uidList as $uid) {
2106 $cmd_data[$tableName][$uid][
'move'] = $newPid;
2116 if (!empty($cmd_data)) {
2118 $this->
callHook(
'before_writeRecordsRecordsOrder', array(
2120 'data' => &$cmd_data
2122 $tce->start(array(), $cmd_data);
2123 $tce->process_cmdmap();
2124 $this->
callHook(
'after_writeRecordsRecordsOrder', array(
2143 if ($this->import_mode[$table .
':' . $uid] ===
'exclude') {
2146 $record = $this->dat[
'records'][$table .
':' . $uid][
'data'];
2147 if (is_array($record)) {
2148 if ($this->update && $this->
doesRecordExist($table, $uid) && $this->import_mode[$table .
':' . $uid] !==
'as_new') {
2150 }
elseif ($table ===
'sys_file_metadata' && $record[
'sys_language_uid'] ==
'0' && $this->import_mapId[
'sys_file'][$record[
'file']]) {
2153 $recordInDatabase =
$GLOBALS[
'TYPO3_DB']->exec_SELECTgetSingleRow(
2155 'sys_file_metadata',
2156 'file = ' . $this->import_mapId[
'sys_file'][$record[
'file']] .
' AND sys_language_uid = 0 AND pid = 0'
2160 if (is_array($recordInDatabase)) {
2161 $this->import_mapId[
'sys_file_metadata'][$record[
'uid']] = $recordInDatabase[
'uid'];
2162 $ID = $recordInDatabase[
'uid'];
2169 $this->import_newId[$table .
':' . $ID] = array(
'table' => $table,
'uid' => $uid);
2170 if ($table ==
'pages') {
2171 $this->import_newId_pids[$uid] = $ID;
2174 $this->import_data[$table][$ID] = $record;
2175 $this->import_data[$table][$ID][
'tx_impexp_origuid'] = $this->import_data[$table][$ID][
'uid'];
2177 if ($table ===
'pages') {
2179 unset($this->import_data[$table][$ID][
'perms_userid']);
2180 unset($this->import_data[$table][$ID][
'perms_groupid']);
2183 unset($this->import_data[$table][$ID][
'uid']);
2185 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($ID)) {
2186 unset($this->import_data[$table][$ID][
'pid']);
2189 $this->import_data[$table][$ID][
'pid'] = $pid;
2190 if (($this->import_mode[$table .
':' . $uid] ===
'force_uid' && $this->update || $this->force_all_UIDS) &&
$GLOBALS[
'BE_USER']->isAdmin()) {
2191 $this->import_data[$table][$ID][
'uid'] = $uid;
2192 $this->suggestedInsertUids[$table .
':' . $uid] =
'DELETE';
2196 foreach ($this->dat[
'records'][$table .
':' . $uid][
'rels'] as $field => $config) {
2197 switch ((
string)$config[
'type']) {
2209 if ($table !==
'sys_file_reference' && $field !==
'uid_local') {
2210 $this->import_data[$table][$ID][$field] =
'';
2218 $this->import_data[$table][$ID][$field] =
'';
2222 }
elseif ($table .
':' . $uid !=
'pages:0') {
2224 $this->
error(
'Error: no record was found in data array!', 1);
2237 foreach ($this->import_data as $table => $recs) {
2238 foreach ($recs as $id => $value) {
2239 $old_uid = $this->import_newId[$table .
':' . $id][
'uid'];
2240 if (isset($substNEWwithIDs[$id])) {
2241 $this->import_mapId[$table][$old_uid] = $substNEWwithIDs[$id];
2242 }
elseif ($this->update) {
2244 $this->import_mapId[$table][$old_uid] = $id;
2248 if (!($table ===
'sys_file_metadata' && isset($this->import_mapId[$table][$old_uid]) && $this->import_mapId[$table][$old_uid] == $id)) {
2249 $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);
2264 $tce->stripslashes_values = 0;
2265 $tce->dontProcessTransformations = 1;
2279 foreach ($this->unlinkFiles as $fileName) {
2283 if (is_file($fileName)) {
2284 $this->
error(
'Error: ' . $fileName .
' was NOT unlinked as it should have been!', 1);
2287 $this->
error(
'Error: ' . $fileName .
' was not in temp-path. Not removed!', 1);
2290 $this->unlinkFiles = array();
2307 $updateData = array();
2309 foreach ($this->import_newId as $nId =>
$dat) {
2310 $table =
$dat[
'table'];
2314 if (is_array($this->import_mapId[$table]) && isset($this->import_mapId[$table][$uid])) {
2316 if (is_array($this->dat[
'records'][$table .
':' . $uid][
'rels'])) {
2317 $thisNewPageUid = 0;
2318 if ($this->legacyImport) {
2319 if ($table !=
'pages') {
2320 $oldPid = $this->dat[
'records'][$table .
':' . $uid][
'data'][
'pid'];
2323 $thisNewPageUid = $thisNewUid;
2327 foreach ($this->dat[
'records'][$table .
':' . $uid][
'rels'] as $field => $config) {
2330 if ($table ===
'sys_file_reference' && $field ===
'uid_local') {
2333 switch ((
string)$config[
'type']) {
2335 if (is_array($config[
'itemArray']) && !empty($config[
'itemArray'])) {
2336 $itemConfig =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
2337 $valArray = $this->
setRelations_db($config[
'itemArray'], $itemConfig);
2338 $updateData[$table][$thisNewUid][$field] = implode(
',', $valArray);
2342 if (is_array($config[
'newValueFiles']) && !empty($config[
'newValueFiles'])) {
2344 foreach ($config[
'newValueFiles'] as $fI) {
2347 if ($this->legacyImport && $this->legacyImportFolder === null && isset($this->legacyImportMigrationTables[$table][$field])) {
2349 }
elseif ($this->legacyImport && $this->legacyImportFolder !== null && isset($this->legacyImportMigrationTables[$table][$field])) {
2351 foreach ($valArr as $tempFile) {
2352 $fileName = $this->alternativeFileName[$tempFile];
2357 if ($this->legacyImportFolder->hasFile($fileName)) {
2358 $fileStorage = $this->legacyImportFolder->getStorage();
2359 $file = $fileStorage->getFile($this->legacyImportFolder->getIdentifier() . $fileName);
2360 if ($file->getSha1() === sha1_file($tempFile)) {
2361 $fileObject = $file;
2367 if ($fileObject === null) {
2370 }
catch (\TYPO3\CMS\Core\
Exception $e) {
2371 $this->
error(
'Error: no file could be added to the storage for file name' . $this->alternativeFileName[$tempFile]);
2374 if ($fileObject !== null) {
2377 $updateData[
'sys_file_reference'][$refId] = array(
2378 'uid_local' => $fileObject->getUid(),
2379 'uid_foreign' => $thisNewUid,
2380 'tablenames' => $table,
2381 'fieldname' => $field,
2382 'pid' => $thisNewPageUid,
2383 'table_local' =>
'sys_file',
2387 $updateData[$table][$thisNewUid][$field] = implode(
',', $refIds);
2388 if (!empty($this->legacyImportMigrationTables[$table][$field])) {
2389 $this->legacyImportMigrationRecords[$table][$thisNewUid][$field] = $refIds;
2392 $updateData[$table][$thisNewUid][$field] = implode(
',', $valArr);
2399 $this->
error(
'Error: no record was found in data array!', 1);
2402 $this->
error(
'Error: this records is NOT created it seems! (' . $table .
':' . $uid .
')', 1);
2405 if (!empty($updateData)) {
2407 $tce->isImporting =
true;
2408 $this->
callHook(
'before_setRelation', array(
2410 'data' => &$updateData
2412 $tce->start($updateData, array());
2413 $tce->process_datamap();
2415 foreach ($this->legacyImportMigrationRecords as $table => $records) {
2416 foreach ($records as $uid => $fields) {
2417 foreach ($fields as $field => $referenceIds) {
2418 foreach ($referenceIds as $key => $referenceId) {
2419 $this->legacyImportMigrationRecords[$table][$uid][$field][$key] = $tce->substNEWwithIDs[$referenceId];
2424 $this->
callHook(
'after_setRelations', array(
2439 $valArray = array();
2440 foreach ($itemArray as $relDat) {
2441 if (is_array($this->import_mapId[$relDat[
'table']]) && isset($this->import_mapId[$relDat[
'table']][$relDat[
'id']])) {
2444 if ($itemConfig[
'type'] ===
'group' && $itemConfig[
'internal_type'] ===
'file_reference') {
2445 $value = $this->import_mapId[$relDat[
'table']][$relDat[
'id']];
2446 }
elseif ($itemConfig[
'type'] ===
'input' && isset($itemConfig[
'wizards'][
'link'])) {
2449 $fileUid = $this->import_mapId[$relDat[
'table']][$relDat[
'id']];
2451 $value =
'file:' . $fileUid;
2453 $file = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->retrieveFileOrFolderObject($fileUid);
2456 if ($file instanceof \TYPO3\CMS\Core\Resource\FileInterface) {
2457 $value = $file->getPublicUrl();
2460 $value = $relDat[
'table'] .
'_' . $this->import_mapId[$relDat[
'table']][$relDat[
'id']];
2462 $valArray[] = $value;
2466 $valArray[] = $relDat[
'table'] .
'_' . $relDat[
'id'];
2468 $this->
error(
'Lost relation: ' . $relDat[
'table'] .
':' . $relDat[
'id'], 1);
2482 if (is_array($this->dat[
'files'][$fI[
'ID']])) {
2485 if ($this->filesPathForImport !== null) {
2486 if (is_file($this->filesPathForImport .
'/' . $this->dat[
'files'][$fI[
'ID']][
'content_md5']) &&
2487 md5_file($this->filesPathForImport .
'/' . $this->dat[
'files'][$fI[
'ID']][
'content_md5']) === $this->dat[
'files'][$fI[
'ID']][
'content_md5']) {
2488 $tmpFile = $this->filesPathForImport .
'/' . $this->dat[
'files'][$fI[
'ID']][
'content_md5'];
2491 if ($tmpFile === null) {
2496 if (@is_file($tmpFile)) {
2497 $this->unlinkFiles[] = $tmpFile;
2498 if (filesize($tmpFile) == $this->dat[
'files'][$fI[
'ID']][
'filesize']) {
2499 $this->alternativeFileName[$tmpFile] = $fI[
'filename'];
2500 $this->alternativeFilePath[$tmpFile] = $this->dat[
'files'][$fI[
'ID']][
'relFileRef'];
2503 $this->
error(
'Error: temporary file ' . $tmpFile .
' had a size (' . filesize($tmpFile) .
') different from the original (' . $this->dat[
'files'][$fI[
'ID']][
'filesize'] .
')', 1);
2506 $this->
error(
'Error: temporary file ' . $tmpFile .
' was not written as it should have been!', 1);
2509 $this->
error(
'Error: No file found for ID ' . $fI[
'ID'], 1);
2523 $updateData = array();
2525 foreach ($this->import_newId as $nId =>
$dat) {
2526 $table =
$dat[
'table'];
2530 if (!isset($this->import_mapId[$table][$uid])) {
2531 $this->
error(
'Error: this records is NOT created it seems! (' . $table .
':' . $uid .
')', 1);
2535 if (!is_array($this->dat[
'records'][$table .
':' . $uid][
'rels'])) {
2536 $this->
error(
'Error: no record was found in data array!', 1);
2541 foreach ($this->dat[
'records'][$table .
':' . $uid][
'rels'] as $field => $config) {
2542 switch ((
string)$config[
'type']) {
2545 $updateData[$table][$thisNewUid][$field] = $this->dat[
'records'][$table .
':' . $uid][
'data'][$field];
2547 if (!empty($config[
'flexFormRels'][
'db']) || !empty($config[
'flexFormRels'][
'file'])) {
2550 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
2551 if (is_array($origRecordRow) && is_array($conf) && $conf[
'type'] ===
'flex') {
2557 $iteratorObj->callBackObj = $this;
2558 $currentValueArray[
'data'] = $iteratorObj->checkValue_flex_procInData(
2559 $currentValueArray[
'data'],
2563 array($table, $thisNewUid, $field, $config),
2564 'remapListedDBRecords_flexFormCallBack'
2567 if (is_array($currentValueArray[
'data'])) {
2568 $updateData[$table][$thisNewUid][$field] = $currentValueArray;
2576 if (!empty($updateData)) {
2578 $tce->isImporting =
true;
2579 $this->
callHook(
'before_setFlexFormRelations', array(
2581 'data' => &$updateData
2583 $tce->start($updateData, array());
2584 $tce->process_datamap();
2585 $this->
callHook(
'after_setFlexFormRelations', array(
2606 list($table, $uid, $field, $config) = $pParams;
2608 if (!is_array($config[
'flexFormRels'][
'db'][$path]) && is_array($config[
'flexFormRels'][
'db'][rtrim($path,
'/')])) {
2609 $path = rtrim($path,
'/');
2611 if (is_array($config[
'flexFormRels'][
'db'][$path])) {
2612 $valArray = $this->
setRelations_db($config[
'flexFormRels'][
'db'][$path], $dsConf);
2613 $dataValue = implode(
',', $valArray);
2615 if (is_array($config[
'flexFormRels'][
'file'][$path])) {
2617 foreach ($config[
'flexFormRels'][
'file'][$path] as $fI) {
2620 $dataValue = implode(
',', $valArr);
2622 return array(
'value' => $dataValue);
2634 public function processSoftReferences()
2639 if (is_array($this->dat[
'header'][
'records'])) {
2640 foreach ($this->dat[
'header'][
'records'] as $table => $recs) {
2641 foreach ($recs as $uid => $thisRec) {
2643 if (isset(
$GLOBALS[
'TCA'][$table]) && is_array($thisRec[
'softrefs'])) {
2646 $fieldsIndex = array();
2647 foreach ($thisRec[
'softrefs'] as $softrefDef) {
2649 if ($softrefDef[
'field'] && is_array($softrefDef[
'subst']) && $softrefDef[
'subst'][
'tokenID']) {
2650 $fieldsIndex[$softrefDef[
'field']][$softrefDef[
'subst'][
'tokenID']] = $softrefDef;
2656 foreach ($fieldsIndex as $field => $softRefCfgs) {
2657 if (is_array(
$GLOBALS[
'TCA'][$table][
'columns'][$field])) {
2658 $conf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
2659 if ($conf[
'type'] ===
'flex') {
2662 if (is_array($origRecordRow)) {
2669 $iteratorObj->callBackObj = $this;
2670 $currentValueArray[
'data'] = $iteratorObj->checkValue_flex_procInData($currentValueArray[
'data'], array(), array(), $dataStructArray, array($table, $uid, $field, $softRefCfgs),
'processSoftReferences_flexFormCallBack');
2672 if (is_array($currentValueArray[
'data'])) {
2673 $inData[$table][$thisNewUid][$field] = $currentValueArray;
2678 $tokenizedContent = $this->dat[
'records'][$table .
':' . $uid][
'rels'][$field][
'softrefs'][
'tokenizedContent'];
2679 if (strlen($tokenizedContent) && is_array($softRefCfgs)) {
2691 $tce->isImporting =
true;
2692 $this->
callHook(
'before_processSoftReferences', array(
2696 $tce->enableLogging =
true;
2697 $tce->start($inData, array());
2698 $tce->process_datamap();
2699 $this->
callHook(
'after_processSoftReferences', array(
2719 list($table, $origUid, $field, $softRefCfgs) = $pParams;
2720 if (is_array($softRefCfgs)) {
2722 $thisSoftRefCfgList = array();
2723 foreach ($softRefCfgs as $sK => $sV) {
2724 if ($sV[
'structurePath'] === $path) {
2725 $thisSoftRefCfgList[$sK] = $sV;
2729 if (!empty($thisSoftRefCfgList)) {
2731 $tokenizedContent = $this->dat[
'records'][$table .
':' . $origUid][
'rels'][$field][
'flexFormRels'][
'softrefs'][$path][
'tokenizedContent'];
2732 if (strlen($tokenizedContent)) {
2738 return array(
'value' => $dataValue);
2753 foreach ($softRefCfgs as $cfg) {
2755 $tokenID = $cfg[
'subst'][
'tokenID'];
2757 $insertValue = $cfg[
'subst'][
'tokenValue'];
2759 switch ((
string)$this->softrefCfg[$tokenID][
'mode']) {
2765 $insertValue = $this->softrefInputValues[$tokenID];
2769 switch ((
string)$cfg[
'subst'][
'type']) {
2777 list($tempTable, $tempUid) = explode(
':', $cfg[
'subst'][
'recordRef']);
2778 if (isset($this->import_mapId[$tempTable][$tempUid])) {
2781 if ($tempTable ===
'pages' && !\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($cfg[
'subst'][
'tokenValue'])) {
2783 if ($recWithUniqueValue[
'alias']) {
2784 $insertValue = $recWithUniqueValue[
'alias'];
2786 }
elseif (strpos($cfg[
'subst'][
'tokenValue'],
':') !==
false) {
2787 list($tokenKey, $tokenId) = explode(
':', $cfg[
'subst'][
'tokenValue']);
2788 $insertValue = $tokenKey .
':' . $insertValue;
2794 $tokenizedContent = str_replace(
'{softref:' . $tokenID .
'}', $insertValue, $tokenizedContent);
2796 return $tokenizedContent;
2810 if ($fileHeaderInfo = $this->dat[
'header'][
'files'][$cfg[
'file_ID']]) {
2818 if (@is_dir((PATH_site . $dirPrefix))) {
2822 $origDestName =
$fileProcObj->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
2824 $pI = pathinfo($relFileName);
2827 !@is_file($copyDestName) && !@is_file($origDestName)
2831 if ($this->dat[
'header'][
'files'][$fileHeaderInfo[
'RTE_ORIG_ID']]) {
2832 if ($this->legacyImport) {
2835 $relFileName = $this->filePathMap[$cfg[
'file_ID']] .
'" data-htmlarea-file-uid="' . $fileName .
'" data-htmlarea-file-table="sys_file';
2842 $this->
writeFileVerify($origDestName, $fileHeaderInfo[
'RTE_ORIG_ID'],
true);
2847 $this->
error(
'ERROR: Could not find original file ID');
2850 $this->
error(
'ERROR: The destination filenames "' . $copyDestName .
'" and "' . $origDestName .
'" either existed or have non-valid names');
2853 $this->
error(
'ERROR: "' . PATH_site . $dirPrefix .
'" was not a directory, so could not process file "' . $relFileName .
'"');
2859 if (strlen($newFileName)) {
2860 $relFileName = $newFileName;
2862 $this->
error(
'ERROR: No new file created for "' . $relFileName .
'"');
2865 $this->
error(
'ERROR: Sorry, cannot operate on non-RTE files which are outside the fileadmin folder.');
2868 $this->
error(
'ERROR: Could not find file ID in header.');
2871 return $relFileName;
2888 if (isset($this->fileIDMap[$fileID])) {
2891 if ($this->legacyImport) {
2893 $dirPrefix = $this->fileadminFolderName .
'/';
2898 if ($dirPrefix && (!$this->update || $origDirPrefix === $dirPrefix) && $this->
checkOrCreateDir($dirPrefix)) {
2899 $fileHeaderInfo = $this->dat[
'header'][
'files'][$fileID];
2900 $updMode = $this->update && $this->import_mapId[$table][$uid] === $uid && $this->import_mode[$table .
':' . $uid] !==
'as_new';
2905 if ($this->legacyImport) {
2908 $newName =
'file:' . $fileName;
2914 $newName = PATH_site . $dirPrefix . $fileName;
2918 $newName =
$fileProcObj->getUniqueName($fileName, PATH_site . $dirPrefix);
2922 if (is_array($fileHeaderInfo[
'EXT_RES_ID'])) {
2923 $tokenizedContent = $this->dat[
'files'][$fileID][
'tokenizedContent'];
2924 $tokenSubstituted =
false;
2927 foreach ($fileHeaderInfo[
'EXT_RES_ID'] as $res_fileID) {
2928 if ($this->dat[
'files'][$res_fileID][
'filename']) {
2930 $relResourceFileName = $this->dat[
'files'][$res_fileID][
'parentRelFileName'];
2938 $this->
error(
'ERROR: Could not create file in directory "' . $destDir .
'"');
2941 $this->
error(
'ERROR: Could not resolve path for "' . $relResourceFileName .
'"');
2943 $tokenizedContent = str_replace(
'{EXT_RES_ID:' . $res_fileID .
'}', $relResourceFileName, $tokenizedContent);
2944 $tokenSubstituted =
true;
2951 foreach ($fileHeaderInfo[
'EXT_RES_ID'] as $res_fileID) {
2952 if ($this->dat[
'files'][$res_fileID][
'filename']) {
2953 $absResourceFileName =
$fileProcObj->getUniqueName($this->dat[
'files'][$res_fileID][
'filename'], $resourceDir);
2954 $relResourceFileName = substr($absResourceFileName, strlen(
PathUtility::dirname($resourceDir)) + 1);
2956 $tokenizedContent = str_replace(
'{EXT_RES_ID:' . $res_fileID .
'}', $relResourceFileName, $tokenizedContent);
2957 $tokenSubstituted =
true;
2963 if ($tokenSubstituted) {
2986 $this->
error(
'ERROR: You did not have sufficient permissions to write the file "' . $fileName .
'"');
2990 if (!
$fileProcObj->checkPathAgainstMounts($fileName) && !$bypassMountCheck) {
2991 $this->
error(
'ERROR: Filename "' . $fileName .
'" was not allowed in destination path!');
2995 if (!
$fileProcObj->checkIfAllowed($fI[
'fileext'], $fI[
'path'], $fI[
'file']) && (!$this->allowPHPScripts || !
$GLOBALS[
'BE_USER']->isAdmin())) {
2996 $this->
error(
'ERROR: Filename "' . $fileName .
'" failed against extension check or deny-pattern!');
3000 $this->
error(
'ERROR: Filename "' . $fileName .
'" was not a valid relative file path!');
3003 if (!$this->dat[
'files'][$fileID]) {
3004 $this->
error(
'ERROR: File ID "' . $fileID .
'" could not be found');
3008 $this->fileIDMap[$fileID] = $fileName;
3012 $this->
error(
'ERROR: File content "' . $fileName .
'" was corrupted');
3028 if ($this->legacyImportFolder === null) {
3032 if (!isset($this->dat[
'files'][$fileId])) {
3033 $this->
error(
'ERROR: File ID "' . $fileId .
'" could not be found');
3038 if ($temporaryFile === null) {
3045 if (isset($this->dat[
'files'][$fileId][
'relFileName'])) {
3048 if (!$this->legacyImportFolder->hasFolder($relativeFilePath)) {
3049 $this->legacyImportFolder->createFolder($relativeFilePath);
3051 $importFolder = $this->legacyImportFolder->getSubfolder($relativeFilePath);
3058 if ($importFolder->hasFile($fileName)) {
3059 $fileStorage = $importFolder->getStorage();
3060 $file = $fileStorage->getFile($importFolder->getIdentifier() . $fileName);
3061 if ($file->getSha1() === sha1_file($temporaryFile)) {
3062 $fileObject = $file;
3068 if ($fileObject === null) {
3071 }
catch (\TYPO3\CMS\Core\
Exception $e) {
3072 $this->
error(
'Error: no file could be added to the storage for file name ' . $this->alternativeFileName[$temporaryFile]);
3076 if (md5_file(PATH_site . $fileObject->getPublicUrl()) == $this->dat[
'files'][$fileId][
'content_md5']) {
3077 $fileName = $fileObject->getUid();
3078 $this->fileIDMap[$fileId] = $fileName;
3079 $this->filePathMap[$fileId] = $fileObject->getPublicUrl();
3082 $this->
error(
'ERROR: File content "' . $this->dat[
'files'][$fileId][
'relFileName'] .
'" was corrupted');
3095 $updateData= array();
3097 foreach ($this->legacyImportMigrationRecords as $table => $records) {
3098 foreach ($records as $uid => $fields) {
3104 foreach ($fields as $field => $referenceIds) {
3105 $fieldConfiguration = $this->legacyImportMigrationTables[$table][$field];
3107 if (isset($fieldConfiguration[
'titleTexts'])) {
3108 $titleTextField = $fieldConfiguration[
'titleTexts'];
3109 if (isset($row[$titleTextField]) && $row[$titleTextField] !==
'') {
3110 $titleTextContents = explode(LF, $row[$titleTextField]);
3111 $updateData[$table][$uid][$titleTextField] =
'';
3115 if (isset($fieldConfiguration[
'alternativeTexts'])) {
3116 $alternativeTextField = $fieldConfiguration[
'alternativeTexts'];
3117 if (isset($row[$alternativeTextField]) && $row[$alternativeTextField] !==
'') {
3118 $alternativeTextContents = explode(LF, $row[$alternativeTextField]);
3119 $updateData[$table][$uid][$alternativeTextField] =
'';
3122 if (isset($fieldConfiguration[
'description'])) {
3123 $descriptionField = $fieldConfiguration[
'description'];
3124 if ($row[$descriptionField] !==
'') {
3125 $descriptionContents = explode(LF, $row[$descriptionField]);
3126 $updateData[$table][$uid][$descriptionField] =
'';
3129 if (isset($fieldConfiguration[
'links'])) {
3130 $linkField = $fieldConfiguration[
'links'];
3131 if ($row[$linkField] !==
'') {
3132 $linkContents = explode(LF, $row[$linkField]);
3133 $updateData[$table][$uid][$linkField] =
'';
3137 foreach ($referenceIds as $key => $referenceId) {
3138 if (isset($titleTextContents[$key])) {
3139 $updateData[
'sys_file_reference'][$referenceId][
'title'] = trim($titleTextContents[$key]);
3141 if (isset($alternativeTextContents[$key])) {
3142 $updateData[
'sys_file_reference'][$referenceId][
'alternative'] = trim($alternativeTextContents[$key]);
3144 if (isset($descriptionContents[$key])) {
3145 $updateData[
'sys_file_reference'][$referenceId][
'description'] = trim($descriptionContents[$key]);
3147 if (isset($linkContents[$key])) {
3148 $updateData[
'sys_file_reference'][$referenceId][
'link'] = trim($linkContents[$key]);
3157 $tce->isImporting =
true;
3158 $tce->start($updateData, array());
3159 $tce->process_datamap();
3171 $filePathParts = explode(
'/', $dirPrefix);
3172 $firstDir = array_shift($filePathParts);
3175 foreach ($filePathParts as $dirname) {
3176 $pathAcc .=
'/' . $dirname;
3177 if (strlen($dirname)) {
3178 if (!@is_dir((PATH_site . $this->fileadminFolderName . $pathAcc))) {
3180 $this->
error(
'ERROR: Directory could not be created....B');
3184 }
elseif ($dirPrefix === $this->fileadminFolderName . $pathAcc) {
3187 $this->
error(
'ERROR: Directory could not be created....A');
3206 $result =
$fileProcObj->checkPathAgainstMounts(PATH_site . $dirPrefix);
3209 if ($noAlternative) {
3218 $dirPrefix = substr($dirPrefix, strlen($this->fileadminFolderName .
'/'));
3251 $this->filesPathForImport = $temporaryFolderName;
3253 $this->
error(
'External import files for the given import source is currently not supported.');
3256 if (strtolower($fI[
'extension']) ==
'xml') {
3259 if (strlen($xmlContent)) {
3261 if (is_array($this->dat)) {
3262 if ($this->dat[
'_DOCUMENT_TAG'] ===
'T3RecordDocument' && is_array($this->dat[
'header']) && is_array($this->dat[
'records'])) {
3266 $this->
error(
'XML file did not contain proper XML for TYPO3 Import');
3269 $this->
error(
'XML could not be parsed: ' . $this->dat);
3281 $this->dat[
'files_fal'] = $this->
getNextFilePart($fd, 1,
'files_fal');
3305 $initStrLen = 32 + 1 + 1 + 1 + 10 + 1;
3307 $initStr = fread($fd, $initStrLen);
3308 if (empty($initStr)) {
3309 $this->
error(
'File does not contain data for "' . $name .
'"');
3312 $initStrDat = explode(
':', $initStr);
3313 if (strstr($initStrDat[0],
'Warning')) {
3314 $this->
error(
'File read error: Warning message in file. (' . $initStr . fgets($fd) .
')');
3317 if ((
string)$initStrDat[3] !==
'') {
3318 $this->
error(
'File read error: InitString had a wrong length. (' . $name .
')');
3321 $datString = fread($fd, (
int)$initStrDat[2]);
3323 if (md5($datString) === $initStrDat[0]) {
3324 if ($initStrDat[1]) {
3325 if ($this->compress) {
3326 $datString = gzuncompress($datString);
3327 return $unserialize ? unserialize($datString) : $datString;
3329 $this->
error(
'Content read error: This file requires decompression, but this server does not offer gzcompress()/gzuncompress() functions.', 1);
3333 $this->
error(
'MD5 check failed (' . $name .
')');
3348 $this->dat[
'header'] = $this->
getNextContentPart($filecontent, $pointer, 1,
'header');
3349 $this->dat[
'records'] = $this->
getNextContentPart($filecontent, $pointer, 1,
'records');
3365 $initStrLen = 32 + 1 + 1 + 1 + 10 + 1;
3367 $initStr = substr($filecontent, $pointer, $initStrLen);
3368 $pointer += $initStrLen;
3369 $initStrDat = explode(
':', $initStr);
3370 if ((
string)$initStrDat[3] !==
'') {
3371 $this->
error(
'Content read error: InitString had a wrong length. (' . $name .
')');
3374 $datString = substr($filecontent, $pointer, (
int)$initStrDat[2]);
3375 $pointer += (int)$initStrDat[2] + 1;
3376 if (md5($datString) === $initStrDat[0]) {
3377 if ($initStrDat[1]) {
3378 if ($this->compress) {
3379 $datString = gzuncompress($datString);
3380 return $unserialize ? unserialize($datString) : $datString;
3382 $this->
error(
'Content read error: This file requires decompression, but this server does not offer gzcompress()/gzuncompress() functions.', 1);
3386 $this->
error(
'MD5 check failed (' . $name .
')');
3398 $this->relStaticTables = (array)$this->dat[
'header'][
'relStaticTables'];
3399 $this->excludeMap = (array)$this->dat[
'header'][
'excludeMap'];
3400 $this->softrefCfg = (array)$this->dat[
'header'][
'softrefCfg'];
3401 $this->extensionDependencies = (array)$this->dat[
'header'][
'extensionDependencies'];
3404 isset($this->dat[
'header'][
'meta'][
'TYPO3_version'])
3405 && \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger($this->dat[
'header'][
'meta'][
'TYPO3_version']) < 6000000
3407 $this->legacyImport =
true;
3408 $this->initializeLegacyImportFolder();
3420 $importCharset = $this->dat[
'header'][
'charset'];
3421 if ($importCharset) {
3422 if ($importCharset !==
$GLOBALS[
'LANG']->charSet) {
3423 $this->
error(
'CHARSET: Converting charset of input file (' . $importCharset .
') to the system charset (' .
$GLOBALS[
'LANG']->charSet .
')');
3425 if (is_array($this->dat[
'header'][
'meta'])) {
3426 $GLOBALS[
'LANG']->csConvObj->convArray($this->dat[
'header'][
'meta'], $importCharset,
$GLOBALS[
'LANG']->charSet);
3429 if (is_array($this->dat[
'header'][
'records'])) {
3430 $GLOBALS[
'LANG']->csConvObj->convArray($this->dat[
'header'][
'records'], $importCharset,
$GLOBALS[
'LANG']->charSet);
3433 if (is_array($this->dat[
'records'])) {
3434 $GLOBALS[
'LANG']->csConvObj->convArray($this->dat[
'records'], $importCharset,
$GLOBALS[
'LANG']->charSet);
3438 $this->
error(
'CHARSET: No charset found in import file!');
3454 if (is_array($this->dat[
'header'][
'extensionDependencies'])) {
3455 foreach ($this->dat[
'header'][
'extensionDependencies'] as $extKey) {
3456 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extKey)) {
3457 $this->
error(
'DEPENDENCY: The extension with key "' . $extKey .
'" must be installed!');
3462 unset($this->dat[
'files']);
3465 if (is_array($this->dat[
'header'])) {
3466 $this->remainHeader = $this->dat[
'header'];
3468 if (is_array($this->dat[
'header'][
'pagetree'])) {
3469 reset($this->dat[
'header'][
'pagetree']);
3474 <tr class="bgColor5 tableheader">
3475 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_controls',
true) .
'</td>
3476 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_title',
true) .
'</td>
3477 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_size',
true) .
'</td>
3478 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_message',
true) .
'</td>
3479 ' . ($this->update ?
'<td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_updateMode',
true) .
'</td>' :
'') .
'
3480 ' . ($this->update ?
'<td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_currentPath',
true) .
'</td>' :
'') .
'
3481 ' . ($this->showDiff ?
'<td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_result',
true) .
'</td>' :
'') .
'
3483 foreach ($lines as $r) {
3485 <tr class="' . $r[
'class'] .
'">
3487 <td nowrap="nowrap">' . $r[
'preCode'] . $r[
'title'] .
'</td>
3489 <td nowrap="nowrap">' . ($r[
'msg'] && !$this->doesImport ?
'<span class="text-danger">' . htmlspecialchars($r[
'msg']) .
'</span>' :
'') .
'</td>
3490 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updateMode'] .
'</td>' :
'') .
'
3491 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updatePath'] .
'</td>' :
'') .
'
3492 ' . ($this->showDiff ?
'<td>' . $r[
'showDiffContent'] .
'</td>' :
'') .
'
3496 <strong>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_insidePagetree',
true) .
'</strong>
3498 <table border="0" cellpadding="0" cellspacing="1">' . implode(
'', $rows) .
'</table>
3503 if (is_array($this->remainHeader[
'records'])) {
3504 if (is_array($this->remainHeader[
'records'][
'pages'])) {
3508 if (!empty($lines)) {
3511 <tr class="bgColor5 tableheader">
3512 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_controls',
true) .
'</td>
3513 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_title',
true) .
'</td>
3514 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_size',
true) .
'</td>
3515 <td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_message',
true) .
'</td>
3516 ' . ($this->update ?
'<td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_updateMode',
true) .
'</td>' :
'') .
'
3517 ' . ($this->update ?
'<td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_currentPath',
true) .
'</td>' :
'') .
'
3518 ' . ($this->showDiff ?
'<td>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_displaycon_result',
true) .
'</td>' :
'') .
'
3520 foreach ($lines as $r) {
3521 $rows[] =
'<tr class="' . $r[
'class'] .
'">
3523 <td nowrap="nowrap">' . $r[
'preCode'] . $r[
'title'] .
'</td>
3525 <td nowrap="nowrap">' . ($r[
'msg'] && !$this->doesImport ?
'<span class="text-danger">' . htmlspecialchars($r[
'msg']) .
'</span>' :
'') .
'</td>
3526 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updateMode'] .
'</td>' :
'') .
'
3527 ' . ($this->update ?
'<td nowrap="nowrap">' . $r[
'updatePath'] .
'</td>' :
'') .
'
3528 ' . ($this->showDiff ?
'<td>' . $r[
'showDiffContent'] .
'</td>' :
'') .
'
3532 <strong>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_singlereco_outsidePagetree',
true) .
'</strong>
3534 <table border="0" cellpadding="0" cellspacing="1">' . implode(
'', $rows) .
'</table>';
3551 foreach ($pT as $k => $v) {
3555 if (is_array($this->dat[
'header'][
'pid_lookup'][$k])) {
3556 foreach ($this->dat[
'header'][
'pid_lookup'][$k] as $t => $recUidArr) {
3557 if ($t !=
'pages') {
3558 foreach ($recUidArr as $ruid => $value) {
3559 $this->
singleRecordLines($t, $ruid, $lines, $preCode .
' ');
3563 unset($this->remainHeader[
'pid_lookup'][$k]);
3566 if (is_array($v[
'subrow'])) {
3567 $this->
traversePageTree($v[
'subrow'], $lines, $preCode .
' ');
3581 foreach ($pT as $k => $rHeader) {
3584 if (is_array($this->dat[
'header'][
'pid_lookup'][$k])) {
3585 foreach ($this->dat[
'header'][
'pid_lookup'][$k] as $t => $recUidArr) {
3586 if ($t !=
'pages') {
3587 foreach ($recUidArr as $ruid => $value) {
3592 unset($this->remainHeader[
'pid_lookup'][$k]);
3606 foreach ($pT as $t => $recUidArr) {
3608 if ($t !=
'pages') {
3610 foreach ($recUidArr as $ruid => $value) {
3625 if ($this->update && $table ===
'sys_file') {
3626 $this->
error(
'Updating sys_file records is not supported! They will be imported as new records!');
3628 if ($this->force_all_UIDS && $table ===
'sys_file') {
3629 $this->
error(
'Forcing uids of sys_file records is not supported! They will be imported as new records!');
3646 $record = $this->dat[
'header'][
'records'][$table][$uid];
3647 unset($this->remainHeader[
'records'][$table][$uid]);
3648 if (!is_array($record) && !($table ===
'pages' && !$uid)) {
3649 $this->
error(
'MISSING RECORD: ' . $table .
':' . $uid, 1);
3653 $pInfo[
'ref'] = $table .
':' . $uid;
3655 if ($table ===
'_SOFTREF_') {
3656 $pInfo[
'preCode'] = $preCode;
3657 $pInfo[
'title'] =
'<em>' .
$GLOBALS[
'LANG']->getLL(
'impexpcore_singlereco_softReferencesFiles',
true) .
'</em>';
3660 $pInfo[
'preCode'] = $preCode;
3661 $pInfo[
'msg'] =
'UNKNOWN TABLE \'' . $pInfo[
'ref'] .
'\'';
3662 $pInfo[
'title'] =
'<em>' . htmlspecialchars($record[
'title']) .
'</em>';
3666 if (is_array($this->display_import_pid_record) && !empty($this->display_import_pid_record)) {
3667 if ($checkImportInPidRecord) {
3668 if (!
$GLOBALS[
'BE_USER']->doesUserHaveAccess($this->display_import_pid_record, ($table ===
'pages' ? 8 : 16))) {
3669 $pInfo[
'msg'] .=
'\'' . $pInfo[
'ref'] .
'\' cannot be INSERTED on
this page!
';
3671 if (!$this->checkDokType($table, $this->display_import_pid_record['doktype
']) && !$GLOBALS['TCA
'][$table]['ctrl
']['rootLevel
']) {
3672 $pInfo['msg
'] .= '\
'' . $table .
'\' cannot be INSERTED on
this page type (change page type to \
'Folder\'.) ';
3675 if (!
$GLOBALS[
'BE_USER']->check(
'tables_modify', $table)) {
3676 $pInfo[
'msg'] .=
'You are not allowed to CREATE \'' . $table .
'\' tables!
';
3678 if ($GLOBALS['TCA
'][$table]['ctrl
']['readOnly
']) {
3679 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' is READ ONLY!
';
3681 if ($GLOBALS['TCA
'][$table]['ctrl
']['adminOnly
'] && !$GLOBALS['BE_USER
']->isAdmin()) {
3682 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' is ADMIN ONLY!
';
3684 if ($GLOBALS['TCA
'][$table]['ctrl
']['is_static
']) {
3685 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' is a STATIC TABLE!
';
3687 if ((int)$GLOBALS['TCA
'][$table]['ctrl
']['rootLevel
'] === 1) {
3688 $pInfo['msg
'] .= 'TABLE \
'' . $table .
'\' will be inserted on ROOT LEVEL!
';
3690 $diffInverse = false;
3692 if ($this->update) {
3693 // In case of update-PREVIEW we swap the diff-sources.
3694 $diffInverse = true;
3695 $recInf = $this->doesRecordExist($table, $uid, $this->showDiff ? '*
' : '');
3696 $pInfo['updatePath
'] = $recInf ? htmlspecialchars($this->getRecordPath($recInf['pid
'])) : '<strong>NEW!</strong>
';
3698 $optValues = array();
3699 $optValues[] = $recInf ? $GLOBALS['LANG
']->getLL('impexpcore_singlereco_update
') : $GLOBALS['LANG
']->getLL('impexpcore_singlereco_insert
');
3701 $optValues['as_new
'] = $GLOBALS['LANG
']->getLL('impexpcore_singlereco_importAsNew
');
3704 if (!$this->global_ignore_pid) {
3705 $optValues['ignore_pid
'] = $GLOBALS['LANG
']->getLL('impexpcore_singlereco_ignorePid
');
3707 $optValues['respect_pid
'] = $GLOBALS['LANG
']->getLL('impexpcore_singlereco_respectPid
');
3710 if (!$recInf && $GLOBALS['BE_USER
']->isAdmin()) {
3711 $optValues['force_uid
'] = sprintf($GLOBALS['LANG
']->getLL('impexpcore_singlereco_forceUidSAdmin
'), $uid);
3713 $optValues['exclude
'] = $GLOBALS['LANG
']->getLL('impexpcore_singlereco_exclude
');
3714 if ($table === 'sys_file
') {
3715 $pInfo['updateMode
'] = '';
3717 $pInfo['updateMode
'] = $this->renderSelectBox('tx_impexp[import_mode][
' . $table . ':
' . $uid . ']
', $this->import_mode[$table . ':
' . $uid], $optValues);
3721 if ($this->showDiff) {
3722 // For IMPORTS, get new id:
3723 if ($newUid = $this->import_mapId[$table][$uid]) {
3724 $diffInverse = false;
3725 $recInf = $this->doesRecordExist($table, $newUid, '*
');
3726 BackendUtility::workspaceOL($table, $recInf);
3728 if (is_array($recInf)) {
3729 $pInfo['showDiffContent
'] = $this->compareRecords($recInf, $this->dat['records
'][$table . ':
' . $uid]['data
'], $table, $diffInverse);
3733 $pInfo['preCode
'] = $preCode . '<span title=
"' . htmlspecialchars($table . ':' . $uid) . '">
'
3734 . $this->iconFactory->getIconForRecord($table, (array)$this->dat['records
'][($table . ':
' . $uid)]['data
'], Icon::SIZE_SMALL)->render()
3736 $pInfo['title
'] = htmlspecialchars($record['title
']);
3738 if ($table === 'pages
') {
3739 $viewID = $this->mode === 'export
' ? $uid : ($this->doesImport ? $this->import_mapId['pages
'][$uid] : 0);
3741 $pInfo['title
'] = '<a href=
"#" onclick=
"' . htmlspecialchars(BackendUtility::viewOnClick($viewID)) . 'return false;">
' . $pInfo['title
'] . '</a>
';
3745 $pInfo['class'] = $table == 'pages
' ? 'bgColor4-20
' : 'bgColor4
';
3746 $pInfo['type
'] = 'record
';
3747 $pInfo['size
'] = $record['size
'];
3750 if (is_array($record['filerefs
'])) {
3751 $this->addFiles($record['filerefs
'], $lines, $preCode);
3754 if (is_array($record['rels
'])) {
3755 $this->addRelations($record['rels
'], $lines, $preCode);
3758 if (!empty($record['softrefs
'])) {
3759 $preCode_A = $preCode . '
';
3760 $preCode_B = $preCode . '
';
3761 foreach ($record['softrefs
'] as $info) {
3763 $pInfo['preCode
'] = $preCode_A . $this->iconFactory->getIcon('status-status-reference-soft
', Icon::SIZE_SMALL)->render();
3764 $pInfo['title
'] = '<em>
' . $info['field
'] . ',
"' . $info['spKey'] . '" </em>: <span title=
"' . htmlspecialchars($info['matchString']) . '">
' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['matchString
'], 60)) . '</span>
';
3765 if ($info['subst
']['type
']) {
3766 if (strlen($info['subst
']['title
'])) {
3767 $pInfo['title
'] .= '<br/>
' . $preCode_B . '<strong>
' . $GLOBALS['LANG
']->getLL('impexpcore_singlereco_title
', true) . '</strong>
' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst
']['title
'], 60));
3769 if (strlen($info['subst
']['description
'])) {
3770 $pInfo['title
'] .= '<br/>
' . $preCode_B . '<strong>
' . $GLOBALS['LANG
']->getLL('impexpcore_singlereco_descr
', true) . '</strong>
' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($info['subst
']['description
'], 60));
3772 $pInfo['title
'] .= '<br/>
' . $preCode_B . ($info['subst
']['type
'] == 'file
' ? $GLOBALS['LANG
']->getLL('impexpcore_singlereco_filename
', true) . ' <strong>
' . $info['subst
']['relFileName
'] . '</strong>
' : '') . ($info['subst
']['type
'] == 'string' ? $GLOBALS['LANG
']->getLL('impexpcore_singlereco_value
', true) . ' <strong>
' . $info['subst
']['tokenValue
'] . '</strong>
' : '') . ($info['subst
']['type
'] == 'db
' ? $GLOBALS['LANG
']->getLL('impexpcore_softrefsel_record
', true) . ' <strong>
' . $info['subst
']['recordRef
'] . '</strong>
' : '');
3774 $pInfo['ref
'] = 'SOFTREF
';
3775 $pInfo['size
'] = '';
3776 $pInfo['class'] = 'bgColor3
';
3777 $pInfo['type
'] = 'softref
';
3778 $pInfo['_softRefInfo
'] = $info;
3779 $pInfo['type
'] = 'softref
';
3780 if ($info['error'] && !GeneralUtility::inList('editable,exclude
', $this->softrefCfg[$info['subst
']['tokenID
']]['mode
'])) {
3781 $pInfo['msg
'] .= $info['error'];
3785 if ($info['subst
']['type
'] == 'db
') {
3786 list($tempTable, $tempUid) = explode(':
', $info['subst
']['recordRef
']);
3787 $this->addRelations(array(array('table
' => $tempTable, 'id' => $tempUid, 'tokenID
' => $info['subst
']['tokenID
'])), $lines, $preCode_B, array(), '');
3790 if ($info['subst
']['type
'] == 'file
') {
3791 $this->addFiles(array($info['file_ID
']), $lines, $preCode_B, '', $info['subst
']['tokenID
']);
3809 public function addRelations($rels, &$lines, $preCode, $recurCheck = array(), $htmlColorClass = '')
3811 foreach ($rels as $dat) {
3812 $table = $dat['table
'];
3815 $pInfo['ref
'] = $table . ':
' . $uid;
3816 if (in_array($pInfo['ref
'], $recurCheck)) {
3817 $this->error($pInfo['ref
'] . ' was recursive...
');
3820 $iconName = 'status-status-checked
';
3822 $staticFixed = false;
3825 $record = $this->dat['header
']['records
'][$table][$uid];
3826 if (!is_array($record)) {
3827 if ($this->isTableStatic($table) || $this->isExcluded($table, $uid) || $dat['tokenID
'] && !$this->includeSoftref($dat['tokenID
'])) {
3828 $pInfo['title
'] = htmlspecialchars('STATIC:
' . $pInfo['ref
']);
3829 $iconClass = 'text-info
';
3830 $staticFixed = true;
3832 $doesRE = $this->doesRecordExist($table, $uid);
3833 $lostPath = $this->getRecordPath($table === 'pages
' ? $doesRE['uid
'] : $doesRE['pid
']);
3834 $pInfo['title
'] = htmlspecialchars($pInfo['ref
']);
3835 $pInfo['title
'] = '<span title=
"' . htmlspecialchars($lostPath) . '">
' . $pInfo['title
'] . '</span>
';
3836 $pInfo['msg
'] = 'LOST RELATION
' . (!$doesRE ? ' (Record not found!)
' : ' (Path:
' . $lostPath . ')
');
3837 $iconClass = 'text-danger
';
3838 $iconName = 'status-dialog-warning
';
3841 $pInfo['title
'] = htmlspecialchars($record['title
']);
3842 $pInfo['title
'] = '<span title=
"' . htmlspecialchars($this->getRecordPath(($table === 'pages' ? $record['uid'] : $record['pid']))) . '">
' . $pInfo['title
'] . '</span>
';
3845 // 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
3846 $pInfo['title
'] = htmlspecialchars('FIXED:
' . $pInfo['ref
']);
3847 $staticFixed = true;
3850 $icon = '<span
class=
"' . $iconClass . '" title=
"' . htmlspecialchars($pInfo['ref']) . '">
' . $this->iconFactory->getIcon($iconName, Icon::SIZE_SMALL)->render() . '</span>
';
3852 $pInfo['preCode
'] = $preCode . '
' . $icon;
3853 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
';
3854 $pInfo['type
'] = 'rel
';
3855 if (!$staticFixed || $this->showStaticRelations) {
3857 if (is_array($record) && is_array($record['rels
'])) {
3858 $this->addRelations($record['rels
'], $lines, $preCode . '
', array_merge($recurCheck, array($pInfo['ref
'])), $htmlColorClass);
3876 public function addFiles($rels, &$lines, $preCode, $htmlColorClass = '', $tokenID = '')
3878 foreach ($rels as $ID) {
3881 $fI = $this->dat['header
']['files
'][$ID];
3882 if (!is_array($fI)) {
3883 if (!$tokenID || $this->includeSoftref($tokenID)) {
3884 $pInfo['msg
'] = 'MISSING FILE:
' . $ID;
3885 $this->error('MISSING FILE:
' . $ID, 1);
3890 $pInfo['preCode
'] = $preCode . '
' . $this->iconFactory->getIcon('status-status-reference-hard
', Icon::SIZE_SMALL)->render();
3891 $pInfo['title
'] = htmlspecialchars($fI['filename
']);
3892 $pInfo['ref
'] = 'FILE
';
3893 $pInfo['size
'] = $fI['filesize
'];
3894 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
';
3895 $pInfo['type
'] = 'file
';
3896 // If import mode and there is a non-RTE softreference, check the destination directory:
3897 if ($this->mode === 'import' && $tokenID && !$fI['RTE_ORIG_ID
']) {
3898 if (isset($fI['parentRelFileName
'])) {
3899 $pInfo['msg
'] = 'Seems like
this file is already referenced from within an HTML/CSS file. That takes precedence.
';
3901 $testDirPrefix = PathUtility::dirname($fI['relFileName
']) . '/
';
3902 $testDirPrefix2 = $this->verifyFolderAccess($testDirPrefix);
3903 if (!$testDirPrefix2) {
3904 $pInfo['msg
'] = 'ERROR: There are no available filemounts to write file in!
';
3905 } elseif ($testDirPrefix !== $testDirPrefix2) {
3906 $pInfo['msg
'] = 'File will be attempted written to
"' . $testDirPrefix2 . '".
';
3909 // Check if file exists:
3910 if (file_exists(PATH_site . $fI['relFileName
'])) {
3911 if ($this->update) {
3912 $pInfo['updatePath
'] .= 'File exists.
';
3914 $pInfo['msg
'] .= 'File already exists!
';
3918 $fileProcObj = $this->getFileProcObj();
3919 if ($fileProcObj->actionPerms['addFile
']) {
3920 $testFI = GeneralUtility::split_fileref(PATH_site . $fI['relFileName
']);
3921 if (!$this->allowPHPScripts && !$fileProcObj->checkIfAllowed($testFI['fileext
'], $testFI['path'], $testFI['file
'])) {
3922 $pInfo['msg
'] .= 'File extension was not allowed!
';
3925 $pInfo['msg
'] = 'You user profile does not allow you to create files on the server!
';
3928 $pInfo['showDiffContent
'] = PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]);
3930 unset($this->remainHeader['files
'][$ID]);
3932 if ($fI['RTE_ORIG_ID
']) {
3933 $ID = $fI['RTE_ORIG_ID
'];
3935 $fI = $this->dat['header
']['files
'][$ID];
3936 if (!is_array($fI)) {
3937 $pInfo['msg
'] = 'MISSING RTE original FILE:
' . $ID;
3938 $this->error('MISSING RTE original FILE:
' . $ID, 1);
3940 $pInfo['showDiffContent
'] = PathUtility::stripPathSitePrefix($this->fileIDMap[$ID]);
3941 $pInfo['preCode
'] = $preCode . '
' . $this->iconFactory->getIcon('status-status-reference-hard
', Icon::SIZE_SMALL)->render();
3942 $pInfo['title
'] = htmlspecialchars($fI['filename
']) . ' <em>(Original)</em>
';
3943 $pInfo['ref
'] = 'FILE
';
3944 $pInfo['size
'] = $fI['filesize
'];
3945 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
';
3946 $pInfo['type
'] = 'file
';
3948 unset($this->remainHeader['files
'][$ID]);
3950 // External resources:
3951 if (is_array($fI['EXT_RES_ID
'])) {
3952 foreach ($fI['EXT_RES_ID
'] as $extID) {
3954 $fI = $this->dat['header
']['files
'][$extID];
3955 if (!is_array($fI)) {
3956 $pInfo['msg
'] = 'MISSING External Resource FILE:
' . $extID;
3957 $this->error('MISSING External Resource FILE:
' . $extID, 1);
3959 $pInfo['updatePath
'] = $fI['parentRelFileName
'];
3961 $pInfo['showDiffContent
'] = PathUtility::stripPathSitePrefix($this->fileIDMap[$extID]);
3962 $pInfo['preCode
'] = $preCode . '
' . $this->iconFactory->getIcon('actions-insert-reference
', Icon::SIZE_SMALL)->render();
3963 $pInfo['title
'] = htmlspecialchars($fI['filename
']) . ' <em>(Resource)</em>
';
3964 $pInfo['ref
'] = 'FILE
';
3965 $pInfo['size
'] = $fI['filesize
'];
3966 $pInfo['class'] = $htmlColorClass ?: 'bgColor3
';
3967 $pInfo['type
'] = 'file
';
3969 unset($this->remainHeader['files
'][$extID]);
3982 public function checkDokType($checkTable, $doktype)
3984 $allowedTableList = isset($GLOBALS['PAGES_TYPES
'][$doktype]['allowedTables
']) ? $GLOBALS['PAGES_TYPES
'][$doktype]['allowedTables
'] : $GLOBALS['PAGES_TYPES
']['default']['allowedTables
'];
3985 $allowedArray = GeneralUtility::trimExplode(',
', $allowedTableList, true);
3986 // If all tables or the table is listed as an allowed type, return TRUE
3987 if (strstr($allowedTableList, '*
') || in_array($checkTable, $allowedArray)) {
3999 public function renderControls($r)
4001 if ($this->mode === 'export
') {
4002 if ($r['type
'] === 'record
') {
4003 return '<input type=
"checkbox" name=
"tx_impexp[exclude][' . $r['ref'] . ']" id=
"checkExclude' . $r['ref'] . '" value=
"1" /> <label
for=
"checkExclude' . $r['ref'] . '">
' . $GLOBALS['LANG
']->getLL('impexpcore_singlereco_exclude
', true) . '</label>
';
4005 return $r['type
'] == 'softref
' ? $this->softrefSelector($r['_softRefInfo
']) : '';
4009 // For softreferences with editable fields:
4010 if ($r['type
'] == 'softref
' && is_array($r['_softRefInfo
']['subst
']) && $r['_softRefInfo
']['subst
']['tokenID
']) {
4011 $tokenID = $r['_softRefInfo
']['subst
']['tokenID
'];
4012 $cfg = $this->softrefCfg[$tokenID];
4013 if ($cfg['mode
'] === 'editable
') {
4014 return (strlen($cfg['title
']) ? '<strong>
' . htmlspecialchars($cfg['title
']) . '</strong><br/>
' : '') . htmlspecialchars($cfg['description
']) . '<br/>
4015 <input type=
"text" name=
"tx_impexp[softrefInputValues][' . $tokenID . ']" value=
"' . htmlspecialchars((isset($this->softrefInputValues[$tokenID]) ? $this->softrefInputValues[$tokenID] : $cfg['defValue'])) . '" />
';
4028 public function softrefSelector($cfg)
4030 // Looking for file ID if any:
4031 $fI = $cfg['file_ID
'] ? $this->dat['header
']['files
'][$cfg['file_ID
']] : array();
4032 // Substitution scheme has to be around and RTE images MUST be exported.
4033 if (is_array($cfg['subst
']) && $cfg['subst
']['tokenID
'] && !$fI['RTE_ORIG_ID
']) {
4035 $optValues = array();
4036 $optValues[''] = '';
4037 $optValues['editable
'] = $GLOBALS['LANG
']->getLL('impexpcore_softrefsel_editable
');
4038 $optValues['exclude
'] = $GLOBALS['LANG
']->getLL('impexpcore_softrefsel_exclude
');
4039 // Get current value:
4040 $value = $this->softrefCfg[$cfg['subst
']['tokenID
']]['mode
'];
4041 // Render options selector:
4042 $selectorbox = $this->renderSelectBox(('tx_impexp[softrefCfg][
' . $cfg['subst
']['tokenID
'] . '][mode]
'), $value, $optValues) . '<br/>
';
4043 if ($value === 'editable
') {
4044 $descriptionField = '';
4046 if (strlen($cfg['subst
']['title
'])) {
4047 $descriptionField .= '
4048 <input type=
"hidden" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][title]" value=
"' . htmlspecialchars($cfg['subst']['title']) . '" />
4049 <strong>
' . htmlspecialchars($cfg['subst
']['title
']) . '</strong><br/>
';
4052 if (!strlen($cfg['subst
']['description
'])) {
4053 $descriptionField .= '
4054 ' . $GLOBALS['LANG
']->getLL('impexpcore_printerror_description
', true) . '<br/>
4055 <input type=
"text" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][description]" value=
"' . htmlspecialchars($this->softrefCfg[$cfg['subst']['tokenID']]['description']) . '" />
';
4057 $descriptionField .= '
4059 <input type=
"hidden" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][description]" value=
"' . htmlspecialchars($cfg['subst']['description']) . '" />
' . htmlspecialchars($cfg['subst
']['description
']);
4062 $descriptionField .= '<input type=
"hidden" name=
"tx_impexp[softrefCfg][' . $cfg['subst']['tokenID'] . '][defValue]" value=
"' . htmlspecialchars($cfg['subst']['tokenValue']) . '" />
';
4064 $descriptionField = '';
4066 return $selectorbox . $descriptionField;
4071 /*****************************
4072 * Helper functions of kinds
4073 *****************************/
4081 public function isTableStatic($table)
4083 if (is_array($GLOBALS['TCA
'][$table])) {
4084 return $GLOBALS['TCA
'][$table]['ctrl
']['is_static
'] || in_array($table, $this->relStaticTables) || in_array('_ALL
', $this->relStaticTables);
4095 public function inclRelation($table)
4097 return is_array($GLOBALS['TCA
'][$table])
4098 && (in_array($table, $this->relOnlyTables) || in_array('_ALL
', $this->relOnlyTables))
4099 && $GLOBALS['BE_USER
']->check('tables_select
', $table);
4109 public function isExcluded($table, $uid)
4111 return (bool)$this->excludeMap[$table . ':
' . $uid];
4120 public function includeSoftref($tokenID)
4122 return $tokenID && !GeneralUtility::inList('exclude,editable
', $this->softrefCfg[$tokenID]['mode
']);
4131 public function checkPID($pid)
4133 if (!isset($this->checkPID_cache[$pid])) {
4134 $this->checkPID_cache[$pid] = (bool)$GLOBALS['BE_USER
']->isInWebMount($pid);
4136 return $this->checkPID_cache[$pid];
4146 public function dontIgnorePid($table, $uid)
4148 return $this->import_mode[$table . ':
' . $uid] !== 'ignore_pid
' && (!$this->global_ignore_pid || $this->import_mode[$table . ':
' . $uid] === 'respect_pid
');
4159 public function doesRecordExist($table, $uid, $fields = '')
4161 return BackendUtility::getRecord($table, $uid, $fields ? $fields : 'uid,pid
');
4170 public function getRecordPath($pid)
4172 if (!isset($this->cache_getRecordPath[$pid])) {
4173 $clause = $GLOBALS['BE_USER
']->getPagePermsClause(1);
4174 $this->cache_getRecordPath[$pid] = (string)BackendUtility::getRecordPath($pid, $clause, 20);
4176 return $this->cache_getRecordPath[$pid];
4187 public function renderSelectBox($prefix, $value, $optValues)
4191 foreach ($optValues as $k => $v) {
4192 $sel = (string)$k === (string)$value ? ' selected=
"selected"' : '';
4196 $opt[] = '<option value=
"' . htmlspecialchars($k) . '"' . $sel . '>
' . htmlspecialchars($v) . '</option>
';
4198 if (!$isSelFlag && (string)$value !== '') {
4199 $opt[] = '<option value=
"' . htmlspecialchars($value) . '" selected=
"selected">
' . htmlspecialchars(('[\
'' . $value .
'\']
')) . '</option>
';
4201 return '<select name=
"' . $prefix . '">
' . implode('', $opt) . '</select>
';
4214 public function compareRecords($databaseRecord, $importRecord, $table, $inverseDiff = false)
4218 $diffUtility = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Utility\DiffUtility::class);
4219 // Check if both inputs are records:
4220 if (is_array($databaseRecord) && is_array($importRecord)) {
4221 // Traverse based on database record
4222 foreach ($databaseRecord as $fN => $value) {
4223 if (is_array($GLOBALS['TCA
'][$table]['columns
'][$fN]) && $GLOBALS['TCA
'][$table]['columns
'][$fN]['config
']['type
'] != 'passthrough
') {
4224 if (isset($importRecord[$fN])) {
4225 if (trim($databaseRecord[$fN]) !== trim($importRecord[$fN])) {
4226 // Create diff-result:
4227 $output[$fN] = $diffUtility->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));
4229 unset($importRecord[$fN]);
4233 // Traverse remaining in import record:
4234 foreach ($importRecord as $fN => $value) {
4235 if (is_array($GLOBALS['TCA
'][$table]['columns
'][$fN]) && $GLOBALS['TCA
'][$table]['columns
'][$fN]['config
']['type
'] !== 'passthrough
') {
4236 $output[$fN] = '<strong>Field missing</strong> in database
';
4240 if (!empty($output)) {
4242 foreach ($output as $fN => $state) {
4245 <td
class=
"bgColor5">
' . $GLOBALS['LANG
']->sL($GLOBALS['TCA
'][$table]['columns
'][$fN]['label
'], true) . ' (
' . htmlspecialchars($fN) . ')</td>
4246 <td
class=
"bgColor4">
' . $state . '</td>
4250 $output = '<table border=
"0" cellpadding=
"0" cellspacing=
"1">
' . implode('', $tRows) . '</table>
';
4254 return '<strong
class=
"text-nowrap">[
' . htmlspecialchars(($table . ':
' . $importRecord['uid
'] . ' =>
' . $databaseRecord['uid
'])) . ']:</strong>
' . $output;
4256 return 'ERROR: One of the inputs were not an array!
';
4265 public function getRTEoriginalFilename($string)
4267 // If "magic image":
4268 if (GeneralUtility::isFirstPartOfStr($string, 'RTEmagicC_
')) {
4269 // Find original file:
4270 $pI = pathinfo(substr($string, strlen('RTEmagicC_
')));
4271 $filename = substr($pI['basename
'], 0, -strlen(('.
' . $pI['extension
'])));
4272 $origFilePath = 'RTEmagicP_
' . $filename;
4273 return $origFilePath;
4283 public function getFileProcObj()
4285 if ($this->fileProcObj === null) {
4286 $this->fileProcObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::class);
4287 $this->fileProcObj->init(array(), $GLOBALS['TYPO3_CONF_VARS
']['BE
']['fileExtensions
']);
4288 $this->fileProcObj->setActionPermissions();
4290 return $this->fileProcObj;
4300 public function callHook($name, $params)
4302 if (is_array($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['ext/impexp/
class.tx_impexp.php
'][$name])) {
4303 foreach ($GLOBALS['TYPO3_CONF_VARS
']['SC_OPTIONS
']['ext/impexp/
class.tx_impexp.php
'][$name] as $hook) {
4304 GeneralUtility::callUserFunction($hook, $params, $this);
4309 /*****************************
4311 *****************************/
4319 public function error($msg)
4321 $this->errorLog[] = $msg;
4329 public function printErrorLog()
4331 return !empty($this->errorLog) ? \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($this->errorLog) : '';