01cc025f60a0249eaa3e1629ddf70a92d451d637
[Packages/TYPO3.CMS.git] / typo3 / sysext / impexp / app / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Import / Export module
29 *
30 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
31 */
32 /**
33 * [CLASS/FUNCTION INDEX of SCRIPT]
34 *
35 *
36 *
37 * 137: class localPageTree extends t3lib_browseTree
38 * 144: function localPageTree()
39 * 155: function wrapTitle($title,$v)
40 * 168: function PM_ATagWrap($icon,$cmd,$bMark='')
41 * 179: function wrapIcon($icon,$row)
42 * 188: function permsC()
43 * 199: function ext_tree($pid, $clause='')
44 *
45 *
46 * 280: class SC_mod_tools_log_index extends t3lib_SCbase
47 * 289: function main()
48 * 359: function printContent()
49 *
50 * SECTION: EXPORT FUNCTIONS
51 * 387: function exportData($inData)
52 * 661: function addRecordsForPid($k, $tables, $maxNumber)
53 * 687: function exec_listQueryPid($table,$pid,$limit)
54 * 717: function makeConfigurationForm($inData, &$row)
55 * 885: function makeAdvancedOptionsForm($inData, &$row)
56 * 933: function makeSaveForm($inData, &$row)
57 *
58 * SECTION: IMPORT FUNCTIONS
59 * 1064: function importData($inData)
60 *
61 * SECTION: Preset functions
62 * 1363: function processPresets(&$inData)
63 * 1458: function getPreset($uid)
64 *
65 * SECTION: Helper functions
66 * 1484: function userTempFolder()
67 * 1500: function userSaveFolder()
68 * 1523: function checkUpload()
69 * 1553: function renderSelectBox($prefix,$value,$optValues)
70 * 1576: function tableSelector($prefix,$value,$excludeList='')
71 * 1612: function extensionSelector($prefix,$value)
72 * 1637: function filterPageIds($exclude)
73 *
74 * TOTAL FUNCTIONS: 24
75 * (This index is automatically created/updated by the extension "extdeveval")
76 *
77 */
78 /**
79 * IMPORTING DATA:
80 *
81 * Incoming array has syntax:
82 * GETvar 'id' = import page id (must be readable)
83 *
84 * file = (pointing to filename relative to PATH_site)
85 *
86 *
87 *
88 * [all relation fields are clear, but not files]
89 * - page-tree is written first
90 * - then remaining pages (to the root of import)
91 * - then all other records are written either to related included pages or if not found to import-root (should be a sysFolder in most cases)
92 * - then all internal relations are set and non-existing relations removed, relations to static tables preserved.
93 *
94 * EXPORTING DATA:
95 *
96 * Incoming array has syntax:
97 *
98 * file[] = file
99 * dir[] = dir
100 * list[] = table:pid
101 * record[] = table:uid
102 *
103 * pagetree[id] = (single id)
104 * pagetree[levels]=1,2,3, -1 = currently unpacked tree, -2 = only tables on page
105 * pagetree[tables][]=table/_ALL
106 *
107 * external_ref[tables][]=table/_ALL
108 */
109
110 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 Skaarhoj <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::getIconImage('pages',$rootRec,$this->backPath,'align="top"'),$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 Skaarhoj <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 // Set up JS for dynamic tab menu
303 $this->doc->JScode .= $this->doc->getDynTabMenuJScode();
304
305 // Setting up the context sensitive menu:
306 $this->doc->getContextMenuCode();
307
308 $this->doc->postCode = $this->doc->wrapScriptTags('
309 script_ended = 1;
310 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
311 ');
312 $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.'" />';
313
314 $this->content.= $this->doc->header($LANG->getLL('title'));
315 $this->content.= $this->doc->spacer(5);
316
317 // Input data grabbed:
318 $inData = t3lib_div::_GP('tx_impexp');
319
320 $this->checkUpload();
321
322 switch((string)$inData['action']) {
323 case 'export':
324
325 // Finally: If upload went well, set the new file as the thumbnail in the $inData array:
326 if (is_object($this->fileProcessor) && $this->fileProcessor->internalUploadMap[1]) {
327 $inData['meta']['thumbnail'] = md5($this->fileProcessor->internalUploadMap[1]);
328 }
329
330 // Call export interface
331 $this->exportData($inData);
332 break;
333 case 'import':
334
335 // Finally: If upload went well, set the new file as the import file:
336 if (is_object($this->fileProcessor) && $this->fileProcessor->internalUploadMap[1]) {
337 $fI = pathinfo($this->fileProcessor->internalUploadMap[1]);
338 if (t3lib_div::inList('t3d,xml',strtolower($fI['extension']))) { // Only allowed extensions....
339 $inData['file'] = $this->fileProcessor->internalUploadMap[1];
340 }
341 }
342
343 // Call import interface:
344 $this->importData($inData);
345 break;
346 }
347
348 // Setting up the buttons and markers for docheader
349 $docHeaderButtons = $this->getButtons();
350 $markers['CONTENT'] = $this->content;
351
352 // Build the <body> for the module
353 $this->content = $this->doc->startPage($LANG->getLL('title'));
354 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
355 $this->content.= $this->doc->endPage();
356 $this->content = $this->doc->insertStylesAndJS($this->content);
357 }
358
359 /**
360 * Print the content
361 *
362 * @return void
363 */
364 function printContent() {
365 echo $this->content;
366 }
367
368 /**
369 * Create the panel of buttons for submitting the form or otherwise perform operations.
370 *
371 * @return array all available buttons as an associated array
372 */
373 protected function getButtons() {
374 $buttons = array(
375 'view' => '',
376 'record_list' => '',
377 'shortcut' => ''
378 );
379
380 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
381 $buttons['shortcut'] = $this->doc->makeShortcutIcon('tx_impexp', '', $this->MCONF['name']);
382 }
383
384 // Input data grabbed:
385 $inData = t3lib_div::_GP('tx_impexp');
386 if((string)$inData['action'] == 'import') {
387 if (($this->id && is_array($this->pageinfo)) || ($GLOBALS['BE_USER']->user['admin'] && !$this->id)) {
388 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
389 // View
390 $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) . '">' .
391 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
392 '</a>';
393
394 // Record list
395 if ($GLOBALS['BE_USER']->check('modules', 'web_list')) {
396 $href = $this->doc->backPath . 'db_list.php?id=' . $this->pageinfo['uid'] . '&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
397 $buttons['record_list'] = '<a href="' . htmlspecialchars($href) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList', TRUE) . '">' .
398 t3lib_iconWorks::getSpriteIcon('actions-system-list-open') .
399 '</a>';
400 }
401 }
402 }
403 }
404
405 return $buttons;
406 }
407
408
409
410
411
412 /**************************
413 *
414 * EXPORT FUNCTIONS
415 *
416 **************************/
417
418 /**
419 * Export part of module
420 *
421 * @param array Content of POST VAR tx_impexp[]..
422 * @return void Setting content in $this->content
423 */
424 function exportData($inData) {
425 global $TCA, $LANG;
426
427 // BUILDING EXPORT DATA:
428
429 // Processing of InData array values:
430 $inData['pagetree']['maxNumber'] = t3lib_div::intInRange($inData['pagetree']['maxNumber'],1,10000,100);
431 $inData['listCfg']['maxNumber'] = t3lib_div::intInRange($inData['listCfg']['maxNumber'],1,10000,100);
432 $inData['maxFileSize'] = t3lib_div::intInRange($inData['maxFileSize'],1,10000,1000);
433 $inData['filename'] = trim(preg_replace('/[^[:alnum:]._-]*/','',preg_replace('/\.(t3d|xml)$/','',$inData['filename'])));
434 if (strlen($inData['filename'])) {
435 $inData['filename'].= $inData['filetype']=='xml' ? '.xml' : '.t3d';
436 }
437
438 // Set exclude fields in export object:
439 if (!is_array($inData['exclude'])) {
440 $inData['exclude'] = array();
441 }
442
443
444 // Saving/Loading/Deleting presets:
445 $this->processPresets($inData);
446
447 // Create export object and configure it:
448 $this->export = t3lib_div::makeInstance('tx_impexp');
449 $this->export->init(0,'export');
450 $this->export->setCharset($LANG->charSet);
451
452 $this->export->maxFileSize = $inData['maxFileSize']*1024;
453 $this->export->excludeMap = (array)$inData['exclude'];
454 $this->export->softrefCfg = (array)$inData['softrefCfg'];
455 $this->export->extensionDependencies = (array)$inData['extension_dep'];
456 $this->export->showStaticRelations = $inData['showStaticRelations'];
457
458 $this->export->includeExtFileResources = !$inData['excludeHTMLfileResources'];
459
460 // Static tables:
461 if (is_array($inData['external_static']['tables'])) {
462 $this->export->relStaticTables = $inData['external_static']['tables'];
463 }
464
465 // Configure which tables external relations are included for:
466 if (is_array($inData['external_ref']['tables'])) {
467 $this->export->relOnlyTables = $inData['external_ref']['tables'];
468 }
469 $this->export->setHeaderBasics();
470
471 // Meta data setting:
472 $this->export->setMetaData(
473 $inData['meta']['title'],
474 $inData['meta']['description'],
475 $inData['meta']['notes'],
476 $GLOBALS['BE_USER']->user['username'],
477 $GLOBALS['BE_USER']->user['realName'],
478 $GLOBALS['BE_USER']->user['email']
479 );
480 if ($inData['meta']['thumbnail']) {
481 $tempDir = $this->userTempFolder();
482 if ($tempDir) {
483 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
484 $theThumb = $thumbnails[$inData['meta']['thumbnail']];
485 if ($theThumb) {
486 $this->export->addThumbnail($theThumb);
487 }
488 }
489 }
490
491
492 // Configure which records to export
493 if (is_array($inData['record'])) {
494 foreach($inData['record'] as $ref) {
495 $rParts = explode(':',$ref);
496 $this->export->export_addRecord($rParts[0],t3lib_BEfunc::getRecord($rParts[0],$rParts[1]));
497 }
498 }
499
500 // Configure which tables to export
501 if (is_array($inData['list'])) {
502 foreach($inData['list'] as $ref) {
503 $rParts = explode(':',$ref);
504 if ($GLOBALS['BE_USER']->check('tables_select',$rParts[0])) {
505 $res = $this->exec_listQueryPid($rParts[0],$rParts[1],t3lib_div::intInRange($inData['listCfg']['maxNumber'],1));
506 while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
507 $this->export->export_addRecord($rParts[0],$subTrow);
508 }
509 }
510 }
511 }
512
513 // Pagetree
514 if (isset($inData['pagetree']['id'])) {
515 if ($inData['pagetree']['levels']==-1) { // Based on click-expandable tree
516 $pagetree = t3lib_div::makeInstance('localPageTree');
517
518 $tree = $pagetree->ext_tree($inData['pagetree']['id'],$this->filterPageIds($this->export->excludeMap));
519 $this->treeHTML = $pagetree->printTree($tree);
520
521 $idH = $pagetree->buffer_idH;
522 } elseif ($inData['pagetree']['levels']==-2) { // Only tables on page
523 $this->addRecordsForPid($inData['pagetree']['id'],$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
524 } else { // Based on depth
525 // Drawing tree:
526 // If the ID is zero, export root
527 if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin()) {
528 $sPage = array(
529 'uid' => 0,
530 'title' => 'ROOT'
531 );
532 } else {
533 $sPage = t3lib_BEfunc::getRecordWSOL('pages',$inData['pagetree']['id'],'*',' AND '.$this->perms_clause);
534 }
535 if (is_array($sPage)) {
536 $pid = $inData['pagetree']['id'];
537 $tree = t3lib_div::makeInstance('t3lib_pageTree');
538 $tree->init('AND '.$this->perms_clause.$this->filterPageIds($this->export->excludeMap));
539
540 $HTML = t3lib_iconWorks::getIconImage('pages',$sPage,$GLOBALS['BACK_PATH'],'align="top"');
541 $tree->tree[] = Array('row'=>$sPage,'HTML'=>$HTML);
542 $tree->buffer_idH = array();
543 if ($inData['pagetree']['levels']>0) {
544 $tree->getTree($pid,$inData['pagetree']['levels'],'');
545 }
546
547 $idH = array();
548 $idH[$pid]['uid'] = $pid;
549 if (count($tree->buffer_idH)) {
550 $idH[$pid]['subrow'] = $tree->buffer_idH;
551 }
552
553 $pagetree = t3lib_div::makeInstance('localPageTree');
554 $this->treeHTML = $pagetree->printTree($tree->tree);
555 }
556 }
557 // 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...)
558 if (is_array($idH)) {
559 $flatList = $this->export->setPageTree($idH); // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...)
560 foreach ($flatList as $k => $value) {
561 $this->export->export_addRecord('pages',t3lib_BEfunc::getRecord('pages',$k));
562 $this->addRecordsForPid($k,$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
563 }
564 }
565 }
566
567 // After adding ALL records we set relations:
568 for($a=0;$a<10;$a++) {
569 $addR = $this->export->export_addDBRelations($a);
570 if (!count($addR)) {
571 break;
572 }
573 }
574
575 // Finally files are added:
576 $this->export->export_addFilesFromRelations(); // MUST be after the DBrelations are set so that files from ALL added records are included!
577 // If the download button is clicked, return file
578 if ($inData['download_export'] || $inData['save_export']) {
579 switch((string)$inData['filetype']) {
580 case 'xml':
581 $out = $this->export->compileMemoryToFileContent('xml');
582 $fExt = '.xml';
583 break;
584 case 't3d':
585 $this->export->dontCompress = 1;
586 default:
587 $out = $this->export->compileMemoryToFileContent();
588 $fExt = ($this->export->doOutputCompress()?'-z':'').'.t3d';
589 break;
590 }
591
592 // Filename:
593 $dlFile = $inData['filename'] ? $inData['filename'] : 'T3D_'.substr(preg_replace('/[^[:alnum:]_]/','-',$inData['download_export_name']),0,20).'_'.date('d-m-H-i-s').$fExt;
594
595 // Export for download:
596 if ($inData['download_export']) {
597 $mimeType = 'application/octet-stream';
598 Header('Content-Type: '.$mimeType);
599 Header('Content-Length: '.strlen($out));
600 Header('Content-Disposition: attachment; filename='.basename($dlFile));
601
602 echo $out;
603 exit;
604 }
605
606 // Export by saving:
607 if ($inData['save_export']) {
608 $savePath = $this->userSaveFolder();
609 $fullName = $savePath.$dlFile;
610
611 if (t3lib_div::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && t3lib_div::isAllowedAbsPath($fullName)) {
612 t3lib_div::writeFile($fullName, $out);
613 $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);
614 } else {
615 $this->content.= $this->doc->section($LANG->getLL('exportdata_problemsSavingFile'),sprintf($LANG->getLL('exportdata_badPathS',1),$fullName),0,1,2);
616 }
617 }
618 }
619
620
621 // OUTPUT to BROWSER:
622 // Now, if we didn't make download file, show configuration form based on export:
623 $menuItems = array();
624
625 // Export configuration
626 $row = array();
627 $this->makeConfigurationForm($inData, $row);
628 $menuItems[] = array(
629 'label' => $LANG->getLL('tableselec_configuration'),
630 'content' => '
631 <table border="0" cellpadding="1" cellspacing="1">
632 '.implode('
633 ',$row).'
634 </table>
635 '
636 );
637
638 // File options
639 $row = array();
640 $this->makeSaveForm($inData, $row);
641 $menuItems[] = array(
642 'label' => $LANG->getLL('exportdata_filePreset'),
643 'content' => '
644 <table border="0" cellpadding="1" cellspacing="1">
645 '.implode('
646 ',$row).'
647 </table>
648 '
649 );
650
651 // File options
652 $row = array();
653 $this->makeAdvancedOptionsForm($inData, $row);
654 $menuItems[] = array(
655 'label' => $LANG->getLL('exportdata_advancedOptions'),
656 'content' => '
657 <table border="0" cellpadding="1" cellspacing="1">
658 '.implode('
659 ',$row).'
660 </table>
661 '
662 );
663
664 // Generate overview:
665 $overViewContent = $this->export->displayContentOverview();
666
667 // Print errors that might be:
668 $errors = $this->export->printErrorLog();
669 $menuItems[] = array(
670 'label' => $LANG->getLL('exportdata_messages'),
671 'content' => $errors,
672 'stateIcon' => $errors ? 2 : 0
673 );
674
675 // Add hidden fields and create tabs:
676 $content = $this->doc->getDynTabMenu($menuItems,'tx_impexp_export',-1);
677 $content.= '<input type="hidden" name="tx_impexp[action]" value="export" />';
678 $this->content.= $this->doc->section('',$content,0,1);
679
680 // Output Overview:
681 $this->content.= $this->doc->section($LANG->getLL('execlistqu_structureToBeExported'),$overViewContent,0,1);
682
683 }
684
685 /**
686 * Adds records to the export object for a specific page id.
687 *
688 * @param integer Page id for which to select records to add
689 * @param array Array of table names to select from
690 * @param integer Max amount of records to select
691 * @return void
692 */
693 function addRecordsForPid($k, $tables, $maxNumber) {
694 global $TCA;
695
696 if (is_array($tables)) {
697 foreach ($TCA as $table => $value) {
698 if ($table!='pages' && (in_array($table,$tables) || in_array('_ALL',$tables))) {
699 if ($GLOBALS['BE_USER']->check('tables_select',$table) && !$TCA[$table]['ctrl']['is_static']) {
700 $res = $this->exec_listQueryPid($table,$k,t3lib_div::intInRange($maxNumber,1));
701 while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
702 $this->export->export_addRecord($table,$subTrow);
703 }
704 }
705 }
706 }
707 }
708 }
709
710 /**
711 * Selects records from table / pid
712 *
713 * @param string Table to select from
714 * @param integer Page ID to select from
715 * @param integer Max number of records to select
716 * @return pointer SQL resource pointer
717 */
718 function exec_listQueryPid($table,$pid,$limit) {
719 global $TCA, $LANG;
720
721 $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
722 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
723 '*',
724 $table,
725 'pid='.intval($pid).
726 t3lib_BEfunc::deleteClause($table).
727 t3lib_BEfunc::versioningPlaceholderClause($table),
728 '',
729 $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
730 $limit
731 );
732
733 // Warning about hitting limit:
734 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == $limit) {
735 $this->content.= $this->doc->section($LANG->getLL('execlistqu_maxNumberLimit'),sprintf($LANG->getLL('makeconfig_anSqlQueryReturned',1),$limit),0,1, 2);
736 }
737
738 return $res;
739 }
740
741 /**
742 * Create configuration form
743 *
744 * @param array Form configurat data
745 * @param array Table row accumulation variable. This is filled with table rows.
746 * @return void Sets content in $this->content
747 */
748 function makeConfigurationForm($inData, &$row) {
749 global $LANG;
750
751 $nameSuggestion = '';
752
753 // Page tree export options:
754 if (isset($inData['pagetree']['id'])) {
755
756 $nameSuggestion.= 'tree_PID'.$inData['pagetree']['id'].'_L'.$inData['pagetree']['levels'];
757
758 $row[] = '
759 <tr class="tableheader bgColor5">
760 <td colspan="2">'.$LANG->getLL('makeconfig_exportPagetreeConfiguration',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeCfg', $GLOBALS['BACK_PATH'],'').'</td>
761 </tr>';
762
763 $row[] = '
764 <tr class="bgColor4">
765 <td><strong>'.$LANG->getLL('makeconfig_pageId',1).'</strong></td>
766 <td>'.htmlspecialchars($inData['pagetree']['id']).
767 '<input type="hidden" value="'.htmlspecialchars($inData['pagetree']['id']).'" name="tx_impexp[pagetree][id]" /></td>
768 </tr>';
769
770 $row[] = '
771 <tr class="bgColor4">
772 <td><strong>'.$LANG->getLL('makeconfig_tree',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeDisplay', $GLOBALS['BACK_PATH'],'').'</td>
773 <td>'.($this->treeHTML ? $this->treeHTML : $LANG->getLL('makeconfig_noTreeExportedOnly',1)).'</td>
774 </tr>';
775
776 $opt = array(
777 '-2' => $LANG->getLL('makeconfig_tablesOnThisPage'),
778 '-1' => $LANG->getLL('makeconfig_expandedTree'),
779 '0' => $LANG->getLL('makeconfig_onlyThisPage'),
780 '1' => $LANG->getLL('makeconfig_1Level'),
781 '2' => $LANG->getLL('makeconfig_2Levels'),
782 '3' => $LANG->getLL('makeconfig_3Levels'),
783 '4' => $LANG->getLL('makeconfig_4Levels'),
784 '999' => $LANG->getLL('makeconfig_infinite')
785 );
786 $row[] = '
787 <tr class="bgColor4">
788 <td><strong>'.$LANG->getLL('makeconfig_levels',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeMode', $GLOBALS['BACK_PATH'],'').'</td>
789 <td>'.$this->renderSelectBox('tx_impexp[pagetree][levels]',$inData['pagetree']['levels'],$opt).'</td>
790 </tr>';
791
792 $row[] = '
793 <tr class="bgColor4">
794 <td><strong>'.$LANG->getLL('makeconfig_includeTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeRecordLimit', $GLOBALS['BACK_PATH'],'').'</td>
795 <td>'.$this->tableSelector('tx_impexp[pagetree][tables]',$inData['pagetree']['tables'],'pages').'<br/>
796 '.$LANG->getLL('makeconfig_maxNumberOfRecords',1).'<br/>
797 <input type="text" name="tx_impexp[pagetree][maxNumber]" value="'.htmlspecialchars($inData['pagetree']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/>
798 </td>
799 </tr>';
800 }
801
802 // Single record export:
803 if (is_array($inData['record'])) {
804 $row[] = '
805 <tr class="tableheader bgColor5">
806 <td colspan="2">'.$LANG->getLL('makeconfig_exportSingleRecord',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'singleRecord', $GLOBALS['BACK_PATH'],'').'</td>
807 </tr>';
808 foreach($inData['record'] as $ref) {
809 $rParts = explode(':', $ref);
810 $tName = $rParts[0];
811 $rUid = $rParts[1];
812 $nameSuggestion.= $tName.'_'.$rUid;
813 $rec = t3lib_BEfunc::getRecordWSOL($tName,$rUid);
814
815 $row[] = '
816 <tr class="bgColor4">
817 <td><strong>'.$LANG->getLL('makeconfig_record',1).'</strong></td>
818 <td>'.t3lib_iconworks::getIconImage($tName,$rec,$GLOBALS['BACK_PATH'],' align="top"').
819 t3lib_BEfunc::getRecordTitle($tName,$rec,TRUE).
820 '<input type="hidden" name="tx_impexp[record][]" value="'.htmlspecialchars($tName.':'.$rUid).'" /></td>
821 </tr>';
822 }
823 }
824
825 // Single tables/pids:
826 if (is_array($inData['list'])) {
827 $row[] = '
828 <tr class="tableheader bgColor5">
829 <td colspan="2">'.$LANG->getLL('makeconfig_exportTablesFromPages',1).'</td>
830 </tr>';
831
832 $tblList = '';
833 foreach($inData['list'] as $ref) {
834 $rParts = explode(':', $ref);
835 $tName = $rParts[0];
836
837 if ($GLOBALS['BE_USER']->check('tables_select',$tName)) {
838 $rec = t3lib_BEfunc::getRecordWSOL('pages', $rParts[1]);
839 $tblList.='Table "'.$tName.'" from '.t3lib_iconworks::getIconImage('pages',$rec,$GLOBALS['BACK_PATH'],' align="top"').
840 t3lib_BEfunc::getRecordTitle('pages',$rec,TRUE).
841 '<input type="hidden" name="tx_impexp[list][]" value="'.htmlspecialchars($ref).'" /><br/>';
842 }
843 }
844 $row[] = '
845 <tr class="bgColor4">
846 <td><strong>'.$LANG->getLL('makeconfig_tablePids',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableList', $GLOBALS['BACK_PATH'],'').'</td>
847 <td>'.$tblList.'</td>
848 </tr>';
849
850 $row[] = '
851 <tr class="bgColor4">
852 <td><strong>'.$LANG->getLL('makeconfig_maxNumberOfRecords',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableListMaxNumber', $GLOBALS['BACK_PATH'],'').'</strong></td>
853 <td>
854 <input type="text" name="tx_impexp[listCfg][maxNumber]" value="'.htmlspecialchars($inData['listCfg']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/>
855 </td>
856 </tr>';
857 }
858
859
860 $row[] = '
861 <tr class="tableheader bgColor5">
862 <td colspan="2">'.$LANG->getLL('makeconfig_relationsAndExclusions',1).'</td>
863 </tr>';
864
865 // Add relation selector:
866 $row[] = '
867 <tr class="bgColor4">
868 <td><strong>'.$LANG->getLL('makeconfig_includeRelationsToTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'inclRelations', $GLOBALS['BACK_PATH'],'').'</td>
869 <td>'.$this->tableSelector('tx_impexp[external_ref][tables]',$inData['external_ref']['tables']).'</td>
870 </tr>';
871
872 // Add static relation selector:
873 $row[] = '
874 <tr class="bgColor4">
875 <td><strong>'.$LANG->getLL('makeconfig_useStaticRelationsFor',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'staticRelations', $GLOBALS['BACK_PATH'],'').'</td>
876 <td>'.$this->tableSelector('tx_impexp[external_static][tables]',$inData['external_static']['tables']).'<br/>
877 <label for="checkShowStaticRelations">'.$LANG->getLL('makeconfig_showStaticRelations',1).'</label> <input type="checkbox" name="tx_impexp[showStaticRelations]" id="checkShowStaticRelations" value="1"'.($inData['showStaticRelations'] ? ' checked="checked"' : '').' />
878 </td>
879 </tr>';
880
881 // Exclude:
882 $excludeHiddenFields = '';
883 if (is_array($inData['exclude'])) {
884 foreach($inData['exclude'] as $key => $value) {
885 $excludeHiddenFields.= '<input type="hidden" name="tx_impexp[exclude]['.$key.']" value="1" />';
886 }
887 }
888 $row[] = '
889 <tr class="bgColor4">
890 <td><strong>'.$LANG->getLL('makeconfig_excludeElements',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'excludedElements', $GLOBALS['BACK_PATH'],'').'</td>
891 <td>'.$excludeHiddenFields.'
892 '.(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)).'
893 </td>
894 </tr>';
895
896
897 // Add buttons:
898 $row[] = '
899 <tr class="bgColor4">
900 <td>&nbsp;</td>
901 <td>
902 <input type="submit" value="'.$LANG->getLL('makeadvanc_update',1).'" />
903 <input type="hidden" name="tx_impexp[download_export_name]" value="'.substr($nameSuggestion,0,30).'" />
904 </td>
905 </tr>';
906
907 }
908
909 /**
910 * Create advanced options form
911 *
912 * @param array Form configurat data
913 * @param array Table row accumulation variable. This is filled with table rows.
914 * @return void Sets content in $this->content
915 */
916 function makeAdvancedOptionsForm($inData, &$row) {
917 global $LANG;
918
919 // Soft references
920 $row[] = '
921 <tr class="tableheader bgColor5">
922 <td colspan="2">'.$LANG->getLL('makeadvanc_softReferences',1).'</td>
923 </tr>';
924 $row[] = '
925 <tr class="bgColor4">
926 <td><label for="checkExcludeHTMLfileResources"><strong>'.$LANG->getLL('makeadvanc_excludeHtmlCssFile',1).'</strong></label>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'htmlCssResources', $GLOBALS['BACK_PATH'],'').'</td>
927 <td><input type="checkbox" name="tx_impexp[excludeHTMLfileResources]" id="checkExcludeHTMLfileResources" value="1"'.($inData['excludeHTMLfileResources'] ? ' checked="checked"' : '').' /></td>
928 </tr>';
929
930
931 // Extensions
932 $row[] = '
933 <tr class="tableheader bgColor5">
934 <td colspan="2">'.$LANG->getLL('makeadvanc_extensionDependencies',1).'</td>
935 </tr>';
936 $row[] = '
937 <tr class="bgColor4">
938 <td><strong>'.$LANG->getLL('makeadvanc_selectExtensionsThatThe',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'extensionDependencies', $GLOBALS['BACK_PATH'],'').'</td>
939 <td>'.$this->extensionSelector('tx_impexp[extension_dep]',$inData['extension_dep']).'</td>
940 </tr>';
941
942
943
944 // Add buttons:
945 $row[] = '
946 <tr class="bgColor4">
947 <td>&nbsp;</td>
948 <td>
949 <input type="submit" value="'.$LANG->getLL('makesavefo_update',1).'" />
950 <input type="hidden" name="tx_impexp[download_export_name]" value="'.substr($nameSuggestion,0,30).'" />
951 </td>
952 </tr>';
953
954
955 }
956
957 /**
958 * Create configuration form
959 *
960 * @param array Form configurat data
961 * @param array Table row accumulation variable. This is filled with table rows.
962 * @return void Sets content in $this->content
963 */
964 function makeSaveForm($inData, &$row) {
965 global $LANG;
966
967 // Presets:
968 $row[] = '
969 <tr class="tableheader bgColor5">
970 <td colspan="2">'.$LANG->getLL('makesavefo_presets',1).'</td>
971 </tr>';
972
973 $opt = array('');
974 $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
975 '*',
976 'tx_impexp_presets',
977 '(public>0 OR user_uid='.intval($GLOBALS['BE_USER']->user['uid']).')'.
978 ($inData['pagetree']['id'] ? ' AND (item_uid='.intval($inData['pagetree']['id']).' OR item_uid=0)' : '')
979
980 );
981 if (is_array($presets)) {
982 foreach($presets as $presetCfg) {
983 $opt[$presetCfg['uid']] = $presetCfg['title'].' ['.$presetCfg['uid'].']'.
984 ($presetCfg['public'] ? ' [Public]' : '').
985 ($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? ' [Own]' : '');
986 }
987 }
988
989 $row[] = '
990 <tr class="bgColor4">
991 <td><strong>'.$LANG->getLL('makesavefo_presets',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'presets', $GLOBALS['BACK_PATH'],'').'</td>
992 <td>
993 '.$LANG->getLL('makesavefo_selectPreset',1).'<br/>
994 '.$this->renderSelectBox('preset[select]','',$opt).'
995 <br/>
996 <input type="submit" value="'.$LANG->getLL('makesavefo_load',1).'" name="preset[load]" />
997 <input type="submit" value="'.$LANG->getLL('makesavefo_save',1).'" name="preset[save]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
998 <input type="submit" value="'.$LANG->getLL('makesavefo_delete',1).'" name="preset[delete]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
999 <input type="submit" value="'.$LANG->getLL('makesavefo_merge',1).'" name="preset[merge]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
1000 <br/>
1001 '.$LANG->getLL('makesavefo_titleOfNewPreset',1).'
1002 <input type="text" name="tx_impexp[preset][title]" value="'.htmlspecialchars($inData['preset']['title']).'"'.$this->doc->formWidth(30).' /><br/>
1003 <label for="checkPresetPublic">'.$LANG->getLL('makesavefo_public',1).'</label>
1004 <input type="checkbox" name="tx_impexp[preset][public]" id="checkPresetPublic" value="1"'.($inData['preset']['public'] ? ' checked="checked"' : '').' /><br/>
1005 </td>
1006 </tr>';
1007
1008 // Output options:
1009 $row[] = '
1010 <tr class="tableheader bgColor5">
1011 <td colspan="2">'.$LANG->getLL('makesavefo_outputOptions',1).'</td>
1012 </tr>';
1013
1014 // Meta data:
1015 $tempDir = $this->userTempFolder();
1016 if ($tempDir) {
1017 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg');
1018 array_unshift($thumbnails,'');
1019 } else $thumbnails = FALSE;
1020 $row[] = '
1021 <tr class="bgColor4">
1022 <td><strong>'.$LANG->getLL('makesavefo_metaData',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'metadata', $GLOBALS['BACK_PATH'],'').'</td>
1023 <td>
1024 '.$LANG->getLL('makesavefo_title',1).' <br/>
1025 <input type="text" name="tx_impexp[meta][title]" value="'.htmlspecialchars($inData['meta']['title']).'"'.$this->doc->formWidth(30).' /><br/>
1026 '.$LANG->getLL('makesavefo_description',1).' <br/>
1027 <input type="text" name="tx_impexp[meta][description]" value="'.htmlspecialchars($inData['meta']['description']).'"'.$this->doc->formWidth(30).' /><br/>
1028 '.$LANG->getLL('makesavefo_notes',1).' <br/>
1029 <textarea name="tx_impexp[meta][notes]"'.$this->doc->formWidth(30,1).'>'.t3lib_div::formatForTextarea($inData['meta']['notes']).'</textarea><br/>
1030 '.(is_array($thumbnails) ? '
1031 '.$LANG->getLL('makesavefo_thumbnail',1).'<br/>
1032 '.$this->renderSelectBox('tx_impexp[meta][thumbnail]',$inData['meta']['thumbnail'],$thumbnails).'<br/>
1033 '.($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/>' : '').'
1034 '.$LANG->getLL('makesavefo_uploadThumbnail',1).'<br/>
1035 <input type="file" name="upload_1" '.$this->doc->formWidth(30).' size="30" /><br/>
1036 <input type="hidden" name="file[upload][1][target]" value="'.htmlspecialchars($tempDir).'" />
1037 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
1038 ' : '').'
1039 </td>
1040 </tr>';
1041
1042 // Add file options:
1043 $savePath = $this->userSaveFolder();
1044 $opt = array();
1045 if ($this->export->compress) {
1046 $opt['t3d_compressed'] = $LANG->getLL('makesavefo_t3dFileCompressed');
1047 }
1048 $opt['t3d'] = $LANG->getLL('makesavefo_t3dFile');
1049 $opt['xml'] = $LANG->getLL('makesavefo_xml');
1050 $row[] = '
1051 <tr class="bgColor4">
1052 <td><strong>'.$LANG->getLL('makesavefo_fileFormat',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'fileFormat', $GLOBALS['BACK_PATH'],'').'</td>
1053 <td>'.$this->renderSelectBox('tx_impexp[filetype]',$inData['filetype'],$opt).'<br/>
1054 '.$LANG->getLL('makesavefo_maxSizeOfFiles',1).'<br/>
1055 <input type="text" name="tx_impexp[maxFileSize]" value="'.htmlspecialchars($inData['maxFileSize']).'"'.$this->doc->formWidth(10).' /><br/>
1056 '.($savePath ? sprintf($LANG->getLL('makesavefo_filenameSavedInS',1),substr($savePath,strlen(PATH_site))).'<br/>
1057 <input type="text" name="tx_impexp[filename]" value="'.htmlspecialchars($inData['filename']).'"'.$this->doc->formWidth(30).' /><br/>' : '').'
1058 </td>
1059 </tr>';
1060
1061
1062 // Add buttons:
1063 $row[] = '
1064 <tr class="bgColor4">
1065 <td>&nbsp;</td>
1066 <td><input type="submit" value="'.$LANG->getLL('makesavefo_update',1).'" /> - <input type="submit" value="'.$LANG->getLL('makesavefo_downloadExport',1).'" name="tx_impexp[download_export]" />'.
1067 ($savePath ? ' - <input type="submit" value="'.$LANG->getLL('importdata_saveToFilename',1).'" name="tx_impexp[save_export]" />' : '').'</td>
1068 </tr>';
1069 }
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083 /**************************
1084 *
1085 * IMPORT FUNCTIONS
1086 *
1087 **************************/
1088
1089 /**
1090 * Import part of module
1091 *
1092 * @param array Content of POST VAR tx_impexp[]..
1093 * @return void Setting content in $this->content
1094 */
1095 function importData($inData) {
1096 global $TCA,$LANG,$BE_USER;
1097
1098 $access = is_array($this->pageinfo) ? 1 : 0;
1099
1100 if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id)) {
1101 if ($BE_USER->user['admin'] && !$this->id) {
1102 $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0);
1103 }
1104
1105 if ($inData['new_import']) {
1106 unset($inData['import_mode']);
1107 }
1108
1109 $import = t3lib_div::makeInstance('tx_impexp');
1110 $import->init(0,'import');
1111 $import->update = $inData['do_update'];
1112 $import->import_mode = $inData['import_mode'];
1113 $import->enableLogging = $inData['enableLogging'];
1114 $import->global_ignore_pid = $inData['global_ignore_pid'];
1115 $import->force_all_UIDS = $inData['force_all_UIDS'];
1116 $import->showDiff = !$inData['notShowDiff'];
1117 $import->allowPHPScripts = $inData['allowPHPScripts'];
1118 $import->softrefInputValues = $inData['softrefInputValues'];
1119
1120
1121 // OUTPUT creation:
1122 $menuItems = array();
1123
1124 // Make input selector:
1125 $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']; // must have trailing slash.
1126 $filesInDir = t3lib_div::getFilesInDir(PATH_site.$path, 't3d,xml', 1, 1);
1127
1128 $userPath = $this->userSaveFolder(); //Files from User-Dir
1129 $filesInUserDir = t3lib_div::getFilesInDir($userPath, 't3d,xml', 1, 1);
1130
1131 $filesInDir = array_merge($filesInUserDir, $filesInDir);
1132
1133 if (is_dir(PATH_site.$path.'export/')) {
1134 $filesInDir = array_merge($filesInDir, t3lib_div::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1));
1135 }
1136 $tempFolder = $this->userTempFolder();
1137 if ($tempFolder) {
1138 $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder, 't3d,xml', 1, 1);
1139 $filesInDir = array_merge($filesInDir, $temp_filesInDir);
1140 }
1141
1142 // Configuration
1143 $row = array();
1144 $opt = array('');
1145 foreach($filesInDir as $file) {
1146 $opt[$file] = substr($file,strlen(PATH_site));
1147 }
1148
1149 $row[] = '<tr class="bgColor5">
1150 <td colspan="2"><strong>'.$LANG->getLL('importdata_selectFileToImport',1).'</strong></td>
1151 </tr>';
1152
1153 $row[] = '<tr class="bgColor4">
1154 <td><strong>'.$LANG->getLL('importdata_file',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'],'').'</td>
1155 <td>'.
1156 $this->renderSelectBox('tx_impexp[file]',$inData['file'],$opt).'<br />'.sprintf($LANG->getLL('importdata_fromPathS',1),$path).
1157 (!$import->compress ? '<br /><span class="typo3-red">'.$LANG->getLL('importdata_noteNoDecompressorAvailable',1).'</span>':'').
1158 '</td>
1159 </tr>';
1160
1161 $row[] = '<tr class="bgColor5">
1162 <td colspan="2"><strong>'.$LANG->getLL('importdata_importOptions',1).'</strong></td>
1163 </tr>';
1164
1165 $row[] = '<tr class="bgColor4">
1166 <td><strong>'.$LANG->getLL('importdata_update',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'],'').'</td>
1167 <td>
1168 <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"'.($inData['do_update'] ? ' checked="checked"' : '').' />
1169 <label for="checkDo_update">'.$LANG->getLL('importdata_updateRecords',1).'</label><br/>
1170 <em>('.$LANG->getLL('importdata_thisOptionRequiresThat',1).')</em>'.
1171 ($inData['do_update'] ?
1172 ' <hr/>
1173 <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"'.($inData['global_ignore_pid'] ? ' checked="checked"' : '').' />
1174 <label for="checkGlobal_ignore_pid">'.$LANG->getLL('importdata_ignorePidDifferencesGlobally',1).'</label><br/>
1175 <em>('.$LANG->getLL('importdata_ifYouSetThis',1).')</em>
1176 ' : ''
1177 ).'</td>
1178 </tr>';
1179
1180 $row[] = '<tr class="bgColor4">
1181 <td><strong>'.$LANG->getLL('importdata_options',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'],'').'</td>
1182 <td>
1183 <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"'.($inData['notShowDiff'] ? ' checked="checked"' : '').' />
1184 <label for="checkNotShowDiff">'.$LANG->getLL('importdata_doNotShowDifferences',1).'</label><br/>
1185 <em>('.$LANG->getLL('importdata_greenValuesAreFrom',1).')</em>
1186 <br/><br/>
1187
1188 '.($GLOBALS['BE_USER']->isAdmin() ? '
1189 <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"'.($inData['allowPHPScripts'] ? ' checked="checked"' : '').' />
1190 <label for="checkAllowPHPScripts">'.$LANG->getLL('importdata_allowToWriteBanned',1).'</label><br/>' : '').
1191
1192 (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? '
1193 <br/>
1194 <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"'.($inData['force_all_UIDS'] ? ' checked="checked"' : '').' />
1195 <label for="checkForce_all_UIDS"><span class="typo3-red">'.$LANG->getLL('importdata_force_all_UIDS',1).'</span></label><br/>
1196 <em>('.$LANG->getLL('importdata_force_all_UIDS_descr',1).')</em>' : '').
1197 '
1198 </td>
1199 </tr>';
1200
1201 $row[] = '<tr class="bgColor4">
1202 <td><strong>'.$LANG->getLL('importdata_action',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'],'').'</td>
1203 <td>'.
1204 (!$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).'" />').'
1205 <input type="hidden" name="tx_impexp[action]" value="import" /></td>
1206 </tr>';
1207
1208 $row[] = '<tr class="bgColor4">
1209 <td><strong>'.$LANG->getLL('importdata_enableLogging',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'],'').'</td>
1210 <td>
1211 <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"'.($inData['enableLogging'] ? ' checked="checked"' : '').' />
1212 <label for="checkEnableLogging">'.$LANG->getLL('importdata_writeIndividualDbActions',1).'</label><br/>
1213 <em>('.$LANG->getLL('importdata_thisIsDisabledBy',1).')</em>
1214 </td>
1215 </tr>';
1216
1217 $menuItems[] = array(
1218 'label' => $LANG->getLL('importdata_import',1),
1219 'content' => '
1220 <table border="0" cellpadding="1" cellspacing="1">
1221 '.implode('
1222 ',$row).'
1223 </table>
1224 '
1225 );
1226
1227 // Upload file:
1228 $tempFolder = $this->userTempFolder();
1229 if ($tempFolder) {
1230 $row = array();
1231
1232 $row[] = '<tr class="bgColor5">
1233 <td colspan="2"><strong>'.$LANG->getLL('importdata_uploadFileFromLocal',1).'</strong></td>
1234 </tr>';
1235
1236 $row[] = '<tr class="bgColor4">
1237 <td>'.$LANG->getLL('importdata_browse',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'],'').'</td>
1238 <td>
1239
1240 <input type="file" name="upload_1"'.$this->doc->formWidth(35).' size="40" />
1241 <input type="hidden" name="file[upload][1][target]" value="'.htmlspecialchars($tempFolder).'" />
1242 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
1243
1244 <input type="submit" name="_upload" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />
1245 <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>
1246 </td>
1247 </tr>';
1248
1249 if (t3lib_div::_POST('_upload')) {
1250 $row[] = '<tr class="bgColor4">
1251 <td>'.$LANG->getLL('importdata_uploadStatus',1).'</td>
1252 <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>
1253 </tr>';
1254 }
1255
1256 $menuItems[] = array(
1257 'label' => $LANG->getLL('importdata_upload'),
1258 'content' => '
1259 <table border="0" cellpadding="1" cellspacing="1">
1260 '.implode('
1261 ',$row).'
1262 </table>
1263 '
1264 );
1265 }
1266
1267
1268 // Perform import or preview depending:
1269 $overviewContent = '';
1270 $extensionInstallationMessage = '';
1271 $emURL = '';
1272 $inFile = t3lib_div::getFileAbsFileName($inData['file']);
1273 if ($inFile && @is_file($inFile)) {
1274 $trow = array();
1275 if ($import->loadFile($inFile,1)) {
1276
1277 // Check extension dependencies:
1278 $extKeysToInstall = array();
1279 if (is_array($import->dat['header']['extensionDependencies'])) {
1280 foreach($import->dat['header']['extensionDependencies'] as $extKey) {
1281 if (!t3lib_extMgm::isLoaded($extKey)) {
1282 $extKeysToInstall[] = $extKey;
1283 }
1284 }
1285 }
1286
1287 if (count($extKeysToInstall)) {
1288 $passParams = t3lib_div::_POST('tx_impexp');
1289 unset($passParams['import_mode']);
1290 unset($passParams['import_file']);
1291
1292 $thisScriptUrl = t3lib_div::getIndpEnv('REQUEST_URI').'?M=xMOD_tximpexp&id='.$this->id.t3lib_div::implodeArrayForUrl('tx_impexp',$passParams);
1293 $emURL = $this->doc->backPath.'mod/tools/em/index.php?CMD[requestInstallExtensions]='.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 "'.$inData['preset']['title'].'" is created';
1456 }
1457 }
1458
1459 // Delete preset:
1460 if (isset($presetData['delete'])) {
1461 $preset = $this->getPreset($presetData['select']);
1462 if (is_array($preset)) { // Update existing
1463 if ($GLOBALS['BE_USER']->isAdmin() || $preset['user_uid'] === $GLOBALS['BE_USER']->user['uid']) {
1464 $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_impexp_presets','uid='.intval($preset['uid']));
1465 $msg = 'Preset #'.$preset['uid'].' deleted!';
1466 } else {
1467 $msg = 'ERROR: You were not the owner of the preset so you could not delete it.';
1468 $err = TRUE;
1469 }
1470 } else {
1471 $msg = 'ERROR: No preset selected for deletion.';
1472 $err = TRUE;
1473 }
1474 }
1475
1476 // Load preset
1477 if (isset($presetData['load']) || isset($presetData['merge'])) {
1478 $preset = $this->getPreset($presetData['select']);
1479 if (is_array($preset)) { // Update existing
1480 $inData_temp = unserialize($preset['preset_data']);
1481 if (is_array($inData_temp)) {
1482 if (isset($presetData['merge'])) {
1483
1484 // Merge records in:
1485 if (is_array($inData_temp['record'])) {
1486 $inData['record'] = array_merge((array)$inData['record'], $inData_temp['record']);
1487 }
1488
1489 // Merge lists in:
1490 if (is_array($inData_temp['list'])) {
1491 $inData['list'] = array_merge((array)$inData['list'], $inData_temp['list']);
1492 }
1493 } else {
1494 $msg = 'Preset #'.$preset['uid'].' loaded!';
1495 $inData = $inData_temp;
1496 }
1497 } else {
1498 $msg = 'ERROR: No configuratio data found in preset record!';
1499 $err = TRUE;
1500 }
1501 } else {
1502 $msg = 'ERROR: No preset selected for loading.';
1503 $err = TRUE;
1504 }
1505 }
1506
1507 // Show message:
1508 if (strlen($msg)) {
1509 $this->content.= $this->doc->section('Presets',$msg,0,1,$err ? 3 : 1);
1510 }
1511 }
1512
1513 /**
1514 * Get single preset record
1515 *
1516 * @param integer Preset record
1517 * @return array Preset record, if any (otherwise false)
1518 */
1519 function getPreset($uid) {
1520 list($preset) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_impexp_presets','uid='.intval($uid));
1521 return $preset;
1522 }
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534 /****************************
1535 *
1536 * Helper functions
1537 *
1538 ****************************/
1539
1540 /**
1541 * Returns first temporary folder of the user account (from $FILEMOUNTS)
1542 *
1543 * @return string Absolute path to first "_temp_" folder of the current user, otherwise blank.
1544 */
1545 function userTempFolder() {
1546 global $FILEMOUNTS;
1547
1548 foreach($FILEMOUNTS as $filePathInfo) {
1549 $tempFolder = $filePathInfo['path'].'_temp_/';
1550 if (@is_dir($tempFolder)) {
1551 return $tempFolder;
1552 }
1553 }
1554 }
1555
1556 /**
1557 * Returns folder where user can save export files.
1558 *
1559 * @return string Absolute path to folder where export files can be saved.
1560 */
1561 function userSaveFolder() {
1562 global $FILEMOUNTS;
1563
1564 reset($FILEMOUNTS);
1565 $filePathInfo = current($FILEMOUNTS);
1566
1567 if (is_array($filePathInfo)) {
1568 $tempFolder = $filePathInfo['path'].'export/';
1569 if (!@is_dir($tempFolder)) {
1570 $tempFolder = $filePathInfo['path'];
1571 if (!@is_dir($tempFolder)) {
1572 return FALSE;
1573 }
1574 }
1575 return $tempFolder;
1576 }
1577 }
1578
1579 /**
1580 * Check if a file has been uploaded
1581 *
1582 * @return void
1583 */
1584 function checkUpload() {
1585 global $FILEMOUNTS,$TYPO3_CONF_VARS,$BE_USER;
1586
1587 $file = t3lib_div::_GP('file');
1588
1589 // Initializing:
1590 $this->fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
1591 $this->fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
1592 $this->fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
1593 $this->fileProcessor->dontCheckForUnique = t3lib_div::_GP('overwriteExistingFiles') ? 1 : 0;
1594
1595 // Checking referer / executing:
1596 $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
1597 $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
1598 if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer']) {
1599 $this->fileProcessor->writeLog(0,2,1,'Referer host "%s" and server host "%s" did not match!',array($refInfo['host'],$httpHost));
1600 } else {
1601 $this->fileProcessor->start($file);
1602 $this->fileProcessor->processData();
1603 }
1604 }
1605
1606 /**
1607 * Makes a selector-box from optValues
1608 *
1609 * @param string Form element name
1610 * @param string Current value
1611 * @param array Options to display (key/value pairs)
1612 * @return string HTML select element
1613 */
1614 function renderSelectBox($prefix,$value,$optValues) {
1615 $opt = array();
1616 $isSelFlag = 0;
1617 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 => $value) {
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') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php']) {
1718 include_once($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 ?>