diff options
author | Michael Hamann <michael@content-space.de> | 2013-08-02 23:30:32 +0200 |
---|---|---|
committer | Michael Hamann <michael@content-space.de> | 2013-08-02 23:31:51 +0200 |
commit | 02779b18797b2ee1304613de684d54988815dacb (patch) | |
tree | aab9f1a898c0603e875ecc4d0e086bb0b5086bcb /lib/plugins/extension/admin.php | |
parent | 1981046ea006031f74fb082960756b3d2919b99e (diff) | |
download | rpg-02779b18797b2ee1304613de684d54988815dacb.tar.gz rpg-02779b18797b2ee1304613de684d54988815dacb.tar.bz2 |
Extension manager: Implement extension table
This uses a lot of code and the whole design from the previous extension
manager implementation.
Diffstat (limited to 'lib/plugins/extension/admin.php')
-rw-r--r-- | lib/plugins/extension/admin.php | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/lib/plugins/extension/admin.php b/lib/plugins/extension/admin.php index 19863e772..373f90183 100644 --- a/lib/plugins/extension/admin.php +++ b/lib/plugins/extension/admin.php @@ -9,7 +9,11 @@ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); +/** + * Admin part of the extension manager + */ class admin_plugin_extension extends DokuWiki_Admin_Plugin { + protected $infoFor = null; /** * @return int sort number in admin menu @@ -26,32 +30,94 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin { } /** - * Should carry out any processing required by the plugin. + * Execute the requested action(s) and initialize the plugin repository */ public function handle() { + global $INPUT; + // initialize the remote repository /* @var helper_plugin_extension_repository $repository */ $repository = $this->loadHelper('extension_repository'); $repository->init(); + + /* @var helper_plugin_extension_extension $extension */ + $extension = $this->loadHelper('extension_extension'); + + if ($INPUT->post->has('fn')) { + $actions = $INPUT->post->arr('fn'); + foreach ($actions as $action => $extensions) { + foreach ($extensions as $extname => $label) { + switch ($action) { + case 'info': + $this->infoFor = $extname; + break; + case 'install': + msg('Not implemented'); + break; + case 'reinstall': + case 'update': + $extension->setExtension($extname, false); + $status = $extension->installOrUpdate(); + if ($status !== true) { + msg($status, -1); + } else { + msg(sprintf($this->getLang('msg_update_success'), hsc($extension->getName())), 1); + } + break; + case 'uninstall': + $extension->setExtension($extname, false); + $status = $extension->uninstall(); + if ($status !== true) { + msg($status, -1); + } else { + msg(sprintf($this->getLang('msg_delete_success'), hsc($extension->getName())), 1); + } + break; + case 'enable'; + $extension->setExtension($extname, false); + $status = $extension->enable(); + if ($status !== true) { + msg($status, -1); + } else { + msg(sprintf($this->getLang('msg_enabled'), hsc($extension->getName())), 1); + } + break; + case 'disable'; + $extension->setExtension($extname, false); + $status = $extension->disable(); + if ($status !== true) { + msg($status, -1); + } else { + msg(sprintf($this->getLang('msg_disabled'), hsc($extension->getName())), 1); + } + break; + } + } + } + } } /** - * Render HTML output, e.g. helpful text and a form + * Render HTML output */ public function html() { /* @var Doku_Plugin_Controller $plugin_controller */ global $plugin_controller; ptln('<h1>'.$this->getLang('menu').'</h1>'); + ptln('<div id="extension__manager">'); $pluginlist = $plugin_controller->getList('', true); /* @var helper_plugin_extension_extension $extension */ $extension = $this->loadHelper('extension_extension'); + /* @var helper_plugin_extension_list $list */ + $list = $this->loadHelper('extension_list'); + $list->start_form(); foreach ($pluginlist as $name) { $extension->setExtension($name, false); - ptln('<h2>'.hsc($extension->getName()).'</h2>'); - ptln('<p>'.hsc($extension->getDescription()).'</p>'); - ptln('<p>Latest available version: '.hsc($extension->getLastUpdate()).'</p>'); - ptln('<p>Installed version: '.hsc($extension->getInstalledVersion()).'</p>'); + $list->add_row($extension, $name == $this->infoFor); } + $list->end_form(); + $list->render(); + ptln('</div>'); } } |