Rev 389 | Rev 411 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
307 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
5 | * Copyright 2019 Daniel Marschall, ViaThinkSoft |
||
6 | * |
||
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
8 | * you may not use this file except in compliance with the License. |
||
9 | * You may obtain a copy of the License at |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
20 | class OIDplusPluginManifest { |
||
21 | |||
389 | daniel-mar | 22 | private $rawXML = null; |
23 | |||
24 | // All plugins |
||
308 | daniel-mar | 25 | private $name = ''; |
26 | private $author = ''; |
||
27 | private $version = ''; |
||
28 | private $htmlDescription = ''; |
||
29 | private $oid = ''; |
||
307 | daniel-mar | 30 | |
308 | daniel-mar | 31 | private $type = ''; |
32 | private $phpMainClass = ''; |
||
389 | daniel-mar | 33 | |
34 | // Only page plugins |
||
307 | daniel-mar | 35 | private $cssFiles = array(); |
36 | private $jsFiles = array(); |
||
37 | |||
389 | daniel-mar | 38 | // Only language plugins |
39 | private $languageCode = ''; |
||
40 | private $languageFlag = ''; |
||
41 | private $languageMessages = ''; |
||
42 | |||
308 | daniel-mar | 43 | public function getTypeClass(): string { |
44 | return $this->type; |
||
45 | } |
||
46 | |||
307 | daniel-mar | 47 | public function getName(): string { |
48 | return $this->name; |
||
49 | } |
||
50 | |||
51 | public function getAuthor(): string { |
||
52 | return $this->author; |
||
53 | } |
||
54 | |||
55 | public function getVersion(): string { |
||
56 | return $this->version; |
||
57 | } |
||
58 | |||
59 | public function getHtmlDescription(): string { |
||
60 | return $this->htmlDescription; |
||
61 | } |
||
62 | |||
308 | daniel-mar | 63 | public function getOid(): string { |
64 | return $this->oid; |
||
65 | } |
||
66 | |||
307 | daniel-mar | 67 | public function getPhpMainClass(): string { |
68 | return $this->phpMainClass; |
||
69 | } |
||
70 | |||
71 | public function getCSSFiles(): array { |
||
72 | return $this->cssFiles; |
||
73 | } |
||
74 | |||
75 | public function getJSFiles(): array { |
||
76 | return $this->jsFiles; |
||
77 | } |
||
78 | |||
359 | daniel-mar | 79 | public function getRawXml(): SimpleXMLElement { |
355 | daniel-mar | 80 | return $this->rawXML; |
81 | } |
||
82 | |||
389 | daniel-mar | 83 | public function getLanguageCode(): string { |
84 | return $this->languageCode; |
||
85 | } |
||
86 | |||
87 | public function getLanguageFlag(): string { |
||
88 | return $this->languageFlag; |
||
89 | } |
||
90 | |||
91 | public function getLanguageMessages(): string { |
||
92 | return $this->languageMessages; |
||
93 | } |
||
94 | |||
307 | daniel-mar | 95 | public function loadManifest($filename) { |
308 | daniel-mar | 96 | if (!file_exists($filename)) return false; |
97 | $xmldata = @simplexml_load_file($filename); |
||
98 | if ($xmldata === false) return false; |
||
307 | daniel-mar | 99 | |
389 | daniel-mar | 100 | $this->rawXML = $xmldata; |
101 | |||
102 | // The following attributes are available for every plugin |
||
391 | daniel-mar | 103 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 (page) |
104 | // urn:oid:1.3.6.1.4.1.37476.2.5.2.5.3.1 (language) |
||
105 | // urn:oid:1.3.6.1.4.1.37476.2.5.2.5.5.1 (general) |
||
308 | daniel-mar | 106 | $this->type = (string)$xmldata->type; |
307 | daniel-mar | 107 | |
308 | daniel-mar | 108 | $this->name = (string)$xmldata->info->name; |
109 | $this->author = (string)$xmldata->info->author; |
||
110 | $this->version = (string)$xmldata->info->version; |
||
111 | $this->htmlDescription = (string)$xmldata->info->descriptionHTML; |
||
112 | $this->oid = (string)$xmldata->info->oid; |
||
307 | daniel-mar | 113 | |
308 | daniel-mar | 114 | $this->phpMainClass = (string)$xmldata->php->mainclass; |
307 | daniel-mar | 115 | |
389 | daniel-mar | 116 | // The following functionalities are only available for page plugins |
391 | daniel-mar | 117 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 |
308 | daniel-mar | 118 | foreach ((array)$xmldata->css->file as $css_file) { |
327 | daniel-mar | 119 | $file = dirname($filename).'/'.$css_file; |
120 | if (!file_exists($file)) continue; |
||
121 | $this->cssFiles[] = $file; |
||
307 | daniel-mar | 122 | } |
308 | daniel-mar | 123 | foreach ((array)$xmldata->js->file as $js_file) { |
327 | daniel-mar | 124 | $file = dirname($filename).'/'.$js_file; |
125 | if (!file_exists($file)) continue; |
||
126 | $this->jsFiles[] = $file; |
||
308 | daniel-mar | 127 | } |
307 | daniel-mar | 128 | |
389 | daniel-mar | 129 | // The following functionalities are only available for language plugins |
391 | daniel-mar | 130 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.3.1 |
389 | daniel-mar | 131 | $this->languageCode = (string)$xmldata->language->code; |
132 | $this->languageFlag = (string)$xmldata->language->flag; |
||
133 | $this->languageMessages = (string)$xmldata->language->messages; |
||
355 | daniel-mar | 134 | |
307 | daniel-mar | 135 | return true; |
136 | } |
||
137 | |||
138 | } |