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