[TASK] Drop 'typo3/ should be link' recommendation
[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 * @return StructureFacadeInterface
26 */
27 public function getStructure()
28 {
29 $rootNode = new RootNode($this->getDefaultStructureDefinition(), null);
30 $structureFacade = new StructureFacade($rootNode);
31 return $structureFacade;
32 }
33
34 /**
35 * Default definition of folder and file structure with dynamic
36 * permission settings
37 *
38 * @return array
39 */
40 protected function getDefaultStructureDefinition()
41 {
42 $filePermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'];
43 $directoryPermission = $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'];
44
45 return [
46 // Cut off trailing forward / from PATH_site, so root node has no trailing slash like all others
47 'name' => substr(PATH_site, 0, -1),
48 'targetPermission' => $directoryPermission,
49 'children' => [
50 [
51 'name' => 'typo3temp',
52 'type' => DirectoryNode::class,
53 'targetPermission' => $directoryPermission,
54 'children' => [
55 [
56 'name' => 'index.html',
57 'type' => FileNode::class,
58 'targetPermission' => $filePermission,
59 'targetContent' => '',
60 ],
61 [
62 'name' => 'assets',
63 'type' => DirectoryNode::class,
64 'targetPermission' => $directoryPermission,
65 'children' => [
66 [
67 'name' => 'compressed',
68 'type' => DirectoryNode::class,
69 'targetPermission' => $directoryPermission
70 ],
71 [
72 'name' => 'css',
73 'type' => DirectoryNode::class,
74 'targetPermission' => $directoryPermission
75 ],
76 [
77 'name' => 'js',
78 'type' => DirectoryNode::class,
79 'targetPermission' => $directoryPermission
80 ],
81 [
82 'name' => 'images',
83 'type' => DirectoryNode::class,
84 'targetPermission' => $directoryPermission
85 ],
86 [
87 'name' => '_processed_',
88 'type' => DirectoryNode::class,
89 'targetPermission' => $directoryPermission
90 ]
91 ]
92 ],
93 [
94 'name' => 'var',
95 'type' => DirectoryNode::class,
96 'targetPermission' => $directoryPermission,
97 'children' => [
98 [
99 'name' => '.htaccess',
100 'type' => FileNode::class,
101 'targetPermission' => $filePermission,
102 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/typo3temp-var-htaccess',
103 ],
104 [
105 'name' => 'charset',
106 'type' => DirectoryNode::class,
107 'targetPermission' => $directoryPermission,
108 ],
109 [
110 'name' => 'Cache',
111 'type' => DirectoryNode::class,
112 'targetPermission' => $directoryPermission,
113 ],
114 [
115 'name' => 'locks',
116 'type' => DirectoryNode::class,
117 'targetPermission' => $directoryPermission,
118 ]
119 ]
120 ],
121 ],
122 ],
123 [
124 'name' => 'typo3conf',
125 'type' => DirectoryNode::class,
126 'targetPermission' => $directoryPermission,
127 'children' => [
128 [
129 'name' => 'ext',
130 'type' => DirectoryNode::class,
131 'targetPermission' => $directoryPermission,
132 ],
133 [
134 'name' => 'l10n',
135 'type' => DirectoryNode::class,
136 'targetPermission' => $directoryPermission,
137 ],
138 ],
139 ],
140 [
141 'name' => !empty($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir']) ? rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') : 'fileadmin',
142 'type' => DirectoryNode::class,
143 'targetPermission' => $directoryPermission,
144 'children' => [
145 [
146 'name' => '_temp_',
147 'type' => DirectoryNode::class,
148 'targetPermission' => $directoryPermission,
149 'children' => [
150 [
151 'name' => '.htaccess',
152 'type' => FileNode::class,
153 'targetPermission' => $filePermission,
154 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-htaccess',
155 ],
156 [
157 'name' => 'index.html',
158 'type' => FileNode::class,
159 'targetPermission' => $filePermission,
160 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
161 ],
162 ],
163 ],
164 [
165 'name' => 'user_upload',
166 'type' => DirectoryNode::class,
167 'targetPermission' => $directoryPermission,
168 'children' => [
169 [
170 'name' => '_temp_',
171 'type' => DirectoryNode::class,
172 'targetPermission' => $directoryPermission,
173 'children' => [
174 [
175 'name' => 'index.html',
176 'type' => FileNode::class,
177 'targetPermission' => $filePermission,
178 'targetContent' => '',
179 ],
180 [
181 'name' => 'importexport',
182 'type' => DirectoryNode::class,
183 'targetPermission' => $directoryPermission,
184 'children' => [
185 [
186 'name' => '.htaccess',
187 'type' => FileNode::class,
188 'targetPermission' => $filePermission,
189 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-user_upload-temp-importexport-htaccess',
190 ],
191 [
192 'name' => 'index.html',
193 'type' => FileNode::class,
194 'targetPermission' => $filePermission,
195 'targetContentFile' => PATH_site . 'typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/fileadmin-temp-index.html',
196 ],
197 ],
198 ],
199 ],
200 ],
201 [
202 'name' => 'index.html',
203 'type' => FileNode::class,
204 'targetPermission' => $filePermission,
205 'targetContent' => '',
206 ],
207 ],
208 ],
209 ],
210 ],
211 ],
212 ];
213 }
214 }