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