[BUGFIX] Fix file handling in import/export module
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / FolderStructure / DefaultFactory.php
1 <?php
2 namespace TYPO3\CMS\Install\FolderStructure;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Factory returns default folder structure object hierarchy
29 */
30 class DefaultFactory {
31
32 /**
33 * Get default structure object hierarchy
34 *
35 * @throws Exception
36 * @return RootNode
37 * @TODO: Use objectManager instead of new (will be injected)
38 */
39 public function getStructure() {
40 $rootNode = new RootNode($this->getDefaultStructureDefinition(), NULL);
41 if (!($rootNode instanceof RootNodeInterface)) {
42 throw new Exception(
43 'Root node must implement RootNodeInterface',
44 1366139176
45 );
46 }
47 $structureFacade = new StructureFacade($rootNode);
48 if (!($structureFacade instanceof StructureFacadeInterface)) {
49 throw new Exception(
50 'Structure facade must implement StructureFacadeInterface',
51 1366535827
52 );
53 }
54 return $structureFacade;
55 }
56
57 /**
58 * Default definition of folder and file structure with dynamic
59 * permission settings
60 *
61 * @return array
62 */
63 protected function getDefaultStructureDefinition() {
64 $filePermission = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'];
65 $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'];
66
67 return array(
68 // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
69 'name' => substr(PATH_site, 0, -1),
70 'targetPermission' => $directoryPermission,
71 'children' => array(
72 array(
73 'name' => 'index.php',
74 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\LinkNode',
75 'target' => 'typo3_src/index.php',
76 ),
77 array(
78 'name' => 'typo3',
79 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\LinkNode',
80 'target' => 'typo3_src/typo3',
81 ),
82 array(
83 'name' => 'typo3_src',
84 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\LinkNode',
85 ),
86 array(
87 'name' => 'typo3temp',
88 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
89 'targetPermission' => $directoryPermission,
90 'children' => array(
91 array(
92 'name' => 'index.html',
93 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
94 'targetPermission' => $filePermission,
95 'targetContent' => '',
96 ),
97 array(
98 'name' => 'compressor',
99 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
100 'targetPermission' => $directoryPermission,
101 ),
102 array(
103 'name' => 'cs',
104 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
105 'targetPermission' => $directoryPermission,
106 ),
107 array(
108 'name' => 'Cache',
109 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
110 'targetPermission' => $directoryPermission,
111 ),
112 array(
113 'name' => 'GB',
114 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
115 'targetPermission' => $directoryPermission,
116 ),
117 array(
118 'name' => 'llxml',
119 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
120 'targetPermission' => $directoryPermission,
121 ),
122 array(
123 'name' => 'locks',
124 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
125 'targetPermission' => $directoryPermission,
126 ),
127 array(
128 'name' => 'pics',
129 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
130 'targetPermission' => $directoryPermission,
131 ),
132 array(
133 'name' => 'sprites',
134 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
135 'targetPermission' => $directoryPermission,
136 ),
137 array(
138 'name' => 'temp',
139 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
140 'targetPermission' => $directoryPermission,
141 ),
142 ),
143 ),
144 array(
145 'name' => 'typo3conf',
146 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
147 'targetPermission' => $directoryPermission,
148 'children' => array(
149 array(
150 'name' => 'ext',
151 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
152 'targetPermission' => $directoryPermission,
153 ),
154 array(
155 'name' => 'l10n',
156 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
157 'targetPermission' => $directoryPermission,
158 ),
159 ),
160 ),
161 array(
162 'name' => 'uploads',
163 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
164 'targetPermission' => $directoryPermission,
165 'children' => array(
166 array(
167 'name' => 'index.html',
168 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
169 'targetPermission' => $filePermission,
170 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/uploads-index.html',
171 ),
172 array(
173 'name' => 'media',
174 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
175 'targetPermission' => $directoryPermission,
176 'children' => array(
177 array(
178 'name' => 'index.html',
179 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
180 'targetPermission' => $filePermission,
181 'targetContent' => '',
182 ),
183 ),
184 ),
185 array(
186 'name' => 'pics',
187 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
188 'targetPermission' => $directoryPermission,
189 'children' => array(
190 array(
191 'name' => 'index.html',
192 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
193 'targetPermission' => $filePermission,
194 'targetContent' => '',
195 ),
196 ),
197 ),
198 array(
199 'name' => 'tf',
200 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
201 'targetPermission' => $directoryPermission,
202 'children' => array(
203 array(
204 'name' => 'index.html',
205 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
206 'targetPermission' => $filePermission,
207 'targetContent' => '',
208 ),
209 ),
210 ),
211 ),
212 ),
213 array(
214 'name' => !empty($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) ? rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') : 'fileadmin',
215 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
216 'targetPermission' => $directoryPermission,
217 'children' => array(
218 array(
219 'name' => '_temp_',
220 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
221 'targetPermission' => $directoryPermission,
222 'children' => array(
223 array(
224 'name' => '.htaccess',
225 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
226 'targetPermission' => $filePermission,
227 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-htaccess',
228 ),
229 array(
230 'name' => 'index.html',
231 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
232 'targetPermission' => $filePermission,
233 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
234 ),
235 ),
236 ),
237 array(
238 'name' => 'user_upload',
239 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
240 'targetPermission' => $directoryPermission,
241 'children' => array(
242 array(
243 'name' => '_temp_',
244 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
245 'targetPermission' => $directoryPermission,
246 'children' => array(
247 array(
248 'name' => 'index.html',
249 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
250 'targetPermission' => $filePermission,
251 'targetContent' => '',
252 ),
253 array(
254 'name' => 'importexport',
255 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
256 'targetPermission' => $directoryPermission,
257 'children' => array(
258 array(
259 'name' => '.htaccess',
260 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
261 'targetPermission' => $filePermission,
262 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-user_upload-temp-importexport-htaccess',
263 ),
264 array(
265 'name' => 'index.html',
266 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
267 'targetPermission' => $filePermission,
268 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
269 ),
270 ),
271 ),
272 ),
273 ),
274 array(
275 'name' => 'index.html',
276 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
277 'targetPermission' => $filePermission,
278 'targetContent' => '',
279 ),
280 ),
281 ),
282 ),
283 ),
284 ),
285 );
286 }
287 }