Subversion Repositories oidplus

Rev

Rev 473 | Rev 594 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2021 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. if (!defined('INSIDE_OIDPLUS')) die();
  21.  
  22. class OIDplusPluginManifest {
  23.  
  24.         private $rawXML = null;
  25.  
  26.         // All plugins
  27.         private $name = '';
  28.         private $author = '';
  29.         private $version = '';
  30.         private $htmlDescription = '';
  31.         private $oid = '';
  32.  
  33.         private $type = '';
  34.         private $phpMainClass = '';
  35.  
  36.         // Only page or design plugins
  37.         private $cssFiles = array();
  38.  
  39.         // only page plugins
  40.         private $jsFiles = array();
  41.  
  42.         // Only database plugins
  43.         private $cssFilesSetup = array();
  44.         private $jsFilesSetup = array();
  45.  
  46.         // Only language plugins
  47.         private $languageCode = '';
  48.         private $languageFlag = '';
  49.         private $languageMessages = '';
  50.  
  51.         public function getTypeClass(): string {
  52.                 return $this->type;
  53.         }
  54.  
  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.  
  71.         public function getOid(): string {
  72.                 return $this->oid;
  73.         }
  74.  
  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.  
  87.         public function getCSSFilesSetup(): array {
  88.                 return $this->cssFilesSetup;
  89.         }
  90.  
  91.         public function getJSFilesSetup(): array {
  92.                 return $this->jsFilesSetup;
  93.         }
  94.  
  95.         public function getRawXml(): SimpleXMLElement {
  96.                 return $this->rawXML;
  97.         }
  98.  
  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.  
  111.         public function loadManifest($filename) {
  112.                 if (!file_exists($filename)) return false;
  113.                 $xmldata = @simplexml_load_file($filename);
  114.                 if ($xmldata === false) return false;
  115.  
  116.                 $this->rawXML = $xmldata;
  117.  
  118.                 // The following attributes are available for every plugin
  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)
  122.                 $this->type = (string)$xmldata->type;
  123.  
  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;
  129.  
  130.                 $this->phpMainClass = (string)$xmldata->php->mainclass;
  131.  
  132.                 // The following functionalities are only available for page or design plugins
  133.                 // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1
  134.                 // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.7.1
  135.                 foreach ((array)$xmldata->css->file as $css_file) {
  136.                         $file = dirname($filename).'/'.$css_file;
  137.                         //if (!file_exists($file)) continue;
  138.                         $this->cssFiles[] = $file;
  139.                 }
  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
  143.                 foreach ((array)$xmldata->js->file as $js_file) {
  144.                         $file = dirname($filename).'/'.$js_file;
  145.                         //if (!file_exists($file)) continue;
  146.                         $this->jsFiles[] = $file;
  147.                 }
  148.  
  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;
  153.                         //if (!file_exists($file)) continue;
  154.                         $this->cssFilesSetup[] = $file;
  155.                 }
  156.                 foreach ((array)$xmldata->jsSetup->file as $js_file) {
  157.                         $file = dirname($filename).'/'.$js_file;
  158.                         //if (!file_exists($file)) continue;
  159.                         $this->jsFilesSetup[] = $file;
  160.                 }
  161.  
  162.                 // The following functionalities are only available for language plugins
  163.                 // XML Schema urn:oid:1.3.6.1.4.1.37476.2.5.2.5.3.1
  164.                 $this->languageCode = (string)$xmldata->language->code;
  165.                 $this->languageFlag = (string)$xmldata->language->flag;
  166.                 $this->languageMessages = (string)$xmldata->language->messages;
  167.  
  168.                 return true;
  169.         }
  170.  
  171. }
  172.