[BUGFIX] EM must treat line breaks correctly in extension data
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Utility / Parser / AbstractExtensionXmlParser.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Utility\Parser;
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 * Module: Extension manager - Extension.xml abstract parser
19 */
20 /**
21 * Abstract parser for TYPO3's extension.xml file.
22 * @since 2010-02-09
23 */
24 abstract class AbstractExtensionXmlParser extends AbstractXmlParser
25 {
26 /**
27 * Keeps current author company of an extension's version.
28 *
29 * @var string
30 */
31 protected $authorcompany = null;
32
33 /**
34 * Keeps current author mail address of an extension's version.
35 *
36 * @var string
37 */
38 protected $authoremail = null;
39
40 /**
41 * Keeps current author name of an extension's version.
42 *
43 * @var string
44 */
45 protected $authorname = null;
46
47 /**
48 * Keeps current category of an extension's version.
49 *
50 * @var string
51 */
52 protected $category = null;
53
54 /**
55 * Keeps current dependencies of an extension's version.
56 *
57 * @var string
58 */
59 protected $dependencies = null;
60
61 /**
62 * Keeps current description of an extension's version.
63 *
64 * @var string
65 */
66 protected $description = null;
67
68 /**
69 * Keeps current download number sum of all extension's versions.
70 *
71 * @var string
72 */
73 protected $extensionDownloadCounter = null;
74
75 /**
76 * Keeps current key of an extension.
77 *
78 * @var string
79 */
80 protected $extensionKey = null;
81
82 /**
83 * Keeps current upload date of an extension's version.
84 *
85 * @var string
86 */
87 protected $lastuploaddate = null;
88
89 /**
90 * Keeps current owner username of an extension's version.
91 *
92 * @var string
93 */
94 protected $ownerusername = null;
95
96 /**
97 * Keeps current reviewstate of an extension's version.
98 *
99 * @var string
100 */
101 protected $reviewstate = null;
102
103 /**
104 * Keeps current state of an extension's version.
105 *
106 * @var string
107 */
108 protected $state = null;
109
110 /**
111 * Keeps current t3x file hash of an extension's version.
112 *
113 * @var string
114 */
115 protected $t3xfilemd5 = null;
116
117 /**
118 * Keeps current title of an extension's version.
119 *
120 * @var string
121 */
122 protected $title = null;
123
124 /**
125 * Keeps current upload comment of an extension's version.
126 *
127 * @var string
128 */
129 protected $uploadcomment = null;
130
131 /**
132 * Keeps current version number.
133 *
134 * @var string
135 */
136 protected $version = null;
137
138 /**
139 * Keeps current download number of an extension's version.
140 *
141 * @var string
142 */
143 protected $versionDownloadCounter = null;
144
145 /**
146 * Returns an assoziative array of all extension version properties.
147 *
148 * Valid array keys of returned array are:
149 * extkey, version, alldownloadcounter, downloadcounter, title, description,
150 * state, reviewstate, category, lastuploaddate, uploadcomment, dependencies,
151 * authorname, authoremail, authorcompany, ownerusername, t3xfilemd5
152 *
153 * @access public
154 * @see $extensionKey, $version, $extensionDownloadCounter,
155 * @return array assoziative array of an extension version's properties
156 */
157 public function getAll()
158 {
159 $versionProperties = [];
160 $versionProperties['extkey'] = $this->extensionKey;
161 $versionProperties['version'] = $this->version;
162 $versionProperties['alldownloadcounter'] = $this->extensionDownloadCounter;
163 $versionProperties['downloadcounter'] = $this->versionDownloadCounter;
164 $versionProperties['title'] = $this->title;
165 $versionProperties['description'] = $this->description;
166 $versionProperties['state'] = $this->state;
167 $versionProperties['reviewstate'] = $this->reviewstate;
168 $versionProperties['category'] = $this->category;
169 $versionProperties['lastuploaddate'] = $this->lastuploaddate;
170 $versionProperties['uploadcomment'] = $this->uploadcomment;
171 $versionProperties['dependencies'] = $this->dependencies;
172 $versionProperties['authorname'] = $this->authorname;
173 $versionProperties['authoremail'] = $this->authoremail;
174 $versionProperties['authorcompany'] = $this->authorcompany;
175 $versionProperties['ownerusername'] = $this->ownerusername;
176 $versionProperties['t3xfilemd5'] = $this->t3xfilemd5;
177 return $versionProperties;
178 }
179
180 /**
181 * Returns download number sum of all extension's versions.
182 *
183 * @access public
184 * @return string download number sum
185 * @see $extensionDLCounter, getAll()
186 */
187 public function getAlldownloadcounter()
188 {
189 return $this->extensionDownloadCounter;
190 }
191
192 /**
193 * Returns company name of extension author.
194 *
195 * @access public
196 * @return string company name of extension author
197 * @see $authorcompany, getAll()
198 */
199 public function getAuthorcompany()
200 {
201 return $this->authorcompany;
202 }
203
204 /**
205 * Returns e-mail address of extension author.
206 *
207 * @access public
208 * @return string e-mail address of extension author
209 * @see $authoremail, getAll()
210 */
211 public function getAuthoremail()
212 {
213 return $this->authoremail;
214 }
215
216 /**
217 * Returns name of extension author.
218 *
219 * @access public
220 * @return string name of extension author
221 * @see $authorname, getAll()
222 */
223 public function getAuthorname()
224 {
225 return $this->authorname;
226 }
227
228 /**
229 * Returns category of an extension.
230 *
231 * @access public
232 * @return string extension category
233 * @see $category, getAll()
234 */
235 public function getCategory()
236 {
237 return $this->category;
238 }
239
240 /**
241 * Returns dependencies of an extension's version.
242 *
243 * @access public
244 * @return string extension dependencies
245 * @see $dependencies, getAll()
246 */
247 public function getDependencies()
248 {
249 return $this->dependencies;
250 }
251
252 /**
253 * Returns description of an extension's version.
254 *
255 * @access public
256 * @return string extension description
257 * @see $description, getAll()
258 */
259 public function getDescription()
260 {
261 return $this->description;
262 }
263
264 /**
265 * Returns download number of an extension's version.
266 *
267 * @access public
268 * @return string download number
269 * @see $versionDLCounter, getAll()
270 */
271 public function getDownloadcounter()
272 {
273 return $this->versionDownloadCounter;
274 }
275
276 /**
277 * Returns key of an extension.
278 *
279 * @access public
280 * @return string extension key
281 * @see $extensionKey, getAll()
282 */
283 public function getExtkey()
284 {
285 return $this->extensionKey;
286 }
287
288 /**
289 * Returns last uploaddate of an extension's version.
290 *
291 * @access public
292 * @return string last upload date of an extension's version
293 * @see $lastuploaddate, getAll()
294 */
295 public function getLastuploaddate()
296 {
297 return $this->lastuploaddate;
298 }
299
300 /**
301 * Returns username of extension owner.
302 *
303 * @access public
304 * @return string extension owner's username
305 * @see $ownerusername, getAll()
306 */
307 public function getOwnerusername()
308 {
309 return $this->ownerusername;
310 }
311
312 /**
313 * Returns review state of an extension's version.
314 *
315 * @access public
316 * @return string extension review state
317 * @see $reviewstate, getAll()
318 */
319 public function getReviewstate()
320 {
321 return $this->reviewstate;
322 }
323
324 /**
325 * Returns state of an extension's version.
326 *
327 * @access public
328 * @return string extension state
329 * @see $state, getAll()
330 */
331 public function getState()
332 {
333 return $this->state;
334 }
335
336 /**
337 * Returns t3x file hash of an extension's version.
338 *
339 * @access public
340 * @return string t3x file hash *
341 * @see $t3xfilemd5, getAll()
342 */
343 public function getT3xfilemd5()
344 {
345 return $this->t3xfilemd5;
346 }
347
348 /**
349 * Returns title of an extension's version.
350 *
351 * @access public
352 * @return string extension title
353 * @see $title, getAll()
354 */
355 public function getTitle()
356 {
357 return $this->title;
358 }
359
360 /**
361 * Returns extension upload comment.
362 *
363 * @access public
364 * @return string extension upload comment
365 * @see $uploadcomment, getAll()
366 */
367 public function getUploadcomment()
368 {
369 return $this->uploadcomment;
370 }
371
372 /**
373 * Returns version number.
374 *
375 * @access public
376 * @return string version number
377 * @see $version, getAll()
378 */
379 public function getVersion()
380 {
381 return $this->version;
382 }
383
384 /**
385 * Method resets version class properties.
386 *
387 * @param $resetAll $all if TRUE, additionally extension properties are reset
388 * @return void
389 * @see $extensionKey, $version, $extensionDLCounter, $versionDLCounter,
390 */
391 protected function resetProperties($resetAll = false)
392 {
393 // resetting at least class property "version" is mandatory
394 // as we need to do some magic in regards to
395 // an extension's and version's child node "downloadcounter"
396 $this->version = $this->title = $this->versionDownloadCounter = $this->description = $this->state = $this->reviewstate = $this->category = $this->lastuploaddate = $this->uploadcomment = $this->dependencies = $this->authorname = $this->authoremail = $this->authorcompany = $this->ownerusername = $this->t3xfilemd5 = null;
397 if ($resetAll) {
398 $this->extensionKey = $this->extensionDownloadCounter = null;
399 }
400 }
401
402 /**
403 * Convert dependencies from TER format to EM_CONF format
404 *
405 * @param string $dependencies serialized dependency array
406 * @return string
407 */
408 protected function convertDependencies($dependencies)
409 {
410 $newDependencies = [];
411 $dependenciesArray = unserialize($dependencies);
412 if (is_array($dependenciesArray)) {
413 foreach ($dependenciesArray as $version) {
414 if (!empty($version['kind']) && !empty($version['extensionKey'])) {
415 $newDependencies[$version['kind']][$version['extensionKey']] = $version['versionRange'];
416 }
417 }
418 }
419 return serialize($newDependencies);
420 }
421 }