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