linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file class.plugin.php

Documentation is available at class.plugin.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage plugin
  5.  * @author Simon Georget <simon@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  *  Plugin Management
  10.  */
  11.  
  12. class plugin {
  13.  
  14.     private $info array();
  15.  
  16.     public function __construct($name{
  17.  
  18.         $a array();
  19.  
  20.         try{
  21.                 
  22.             if(!@$flow=simplexml_load_file(SITE_PATH.'plugins/'.$name.'/plugin.xml')){
  23.                 throw new Exception($name.' plugin : xml file was not found');
  24.             }
  25.             $this->info['name'$name;
  26.             $this->info['shortname'str_replace('l21_'''$name);
  27.             $this->info['description'$flow->description;
  28.             $this->info['version'$flow->version;
  29.             $this->info['date'$flow->date;
  30.             $this->info['compatibility'$flow->compatibility;
  31.             $this->info['author'$flow->author;
  32.             $this->info['homepage'$flow->homepage;
  33.             $this->info['settings'= (integer) $flow->settings;
  34.             $this->info['default_language'$flow->default_language;
  35.             $this->info['image'$flow->image;
  36.             $this->info['active_path'SITE_PATH.'plugins/'.$this->info['name'].'/.active';
  37.             $this->info['active_url'SITE_ROOT_URL.'plugins/'.$this->info['name'].'/';
  38.             $this->info['relative_url''../plugins/'.$this->info['name'].'/';
  39.  
  40.             foreach($flow->apps->app as $el{
  41.                 $this->info['apps'][]=(string) $el;
  42.             }
  43.         }
  44.         catch(Exception $e){
  45.             return $e->getMessage();
  46.         }
  47.  
  48.     }
  49.  
  50.     public function __toString({
  51.         return $this->getVar('name');
  52.     }
  53.  
  54.     public function hasImage({
  55.  
  56.         if(!empty($this->info['image'])) return true;
  57.         else return false;
  58.  
  59.     }
  60.  
  61.     public function hasAdvancedSettings({
  62.  
  63.         if($this->info['settings'== truereturn true;
  64.         else return false;
  65.  
  66.     }
  67.  
  68.     public function imagePath({
  69.  
  70.         return '../plugins/'.$this->info['name'].'/'.$this->info['image'];
  71.  
  72.     }
  73.  
  74.     public function getPluginInfo({
  75.  
  76.         return $this->info;
  77.  
  78.     }
  79.  
  80.     public function getVar($varname{
  81.  
  82.         return $this->info[$varname];
  83.     }
  84.  
  85.     public function getAvailablePlugins({
  86.  
  87.         return availablePlugins();
  88.  
  89.     }
  90.  
  91.     public function loadPlugin({
  92.         // we check if the current app is concerned by the module
  93.         if(!in_array(CURRENT_APP$this->getVar('apps'))) return false;
  94.         IncludeLanguagesPluginfiles($this);
  95.         if(file_exists(SITE_PATH.'plugins/'.$this->info['name'].'/__init__.php')) {
  96.             include_once(SITE_PATH.'plugins/'.$this->info['name'].'/__init__.php');
  97.         }
  98.         return true;
  99.     }
  100.  
  101.     public function enable({
  102.  
  103.         $fp fopen($this->getVar('active_path')"x");
  104.         fclose($fp);
  105.  
  106.         if(file_exists(SITE_PATH.'plugins/'.$this->info['name'].'/__install__.php')) {
  107.             include_once(SITE_PATH.'plugins/'.$this->info['name'].'/__install__.php');
  108.         }
  109.  
  110.     }
  111.  
  112.     public function disable({
  113.  
  114.         return unlink($this->getVar('active_path'));
  115.  
  116.     }
  117.  
  118.     public function is_active({
  119.  
  120.         return file_exists($this->getVar('active_path'));
  121.  
  122.     }
  123.  
  124.  
  125. }
  126.  
  127. ?>

Documentation generated on Thu, 03 May 2012 15:02:56 +0200 by phpDocumentor 1.4.1