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