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