[FEATURE] Change t3d exports default export target directory
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / app / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Import / Export module
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 */
32 /**
33 * IMPORTING DATA:
34 *
35 * Incoming array has syntax:
36 * GETvar 'id' = import page id (must be readable)
37 *
38 * file = (pointing to filename relative to PATH_site)
39 *
40 *
41 *
42 * [all relation fields are clear, but not files]
43 * - page-tree is written first
44 * - then remaining pages (to the root of import)
45 * - then all other records are written either to related included pages or if not found to import-root (should be a sysFolder in most cases)
46 * - then all internal relations are set and non-existing relations removed, relations to static tables preserved.
47 *
48 * EXPORTING DATA:
49 *
50 * Incoming array has syntax:
51 *
52 * file[] = file
53 * dir[] = dir
54 * list[] = table:pid
55 * record[] = table:uid
56 *
57 * pagetree[id] = (single id)
58 * pagetree[levels]=1,2,3, -1 = currently unpacked tree, -2 = only tables on page
59 * pagetree[tables][]=table/_ALL
60 *
61 * external_ref[tables][]=table/_ALL
62 */
63
64 unset($MCONF);
65 require ('conf.php');
66 require_once ($BACK_PATH.'init.php');
67 require_once ($BACK_PATH.'template.php');
68 $LANG->includeLLFile('EXT:impexp/app/locallang.php');
69 require_once (t3lib_extMgm::extPath('impexp').'class.tx_impexp.php');
70
71 t3lib_extMgm::isLoaded('impexp',1);
72
73
74
75
76
77 /**
78 * Extension of the page tree class. Used to get the tree of pages to export.
79 *
80 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
81 * @package TYPO3
82 * @subpackage tx_impexp
83 */
84 class localPageTree extends t3lib_browseTree {
85
86 /**
87 * Initialization
88 *
89 * @return void
90 */
91 function __construct() {
92 $this->init();
93 }
94
95 /**
96 * Compatibility constructor.
97 *
98 * @deprecated since TYPO3 4.6 and will be removed in TYPO3 4.8. Use __construct() instead.
99 */
100 public function localPageTree() {
101 t3lib_div::logDeprecatedFunction();
102 // Note: we cannot call $this->__construct() here because it would call the derived class constructor and cause recursion
103 // This code uses official PHP behavior (http://www.php.net/manual/en/language.oop5.basic.php) when $this in the
104 // statically called non-static method inherits $this from the caller's scope.
105 localPageTree::__construct();
106 }
107
108 /**
109 * Wrapping title from page tree.
110 *
111 * @param string Title to wrap
112 * @param mixed (See parent class)
113 * @return string Wrapped title
114 */
115 function wrapTitle($title,$v) {
116 $title = (!strcmp(trim($title),'')) ? '<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</em>' : htmlspecialchars($title);
117 return $title;
118 }
119
120 /**
121 * Wrapping Plus/Minus icon
122 *
123 * @param string Icon HTML
124 * @param mixed (See parent class)
125 * @param mixed (See parent class)
126 * @return string Icon HTML
127 */
128 function PM_ATagWrap($icon,$cmd,$bMark='') {
129 return $icon;
130 }
131
132 /**
133 * Wrapping Icon
134 *
135 * @param string Icon HTML
136 * @param array Record row (page)
137 * @return string Icon HTML
138 */
139 function wrapIcon($icon,$row) {
140 return $icon;
141 }
142
143 /**
144 * Select permissions
145 *
146 * @return string SQL where clause
147 */
148 function permsC() {
149 return $this->BE_USER->getPagePermsClause(1);
150 }
151
152 /**
153 * Tree rendering
154 *
155 * @param integer PID value
156 * @param string Additional where clause
157 * @return array Array of tree elements
158 */
159 function ext_tree($pid, $clause='') {
160
161 // Initialize:
162 $this->init(' AND '.$this->permsC().$clause);
163
164 // Get stored tree structure:
165 $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
166
167 // PM action:
168 $PM = t3lib_div::intExplode('_',t3lib_div::_GP('PM'));
169
170 // traverse mounts:
171 $titleLen = intval($this->BE_USER->uc['titleLen']);
172 $treeArr = array();
173
174 $idx = 0;
175
176 // Set first:
177 $this->bank = $idx;
178 $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
179
180 $curIds = $this->ids; // save ids
181 $this->reset();
182 $this->ids = $curIds;
183
184 // Set PM icon:
185 $cmd = $this->bank.'_'.($isOpen?'0_':'1_').$pid;
186 $icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen?'minus':'plus').'only.gif','width="18" height="16"').' align="top" alt="" />';
187 $firstHtml = $this->PM_ATagWrap($icon,$cmd);
188
189 if ($pid>0) {
190 $rootRec = t3lib_befunc::getRecordWSOL('pages',$pid);
191 $firstHtml.= $this->wrapIcon(t3lib_iconWorks::getSpriteIconForRecord('pages', $rootRec), $rootRec);
192 } else {
193 $rootRec = array(
194 'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
195 'uid' => 0
196 );
197 $firstHtml.= $this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' align="top" alt="" />',$rootRec);
198 }
199 $this->tree[] = array('HTML'=>$firstHtml, 'row'=>$rootRec);
200 if ($isOpen) {
201 // Set depth:
202 $depthD = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/blank.gif','width="18" height="16"').' align="top" alt="" />';
203 if ($this->addSelfId) $this->ids[] = $pid;
204 $this->getTree($pid,999,$depthD);
205
206 $idH = array();
207 $idH[$pid]['uid'] = $pid;
208 if (count($this->buffer_idH)) $idH[$pid]['subrow'] = $this->buffer_idH;
209 $this->buffer_idH = $idH;
210
211 }
212
213 // Add tree:
214 $treeArr = array_merge($treeArr,$this->tree);
215
216 return $treeArr;
217 }
218 }
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 /**
234 * Main script class for the Import / Export facility
235 *
236 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
237 * @package TYPO3
238 * @subpackage tx_impexp
239 */
240 class SC_mod_tools_log_index extends t3lib_SCbase {
241
242 var $pageinfo; // array containing the current page.
243
244 /**
245 * Main module function
246 *
247 * @return void
248 */
249 function main() {
250 // Start document template object:
251 $this->doc = t3lib_div::makeInstance('template');
252 $this->doc->backPath = $GLOBALS['BACK_PATH'];
253 $this->doc->bodyTagId = 'imp-exp-mod';
254 $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('impexp') . '/app/template.html');
255
256
257 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
258
259 // JavaScript
260 $this->doc->JScode = $this->doc->wrapScriptTags('
261 script_ended = 0;
262 function jumpToUrl(URL) { //
263 window.location.href = URL;
264 }
265 ');
266
267 // Setting up the context sensitive menu:
268 $this->doc->getContextMenuCode();
269
270 $this->doc->postCode = $this->doc->wrapScriptTags('
271 script_ended = 1;
272 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
273 ');
274 $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.'" />';
275
276 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('title'));
277 $this->content.= $this->doc->spacer(5);
278
279 // Input data grabbed:
280 $inData = t3lib_div::_GP('tx_impexp');
281
282 $this->checkUpload();
283
284 switch((string)$inData['action']) {
285 case 'export':
286
287 // Finally: If upload went well, set the new file as the thumbnail in the $inData array:
288 if (is_object($this->fileProcessor) && $this->fileProcessor->internalUploadMap[1]) {
289 $inData['meta']['thumbnail'] = md5($this->fileProcessor->internalUploadMap[1]);
290 }
291
292 // Call export interface
293 $this->exportData($inData);
294 break;
295 case 'import':
296
297 // Finally: If upload went well, set the new file as the import file:
298 if (is_object($this->fileProcessor) && $this->fileProcessor->internalUploadMap[1]) {
299 $fI = pathinfo($this->fileProcessor->internalUploadMap[1]);
300 if (t3lib_div::inList('t3d,xml',strtolower($fI['extension']))) { // Only allowed extensions....
301 $inData['file'] = $this->fileProcessor->internalUploadMap[1];
302 }
303 }
304
305 // Call import interface:
306 $this->importData($inData);
307 break;
308 }
309
310 // Setting up the buttons and markers for docheader
311 $docHeaderButtons = $this->getButtons();
312 $markers['CONTENT'] = $this->content;
313
314 // Build the <body> for the module
315 $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
316 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
317 $this->content.= $this->doc->endPage();
318 $this->content = $this->doc->insertStylesAndJS($this->content);
319 }
320
321 /**
322 * Print the content
323 *
324 * @return void
325 */
326 function printContent() {
327 echo $this->content;
328 }
329
330 /**
331 * Create the panel of buttons for submitting the form or otherwise perform operations.
332 *
333 * @return array all available buttons as an associated array
334 */
335 protected function getButtons() {
336 $buttons = array(
337 'view' => '',
338 'record_list' => '',
339 'shortcut' => ''
340 );
341
342 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
343 $buttons['shortcut'] = $this->doc->makeShortcutIcon('tx_impexp', '', $this->MCONF['name']);
344 }
345
346 // Input data grabbed:
347 $inData = t3lib_div::_GP('tx_impexp');
348 if((string)$inData['action'] == 'import') {
349 if (($this->id && is_array($this->pageinfo)) || ($GLOBALS['BE_USER']->user['admin'] && !$this->id)) {
350 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
351 // View
352 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->pageinfo['uid'], $this->doc->backPath, t3lib_BEfunc::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage', TRUE) . '">' .
353 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
354 '</a>';
355
356 // Record list
357 // If access to Web>List for user, then link to that module.
358 $buttons['record_list'] = t3lib_BEfunc::getListViewLink(
359 array(
360 'id' => $this->pageinfo['uid'],
361 'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
362 ),
363 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
364 );
365 }
366 }
367 }
368
369 return $buttons;
370 }
371
372
373
374
375
376 /**************************
377 *
378 * EXPORT FUNCTIONS
379 *
380 **************************/
381
382 /**
383 * Export part of module
384 *
385 * @param array Content of POST VAR tx_impexp[]..
386 * @return void Setting content in $this->content
387 */
388 function exportData($inData) {
389 // BUILDING EXPORT DATA:
390
391 // Processing of InData array values:
392 $inData['pagetree']['maxNumber'] = t3lib_utility_Math::forceIntegerInRange($inData['pagetree']['maxNumber'],1,10000,100);
393 $inData['listCfg']['maxNumber'] = t3lib_utility_Math::forceIntegerInRange($inData['listCfg']['maxNumber'],1,10000,100);
394 $inData['maxFileSize'] = t3lib_utility_Math::forceIntegerInRange($inData['maxFileSize'],1,10000,1000);
395 $inData['filename'] = trim(preg_replace('/[^[:alnum:]._-]*/','',preg_replace('/\.(t3d|xml)$/','',$inData['filename'])));
396 if (strlen($inData['filename'])) {
397 $inData['filename'].= $inData['filetype']=='xml' ? '.xml' : '.t3d';
398 }
399
400 // Set exclude fields in export object:
401 if (!is_array($inData['exclude'])) {
402 $inData['exclude'] = array();
403 }
404
405
406 // Saving/Loading/Deleting presets:
407 $this->processPresets($inData);
408
409 // Create export object and configure it:
410 $this->export = t3lib_div::makeInstance('tx_impexp');
411 $this->export->init(0,'export');
412 $this->export->setCharset($GLOBALS['LANG']->charSet);
413
414 $this->export->maxFileSize = $inData['maxFileSize']*1024;
415 $this->export->excludeMap = (array)$inData['exclude'];
416 $this->export->softrefCfg = (array)$inData['softrefCfg'];
417 $this->export->extensionDependencies = (array)$inData['extension_dep'];
418 $this->export->showStaticRelations = $inData['showStaticRelations'];
419
420 $this->export->includeExtFileResources = !$inData['excludeHTMLfileResources'];
421
422 // Static tables:
423 if (is_array($inData['external_static']['tables'])) {
424 $this->export->relStaticTables = $inData['external_static']['tables'];
425 }
426
427 // Configure which tables external relations are included for:
428 if (is_array($inData['external_ref']['tables'])) {
429 $this->export->relOnlyTables = $inData['external_ref']['tables'];
430 }
431 $this->export->setHeaderBasics();
432
433 // Meta data setting:
434 $this->export->setMetaData(
435 $inData['meta']['title'],
436 $inData['meta']['description'],
437 $inData['meta']['notes'],
438 $GLOBALS['BE_USER']->user['username'],
439 $GLOBALS['BE_USER']->user['realName'],
440 $GLOBALS['BE_USER']->user['email']
441 );
442 if ($inData['meta']['thumbnail']) {
443 $tempDir = $this->userTempFolder();
444 if ($tempDir) {
445 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
446 $theThumb = $thumbnails[$inData['meta']['thumbnail']];
447 if ($theThumb) {
448 $this->export->addThumbnail($theThumb);
449 }
450 }
451 }
452
453
454 // Configure which records to export
455 if (is_array($inData['record'])) {
456 foreach($inData['record'] as $ref) {
457 $rParts = explode(':',$ref);
458 $this->export->export_addRecord($rParts[0],t3lib_BEfunc::getRecord($rParts[0],$rParts[1]));
459 }
460 }
461
462 // Configure which tables to export
463 if (is_array($inData['list'])) {
464 foreach($inData['list'] as $ref) {
465 $rParts = explode(':',$ref);
466 if ($GLOBALS['BE_USER']->check('tables_select',$rParts[0])) {
467 $res = $this->exec_listQueryPid($rParts[0],$rParts[1],t3lib_utility_Math::forceIntegerInRange($inData['listCfg']['maxNumber'],1));
468 while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
469 $this->export->export_addRecord($rParts[0],$subTrow);
470 }
471 }
472 }
473 }
474
475 // Pagetree
476 if (isset($inData['pagetree']['id'])) {
477 if ($inData['pagetree']['levels']==-1) { // Based on click-expandable tree
478 $pagetree = t3lib_div::makeInstance('localPageTree');
479
480 $tree = $pagetree->ext_tree($inData['pagetree']['id'],$this->filterPageIds($this->export->excludeMap));
481 $this->treeHTML = $pagetree->printTree($tree);
482
483 $idH = $pagetree->buffer_idH;
484 } elseif ($inData['pagetree']['levels']==-2) { // Only tables on page
485 $this->addRecordsForPid($inData['pagetree']['id'],$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
486 } else { // Based on depth
487 // Drawing tree:
488 // If the ID is zero, export root
489 if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin()) {
490 $sPage = array(
491 'uid' => 0,
492 'title' => 'ROOT'
493 );
494 } else {
495 $sPage = t3lib_BEfunc::getRecordWSOL('pages',$inData['pagetree']['id'],'*',' AND '.$this->perms_clause);
496 }
497 if (is_array($sPage)) {
498 $pid = $inData['pagetree']['id'];
499 $tree = t3lib_div::makeInstance('t3lib_pageTree');
500 $tree->init('AND '.$this->perms_clause.$this->filterPageIds($this->export->excludeMap));
501
502 $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $sPage);
503 $tree->tree[] = Array('row'=>$sPage,'HTML'=>$HTML);
504 $tree->buffer_idH = array();
505 if ($inData['pagetree']['levels']>0) {
506 $tree->getTree($pid,$inData['pagetree']['levels'],'');
507 }
508
509 $idH = array();
510 $idH[$pid]['uid'] = $pid;
511 if (count($tree->buffer_idH)) {
512 $idH[$pid]['subrow'] = $tree->buffer_idH;
513 }
514
515 $pagetree = t3lib_div::makeInstance('localPageTree');
516 $this->treeHTML = $pagetree->printTree($tree->tree);
517 }
518 }
519 // 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...)
520 if (is_array($idH)) {
521 $flatList = $this->export->setPageTree($idH); // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...)
522 foreach ($flatList as $k => $value) {
523 $this->export->export_addRecord('pages',t3lib_BEfunc::getRecord('pages',$k));
524 $this->addRecordsForPid($k,$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
525 }
526 }
527 }
528
529 // After adding ALL records we set relations:
530 for($a=0;$a<10;$a++) {
531 $addR = $this->export->export_addDBRelations($a);
532 if (!count($addR)) {
533 break;
534 }
535 }
536
537 // Finally files are added:
538 $this->export->export_addFilesFromRelations(); // MUST be after the DBrelations are set so that files from ALL added records are included!
539 // If the download button is clicked, return file
540 if ($inData['download_export'] || $inData['save_export']) {
541 switch((string)$inData['filetype']) {
542 case 'xml':
543 $out = $this->export->compileMemoryToFileContent('xml');
544 $fExt = '.xml';
545 break;
546 case 't3d':
547 $this->export->dontCompress = 1;
548 default:
549 $out = $this->export->compileMemoryToFileContent();
550 $fExt = ($this->export->doOutputCompress()?'-z':'').'.t3d';
551 break;
552 }
553
554 // Filename:
555 $dlFile = $inData['filename'] ? $inData['filename'] : 'T3D_'.substr(preg_replace('/[^[:alnum:]_]/','-',$inData['download_export_name']),0,20).'_'.date('d-m-H-i-s').$fExt;
556
557 // Export for download:
558 if ($inData['download_export']) {
559 $mimeType = 'application/octet-stream';
560 Header('Content-Type: '.$mimeType);
561 Header('Content-Length: '.strlen($out));
562 Header('Content-Disposition: attachment; filename='.basename($dlFile));
563
564 echo $out;
565 exit;
566 }
567
568 // Export by saving:
569 if ($inData['save_export']) {
570 $savePath = $this->userSaveFolder();
571 $fullName = $savePath.$dlFile;
572
573 if (t3lib_div::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && t3lib_div::isAllowedAbsPath($fullName)) {
574 t3lib_div::writeFile($fullName, $out);
575 $this->content .= $this->doc->section(
576 $GLOBALS['LANG']->getLL('exportdata_savedFile'),
577 sprintf(
578 $GLOBALS['LANG']->getLL('exportdata_savedInSBytes', 1),
579 substr($savePath . $dlFile, strlen(PATH_site)),
580 t3lib_div::formatSize(strlen($out))),
581 0,
582 1
583 );
584 } else {
585 $this->content .= $this->doc->section(
586 $GLOBALS['LANG']->getLL('exportdata_problemsSavingFile'),
587 sprintf($GLOBALS['LANG']->getLL('exportdata_badPathS', 1), $fullName),
588 0,
589 1,
590 2
591 );
592 }
593 }
594 }
595
596
597 // OUTPUT to BROWSER:
598 // Now, if we didn't make download file, show configuration form based on export:
599 $menuItems = array();
600
601 // Export configuration
602 $row = array();
603 $this->makeConfigurationForm($inData, $row);
604 $menuItems[] = array(
605 'label' => $GLOBALS['LANG']->getLL('tableselec_configuration'),
606 'content' => '
607 <table border="0" cellpadding="1" cellspacing="1">
608 '.implode('
609 ',$row).'
610 </table>
611 '
612 );
613
614 // File options
615 $row = array();
616 $this->makeSaveForm($inData, $row);
617 $menuItems[] = array(
618 'label' => $GLOBALS['LANG']->getLL('exportdata_filePreset'),
619 'content' => '
620 <table border="0" cellpadding="1" cellspacing="1">
621 '.implode('
622 ',$row).'
623 </table>
624 '
625 );
626
627 // File options
628 $row = array();
629 $this->makeAdvancedOptionsForm($inData, $row);
630 $menuItems[] = array(
631 'label' => $GLOBALS['LANG']->getLL('exportdata_advancedOptions'),
632 'content' => '
633 <table border="0" cellpadding="1" cellspacing="1">
634 '.implode('
635 ',$row).'
636 </table>
637 '
638 );
639
640 // Generate overview:
641 $overViewContent = $this->export->displayContentOverview();
642
643 // Print errors that might be:
644 $errors = $this->export->printErrorLog();
645 $menuItems[] = array(
646 'label' => $GLOBALS['LANG']->getLL('exportdata_messages'),
647 'content' => $errors,
648 'stateIcon' => $errors ? 2 : 0
649 );
650
651 // Add hidden fields and create tabs:
652 $content = $this->doc->getDynTabMenu($menuItems,'tx_impexp_export',-1);
653 $content.= '<input type="hidden" name="tx_impexp[action]" value="export" />';
654 $this->content.= $this->doc->section('',$content,0,1);
655
656 // Output Overview:
657 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('execlistqu_structureToBeExported'), $overViewContent, 0, 1);
658
659 }
660
661 /**
662 * Adds records to the export object for a specific page id.
663 *
664 * @param integer Page id for which to select records to add
665 * @param array Array of table names to select from
666 * @param integer Max amount of records to select
667 * @return void
668 */
669 function addRecordsForPid($k, $tables, $maxNumber) {
670 if (is_array($tables)) {
671 foreach ($GLOBALS['TCA'] as $table => $value) {
672 if ($table!='pages' && (in_array($table,$tables) || in_array('_ALL',$tables))) {
673 if ($GLOBALS['BE_USER']->check('tables_select',$table) && !$GLOBALS['TCA'][$table]['ctrl']['is_static']) {
674 $res = $this->exec_listQueryPid($table,$k,t3lib_utility_Math::forceIntegerInRange($maxNumber,1));
675 while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
676 $this->export->export_addRecord($table,$subTrow);
677 }
678 }
679 }
680 }
681 }
682 }
683
684 /**
685 * Selects records from table / pid
686 *
687 * @param string Table to select from
688 * @param integer Page ID to select from
689 * @param integer Max number of records to select
690 * @return pointer SQL resource pointer
691 */
692 function exec_listQueryPid($table,$pid,$limit) {
693 $orderBy = ($GLOBALS['TCA'][$table]['ctrl']['sortby']
694 ? 'ORDER BY ' . $GLOBALS['TCA'][$table]['ctrl']['sortby']
695 : $GLOBALS['TCA'][$table]['ctrl']['default_sortby']);
696 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
697 '*',
698 $table,
699 'pid='.intval($pid).
700 t3lib_BEfunc::deleteClause($table).
701 t3lib_BEfunc::versioningPlaceholderClause($table),
702 '',
703 $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
704 $limit
705 );
706
707 // Warning about hitting limit:
708 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == $limit) {
709 $this->content .= $this->doc->section(
710 $GLOBALS['LANG']->getLL('execlistqu_maxNumberLimit'),
711 sprintf($GLOBALS['LANG']->getLL('makeconfig_anSqlQueryReturned', 1), $limit),
712 0,
713 1,
714 2
715 );
716 }
717
718 return $res;
719 }
720
721 /**
722 * Create configuration form
723 *
724 * @param array Form configurat data
725 * @param array Table row accumulation variable. This is filled with table rows.
726 * @return void Sets content in $this->content
727 */
728 function makeConfigurationForm($inData, &$row) {
729 global $LANG;
730
731 $nameSuggestion = '';
732
733 // Page tree export options:
734 if (isset($inData['pagetree']['id'])) {
735
736 $nameSuggestion.= 'tree_PID'.$inData['pagetree']['id'].'_L'.$inData['pagetree']['levels'];
737
738 $row[] = '
739 <tr class="tableheader bgColor5">
740 <td colspan="2">'.$LANG->getLL('makeconfig_exportPagetreeConfiguration',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeCfg', $GLOBALS['BACK_PATH'],'').'</td>
741 </tr>';
742
743 $row[] = '
744 <tr class="bgColor4">
745 <td><strong>'.$LANG->getLL('makeconfig_pageId',1).'</strong></td>
746 <td>'.htmlspecialchars($inData['pagetree']['id']).
747 '<input type="hidden" value="'.htmlspecialchars($inData['pagetree']['id']).'" name="tx_impexp[pagetree][id]" /></td>
748 </tr>';
749
750 $row[] = '
751 <tr class="bgColor4">
752 <td><strong>'.$LANG->getLL('makeconfig_tree',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeDisplay', $GLOBALS['BACK_PATH'],'').'</td>
753 <td>'.($this->treeHTML ? $this->treeHTML : $LANG->getLL('makeconfig_noTreeExportedOnly',1)).'</td>
754 </tr>';
755
756 $opt = array(
757 '-2' => $LANG->getLL('makeconfig_tablesOnThisPage'),
758 '-1' => $LANG->getLL('makeconfig_expandedTree'),
759 '0' => $LANG->getLL('makeconfig_onlyThisPage'),
760 '1' => $LANG->getLL('makeconfig_1Level'),
761 '2' => $LANG->getLL('makeconfig_2Levels'),
762 '3' => $LANG->getLL('makeconfig_3Levels'),
763 '4' => $LANG->getLL('makeconfig_4Levels'),
764 '999' => $LANG->getLL('makeconfig_infinite')
765 );
766 $row[] = '
767 <tr class="bgColor4">
768 <td><strong>'.$LANG->getLL('makeconfig_levels',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeMode', $GLOBALS['BACK_PATH'],'').'</td>
769 <td>'.$this->renderSelectBox('tx_impexp[pagetree][levels]',$inData['pagetree']['levels'],$opt).'</td>
770 </tr>';
771
772 $row[] = '
773 <tr class="bgColor4">
774 <td><strong>'.$LANG->getLL('makeconfig_includeTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeRecordLimit', $GLOBALS['BACK_PATH'],'').'</td>
775 <td>'.$this->tableSelector('tx_impexp[pagetree][tables]',$inData['pagetree']['tables'],'pages').'<br/>
776 '.$LANG->getLL('makeconfig_maxNumberOfRecords',1).'<br/>
777 <input type="text" name="tx_impexp[pagetree][maxNumber]" value="'.htmlspecialchars($inData['pagetree']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/>
778 </td>
779 </tr>';
780 }
781
782 // Single record export:
783 if (is_array($inData['record'])) {
784 $row[] = '
785 <tr class="tableheader bgColor5">
786 <td colspan="2">'.$LANG->getLL('makeconfig_exportSingleRecord',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'singleRecord', $GLOBALS['BACK_PATH'],'').'</td>
787 </tr>';
788 foreach($inData['record'] as $ref) {
789 $rParts = explode(':', $ref);
790 $tName = $rParts[0];
791 $rUid = $rParts[1];
792 $nameSuggestion.= $tName.'_'.$rUid;
793 $rec = t3lib_BEfunc::getRecordWSOL($tName,$rUid);
794
795 $row[] = '
796 <tr class="bgColor4">
797 <td><strong>'.$LANG->getLL('makeconfig_record',1).'</strong></td>
798 <td>' . t3lib_iconworks::getSpriteIconForRecord($tName, $rec) .
799 t3lib_BEfunc::getRecordTitle($tName,$rec,TRUE).
800 '<input type="hidden" name="tx_impexp[record][]" value="'.htmlspecialchars($tName.':'.$rUid).'" /></td>
801 </tr>';
802 }
803 }
804
805 // Single tables/pids:
806 if (is_array($inData['list'])) {
807 $row[] = '
808 <tr class="tableheader bgColor5">
809 <td colspan="2">'.$LANG->getLL('makeconfig_exportTablesFromPages',1).'</td>
810 </tr>';
811
812 $tblList = '';
813 foreach($inData['list'] as $ref) {
814 $rParts = explode(':', $ref);
815 $tName = $rParts[0];
816
817 if ($GLOBALS['BE_USER']->check('tables_select',$tName)) {
818 $rec = t3lib_BEfunc::getRecordWSOL('pages', $rParts[1]);
819 $tblList .= 'Table "' . $tName . '" from ' . t3lib_iconworks::getSpriteIconForRecord('pages', $rec) .
820 t3lib_BEfunc::getRecordTitle('pages', $rec, TRUE).
821 '<input type="hidden" name="tx_impexp[list][]" value="'.htmlspecialchars($ref).'" /><br/>';
822 }
823 }
824 $row[] = '
825 <tr class="bgColor4">
826 <td><strong>'.$LANG->getLL('makeconfig_tablePids',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableList', $GLOBALS['BACK_PATH'],'').'</td>
827 <td>'.$tblList.'</td>
828 </tr>';
829
830 $row[] = '
831 <tr class="bgColor4">
832 <td><strong>'.$LANG->getLL('makeconfig_maxNumberOfRecords',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableListMaxNumber', $GLOBALS['BACK_PATH'],'').'</strong></td>
833 <td>
834 <input type="text" name="tx_impexp[listCfg][maxNumber]" value="'.htmlspecialchars($inData['listCfg']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/>
835 </td>
836 </tr>';
837 }
838
839
840 $row[] = '
841 <tr class="tableheader bgColor5">
842 <td colspan="2">'.$LANG->getLL('makeconfig_relationsAndExclusions',1).'</td>
843 </tr>';
844
845 // Add relation selector:
846 $row[] = '
847 <tr class="bgColor4">
848 <td><strong>'.$LANG->getLL('makeconfig_includeRelationsToTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'inclRelations', $GLOBALS['BACK_PATH'],'').'</td>
849 <td>'.$this->tableSelector('tx_impexp[external_ref][tables]',$inData['external_ref']['tables']).'</td>
850 </tr>';
851
852 // Add static relation selector:
853 $row[] = '
854 <tr class="bgColor4">
855 <td><strong>'.$LANG->getLL('makeconfig_useStaticRelationsFor',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'staticRelations', $GLOBALS['BACK_PATH'],'').'</td>
856 <td>'.$this->tableSelector('tx_impexp[external_static][tables]',$inData['external_static']['tables']).'<br/>
857 <label for="checkShowStaticRelations">'.$LANG->getLL('makeconfig_showStaticRelations',1).'</label> <input type="checkbox" name="tx_impexp[showStaticRelations]" id="checkShowStaticRelations" value="1"'.($inData['showStaticRelations'] ? ' checked="checked"' : '').' />
858 </td>
859 </tr>';
860
861 // Exclude:
862 $excludeHiddenFields = '';
863 if (is_array($inData['exclude'])) {
864 foreach($inData['exclude'] as $key => $value) {
865 $excludeHiddenFields.= '<input type="hidden" name="tx_impexp[exclude]['.$key.']" value="1" />';
866 }
867 }
868 $row[] = '
869 <tr class="bgColor4">
870 <td><strong>'.$LANG->getLL('makeconfig_excludeElements',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'excludedElements', $GLOBALS['BACK_PATH'],'').'</td>
871 <td>'.$excludeHiddenFields.'
872 '.(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)).'
873 </td>
874 </tr>';
875
876
877 // Add buttons:
878 $row[] = '
879 <tr class="bgColor4">
880 <td>&nbsp;</td>
881 <td>
882 <input type="submit" value="'.$LANG->getLL('makeadvanc_update',1).'" />
883 <input type="hidden" name="tx_impexp[download_export_name]" value="'.substr($nameSuggestion,0,30).'" />
884 </td>
885 </tr>';
886
887 }
888
889 /**
890 * Create advanced options form
891 *
892 * @param array Form configurat data
893 * @param array Table row accumulation variable. This is filled with table rows.
894 * @return void Sets content in $this->content
895 */
896 function makeAdvancedOptionsForm($inData, &$row) {
897 global $LANG;
898
899 // Soft references
900 $row[] = '
901 <tr class="tableheader bgColor5">
902 <td colspan="2">'.$LANG->getLL('makeadvanc_softReferences',1).'</td>
903 </tr>';
904 $row[] = '
905 <tr class="bgColor4">
906 <td><label for="checkExcludeHTMLfileResources"><strong>'.$LANG->getLL('makeadvanc_excludeHtmlCssFile',1).'</strong></label>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'htmlCssResources', $GLOBALS['BACK_PATH'],'').'</td>
907 <td><input type="checkbox" name="tx_impexp[excludeHTMLfileResources]" id="checkExcludeHTMLfileResources" value="1"'.($inData['excludeHTMLfileResources'] ? ' checked="checked"' : '').' /></td>
908 </tr>';
909
910
911 // Extensions
912 $row[] = '
913 <tr class="tableheader bgColor5">
914 <td colspan="2">'.$LANG->getLL('makeadvanc_extensionDependencies',1).'</td>
915 </tr>';
916 $row[] = '
917 <tr class="bgColor4">
918 <td><strong>'.$LANG->getLL('makeadvanc_selectExtensionsThatThe',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'extensionDependencies', $GLOBALS['BACK_PATH'],'').'</td>
919 <td>'.$this->extensionSelector('tx_impexp[extension_dep]',$inData['extension_dep']).'</td>
920 </tr>';
921
922
923
924 // Add buttons:
925 $row[] = '
926 <tr class="bgColor4">
927 <td>&nbsp;</td>
928 <td>
929 <input type="submit" value="'.$LANG->getLL('makesavefo_update',1).'" />
930 <input type="hidden" name="tx_impexp[download_export_name]" value="'.substr($nameSuggestion,0,30).'" />
931 </td>
932 </tr>';
933
934
935 }
936
937 /**
938 * Create configuration form
939 *
940 * @param array Form configurat data
941 * @param array Table row accumulation variable. This is filled with table rows.
942 * @return void Sets content in $this->content
943 */
944 function makeSaveForm($inData, &$row) {
945 global $LANG;
946
947 // Presets:
948 $row[] = '
949 <tr class="tableheader bgColor5">
950 <td colspan="2">'.$LANG->getLL('makesavefo_presets',1).'</td>
951 </tr>';
952
953 $opt = array('');
954 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
955 '*',
956 'tx_impexp_presets',
957 '(public>0 OR user_uid='.intval($GLOBALS['BE_USER']->user['uid']).')'.
958 ($inData['pagetree']['id'] ? ' AND (item_uid='.intval($inData['pagetree']['id']).' OR item_uid=0)' : '')
959
960 );
961 if (is_array($presets)) {
962 foreach($presets as $presetCfg) {
963 $opt[$presetCfg['uid']] = $presetCfg['title'].' ['.$presetCfg['uid'].']'.
964 ($presetCfg['public'] ? ' [Public]' : '').
965 ($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? ' [Own]' : '');
966 }
967 }
968
969 $row[] = '
970 <tr class="bgColor4">
971 <td><strong>'.$LANG->getLL('makesavefo_presets',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'presets', $GLOBALS['BACK_PATH'],'').'</td>
972 <td>
973 '.$LANG->getLL('makesavefo_selectPreset',1).'<br/>
974 '.$this->renderSelectBox('preset[select]','',$opt).'
975 <br/>
976 <input type="submit" value="'.$LANG->getLL('makesavefo_load',1).'" name="preset[load]" />
977 <input type="submit" value="'.$LANG->getLL('makesavefo_save',1).'" name="preset[save]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
978 <input type="submit" value="'.$LANG->getLL('makesavefo_delete',1).'" name="preset[delete]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
979 <input type="submit" value="'.$LANG->getLL('makesavefo_merge',1).'" name="preset[merge]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
980 <br/>
981 '.$LANG->getLL('makesavefo_titleOfNewPreset',1).'
982 <input type="text" name="tx_impexp[preset][title]" value="'.htmlspecialchars($inData['preset']['title']).'"'.$this->doc->formWidth(30).' /><br/>
983 <label for="checkPresetPublic">'.$LANG->getLL('makesavefo_public',1).'</label>
984 <input type="checkbox" name="tx_impexp[preset][public]" id="checkPresetPublic" value="1"'.($inData['preset']['public'] ? ' checked="checked"' : '').' /><br/>
985 </td>
986 </tr>';
987
988 // Output options:
989 $row[] = '
990 <tr class="tableheader bgColor5">
991 <td colspan="2">'.$LANG->getLL('makesavefo_outputOptions',1).'</td>
992 </tr>';
993
994 // Meta data:
995 $tempDir = $this->userTempFolder();
996 if ($tempDir) {
997 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg');
998 array_unshift($thumbnails,'');
999 } else $thumbnails = FALSE;
1000 $row[] = '
1001 <tr class="bgColor4">
1002 <td><strong>'.$LANG->getLL('makesavefo_metaData',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'metadata', $GLOBALS['BACK_PATH'],'').'</td>
1003 <td>
1004 '.$LANG->getLL('makesavefo_title',1).' <br/>
1005 <input type="text" name="tx_impexp[meta][title]" value="'.htmlspecialchars($inData['meta']['title']).'"'.$this->doc->formWidth(30).' /><br/>
1006 '.$LANG->getLL('makesavefo_description',1).' <br/>
1007 <input type="text" name="tx_impexp[meta][description]" value="'.htmlspecialchars($inData['meta']['description']).'"'.$this->doc->formWidth(30).' /><br/>
1008 '.$LANG->getLL('makesavefo_notes',1).' <br/>
1009 <textarea name="tx_impexp[meta][notes]"'.$this->doc->formWidth(30,1).'>'.t3lib_div::formatForTextarea($inData['meta']['notes']).'</textarea><br/>
1010 '.(is_array($thumbnails) ? '
1011 '.$LANG->getLL('makesavefo_thumbnail',1).'<br/>
1012 '.$this->renderSelectBox('tx_impexp[meta][thumbnail]',$inData['meta']['thumbnail'],$thumbnails).'<br/>
1013 '.($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/>' : '').'
1014 '.$LANG->getLL('makesavefo_uploadThumbnail',1).'<br/>
1015 <input type="file" name="upload_1" '.$this->doc->formWidth(30).' size="30" /><br/>
1016 <input type="hidden" name="file[upload][1][target]" value="'.htmlspecialchars($tempDir).'" />
1017 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
1018 ' : '').'
1019 </td>
1020 </tr>';
1021
1022 // Add file options:
1023 $savePath = $this->userSaveFolder();
1024 $opt = array();
1025 if ($this->export->compress) {
1026 $opt['t3d_compressed'] = $LANG->getLL('makesavefo_t3dFileCompressed');
1027 }
1028 $opt['t3d'] = $LANG->getLL('makesavefo_t3dFile');
1029 $opt['xml'] = $LANG->getLL('makesavefo_xml');
1030 $row[] = '
1031 <tr class="bgColor4">
1032 <td><strong>'.$LANG->getLL('makesavefo_fileFormat',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'fileFormat', $GLOBALS['BACK_PATH'],'').'</td>
1033 <td>'.$this->renderSelectBox('tx_impexp[filetype]',$inData['filetype'],$opt).'<br/>
1034 '.$LANG->getLL('makesavefo_maxSizeOfFiles',1).'<br/>
1035 <input type="text" name="tx_impexp[maxFileSize]" value="'.htmlspecialchars($inData['maxFileSize']).'"'.$this->doc->formWidth(10).' /><br/>
1036 '.($savePath ? sprintf($LANG->getLL('makesavefo_filenameSavedInS',1),substr($savePath,strlen(PATH_site))).'<br/>
1037 <input type="text" name="tx_impexp[filename]" value="'.htmlspecialchars($inData['filename']).'"'.$this->doc->formWidth(30).' /><br/>' : '').'
1038 </td>
1039 </tr>';
1040
1041
1042 // Add buttons:
1043 $row[] = '
1044 <tr class="bgColor4">
1045 <td>&nbsp;</td>
1046 <td><input type="submit" value="'.$LANG->getLL('makesavefo_update',1).'" /> - <input type="submit" value="'.$LANG->getLL('makesavefo_downloadExport',1).'" name="tx_impexp[download_export]" />'.
1047 ($savePath ? ' - <input type="submit" value="'.$LANG->getLL('importdata_saveToFilename',1).'" name="tx_impexp[save_export]" />' : '').'</td>
1048 </tr>';
1049 }
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063 /**************************
1064 *
1065 * IMPORT FUNCTIONS
1066 *
1067 **************************/
1068
1069 /**
1070 * Import part of module
1071 *
1072 * @param array Content of POST VAR tx_impexp[]..
1073 * @return void Setting content in $this->content
1074 */
1075 function importData($inData) {
1076 global $LANG;
1077
1078 $access = is_array($this->pageinfo) ? 1 : 0;
1079
1080 if (($this->id && $access) || ($GLOBALS['BE_USER']->user['admin'] && !$this->id)) {
1081 if ($GLOBALS['BE_USER']->user['admin'] && !$this->id) {
1082 $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0);
1083 }
1084
1085 if ($inData['new_import']) {
1086 unset($inData['import_mode']);
1087 }
1088
1089 /** @var $import tx_impexp */
1090 $import = t3lib_div::makeInstance('tx_impexp');
1091 $import->init(0,'import');
1092 $import->update = $inData['do_update'];
1093 $import->import_mode = $inData['import_mode'];
1094 $import->enableLogging = $inData['enableLogging'];
1095 $import->global_ignore_pid = $inData['global_ignore_pid'];
1096 $import->force_all_UIDS = $inData['force_all_UIDS'];
1097 $import->showDiff = !$inData['notShowDiff'];
1098 $import->allowPHPScripts = $inData['allowPHPScripts'];
1099 $import->softrefInputValues = $inData['softrefInputValues'];
1100
1101
1102 // OUTPUT creation:
1103 $menuItems = array();
1104
1105 // Make input selector:
1106 $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; // must have trailing slash.
1107 $filesInDir = t3lib_div::getFilesInDir(PATH_site.$path, 't3d,xml', 1, 1);
1108
1109 $userPath = $this->userSaveFolder(); //Files from User-Dir
1110 $filesInUserDir = t3lib_div::getFilesInDir($userPath, 't3d,xml', 1, 1);
1111
1112 $filesInDir = array_merge($filesInUserDir, $filesInDir);
1113
1114 if (is_dir(PATH_site.$path.'export/')) {
1115 $filesInDir = array_merge($filesInDir, t3lib_div::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1));
1116 }
1117 $tempFolder = $this->userTempFolder();
1118 if ($tempFolder) {
1119 $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder, 't3d,xml', 1, 1);
1120 $filesInDir = array_merge($filesInDir, $temp_filesInDir);
1121 }
1122
1123 // Configuration
1124 $row = array();
1125 $opt = array('');
1126 foreach($filesInDir as $file) {
1127 $opt[$file] = substr($file,strlen(PATH_site));
1128 }
1129
1130 $row[] = '<tr class="bgColor5">
1131 <td colspan="2"><strong>'.$LANG->getLL('importdata_selectFileToImport',1).'</strong></td>
1132 </tr>';
1133
1134 $row[] = '<tr class="bgColor4">
1135 <td><strong>'.$LANG->getLL('importdata_file',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'],'').'</td>
1136 <td>'.
1137 $this->renderSelectBox('tx_impexp[file]',$inData['file'],$opt).'<br />'.sprintf($LANG->getLL('importdata_fromPathS',1),$path).
1138 (!$import->compress ? '<br /><span class="typo3-red">'.$LANG->getLL('importdata_noteNoDecompressorAvailable',1).'</span>':'').
1139 '</td>
1140 </tr>';
1141
1142 $row[] = '<tr class="bgColor5">
1143 <td colspan="2"><strong>'.$LANG->getLL('importdata_importOptions',1).'</strong></td>
1144 </tr>';
1145
1146 $row[] = '<tr class="bgColor4">
1147 <td><strong>'.$LANG->getLL('importdata_update',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'],'').'</td>
1148 <td>
1149 <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"'.($inData['do_update'] ? ' checked="checked"' : '').' />
1150 <label for="checkDo_update">'.$LANG->getLL('importdata_updateRecords',1).'</label><br/>
1151 <em>('.$LANG->getLL('importdata_thisOptionRequiresThat',1).')</em>'.
1152 ($inData['do_update'] ?
1153 ' <hr/>
1154 <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"'.($inData['global_ignore_pid'] ? ' checked="checked"' : '').' />
1155 <label for="checkGlobal_ignore_pid">'.$LANG->getLL('importdata_ignorePidDifferencesGlobally',1).'</label><br/>
1156 <em>('.$LANG->getLL('importdata_ifYouSetThis',1).')</em>
1157 ' : ''
1158 ).'</td>
1159 </tr>';
1160
1161 $row[] = '<tr class="bgColor4">
1162 <td><strong>'.$LANG->getLL('importdata_options',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'],'').'</td>
1163 <td>
1164 <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"'.($inData['notShowDiff'] ? ' checked="checked"' : '').' />
1165 <label for="checkNotShowDiff">'.$LANG->getLL('importdata_doNotShowDifferences',1).'</label><br/>
1166 <em>('.$LANG->getLL('importdata_greenValuesAreFrom',1).')</em>
1167 <br/><br/>
1168
1169 '.($GLOBALS['BE_USER']->isAdmin() ? '
1170 <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"'.($inData['allowPHPScripts'] ? ' checked="checked"' : '').' />
1171 <label for="checkAllowPHPScripts">'.$LANG->getLL('importdata_allowToWriteBanned',1).'</label><br/>' : '').
1172
1173 (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? '
1174 <br/>
1175 <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"'.($inData['force_all_UIDS'] ? ' checked="checked"' : '').' />
1176 <label for="checkForce_all_UIDS"><span class="typo3-red">'.$LANG->getLL('importdata_force_all_UIDS',1).'</span></label><br/>
1177 <em>('.$LANG->getLL('importdata_force_all_UIDS_descr',1).')</em>' : '').
1178 '
1179 </td>
1180 </tr>';
1181
1182 $row[] = '<tr class="bgColor4">
1183 <td><strong>'.$LANG->getLL('importdata_action',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'],'').'</td>
1184 <td>'.
1185 (!$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).'" />').'
1186 <input type="hidden" name="tx_impexp[action]" value="import" /></td>
1187 </tr>';
1188
1189 $row[] = '<tr class="bgColor4">
1190 <td><strong>'.$LANG->getLL('importdata_enableLogging',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'],'').'</td>
1191 <td>
1192 <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"'.($inData['enableLogging'] ? ' checked="checked"' : '').' />
1193 <label for="checkEnableLogging">'.$LANG->getLL('importdata_writeIndividualDbActions',1).'</label><br/>
1194 <em>('.$LANG->getLL('importdata_thisIsDisabledBy',1).')</em>
1195 </td>
1196 </tr>';
1197
1198 $menuItems[] = array(
1199 'label' => $LANG->getLL('importdata_import',1),
1200 'content' => '
1201 <table border="0" cellpadding="1" cellspacing="1">
1202 '.implode('
1203 ',$row).'
1204 </table>
1205 '
1206 );
1207
1208 // Upload file:
1209 $tempFolder = $this->userTempFolder();
1210 if ($tempFolder) {
1211 $row = array();
1212
1213 $row[] = '<tr class="bgColor5">
1214 <td colspan="2"><strong>'.$LANG->getLL('importdata_uploadFileFromLocal',1).'</strong></td>
1215 </tr>';
1216
1217 $row[] = '<tr class="bgColor4">
1218 <td>'.$LANG->getLL('importdata_browse',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'],'').'</td>
1219 <td>
1220
1221 <input type="file" name="upload_1"'.$this->doc->formWidth(35).' size="40" />
1222 <input type="hidden" name="file[upload][1][target]" value="'.htmlspecialchars($tempFolder).'" />
1223 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
1224
1225 <input type="submit" name="_upload" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />
1226 <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>
1227 </td>
1228 </tr>';
1229
1230 if (t3lib_div::_POST('_upload')) {
1231 $row[] = '<tr class="bgColor4">
1232 <td>'.$LANG->getLL('importdata_uploadStatus',1).'</td>
1233 <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>
1234 </tr>';
1235 }
1236
1237 $menuItems[] = array(
1238 'label' => $LANG->getLL('importdata_upload'),
1239 'content' => '
1240 <table border="0" cellpadding="1" cellspacing="1">
1241 '.implode('
1242 ',$row).'
1243 </table>
1244 '
1245 );
1246 }
1247
1248
1249 // Perform import or preview depending:
1250 $overviewContent = '';
1251 $extensionInstallationMessage = '';
1252 $emURL = '';
1253 $inFile = t3lib_div::getFileAbsFileName($inData['file']);
1254 if ($inFile && @is_file($inFile)) {
1255 $trow = array();
1256 if ($import->loadFile($inFile,1)) {
1257
1258 // Check extension dependencies:
1259 $extKeysToInstall = array();
1260 if (is_array($import->dat['header']['extensionDependencies'])) {
1261 foreach($import->dat['header']['extensionDependencies'] as $extKey) {
1262 if (!t3lib_extMgm::isLoaded($extKey)) {
1263 $extKeysToInstall[] = $extKey;
1264 }
1265 }
1266 }
1267
1268 if (count($extKeysToInstall)) {
1269 $passParams = t3lib_div::_POST('tx_impexp');
1270 unset($passParams['import_mode']);
1271 unset($passParams['import_file']);
1272
1273 $thisScriptUrl = t3lib_div::getIndpEnv('REQUEST_URI').'?M=xMOD_tximpexp&id='.$this->id.t3lib_div::implodeArrayForUrl('tx_impexp',$passParams);
1274 $emURL = $this->doc->backPath . t3lib_extMgm::extRelPath('em') . 'mod1/index.php?CMD[requestInstallExtensions]=' .
1275 implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl);
1276 $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.';
1277 }
1278
1279 if ($inData['import_file']) {
1280 if (!count($extKeysToInstall)) {
1281 $import->importData($this->id);
1282 t3lib_BEfunc::setUpdateSignal('updatePageTree');
1283 } else {
1284 t3lib_utility_Http::redirect($emURL);
1285 }
1286 }
1287
1288 $import->display_import_pid_record = $this->pageinfo;
1289 $overviewContent = $import->displayContentOverview();
1290 }
1291
1292 // Meta data output:
1293 $trow[] = '<tr class="bgColor5">
1294 <td colspan="2"><strong>'.$LANG->getLL('importdata_metaData',1).'</strong></td>
1295 </tr>';
1296
1297 $opt = array('');
1298 foreach($filesInDir as $file) {
1299 $opt[$file] = substr($file,strlen(PATH_site));
1300 }
1301
1302 $trow[] = '<tr class="bgColor4">
1303 <td><strong>'.$LANG->getLL('importdata_title',1).'</strong></td>
1304 <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['title'])).'</td>
1305 </tr>';
1306
1307 $trow[] = '<tr class="bgColor4">
1308 <td><strong>'.$LANG->getLL('importdata_description',1).'</strong></td>
1309 <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['description'])).'</td>
1310 </tr>';
1311
1312 $trow[] = '<tr class="bgColor4">
1313 <td><strong>'.$LANG->getLL('importdata_notes',1).'</strong></td>
1314 <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])).'</td>
1315 </tr>';
1316
1317 $trow[] = '<tr class="bgColor4">
1318 <td><strong>'.$LANG->getLL('importdata_packager',1).'</strong></td>
1319 <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'].' ('.$import->dat['header']['meta']['packager_username'].')')).'<br/>
1320 '.$LANG->getLL('importdata_email',1).' '.$import->dat['header']['meta']['packager_email'].'</td>
1321 </tr>';
1322
1323 // Thumbnail icon:
1324 if (is_array($import->dat['header']['thumbnail'])) {
1325 $pI = pathinfo($import->dat['header']['thumbnail']['filename']);
1326 if (t3lib_div::inList('gif,jpg,png,jpeg',strtolower($pI['extension']))) {
1327
1328 // Construct filename and write it:
1329 $fileName = PATH_site.
1330 'typo3temp/importthumb.'.$pI['extension'];
1331 t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
1332
1333 // Check that the image really is an image and not a malicious PHP script...
1334 if (getimagesize($fileName)) {
1335 // Create icon tag:
1336 $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="" />';
1337
1338 $trow[] = '<tr class="bgColor4">
1339 <td><strong>'.$LANG->getLL('importdata_icon',1).'</strong></td>
1340 <td>'.$iconTag.'</td>
1341 </tr>';
1342 } else {
1343 t3lib_div::unlink_tempfile($fileName);
1344 }
1345 }
1346 }
1347
1348 $menuItems[] = array(
1349 'label' => $LANG->getLL('importdata_metaData_1387'),
1350 'content' => '
1351 <table border="0" cellpadding="1" cellspacing="1">
1352 '.implode('
1353 ',$trow).'
1354 </table>
1355 '
1356 );
1357 }
1358
1359 // Print errors that might be:
1360 $errors = $import->printErrorLog();
1361 $menuItems[] = array(
1362 'label' => $LANG->getLL('importdata_messages'),
1363 'content' => $errors,
1364 'stateIcon' => $errors ? 2 : 0
1365 );
1366
1367 // Output tabs:
1368 $content = $this->doc->getDynTabMenu($menuItems,'tx_impexp_import',-1);
1369 if ($extensionInstallationMessage) {
1370 $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;
1371 }
1372 $this->content.= $this->doc->section('',$content,0,1);
1373
1374
1375 // Print overview:
1376 if ($overviewContent) {
1377 $this->content.= $this->doc->section($inData['import_file'] ? $LANG->getLL('importdata_structureHasBeenImported',1) : $LANG->getLL('filterpage_structureToBeImported',1), $overviewContent, 0, 1);
1378 }
1379 }
1380 }
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394 /****************************
1395 *
1396 * Preset functions
1397 *
1398 ****************************/
1399
1400 /**
1401 * Manipulate presets
1402 *
1403 * @param array In data array, passed by reference!
1404 * @return void
1405 */
1406 function processPresets(&$inData) {
1407
1408 $presetData = t3lib_div::_GP('preset');
1409 $err = FALSE;
1410
1411 // Save preset
1412 if (isset($presetData['save'])) {
1413 $preset = $this->getPreset($presetData['select']);
1414 if (is_array($preset)) { // Update existing
1415 if ($GLOBALS['BE_USER']->isAdmin() || $preset['user_uid'] === $GLOBALS['BE_USER']->user['uid']) {
1416 $fields_values = array(
1417 'public' => $inData['preset']['public'],
1418 'title' => $inData['preset']['title'],
1419 'item_uid' => $inData['pagetree']['id'],
1420 'preset_data' => serialize($inData)
1421 );
1422 $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_impexp_presets','uid='.intval($preset['uid']),$fields_values);
1423 $msg = 'Preset #'.$preset['uid'].' saved!';
1424 } else {
1425 $msg = 'ERROR: The preset was not saved because you were not the owner of it!';
1426 $err = TRUE;
1427 }
1428 } else { // Insert new:
1429 $fields_values = array(
1430 'user_uid' => $GLOBALS['BE_USER']->user['uid'],
1431 'public' => $inData['preset']['public'],
1432 'title' => $inData['preset']['title'],
1433 'item_uid' => $inData['pagetree']['id'],
1434 'preset_data' => serialize($inData)
1435 );
1436 $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_impexp_presets',$fields_values);
1437 $msg = 'New preset "' . htmlspecialchars($inData['preset']['title']) . '" is created';
1438 }
1439 }
1440
1441 // Delete preset:
1442 if (isset($presetData['delete'])) {
1443 $preset = $this->getPreset($presetData['select']);
1444 if (is_array($preset)) { // Update existing
1445 if ($GLOBALS['BE_USER']->isAdmin() || $preset['user_uid'] === $GLOBALS['BE_USER']->user['uid']) {
1446 $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_impexp_presets','uid='.intval($preset['uid']));
1447 $msg = 'Preset #'.$preset['uid'].' deleted!';
1448 } else {
1449 $msg = 'ERROR: You were not the owner of the preset so you could not delete it.';
1450 $err = TRUE;
1451 }
1452 } else {
1453 $msg = 'ERROR: No preset selected for deletion.';
1454 $err = TRUE;
1455 }
1456 }
1457
1458 // Load preset
1459 if (isset($presetData['load']) || isset($presetData['merge'])) {
1460 $preset = $this->getPreset($presetData['select']);
1461 if (is_array($preset)) { // Update existing
1462 $inData_temp = unserialize($preset['preset_data']);
1463 if (is_array($inData_temp)) {
1464 if (isset($presetData['merge'])) {
1465
1466 // Merge records in:
1467 if (is_array($inData_temp['record'])) {
1468 $inData['record'] = array_merge((array)$inData['record'], $inData_temp['record']);
1469 }
1470
1471 // Merge lists in:
1472 if (is_array($inData_temp['list'])) {
1473 $inData['list'] = array_merge((array)$inData['list'], $inData_temp['list']);
1474 }
1475 } else {
1476 $msg = 'Preset #'.$preset['uid'].' loaded!';
1477 $inData = $inData_temp;
1478 }
1479 } else {
1480 $msg = 'ERROR: No configuratio data found in preset record!';
1481 $err = TRUE;
1482 }
1483 } else {
1484 $msg = 'ERROR: No preset selected for loading.';
1485 $err = TRUE;
1486 }
1487 }
1488
1489 // Show message:
1490 if (strlen($msg)) {
1491 $this->content.= $this->doc->section('Presets',$msg,0,1,$err ? 3 : 1);
1492 }
1493 }
1494
1495 /**
1496 * Get single preset record
1497 *
1498 * @param integer Preset record
1499 * @return array Preset record, if any (otherwise FALSE)
1500 */
1501 function getPreset($uid) {
1502 $preset = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tx_impexp_presets', 'uid=' . intval($uid));
1503 return $preset;
1504 }
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516 /****************************
1517 *
1518 * Helper functions
1519 *
1520 ****************************/
1521
1522 /**
1523 * Returns first temporary folder of the user account (from $FILEMOUNTS)
1524 *
1525 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
1526 */
1527 function userTempFolder() {
1528 global $FILEMOUNTS;
1529
1530 foreach($FILEMOUNTS as $filePathInfo) {
1531 $tempFolder = $filePathInfo['path'].'_temp_/';
1532 if (@is_dir($tempFolder)) {
1533 return $tempFolder;
1534 }
1535 }
1536 }
1537
1538 /**
1539 * Returns folder where user can save export files.
1540 *
1541 * @return string Absolute path to folder where export files can be saved.
1542 */
1543 function userSaveFolder() {
1544 global $FILEMOUNTS;
1545
1546 reset($FILEMOUNTS);
1547 $filePathInfo = current($FILEMOUNTS);
1548
1549 if (is_array($filePathInfo)) {
1550 $tempFolder = $filePathInfo['path'] . '_temp_/';
1551 if (!@is_dir($tempFolder)) {
1552 $tempFolder = $filePathInfo['path'];
1553 if (!@is_dir($tempFolder)) {
1554 return FALSE;
1555 }
1556 }
1557 return $tempFolder;
1558 }
1559 }
1560
1561 /**
1562 * Check if a file has been uploaded
1563 *
1564 * @return void
1565 */
1566 function checkUpload() {
1567 $file = t3lib_div::_GP('file');
1568
1569 // Initializing:
1570 $this->fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
1571 $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
1572 $this->fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
1573 $this->fileProcessor->dontCheckForUnique = t3lib_div::_GP('overwriteExistingFiles') ? 1 : 0;
1574
1575 // Checking referer / executing:
1576 $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
1577 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
1578 if ($httpHost != $refInfo['host'] && $this->vC != $GLOBALS['BE_USER']->veriCode()
1579 && !$GLOBALS['$TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']) {
1580 $this->fileProcessor->writeLog(0,2,1,'Referer host "%s" and server host "%s" did not match!',array($refInfo['host'],$httpHost));
1581 } else {
1582 $this->fileProcessor->start($file);
1583 $this->fileProcessor->processData();
1584 }
1585 }
1586
1587 /**
1588 * Makes a selector-box from optValues
1589 *
1590 * @param string Form element name
1591 * @param string Current value
1592 * @param array Options to display (key/value pairs)
1593 * @return string HTML select element
1594 */
1595 function renderSelectBox($prefix,$value,$optValues) {
1596 $opt = array();
1597 $isSelFlag = 0;
1598 foreach ($optValues as $k => $v) {
1599 $sel = (!strcmp($k,$value) ? ' selected="selected"' : '');
1600 if ($sel) $isSelFlag++;
1601 $opt[] = '<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
1602 }
1603 if (!$isSelFlag && strcmp('',$value)) {
1604 $opt[] = '<option value="'.htmlspecialchars($value).'" selected="selected">'.htmlspecialchars("['".$value."']").'</option>';
1605 }
1606 return '<select name="'.$prefix.'">'.implode('',$opt).'</select>';
1607 }
1608
1609 /**
1610 * Returns a selector-box with TCA tables
1611 *
1612 * @param string Form element name prefix
1613 * @param array The current values selected
1614 * @param string Table names (and the string "_ALL") to exclude. Comma list
1615 * @return string HTML select element
1616 */
1617 function tableSelector($prefix,$value,$excludeList='') {
1618 $optValues = array();
1619
1620 if (!t3lib_div::inList($excludeList,'_ALL')) {
1621 $optValues['_ALL'] = '[' . $GLOBALS['LANG']->getLL('ALL_tables').']';
1622 }
1623
1624 foreach ($GLOBALS['TCA'] as $table => $_) {
1625 if ($GLOBALS['BE_USER']->check('tables_select',$table) && !t3lib_div::inList($excludeList,$table)) {
1626 $optValues[$table] = $table;
1627 }
1628 }
1629
1630 // make box:
1631 $opt = array();
1632 $opt[] = '<option value=""></option>';
1633 foreach ($optValues as $k => $v) {
1634 if (is_array($value)) {
1635 $sel = in_array($k,$value)?' selected="selected"':'';
1636 }
1637 $opt[] = '<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
1638 }
1639 return '<select name="'.$prefix.'[]" multiple="multiple" size="'.t3lib_utility_Math::forceIntegerInRange(count($opt),5,10).'">'.implode('',$opt).'</select>';
1640 }
1641
1642 /**
1643 * Returns a selector-box with loaded extension keys
1644 *
1645 * @param string Form element name prefix
1646 * @param array The current values selected
1647 * @return string HTML select element
1648 */
1649 function extensionSelector($prefix,$value) {
1650 global $TYPO3_LOADED_EXT;
1651
1652 $extTrav = array_keys($TYPO3_LOADED_EXT);
1653
1654 // make box:
1655 $opt = array();
1656 $opt[] = '<option value=""></option>';
1657 foreach($extTrav as $v) {
1658 if ($v!=='_CACHEFILE') {
1659 if (is_array($value)) {
1660 $sel = in_array($v,$value)?' selected="selected"':'';
1661 }
1662 $opt[] = '<option value="'.htmlspecialchars($v).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
1663 }
1664 }
1665 return '<select name="'.$prefix.'[]" multiple="multiple" size="'.t3lib_utility_Math::forceIntegerInRange(count($opt),5,10).'">'.implode('',$opt).'</select>';
1666 }
1667
1668 /**
1669 * Filter page IDs by traversing exclude array, finding all excluded pages (if any) and making an AND NOT IN statement for the select clause.
1670 *
1671 * @param array Exclude array from import/export object.
1672 * @return string AND where clause part to filter out page uids.
1673 */
1674 function filterPageIds($exclude) {
1675
1676 // Get keys:
1677 $exclude = array_keys($exclude);
1678
1679 // Traverse
1680 $pageIds = array();
1681 foreach($exclude as $element) {
1682 list($table,$uid) = explode(':', $element);
1683 if ($table==='pages') {
1684 $pageIds[] = intval($uid);
1685 }
1686 }
1687
1688 // Add to clause:
1689 if (count($pageIds)) {
1690 return ' AND uid NOT IN ('.implode(',', $pageIds).')';
1691 }
1692 }
1693 }
1694
1695
1696 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php'])) {
1697 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php']);
1698 }
1699
1700
1701
1702 // Make instance:
1703 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
1704 $SOBE->init();
1705 $SOBE->main();
1706 $SOBE->printContent();
1707
1708 ?>