[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/lib/plugins/plugin/ -> admin.php (source)

   1  <?php
   2  /**
   3   * Plugin management functions
   4   *
   5   * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
   6   * @author     Christopher Smith <chris@jalakai.co.uk>
   7   */
   8  // must be run within Dokuwiki
   9  if(!defined('DOKU_INC')) die();
  10  
  11  // todo
  12  // - maintain a history of file modified
  13  // - allow a plugin to contain extras to be copied to the current template (extra/tpl/)
  14  // - to images (lib/images/) [ not needed, should go in lib/plugin/images/ ]
  15  
  16  require_once(DOKU_PLUGIN."/plugin/classes/ap_manage.class.php");
  17  
  18  //--------------------------[ GLOBALS ]------------------------------------------------
  19  // note: probably should be dokuwiki wide globals, where they can be accessed by pluginutils.php
  20  // global $plugin_types;
  21  // $plugin_types = array('syntax', 'admin');
  22  
  23  // plugins that are an integral part of dokuwiki, they shouldn't be disabled or deleted
  24  global $plugin_protected;
  25  $plugin_protected = array('acl','plugin','config','info','usermanager','revert');
  26  
  27  /**
  28   * All DokuWiki plugins to extend the admin function
  29   * need to inherit from this class
  30   */
  31  class admin_plugin_plugin extends DokuWiki_Admin_Plugin {
  32  
  33      var $disabled = 0;
  34      var $plugin = '';
  35      var $cmd = '';
  36  
  37      /**
  38       * @var ap_manage
  39       */
  40      var $handler = null;
  41  
  42      var $functions = array('delete','update',/*'settings',*/'info');  // require a plugin name
  43      var $commands = array('manage','download','enable');              // don't require a plugin name
  44      var $plugin_list = array();
  45  
  46      var $msg = '';
  47      var $error = '';
  48  
  49      function admin_plugin_plugin() {
  50          $this->disabled = plugin_isdisabled('plugin');
  51      }
  52  
  53      /**
  54       * return sort order for position in admin menu
  55       */
  56      function getMenuSort() {
  57          return 20;
  58      }
  59  
  60      /**
  61       * handle user request
  62       */
  63      function handle() {
  64          global $INPUT;
  65          // enable direct access to language strings
  66          $this->setupLocale();
  67  
  68          $fn = $INPUT->param('fn');
  69          if (is_array($fn)) {
  70              $this->cmd = key($fn);
  71              $this->plugin = is_array($fn[$this->cmd]) ? key($fn[$this->cmd]) : null;
  72          } else {
  73              $this->cmd = $fn;
  74              $this->plugin = null;
  75          }
  76          $this->_get_plugin_list();
  77  
  78          // verify $_REQUEST vars
  79          if (in_array($this->cmd, $this->commands)) {
  80              $this->plugin = '';
  81          } else if (!in_array($this->cmd, $this->functions) || !in_array($this->plugin, $this->plugin_list)) {
  82              $this->cmd = 'manage';
  83              $this->plugin = '';
  84          }
  85  
  86          if(($this->cmd != 'manage' || $this->plugin != '') && !checkSecurityToken()){
  87              $this->cmd = 'manage';
  88              $this->plugin = '';
  89          }
  90  
  91          // create object to handle the command
  92          $class = "ap_".$this->cmd;
  93          @require_once(DOKU_PLUGIN."/plugin/classes/$class.class.php");
  94          if (!class_exists($class)){
  95              $class = 'ap_manage';
  96          }
  97  
  98          $this->handler = new $class($this, $this->plugin);
  99          $this->msg = $this->handler->process();
 100  
 101      }
 102  
 103      /**
 104       * output appropriate html
 105       */
 106      function html() {
 107          // enable direct access to language strings
 108          $this->setupLocale();
 109          $this->_get_plugin_list();
 110  
 111          if ($this->handler === null) $this->handler = new ap_manage($this, $this->plugin);
 112  
 113          ptln('<div id="plugin__manager">');
 114          $this->handler->html();
 115          ptln('</div><!-- #plugin_manager -->');
 116      }
 117  
 118      /**
 119       * Returns a list of all plugins, including the disabled ones
 120       */
 121      function _get_plugin_list() {
 122          if (empty($this->plugin_list)) {
 123              $list = plugin_list('',true);     // all plugins, including disabled ones
 124              sort($list);
 125              trigger_event('PLUGIN_PLUGINMANAGER_PLUGINLIST',$list);
 126              $this->plugin_list = $list;
 127          }
 128          return $this->plugin_list;
 129      }
 130  
 131  }
 132  
 133  
 134  
 135  
 136  
 137  


Generated: Sun Jan 19 03:00:05 2014 Cross-referenced by PHPXref 0.7