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