00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00065 unset($MCONF);
00066 require ('conf.php');
00067 require ($BACK_PATH.'init.php');
00068 require ($BACK_PATH.'template.php');
00069 $LANG->includeLLFile('EXT:impexp/app/locallang.php');
00070 require_once (PATH_t3lib.'class.t3lib_scbase.php');
00071 require_once (t3lib_extMgm::extPath('impexp').'class.tx_impexp.php');
00072 require_once (PATH_t3lib.'class.t3lib_browsetree.php');
00073 require_once (PATH_t3lib.'class.t3lib_pagetree.php');
00074
00075 t3lib_extMgm::isLoaded('impexp',1);
00076
00077
00078
00079
00087 class localPageTree extends t3lib_browseTree {
00088
00092 function localPageTree() {
00093 $this->init();
00094 }
00095
00103 function wrapTitle($title,$v) {
00104 $title= (!strcmp(trim($title),'')) ? '<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</em>' : htmlspecialchars($title);
00105 return $title;
00106 }
00107
00116 function PM_ATagWrap($icon,$cmd,$bMark='') {
00117 return $icon;
00118 }
00119
00127 function wrapIcon($icon,$row) {
00128 return $icon;
00129 }
00130
00136 function permsC() {
00137 return $this->BE_USER->getPagePermsClause(1);
00138 }
00139
00146 function ext_tree($pid) {
00147 $this->init(' AND '.$this->permsC());
00148
00149
00150 $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
00151
00152
00153 $PM = t3lib_div::intExplode('_',t3lib_div::_GP('PM'));
00154
00155
00156 $titleLen=intval($this->BE_USER->uc['titleLen']);
00157 $treeArr=array();
00158
00159
00160 $idx=0;
00161 # $pid=1;
00162
00163
00164 $this->bank=$idx;
00165 $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
00166
00167 $curIds = $this->ids;
00168 $this->reset();
00169 $this->ids = $curIds;
00170
00171
00172 $cmd=$this->bank.'_'.($isOpen?'0_':'1_').$pid;
00173 $icon='<img src="'.$this->backPath.'t3lib/gfx/ol/'.($isOpen?'minus':'plus').'only.gif" width="18" height="16" align="top" border="0" alt="" /></a>';
00174 $firstHtml= $this->PM_ATagWrap($icon,$cmd);
00175
00176 if ($pid>0) {
00177 $rootRec=t3lib_befunc::getRecord('pages',$pid);
00178 $firstHtml.=$this->wrapIcon('<img src="'.$this->backPath.t3lib_iconWorks::getIcon('pages',$rootRec).'" width="18" height="16" align="top" alt="" />',$rootRec);
00179 } else {
00180 $rootRec=array(
00181 'title'=>$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
00182 'uid'=>0
00183 );
00184 $firstHtml.=$this->wrapIcon('<img src="'.$this->backPath.'gfx/i/_icon_website.gif" width="18" height="16" align="top" alt="" />',$rootRec);
00185 }
00186 $this->tree[]=array('HTML'=>$firstHtml,'row'=>$rootRec);
00187 if ($isOpen) {
00188
00189 $depthD='<img src="'.$this->backPath.'t3lib/gfx/ol/blank.gif" width="18" height="16" align="top" alt="" />';
00190 if ($this->addSelfId) $this->ids[] = $pid;
00191 $this->getTree($pid,999,$depthD);
00192
00193 $idH=array();
00194 $idH[$pid]['uid']=$pid;
00195 if (count($this->buffer_idH)) $idH[$pid]['subrow']=$this->buffer_idH;
00196 $this->buffer_idH=$idH;
00197
00198 }
00199
00200
00201 $treeArr=array_merge($treeArr,$this->tree);
00202
00203 return $treeArr;
00204 }
00205 }
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00227 class SC_mod_tools_log_index extends t3lib_SCbase {
00228
00229 var $pageinfo;
00230
00234 function main() {
00235 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
00236
00237 $this->checkExtObj();
00238
00239 $this->doc = t3lib_div::makeInstance('mediumDoc');
00240 $this->doc->backPath = $BACK_PATH;
00241
00242
00243 $this->doc->JScode = $this->doc->wrapScriptTags('
00244 script_ended = 0;
00245 function jumpToUrl(URL) {
00246 document.location = URL;
00247 }
00248 ');
00249
00250 $this->doc->postCode=$this->doc->wrapScriptTags('
00251 script_ended = 1;
00252 if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
00253 ');
00254 $this->doc->form='<form action="index.php" method="post"><input type="hidden" name="id" value="'.$this->id.'" />';
00255
00256 $this->content.=$this->doc->startPage($LANG->getLL('title'));
00257 $this->content.=$this->doc->header($LANG->getLL('title'));
00258 $this->content.=$this->doc->spacer(5);
00259
00260
00261 $inData = t3lib_div::_GP('tx_impexp');
00262 switch((string)$inData['action']) {
00263 case 'export':
00264 $this->exportData($inData);
00265 break;
00266 case 'import':
00267 $this->importData($inData);
00268 break;
00269 }
00270
00353 if ($BE_USER->mayMakeShortcut()) {
00354 $this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('tx_impexp','',$this->MCONF['name']));
00355 }
00356 }
00357
00363 function printContent() {
00364
00365 $this->content.=$this->doc->spacer(20);
00366 $this->content.=$this->doc->endPage();
00367 echo $this->content;
00368 }
00369
00370
00371
00372
00383 function exportData($inData) {
00384 global $TCA;
00385
00386 $this->export = t3lib_div::makeInstance('tx_impexp');
00387 $this->export->init($inData['dont_compress']);
00388 $this->export->relExclTables=array();
00389 $this->export->relOnlyTables=array();
00390
00391 if (is_array($inData['external_ref']['tables'])) {
00392 reset($TCA);
00393 while(list($table)=each($TCA)) {
00394 if (in_array($table,$inData['external_ref']['tables']) || in_array('_ALL',$inData['external_ref']['tables'])) {
00395 if ($GLOBALS['BE_USER']->check('tables_select',$table)) {
00396 $this->export->relOnlyTables[]=$table;
00397 }
00398 }
00399 }
00400 }
00401
00402
00403 if (is_array($inData['record'])) {
00404 reset($inData['record']);
00405 while(list(,$ref)=each($inData['record'])) {
00406 $rParts = explode(':',$ref);
00407 $tName=$rParts[0];
00408 $uidList=t3lib_div::trimExplode(',',$rParts[1],1);
00409 reset($uidList);
00410 while(list(,$rUid)=each($uidList)) {
00411 $this->export->export_addRecord($rParts[0],t3lib_BEfunc::getRecord($tName,$rUid));
00412 }
00413 }
00414 }
00415
00416
00417 if (is_array($inData['pagetree'])) {
00418 if ($inData['pagetree']['levels']<0) {
00419 $pagetree = t3lib_div::makeInstance('localPageTree');
00420 $tree = $pagetree->ext_tree($inData['pagetree']['id']);
00421 $this->treeHTML = $pagetree->printTree($tree);
00422
00423 $idH=$pagetree->buffer_idH;
00424 # debug($pagetree->buffer_idH);
00425 } else {
00426
00427 $sPage = t3lib_BEfunc::getRecord ('pages',$inData['pagetree']['id'],'*',' AND '.$this->perms_clause);
00428 if (is_array($sPage)) {
00429 $pid = $inData['pagetree']['id'];
00430 $tree = t3lib_div::makeInstance('t3lib_pageTree');
00431 $tree->init('AND '.$this->perms_clause);
00432
00433 $HTML='<img src="'.$GLOBALS['BACK_PATH'].t3lib_iconWorks::getIcon('pages',$sPage).'" width="18" height="16" align="top" alt="" />';
00434 $tree->tree[]=Array('row'=>$sPage,'HTML'=>$HTML);
00435 $tree->buffer_idH=array();
00436 if ($inData['pagetree']['levels']>0) $tree->getTree($pid,$inData['pagetree']['levels'],'');
00437
00438 $idH=array();
00439 $idH[$pid]['uid']=$pid;
00440 if (count($tree->buffer_idH)) $idH[$pid]['subrow']=$tree->buffer_idH;
00441
00442
00443 $pagetree = t3lib_div::makeInstance('localPageTree');
00444 $this->treeHTML = $pagetree->printTree($tree->tree);
00445
00446 # debug($idH);
00447 }
00448 }
00449
00450 if (is_array($idH)) {
00451 $flatList = $this->export->setPageTree($idH);
00452 reset($flatList);
00453 while(list($k)=each($flatList)) {
00454 $this->export->export_addRecord('pages',t3lib_BEfunc::getRecord('pages',$k));
00455
00456 if (is_array($inData['pagetree']['tables'])) {
00457 reset($TCA);
00458 while(list($table)=each($TCA)) {
00459 if ($table!='pages' && (in_array($table,$inData['pagetree']['tables']) || in_array('_ALL',$inData['pagetree']['tables']))) {
00460 if ($GLOBALS['BE_USER']->check('tables_select',$table)) {
00461 $res = $this->exec_listQueryPid($table,$k);
00462 while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
00463 $this->export->export_addRecord($table,$subTrow);
00464 }
00465 }
00466 }
00467 }
00468 }
00469 }
00470 }
00471 }
00472
00473
00474
00475 # debug($this->export->relOnlyTables);
00476 if (count($this->export->relOnlyTables)) {
00477 for($a=0;$a<10;$a++) {
00478 $addR = $this->export->export_addDBRelations($a);
00479 if (!count($addR)) break;
00480 # debug("ADDED: ".count($addR),1);
00481 }
00482 }
00483
00484
00485 $this->export->export_addFilesFromRelations();
00486
00487
00488
00489 if ($inData['download_export']) {
00490 $out = $this->export->compileMemoryToFileContent();
00491 $dlFile='T3D_'.substr(ereg_replace('[^[:alnum:]_]','-',$inData['download_export_name']),0,20).'_'.date('d-m-H-i-s').($this->export->doOutputCompress()?'-z':'').'.t3d';
00492
00493 $mimeType = 'application/octet-stream';
00494 Header('Content-Type: '.$mimeType);
00495 Header('Content-Disposition: attachment; filename='.basename($dlFile));
00496 echo $out;
00497 exit;
00498
00499 #debug(strlen($out));
00500 }
00501
00502
00503
00504
00505 $this->makeConfigurationForm($inData);
00506
00507
00508 $content=$this->export->displayContentOverview();
00509 $this->content.=$this->doc->section('Structure to be exported:',$content,0,1);
00510
00511
00512 $errors = $this->export->printErrorLog();
00513 if ($errors) $this->content.=$this->doc->section('Messages:',$errors,0,1);
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527 }
00528
00536 function exec_listQueryPid($table,$pid) {
00537 global $TCA;
00538 $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
00539 return $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, 'pid='.intval($pid).t3lib_BEfunc::deleteClause($table), '', $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy));
00540 }
00541
00548 function makeConfigurationForm($inData) {
00549 $nameSuggestion ='';
00550 if (is_array($inData['pagetree']) && $this->treeHTML) {
00551 $row=array();
00552
00553 $nameSuggestion.='tree_PID'.$inData['pagetree']['id'].'_L'.$inData['pagetree']['levels'];
00554 $row[]='<tr class="bgColor5">
00555 <td colspan=2><strong>Export pagetree configuration:</strong></td>
00556 </tr>';
00557
00558 $row[]='<tr class="bgColor4">
00559 <td><strong>Page ID:</strong></td>
00560 <td>'.htmlspecialchars($inData['pagetree']['id']).'<input type="hidden" value="'.htmlspecialchars($inData['pagetree']['id']).'" name="tx_impexp[pagetree][id]" /></td>
00561 </tr>';
00562
00563 $row[]='<tr class="bgColor4">
00564 <td><strong>Tree:</strong></td>
00565 <td>'.$this->treeHTML.'</td>
00566 </tr>';
00567
00568 $opt = array(
00569 '-1' => 'Expanded tree',
00570 '0' => 'Only this page',
00571 '1' => '1 level',
00572 '2' => '2 levels',
00573 '3' => '3 levels',
00574 '4' => '4 levels',
00575 '999' => 'Infinite'
00576 );
00577 $row[]='<tr class="bgColor4">
00578 <td><strong>Levels:</strong></td>
00579 <td>'.$this->renderSelectBox('tx_impexp[pagetree][levels]',$inData['pagetree']['levels'],$opt).'</td>
00580 </tr>';
00581
00582 $row[]='<tr class="bgColor4">
00583 <td><strong>Include tables:</strong></td>
00584 <td>'.$this->tableSelector('tx_impexp[pagetree][tables]',$inData['pagetree']['tables'],'pages').'</td>
00585 </tr>';
00586 $content.='<table border=0 cellpadding=1 cellspacing=1>'.implode('',$row).'</table>';
00587 }
00588
00589
00590
00591 if (is_array($inData['record'])) {
00592 $row[]='<tr class="bgColor5">
00593 <td colspan=2><strong>Export single record:</strong></td>
00594 </tr>';
00595 reset($inData['record']);
00596 while(list(,$ref)=each($inData['record'])) {
00597 $rParts = explode(':',$ref);
00598 $tName=$rParts[0];
00599 $uidList=t3lib_div::trimExplode(',',$rParts[1],1);
00600 reset($uidList);
00601 while(list(,$rUid)=each($uidList)) {
00602 $nameSuggestion.=$tName.'_'.$rUid;
00603 $rec = t3lib_BEfunc::getRecord($tName,$rUid);
00604
00605 $row[]='<tr class="bgColor4">
00606 <td><strong>Record:</strong></td>
00607 <td>'.t3lib_iconworks::getIconImage($tName,$rec,$GLOBALS['BACK_PATH'],' align="top"').t3lib_BEfunc::getRecordTitle($tName,$rec,1).'<input type="hidden" name="tx_impexp[record][]" value="'.htmlspecialchars($tName.':'.$rUid).'" /></td>
00608 </tr>';
00609 }
00610 }
00611 $content.='<table border=0 cellpadding=1 cellspacing=1>'.implode('',$row).'</table>';
00612 }
00613
00614
00615
00616 $content.='Include relations to tables:<br />'.$this->tableSelector('tx_impexp[external_ref][tables]',$inData['external_ref']['tables']);
00617 $content.='<hr /><input type="submit" value="Update" /> - <input type="submit" value="Download export" name="tx_impexp[download_export]" />';
00618 if ($this->export->compress) $content.='<input type="checkbox" name="tx_impexp[dont_compress]" value="1"'.($inData['dont_compress']?' checked="checked"':'').' />Don\'t compress';
00619 $content.='<input type="hidden" name="tx_impexp[download_export_name]" value="'.$nameSuggestion.'" />';
00620
00621 $content.='<input type="hidden" name="tx_impexp[action]" value="export" />';
00622 $this->content.=$this->doc->section('Export to TYPO3 Document (.t3d)',$content,0,1);
00623 }
00624
00625
00626
00627
00628
00629
00630
00641 function importData($inData) {
00642 global $TCA,$LANG;
00643
00644
00645 $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
00646 $access = is_array($this->pageinfo) ? 1 : 0;
00647
00648 if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id)) {
00649 if ($BE_USER->user['admin'] && !$this->id) {
00650 $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0);
00651 }
00652
00653 $headerSection = $this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath']).'<br />'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.path').': '.t3lib_div::fixed_lgd_cs($this->pageinfo['_thePath'],-50);
00654 $this->content.=$this->doc->section('',$headerSection);
00655
00656 $import = t3lib_div::makeInstance('tx_impexp');
00657 $import->init();
00658
00659 $row=array();
00660
00661
00662 $tempFolder = $this->userTempFolder();
00663 if ($tempFolder) {
00664 $row[]='<tr class="bgColor5">
00665 <td colspan=2><strong>Upload file:</strong></td>
00666 </tr>';
00667 $row[]='<tr class="bgColor5">
00668 <td colspan=2>
00669
00670 <!--
00671 Form, for uploading files:
00672 -->
00673 </form>
00674 <form action="'.$GLOBALS['BACK_PATH'].'tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">
00675 <input type="file" name="upload_1"'.$this->doc->formWidth(35).' size="50" />
00676 <input type="hidden" name="file[upload][1][target]" value="'.htmlspecialchars($tempFolder).'" />
00677 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
00678
00679 <input type="hidden" name="redirect" value="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'" />
00680 <input type="submit" name="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />
00681 <input type="checkbox" name="overwriteExistingFiles" value="1" checked="checked" /> '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles',1).'
00682 </form>
00683 '.$this->doc->form.'
00684 </td>
00685 </tr>';
00686
00687 $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder,'t3d',1,1);
00688 }
00689
00690
00691
00692 $path = 'fileadmin/';
00693 $filesInDir = t3lib_div::getFilesInDir(PATH_site.$path,'t3d',1,1);
00694
00695 if (is_array($temp_filesInDir)) {
00696 if (is_array($filesInDir)) {
00697 $filesInDir = array_merge($temp_filesInDir, $filesInDir);
00698 } else {
00699 $filesInDir = $temp_filesInDir;
00700 }
00701 }
00702
00703 $row[]='<tr class="bgColor5">
00704 <td colspan=2><strong>Import file:</strong></td>
00705 </tr>';
00706
00707 $opt = array('');
00708 if (is_array($filesInDir)) {
00709 while(list(,$file)=each($filesInDir)) {
00710 # $file=$path.$file;
00711 $opt[$file]= substr($file,strlen(PATH_site));
00712 }
00713 }
00714
00715 $row[]='<tr class="bgColor4">
00716 <td><strong>File:</strong></td>
00717 <td>'.$this->renderSelectBox('tx_impexp[file]',$inData['file'],$opt).'<br />(From path: '.$path.')'.
00718 (!$import->compress ? '<br /><span class="typo3-red">NOTE: No decompressor available for compressed files!</span>':'').
00719 '</td>
00720 </tr>';
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734 $content.='<table border=0 cellpadding=1 cellspacing=1>'.implode('',$row).'</table>';
00735
00736 $content.='<hr /><input type="submit" value="Preview" />';
00737 if (!$inData['import_file']) {
00738 $content.=' - <input type="submit" value="Import" name="tx_impexp[import_file]" />';
00739 }
00740 $content.='<input type="hidden" name="tx_impexp[action]" value="import" />';
00741
00742 $this->content.=$this->doc->section('Import TYPO3 Document (.t3d)',$content,0,1);
00743
00744
00745
00746 $inFile = t3lib_div::getFileAbsFileName($inData['file']);
00747 if ($inFile && @is_file($inFile)) {
00748 $import->loadFile($inFile,1);
00749
00750 # debug($import->dat['header']);
00751 if ($inData['import_file']) {
00752 $import->importData($this->id);
00753 t3lib_BEfunc::getSetUpdateSignal('updatePageTree');
00754 }
00755
00756 $import->display_import_pid_record=$this->pageinfo;
00757 $content=$import->displayContentOverview(1);
00758 $this->content.=$this->doc->section($inData['import_file']?'Structure has been imported:':'Structure to be imported:',$content,0,1);
00759
00760 $errors = $import->printErrorLog();
00761 if ($errors) $this->content.=$this->doc->section('Messages:',$errors,0,1);
00762 }
00763 }
00764
00765 }
00766
00775 function tableSelector($prefix,$value,$excludeList='') {
00776 global $TCA;
00777 reset($TCA);
00778 $optValues = array();
00779
00780 if (!t3lib_div::inList($excludeList,'_ALL')) $optValues['_ALL']='[ALL tables]';
00781
00782 while(list($table)=each($TCA)) {
00783 if ($GLOBALS['BE_USER']->check('tables_select',$table) && !t3lib_div::inList($excludeList,$table)) {
00784 $optValues[$table]=$table;
00785 }
00786 }
00787
00788
00789
00790 $opt=array();
00791 $opt[]='<option value=""></option>';
00792 reset($optValues);
00793 while(list($k,$v)=each($optValues)) {
00794 if (is_array($value)) $sel = (in_array($k,$value)?' selected="selected"':'');
00795 $opt[]='<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
00796 }
00797 return '<select name="'.$prefix.'[]" multiple size="'.t3lib_div::intInRange(count($opt),5,10).'">'.implode('',$opt).'</select>';
00798 }
00799
00808 function renderSelectBox($prefix,$value,$optValues) {
00809 $opt=array();
00810 $isSelFlag=0;
00811 reset($optValues);
00812 while(list($k,$v)=each($optValues)) {
00813 $sel = (!strcmp($k,$value)?' selected="selected"':'');
00814 if ($sel) $isSelFlag++;
00815 $opt[]='<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
00816 }
00817 if (!$isSelFlag && strcmp('',$value)) $opt[]='<option value="'.$value.'" selected="selected">'.htmlspecialchars("['".$value."']").'</option>';
00818 return '<select name="'.$prefix.'">'.implode('',$opt).'</select>';
00819 }
00820
00821
00822
00823
00829 function userTempFolder() {
00830 global $FILEMOUNTS;
00831
00832 foreach($FILEMOUNTS as $filePathInfo) {
00833 $tempFolder = $filePathInfo['path'].'_temp_/';
00834 if (@is_dir($tempFolder)) {
00835 return $tempFolder;
00836 }
00837 }
00838 }
00839 }
00840
00841
00842 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php']) {
00843 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php']);
00844 }
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
00859 $SOBE->init();
00860 $SOBE->main();
00861 $SOBE->printContent();
00862 ?>