[BUGFIX] Folder structure honors file and folderCreateMask
[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 hierachie
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' => 'typo3temp',
74 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
75 'targetPermission' => $directoryPermission,
76 'children' => array(
77 array(
78 'name' => 'index.html',
79 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
80 'targetPermission' => $filePermission,
81 'targetContent' => '',
82 ),
83 array(
84 'name' => 'compressor',
85 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
86 'targetPermission' => $directoryPermission,
87 ),
88 array(
89 'name' => 'cs',
90 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
91 'targetPermission' => $directoryPermission,
92 ),
93 array(
94 'name' => 'Cache',
95 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
96 'targetPermission' => $directoryPermission,
97 ),
98 array(
99 'name' => 'GB',
100 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
101 'targetPermission' => $directoryPermission,
102 ),
103 array(
104 'name' => 'llxml',
105 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
106 'targetPermission' => $directoryPermission,
107 ),
108 array(
109 'name' => 'locks',
110 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
111 'targetPermission' => $directoryPermission,
112 ),
113 array(
114 'name' => 'pics',
115 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
116 'targetPermission' => $directoryPermission,
117 ),
118 array(
119 'name' => 'sprites',
120 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
121 'targetPermission' => $directoryPermission,
122 ),
123 array(
124 'name' => 'temp',
125 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
126 'targetPermission' => $directoryPermission,
127 ),
128 ),
129 ),
130 array(
131 'name' => 'typo3conf',
132 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
133 'targetPermission' => $directoryPermission,
134 'children' => array(
135 array(
136 'name' => 'ext',
137 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
138 'targetPermission' => $directoryPermission,
139 ),
140 array(
141 'name' => 'l10n',
142 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
143 'targetPermission' => $directoryPermission,
144 ),
145 ),
146 ),
147 array(
148 'name' => 'uploads',
149 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
150 'targetPermission' => $directoryPermission,
151 'children' => array(
152 array(
153 'name' => 'index.html',
154 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
155 'targetPermission' => $filePermission,
156 'targetContent' =>
157 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' . LF .
158 '<HTML>' . LF .
159 '<HEAD>' . LF .
160 TAB . '<TITLE></TITLE>' . LF .
161 '<META http-equiv=Refresh Content="0; Url=../">' . LF .
162 '</HEAD>' . LF .
163 '</HTML>',
164 ),
165 array(
166 'name' => 'media',
167 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
168 'targetPermission' => $directoryPermission,
169 'children' => array(
170 array(
171 'name' => 'index.html',
172 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
173 'targetPermission' => $filePermission,
174 'targetContent' => '',
175 ),
176 ),
177 ),
178 array(
179 'name' => 'pics',
180 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
181 'targetPermission' => $directoryPermission,
182 'children' => array(
183 array(
184 'name' => 'index.html',
185 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
186 'targetPermission' => $filePermission,
187 'targetContent' => '',
188 ),
189 ),
190 ),
191 array(
192 'name' => 'tf',
193 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
194 'targetPermission' => $directoryPermission,
195 'children' => array(
196 array(
197 'name' => 'index.html',
198 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
199 'targetPermission' => $filePermission,
200 'targetContent' => '',
201 ),
202 ),
203 ),
204 ),
205 ),
206 array(
207 'name' => 'fileadmin',
208 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
209 'targetPermission' => $directoryPermission,
210 'children' => array(
211 array(
212 'name' => '_temp_',
213 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
214 'targetPermission' => $directoryPermission,
215 'children' => array(
216 array(
217 'name' => '.htaccess',
218 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
219 'targetPermission' => $filePermission,
220 'targetContent' =>
221 '# This file restricts access to the fileadmin/_temp_ directory. It is' . LF .
222 '# meant to protect temporary files which could contain sensible' . LF .
223 '# information. Please do not touch.' . LF .
224 LF .
225 'Order deny,allow' . LF .
226 'Deny from all' . LF,
227 ),
228 array(
229 'name' => 'index.html',
230 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
231 'targetPermission' => $filePermission,
232 'targetContent' =>
233 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' . LF .
234 '<HTML>' . LF .
235 '<HEAD>' . LF .
236 TAB . '<TITLE></TITLE>' . LF .
237 '<META http-equiv=Refresh Content="0; Url=/">' . LF .
238 '</HEAD>' . LF .
239 '</HTML>',
240 ),
241 ),
242 ),
243 array(
244 'name' => 'user_upload',
245 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
246 'targetPermission' => $directoryPermission,
247 'children' => array(
248 array(
249 'name' => '_temp_',
250 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
251 'targetPermission' => $directoryPermission,
252 'children' => array(
253 array(
254 'name' => 'index.html',
255 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
256 'targetPermission' => $filePermission,
257 'targetContent' => '',
258 ),
259 ),
260 ),
261 array(
262 'name' => 'index.html',
263 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
264 'targetPermission' => $filePermission,
265 'targetContent' => '',
266 ),
267 ),
268 ),
269 ),
270 ),
271 ),
272 );
273 }
274
275 }
276 ?>