Subversion Repositories oidplus

Rev

Rev 308 | 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.  
  27.         private $phpMainClass;
  28.         private $cssFiles = array();
  29.         private $jsFiles = array();
  30.  
  31.         public function getName(): string {
  32.                 return $this->name;
  33.         }
  34.  
  35.         public function getAuthor(): string {
  36.                 return $this->author;
  37.         }
  38.  
  39.         public function getVersion(): string {
  40.                 return $this->version;
  41.         }
  42.  
  43.         public function getHtmlDescription(): string {
  44.                 return $this->htmlDescription;
  45.         }
  46.  
  47.         public function getPhpMainClass(): string {
  48.                 return $this->phpMainClass;
  49.         }
  50.  
  51.         public function getCSSFiles(): array {
  52.                 return $this->cssFiles;
  53.         }
  54.  
  55.         public function getJSFiles(): array {
  56.                 return $this->jsFiles;
  57.         }
  58.  
  59.         public function loadManifest($filename) {
  60.                 $ini = $filename;
  61.                 if (!file_exists($ini)) return false;
  62.                 $bry = parse_ini_file($ini, true, INI_SCANNER_TYPED); // TODO: in the future, make an XML manifest file
  63.                 if (!isset($bry['Plugin'])) return false;
  64.  
  65.                 $this->name = $bry['Plugin']['name'];
  66.                 $this->author = $bry['Plugin']['author'];
  67.                 $this->version = $bry['Plugin']['version'];
  68.                 $this->htmlDescription = $bry['Plugin']['descriptionHTML'];
  69.  
  70.                 $this->phpMainClass = isset($bry['PHP']['pluginclass']) ? $bry['PHP']['pluginclass'] : '';
  71.  
  72.                 if (isset($bry['CSS'])) {
  73.                         foreach ($bry['CSS'] as $dry_name => $dry) {
  74.                                 if ($dry_name != 'file') continue;
  75.                                 foreach ($dry as $css_file) {
  76.                                         $this->cssFiles[] = dirname($filename).'/'.$css_file;
  77.                                 }
  78.                         }
  79.                 }
  80.  
  81.                 if (isset($bry['JavaScript'])) {
  82.                         foreach ($bry['JavaScript'] as $dry_name => $dry) {
  83.                                 if ($dry_name != 'file') continue;
  84.                                 foreach ($dry as $js_file) {
  85.                                         $this->jsFiles[] = dirname($filename).'/'.$js_file;
  86.                                 }
  87.                         }
  88.                 }
  89.  
  90.                 return true;
  91.         }
  92.  
  93. }
  94.  
  95.