📄 index.php
字号:
if (is_array($inData['external_ref']['tables'])) { $this->export->relOnlyTables = $inData['external_ref']['tables']; } $this->export->setHeaderBasics(); // Meta data setting: $this->export->setMetaData( $inData['meta']['title'], $inData['meta']['description'], $inData['meta']['notes'], $GLOBALS['BE_USER']->user['username'], $GLOBALS['BE_USER']->user['realName'], $GLOBALS['BE_USER']->user['email'] ); if ($inData['meta']['thumbnail']) { $tempDir = $this->userTempFolder(); if ($tempDir) { $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1); $theThumb = $thumbnails[$inData['meta']['thumbnail']]; if ($theThumb) { $this->export->addThumbnail($theThumb); } } } // Configure which records to export if (is_array($inData['record'])) { foreach($inData['record'] as $ref) { $rParts = explode(':',$ref); $this->export->export_addRecord($rParts[0],t3lib_BEfunc::getRecord($rParts[0],$rParts[1])); } } // Configure which tables to export if (is_array($inData['list'])) { foreach($inData['list'] as $ref) { $rParts = explode(':',$ref); if ($GLOBALS['BE_USER']->check('tables_select',$rParts[0])) { $res = $this->exec_listQueryPid($rParts[0],$rParts[1],t3lib_div::intInRange($inData['listCfg']['maxNumber'],1)); while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->export->export_addRecord($rParts[0],$subTrow); } } } } // Pagetree if (isset($inData['pagetree']['id'])) { if ($inData['pagetree']['levels']==-1) { // Based on click-expandable tree $pagetree = t3lib_div::makeInstance('localPageTree'); $tree = $pagetree->ext_tree($inData['pagetree']['id'],$this->filterPageIds($this->export->excludeMap)); $this->treeHTML = $pagetree->printTree($tree); $idH = $pagetree->buffer_idH;# debug($pagetree->buffer_idH); } elseif ($inData['pagetree']['levels']==-2) { // Only tables on page $this->addRecordsForPid($inData['pagetree']['id'],$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']); } else { // Based on depth // Drawing tree: // If the ID is zero, export root if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin()) { $sPage = array( 'uid' => 0, 'title' => 'ROOT' ); } else { $sPage = t3lib_BEfunc::getRecordWSOL('pages',$inData['pagetree']['id'],'*',' AND '.$this->perms_clause); } if (is_array($sPage)) { $pid = $inData['pagetree']['id']; $tree = t3lib_div::makeInstance('t3lib_pageTree'); $tree->init('AND '.$this->perms_clause.$this->filterPageIds($this->export->excludeMap)); $HTML = t3lib_iconWorks::getIconImage('pages',$sPage,$GLOBALS['BACK_PATH'],'align="top"'); $tree->tree[] = Array('row'=>$sPage,'HTML'=>$HTML); $tree->buffer_idH = array(); if ($inData['pagetree']['levels']>0) { $tree->getTree($pid,$inData['pagetree']['levels'],''); } $idH = array(); $idH[$pid]['uid'] = $pid; if (count($tree->buffer_idH)) { $idH[$pid]['subrow'] = $tree->buffer_idH; } $pagetree = t3lib_div::makeInstance('localPageTree'); $this->treeHTML = $pagetree->printTree($tree->tree);#debug($idH); } } // 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...) if (is_array($idH)) { $flatList = $this->export->setPageTree($idH); // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...) reset($flatList); while(list($k)=each($flatList)) { $this->export->export_addRecord('pages',t3lib_BEfunc::getRecord('pages',$k)); $this->addRecordsForPid($k,$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']); } } } // After adding ALL records we set relations:# debug($this->export->relOnlyTables);# if (count($this->export->relOnlyTables)) { for($a=0;$a<10;$a++) { $addR = $this->export->export_addDBRelations($a); if (!count($addR)) break; }# } // Finally files are added: $this->export->export_addFilesFromRelations(); // MUST be after the DBrelations are set so that files from ALL added records are included!#debug($this->export->dat['header']); // If the download button is clicked, return file if ($inData['download_export'] || $inData['save_export']) { switch((string)$inData['filetype']) { case 'xml': $out = $this->export->compileMemoryToFileContent('xml'); $fExt = '.xml'; break; case 't3d': $this->export->dontCompress = 1; default: $out = $this->export->compileMemoryToFileContent(); $fExt = ($this->export->doOutputCompress()?'-z':'').'.t3d'; break; } // Filename: $dlFile = $inData['filename'] ? $inData['filename'] : 'T3D_'.substr(ereg_replace('[^[:alnum:]_]','-',$inData['download_export_name']),0,20).'_'.date('d-m-H-i-s').$fExt; // Export for download: if ($inData['download_export']) { $mimeType = 'application/octet-stream'; Header('Content-Type: '.$mimeType); Header('Content-Length: '.strlen($out)); Header('Content-Disposition: attachment; filename='.basename($dlFile)); echo $out; exit; } // Export by saving: if ($inData['save_export']) { $savePath = $this->userSaveFolder(); $fullName = $savePath.$dlFile; if (t3lib_div::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && t3lib_div::isAllowedAbsPath($fullName)) { t3lib_div::writeFile($fullName, $out); $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); } else { $this->content.= $this->doc->section($LANG->getLL('exportdata_problemsSavingFile'),sprintf($LANG->getLL('exportdata_badPathS',1),$fullName),0,1,2); } } } // OUTPUT to BROWSER: // Now, if we didn't make download file, show configuration form based on export: $menuItems = array(); // Export configuration $row = array(); $this->makeConfigurationForm($inData, $row); $menuItems[] = array( 'label' => $LANG->getLL('tableselec_configuration'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> '.implode(' ',$row).' </table> ' ); // File options $row = array(); $this->makeSaveForm($inData, $row); $menuItems[] = array( 'label' => $LANG->getLL('exportdata_filePreset'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> '.implode(' ',$row).' </table> ' ); // File options $row = array(); $this->makeAdvancedOptionsForm($inData, $row); $menuItems[] = array( 'label' => $LANG->getLL('exportdata_advancedOptions'), 'content' => ' <table border="0" cellpadding="1" cellspacing="1"> '.implode(' ',$row).' </table> ' ); // Generate overview: $overViewContent = $this->export->displayContentOverview(); // Print errors that might be: $errors = $this->export->printErrorLog(); $menuItems[] = array( 'label' => $LANG->getLL('exportdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0 ); // Add hidden fields and create tabs: $content = $this->doc->getDynTabMenu($menuItems,'tx_impexp_export',-1); $content.= '<input type="hidden" name="tx_impexp[action]" value="export" />'; $this->content.= $this->doc->section('',$content,0,1); // Output Overview: $this->content.= $this->doc->section($LANG->getLL('execlistqu_structureToBeExported'),$overViewContent,0,1); } /** * Adds records to the export object for a specific page id. * * @param integer Page id for which to select records to add * @param array Array of table names to select from * @param integer Max amount of records to select * @return void */ function addRecordsForPid($k, $tables, $maxNumber) { global $TCA; if (is_array($tables)) { reset($TCA); while(list($table)=each($TCA)) { if ($table!='pages' && (in_array($table,$tables) || in_array('_ALL',$tables))) { if ($GLOBALS['BE_USER']->check('tables_select',$table) && !$TCA[$table]['ctrl']['is_static']) { $res = $this->exec_listQueryPid($table,$k,t3lib_div::intInRange($maxNumber,1)); while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->export->export_addRecord($table,$subTrow); } } } } } } /** * Selects records from table / pid * * @param string Table to select from * @param integer Page ID to select from * @param integer Max number of records to select * @return pointer SQL resource pointer */ function exec_listQueryPid($table,$pid,$limit) { global $TCA, $LANG; $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby']; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*', $table, 'pid='.intval($pid). t3lib_BEfunc::deleteClause($table). t3lib_BEfunc::versioningPlaceholderClause($table), '', $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy), $limit ); // Warning about hitting limit: if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == $limit) { $this->content.= $this->doc->section($LANG->getLL('execlistqu_maxNumberLimit'),sprintf($LANG->getLL('makeconfig_anSqlQueryReturned',1),$limit),0,1, 2); } return $res; } /** * Create configuration form * * @param array Form configurat data * @param array Table row accumulation variable. This is filled with table rows. * @return void Sets content in $this->content */ function makeConfigurationForm($inData, &$row) { global $LANG; $nameSuggestion = ''; // Page tree export options: if (isset($inData['pagetree']['id'])) { $nameSuggestion.= 'tree_PID'.$inData['pagetree']['id'].'_L'.$inData['pagetree']['levels']; $row[] = ' <tr class="tableheader bgColor5"> <td colspan="2">'.$LANG->getLL('makeconfig_exportPagetreeConfiguration',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeCfg', $GLOBALS['BACK_PATH'],'').'</td> </tr>'; $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_pageId',1).'</strong></td> <td>'.htmlspecialchars($inData['pagetree']['id']). '<input type="hidden" value="'.htmlspecialchars($inData['pagetree']['id']).'" name="tx_impexp[pagetree][id]" /></td> </tr>'; $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_tree',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeDisplay', $GLOBALS['BACK_PATH'],'').'</td> <td>'.($this->treeHTML ? $this->treeHTML : $LANG->getLL('makeconfig_noTreeExportedOnly',1)).'</td> </tr>'; $opt = array( '-2' => $LANG->getLL('makeconfig_tablesOnThisPage'), '-1' => $LANG->getLL('makeconfig_expandedTree'), '0' => $LANG->getLL('makeconfig_onlyThisPage'), '1' => $LANG->getLL('makeconfig_1Level'), '2' => $LANG->getLL('makeconfig_2Levels'), '3' => $LANG->getLL('makeconfig_3Levels'), '4' => $LANG->getLL('makeconfig_4Levels'), '999' => $LANG->getLL('makeconfig_infinite') ); $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_levels',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeMode', $GLOBALS['BACK_PATH'],'').'</td> <td>'.$this->renderSelectBox('tx_impexp[pagetree][levels]',$inData['pagetree']['levels'],$opt).'</td> </tr>'; $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_includeTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeRecordLimit', $GLOBALS['BACK_PATH'],'').'</td> <td>'.$this->tableSelector('tx_impexp[pagetree][tables]',$inData['pagetree']['tables'],'pages').'<br/> '.$LANG->getLL('makeconfig_maxNumberOfRecords',1).'<br/> <input type="text" name="tx_impexp[pagetree][maxNumber]" value="'.htmlspecialchars($inData['pagetree']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/> </td> </tr>'; } // Single record export: if (is_array($inData['record'])) { $row[] = ' <tr class="tableheader bgColor5"> <td colspan="2">'.$LANG->getLL('makeconfig_exportSingleRecord',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'singleRecord', $GLOBALS['BACK_PATH'],'').'</td> </tr>'; foreach($inData['record'] as $ref) { $rParts = explode(':', $ref); $tName = $rParts[0]; $rUid = $rParts[1]; $nameSuggestion.= $tName.'_'.$rUid; $rec = t3lib_BEfunc::getRecordWSOL($tName,$rUid); $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_record',1).'</strong></td> <td>'.t3lib_iconworks::getIconImage($tName,$rec,$GLOBALS['BACK_PATH'],' align="top"'). t3lib_BEfunc::getRecordTitle($tName,$rec,TRUE). '<input type="hidden" name="tx_impexp[record][]" value="'.htmlspecialchars($tName.':'.$rUid).'" /></td> </tr>'; } } // Single tables/pids: if (is_array($inData['list'])) { $row[] = ' <tr class="tableheader bgColor5"> <td colspan="2">'.$LANG->getLL('makeconfig_exportTablesFromPages',1).'</td> </tr>'; $tblList = ''; foreach($inData['list'] as $ref) { $rParts = explode(':', $ref); $tName = $rParts[0]; if ($GLOBALS['BE_USER']->check('tables_select',$tName)) { $rec = t3lib_BEfunc::getRecordWSOL('pages', $rParts[1]); $tblList.='Table "'.$tName.'" from '.t3lib_iconworks::getIconImage('pages',$rec,$GLOBALS['BACK_PATH'],' align="top"'). t3lib_BEfunc::getRecordTitle('pages',$rec,TRUE). '<input type="hidden" name="tx_impexp[list][]" value="'.htmlspecialchars($ref).'" /><br/>'; } } $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_tablePids',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableList', $GLOBALS['BACK_PATH'],'').'</td> <td>'.$tblList.'</td> </tr>'; $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_maxNumberOfRecords',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableListMaxNumber', $GLOBALS['BACK_PATH'],'').'</strong></td> <td> <input type="text" name="tx_impexp[listCfg][maxNumber]" value="'.htmlspecialchars($inData['listCfg']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/> </td> </tr>'; } $row[] = ' <tr class="tableheader bgColor5"> <td colspan="2">'.$LANG->getLL('makeconfig_relationsAndExclusions',1).'</td> </tr>'; // Add relation selector: $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_includeRelationsToTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'inclRelations', $GLOBALS['BACK_PATH'],'').'</td> <td>'.$this->tableSelector('tx_impexp[external_ref][tables]',$inData['external_ref']['tables']).'</td> </tr>'; // Add static relation selector: $row[] = ' <tr class="bgColor4"> <td><strong>'.$LANG->getLL('makeconfig_useStaticRelationsFor',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'staticRelations', $GLOBALS['BACK_PATH'],'').'</td> <td>'.$this->tableSelector('tx_impexp[external_static][tables]',$inData['external_static']['tables']).'<br/> <label for="checkShowStaticRelations">'.$LANG->getLL('makeconfig_showStaticRelations',1).'</label> <input type="checkbox" name="tx_impexp[showStaticRelations]" id="checkShowStaticRelations" value="1"'.($inData['showStaticRelations'] ? ' checked="checked"' : '').' /> </td> </tr>'; // Exclude: $excludeHiddenFields = ''; if (is_array($inData['exclude'])) { foreach($inData['exclude'] as $key => $value) { $excludeHiddenFields.= '<input type="hidden" name="tx_impexp[exclude]['.$key.']" value="1" />'; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -