Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / app / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Import / Export module
29 *
30 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
31 */
32 /**
33 * [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_BEfunc::getListViewLink(
394 array(
395 'id' => $this->pageinfo['uid'],
396 'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
397 ),
398 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
399 );
400 }
401 }
402 }
403
404 return $buttons;
405 }
406
407
408
409
410
411 /**************************
412 *
413 * EXPORT FUNCTIONS
414 *
415 **************************/
416
417 /**
418 * Export part of module
419 *
420 * @param array Content of POST VAR tx_impexp[]..
421 * @return void Setting content in $this->content
422 */
423 function exportData($inData) {
424 global $TCA, $LANG;
425
426 // BUILDING EXPORT DATA:
427
428 // Processing of InData array values:
429 $inData['pagetree']['maxNumber'] = t3lib_div::intInRange($inData['pagetree']['maxNumber'],1,10000,100);
430 $inData['listCfg']['maxNumber'] = t3lib_div::intInRange($inData['listCfg']['maxNumber'],1,10000,100);
431 $inData['maxFileSize'] = t3lib_div::intInRange($inData['maxFileSize'],1,10000,1000);
432 $inData['filename'] = trim(preg_replace('/[^[:alnum:]._-]*/','',preg_replace('/\.(t3d|xml)$/','',$inData['filename'])));
433 if (strlen($inData['filename'])) {
434 $inData['filename'].= $inData['filetype']=='xml' ? '.xml' : '.t3d';
435 }
436
437 // Set exclude fields in export object:
438 if (!is_array($inData['exclude'])) {
439 $inData['exclude'] = array();
440 }
441
442
443 // Saving/Loading/Deleting presets:
444 $this->processPresets($inData);
445
446 // Create export object and configure it:
447 $this->export = t3lib_div::makeInstance('tx_impexp');
448 $this->export->init(0,'export');
449 $this->export->setCharset($LANG->charSet);
450
451 $this->export->maxFileSize = $inData['maxFileSize']*1024;
452 $this->export->excludeMap = (array)$inData['exclude'];
453 $this->export->softrefCfg = (array)$inData['softrefCfg'];
454 $this->export->extensionDependencies = (array)$inData['extension_dep'];
455 $this->export->showStaticRelations = $inData['showStaticRelations'];
456
457 $this->export->includeExtFileResources = !$inData['excludeHTMLfileResources'];
458
459 // Static tables:
460 if (is_array($inData['external_static']['tables'])) {
461 $this->export->relStaticTables = $inData['external_static']['tables'];
462 }
463
464 // Configure which tables external relations are included for:
465 if (is_array($inData['external_ref']['tables'])) {
466 $this->export->relOnlyTables = $inData['external_ref']['tables'];
467 }
468 $this->export->setHeaderBasics();
469
470 // Meta data setting:
471 $this->export->setMetaData(
472 $inData['meta']['title'],
473 $inData['meta']['description'],
474 $inData['meta']['notes'],
475 $GLOBALS['BE_USER']->user['username'],
476 $GLOBALS['BE_USER']->user['realName'],
477 $GLOBALS['BE_USER']->user['email']
478 );
479 if ($inData['meta']['thumbnail']) {
480 $tempDir = $this->userTempFolder();
481 if ($tempDir) {
482 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
483 $theThumb = $thumbnails[$inData['meta']['thumbnail']];
484 if ($theThumb) {
485 $this->export->addThumbnail($theThumb);
486 }
487 }
488 }
489
490
491 // Configure which records to export
492 if (is_array($inData['record'])) {
493 foreach($inData['record'] as $ref) {
494 $rParts = explode(':',$ref);
495 $this->export->export_addRecord($rParts[0],t3lib_BEfunc::getRecord($rParts[0],$rParts[1]));
496 }
497 }
498
499 // Configure which tables to export
500 if (is_array($inData['list'])) {
501 foreach($inData['list'] as $ref) {
502 $rParts = explode(':',$ref);
503 if ($GLOBALS['BE_USER']->check('tables_select',$rParts[0])) {
504 $res = $this->exec_listQueryPid($rParts[0],$rParts[1],t3lib_div::intInRange($inData['listCfg']['maxNumber'],1));
505 while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
506 $this->export->export_addRecord($rParts[0],$subTrow);
507 }
508 }
509 }
510 }
511
512 // Pagetree
513 if (isset($inData['pagetree']['id'])) {
514 if ($inData['pagetree']['levels']==-1) { // Based on click-expandable tree
515 $pagetree = t3lib_div::makeInstance('localPageTree');
516
517 $tree = $pagetree->ext_tree($inData['pagetree']['id'],$this->filterPageIds($this->export->excludeMap));
518 $this->treeHTML = $pagetree->printTree($tree);
519
520 $idH = $pagetree->buffer_idH;
521 } elseif ($inData['pagetree']['levels']==-2) { // Only tables on page
522 $this->addRecordsForPid($inData['pagetree']['id'],$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
523 } else { // Based on depth
524 // Drawing tree:
525 // If the ID is zero, export root
526 if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin()) {
527 $sPage = array(
528 'uid' => 0,
529 'title' => 'ROOT'
530 );
531 } else {
532 $sPage = t3lib_BEfunc::getRecordWSOL('pages',$inData['pagetree']['id'],'*',' AND '.$this->perms_clause);
533 }
534 if (is_array($sPage)) {
535 $pid = $inData['pagetree']['id'];
536 $tree = t3lib_div::makeInstance('t3lib_pageTree');
537 $tree->init('AND '.$this->perms_clause.$this->filterPageIds($this->export->excludeMap));
538
539 $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $sPage);
540 $tree->tree[] = Array('row'=>$sPage,'HTML'=>$HTML);
541 $tree->buffer_idH = array();
542 if ($inData['pagetree']['levels']>0) {
543 $tree->getTree($pid,$inData['pagetree']['levels'],'');
544 }
545
546 $idH = array();
547 $idH[$pid]['uid'] = $pid;
548 if (count($tree->buffer_idH)) {
549 $idH[$pid]['subrow'] = $tree->buffer_idH;
550 }
551
552 $pagetree = t3lib_div::makeInstance('localPageTree');
553 $this->treeHTML = $pagetree->printTree($tree->tree);
554 }
555 }
556 // 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...)
557 if (is_array($idH)) {
558 $flatList = $this->export->setPageTree($idH); // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...)
559 foreach ($flatList as $k => $value) {
560 $this->export->export_addRecord('pages',t3lib_BEfunc::getRecord('pages',$k));
561 $this->addRecordsForPid($k,$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
562 }
563 }
564 }
565
566 // After adding ALL records we set relations:
567 for($a=0;$a<10;$a++) {
568 $addR = $this->export->export_addDBRelations($a);
569 if (!count($addR)) {
570 break;
571 }
572 }
573
574 // Finally files are added:
575 $this->export->export_addFilesFromRelations(); // MUST be after the DBrelations are set so that files from ALL added records are included!
576 // If the download button is clicked, return file
577 if ($inData['download_export'] || $inData['save_export']) {
578 switch((string)$inData['filetype']) {
579 case 'xml':
580 $out = $this->export->compileMemoryToFileContent('xml');
581 $fExt = '.xml';
582 break;
583 case 't3d':
584 $this->export->dontCompress = 1;
585 default:
586 $out = $this->export->compileMemoryToFileContent();
587 $fExt = ($this->export->doOutputCompress()?'-z':'').'.t3d';
588 break;
589 }
590
591 // Filename:
592 $dlFile = $inData['filename'] ? $inData['filename'] : 'T3D_'.substr(preg_replace('/[^[:alnum:]_]/','-',$inData['download_export_name']),0,20).'_'.date('d-m-H-i-s').$fExt;
593
594 // Export for download:
595 if ($inData['download_export']) {
596 $mimeType = 'application/octet-stream';
597 Header('Content-Type: '.$mimeType);
598 Header('Content-Length: '.strlen($out));
599 Header('Content-Disposition: attachment; filename='.basename($dlFile));
600
601 echo $out;
602 exit;
603 }
604
605 // Export by saving:
606 if ($inData['save_export']) {
607 $savePath = $this->userSaveFolder();
608 $fullName = $savePath.$dlFile;
609
610 if (t3lib_div::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && t3lib_div::isAllowedAbsPath($fullName)) {
611 t3lib_div::writeFile($fullName, $out);
612 $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);
613 } else {
614 $this->content.= $this->doc->section($LANG->getLL('exportdata_problemsSavingFile'),sprintf($LANG->getLL('exportdata_badPathS',1),$fullName),0,1,2);
615 }
616 }
617 }
618
619
620 // OUTPUT to BROWSER:
621 // Now, if we didn't make download file, show configuration form based on export:
622 $menuItems = array();
623
624 // Export configuration
625 $row = array();
626 $this->makeConfigurationForm($inData, $row);
627 $menuItems[] = array(
628 'label' => $LANG->getLL('tableselec_configuration'),
629 'content' => '
630 <table border="0" cellpadding="1" cellspacing="1">
631 '.implode('
632 ',$row).'
633 </table>
634 '
635 );
636
637 // File options
638 $row = array();
639 $this->makeSaveForm($inData, $row);
640 $menuItems[] = array(
641 'label' => $LANG->getLL('exportdata_filePreset'),
642 'content' => '
643 <table border="0" cellpadding="1" cellspacing="1">
644 '.implode('
645 ',$row).'
646 </table>
647 '
648 );
649
650 // File options
651 $row = array();
652 $this->makeAdvancedOptionsForm($inData, $row);
653 $menuItems[] = array(
654 'label' => $LANG->getLL('exportdata_advancedOptions'),
655 'content' => '
656 <table border="0" cellpadding="1" cellspacing="1">
657 '.implode('
658 ',$row).'
659 </table>
660 '
661 );
662
663 // Generate overview:
664 $overViewContent = $this->export->displayContentOverview();
665
666 // Print errors that might be:
667 $errors = $this->export->printErrorLog();
668 $menuItems[] = array(
669 'label' => $LANG->getLL('exportdata_messages'),
670 'content' => $errors,
671 'stateIcon' => $errors ? 2 : 0
672 );
673
674 // Add hidden fields and create tabs:
675 $content = $this->doc->getDynTabMenu($menuItems,'tx_impexp_export',-1);
676 $content.= '<input type="hidden" name="tx_impexp[action]" value="export" />';
677 $this->content.= $this->doc->section('',$content,0,1);
678
679 // Output Overview:
680 $this->content.= $this->doc->section($LANG->getLL('execlistqu_structureToBeExported'),$overViewContent,0,1);
681
682 }
683
684 /**
685 * Adds records to the export object for a specific page id.
686 *
687 * @param integer Page id for which to select records to add
688 * @param array Array of table names to select from
689 * @param integer Max amount of records to select
690 * @return void
691 */
692 function addRecordsForPid($k, $tables, $maxNumber) {
693 global $TCA;
694
695 if (is_array($tables)) {
696 foreach ($TCA as $table => $value) {
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::getSpriteIconForRecord($tName, $rec) .
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::getSpriteIconForRecord('pages', $rec) .
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 . t3lib_extMgm::extRelPath('em') . 'mod1/index.php?CMD[requestInstallExtensions]=' .
1293 implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl);
1294 $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.';
1295 }
1296
1297 if ($inData['import_file']) {
1298 if (!count($extKeysToInstall)) {
1299 $import->importData($this->id);
1300 t3lib_BEfunc::setUpdateSignal('updatePageTree');
1301 } else {
1302 t3lib_utility_Http::redirect($emURL);
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 "' . htmlspecialchars($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 $preset = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', '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 foreach ($optValues as $k => $v) {
1618 $sel = (!strcmp($k,$value) ? ' selected="selected"' : '');
1619 if ($sel) $isSelFlag++;
1620 $opt[] = '<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
1621 }
1622 if (!$isSelFlag && strcmp('',$value)) {
1623 $opt[] = '<option value="'.htmlspecialchars($value).'" selected="selected">'.htmlspecialchars("['".$value."']").'</option>';
1624 }
1625 return '<select name="'.$prefix.'">'.implode('',$opt).'</select>';
1626 }
1627
1628 /**
1629 * Returns a selector-box with TCA tables
1630 *
1631 * @param string Form element name prefix
1632 * @param array The current values selected
1633 * @param string Table names (and the string "_ALL") to exclude. Comma list
1634 * @return string HTML select element
1635 */
1636 function tableSelector($prefix,$value,$excludeList='') {
1637 global $TCA, $LANG;
1638
1639 $optValues = array();
1640
1641 if (!t3lib_div::inList($excludeList,'_ALL')) {
1642 $optValues['_ALL'] = '['.$LANG->getLL('ALL_tables').']';
1643 }
1644
1645 foreach ($TCA as $table => $_) {
1646 if ($GLOBALS['BE_USER']->check('tables_select',$table) && !t3lib_div::inList($excludeList,$table)) {
1647 $optValues[$table] = $table;
1648 }
1649 }
1650
1651 // make box:
1652 $opt = array();
1653 $opt[] = '<option value=""></option>';
1654 foreach ($optValues as $k => $v) {
1655 if (is_array($value)) {
1656 $sel = in_array($k,$value)?' selected="selected"':'';
1657 }
1658 $opt[] = '<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
1659 }
1660 return '<select name="'.$prefix.'[]" multiple="multiple" size="'.t3lib_div::intInRange(count($opt),5,10).'">'.implode('',$opt).'</select>';
1661 }
1662
1663 /**
1664 * Returns a selector-box with loaded extension keys
1665 *
1666 * @param string Form element name prefix
1667 * @param array The current values selected
1668 * @return string HTML select element
1669 */
1670 function extensionSelector($prefix,$value) {
1671 global $TYPO3_LOADED_EXT;
1672
1673 $extTrav = array_keys($TYPO3_LOADED_EXT);
1674
1675 // make box:
1676 $opt = array();
1677 $opt[] = '<option value=""></option>';
1678 foreach($extTrav as $v) {
1679 if ($v!=='_CACHEFILE') {
1680 if (is_array($value)) {
1681 $sel = in_array($v,$value)?' selected="selected"':'';
1682 }
1683 $opt[] = '<option value="'.htmlspecialchars($v).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
1684 }
1685 }
1686 return '<select name="'.$prefix.'[]" multiple="multiple" size="'.t3lib_div::intInRange(count($opt),5,10).'">'.implode('',$opt).'</select>';
1687 }
1688
1689 /**
1690 * Filter page IDs by traversing exclude array, finding all excluded pages (if any) and making an AND NOT IN statement for the select clause.
1691 *
1692 * @param array Exclude array from import/export object.
1693 * @return string AND where clause part to filter out page uids.
1694 */
1695 function filterPageIds($exclude) {
1696
1697 // Get keys:
1698 $exclude = array_keys($exclude);
1699
1700 // Traverse
1701 $pageIds = array();
1702 foreach($exclude as $element) {
1703 list($table,$uid) = explode(':', $element);
1704 if ($table==='pages') {
1705 $pageIds[] = intval($uid);
1706 }
1707 }
1708
1709 // Add to clause:
1710 if (count($pageIds)) {
1711 return ' AND uid NOT IN ('.implode(',', $pageIds).')';
1712 }
1713 }
1714 }
1715
1716
1717 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php'])) {
1718 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php']);
1719 }
1720
1721
1722
1723 // Make instance:
1724 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
1725 $SOBE->init();
1726 $SOBE->main();
1727 $SOBE->printContent();
1728
1729 ?>