[!!!][TASK] Rewrite install tool
[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 * @var array Expected folder structure
34 */
35 protected $expectedDefaultStructure = array();
36
37 /**
38 * Constructor
39 */
40 public function __construct() {
41 $this->expectedDefaultStructure = array(
42 // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
43 'name' => substr(PATH_site, 0, -1),
44 'targetPermission' => '2770',
45 'children' => array(
46 array(
47 'name' => 'typo3temp',
48 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
49 'targetPermission' => '2770',
50 'children' => array(
51 array(
52 'name' => 'index.html',
53 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
54 'targetPermission' => '0660',
55 'targetContent' => '',
56 ),
57 array(
58 'name' => 'compressor',
59 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
60 'targetPermission' => '2770',
61 ),
62 array(
63 'name' => 'cs',
64 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
65 'targetPermission' => '2770',
66 ),
67 array(
68 'name' => 'Cache',
69 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
70 'targetPermission' => '2770',
71 ),
72 array(
73 'name' => 'GB',
74 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
75 'targetPermission' => '2770',
76 ),
77 array(
78 'name' => 'llxml',
79 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
80 'targetPermission' => '2770',
81 ),
82 array(
83 'name' => 'locks',
84 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
85 'targetPermission' => '2770',
86 ),
87 array(
88 'name' => 'pics',
89 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
90 'targetPermission' => '2770',
91 ),
92 array(
93 'name' => 'sprites',
94 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
95 'targetPermission' => '2770',
96 ),
97 array(
98 'name' => 'temp',
99 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
100 'targetPermission' => '2770',
101 ),
102 ),
103 ),
104 array(
105 'name' => 'typo3conf',
106 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
107 'targetPermission' => '2770',
108 'children' => array(
109 array(
110 'name' => 'ext',
111 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
112 'targetPermission' => '2770',
113 ),
114 array(
115 'name' => 'l10n',
116 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
117 'targetPermission' => '2770',
118 ),
119 ),
120 ),
121 array(
122 'name' => 'uploads',
123 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
124 'targetPermission' => '2770',
125 'children' => array(
126 array(
127 'name' => 'index.html',
128 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
129 'targetPermission' => '0660',
130 'targetContent' =>
131 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' . LF .
132 '<HTML>' . LF .
133 '<HEAD>' . LF .
134 TAB . '<TITLE></TITLE>' . LF .
135 '<META http-equiv=Refresh Content="0; Url=../">' . LF .
136 '</HEAD>' . LF .
137 '</HTML>',
138 ),
139 array(
140 'name' => 'media',
141 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
142 'targetPermission' => '2770',
143 'children' => array(
144 array(
145 'name' => 'index.html',
146 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
147 'targetPermission' => '0660',
148 'targetContent' => '',
149 ),
150 ),
151 ),
152 array(
153 'name' => 'pics',
154 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
155 'targetPermission' => '2770',
156 'children' => array(
157 array(
158 'name' => 'index.html',
159 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
160 'targetPermission' => '0660',
161 'targetContent' => '',
162 ),
163 ),
164 ),
165 array(
166 'name' => 'tf',
167 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
168 'targetPermission' => '2770',
169 'children' => array(
170 array(
171 'name' => 'index.html',
172 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
173 'targetPermission' => '0660',
174 'targetContent' => '',
175 ),
176 ),
177 ),
178 ),
179 ),
180 array(
181 'name' => 'fileadmin',
182 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
183 'targetPermission' => '2770',
184 'children' => array(
185 array(
186 'name' => '_temp_',
187 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
188 'targetPermission' => '2770',
189 'children' => array(
190 array(
191 'name' => '.htaccess',
192 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
193 'targetPermission' => '0660',
194 'targetContent' =>
195 '# This file restricts access to the fileadmin/_temp_ directory. It is' . LF .
196 '# meant to protect temporary files which could contain sensible' . LF .
197 '# information. Please do not touch.' . LF .
198 LF .
199 'Order deny,allow' . LF .
200 'Deny from all' . LF,
201 ),
202 array(
203 'name' => 'index.html',
204 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
205 'targetPermission' => '0660',
206 'targetContent' =>
207 '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">' . LF .
208 '<HTML>' . LF .
209 '<HEAD>' . LF .
210 TAB . '<TITLE></TITLE>' . LF .
211 '<META http-equiv=Refresh Content="0; Url=/">' . LF .
212 '</HEAD>' . LF .
213 '</HTML>',
214 ),
215 ),
216 ),
217 array(
218 'name' => 'user_upload',
219 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
220 'targetPermission' => '2770',
221 'children' => array(
222 array(
223 'name' => '_temp_',
224 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
225 'targetPermission' => '2770',
226 'children' => array(
227 array(
228 'name' => 'index.html',
229 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
230 'targetPermission' => '0660',
231 'targetContent' => '',
232 ),
233 ),
234 ),
235 array(
236 'name' => 'index.html',
237 'type' => 'TYPO3\\CMS\\install\\FolderStructure\\FileNode',
238 'targetPermission' => '0660',
239 'targetContent' => '',
240 ),
241 ),
242 ),
243 ),
244 ),
245 ),
246 );
247 }
248
249 /**
250 * Get default structure object hierarchy
251 *
252 * @throws Exception
253 * @return RootNode
254 * @TODO: Use objectManager instead of new (will be injected)
255 * @TODO: Handle targetPermission for files / directory if set in TYPO3_CONF_VARS
256 */
257 public function getStructure() {
258 $rootNode = new RootNode($this->expectedDefaultStructure, NULL);
259 if (!($rootNode instanceof RootNodeInterface)) {
260 throw new Exception(
261 'Root node must implement RootNodeInterface',
262 1366139176
263 );
264 }
265 $structureFacade = new StructureFacade($rootNode);
266 if (!($structureFacade instanceof StructureFacadeInterface)) {
267 throw new Exception(
268 'Structure facade must implement StructureFacadeInterface',
269 1366535827
270 );
271 }
272 return $structureFacade;
273 }
274 }
275 ?>