2 namespace TYPO3\CMS\Impexp\Controller
;
5 * Main script class for the Import / Export facility
7 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
9 class ImportExportController
extends \TYPO3\CMS\Backend\Module\BaseScriptClass
{
11 // Array containing the current page.
13 * @todo Define visibility
18 * Main module function
21 * @todo Define visibility
23 public function main() {
24 // Start document template object:
25 $this->doc
= \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
26 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
27 $this->doc
->bodyTagId
= 'imp-exp-mod';
28 $this->doc
->setModuleTemplate(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::extRelPath('impexp') . '/app/template.html');
29 $this->pageinfo
= \TYPO3\CMS\Backend\Utility\BackendUtility
::readPageAccess($this->id
, $this->perms_clause
);
31 $this->doc
->JScode
= $this->doc
->wrapScriptTags('
33 function jumpToUrl(URL) { //
34 window.location.href = URL;
37 // Setting up the context sensitive menu:
38 $this->doc
->getContextMenuCode();
39 $this->doc
->postCode
= $this->doc
->wrapScriptTags('
41 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id
) . ';
43 $this->doc
->form
= '<form action="' . htmlspecialchars($GLOBALS['MCONF']['_']) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"><input type="hidden" name="id" value="' . $this->id
. '" />';
44 $this->content
.= $this->doc
->header($GLOBALS['LANG']->getLL('title'));
45 $this->content
.= $this->doc
->spacer(5);
46 // Input data grabbed:
47 $inData = \TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('tx_impexp');
49 switch ((string) $inData['action']) {
51 // Finally: If upload went well, set the new file as the thumbnail in the $inData array:
52 if (is_object($this->fileProcessor
) && $this->fileProcessor
->internalUploadMap
[1]) {
53 $inData['meta']['thumbnail'] = md5($this->fileProcessor
->internalUploadMap
[1]);
55 // Call export interface
56 $this->exportData($inData);
59 // Finally: If upload went well, set the new file as the import file:
60 if (is_object($this->fileProcessor
) && $this->fileProcessor
->internalUploadMap
[1]) {
61 $fI = pathinfo($this->fileProcessor
->internalUploadMap
[1]);
62 // Only allowed extensions....
63 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList('t3d,xml', strtolower($fI['extension']))) {
64 $inData['file'] = $this->fileProcessor
->internalUploadMap
[1];
67 // Call import interface:
68 $this->importData($inData);
71 // Setting up the buttons and markers for docheader
72 $docHeaderButtons = $this->getButtons();
73 $markers['CONTENT'] = $this->content
;
74 // Build the <body> for the module
75 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->getLL('title'));
76 $this->content
.= $this->doc
->moduleBody($this->pageinfo
, $docHeaderButtons, $markers);
77 $this->content
.= $this->doc
->endPage();
78 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
85 * @todo Define visibility
87 public function printContent() {
92 * Create the panel of buttons for submitting the form or otherwise perform operations.
94 * @return array all available buttons as an associated array
96 protected function getButtons() {
101 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
102 $buttons['shortcut'] = $this->doc
->makeShortcutIcon('tx_impexp', '', $this->MCONF
['name']);
104 // Input data grabbed:
105 $inData = \TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('tx_impexp');
106 if ((string) $inData['action'] == 'import') {
107 if ($this->id
&& is_array($this->pageinfo
) ||
$GLOBALS['BE_USER']->user
['admin'] && !$this->id
) {
108 if (is_array($this->pageinfo
) && $this->pageinfo
['uid']) {
110 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility
::viewOnClick($this->pageinfo
['uid'], $this->doc
->backPath
, \TYPO3\CMS\Backend\Utility\BackendUtility
::BEgetRootLine($this->pageinfo
['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('actions-document-view') . '</a>';
117 /**************************
121 **************************/
123 * Export part of module
125 * @param array $inData Content of POST VAR tx_impexp[]..
126 * @return void Setting content in $this->content
127 * @todo Define visibility
129 public function exportData($inData) {
130 // BUILDING EXPORT DATA:
131 // Processing of InData array values:
132 $inData['pagetree']['maxNumber'] = \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange($inData['pagetree']['maxNumber'], 1, 10000, 100);
133 $inData['listCfg']['maxNumber'] = \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange($inData['listCfg']['maxNumber'], 1, 10000, 100);
134 $inData['maxFileSize'] = \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange($inData['maxFileSize'], 1, 10000, 1000);
135 $inData['filename'] = trim(preg_replace('/[^[:alnum:]._-]*/', '', preg_replace('/\\.(t3d|xml)$/', '', $inData['filename'])));
136 if (strlen($inData['filename'])) {
137 $inData['filename'] .= $inData['filetype'] == 'xml' ?
'.xml' : '.t3d';
139 // Set exclude fields in export object:
140 if (!is_array($inData['exclude'])) {
141 $inData['exclude'] = array();
143 // Saving/Loading/Deleting presets:
144 $this->processPresets($inData);
145 // Create export object and configure it:
146 $this->export
= \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Impexp\\ImportExport');
147 $this->export
->init(0, 'export');
148 $this->export
->setCharset($GLOBALS['LANG']->charSet
);
149 $this->export
->maxFileSize
= $inData['maxFileSize'] * 1024;
150 $this->export
->excludeMap
= (array) $inData['exclude'];
151 $this->export
->softrefCfg
= (array) $inData['softrefCfg'];
152 $this->export
->extensionDependencies
= (array) $inData['extension_dep'];
153 $this->export
->showStaticRelations
= $inData['showStaticRelations'];
154 $this->export
->includeExtFileResources
= !$inData['excludeHTMLfileResources'];
156 if (is_array($inData['external_static']['tables'])) {
157 $this->export
->relStaticTables
= $inData['external_static']['tables'];
159 // Configure which tables external relations are included for:
160 if (is_array($inData['external_ref']['tables'])) {
161 $this->export
->relOnlyTables
= $inData['external_ref']['tables'];
163 $this->export
->setHeaderBasics();
164 // Meta data setting:
165 $this->export
->setMetaData($inData['meta']['title'], $inData['meta']['description'], $inData['meta']['notes'], $GLOBALS['BE_USER']->user
['username'], $GLOBALS['BE_USER']->user
['realName'], $GLOBALS['BE_USER']->user
['email']);
166 if ($inData['meta']['thumbnail']) {
167 $tempDir = $this->userTempFolder();
169 $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir($tempDir, 'png,gif,jpg', 1);
170 $theThumb = $thumbnails[$inData['meta']['thumbnail']];
172 $this->export
->addThumbnail($theThumb);
176 // Configure which records to export
177 if (is_array($inData['record'])) {
178 foreach ($inData['record'] as $ref) {
179 $rParts = explode(':', $ref);
180 $this->export
->export_addRecord($rParts[0], \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecord($rParts[0], $rParts[1]));
183 // Configure which tables to export
184 if (is_array($inData['list'])) {
185 foreach ($inData['list'] as $ref) {
186 $rParts = explode(':', $ref);
187 if ($GLOBALS['BE_USER']->check('tables_select', $rParts[0])) {
188 $res = $this->exec_listQueryPid($rParts[0], $rParts[1], \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange($inData['listCfg']['maxNumber'], 1));
189 while ($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
190 $this->export
->export_addRecord($rParts[0], $subTrow);
196 if (isset($inData['pagetree']['id'])) {
197 // Based on click-expandable tree
198 if ($inData['pagetree']['levels'] == -1) {
199 $pagetree = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Impexp\\LocalPageTree');
200 $tree = $pagetree->ext_tree($inData['pagetree']['id'], $this->filterPageIds($this->export
->excludeMap
));
201 $this->treeHTML
= $pagetree->printTree($tree);
202 $idH = $pagetree->buffer_idH
;
203 } elseif ($inData['pagetree']['levels'] == -2) {
204 $this->addRecordsForPid($inData['pagetree']['id'], $inData['pagetree']['tables'], $inData['pagetree']['maxNumber']);
208 // If the ID is zero, export root
209 if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin()) {
215 $sPage = \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordWSOL('pages', $inData['pagetree']['id'], '*', ' AND ' . $this->perms_clause
);
217 if (is_array($sPage)) {
218 $pid = $inData['pagetree']['id'];
219 $tree = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Tree\\View\\PageTreeView');
220 $tree->init('AND ' . $this->perms_clause
. $this->filterPageIds($this->export
->excludeMap
));
221 $HTML = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIconForRecord('pages', $sPage);
222 $tree->tree
[] = array('row' => $sPage, 'HTML' => $HTML);
223 $tree->buffer_idH
= array();
224 if ($inData['pagetree']['levels'] > 0) {
225 $tree->getTree($pid, $inData['pagetree']['levels'], '');
228 $idH[$pid]['uid'] = $pid;
229 if (count($tree->buffer_idH
)) {
230 $idH[$pid]['subrow'] = $tree->buffer_idH
;
232 $pagetree = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Impexp\\LocalPageTree');
233 $this->treeHTML
= $pagetree->printTree($tree->tree
);
236 // In any case we should have a multi-level array, $idH, with the page structure here (and the HTML-code loaded into memory for nice display...)
237 if (is_array($idH)) {
238 // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...)
239 $flatList = $this->export
->setPageTree($idH);
240 foreach ($flatList as $k => $value) {
241 $this->export
->export_addRecord('pages', \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecord('pages', $k));
242 $this->addRecordsForPid($k, $inData['pagetree']['tables'], $inData['pagetree']['maxNumber']);
246 // After adding ALL records we set relations:
247 for ($a = 0; $a < 10; $a++
) {
248 $addR = $this->export
->export_addDBRelations($a);
253 // Finally files are added:
254 // MUST be after the DBrelations are set so that files from ALL added records are included!
255 $this->export
->export_addFilesFromRelations();
256 // If the download button is clicked, return file
257 if ($inData['download_export'] ||
$inData['save_export']) {
258 switch ((string) $inData['filetype']) {
260 $out = $this->export
->compileMemoryToFileContent('xml');
264 $this->export
->dontCompress
= 1;
266 $out = $this->export
->compileMemoryToFileContent();
267 $fExt = ($this->export
->doOutputCompress() ?
'-z' : '') . '.t3d';
271 $dlFile = $inData['filename'] ?
$inData['filename'] : 'T3D_' . substr(preg_replace('/[^[:alnum:]_]/', '-', $inData['download_export_name']), 0, 20) . '_' . date('Y-m-d_H-i') . $fExt;
272 // Export for download:
273 if ($inData['download_export']) {
274 $mimeType = 'application/octet-stream';
275 Header('Content-Type: ' . $mimeType);
276 Header('Content-Length: ' . strlen($out));
277 Header('Content-Disposition: attachment; filename=' . basename($dlFile));
282 if ($inData['save_export']) {
283 $savePath = $this->userSaveFolder();
284 $fullName = $savePath . $dlFile;
285 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::isAllowedAbsPath($savePath) && @is_dir
(dirname($fullName)) && \TYPO3\CMS\Core\Utility\GeneralUtility
::isAllowedAbsPath($fullName)) {
286 \TYPO3\CMS\Core\Utility\GeneralUtility
::writeFile($fullName, $out);
287 $this->content
.= $this->doc
->section($GLOBALS['LANG']->getLL('exportdata_savedFile'), sprintf($GLOBALS['LANG']->getLL('exportdata_savedInSBytes', 1), substr($savePath . $dlFile, strlen(PATH_site
)), \TYPO3\CMS\Core\Utility\GeneralUtility
::formatSize(strlen($out))), 0, 1);
289 $this->content
.= $this->doc
->section($GLOBALS['LANG']->getLL('exportdata_problemsSavingFile'), sprintf($GLOBALS['LANG']->getLL('exportdata_badPathS', 1), $fullName), 0, 1, 2);
293 // OUTPUT to BROWSER:
294 // Now, if we didn't make download file, show configuration form based on export:
295 $menuItems = array();
296 // Export configuration
298 $this->makeConfigurationForm($inData, $row);
299 $menuItems[] = array(
300 'label' => $GLOBALS['LANG']->getLL('tableselec_configuration'),
302 <table border="0" cellpadding="1" cellspacing="1">
310 $this->makeSaveForm($inData, $row);
311 $menuItems[] = array(
312 'label' => $GLOBALS['LANG']->getLL('exportdata_filePreset'),
314 <table border="0" cellpadding="1" cellspacing="1">
322 $this->makeAdvancedOptionsForm($inData, $row);
323 $menuItems[] = array(
324 'label' => $GLOBALS['LANG']->getLL('exportdata_advancedOptions'),
326 <table border="0" cellpadding="1" cellspacing="1">
332 // Generate overview:
333 $overViewContent = $this->export
->displayContentOverview();
334 // Print errors that might be:
335 $errors = $this->export
->printErrorLog();
336 $menuItems[] = array(
337 'label' => $GLOBALS['LANG']->getLL('exportdata_messages'),
338 'content' => $errors,
339 'stateIcon' => $errors ?
2 : 0
341 // Add hidden fields and create tabs:
342 $content = $this->doc
->getDynTabMenu($menuItems, 'tx_impexp_export', -1);
343 $content .= '<input type="hidden" name="tx_impexp[action]" value="export" />';
344 $this->content
.= $this->doc
->section('', $content, 0, 1);
346 $this->content
.= $this->doc
->section($GLOBALS['LANG']->getLL('execlistqu_structureToBeExported'), $overViewContent, 0, 1);
350 * Adds records to the export object for a specific page id.
352 * @param integer $k Page id for which to select records to add
353 * @param array $tables Array of table names to select from
354 * @param integer $maxNumber Max amount of records to select
356 * @todo Define visibility
358 public function addRecordsForPid($k, $tables, $maxNumber) {
359 if (is_array($tables)) {
360 foreach ($GLOBALS['TCA'] as $table => $value) {
361 if ($table != 'pages' && (in_array($table, $tables) ||
in_array('_ALL', $tables))) {
362 if ($GLOBALS['BE_USER']->check('tables_select', $table) && !$GLOBALS['TCA'][$table]['ctrl']['is_static']) {
363 $res = $this->exec_listQueryPid($table, $k, \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange($maxNumber, 1));
364 while ($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
365 $this->export
->export_addRecord($table, $subTrow);
374 * Selects records from table / pid
376 * @param string $table Table to select from
377 * @param integer $pid Page ID to select from
378 * @param integer $limit Max number of records to select
379 * @return pointer SQL resource pointer
380 * @todo Define visibility
382 public function exec_listQueryPid($table, $pid, $limit) {
383 $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ?
'ORDER BY ' . $GLOBALS['TCA'][$table]['ctrl']['sortby'] : $GLOBALS['TCA'][$table]['ctrl']['default_sortby'];
384 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid=' . intval($pid) . \TYPO3\CMS\Backend\Utility\BackendUtility
::deleteClause($table) . \TYPO3\CMS\Backend\Utility\BackendUtility
::versioningPlaceholderClause($table), '', $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy), $limit);
385 // Warning about hitting limit:
386 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == $limit) {
387 $this->content
.= $this->doc
->section($GLOBALS['LANG']->getLL('execlistqu_maxNumberLimit'), sprintf($GLOBALS['LANG']->getLL('makeconfig_anSqlQueryReturned', 1), $limit), 0, 1, 2);
393 * Create configuration form
395 * @param array $inData Form configurat data
396 * @param array Table row accumulation variable. This is filled with table rows.
397 * @return void Sets content in $this->content
398 * @todo Define visibility
400 public function makeConfigurationForm($inData, &$row) {
402 $nameSuggestion = '';
403 // Page tree export options:
404 if (isset($inData['pagetree']['id'])) {
405 $nameSuggestion .= 'tree_PID' . $inData['pagetree']['id'] . '_L' . $inData['pagetree']['levels'];
407 <tr class="tableheader bgColor5">
408 <td colspan="2">' . $LANG->getLL('makeconfig_exportPagetreeConfiguration', 1) . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'pageTreeCfg', $GLOBALS['BACK_PATH'], '') . '</td>
411 <tr class="bgColor4">
412 <td><strong>' . $LANG->getLL('makeconfig_pageId', 1) . '</strong></td>
413 <td>' . htmlspecialchars($inData['pagetree']['id']) . '<input type="hidden" value="' . htmlspecialchars($inData['pagetree']['id']) . '" name="tx_impexp[pagetree][id]" /></td>
416 <tr class="bgColor4">
417 <td><strong>' . $LANG->getLL('makeconfig_tree', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'pageTreeDisplay', $GLOBALS['BACK_PATH'], '') . '</td>
418 <td>' . ($this->treeHTML ?
$this->treeHTML
: $LANG->getLL('makeconfig_noTreeExportedOnly', 1)) . '</td>
421 '-2' => $LANG->getLL('makeconfig_tablesOnThisPage'),
422 '-1' => $LANG->getLL('makeconfig_expandedTree'),
423 '0' => $LANG->getLL('makeconfig_onlyThisPage'),
424 '1' => $LANG->getLL('makeconfig_1Level'),
425 '2' => $LANG->getLL('makeconfig_2Levels'),
426 '3' => $LANG->getLL('makeconfig_3Levels'),
427 '4' => $LANG->getLL('makeconfig_4Levels'),
428 '999' => $LANG->getLL('makeconfig_infinite')
431 <tr class="bgColor4">
432 <td><strong>' . $LANG->getLL('makeconfig_levels', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'pageTreeMode', $GLOBALS['BACK_PATH'], '') . '</td>
433 <td>' . $this->renderSelectBox('tx_impexp[pagetree][levels]', $inData['pagetree']['levels'], $opt) . '</td>
436 <tr class="bgColor4">
437 <td><strong>' . $LANG->getLL('makeconfig_includeTables', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'pageTreeRecordLimit', $GLOBALS['BACK_PATH'], '') . '</td>
438 <td>' . $this->tableSelector('tx_impexp[pagetree][tables]', $inData['pagetree']['tables'], 'pages') . '<br/>
439 ' . $LANG->getLL('makeconfig_maxNumberOfRecords', 1) . '<br/>
440 <input type="text" name="tx_impexp[pagetree][maxNumber]" value="' . htmlspecialchars($inData['pagetree']['maxNumber']) . '"' . $this->doc
->formWidth(10) . ' /><br/>
444 // Single record export:
445 if (is_array($inData['record'])) {
447 <tr class="tableheader bgColor5">
448 <td colspan="2">' . $LANG->getLL('makeconfig_exportSingleRecord', 1) . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'singleRecord', $GLOBALS['BACK_PATH'], '') . '</td>
450 foreach ($inData['record'] as $ref) {
451 $rParts = explode(':', $ref);
454 $nameSuggestion .= $tName . '_' . $rUid;
455 $rec = \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordWSOL($tName, $rUid);
457 <tr class="bgColor4">
458 <td><strong>' . $LANG->getLL('makeconfig_record', 1) . '</strong></td>
459 <td>' . \t3lib_iconworks
::getSpriteIconForRecord($tName, $rec) . \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordTitle($tName, $rec, TRUE) . '<input type="hidden" name="tx_impexp[record][]" value="' . htmlspecialchars(($tName . ':' . $rUid)) . '" /></td>
463 // Single tables/pids:
464 if (is_array($inData['list'])) {
466 <tr class="tableheader bgColor5">
467 <td colspan="2">' . $LANG->getLL('makeconfig_exportTablesFromPages', 1) . '</td>
469 // Display information about pages from which the export takes place
471 foreach ($inData['list'] as $reference) {
472 $referenceParts = explode(':', $reference);
473 $tableName = $referenceParts[0];
474 if ($GLOBALS['BE_USER']->check('tables_select', $tableName)) {
475 // If the page is actually the root, handle it differently
476 // NOTE: we don't compare integers, because the number actually comes from the split string above
477 if ($referenceParts[1] === '0') {
478 $iconAndTitle = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('apps-pagetree-root') . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
480 $record = \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordWSOL('pages', $referenceParts[1]);
481 $iconAndTitle = \t3lib_iconworks
::getSpriteIconForRecord('pages', $record) . \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordTitle('pages', $record, TRUE);
483 $tblList .= 'Table "' . $tableName . '" from ' . $iconAndTitle . '<input type="hidden" name="tx_impexp[list][]" value="' . htmlspecialchars($reference) . '" /><br/>';
487 <tr class="bgColor4">
488 <td><strong>' . $LANG->getLL('makeconfig_tablePids', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'tableList', $GLOBALS['BACK_PATH'], '') . '</td>
489 <td>' . $tblList . '</td>
492 <tr class="bgColor4">
493 <td><strong>' . $LANG->getLL('makeconfig_maxNumberOfRecords', 1) . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'tableListMaxNumber', $GLOBALS['BACK_PATH'], '') . '</strong></td>
495 <input type="text" name="tx_impexp[listCfg][maxNumber]" value="' . htmlspecialchars($inData['listCfg']['maxNumber']) . '"' . $this->doc
->formWidth(10) . ' /><br/>
500 <tr class="tableheader bgColor5">
501 <td colspan="2">' . $LANG->getLL('makeconfig_relationsAndExclusions', 1) . '</td>
503 // Add relation selector:
505 <tr class="bgColor4">
506 <td><strong>' . $LANG->getLL('makeconfig_includeRelationsToTables', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'inclRelations', $GLOBALS['BACK_PATH'], '') . '</td>
507 <td>' . $this->tableSelector('tx_impexp[external_ref][tables]', $inData['external_ref']['tables']) . '</td>
509 // Add static relation selector:
511 <tr class="bgColor4">
512 <td><strong>' . $LANG->getLL('makeconfig_useStaticRelationsFor', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'staticRelations', $GLOBALS['BACK_PATH'], '') . '</td>
513 <td>' . $this->tableSelector('tx_impexp[external_static][tables]', $inData['external_static']['tables']) . '<br/>
514 <label for="checkShowStaticRelations">' . $LANG->getLL('makeconfig_showStaticRelations', 1) . '</label> <input type="checkbox" name="tx_impexp[showStaticRelations]" id="checkShowStaticRelations" value="1"' . ($inData['showStaticRelations'] ?
' checked="checked"' : '') . ' />
518 $excludeHiddenFields = '';
519 if (is_array($inData['exclude'])) {
520 foreach ($inData['exclude'] as $key => $value) {
521 $excludeHiddenFields .= '<input type="hidden" name="tx_impexp[exclude][' . $key . ']" value="1" />';
525 <tr class="bgColor4">
526 <td><strong>' . $LANG->getLL('makeconfig_excludeElements', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'excludedElements', $GLOBALS['BACK_PATH'], '') . '</td>
527 <td>' . $excludeHiddenFields . '
528 ' . (count($inData['exclude']) ?
'<em>' . implode(', ', array_keys($inData['exclude'])) . '</em><hr/><label for="checkExclude">' . $LANG->getLL('makeconfig_clearAllExclusions', 1) . '</label> <input type="checkbox" name="tx_impexp[exclude]" id="checkExclude" value="1" />' : $LANG->getLL('makeconfig_noExcludedElementsYet', 1)) . '
533 <tr class="bgColor4">
536 <input type="submit" value="' . $LANG->getLL('makeadvanc_update', 1) . '" />
537 <input type="hidden" name="tx_impexp[download_export_name]" value="' . substr($nameSuggestion, 0, 30) . '" />
543 * Create advanced options form
545 * @param array $inData Form configurat data
546 * @param array $row Table row accumulation variable. This is filled with table rows.
547 * @return void Sets content in $this->content
548 * @todo Define visibility
550 public function makeAdvancedOptionsForm($inData, &$row) {
554 <tr class="tableheader bgColor5">
555 <td colspan="2">' . $LANG->getLL('makeadvanc_softReferences', 1) . '</td>
558 <tr class="bgColor4">
559 <td><label for="checkExcludeHTMLfileResources"><strong>' . $LANG->getLL('makeadvanc_excludeHtmlCssFile', 1) . '</strong></label>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'htmlCssResources', $GLOBALS['BACK_PATH'], '') . '</td>
560 <td><input type="checkbox" name="tx_impexp[excludeHTMLfileResources]" id="checkExcludeHTMLfileResources" value="1"' . ($inData['excludeHTMLfileResources'] ?
' checked="checked"' : '') . ' /></td>
564 <tr class="tableheader bgColor5">
565 <td colspan="2">' . $LANG->getLL('makeadvanc_extensionDependencies', 1) . '</td>
568 <tr class="bgColor4">
569 <td><strong>' . $LANG->getLL('makeadvanc_selectExtensionsThatThe', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'extensionDependencies', $GLOBALS['BACK_PATH'], '') . '</td>
570 <td>' . $this->extensionSelector('tx_impexp[extension_dep]', $inData['extension_dep']) . '</td>
574 <tr class="bgColor4">
577 <input type="submit" value="' . $LANG->getLL('makesavefo_update', 1) . '" />
578 <input type="hidden" name="tx_impexp[download_export_name]" value="' . substr($nameSuggestion, 0, 30) . '" />
584 * Create configuration form
586 * @param array $inData Form configurat data
587 * @param array $row Table row accumulation variable. This is filled with table rows.
588 * @return void Sets content in $this->content
589 * @todo Define visibility
591 public function makeSaveForm($inData, &$row) {
595 <tr class="tableheader bgColor5">
596 <td colspan="2">' . $LANG->getLL('makesavefo_presets', 1) . '</td>
599 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'tx_impexp_presets', '(public>0 OR user_uid=' . intval($GLOBALS['BE_USER']->user
['uid']) . ')' . ($inData['pagetree']['id'] ?
' AND (item_uid=' . intval($inData['pagetree']['id']) . ' OR item_uid=0)' : ''));
600 if (is_array($presets)) {
601 foreach ($presets as $presetCfg) {
602 $opt[$presetCfg['uid']] = $presetCfg['title'] . ' [' . $presetCfg['uid'] . ']' . ($presetCfg['public'] ?
' [Public]' : '') . ($presetCfg['user_uid'] === $GLOBALS['BE_USER']->user
['uid'] ?
' [Own]' : '');
606 <tr class="bgColor4">
607 <td><strong>' . $LANG->getLL('makesavefo_presets', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'presets', $GLOBALS['BACK_PATH'], '') . '</td>
609 ' . $LANG->getLL('makesavefo_selectPreset', 1) . '<br/>
610 ' . $this->renderSelectBox('preset[select]', '', $opt) . '
612 <input type="submit" value="' . $LANG->getLL('makesavefo_load', 1) . '" name="preset[load]" />
613 <input type="submit" value="' . $LANG->getLL('makesavefo_save', 1) . '" name="preset[save]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
614 <input type="submit" value="' . $LANG->getLL('makesavefo_delete', 1) . '" name="preset[delete]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
615 <input type="submit" value="' . $LANG->getLL('makesavefo_merge', 1) . '" name="preset[merge]" onclick="return confirm(\'' . $LANG->getLL('makesavefo_areYouSure', 1) . '\');" />
617 ' . $LANG->getLL('makesavefo_titleOfNewPreset', 1) . '
618 <input type="text" name="tx_impexp[preset][title]" value="' . htmlspecialchars($inData['preset']['title']) . '"' . $this->doc
->formWidth(30) . ' /><br/>
619 <label for="checkPresetPublic">' . $LANG->getLL('makesavefo_public', 1) . '</label>
620 <input type="checkbox" name="tx_impexp[preset][public]" id="checkPresetPublic" value="1"' . ($inData['preset']['public'] ?
' checked="checked"' : '') . ' /><br/>
625 <tr class="tableheader bgColor5">
626 <td colspan="2">' . $LANG->getLL('makesavefo_outputOptions', 1) . '</td>
629 $tempDir = $this->userTempFolder();
631 $thumbnails = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir($tempDir, 'png,gif,jpg');
632 array_unshift($thumbnails, '');
637 <tr class="bgColor4">
638 <td><strong>' . $LANG->getLL('makesavefo_metaData', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'metadata', $GLOBALS['BACK_PATH'], '') . '</td>
640 ' . $LANG->getLL('makesavefo_title', 1) . ' <br/>
641 <input type="text" name="tx_impexp[meta][title]" value="' . htmlspecialchars($inData['meta']['title']) . '"' . $this->doc
->formWidth(30) . ' /><br/>
642 ' . $LANG->getLL('makesavefo_description', 1) . ' <br/>
643 <input type="text" name="tx_impexp[meta][description]" value="' . htmlspecialchars($inData['meta']['description']) . '"' . $this->doc
->formWidth(30) . ' /><br/>
644 ' . $LANG->getLL('makesavefo_notes', 1) . ' <br/>
645 <textarea name="tx_impexp[meta][notes]"' . $this->doc
->formWidth(30, 1) . '>' . \TYPO3\CMS\Core\Utility\GeneralUtility
::formatForTextarea($inData['meta']['notes']) . '</textarea><br/>
646 ' . (is_array($thumbnails) ?
'
647 ' . $LANG->getLL('makesavefo_thumbnail', 1) . '<br/>
648 ' . $this->renderSelectBox('tx_impexp[meta][thumbnail]', $inData['meta']['thumbnail'], $thumbnails) . '<br/>
649 ' . ($inData['meta']['thumbnail'] ?
'<img src="' . $this->doc
->backPath
. '../' . substr($tempDir, strlen(PATH_site
)) . $thumbnails[$inData['meta']['thumbnail']] . '" vspace="5" style="border: solid black 1px;" alt="" /><br/>' : '') . '
650 ' . $LANG->getLL('makesavefo_uploadThumbnail', 1) . '<br/>
651 <input type="file" name="upload_1" ' . $this->doc
->formWidth(30) . ' size="30" /><br/>
652 <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempDir) . '" />
653 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
658 $savePath = $this->userSaveFolder();
660 if ($this->export
->compress
) {
661 $opt['t3d_compressed'] = $LANG->getLL('makesavefo_t3dFileCompressed');
663 $opt['t3d'] = $LANG->getLL('makesavefo_t3dFile');
664 $opt['xml'] = $LANG->getLL('makesavefo_xml');
666 <tr class="bgColor4">
667 <td><strong>' . $LANG->getLL('makesavefo_fileFormat', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'fileFormat', $GLOBALS['BACK_PATH'], '') . '</td>
668 <td>' . $this->renderSelectBox('tx_impexp[filetype]', $inData['filetype'], $opt) . '<br/>
669 ' . $LANG->getLL('makesavefo_maxSizeOfFiles', 1) . '<br/>
670 <input type="text" name="tx_impexp[maxFileSize]" value="' . htmlspecialchars($inData['maxFileSize']) . '"' . $this->doc
->formWidth(10) . ' /><br/>
671 ' . ($savePath ?
sprintf($LANG->getLL('makesavefo_filenameSavedInS', 1), substr($savePath, strlen(PATH_site
))) . '<br/>
672 <input type="text" name="tx_impexp[filename]" value="' . htmlspecialchars($inData['filename']) . '"' . $this->doc
->formWidth(30) . ' /><br/>' : '') . '
677 <tr class="bgColor4">
679 <td><input type="submit" value="' . $LANG->getLL('makesavefo_update', 1) . '" /> - <input type="submit" value="' . $LANG->getLL('makesavefo_downloadExport', 1) . '" name="tx_impexp[download_export]" />' . ($savePath ?
' - <input type="submit" value="' . $LANG->getLL('importdata_saveToFilename', 1) . '" name="tx_impexp[save_export]" />' : '') . '</td>
683 /**************************
687 **************************/
689 * Import part of module
691 * @param array $inData Content of POST VAR tx_impexp[]..
692 * @return void Setting content in $this->content
693 * @todo Define visibility
695 public function importData($inData) {
697 $access = is_array($this->pageinfo
) ?
1 : 0;
698 if ($this->id
&& $access ||
$GLOBALS['BE_USER']->user
['admin'] && !$this->id
) {
699 if ($GLOBALS['BE_USER']->user
['admin'] && !$this->id
) {
700 $this->pageinfo
= array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
702 if ($inData['new_import']) {
703 unset($inData['import_mode']);
705 /** @var $import \TYPO3\CMS\Impexp\ImportExport */
706 $import = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Impexp\\ImportExport');
707 $import->init(0, 'import');
708 $import->update
= $inData['do_update'];
709 $import->import_mode
= $inData['import_mode'];
710 $import->enableLogging
= $inData['enableLogging'];
711 $import->global_ignore_pid
= $inData['global_ignore_pid'];
712 $import->force_all_UIDS
= $inData['force_all_UIDS'];
713 $import->showDiff
= !$inData['notShowDiff'];
714 $import->allowPHPScripts
= $inData['allowPHPScripts'];
715 $import->softrefInputValues
= $inData['softrefInputValues'];
717 $menuItems = array();
718 // Make input selector:
719 // must have trailing slash.
720 $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
721 $filesInDir = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir(PATH_site
. $path, 't3d,xml', 1, 1);
722 $userPath = $this->userSaveFolder();
723 //Files from User-Dir
724 $filesInUserDir = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir($userPath, 't3d,xml', 1, 1);
725 $filesInDir = array_merge($filesInUserDir, $filesInDir);
726 if (is_dir(PATH_site
. $path . 'export/')) {
727 $filesInDir = array_merge($filesInDir, \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir(PATH_site
. $path . 'export/', 't3d,xml', 1, 1));
729 $tempFolder = $this->userTempFolder();
731 $temp_filesInDir = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir($tempFolder, 't3d,xml', 1, 1);
732 $filesInDir = array_merge($filesInDir, $temp_filesInDir);
737 foreach ($filesInDir as $file) {
738 $opt[$file] = substr($file, strlen(PATH_site
));
740 $row[] = '<tr class="bgColor5">
741 <td colspan="2"><strong>' . $LANG->getLL('importdata_selectFileToImport', 1) . '</strong></td>
743 $row[] = '<tr class="bgColor4">
744 <td><strong>' . $LANG->getLL('importdata_file', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'], '') . '</td>
745 <td>' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $opt) . '<br />' . sprintf($LANG->getLL('importdata_fromPathS', 1), $path) . (!$import->compress ?
'<br /><span class="typo3-red">' . $LANG->getLL('importdata_noteNoDecompressorAvailable', 1) . '</span>' : '') . '</td>
747 $row[] = '<tr class="bgColor5">
748 <td colspan="2"><strong>' . $LANG->getLL('importdata_importOptions', 1) . '</strong></td>
750 $row[] = '<tr class="bgColor4">
751 <td><strong>' . $LANG->getLL('importdata_update', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'], '') . '</td>
753 <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ?
' checked="checked"' : '') . ' />
754 <label for="checkDo_update">' . $LANG->getLL('importdata_updateRecords', 1) . '</label><br/>
755 <em>(' . $LANG->getLL('importdata_thisOptionRequiresThat', 1) . ')</em>' . ($inData['do_update'] ?
' <hr/>
756 <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ?
' checked="checked"' : '') . ' />
757 <label for="checkGlobal_ignore_pid">' . $LANG->getLL('importdata_ignorePidDifferencesGlobally', 1) . '</label><br/>
758 <em>(' . $LANG->getLL('importdata_ifYouSetThis', 1) . ')</em>
761 $row[] = '<tr class="bgColor4">
762 <td><strong>' . $LANG->getLL('importdata_options', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'], '') . '</td>
764 <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ?
' checked="checked"' : '') . ' />
765 <label for="checkNotShowDiff">' . $LANG->getLL('importdata_doNotShowDifferences', 1) . '</label><br/>
766 <em>(' . $LANG->getLL('importdata_greenValuesAreFrom', 1) . ')</em>
769 ' . ($GLOBALS['BE_USER']->isAdmin() ?
'
770 <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ?
' checked="checked"' : '') . ' />
771 <label for="checkAllowPHPScripts">' . $LANG->getLL('importdata_allowToWriteBanned', 1) . '</label><br/>' : '') . (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ?
'
773 <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ?
' checked="checked"' : '') . ' />
774 <label for="checkForce_all_UIDS"><span class="typo3-red">' . $LANG->getLL('importdata_force_all_UIDS', 1) . '</span></label><br/>
775 <em>(' . $LANG->getLL('importdata_force_all_UIDS_descr', 1) . ')</em>' : '') . '
778 $row[] = '<tr class="bgColor4">
779 <td><strong>' . $LANG->getLL('importdata_action', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'], '') . '</td>
780 <td>' . (!$inData['import_file'] ?
'<input type="submit" value="' . $LANG->getLL('importdata_preview', 1) . '" />' . ($inData['file'] ?
' - <input type="submit" value="' . ($inData['do_update'] ?
$LANG->getLL('importdata_update_299e', 1) : $LANG->getLL('importdata_import', 1)) . '" name="tx_impexp[import_file]" onclick="return confirm(\'' . $LANG->getLL('importdata_areYouSure', 1) . '\');" />' : '') : '<input type="submit" name="tx_impexp[new_import]" value="' . $LANG->getLL('importdata_newImport', 1) . '" />') . '
781 <input type="hidden" name="tx_impexp[action]" value="import" /></td>
783 $row[] = '<tr class="bgColor4">
784 <td><strong>' . $LANG->getLL('importdata_enableLogging', 1) . '</strong>' . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'], '') . '</td>
786 <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ?
' checked="checked"' : '') . ' />
787 <label for="checkEnableLogging">' . $LANG->getLL('importdata_writeIndividualDbActions', 1) . '</label><br/>
788 <em>(' . $LANG->getLL('importdata_thisIsDisabledBy', 1) . ')</em>
791 $menuItems[] = array(
792 'label' => $LANG->getLL('importdata_import', 1),
794 <table border="0" cellpadding="1" cellspacing="1">
801 $tempFolder = $this->userTempFolder();
804 $row[] = '<tr class="bgColor5">
805 <td colspan="2"><strong>' . $LANG->getLL('importdata_uploadFileFromLocal', 1) . '</strong></td>
807 $row[] = '<tr class="bgColor4">
808 <td>' . $LANG->getLL('importdata_browse', 1) . \TYPO3\CMS\Backend\Utility\BackendUtility
::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'], '') . '</td>
811 <input type="file" name="upload_1"' . $this->doc
->formWidth(35) . ' size="40" />
812 <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder) . '" />
813 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
815 <input type="submit" name="_upload" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" />
816 <input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles', 1) . '</label>
819 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::_POST('_upload')) {
820 $row[] = '<tr class="bgColor4">
821 <td>' . $LANG->getLL('importdata_uploadStatus', 1) . '</td>
822 <td>' . ($this->fileProcessor
->internalUploadMap
[1] ?
$LANG->getLL('importdata_success', 1) . ' ' . substr($this->fileProcessor
->internalUploadMap
[1], strlen(PATH_site
)) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', 1) . '</span>') . '</td>
825 $menuItems[] = array(
826 'label' => $LANG->getLL('importdata_upload'),
828 <table border="0" cellpadding="1" cellspacing="1">
835 // Perform import or preview depending:
836 $overviewContent = '';
837 $extensionInstallationMessage = '';
839 $inFile = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFileAbsFileName($inData['file']);
840 if ($inFile && @is_file
($inFile)) {
842 if ($import->loadFile($inFile, 1)) {
843 // Check extension dependencies:
844 $extKeysToInstall = array();
845 if (is_array($import->dat
['header']['extensionDependencies'])) {
846 foreach ($import->dat
['header']['extensionDependencies'] as $extKey) {
847 if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::isLoaded($extKey)) {
848 $extKeysToInstall[] = $extKey;
852 if (count($extKeysToInstall)) {
853 $passParams = \TYPO3\CMS\Core\Utility\GeneralUtility
::_POST('tx_impexp');
854 unset($passParams['import_mode']);
855 unset($passParams['import_file']);
856 $thisScriptUrl = \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REQUEST_URI') . '?M=xMOD_tximpexp&id=' . $this->id
. \TYPO3\CMS\Core\Utility\GeneralUtility
::implodeArrayForUrl('tx_impexp', $passParams);
857 $emURL = $this->doc
->backPath
. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::extRelPath('em') . 'classes/index.php?CMD[requestInstallExtensions]=' . implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl);
858 $extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '". Clicking Import will first take you to the Extension Manager so these dependencies can be resolved.';
860 if ($inData['import_file']) {
861 if (!count($extKeysToInstall)) {
862 $import->importData($this->id
);
863 \TYPO3\CMS\Backend\Utility\BackendUtility
::setUpdateSignal('updatePageTree');
865 \TYPO3\CMS\Core\Utility\HttpUtility
::redirect($emURL);
868 $import->display_import_pid_record
= $this->pageinfo
;
869 $overviewContent = $import->displayContentOverview();
872 $trow[] = '<tr class="bgColor5">
873 <td colspan="2"><strong>' . $LANG->getLL('importdata_metaData', 1) . '</strong></td>
876 foreach ($filesInDir as $file) {
877 $opt[$file] = substr($file, strlen(PATH_site
));
879 $trow[] = '<tr class="bgColor4">
880 <td><strong>' . $LANG->getLL('importdata_title', 1) . '</strong></td>
881 <td width="95%">' . nl2br(htmlspecialchars($import->dat
['header']['meta']['title'])) . '</td>
883 $trow[] = '<tr class="bgColor4">
884 <td><strong>' . $LANG->getLL('importdata_description', 1) . '</strong></td>
885 <td width="95%">' . nl2br(htmlspecialchars($import->dat
['header']['meta']['description'])) . '</td>
887 $trow[] = '<tr class="bgColor4">
888 <td><strong>' . $LANG->getLL('importdata_notes', 1) . '</strong></td>
889 <td width="95%">' . nl2br(htmlspecialchars($import->dat
['header']['meta']['notes'])) . '</td>
891 $trow[] = '<tr class="bgColor4">
892 <td><strong>' . $LANG->getLL('importdata_packager', 1) . '</strong></td>
893 <td width="95%">' . nl2br(htmlspecialchars(($import->dat
['header']['meta']['packager_name'] . ' (' . $import->dat
['header']['meta']['packager_username'] . ')'))) . '<br/>
894 ' . $LANG->getLL('importdata_email', 1) . ' ' . $import->dat
['header']['meta']['packager_email'] . '</td>
897 if (is_array($import->dat
['header']['thumbnail'])) {
898 $pI = pathinfo($import->dat
['header']['thumbnail']['filename']);
899 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
900 // Construct filename and write it:
901 $fileName = PATH_site
. 'typo3temp/importthumb.' . $pI['extension'];
902 \TYPO3\CMS\Core\Utility\GeneralUtility
::writeFile($fileName, $import->dat
['header']['thumbnail']['content']);
903 // Check that the image really is an image and not a malicious PHP script...
904 if (getimagesize($fileName)) {
906 $iconTag = '<img src="' . $this->doc
->backPath
. '../' . substr($fileName, strlen(PATH_site
)) . '" ' . $import->dat
['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
907 $trow[] = '<tr class="bgColor4">
908 <td><strong>' . $LANG->getLL('importdata_icon', 1) . '</strong></td>
909 <td>' . $iconTag . '</td>
912 \TYPO3\CMS\Core\Utility\GeneralUtility
::unlink_tempfile($fileName);
916 $menuItems[] = array(
917 'label' => $LANG->getLL('importdata_metaData_1387'),
919 <table border="0" cellpadding="1" cellspacing="1">
926 // Print errors that might be:
927 $errors = $import->printErrorLog();
928 $menuItems[] = array(
929 'label' => $LANG->getLL('importdata_messages'),
930 'content' => $errors,
931 'stateIcon' => $errors ?
2 : 0
934 $content = $this->doc
->getDynTabMenu($menuItems, 'tx_impexp_import', -1);
935 if ($extensionInstallationMessage) {
936 $content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->doc
->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content;
938 $this->content
.= $this->doc
->section('', $content, 0, 1);
940 if ($overviewContent) {
941 $this->content
.= $this->doc
->section($inData['import_file'] ?
$LANG->getLL('importdata_structureHasBeenImported', 1) : $LANG->getLL('filterpage_structureToBeImported', 1), $overviewContent, 0, 1);
946 /****************************
950 ****************************/
954 * @param array $inData In data array, passed by reference!
956 * @todo Define visibility
958 public function processPresets(&$inData) {
959 $presetData = \TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('preset');
962 if (isset($presetData['save'])) {
963 $preset = $this->getPreset($presetData['select']);
965 if (is_array($preset)) {
966 if ($GLOBALS['BE_USER']->isAdmin() ||
$preset['user_uid'] === $GLOBALS['BE_USER']->user
['uid']) {
967 $fields_values = array(
968 'public' => $inData['preset']['public'],
969 'title' => $inData['preset']['title'],
970 'item_uid' => $inData['pagetree']['id'],
971 'preset_data' => serialize($inData)
973 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_impexp_presets', 'uid=' . intval($preset['uid']), $fields_values);
974 $msg = 'Preset #' . $preset['uid'] . ' saved!';
976 $msg = 'ERROR: The preset was not saved because you were not the owner of it!';
981 $fields_values = array(
982 'user_uid' => $GLOBALS['BE_USER']->user
['uid'],
983 'public' => $inData['preset']['public'],
984 'title' => $inData['preset']['title'],
985 'item_uid' => $inData['pagetree']['id'],
986 'preset_data' => serialize($inData)
988 $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_impexp_presets', $fields_values);
989 $msg = 'New preset "' . htmlspecialchars($inData['preset']['title']) . '" is created';
993 if (isset($presetData['delete'])) {
994 $preset = $this->getPreset($presetData['select']);
995 if (is_array($preset)) {
997 if ($GLOBALS['BE_USER']->isAdmin() ||
$preset['user_uid'] === $GLOBALS['BE_USER']->user
['uid']) {
998 $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_impexp_presets', 'uid=' . intval($preset['uid']));
999 $msg = 'Preset #' . $preset['uid'] . ' deleted!';
1001 $msg = 'ERROR: You were not the owner of the preset so you could not delete it.';
1005 $msg = 'ERROR: No preset selected for deletion.';
1010 if (isset($presetData['load']) ||
isset($presetData['merge'])) {
1011 $preset = $this->getPreset($presetData['select']);
1012 if (is_array($preset)) {
1014 $inData_temp = unserialize($preset['preset_data']);
1015 if (is_array($inData_temp)) {
1016 if (isset($presetData['merge'])) {
1017 // Merge records in:
1018 if (is_array($inData_temp['record'])) {
1019 $inData['record'] = array_merge((array) $inData['record'], $inData_temp['record']);
1022 if (is_array($inData_temp['list'])) {
1023 $inData['list'] = array_merge((array) $inData['list'], $inData_temp['list']);
1026 $msg = 'Preset #' . $preset['uid'] . ' loaded!';
1027 $inData = $inData_temp;
1030 $msg = 'ERROR: No configuratio data found in preset record!';
1034 $msg = 'ERROR: No preset selected for loading.';
1040 $this->content
.= $this->doc
->section('Presets', $msg, 0, 1, $err ?
3 : 1);
1045 * Get single preset record
1047 * @param integer $uid Preset record
1048 * @return array Preset record, if any (otherwise FALSE)
1049 * @todo Define visibility
1051 public function getPreset($uid) {
1052 $preset = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tx_impexp_presets', 'uid=' . intval($uid));
1056 /****************************
1060 ****************************/
1062 * Returns first temporary folder of the user account (from $FILEMOUNTS)
1064 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
1065 * @todo Define visibility
1067 public function userTempFolder() {
1069 foreach ($FILEMOUNTS as $filePathInfo) {
1070 $tempFolder = $filePathInfo['path'] . '_temp_/';
1071 if (@is_dir
($tempFolder)) {
1078 * Returns folder where user can save export files.
1080 * @return string Absolute path to folder where export files can be saved.
1081 * @todo Define visibility
1083 public function userSaveFolder() {
1086 $filePathInfo = current($FILEMOUNTS);
1087 if (is_array($filePathInfo)) {
1088 $tempFolder = $filePathInfo['path'] . '_temp_/';
1089 if (!@is_dir
($tempFolder)) {
1090 $tempFolder = $filePathInfo['path'];
1091 if (!@is_dir
($tempFolder)) {
1100 * Check if a file has been uploaded
1103 * @todo Define visibility
1105 public function checkUpload() {
1106 $file = \TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('file');
1108 $this->fileProcessor
= \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\ExtendedFileUtility');
1109 $this->fileProcessor
->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
1110 $this->fileProcessor
->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
1111 $this->fileProcessor
->dontCheckForUnique
= \TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('overwriteExistingFiles') ?
1 : 0;
1112 // Checking referer / executing:
1113 $refInfo = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('HTTP_REFERER'));
1114 $httpHost = \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('TYPO3_HOST_ONLY');
1115 if ($httpHost != $refInfo['host'] && $this->vC
!= $GLOBALS['BE_USER']->veriCode() && !$GLOBALS['$TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
1116 $this->fileProcessor
->writeLog(0, 2, 1, 'Referer host "%s" and server host "%s" did not match!', array($refInfo['host'], $httpHost));
1118 $this->fileProcessor
->start($file);
1119 $this->fileProcessor
->processData();
1124 * Makes a selector-box from optValues
1126 * @param string $prefix Form element name
1127 * @param string $value Current value
1128 * @param array $optValues Options to display (key/value pairs)
1129 * @return string HTML select element
1130 * @todo Define visibility
1132 public function renderSelectBox($prefix, $value, $optValues) {
1135 foreach ($optValues as $k => $v) {
1136 $sel = !strcmp($k, $value) ?
' selected="selected"' : '';
1140 $opt[] = '<option value="' . htmlspecialchars($k) . '"' . $sel . '>' . htmlspecialchars($v) . '</option>';
1142 if (!$isSelFlag && strcmp('', $value)) {
1143 $opt[] = '<option value="' . htmlspecialchars($value) . '" selected="selected">' . htmlspecialchars(('[\'' . $value . '\']')) . '</option>';
1145 return '<select name="' . $prefix . '">' . implode('', $opt) . '</select>';
1149 * Returns a selector-box with TCA tables
1151 * @param string $prefix Form element name prefix
1152 * @param array $value The current values selected
1153 * @param string $excludeList Table names (and the string "_ALL") to exclude. Comma list
1154 * @return string HTML select element
1155 * @todo Define visibility
1157 public function tableSelector($prefix, $value, $excludeList = '') {
1158 $optValues = array();
1159 if (!\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($excludeList, '_ALL')) {
1160 $optValues['_ALL'] = '[' . $GLOBALS['LANG']->getLL('ALL_tables') . ']';
1162 foreach ($GLOBALS['TCA'] as $table => $_) {
1163 if ($GLOBALS['BE_USER']->check('tables_select', $table) && !\TYPO3\CMS\Core\Utility\GeneralUtility
::inList($excludeList, $table)) {
1164 $optValues[$table] = $table;
1169 $opt[] = '<option value=""></option>';
1170 foreach ($optValues as $k => $v) {
1171 if (is_array($value)) {
1172 $sel = in_array($k, $value) ?
' selected="selected"' : '';
1174 $opt[] = '<option value="' . htmlspecialchars($k) . '"' . $sel . '>' . htmlspecialchars($v) . '</option>';
1176 return '<select name="' . $prefix . '[]" multiple="multiple" size="' . \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange(count($opt), 5, 10) . '">' . implode('', $opt) . '</select>';
1180 * Returns a selector-box with loaded extension keys
1182 * @param string $prefix Form element name prefix
1183 * @param array $value The current values selected
1184 * @return string HTML select element
1185 * @todo Define visibility
1187 public function extensionSelector($prefix, $value) {
1188 global $TYPO3_LOADED_EXT;
1189 $extTrav = array_keys($TYPO3_LOADED_EXT);
1192 $opt[] = '<option value=""></option>';
1193 foreach ($extTrav as $v) {
1194 if (is_array($value)) {
1195 $sel = in_array($v, $value) ?
' selected="selected"' : '';
1197 $opt[] = '<option value="' . htmlspecialchars($v) . '"' . $sel . '>' . htmlspecialchars($v) . '</option>';
1199 return '<select name="' . $prefix . '[]" multiple="multiple" size="' . \TYPO3\CMS\Core\Utility\MathUtility
::forceIntegerInRange(count($opt), 5, 10) . '">' . implode('', $opt) . '</select>';
1203 * Filter page IDs by traversing exclude array, finding all excluded pages (if any) and making an AND NOT IN statement for the select clause.
1205 * @param array $exclude Exclude array from import/export object.
1206 * @return string AND where clause part to filter out page uids.
1207 * @todo Define visibility
1209 public function filterPageIds($exclude) {
1211 $exclude = array_keys($exclude);
1214 foreach ($exclude as $element) {
1215 list($table, $uid) = explode(':', $element);
1216 if ($table === 'pages') {
1217 $pageIds[] = intval($uid);
1221 if (count($pageIds)) {
1222 return ' AND uid NOT IN (' . implode(',', $pageIds) . ')';