[TASK] Move publicly accessible files to typo3temp/assets/
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / FolderStructure / DefaultFactory.php
1 <?php
2 namespace TYPO3\CMS\Install\FolderStructure;
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
17 use TYPO3\CMS\Core\Core\Bootstrap;
18
19 /**
20 * Factory returns default folder structure object hierarchy
21 */
22 class DefaultFactory
23 {
24 /**
25 * Get default structure object hierarchy
26 *
27 * @throws Exception
28 * @return RootNode
29 * @TODO: Use objectManager instead of new (will be injected)
30 */
31 public function getStructure()
32 {
33 $rootNode = new RootNode($this->getDefaultStructureDefinition(), null);
34 if (!($rootNode instanceof RootNodeInterface)) {
35 throw new Exception(
36 'Root node must implement RootNodeInterface',
37 1366139176
38 );
39 }
40 $structureFacade = new StructureFacade($rootNode);
41 if (!($structureFacade instanceof StructureFacadeInterface)) {
42 throw new Exception(
43 'Structure facade must implement StructureFacadeInterface',
44 1366535827
45 );
46 }
47 return $structureFacade;
48 }
49
50 /**
51 * Default definition of folder and file structure with dynamic
52 * permission settings
53 *
54 * @return array
55 */
56 protected function getDefaultStructureDefinition()
57 {
58 $filePermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'];
59 $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'];
60
61 if (Bootstrap::usesComposerClassLoading()) {
62 // In composer mode the links are configurable and might even be actual files
63 // Ignore this structure in this case
64 $structureAdditional = array();
65 } else {
66 $structureAdditional = array(
67 array(
68 'name' => 'index.php',
69 'type' => LinkNode::class,
70 'target' => 'typo3_src/index.php',
71 ),
72 array(
73 'name' => 'typo3',
74 'type' => LinkNode::class,
75 'target' => 'typo3_src/typo3',
76 ),
77 array(
78 'name' => 'typo3_src',
79 'type' => LinkNode::class,
80 ),
81 );
82 }
83 $structureBase = array(
84 array(
85 'name' => 'typo3temp',
86 'type' => DirectoryNode::class,
87 'targetPermission' => $directoryPermission,
88 'children' => array(
89 array(
90 'name' => 'index.html',
91 'type' => FileNode::class,
92 'targetPermission' => $filePermission,
93 'targetContent' => '',
94 ),
95 array(
96 'name' => 'assets',
97 'type' => DirectoryNode::class,
98 'targetPermission' => $directoryPermission,
99 'children' => array(
100 array(
101 'name' => 'compressed',
102 'type' => DirectoryNode::class,
103 'targetPermission' => $directoryPermission
104 ),
105 array(
106 'name' => 'css',
107 'type' => DirectoryNode::class,
108 'targetPermission' => $directoryPermission
109 ),
110 array(
111 'name' => 'js',
112 'type' => DirectoryNode::class,
113 'targetPermission' => $directoryPermission
114 ),
115 array(
116 'name' => 'images',
117 'type' => DirectoryNode::class,
118 'targetPermission' => $directoryPermission
119 ),
120 array(
121 'name' => 'transient',
122 'type' => DirectoryNode::class,
123 'targetPermission' => $directoryPermission
124 ),
125 array(
126 'name' => '_processed_',
127 'type' => DirectoryNode::class,
128 'targetPermission' => $directoryPermission
129 )
130 )
131 ),
132 array(
133 'name' => 'cs',
134 'type' => DirectoryNode::class,
135 'targetPermission' => $directoryPermission,
136 ),
137 array(
138 'name' => 'Cache',
139 'type' => DirectoryNode::class,
140 'targetPermission' => $directoryPermission,
141 ),
142 array(
143 'name' => 'locks',
144 'type' => DirectoryNode::class,
145 'targetPermission' => $directoryPermission,
146 ),
147 ),
148 ),
149 array(
150 'name' => 'typo3conf',
151 'type' => DirectoryNode::class,
152 'targetPermission' => $directoryPermission,
153 'children' => array(
154 array(
155 'name' => 'ext',
156 'type' => DirectoryNode::class,
157 'targetPermission' => $directoryPermission,
158 ),
159 array(
160 'name' => 'l10n',
161 'type' => DirectoryNode::class,
162 'targetPermission' => $directoryPermission,
163 ),
164 ),
165 ),
166 array(
167 'name' => 'uploads',
168 'type' => DirectoryNode::class,
169 'targetPermission' => $directoryPermission,
170 'children' => array(
171 array(
172 'name' => 'index.html',
173 'type' => FileNode::class,
174 'targetPermission' => $filePermission,
175 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/uploads-index.html',
176 ),
177 array(
178 'name' => 'media',
179 'type' => DirectoryNode::class,
180 'targetPermission' => $directoryPermission,
181 'children' => array(
182 array(
183 'name' => 'index.html',
184 'type' => FileNode::class,
185 'targetPermission' => $filePermission,
186 'targetContent' => '',
187 ),
188 ),
189 ),
190 array(
191 'name' => 'pics',
192 'type' => DirectoryNode::class,
193 'targetPermission' => $directoryPermission,
194 'children' => array(
195 array(
196 'name' => 'index.html',
197 'type' => FileNode::class,
198 'targetPermission' => $filePermission,
199 'targetContent' => '',
200 ),
201 ),
202 ),
203 array(
204 'name' => 'tx_felogin',
205 'type' => DirectoryNode::class,
206 'targetPermission' => $directoryPermission,
207 ),
208 ),
209 ),
210 array(
211 'name' => !empty($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) ? rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') : 'fileadmin',
212 'type' => DirectoryNode::class,
213 'targetPermission' => $directoryPermission,
214 'children' => array(
215 array(
216 'name' => '_temp_',
217 'type' => DirectoryNode::class,
218 'targetPermission' => $directoryPermission,
219 'children' => array(
220 array(
221 'name' => '.htaccess',
222 'type' => FileNode::class,
223 'targetPermission' => $filePermission,
224 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-htaccess',
225 ),
226 array(
227 'name' => 'index.html',
228 'type' => FileNode::class,
229 'targetPermission' => $filePermission,
230 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
231 ),
232 ),
233 ),
234 array(
235 'name' => 'user_upload',
236 'type' => DirectoryNode::class,
237 'targetPermission' => $directoryPermission,
238 'children' => array(
239 array(
240 'name' => '_temp_',
241 'type' => DirectoryNode::class,
242 'targetPermission' => $directoryPermission,
243 'children' => array(
244 array(
245 'name' => 'index.html',
246 'type' => FileNode::class,
247 'targetPermission' => $filePermission,
248 'targetContent' => '',
249 ),
250 array(
251 'name' => 'importexport',
252 'type' => DirectoryNode::class,
253 'targetPermission' => $directoryPermission,
254 'children' => array(
255 array(
256 'name' => '.htaccess',
257 'type' => FileNode::class,
258 'targetPermission' => $filePermission,
259 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-user_upload-temp-importexport-htaccess',
260 ),
261 array(
262 'name' => 'index.html',
263 'type' => FileNode::class,
264 'targetPermission' => $filePermission,
265 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
266 ),
267 ),
268 ),
269 ),
270 ),
271 array(
272 'name' => 'index.html',
273 'type' => FileNode::class,
274 'targetPermission' => $filePermission,
275 'targetContent' => '',
276 ),
277 ),
278 ),
279 ),
280 ),
281 );
282
283 return array(
284 // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
285 'name' => substr(PATH_site, 0, -1),
286 'targetPermission' => $directoryPermission,
287 'children' => array_merge($structureAdditional, $structureBase)
288 );
289 }
290 }