1: <?php
2: 3: 4: 5: 6: 7: 8:
9: class ElggPluginManifestParser18 extends ElggPluginManifestParser {
10: 11: 12: 13: 14:
15: protected $validAttributes = array(
16: 'name', 'author', 'version', 'blurb', 'description','website',
17: 'repository', 'bugtracker', 'donations', 'copyright', 'license',
18: 'requires', 'suggests', 'conflicts', 'provides',
19: 'screenshot', 'category', 'activate_on_install'
20: );
21:
22: 23: 24: 25: 26:
27: protected $requiredAttributes = array(
28: 'name', 'author', 'version', 'description', 'requires'
29: );
30:
31: 32: 33: 34: 35:
36: public function parse() {
37: $parsed = array();
38: foreach ($this->manifestObject->children as $element) {
39: switch ($element->name) {
40:
41: case 'blurb':
42: case 'description':
43: case 'name':
44: case 'author':
45: case 'version':
46: case 'website':
47: case 'copyright':
48: case 'license':
49: case 'repository':
50: case 'bugtracker':
51: case 'donations':
52: case 'activate_on_install':
53: $parsed[$element->name] = $element->content;
54: break;
55:
56:
57: case 'category':
58: $parsed[$element->name][] = $element->content;
59: break;
60:
61:
62: case 'screenshot':
63: case 'provides':
64: case 'conflicts':
65: case 'requires':
66: case 'suggests':
67: if (!isset($element->children)) {
68: return false;
69: }
70:
71: $info = array();
72: foreach ($element->children as $child_element) {
73: $info[$child_element->name] = $child_element->content;
74: }
75:
76: $parsed[$element->name][] = $info;
77: break;
78: }
79: }
80:
81:
82: foreach ($this->requiredAttributes as $attr) {
83: if (!array_key_exists($attr, $parsed)) {
84: throw new PluginException(elgg_echo('PluginException:ParserErrorMissingRequiredAttribute',
85: array($attr, $this->caller->getPluginID())));
86: }
87: }
88:
89: $this->manifest = $parsed;
90:
91: if (!$this->manifest) {
92: return false;
93: }
94:
95: return true;
96: }
97: }
98: