TYPO3 API  SVNRelease
index.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Import / Export module
00029  *
00030  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00031  */
00032 /**
00033  * [CLASS/FUNCTION INDEX of SCRIPT]
00034  *
00035  *
00036  *
00037  *  137: class localPageTree extends t3lib_browseTree
00038  *  144:     function localPageTree()
00039  *  155:     function wrapTitle($title,$v)
00040  *  168:     function PM_ATagWrap($icon,$cmd,$bMark='')
00041  *  179:     function wrapIcon($icon,$row)
00042  *  188:     function permsC()
00043  *  199:     function ext_tree($pid, $clause='')
00044  *
00045  *
00046  *  280: class SC_mod_tools_log_index extends t3lib_SCbase
00047  *  289:     function main()
00048  *  359:     function printContent()
00049  *
00050  *              SECTION: EXPORT FUNCTIONS
00051  *  387:     function exportData($inData)
00052  *  661:     function addRecordsForPid($k, $tables, $maxNumber)
00053  *  687:     function exec_listQueryPid($table,$pid,$limit)
00054  *  717:     function makeConfigurationForm($inData, &$row)
00055  *  885:     function makeAdvancedOptionsForm($inData, &$row)
00056  *  933:     function makeSaveForm($inData, &$row)
00057  *
00058  *              SECTION: IMPORT FUNCTIONS
00059  * 1064:     function importData($inData)
00060  *
00061  *              SECTION: Preset functions
00062  * 1363:     function processPresets(&$inData)
00063  * 1458:     function getPreset($uid)
00064  *
00065  *              SECTION: Helper functions
00066  * 1484:     function userTempFolder()
00067  * 1500:     function userSaveFolder()
00068  * 1523:     function checkUpload()
00069  * 1553:     function renderSelectBox($prefix,$value,$optValues)
00070  * 1576:     function tableSelector($prefix,$value,$excludeList='')
00071  * 1612:     function extensionSelector($prefix,$value)
00072  * 1637:     function filterPageIds($exclude)
00073  *
00074  * TOTAL FUNCTIONS: 24
00075  * (This index is automatically created/updated by the extension "extdeveval")
00076  *
00077  */
00078 /**
00079  *  IMPORTING DATA:
00080  *
00081  *  Incoming array has syntax:
00082  *      GETvar 'id' = import page id (must be readable)
00083  *
00084  *      file =  (pointing to filename relative to PATH_site)
00085  *
00086  *
00087  *
00088  *      [all relation fields are clear, but not files]
00089  *      - page-tree is written first
00090  *      - then remaining pages (to the root of import)
00091  *      - 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)
00092  *      - then all internal relations are set and non-existing relations removed, relations to static tables preserved.
00093  *
00094  *  EXPORTING DATA:
00095  *
00096  *  Incoming array has syntax:
00097  *
00098  *      file[] = file
00099  *      dir[] = dir
00100  *      list[] = table:pid
00101  *      record[] = table:uid
00102  *
00103  *      pagetree[id] = (single id)
00104  *      pagetree[levels]=1,2,3, -1 = currently unpacked tree, -2 = only tables on page
00105  *      pagetree[tables][]=table/_ALL
00106  *
00107  *      external_ref[tables][]=table/_ALL
00108  */
00109 
00110 unset($MCONF);
00111 require ('conf.php');
00112 require_once ($BACK_PATH.'init.php');
00113 require_once ($BACK_PATH.'template.php');
00114 $LANG->includeLLFile('EXT:impexp/app/locallang.php');
00115 require_once (t3lib_extMgm::extPath('impexp').'class.tx_impexp.php');
00116 
00117 t3lib_extMgm::isLoaded('impexp',1);
00118 
00119 
00120 
00121 
00122 
00123 /**
00124  * Extension of the page tree class. Used to get the tree of pages to export.
00125  *
00126  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00127  * @package TYPO3
00128  * @subpackage tx_impexp
00129  */
00130 class localPageTree extends t3lib_browseTree {
00131 
00132     /**
00133      * Initialization
00134      *
00135      * @return  void
00136      */
00137     function localPageTree() {
00138         $this->init();
00139     }
00140 
00141     /**
00142      * Wrapping title from page tree.
00143      *
00144      * @param   string      Title to wrap
00145      * @param   mixed       (See parent class)
00146      * @return  string      Wrapped title
00147      */
00148     function wrapTitle($title,$v)   {
00149         $title = (!strcmp(trim($title),'')) ? '<em>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</em>' : htmlspecialchars($title);
00150         return $title;
00151     }
00152 
00153     /**
00154      * Wrapping Plus/Minus icon
00155      *
00156      * @param   string      Icon HTML
00157      * @param   mixed       (See parent class)
00158      * @param   mixed       (See parent class)
00159      * @return  string      Icon HTML
00160      */
00161     function PM_ATagWrap($icon,$cmd,$bMark='')  {
00162         return $icon;
00163     }
00164 
00165     /**
00166      * Wrapping Icon
00167      *
00168      * @param   string      Icon HTML
00169      * @param   array       Record row (page)
00170      * @return  string      Icon HTML
00171      */
00172     function wrapIcon($icon,$row)   {
00173         return $icon;
00174     }
00175 
00176     /**
00177      * Select permissions
00178      *
00179      * @return  string      SQL where clause
00180      */
00181     function permsC()   {
00182         return $this->BE_USER->getPagePermsClause(1);
00183     }
00184 
00185     /**
00186      * Tree rendering
00187      *
00188      * @param   integer     PID value
00189      * @param   string      Additional where clause
00190      * @return  array       Array of tree elements
00191      */
00192     function ext_tree($pid, $clause='') {
00193 
00194             // Initialize:
00195         $this->init(' AND '.$this->permsC().$clause);
00196 
00197             // Get stored tree structure:
00198         $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
00199 
00200             // PM action:
00201         $PM = t3lib_div::intExplode('_',t3lib_div::_GP('PM'));
00202 
00203             // traverse mounts:
00204         $titleLen = intval($this->BE_USER->uc['titleLen']);
00205         $treeArr = array();
00206 
00207         $idx = 0;
00208 
00209             // Set first:
00210         $this->bank = $idx;
00211         $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
00212 
00213         $curIds = $this->ids;   // save ids
00214         $this->reset();
00215         $this->ids = $curIds;
00216 
00217             // Set PM icon:
00218         $cmd = $this->bank.'_'.($isOpen?'0_':'1_').$pid;
00219         $icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen?'minus':'plus').'only.gif','width="18" height="16"').' align="top" alt="" />';
00220         $firstHtml = $this->PM_ATagWrap($icon,$cmd);
00221 
00222         if ($pid>0) {
00223             $rootRec = t3lib_befunc::getRecordWSOL('pages',$pid);
00224             $firstHtml.= $this->wrapIcon(t3lib_iconWorks::getSpriteIconForRecord('pages', $rootRec), $rootRec);
00225         } else {
00226             $rootRec = array(
00227                 'title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
00228                 'uid' => 0
00229             );
00230             $firstHtml.= $this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' align="top" alt="" />',$rootRec);
00231         }
00232         $this->tree[] = array('HTML'=>$firstHtml, 'row'=>$rootRec);
00233         if ($isOpen)    {
00234                 // Set depth:
00235             $depthD = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/blank.gif','width="18" height="16"').' align="top" alt="" />';
00236             if ($this->addSelfId)   $this->ids[] = $pid;
00237             $this->getTree($pid,999,$depthD);
00238 
00239             $idH = array();
00240             $idH[$pid]['uid'] = $pid;
00241             if (count($this->buffer_idH))   $idH[$pid]['subrow'] = $this->buffer_idH;
00242             $this->buffer_idH = $idH;
00243 
00244         }
00245 
00246             // Add tree:
00247         $treeArr = array_merge($treeArr,$this->tree);
00248 
00249         return $treeArr;
00250     }
00251 }
00252 
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 /**
00267  * Main script class for the Import / Export facility
00268  *
00269  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00270  * @package TYPO3
00271  * @subpackage tx_impexp
00272  */
00273 class SC_mod_tools_log_index extends t3lib_SCbase {
00274 
00275     var $pageinfo;          // array containing the current page.
00276 
00277     /**
00278      * Main module function
00279      *
00280      * @return  void
00281      */
00282     function main() {
00283         global $BE_USER,$LANG,$BACK_PATH;
00284 
00285             // Start document template object:
00286         $this->doc = t3lib_div::makeInstance('template');
00287         $this->doc->backPath = $BACK_PATH;
00288         $this->doc->bodyTagId = 'imp-exp-mod';
00289         $this->doc->setModuleTemplate(t3lib_extMgm::extRelPath('impexp') . '/app/template.html');
00290 
00291 
00292         $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause);
00293 
00294                 // JavaScript
00295         $this->doc->JScode = $this->doc->wrapScriptTags('
00296             script_ended = 0;
00297             function jumpToUrl(URL) {   //
00298                 window.location.href = URL;
00299             }
00300         ');
00301 
00302         // Setting up the context sensitive menu:
00303         $this->doc->getContextMenuCode();
00304 
00305         $this->doc->postCode = $this->doc->wrapScriptTags('
00306             script_ended = 1;
00307             if (top.fsMod) top.fsMod.recentIds["web"] = '.intval($this->id).';
00308         ');
00309         $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.'" />';
00310 
00311         $this->content.= $this->doc->header($LANG->getLL('title'));
00312         $this->content.= $this->doc->spacer(5);
00313 
00314             // Input data grabbed:
00315         $inData = t3lib_div::_GP('tx_impexp');
00316 
00317         $this->checkUpload();
00318 
00319         switch((string)$inData['action'])   {
00320             case 'export':
00321 
00322                     // Finally: If upload went well, set the new file as the thumbnail in the $inData array:
00323                 if (is_object($this->fileProcessor) && $this->fileProcessor->internalUploadMap[1])  {
00324                     $inData['meta']['thumbnail'] = md5($this->fileProcessor->internalUploadMap[1]);
00325                 }
00326 
00327                     // Call export interface
00328                 $this->exportData($inData);
00329             break;
00330             case 'import':
00331 
00332                     // Finally: If upload went well, set the new file as the import file:
00333                 if (is_object($this->fileProcessor) && $this->fileProcessor->internalUploadMap[1])  {
00334                     $fI = pathinfo($this->fileProcessor->internalUploadMap[1]);
00335                     if (t3lib_div::inList('t3d,xml',strtolower($fI['extension'])))  {   // Only allowed extensions....
00336                         $inData['file'] = $this->fileProcessor->internalUploadMap[1];
00337                     }
00338                 }
00339 
00340                     // Call import interface:
00341                 $this->importData($inData);
00342             break;
00343         }
00344 
00345         // Setting up the buttons and markers for docheader
00346         $docHeaderButtons = $this->getButtons();
00347         $markers['CONTENT'] = $this->content;
00348 
00349         // Build the <body> for the module
00350         $this->content = $this->doc->startPage($LANG->getLL('title'));
00351         $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00352         $this->content.= $this->doc->endPage();
00353         $this->content = $this->doc->insertStylesAndJS($this->content);
00354     }
00355 
00356     /**
00357      * Print the content
00358      *
00359      * @return  void
00360      */
00361     function printContent() {
00362         echo $this->content;
00363     }
00364 
00365     /**
00366      * Create the panel of buttons for submitting the form or otherwise perform operations.
00367      *
00368      * @return array all available buttons as an associated array
00369      */
00370     protected function getButtons() {
00371         $buttons = array(
00372             'view' => '',
00373             'record_list' => '',
00374             'shortcut' => ''
00375         );
00376 
00377         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00378             $buttons['shortcut'] = $this->doc->makeShortcutIcon('tx_impexp', '', $this->MCONF['name']);
00379         }
00380 
00381         // Input data grabbed:
00382         $inData = t3lib_div::_GP('tx_impexp');
00383         if((string)$inData['action'] == 'import') {
00384             if (($this->id && is_array($this->pageinfo)) || ($GLOBALS['BE_USER']->user['admin'] && !$this->id)) {
00385                 if (is_array($this->pageinfo) && $this->pageinfo['uid']) {
00386                     // View
00387                     $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) . '">' .
00388                         t3lib_iconWorks::getSpriteIcon('actions-document-view') .
00389                   '</a>';
00390 
00391                         // Record list
00392                         // If access to Web>List for user, then link to that module.
00393                     $buttons['record_list'] = t3lib_BEfunc::getListViewLink(
00394                         array(
00395                             'id' => $this->pageinfo['uid'],
00396                             'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
00397                         ),
00398                         $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
00399                     );
00400                 }
00401             }
00402         }
00403 
00404         return $buttons;
00405     }
00406 
00407 
00408 
00409 
00410 
00411     /**************************
00412      *
00413      * EXPORT FUNCTIONS
00414      *
00415      **************************/
00416 
00417     /**
00418      * Export part of module
00419      *
00420      * @param   array       Content of POST VAR tx_impexp[]..
00421      * @return  void        Setting content in $this->content
00422      */
00423     function exportData($inData)    {
00424         global $TCA, $LANG;
00425 
00426             // BUILDING EXPORT DATA:
00427 
00428             // Processing of InData array values:
00429         $inData['pagetree']['maxNumber'] = t3lib_div::intInRange($inData['pagetree']['maxNumber'],1,10000,100);
00430         $inData['listCfg']['maxNumber'] = t3lib_div::intInRange($inData['listCfg']['maxNumber'],1,10000,100);
00431         $inData['maxFileSize'] = t3lib_div::intInRange($inData['maxFileSize'],1,10000,1000);
00432         $inData['filename'] = trim(preg_replace('/[^[:alnum:]._-]*/','',preg_replace('/\.(t3d|xml)$/','',$inData['filename'])));
00433         if (strlen($inData['filename']))    {
00434             $inData['filename'].= $inData['filetype']=='xml' ? '.xml' : '.t3d';
00435         }
00436 
00437             // Set exclude fields in export object:
00438         if (!is_array($inData['exclude']))  {
00439             $inData['exclude'] = array();
00440         }
00441 
00442 
00443             // Saving/Loading/Deleting presets:
00444         $this->processPresets($inData);
00445 
00446             // Create export object and configure it:
00447         $this->export = t3lib_div::makeInstance('tx_impexp');
00448         $this->export->init(0,'export');
00449         $this->export->setCharset($LANG->charSet);
00450 
00451         $this->export->maxFileSize = $inData['maxFileSize']*1024;
00452         $this->export->excludeMap = (array)$inData['exclude'];
00453         $this->export->softrefCfg = (array)$inData['softrefCfg'];
00454         $this->export->extensionDependencies = (array)$inData['extension_dep'];
00455         $this->export->showStaticRelations = $inData['showStaticRelations'];
00456 
00457         $this->export->includeExtFileResources = !$inData['excludeHTMLfileResources'];
00458 
00459             // Static tables:
00460         if (is_array($inData['external_static']['tables'])) {
00461             $this->export->relStaticTables = $inData['external_static']['tables'];
00462         }
00463 
00464             // Configure which tables external relations are included for:
00465         if (is_array($inData['external_ref']['tables']))    {
00466             $this->export->relOnlyTables = $inData['external_ref']['tables'];
00467         }
00468         $this->export->setHeaderBasics();
00469 
00470             // Meta data setting:
00471         $this->export->setMetaData(
00472             $inData['meta']['title'],
00473             $inData['meta']['description'],
00474             $inData['meta']['notes'],
00475             $GLOBALS['BE_USER']->user['username'],
00476             $GLOBALS['BE_USER']->user['realName'],
00477             $GLOBALS['BE_USER']->user['email']
00478         );
00479         if ($inData['meta']['thumbnail'])   {
00480             $tempDir = $this->userTempFolder();
00481             if ($tempDir)   {
00482                 $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg',1);
00483                 $theThumb = $thumbnails[$inData['meta']['thumbnail']];
00484                 if ($theThumb)  {
00485                     $this->export->addThumbnail($theThumb);
00486                 }
00487             }
00488         }
00489 
00490 
00491             // Configure which records to export
00492         if (is_array($inData['record']))    {
00493             foreach($inData['record'] as $ref)  {
00494                 $rParts = explode(':',$ref);
00495                 $this->export->export_addRecord($rParts[0],t3lib_BEfunc::getRecord($rParts[0],$rParts[1]));
00496             }
00497         }
00498 
00499             // Configure which tables to export
00500         if (is_array($inData['list']))  {
00501             foreach($inData['list'] as $ref)    {
00502                 $rParts = explode(':',$ref);
00503                 if ($GLOBALS['BE_USER']->check('tables_select',$rParts[0])) {
00504                     $res = $this->exec_listQueryPid($rParts[0],$rParts[1],t3lib_div::intInRange($inData['listCfg']['maxNumber'],1));
00505                     while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
00506                         $this->export->export_addRecord($rParts[0],$subTrow);
00507                     }
00508                 }
00509             }
00510         }
00511 
00512             // Pagetree
00513         if (isset($inData['pagetree']['id']))   {
00514             if ($inData['pagetree']['levels']==-1)  {   // Based on click-expandable tree
00515                 $pagetree = t3lib_div::makeInstance('localPageTree');
00516 
00517                 $tree = $pagetree->ext_tree($inData['pagetree']['id'],$this->filterPageIds($this->export->excludeMap));
00518                 $this->treeHTML = $pagetree->printTree($tree);
00519 
00520                 $idH = $pagetree->buffer_idH;
00521             } elseif ($inData['pagetree']['levels']==-2)    {   // Only tables on page
00522                 $this->addRecordsForPid($inData['pagetree']['id'],$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
00523             } else {    // Based on depth
00524                     // Drawing tree:
00525                     // If the ID is zero, export root
00526                 if (!$inData['pagetree']['id'] && $GLOBALS['BE_USER']->isAdmin())   {
00527                     $sPage = array(
00528                         'uid' => 0,
00529                         'title' => 'ROOT'
00530                     );
00531                 } else {
00532                     $sPage = t3lib_BEfunc::getRecordWSOL('pages',$inData['pagetree']['id'],'*',' AND '.$this->perms_clause);
00533                 }
00534                 if (is_array($sPage))   {
00535                     $pid = $inData['pagetree']['id'];
00536                     $tree = t3lib_div::makeInstance('t3lib_pageTree');
00537                     $tree->init('AND '.$this->perms_clause.$this->filterPageIds($this->export->excludeMap));
00538 
00539                     $HTML = t3lib_iconWorks::getSpriteIconForRecord('pages', $sPage);
00540                     $tree->tree[] = Array('row'=>$sPage,'HTML'=>$HTML);
00541                     $tree->buffer_idH = array();
00542                     if ($inData['pagetree']['levels']>0)    {
00543                         $tree->getTree($pid,$inData['pagetree']['levels'],'');
00544                     }
00545 
00546                     $idH = array();
00547                     $idH[$pid]['uid'] = $pid;
00548                     if (count($tree->buffer_idH))   {
00549                         $idH[$pid]['subrow'] = $tree->buffer_idH;
00550                     }
00551 
00552                     $pagetree = t3lib_div::makeInstance('localPageTree');
00553                     $this->treeHTML = $pagetree->printTree($tree->tree);
00554                 }
00555             }
00556                 // 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...)
00557             if (is_array($idH)) {
00558                 $flatList = $this->export->setPageTree($idH);   // Sets the pagetree and gets a 1-dim array in return with the pages (in correct submission order BTW...)
00559                 foreach ($flatList as $k => $value) {
00560                     $this->export->export_addRecord('pages',t3lib_BEfunc::getRecord('pages',$k));
00561                     $this->addRecordsForPid($k,$inData['pagetree']['tables'],$inData['pagetree']['maxNumber']);
00562                 }
00563             }
00564         }
00565 
00566             // After adding ALL records we set relations:
00567         for($a=0;$a<10;$a++)    {
00568             $addR = $this->export->export_addDBRelations($a);
00569             if (!count($addR)) {
00570                 break;
00571             }
00572         }
00573 
00574             // Finally files are added:
00575         $this->export->export_addFilesFromRelations();  // MUST be after the DBrelations are set so that files from ALL added records are included!
00576             // If the download button is clicked, return file
00577         if ($inData['download_export'] || $inData['save_export'])   {
00578             switch((string)$inData['filetype']) {
00579                 case 'xml':
00580                     $out = $this->export->compileMemoryToFileContent('xml');
00581                     $fExt = '.xml';
00582                 break;
00583                 case 't3d':
00584                     $this->export->dontCompress = 1;
00585                 default:
00586                     $out = $this->export->compileMemoryToFileContent();
00587                     $fExt = ($this->export->doOutputCompress()?'-z':'').'.t3d';
00588                 break;
00589             }
00590 
00591                 // Filename:
00592             $dlFile = $inData['filename'] ? $inData['filename'] : 'T3D_'.substr(preg_replace('/[^[:alnum:]_]/','-',$inData['download_export_name']),0,20).'_'.date('d-m-H-i-s').$fExt;
00593 
00594                 // Export for download:
00595             if ($inData['download_export']) {
00596                 $mimeType = 'application/octet-stream';
00597                 Header('Content-Type: '.$mimeType);
00598                 Header('Content-Length: '.strlen($out));
00599                 Header('Content-Disposition: attachment; filename='.basename($dlFile));
00600 
00601                 echo $out;
00602                 exit;
00603             }
00604 
00605                 // Export by saving:
00606             if ($inData['save_export']) {
00607                 $savePath = $this->userSaveFolder();
00608                 $fullName = $savePath.$dlFile;
00609 
00610                 if (t3lib_div::isAllowedAbsPath($savePath) && @is_dir(dirname($fullName)) && t3lib_div::isAllowedAbsPath($fullName))    {
00611                     t3lib_div::writeFile($fullName, $out);
00612                     $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);
00613                 } else {
00614                     $this->content.= $this->doc->section($LANG->getLL('exportdata_problemsSavingFile'),sprintf($LANG->getLL('exportdata_badPathS',1),$fullName),0,1,2);
00615                 }
00616             }
00617         }
00618 
00619 
00620             // OUTPUT to BROWSER:
00621             // Now, if we didn't make download file, show configuration form based on export:
00622         $menuItems = array();
00623 
00624             // Export configuration
00625         $row = array();
00626         $this->makeConfigurationForm($inData, $row);
00627         $menuItems[] = array(
00628             'label' => $LANG->getLL('tableselec_configuration'),
00629             'content' => '
00630                 <table border="0" cellpadding="1" cellspacing="1">
00631                     '.implode('
00632                     ',$row).'
00633                 </table>
00634             '
00635         );
00636 
00637             // File options
00638         $row = array();
00639         $this->makeSaveForm($inData, $row);
00640         $menuItems[] = array(
00641             'label' => $LANG->getLL('exportdata_filePreset'),
00642             'content' => '
00643                 <table border="0" cellpadding="1" cellspacing="1">
00644                     '.implode('
00645                     ',$row).'
00646                 </table>
00647             '
00648         );
00649 
00650             // File options
00651         $row = array();
00652         $this->makeAdvancedOptionsForm($inData, $row);
00653         $menuItems[] = array(
00654             'label' => $LANG->getLL('exportdata_advancedOptions'),
00655             'content' => '
00656                 <table border="0" cellpadding="1" cellspacing="1">
00657                     '.implode('
00658                     ',$row).'
00659                 </table>
00660             '
00661         );
00662 
00663             // Generate overview:
00664         $overViewContent = $this->export->displayContentOverview();
00665 
00666             // Print errors that might be:
00667         $errors = $this->export->printErrorLog();
00668         $menuItems[] = array(
00669             'label' => $LANG->getLL('exportdata_messages'),
00670             'content' => $errors,
00671             'stateIcon' => $errors ? 2 : 0
00672         );
00673 
00674             // Add hidden fields and create tabs:
00675         $content = $this->doc->getDynTabMenu($menuItems,'tx_impexp_export',-1);
00676         $content.= '<input type="hidden" name="tx_impexp[action]" value="export" />';
00677         $this->content.= $this->doc->section('',$content,0,1);
00678 
00679             // Output Overview:
00680         $this->content.= $this->doc->section($LANG->getLL('execlistqu_structureToBeExported'),$overViewContent,0,1);
00681 
00682     }
00683 
00684     /**
00685      * Adds records to the export object for a specific page id.
00686      *
00687      * @param   integer     Page id for which to select records to add
00688      * @param   array       Array of table names to select from
00689      * @param   integer     Max amount of records to select
00690      * @return  void
00691      */
00692     function addRecordsForPid($k, $tables, $maxNumber)  {
00693         global $TCA;
00694 
00695         if (is_array($tables))  {
00696             foreach ($TCA as $table => $value) {
00697                 if ($table!='pages' && (in_array($table,$tables) || in_array('_ALL',$tables)))  {
00698                     if ($GLOBALS['BE_USER']->check('tables_select',$table) && !$TCA[$table]['ctrl']['is_static'])   {
00699                         $res = $this->exec_listQueryPid($table,$k,t3lib_div::intInRange($maxNumber,1));
00700                         while($subTrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
00701                             $this->export->export_addRecord($table,$subTrow);
00702                         }
00703                     }
00704                 }
00705             }
00706         }
00707     }
00708 
00709     /**
00710      * Selects records from table / pid
00711      *
00712      * @param   string      Table to select from
00713      * @param   integer     Page ID to select from
00714      * @param   integer     Max number of records to select
00715      * @return  pointer     SQL resource pointer
00716      */
00717     function exec_listQueryPid($table,$pid,$limit)  {
00718         global $TCA, $LANG;
00719 
00720         $orderBy = $TCA[$table]['ctrl']['sortby'] ? 'ORDER BY '.$TCA[$table]['ctrl']['sortby'] : $TCA[$table]['ctrl']['default_sortby'];
00721         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
00722                 '*',
00723                 $table,
00724                 'pid='.intval($pid).
00725                     t3lib_BEfunc::deleteClause($table).
00726                     t3lib_BEfunc::versioningPlaceholderClause($table),
00727                 '',
00728                 $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy),
00729                 $limit
00730             );
00731 
00732             // Warning about hitting limit:
00733         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) == $limit) {
00734             $this->content.= $this->doc->section($LANG->getLL('execlistqu_maxNumberLimit'),sprintf($LANG->getLL('makeconfig_anSqlQueryReturned',1),$limit),0,1, 2);
00735         }
00736 
00737         return $res;
00738     }
00739 
00740     /**
00741      * Create configuration form
00742      *
00743      * @param   array       Form configurat data
00744      * @param   array       Table row accumulation variable. This is filled with table rows.
00745      * @return  void        Sets content in $this->content
00746      */
00747     function makeConfigurationForm($inData, &$row)  {
00748         global $LANG;
00749 
00750         $nameSuggestion = '';
00751 
00752             // Page tree export options:
00753         if (isset($inData['pagetree']['id']))   {
00754 
00755             $nameSuggestion.= 'tree_PID'.$inData['pagetree']['id'].'_L'.$inData['pagetree']['levels'];
00756 
00757             $row[] = '
00758                 <tr class="tableheader bgColor5">
00759                     <td colspan="2">'.$LANG->getLL('makeconfig_exportPagetreeConfiguration',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeCfg', $GLOBALS['BACK_PATH'],'').'</td>
00760                 </tr>';
00761 
00762             $row[] = '
00763                 <tr class="bgColor4">
00764                     <td><strong>'.$LANG->getLL('makeconfig_pageId',1).'</strong></td>
00765                     <td>'.htmlspecialchars($inData['pagetree']['id']).
00766                         '<input type="hidden" value="'.htmlspecialchars($inData['pagetree']['id']).'" name="tx_impexp[pagetree][id]" /></td>
00767                 </tr>';
00768 
00769             $row[] = '
00770                 <tr class="bgColor4">
00771                     <td><strong>'.$LANG->getLL('makeconfig_tree',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeDisplay', $GLOBALS['BACK_PATH'],'').'</td>
00772                     <td>'.($this->treeHTML ? $this->treeHTML : $LANG->getLL('makeconfig_noTreeExportedOnly',1)).'</td>
00773                 </tr>';
00774 
00775             $opt = array(
00776                 '-2' => $LANG->getLL('makeconfig_tablesOnThisPage'),
00777                 '-1' => $LANG->getLL('makeconfig_expandedTree'),
00778                 '0' => $LANG->getLL('makeconfig_onlyThisPage'),
00779                 '1' => $LANG->getLL('makeconfig_1Level'),
00780                 '2' => $LANG->getLL('makeconfig_2Levels'),
00781                 '3' => $LANG->getLL('makeconfig_3Levels'),
00782                 '4' => $LANG->getLL('makeconfig_4Levels'),
00783                 '999' => $LANG->getLL('makeconfig_infinite')
00784             );
00785             $row[] = '
00786                 <tr class="bgColor4">
00787                     <td><strong>'.$LANG->getLL('makeconfig_levels',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeMode', $GLOBALS['BACK_PATH'],'').'</td>
00788                     <td>'.$this->renderSelectBox('tx_impexp[pagetree][levels]',$inData['pagetree']['levels'],$opt).'</td>
00789                 </tr>';
00790 
00791             $row[] = '
00792                 <tr class="bgColor4">
00793                     <td><strong>'.$LANG->getLL('makeconfig_includeTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'pageTreeRecordLimit', $GLOBALS['BACK_PATH'],'').'</td>
00794                     <td>'.$this->tableSelector('tx_impexp[pagetree][tables]',$inData['pagetree']['tables'],'pages').'<br/>
00795                         '.$LANG->getLL('makeconfig_maxNumberOfRecords',1).'<br/>
00796                         <input type="text" name="tx_impexp[pagetree][maxNumber]" value="'.htmlspecialchars($inData['pagetree']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/>
00797                     </td>
00798                 </tr>';
00799         }
00800 
00801             // Single record export:
00802         if (is_array($inData['record']))    {
00803             $row[] = '
00804                 <tr class="tableheader bgColor5">
00805                     <td colspan="2">'.$LANG->getLL('makeconfig_exportSingleRecord',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'singleRecord', $GLOBALS['BACK_PATH'],'').'</td>
00806                 </tr>';
00807             foreach($inData['record'] as $ref)  {
00808                 $rParts = explode(':', $ref);
00809                 $tName = $rParts[0];
00810                 $rUid = $rParts[1];
00811                 $nameSuggestion.= $tName.'_'.$rUid;
00812                 $rec = t3lib_BEfunc::getRecordWSOL($tName,$rUid);
00813 
00814                 $row[] = '
00815                 <tr class="bgColor4">
00816                     <td><strong>'.$LANG->getLL('makeconfig_record',1).'</strong></td>
00817                     <td>' . t3lib_iconworks::getSpriteIconForRecord($tName, $rec) .
00818                         t3lib_BEfunc::getRecordTitle($tName,$rec,TRUE).
00819                         '<input type="hidden" name="tx_impexp[record][]" value="'.htmlspecialchars($tName.':'.$rUid).'" /></td>
00820                 </tr>';
00821             }
00822         }
00823 
00824             // Single tables/pids:
00825         if (is_array($inData['list']))  {
00826             $row[] = '
00827                 <tr class="tableheader bgColor5">
00828                     <td colspan="2">'.$LANG->getLL('makeconfig_exportTablesFromPages',1).'</td>
00829                 </tr>';
00830 
00831             $tblList = '';
00832             foreach($inData['list'] as $ref)    {
00833                 $rParts = explode(':', $ref);
00834                 $tName = $rParts[0];
00835 
00836                 if ($GLOBALS['BE_USER']->check('tables_select',$tName)) {
00837                     $rec = t3lib_BEfunc::getRecordWSOL('pages', $rParts[1]);
00838                     $tblList .= 'Table "' . $tName . '" from ' . t3lib_iconworks::getSpriteIconForRecord('pages', $rec) .
00839                     t3lib_BEfunc::getRecordTitle('pages', $rec, TRUE).
00840                     '<input type="hidden" name="tx_impexp[list][]" value="'.htmlspecialchars($ref).'" /><br/>';
00841                 }
00842             }
00843             $row[] = '
00844             <tr class="bgColor4">
00845                 <td><strong>'.$LANG->getLL('makeconfig_tablePids',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableList', $GLOBALS['BACK_PATH'],'').'</td>
00846                 <td>'.$tblList.'</td>
00847             </tr>';
00848 
00849             $row[] = '
00850                 <tr class="bgColor4">
00851                     <td><strong>'.$LANG->getLL('makeconfig_maxNumberOfRecords',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'tableListMaxNumber', $GLOBALS['BACK_PATH'],'').'</strong></td>
00852                     <td>
00853                         <input type="text" name="tx_impexp[listCfg][maxNumber]" value="'.htmlspecialchars($inData['listCfg']['maxNumber']).'"'.$this->doc->formWidth(10).' /><br/>
00854                     </td>
00855                 </tr>';
00856         }
00857 
00858 
00859         $row[] = '
00860             <tr class="tableheader bgColor5">
00861                 <td colspan="2">'.$LANG->getLL('makeconfig_relationsAndExclusions',1).'</td>
00862             </tr>';
00863 
00864             // Add relation selector:
00865         $row[] = '
00866                 <tr class="bgColor4">
00867                     <td><strong>'.$LANG->getLL('makeconfig_includeRelationsToTables',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'inclRelations', $GLOBALS['BACK_PATH'],'').'</td>
00868                     <td>'.$this->tableSelector('tx_impexp[external_ref][tables]',$inData['external_ref']['tables']).'</td>
00869                 </tr>';
00870 
00871             // Add static relation selector:
00872         $row[] = '
00873                 <tr class="bgColor4">
00874                     <td><strong>'.$LANG->getLL('makeconfig_useStaticRelationsFor',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'staticRelations', $GLOBALS['BACK_PATH'],'').'</td>
00875                     <td>'.$this->tableSelector('tx_impexp[external_static][tables]',$inData['external_static']['tables']).'<br/>
00876                         <label for="checkShowStaticRelations">'.$LANG->getLL('makeconfig_showStaticRelations',1).'</label> <input type="checkbox" name="tx_impexp[showStaticRelations]" id="checkShowStaticRelations" value="1"'.($inData['showStaticRelations'] ? ' checked="checked"' : '').' />
00877                         </td>
00878                 </tr>';
00879 
00880             // Exclude:
00881         $excludeHiddenFields = '';
00882         if (is_array($inData['exclude']))   {
00883             foreach($inData['exclude'] as $key => $value)   {
00884                 $excludeHiddenFields.= '<input type="hidden" name="tx_impexp[exclude]['.$key.']" value="1" />';
00885             }
00886         }
00887         $row[] = '
00888                 <tr class="bgColor4">
00889                     <td><strong>'.$LANG->getLL('makeconfig_excludeElements',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'excludedElements', $GLOBALS['BACK_PATH'],'').'</td>
00890                     <td>'.$excludeHiddenFields.'
00891                     '.(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)).'
00892                     </td>
00893                 </tr>';
00894 
00895 
00896             // Add buttons:
00897         $row[] = '
00898                 <tr class="bgColor4">
00899                     <td>&nbsp;</td>
00900                     <td>
00901                         <input type="submit" value="'.$LANG->getLL('makeadvanc_update',1).'" />
00902                         <input type="hidden" name="tx_impexp[download_export_name]" value="'.substr($nameSuggestion,0,30).'" />
00903                     </td>
00904                 </tr>';
00905 
00906     }
00907 
00908     /**
00909      * Create advanced options form
00910      *
00911      * @param   array       Form configurat data
00912      * @param   array       Table row accumulation variable. This is filled with table rows.
00913      * @return  void        Sets content in $this->content
00914      */
00915     function makeAdvancedOptionsForm($inData, &$row)    {
00916         global $LANG;
00917 
00918             // Soft references
00919         $row[] = '
00920             <tr class="tableheader bgColor5">
00921                 <td colspan="2">'.$LANG->getLL('makeadvanc_softReferences',1).'</td>
00922             </tr>';
00923         $row[] = '
00924                 <tr class="bgColor4">
00925                     <td><label for="checkExcludeHTMLfileResources"><strong>'.$LANG->getLL('makeadvanc_excludeHtmlCssFile',1).'</strong></label>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'htmlCssResources', $GLOBALS['BACK_PATH'],'').'</td>
00926                     <td><input type="checkbox" name="tx_impexp[excludeHTMLfileResources]" id="checkExcludeHTMLfileResources" value="1"'.($inData['excludeHTMLfileResources'] ? ' checked="checked"' : '').' /></td>
00927                 </tr>';
00928 
00929 
00930             // Extensions
00931         $row[] = '
00932             <tr class="tableheader bgColor5">
00933                 <td colspan="2">'.$LANG->getLL('makeadvanc_extensionDependencies',1).'</td>
00934             </tr>';
00935         $row[] = '
00936                 <tr class="bgColor4">
00937                     <td><strong>'.$LANG->getLL('makeadvanc_selectExtensionsThatThe',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'extensionDependencies', $GLOBALS['BACK_PATH'],'').'</td>
00938                     <td>'.$this->extensionSelector('tx_impexp[extension_dep]',$inData['extension_dep']).'</td>
00939                 </tr>';
00940 
00941 
00942 
00943             // Add buttons:
00944         $row[] = '
00945                 <tr class="bgColor4">
00946                     <td>&nbsp;</td>
00947                     <td>
00948                         <input type="submit" value="'.$LANG->getLL('makesavefo_update',1).'" />
00949                         <input type="hidden" name="tx_impexp[download_export_name]" value="'.substr($nameSuggestion,0,30).'" />
00950                     </td>
00951                 </tr>';
00952 
00953 
00954     }
00955 
00956     /**
00957      * Create configuration form
00958      *
00959      * @param   array       Form configurat data
00960      * @param   array       Table row accumulation variable. This is filled with table rows.
00961      * @return  void        Sets content in $this->content
00962      */
00963     function makeSaveForm($inData, &$row)   {
00964         global $LANG;
00965 
00966             // Presets:
00967         $row[] = '
00968             <tr class="tableheader bgColor5">
00969                 <td colspan="2">'.$LANG->getLL('makesavefo_presets',1).'</td>
00970             </tr>';
00971 
00972         $opt = array('');
00973         $presets = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00974                         '*',
00975                         'tx_impexp_presets',
00976                         '(public>0 OR user_uid='.intval($GLOBALS['BE_USER']->user['uid']).')'.
00977                             ($inData['pagetree']['id'] ? ' AND (item_uid='.intval($inData['pagetree']['id']).' OR item_uid=0)' : '')
00978 
00979                     );
00980         if (is_array($presets)) {
00981             foreach($presets as $presetCfg) {
00982                 $opt[$presetCfg['uid']] = $presetCfg['title'].' ['.$presetCfg['uid'].']'.
00983                                             ($presetCfg['public'] ? ' [Public]' : '').
00984                                             ($presetCfg['user_uid']===$GLOBALS['BE_USER']->user['uid'] ? ' [Own]' : '');
00985             }
00986         }
00987 
00988         $row[] = '
00989                 <tr class="bgColor4">
00990                     <td><strong>'.$LANG->getLL('makesavefo_presets',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'presets', $GLOBALS['BACK_PATH'],'').'</td>
00991                     <td>
00992                         '.$LANG->getLL('makesavefo_selectPreset',1).'<br/>
00993                         '.$this->renderSelectBox('preset[select]','',$opt).'
00994                         <br/>
00995                         <input type="submit" value="'.$LANG->getLL('makesavefo_load',1).'" name="preset[load]" />
00996                         <input type="submit" value="'.$LANG->getLL('makesavefo_save',1).'" name="preset[save]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
00997                         <input type="submit" value="'.$LANG->getLL('makesavefo_delete',1).'" name="preset[delete]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
00998                         <input type="submit" value="'.$LANG->getLL('makesavefo_merge',1).'" name="preset[merge]" onclick="return confirm(\''.$LANG->getLL('makesavefo_areYouSure',1).'\');" />
00999                         <br/>
01000                         '.$LANG->getLL('makesavefo_titleOfNewPreset',1).'
01001                         <input type="text" name="tx_impexp[preset][title]" value="'.htmlspecialchars($inData['preset']['title']).'"'.$this->doc->formWidth(30).' /><br/>
01002                         <label for="checkPresetPublic">'.$LANG->getLL('makesavefo_public',1).'</label>
01003                         <input type="checkbox" name="tx_impexp[preset][public]" id="checkPresetPublic" value="1"'.($inData['preset']['public'] ? ' checked="checked"' : '').' /><br/>
01004                     </td>
01005                 </tr>';
01006 
01007             // Output options:
01008         $row[] = '
01009             <tr class="tableheader bgColor5">
01010                 <td colspan="2">'.$LANG->getLL('makesavefo_outputOptions',1).'</td>
01011             </tr>';
01012 
01013             // Meta data:
01014         $tempDir = $this->userTempFolder();
01015         if ($tempDir)   {
01016             $thumbnails = t3lib_div::getFilesInDir($tempDir,'png,gif,jpg');
01017             array_unshift($thumbnails,'');
01018         } else $thumbnails = FALSE;
01019         $row[] = '
01020                 <tr class="bgColor4">
01021                     <td><strong>'.$LANG->getLL('makesavefo_metaData',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'metadata', $GLOBALS['BACK_PATH'],'').'</td>
01022                     <td>
01023                             '.$LANG->getLL('makesavefo_title',1).' <br/>
01024                             <input type="text" name="tx_impexp[meta][title]" value="'.htmlspecialchars($inData['meta']['title']).'"'.$this->doc->formWidth(30).' /><br/>
01025                             '.$LANG->getLL('makesavefo_description',1).' <br/>
01026                             <input type="text" name="tx_impexp[meta][description]" value="'.htmlspecialchars($inData['meta']['description']).'"'.$this->doc->formWidth(30).' /><br/>
01027                             '.$LANG->getLL('makesavefo_notes',1).' <br/>
01028                             <textarea name="tx_impexp[meta][notes]"'.$this->doc->formWidth(30,1).'>'.t3lib_div::formatForTextarea($inData['meta']['notes']).'</textarea><br/>
01029                             '.(is_array($thumbnails) ? '
01030                             '.$LANG->getLL('makesavefo_thumbnail',1).'<br/>
01031                             '.$this->renderSelectBox('tx_impexp[meta][thumbnail]',$inData['meta']['thumbnail'],$thumbnails).'<br/>
01032                             '.($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/>' : '').'
01033                             '.$LANG->getLL('makesavefo_uploadThumbnail',1).'<br/>
01034                             <input type="file" name="upload_1" '.$this->doc->formWidth(30).' size="30" /><br/>
01035                                 <input type="hidden" name="file[upload][1][target]" value="'.htmlspecialchars($tempDir).'" />
01036                                 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
01037                             ' : '').'
01038                         </td>
01039                 </tr>';
01040 
01041             // Add file options:
01042         $savePath = $this->userSaveFolder();
01043         $opt = array();
01044         if ($this->export->compress)    {
01045             $opt['t3d_compressed'] = $LANG->getLL('makesavefo_t3dFileCompressed');
01046         }
01047         $opt['t3d'] = $LANG->getLL('makesavefo_t3dFile');
01048         $opt['xml'] = $LANG->getLL('makesavefo_xml');
01049         $row[] = '
01050                 <tr class="bgColor4">
01051                     <td><strong>'.$LANG->getLL('makesavefo_fileFormat',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'fileFormat', $GLOBALS['BACK_PATH'],'').'</td>
01052                     <td>'.$this->renderSelectBox('tx_impexp[filetype]',$inData['filetype'],$opt).'<br/>
01053                         '.$LANG->getLL('makesavefo_maxSizeOfFiles',1).'<br/>
01054                         <input type="text" name="tx_impexp[maxFileSize]" value="'.htmlspecialchars($inData['maxFileSize']).'"'.$this->doc->formWidth(10).' /><br/>
01055                         '.($savePath ? sprintf($LANG->getLL('makesavefo_filenameSavedInS',1),substr($savePath,strlen(PATH_site))).'<br/>
01056                         <input type="text" name="tx_impexp[filename]" value="'.htmlspecialchars($inData['filename']).'"'.$this->doc->formWidth(30).' /><br/>' : '').'
01057                     </td>
01058                 </tr>';
01059 
01060 
01061             // Add buttons:
01062         $row[] = '
01063                 <tr class="bgColor4">
01064                     <td>&nbsp;</td>
01065                     <td><input type="submit" value="'.$LANG->getLL('makesavefo_update',1).'" /> - <input type="submit" value="'.$LANG->getLL('makesavefo_downloadExport',1).'" name="tx_impexp[download_export]" />'.
01066                         ($savePath ? ' - <input type="submit" value="'.$LANG->getLL('importdata_saveToFilename',1).'" name="tx_impexp[save_export]" />' : '').'</td>
01067                 </tr>';
01068     }
01069 
01070 
01071 
01072 
01073 
01074 
01075 
01076 
01077 
01078 
01079 
01080 
01081 
01082     /**************************
01083      *
01084      * IMPORT FUNCTIONS
01085      *
01086      **************************/
01087 
01088     /**
01089      * Import part of module
01090      *
01091      * @param   array       Content of POST VAR tx_impexp[]..
01092      * @return  void        Setting content in $this->content
01093      */
01094     function importData($inData)    {
01095         global $TCA,$LANG,$BE_USER;
01096 
01097         $access = is_array($this->pageinfo) ? 1 : 0;
01098 
01099         if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id))  {
01100             if ($BE_USER->user['admin'] && !$this->id)  {
01101                 $this->pageinfo=array('title' => '[root-level]','uid'=>0,'pid'=>0);
01102             }
01103 
01104             if ($inData['new_import'])  {
01105                 unset($inData['import_mode']);
01106             }
01107 
01108             $import = t3lib_div::makeInstance('tx_impexp');
01109             $import->init(0,'import');
01110             $import->update = $inData['do_update'];
01111             $import->import_mode = $inData['import_mode'];
01112             $import->enableLogging = $inData['enableLogging'];
01113             $import->global_ignore_pid = $inData['global_ignore_pid'];
01114             $import->force_all_UIDS = $inData['force_all_UIDS'];
01115             $import->showDiff = !$inData['notShowDiff'];
01116             $import->allowPHPScripts = $inData['allowPHPScripts'];
01117             $import->softrefInputValues = $inData['softrefInputValues'];
01118 
01119 
01120                 // OUTPUT creation:
01121             $menuItems = array();
01122 
01123             // Make input selector:
01124             $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];  // must have trailing slash.
01125             $filesInDir = t3lib_div::getFilesInDir(PATH_site.$path, 't3d,xml', 1, 1);
01126 
01127             $userPath = $this->userSaveFolder(); //Files from User-Dir
01128             $filesInUserDir = t3lib_div::getFilesInDir($userPath, 't3d,xml', 1, 1);
01129 
01130             $filesInDir = array_merge($filesInUserDir, $filesInDir);
01131 
01132             if (is_dir(PATH_site.$path.'export/'))  {
01133                 $filesInDir = array_merge($filesInDir, t3lib_div::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1));
01134             }
01135             $tempFolder = $this->userTempFolder();
01136             if ($tempFolder)    {
01137                 $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder, 't3d,xml', 1, 1);
01138                 $filesInDir = array_merge($filesInDir, $temp_filesInDir);
01139             }
01140 
01141                 // Configuration
01142             $row = array();
01143             $opt = array('');
01144             foreach($filesInDir as $file)   {
01145                 $opt[$file] = substr($file,strlen(PATH_site));
01146             }
01147 
01148             $row[] = '<tr class="bgColor5">
01149                     <td colspan="2"><strong>'.$LANG->getLL('importdata_selectFileToImport',1).'</strong></td>
01150                 </tr>';
01151 
01152             $row[] = '<tr class="bgColor4">
01153                 <td><strong>'.$LANG->getLL('importdata_file',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'],'').'</td>
01154                 <td>'.
01155                     $this->renderSelectBox('tx_impexp[file]',$inData['file'],$opt).'<br />'.sprintf($LANG->getLL('importdata_fromPathS',1),$path).
01156                     (!$import->compress ? '<br /><span class="typo3-red">'.$LANG->getLL('importdata_noteNoDecompressorAvailable',1).'</span>':'').
01157                 '</td>
01158                 </tr>';
01159 
01160             $row[] = '<tr class="bgColor5">
01161                     <td colspan="2"><strong>'.$LANG->getLL('importdata_importOptions',1).'</strong></td>
01162                 </tr>';
01163 
01164             $row[] = '<tr class="bgColor4">
01165                 <td><strong>'.$LANG->getLL('importdata_update',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'],'').'</td>
01166                 <td>
01167                     <input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"'.($inData['do_update'] ? ' checked="checked"' : '').' />
01168                     <label for="checkDo_update">'.$LANG->getLL('importdata_updateRecords',1).'</label><br/>
01169                 <em>('.$LANG->getLL('importdata_thisOptionRequiresThat',1).')</em>'.
01170                 ($inData['do_update'] ?
01171                 '   <hr/>
01172                     <input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"'.($inData['global_ignore_pid'] ? ' checked="checked"' : '').' />
01173                     <label for="checkGlobal_ignore_pid">'.$LANG->getLL('importdata_ignorePidDifferencesGlobally',1).'</label><br/>
01174                     <em>('.$LANG->getLL('importdata_ifYouSetThis',1).')</em>
01175                     ' : ''
01176                 ).'</td>
01177                 </tr>';
01178 
01179             $row[] = '<tr class="bgColor4">
01180                 <td><strong>'.$LANG->getLL('importdata_options',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'],'').'</td>
01181                 <td>
01182                     <input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"'.($inData['notShowDiff'] ? ' checked="checked"' : '').' />
01183                     <label for="checkNotShowDiff">'.$LANG->getLL('importdata_doNotShowDifferences',1).'</label><br/>
01184                     <em>('.$LANG->getLL('importdata_greenValuesAreFrom',1).')</em>
01185                     <br/><br/>
01186 
01187                     '.($GLOBALS['BE_USER']->isAdmin() ? '
01188                     <input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"'.($inData['allowPHPScripts'] ? ' checked="checked"' : '').' />
01189                     <label for="checkAllowPHPScripts">'.$LANG->getLL('importdata_allowToWriteBanned',1).'</label><br/>' : '').
01190 
01191                     (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? '
01192                     <br/>
01193                     <input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"'.($inData['force_all_UIDS'] ? ' checked="checked"' : '').' />
01194                     <label for="checkForce_all_UIDS"><span class="typo3-red">'.$LANG->getLL('importdata_force_all_UIDS',1).'</span></label><br/>
01195                     <em>('.$LANG->getLL('importdata_force_all_UIDS_descr',1).')</em>' : '').
01196                     '
01197                 </td>
01198                 </tr>';
01199 
01200             $row[] = '<tr class="bgColor4">
01201                 <td><strong>'.$LANG->getLL('importdata_action',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'],'').'</td>
01202                 <td>'.
01203                     (!$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).'" />').'
01204                     <input type="hidden" name="tx_impexp[action]" value="import" /></td>
01205                 </tr>';
01206 
01207             $row[] = '<tr class="bgColor4">
01208                 <td><strong>'.$LANG->getLL('importdata_enableLogging',1).'</strong>'.t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'],'').'</td>
01209                 <td>
01210                     <input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"'.($inData['enableLogging'] ? ' checked="checked"' : '').' />
01211                     <label for="checkEnableLogging">'.$LANG->getLL('importdata_writeIndividualDbActions',1).'</label><br/>
01212                     <em>('.$LANG->getLL('importdata_thisIsDisabledBy',1).')</em>
01213                 </td>
01214                 </tr>';
01215 
01216             $menuItems[] = array(
01217                 'label' => $LANG->getLL('importdata_import',1),
01218                 'content' => '
01219                     <table border="0" cellpadding="1" cellspacing="1">
01220                         '.implode('
01221                         ',$row).'
01222                     </table>
01223                 '
01224             );
01225 
01226                 // Upload file:
01227             $tempFolder = $this->userTempFolder();
01228             if ($tempFolder)    {
01229                 $row = array();
01230 
01231                 $row[] = '<tr class="bgColor5">
01232                         <td colspan="2"><strong>'.$LANG->getLL('importdata_uploadFileFromLocal',1).'</strong></td>
01233                     </tr>';
01234 
01235                 $row[] = '<tr class="bgColor4">
01236                         <td>'.$LANG->getLL('importdata_browse',1).t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'],'').'</td>
01237                         <td>
01238 
01239                                 <input type="file" name="upload_1"'.$this->doc->formWidth(35).' size="40" />
01240                                 <input type="hidden" name="file[upload][1][target]" value="'.htmlspecialchars($tempFolder).'" />
01241                                 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
01242 
01243                                 <input type="submit" name="_upload" value="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" />
01244                                 <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>
01245                         </td>
01246                     </tr>';
01247 
01248                 if (t3lib_div::_POST('_upload'))    {
01249                     $row[] = '<tr class="bgColor4">
01250                             <td>'.$LANG->getLL('importdata_uploadStatus',1).'</td>
01251                             <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>
01252                         </tr>';
01253                 }
01254 
01255                 $menuItems[] = array(
01256                     'label' => $LANG->getLL('importdata_upload'),
01257                     'content' => '
01258                         <table border="0" cellpadding="1" cellspacing="1">
01259                             '.implode('
01260                             ',$row).'
01261                         </table>
01262                     '
01263                 );
01264             }
01265 
01266 
01267                 // Perform import or preview depending:
01268             $overviewContent = '';
01269             $extensionInstallationMessage = '';
01270             $emURL = '';
01271             $inFile = t3lib_div::getFileAbsFileName($inData['file']);
01272             if ($inFile && @is_file($inFile))   {
01273                 $trow = array();
01274                 if ($import->loadFile($inFile,1))   {
01275 
01276                         // Check extension dependencies:
01277                     $extKeysToInstall = array();
01278                     if (is_array($import->dat['header']['extensionDependencies']))  {
01279                         foreach($import->dat['header']['extensionDependencies'] as $extKey) {
01280                             if (!t3lib_extMgm::isLoaded($extKey))   {
01281                                 $extKeysToInstall[] = $extKey;
01282                             }
01283                         }
01284                     }
01285 
01286                     if (count($extKeysToInstall)) {
01287                         $passParams = t3lib_div::_POST('tx_impexp');
01288                         unset($passParams['import_mode']);
01289                         unset($passParams['import_file']);
01290 
01291                         $thisScriptUrl = t3lib_div::getIndpEnv('REQUEST_URI').'?M=xMOD_tximpexp&id='.$this->id.t3lib_div::implodeArrayForUrl('tx_impexp',$passParams);
01292                         $emURL = $this->doc->backPath . t3lib_extMgm::extRelPath('em') . 'mod1/index.php?CMD[requestInstallExtensions]=' .
01293                             implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl);
01294                         $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.';
01295                     }
01296 
01297                     if ($inData['import_file']) {
01298                         if (!count($extKeysToInstall))  {
01299                             $import->importData($this->id);
01300                             t3lib_BEfunc::setUpdateSignal('updatePageTree');
01301                         } else {
01302                             t3lib_utility_Http::redirect($emURL);
01303                         }
01304                     }
01305 
01306                     $import->display_import_pid_record = $this->pageinfo;
01307                     $overviewContent = $import->displayContentOverview();
01308                 }
01309 
01310                     // Meta data output:
01311                 $trow[] = '<tr class="bgColor5">
01312                         <td colspan="2"><strong>'.$LANG->getLL('importdata_metaData',1).'</strong></td>
01313                     </tr>';
01314 
01315                 $opt = array('');
01316                 foreach($filesInDir as $file)   {
01317                     $opt[$file] = substr($file,strlen(PATH_site));
01318                 }
01319 
01320                 $trow[] = '<tr class="bgColor4">
01321                     <td><strong>'.$LANG->getLL('importdata_title',1).'</strong></td>
01322                     <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['title'])).'</td>
01323                     </tr>';
01324 
01325                 $trow[] = '<tr class="bgColor4">
01326                     <td><strong>'.$LANG->getLL('importdata_description',1).'</strong></td>
01327                     <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['description'])).'</td>
01328                     </tr>';
01329 
01330                 $trow[] = '<tr class="bgColor4">
01331                     <td><strong>'.$LANG->getLL('importdata_notes',1).'</strong></td>
01332                     <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])).'</td>
01333                     </tr>';
01334 
01335                 $trow[] = '<tr class="bgColor4">
01336                     <td><strong>'.$LANG->getLL('importdata_packager',1).'</strong></td>
01337                     <td width="95%">'.nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'].' ('.$import->dat['header']['meta']['packager_username'].')')).'<br/>
01338                         '.$LANG->getLL('importdata_email',1).' '.$import->dat['header']['meta']['packager_email'].'</td>
01339                     </tr>';
01340 
01341                     // Thumbnail icon:
01342                 if (is_array($import->dat['header']['thumbnail']))  {
01343                     $pI = pathinfo($import->dat['header']['thumbnail']['filename']);
01344                     if (t3lib_div::inList('gif,jpg,png,jpeg',strtolower($pI['extension']))) {
01345 
01346                             // Construct filename and write it:
01347                         $fileName = PATH_site.
01348                                     'typo3temp/importthumb.'.$pI['extension'];
01349                         t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
01350 
01351                             // Check that the image really is an image and not a malicious PHP script...
01352                         if (getimagesize($fileName))    {
01353                                 // Create icon tag:
01354                             $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="" />';
01355 
01356                             $trow[] = '<tr class="bgColor4">
01357                                 <td><strong>'.$LANG->getLL('importdata_icon',1).'</strong></td>
01358                                 <td>'.$iconTag.'</td>
01359                                 </tr>';
01360                         } else {
01361                             t3lib_div::unlink_tempfile($fileName);
01362                         }
01363                     }
01364                 }
01365 
01366                 $menuItems[] = array(
01367                     'label' => $LANG->getLL('importdata_metaData_1387'),
01368                     'content' => '
01369                         <table border="0" cellpadding="1" cellspacing="1">
01370                             '.implode('
01371                             ',$trow).'
01372                         </table>
01373                     '
01374                 );
01375             }
01376 
01377                 // Print errors that might be:
01378             $errors = $import->printErrorLog();
01379             $menuItems[] = array(
01380                 'label' => $LANG->getLL('importdata_messages'),
01381                 'content' => $errors,
01382                 'stateIcon' => $errors ? 2 : 0
01383             );
01384 
01385                 // Output tabs:
01386             $content = $this->doc->getDynTabMenu($menuItems,'tx_impexp_import',-1);
01387             if ($extensionInstallationMessage)  {
01388                 $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;
01389             }
01390             $this->content.= $this->doc->section('',$content,0,1);
01391 
01392 
01393                 // Print overview:
01394             if ($overviewContent) {
01395                 $this->content.= $this->doc->section($inData['import_file'] ? $LANG->getLL('importdata_structureHasBeenImported',1) : $LANG->getLL('filterpage_structureToBeImported',1), $overviewContent, 0, 1);
01396             }
01397         }
01398     }
01399 
01400 
01401 
01402 
01403 
01404 
01405 
01406 
01407 
01408 
01409 
01410 
01411 
01412     /****************************
01413      *
01414      * Preset functions
01415      *
01416      ****************************/
01417 
01418     /**
01419      * Manipulate presets
01420      *
01421      * @param   array       In data array, passed by reference!
01422      * @return  void
01423      */
01424     function processPresets(&$inData)   {
01425 
01426         $presetData = t3lib_div::_GP('preset');
01427         $err = FALSE;
01428 
01429             // Save preset
01430         if (isset($presetData['save'])) {
01431             $preset = $this->getPreset($presetData['select']);
01432             if (is_array($preset))  {   // Update existing
01433                 if ($GLOBALS['BE_USER']->isAdmin() || $preset['user_uid'] === $GLOBALS['BE_USER']->user['uid']) {
01434                     $fields_values = array(
01435                         'public' => $inData['preset']['public'],
01436                         'title' => $inData['preset']['title'],
01437                         'item_uid' => $inData['pagetree']['id'],
01438                         'preset_data' => serialize($inData)
01439                     );
01440                     $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_impexp_presets','uid='.intval($preset['uid']),$fields_values);
01441                     $msg = 'Preset #'.$preset['uid'].' saved!';
01442                 } else {
01443                     $msg = 'ERROR: The preset was not saved because you were not the owner of it!';
01444                     $err = TRUE;
01445                 }
01446             } else {    // Insert new:
01447                 $fields_values = array(
01448                     'user_uid' => $GLOBALS['BE_USER']->user['uid'],
01449                     'public' => $inData['preset']['public'],
01450                     'title' => $inData['preset']['title'],
01451                     'item_uid' => $inData['pagetree']['id'],
01452                     'preset_data' => serialize($inData)
01453                 );
01454                 $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_impexp_presets',$fields_values);
01455                 $msg = 'New preset "' . htmlspecialchars($inData['preset']['title']) . '" is created';
01456             }
01457         }
01458 
01459             // Delete preset:
01460         if (isset($presetData['delete']))   {
01461             $preset = $this->getPreset($presetData['select']);
01462             if (is_array($preset))  {   // Update existing
01463                 if ($GLOBALS['BE_USER']->isAdmin() || $preset['user_uid'] === $GLOBALS['BE_USER']->user['uid']) {
01464                     $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_impexp_presets','uid='.intval($preset['uid']));
01465                     $msg = 'Preset #'.$preset['uid'].' deleted!';
01466                 } else {
01467                     $msg = 'ERROR: You were not the owner of the preset so you could not delete it.';
01468                     $err = TRUE;
01469                 }
01470             } else {
01471                 $msg = 'ERROR: No preset selected for deletion.';
01472                 $err = TRUE;
01473             }
01474         }
01475 
01476             // Load preset
01477         if (isset($presetData['load']) || isset($presetData['merge']))  {
01478             $preset = $this->getPreset($presetData['select']);
01479             if (is_array($preset))  {   // Update existing
01480                 $inData_temp = unserialize($preset['preset_data']);
01481                 if (is_array($inData_temp)) {
01482                     if (isset($presetData['merge']))    {
01483 
01484                             // Merge records in:
01485                         if (is_array($inData_temp['record']))   {
01486                             $inData['record'] = array_merge((array)$inData['record'], $inData_temp['record']);
01487                         }
01488 
01489                             // Merge lists in:
01490                         if (is_array($inData_temp['list'])) {
01491                             $inData['list'] = array_merge((array)$inData['list'], $inData_temp['list']);
01492                         }
01493                     } else {
01494                         $msg = 'Preset #'.$preset['uid'].' loaded!';
01495                         $inData = $inData_temp;
01496                     }
01497                 } else {
01498                     $msg = 'ERROR: No configuratio data found in preset record!';
01499                     $err = TRUE;
01500                 }
01501             } else {
01502                 $msg = 'ERROR: No preset selected for loading.';
01503                 $err = TRUE;
01504             }
01505         }
01506 
01507             // Show message:
01508         if (strlen($msg))   {
01509             $this->content.= $this->doc->section('Presets',$msg,0,1,$err ? 3 : 1);
01510         }
01511     }
01512 
01513     /**
01514      * Get single preset record
01515      *
01516      * @param   integer     Preset record
01517      * @return  array       Preset record, if any (otherwise false)
01518      */
01519     function getPreset($uid)    {
01520         $preset = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'tx_impexp_presets', 'uid=' . intval($uid));
01521         return $preset;
01522     }
01523 
01524 
01525 
01526 
01527 
01528 
01529 
01530 
01531 
01532 
01533 
01534     /****************************
01535      *
01536      * Helper functions
01537      *
01538      ****************************/
01539 
01540     /**
01541      * Returns first temporary folder of the user account (from $FILEMOUNTS)
01542      *
01543      * @return  string      Absolute path to first "_temp_" folder of the current user, otherwise blank.
01544      */
01545     function userTempFolder()   {
01546         global $FILEMOUNTS;
01547 
01548         foreach($FILEMOUNTS as $filePathInfo)   {
01549             $tempFolder = $filePathInfo['path'].'_temp_/';
01550             if (@is_dir($tempFolder))   {
01551                 return $tempFolder;
01552             }
01553         }
01554     }
01555 
01556     /**
01557      * Returns folder where user can save export files.
01558      *
01559      * @return  string      Absolute path to folder where export files can be saved.
01560      */
01561     function userSaveFolder()   {
01562         global $FILEMOUNTS;
01563 
01564         reset($FILEMOUNTS);
01565         $filePathInfo = current($FILEMOUNTS);
01566 
01567         if (is_array($filePathInfo))    {
01568             $tempFolder = $filePathInfo['path'].'export/';
01569             if (!@is_dir($tempFolder))  {
01570                 $tempFolder = $filePathInfo['path'];
01571                 if (!@is_dir($tempFolder))  {
01572                     return FALSE;
01573                 }
01574             }
01575             return $tempFolder;
01576         }
01577     }
01578 
01579     /**
01580      * Check if a file has been uploaded
01581      *
01582      * @return  void
01583      */
01584     function checkUpload()  {
01585         global $FILEMOUNTS,$TYPO3_CONF_VARS,$BE_USER;
01586 
01587         $file = t3lib_div::_GP('file');
01588 
01589             // Initializing:
01590         $this->fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
01591         $this->fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
01592         $this->fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
01593         $this->fileProcessor->dontCheckForUnique = t3lib_div::_GP('overwriteExistingFiles') ? 1 : 0;
01594 
01595             // Checking referer / executing:
01596         $refInfo = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER'));
01597         $httpHost = t3lib_div::getIndpEnv('TYPO3_HOST_ONLY');
01598         if ($httpHost!=$refInfo['host'] && $this->vC!=$BE_USER->veriCode() && !$TYPO3_CONF_VARS['SYS']['doNotCheckReferer'])    {
01599             $this->fileProcessor->writeLog(0,2,1,'Referer host "%s" and server host "%s" did not match!',array($refInfo['host'],$httpHost));
01600         } else {
01601             $this->fileProcessor->start($file);
01602             $this->fileProcessor->processData();
01603         }
01604     }
01605 
01606     /**
01607      * Makes a selector-box from optValues
01608      *
01609      * @param   string      Form element name
01610      * @param   string      Current value
01611      * @param   array       Options to display (key/value pairs)
01612      * @return  string      HTML select element
01613      */
01614     function renderSelectBox($prefix,$value,$optValues) {
01615         $opt = array();
01616         $isSelFlag = 0;
01617         foreach ($optValues as $k => $v) {
01618             $sel = (!strcmp($k,$value) ? ' selected="selected"' : '');
01619             if ($sel)   $isSelFlag++;
01620             $opt[] = '<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
01621         }
01622         if (!$isSelFlag && strcmp('',$value))   {
01623             $opt[] = '<option value="'.htmlspecialchars($value).'" selected="selected">'.htmlspecialchars("['".$value."']").'</option>';
01624         }
01625         return '<select name="'.$prefix.'">'.implode('',$opt).'</select>';
01626     }
01627 
01628     /**
01629      * Returns a selector-box with TCA tables
01630      *
01631      * @param   string      Form element name prefix
01632      * @param   array       The current values selected
01633      * @param   string      Table names (and the string "_ALL") to exclude. Comma list
01634      * @return  string      HTML select element
01635      */
01636     function tableSelector($prefix,$value,$excludeList='')  {
01637         global $TCA, $LANG;
01638 
01639         $optValues = array();
01640 
01641         if (!t3lib_div::inList($excludeList,'_ALL'))    {
01642             $optValues['_ALL'] = '['.$LANG->getLL('ALL_tables').']';
01643         }
01644 
01645         foreach ($TCA as $table => $_) {
01646             if ($GLOBALS['BE_USER']->check('tables_select',$table) && !t3lib_div::inList($excludeList,$table))  {
01647                 $optValues[$table] = $table;
01648             }
01649         }
01650 
01651             // make box:
01652         $opt = array();
01653         $opt[] = '<option value=""></option>';
01654         foreach ($optValues as $k => $v) {
01655             if (is_array($value))   {
01656                 $sel = in_array($k,$value)?' selected="selected"':'';
01657             }
01658             $opt[] = '<option value="'.htmlspecialchars($k).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
01659         }
01660         return '<select name="'.$prefix.'[]" multiple="multiple" size="'.t3lib_div::intInRange(count($opt),5,10).'">'.implode('',$opt).'</select>';
01661     }
01662 
01663     /**
01664      * Returns a selector-box with loaded extension keys
01665      *
01666      * @param   string      Form element name prefix
01667      * @param   array       The current values selected
01668      * @return  string      HTML select element
01669      */
01670     function extensionSelector($prefix,$value)  {
01671         global $TYPO3_LOADED_EXT;
01672 
01673         $extTrav = array_keys($TYPO3_LOADED_EXT);
01674 
01675             // make box:
01676         $opt = array();
01677         $opt[] = '<option value=""></option>';
01678         foreach($extTrav as $v) {
01679             if ($v!=='_CACHEFILE')  {
01680                 if (is_array($value))   {
01681                     $sel = in_array($v,$value)?' selected="selected"':'';
01682                 }
01683                 $opt[] = '<option value="'.htmlspecialchars($v).'"'.$sel.'>'.htmlspecialchars($v).'</option>';
01684             }
01685         }
01686         return '<select name="'.$prefix.'[]" multiple="multiple" size="'.t3lib_div::intInRange(count($opt),5,10).'">'.implode('',$opt).'</select>';
01687     }
01688 
01689     /**
01690      * Filter page IDs by traversing exclude array, finding all excluded pages (if any) and making an AND NOT IN statement for the select clause.
01691      *
01692      * @param   array       Exclude array from import/export object.
01693      * @return  string      AND where clause part to filter out page uids.
01694      */
01695     function filterPageIds($exclude)    {
01696 
01697             // Get keys:
01698         $exclude = array_keys($exclude);
01699 
01700             // Traverse
01701         $pageIds = array();
01702         foreach($exclude as $element)   {
01703             list($table,$uid) = explode(':', $element);
01704             if ($table==='pages')   {
01705                 $pageIds[] = intval($uid);
01706             }
01707         }
01708 
01709             // Add to clause:
01710         if (count($pageIds))    {
01711             return ' AND uid NOT IN ('.implode(',', $pageIds).')';
01712         }
01713     }
01714 }
01715 
01716 
01717 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php'])) {
01718     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/impexp/app/index.php']);
01719 }
01720 
01721 
01722 
01723 // Make instance:
01724 $SOBE = t3lib_div::makeInstance('SC_mod_tools_log_index');
01725 $SOBE->init();
01726 $SOBE->main();
01727 $SOBE->printContent();
01728 
01729 ?>