Subversion Repositories oidplus

Rev

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