Rev 473 | Rev 594 | 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 | |||
79 | public function getCSSFiles(): array { |
||
80 | return $this->cssFiles; |
||
81 | } |
||
82 | |||
83 | public function getJSFiles(): array { |
||
84 | return $this->jsFiles; |
||
85 | } |
||
86 | |||
411 | daniel-mar | 87 | public function getCSSFilesSetup(): array { |
88 | return $this->cssFilesSetup; |
||
89 | } |
||
90 | |||
91 | public function getJSFilesSetup(): array { |
||
92 | return $this->jsFilesSetup; |
||
93 | } |
||
94 | |||
359 | daniel-mar | 95 | public function getRawXml(): SimpleXMLElement { |
355 | daniel-mar | 96 | return $this->rawXML; |
97 | } |
||
98 | |||
389 | daniel-mar | 99 | public function getLanguageCode(): string { |
100 | return $this->languageCode; |
||
101 | } |
||
102 | |||
103 | public function getLanguageFlag(): string { |
||
104 | return $this->languageFlag; |
||
105 | } |
||
106 | |||
107 | public function getLanguageMessages(): string { |
||
108 | return $this->languageMessages; |
||
109 | } |
||
110 | |||
307 | daniel-mar | 111 | public function loadManifest($filename) { |
308 | daniel-mar | 112 | if (!file_exists($filename)) return false; |
113 | $xmldata = @simplexml_load_file($filename); |
||
114 | if ($xmldata === false) return false; |
||
307 | daniel-mar | 115 | |
389 | daniel-mar | 116 | $this->rawXML = $xmldata; |
117 | |||
118 | // The following attributes are available for every plugin |
||
391 | daniel-mar | 119 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 (page) |
120 | // urn:oid:1.3.6.1.4.1.37476.2.5.2.5.3.1 (language) |
||
121 | // urn:oid:1.3.6.1.4.1.37476.2.5.2.5.5.1 (general) |
||
308 | daniel-mar | 122 | $this->type = (string)$xmldata->type; |
307 | daniel-mar | 123 | |
308 | daniel-mar | 124 | $this->name = (string)$xmldata->info->name; |
125 | $this->author = (string)$xmldata->info->author; |
||
126 | $this->version = (string)$xmldata->info->version; |
||
127 | $this->htmlDescription = (string)$xmldata->info->descriptionHTML; |
||
128 | $this->oid = (string)$xmldata->info->oid; |
||
307 | daniel-mar | 129 | |
308 | daniel-mar | 130 | $this->phpMainClass = (string)$xmldata->php->mainclass; |
307 | daniel-mar | 131 | |
473 | daniel-mar | 132 | // The following functionalities are only available for page or design plugins |
391 | daniel-mar | 133 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 |
473 | daniel-mar | 134 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.7.1 |
308 | daniel-mar | 135 | foreach ((array)$xmldata->css->file as $css_file) { |
327 | daniel-mar | 136 | $file = dirname($filename).'/'.$css_file; |
429 | daniel-mar | 137 | //if (!file_exists($file)) continue; |
327 | daniel-mar | 138 | $this->cssFiles[] = $file; |
307 | daniel-mar | 139 | } |
473 | daniel-mar | 140 | |
141 | // The following functionalities are only available for page plugins |
||
142 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 |
||
308 | daniel-mar | 143 | foreach ((array)$xmldata->js->file as $js_file) { |
327 | daniel-mar | 144 | $file = dirname($filename).'/'.$js_file; |
429 | daniel-mar | 145 | //if (!file_exists($file)) continue; |
327 | daniel-mar | 146 | $this->jsFiles[] = $file; |
308 | daniel-mar | 147 | } |
307 | daniel-mar | 148 | |
411 | daniel-mar | 149 | // The following functionalities are only available for database plugins |
150 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.6 |
||
151 | foreach ((array)$xmldata->cssSetup->file as $css_file) { |
||
152 | $file = dirname($filename).'/'.$css_file; |
||
429 | daniel-mar | 153 | //if (!file_exists($file)) continue; |
411 | daniel-mar | 154 | $this->cssFilesSetup[] = $file; |
155 | } |
||
156 | foreach ((array)$xmldata->jsSetup->file as $js_file) { |
||
157 | $file = dirname($filename).'/'.$js_file; |
||
429 | daniel-mar | 158 | //if (!file_exists($file)) continue; |
411 | daniel-mar | 159 | $this->jsFilesSetup[] = $file; |
160 | } |
||
161 | |||
389 | daniel-mar | 162 | // The following functionalities are only available for language plugins |
391 | daniel-mar | 163 | // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.3.1 |
389 | daniel-mar | 164 | $this->languageCode = (string)$xmldata->language->code; |
165 | $this->languageFlag = (string)$xmldata->language->flag; |
||
166 | $this->languageMessages = (string)$xmldata->language->messages; |
||
355 | daniel-mar | 167 | |
307 | daniel-mar | 168 | return true; |
169 | } |
||
170 | |||
171 | } |