source: documentation/trunk/packages/dokuwiki-2011-05-25a/lib/plugins/plugin/admin.php@ 25027

Last change on this file since 25027 was 25027, checked in by jmt12, 12 years ago

Adding the packages directory, and within it a configured version of dokuwiki all ready to run

File size: 4.3 KB
Line 
1<?php
2/**
3 * Plugin management functions
4 *
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Christopher Smith <[email protected]>
7 */
8// must be run within Dokuwiki
9if(!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
16require_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
24global $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 */
31class admin_plugin_plugin extends DokuWiki_Admin_Plugin {
32
33 var $disabled = 0;
34 var $plugin = '';
35 var $cmd = '';
36 var $handler = NULL;
37
38 var $functions = array('delete','update',/*'settings',*/'info'); // require a plugin name
39 var $commands = array('manage','download','enable'); // don't require a plugin name
40 var $plugin_list = array();
41
42 var $msg = '';
43 var $error = '';
44
45 function admin_plugin_plugin() {
46 global $conf;
47 $this->disabled = plugin_isdisabled('plugin');
48 }
49
50 /**
51 * return some info
52 */
53 function getInfo(){
54 $disabled = ($this->disabled) ? '(disabled)' : '';
55
56 return array(
57 'author' => 'Christopher Smith',
58 'email' => '[email protected]',
59 'date' => '2009-11-11',
60 'name' => 'Plugin Manager',
61 'desc' => "Manage Plugins, including automated plugin installer $disabled",
62 'url' => 'http://www.dokuwiki.org/plugin:plugin',
63 );
64 }
65
66
67 /**
68 * return sort order for position in admin menu
69 */
70 function getMenuSort() {
71 return 20;
72 }
73
74 /**
75 * handle user request
76 */
77 function handle() {
78 // enable direct access to language strings
79 $this->setupLocale();
80
81
82 $fn = $_REQUEST['fn'];
83 if (is_array($fn)) {
84 $this->cmd = key($fn);
85 $this->plugin = is_array($fn[$this->cmd]) ? key($fn[$this->cmd]) : null;
86 } else {
87 $this->cmd = $fn;
88 $this->plugin = null;
89 }
90 $this->_get_plugin_list();
91
92 // verify $_REQUEST vars
93 if (in_array($this->cmd, $this->commands)) {
94 $this->plugin = '';
95 } else if (!in_array($this->cmd, $this->functions) || !in_array($this->plugin, $this->plugin_list)) {
96 $this->cmd = 'manage';
97 $this->plugin = '';
98 }
99
100 if(($this->cmd != 'manage' || $this->plugin != '') && !checkSecurityToken()){
101 $this->cmd = 'manage';
102 $this->plugin = '';
103 }
104
105 // create object to handle the command
106 $class = "ap_".$this->cmd;
107 @require_once(DOKU_PLUGIN."/plugin/classes/$class.class.php");
108 if (!class_exists($class)){
109 $class = 'ap_manage';
110 }
111
112 $this->handler = new $class($this, $this->plugin);
113 $this->msg = $this->handler->process();
114
115 }
116
117 /**
118 * output appropriate html
119 */
120 function html() {
121 // enable direct access to language strings
122 $this->setupLocale();
123 $this->_get_plugin_list();
124
125 if ($this->handler === NULL) $this->handler = new ap_manage($this, $this->plugin);
126
127 ptln('<div id="plugin__manager">');
128 $this->handler->html();
129 ptln('</div><!-- #plugin_manager -->');
130 }
131
132 /**
133 * Returns a list of all plugins, including the disabled ones
134 */
135 function _get_plugin_list() {
136 if (empty($this->plugin_list)) {
137 $list = plugin_list('',true); // all plugins, including disabled ones
138 sort($list);
139 trigger_event('PLUGIN_PLUGINMANAGER_PLUGINLIST',$list);
140 $this->plugin_list = $list;
141 }
142 return $this->plugin_list;
143 }
144
145}
146
147
148
149
150
151
Note: See TracBrowser for help on using the repository browser.