TYPO3 CMS  TYPO3_7-6
AbstractExportTestCase.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 
24 {
28  protected $coreExtensionsToLoad = ['impexp'];
29 
33  protected $export;
34 
41  protected function setUp()
42  {
43  parent::setUp();
44 
45  $this->setUpBackendUserFromFixture(1);
46  // Needed to avoid PHP Warnings
47  $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'] = [];
48 
49  \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
50 
51  $this->export = GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\Export::class);
52  $this->export->init(0, 'export');
53  }
54 
63  protected function setPageTree($pidToStart, $depth = 1)
64  {
65  $permsClause = $GLOBALS['BE_USER']->getPagePermsClause(1);
66 
68  $tree = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\View\PageTreeView::class);
69  $tree->init('AND ' . $permsClause);
70  $tree->tree[] = ['row' => $pidToStart];
71  $tree->buffer_idH = [];
72  if ($depth > 0) {
73  $tree->getTree($pidToStart, $depth, '');
74  }
75 
76  $idH[$pidToStart]['uid'] = $pidToStart;
77  if (!empty($tree->buffer_idH)) {
78  $idH[$pidToStart]['subrow'] = $tree->buffer_idH;
79  }
80 
81  $this->export->setPageTree($idH);
82  }
83 
91  protected function addRecordsForPid($pid, array $tables)
92  {
93  foreach ($GLOBALS['TCA'] as $table => $value) {
94  if ($table != 'pages' && (in_array($table, $tables) || in_array('_ALL', $tables))) {
95  if ($GLOBALS['BE_USER']->check('tables_select', $table) && !$GLOBALS['TCA'][$table]['ctrl']['is_static']) {
96  $orderBy = $GLOBALS['TCA'][$table]['ctrl']['sortby'] ? 'ORDER BY ' . $GLOBALS['TCA'][$table]['ctrl']['sortby'] : $GLOBALS['TCA'][$table]['ctrl']['default_sortby'];
97  $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
98  '*',
99  $table,
100  'pid = ' . (int)$pid . BackendUtility::deleteClause($table),
101  '',
102  $GLOBALS['TYPO3_DB']->stripOrderBy($orderBy)
103  );
104  while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
105  $this->export->export_addRecord($table, $row);
106  }
107  }
108  }
109  }
110  }
111 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static deleteClause($table, $tableAlias='')