3 * DokuWiki Plugin extension (Admin Component)
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author Michael Hamann <michael@content-space.de>
10 * Admin part of the extension manager
12 class admin_plugin_extension
extends DokuWiki_Admin_Plugin
14 protected $infoFor = null;
15 /** @var helper_plugin_extension_gui */
21 * loads additional helpers
23 public function __construct()
25 $this->gui
= plugin_load('helper', 'extension_gui');
29 * @return int sort number in admin menu
31 public function getMenuSort()
37 * @return bool true if only access for superuser, false is for superusers and moderators
39 public function forAdminOnly()
45 * Execute the requested action(s) and initialize the plugin repository
47 public function handle()
50 // initialize the remote repository
51 /* @var helper_plugin_extension_repository $repository */
52 $repository = $this->loadHelper('extension_repository');
54 if (!$repository->hasAccess(!$INPUT->bool('purge'))) {
55 $url = $this->gui
->tabURL('', ['purge' => 1], '&');
56 msg($this->getLang('repo_error').
57 ' [<a href="'.$url.'">'.$this->getLang('repo_retry').'</a>]', -1
61 if (!in_array('ssl', stream_get_transports())) {
62 msg($this->getLang('nossl'), -1);
65 /* @var helper_plugin_extension_extension $extension */
66 $extension = $this->loadHelper('extension_extension');
69 if ($INPUT->post
->has('fn') && checkSecurityToken()) {
70 $actions = $INPUT->post
->arr('fn');
71 foreach ($actions as $action => $extensions) {
72 foreach ($extensions as $extname => $label) {
77 $extension->setExtension($extname);
78 $installed = $extension->installOrUpdate();
79 foreach ($installed as $ext => $info) {
81 $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
87 $extension->setExtension($extname);
88 $status = $extension->uninstall();
91 $this->getLang('msg_delete_success'),
92 hsc($extension->getDisplayName())), 1
96 $this->getLang('msg_delete_failed'),
97 hsc($extension->getDisplayName())), -1
102 $extension->setExtension($extname);
103 $status = $extension->enable();
104 if ($status !== true) {
108 $this->getLang('msg_enabled'),
109 hsc($extension->getDisplayName())), 1
114 $extension->setExtension($extname);
115 $status = $extension->disable();
116 if ($status !== true) {
120 $this->getLang('msg_disabled'),
121 hsc($extension->getDisplayName())), 1
128 send_redirect($this->gui
->tabURL('', [], '&', true));
129 } elseif ($INPUT->post
->str('installurl') && checkSecurityToken()) {
130 $installed = $extension->installFromURL(
131 $INPUT->post
->str('installurl'),
132 $INPUT->post
->bool('overwrite'));
133 foreach ($installed as $ext => $info) {
135 $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
139 send_redirect($this->gui
->tabURL('', [], '&', true));
140 } elseif (isset($_FILES['installfile']) && checkSecurityToken()) {
141 $installed = $extension->installFromUpload('installfile', $INPUT->post
->bool('overwrite'));
142 foreach ($installed as $ext => $info) {
144 $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
148 send_redirect($this->gui
->tabURL('', [], '&', true));
150 } catch (Exception
$e) {
151 msg($e->getMessage(), -1);
152 send_redirect($this->gui
->tabURL('', [], '&', true));
159 public function html()
161 echo '<h1>'.$this->getLang('menu').'</h1>'.DOKU_LF
;
162 echo '<div id="extension__manager">'.DOKU_LF
;
164 $this->gui
->tabNavigation();
166 switch ($this->gui
->currentTab()) {
168 $this->gui
->tabSearch();
171 $this->gui
->tabTemplates();
174 $this->gui
->tabInstall();
178 $this->gui
->tabPlugins();
181 echo '</div>'.DOKU_LF
;