Rev 511 | Rev 601 | 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 |
||
511 | daniel-mar | 5 | * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft |
307 | daniel-mar | 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 | |||
511 | daniel-mar | 20 | if (!defined('INSIDE_OIDPLUS')) die(); |
21 | |||
307 | daniel-mar | 22 | class OIDplusPluginManifest { |
23 | |||
389 | daniel-mar | 24 | private $rawXML = null; |
25 | |||
26 | // All plugins |
||
308 | daniel-mar | 27 | private $name = ''; |
28 | private $author = ''; |
||
29 | private $version = ''; |
||
30 | private $htmlDescription = ''; |
||
31 | private $oid = ''; |
||
307 | daniel-mar | 32 | |
308 | daniel-mar | 33 | private $type = ''; |
34 | private $phpMainClass = ''; |
||
389 | daniel-mar | 35 | |
473 | daniel-mar | 36 | // Only page or design plugins |
307 | daniel-mar | 37 | private $cssFiles = array(); |
473 | daniel-mar | 38 | |
39 | // only page plugins |
||
307 | daniel-mar | 40 | private $jsFiles = array(); |
41 | |||
411 | daniel-mar | 42 | // Only database plugins |
43 | private $cssFilesSetup = array(); |
||
44 | private $jsFilesSetup = array(); |
||
45 | |||
389 | daniel-mar | 46 | // Only language plugins |
47 | private $languageCode = ''; |
||
48 | private $languageFlag = ''; |
||
49 | private $languageMessages = ''; |
||
50 | |||
308 | daniel-mar | 51 | public function getTypeClass(): string { |
52 | return $this->type; |
||
53 | } |
||
54 | |||
307 | daniel-mar | 55 | public function getName(): string { |
56 | return $this->name; |
||
57 | } |
||
58 | |||
59 | public function getAuthor(): string { |
||
60 | return $this->author; |
||
61 | } |
||
62 | |||
63 | public function getVersion(): string { |
||
64 | return $this->version; |
||
65 | } |
||
66 | |||
67 | public function getHtmlDescription(): string { |
||
68 | return $this->htmlDescription; |
||
69 | } |
||
70 | |||
308 | daniel-mar | 71 | public function getOid(): string { |
72 | return $this->oid; |
||
73 | } |
||
74 | |||
307 | daniel-mar | 75 | public function getPhpMainClass(): string { |
76 | return $this->phpMainClass; |
||
77 | } |
||
78 | |||
594 | daniel-mar | 79 | /** |
80 | * @return array<string> |
||
81 | */ |
||
307 | daniel-mar | 82 | public function getCSSFiles(): array { |
83 | return $this->cssFiles; |
||
84 | } |
||
85 | |||
594 | daniel-mar | 86 | /** |
87 | * @return array<string> |
||
88 | */ |
||
307 | daniel-mar | 89 | public function getJSFiles(): array { |
90 | return $this->jsFiles; |
||
91 | } |
||
92 | |||
594 | daniel-mar | 93 | /** |
94 | * @return array<string> |
||
95 | */ |
||
411 | daniel-mar | 96 | public function getCSSFilesSetup(): array { |
97 | return $this->cssFilesSetup; |
||
98 | } |
||
99 | |||
594 | daniel-mar | 100 | /** |
101 | * @return array<string> |
||
102 | */ |
||
411 | daniel-mar | 103 | public function getJSFilesSetup(): array { |
104 | return $this->jsFilesSetup; |
||
105 | } |
||
106 | |||
359 | daniel-mar | 107 | public function getRawXml(): SimpleXMLElement { |
355 | daniel-mar | 108 | return $this->rawXML; |
109 | } |
||
110 | |||
389 | daniel-mar | 111 | public function getLanguageCode(): string { |
112 | return $this->languageCode; |
||
113 | } |
||
114 | |||
115 | public function getLanguageFlag(): string { |
||
116 | return $this->languageFlag; |
||
117 | } |
||
118 | |||
119 | public function getLanguageMessages(): string { |
||
120 | return $this->languageMessages; |
||
121 | } |
||
122 | |||
307 | daniel-mar | 123 | public function loadManifest($filename) { |
308 | daniel-mar | 124 | if (!file_exists($filename)) return false; |
125 | $xmldata = @simplexml_load_file($filename); |
||
126 | if ($xmldata === false) return false; |
||
307 | daniel-mar | 127 | |
389 | daniel-mar | 128 | $this->rawXML = $xmldata; |
129 | |||
130 | // The following attributes are available for every plugin |
||
391 | daniel-mar | 131 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 (page) |
132 | // urn:oid:1.3.6.1.4.1.37476.2.5.2.5.3.1 (language) |
||
133 | // urn:oid:1.3.6.1.4.1.37476.2.5.2.5.5.1 (general) |
||
308 | daniel-mar | 134 | $this->type = (string)$xmldata->type; |
307 | daniel-mar | 135 | |
308 | daniel-mar | 136 | $this->name = (string)$xmldata->info->name; |
137 | $this->author = (string)$xmldata->info->author; |
||
138 | $this->version = (string)$xmldata->info->version; |
||
139 | $this->htmlDescription = (string)$xmldata->info->descriptionHTML; |
||
140 | $this->oid = (string)$xmldata->info->oid; |
||
307 | daniel-mar | 141 | |
308 | daniel-mar | 142 | $this->phpMainClass = (string)$xmldata->php->mainclass; |
307 | daniel-mar | 143 | |
473 | daniel-mar | 144 | // The following functionalities are only available for page or design plugins |
391 | daniel-mar | 145 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 |
473 | daniel-mar | 146 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.7.1 |
308 | daniel-mar | 147 | foreach ((array)$xmldata->css->file as $css_file) { |
327 | daniel-mar | 148 | $file = dirname($filename).'/'.$css_file; |
429 | daniel-mar | 149 | //if (!file_exists($file)) continue; |
327 | daniel-mar | 150 | $this->cssFiles[] = $file; |
307 | daniel-mar | 151 | } |
473 | daniel-mar | 152 | |
153 | // The following functionalities are only available for page plugins |
||
154 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 |
||
308 | daniel-mar | 155 | foreach ((array)$xmldata->js->file as $js_file) { |
327 | daniel-mar | 156 | $file = dirname($filename).'/'.$js_file; |
429 | daniel-mar | 157 | //if (!file_exists($file)) continue; |
327 | daniel-mar | 158 | $this->jsFiles[] = $file; |
308 | daniel-mar | 159 | } |
307 | daniel-mar | 160 | |
411 | daniel-mar | 161 | // The following functionalities are only available for database plugins |
162 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.6 |
||
163 | foreach ((array)$xmldata->cssSetup->file as $css_file) { |
||
164 | $file = dirname($filename).'/'.$css_file; |
||
429 | daniel-mar | 165 | //if (!file_exists($file)) continue; |
411 | daniel-mar | 166 | $this->cssFilesSetup[] = $file; |
167 | } |
||
168 | foreach ((array)$xmldata->jsSetup->file as $js_file) { |
||
169 | $file = dirname($filename).'/'.$js_file; |
||
429 | daniel-mar | 170 | //if (!file_exists($file)) continue; |
411 | daniel-mar | 171 | $this->jsFilesSetup[] = $file; |
172 | } |
||
173 | |||
389 | daniel-mar | 174 | // The following functionalities are only available for language plugins |
391 | daniel-mar | 175 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.3.1 |
389 | daniel-mar | 176 | $this->languageCode = (string)$xmldata->language->code; |
177 | $this->languageFlag = (string)$xmldata->language->flag; |
||
178 | $this->languageMessages = (string)$xmldata->language->messages; |
||
355 | daniel-mar | 179 | |
307 | daniel-mar | 180 | return true; |
181 | } |
||
182 | |||
183 | } |