Subversion Repositories oidplus

Rev

Rev 327 | Rev 359 | 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 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.  
  22.         private $name = '';
  23.         private $author = '';
  24.         private $version = '';
  25.         private $htmlDescription = '';
  26.         private $oid = '';
  27.  
  28.         private $type = '';
  29.         private $phpMainClass = '';
  30.         private $cssFiles = array();
  31.         private $jsFiles = array();
  32.         private $rawXML = null;
  33.  
  34.         public function getTypeClass(): string {
  35.                 return $this->type;
  36.         }
  37.  
  38.         public function getName(): string {
  39.                 return $this->name;
  40.         }
  41.  
  42.         public function getAuthor(): string {
  43.                 return $this->author;
  44.         }
  45.  
  46.         public function getVersion(): string {
  47.                 return $this->version;
  48.         }
  49.  
  50.         public function getHtmlDescription(): string {
  51.                 return $this->htmlDescription;
  52.         }
  53.  
  54.         public function getOid(): string {
  55.                 return $this->oid;
  56.         }
  57.  
  58.         public function getPhpMainClass(): string {
  59.                 return $this->phpMainClass;
  60.         }
  61.  
  62.         public function getCSSFiles(): array {
  63.                 return $this->cssFiles;
  64.         }
  65.  
  66.         public function getJSFiles(): array {
  67.                 return $this->jsFiles;
  68.         }
  69.  
  70.         public function getRawXml(): object {
  71.                 return $this->rawXML;
  72.         }
  73.  
  74.         public function loadManifest($filename) {
  75.                 if (!file_exists($filename)) return false;
  76.                 $xmldata = @simplexml_load_file($filename);
  77.                 if ($xmldata === false) return false;
  78.  
  79.                 $this->type = (string)$xmldata->type;
  80.  
  81.                 $this->name = (string)$xmldata->info->name;
  82.                 $this->author = (string)$xmldata->info->author;
  83.                 $this->version = (string)$xmldata->info->version;
  84.                 $this->htmlDescription = (string)$xmldata->info->descriptionHTML;
  85.                 $this->oid = (string)$xmldata->info->oid;
  86.  
  87.                 $this->phpMainClass = (string)$xmldata->php->mainclass;
  88.  
  89.                 foreach ((array)$xmldata->css->file as $css_file) {
  90.                         $file = dirname($filename).'/'.$css_file;
  91.                         if (!file_exists($file)) continue;
  92.                         $this->cssFiles[] = $file;
  93.                 }
  94.                 foreach ((array)$xmldata->js->file as $js_file) {
  95.                         $file = dirname($filename).'/'.$js_file;
  96.                         if (!file_exists($file)) continue;
  97.                         $this->jsFiles[] = $file;
  98.                 }
  99.  
  100.                 $this->rawXML = $xmldata;
  101.  
  102.                 return true;
  103.         }
  104.  
  105. }
  106.