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