From d7410643d8e3db12a76845370d8eee2508fa6115 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 4 Aug 2013 19:46:02 +0200 Subject: added tab navigation --- lib/plugins/extension/admin.php | 49 +++++++++++++++++------ lib/plugins/extension/helper/gui.php | 71 ++++++++++++++++++++++++++++++++++ lib/plugins/extension/helper/list.php | 35 +++++++---------- lib/plugins/extension/lang/en/lang.php | 6 ++- 4 files changed, 126 insertions(+), 35 deletions(-) create mode 100644 lib/plugins/extension/helper/gui.php (limited to 'lib/plugins/extension') diff --git a/lib/plugins/extension/admin.php b/lib/plugins/extension/admin.php index 6cad58595..4faafedb2 100644 --- a/lib/plugins/extension/admin.php +++ b/lib/plugins/extension/admin.php @@ -14,6 +14,17 @@ if(!defined('DOKU_INC')) die(); */ class admin_plugin_extension extends DokuWiki_Admin_Plugin { protected $infoFor = null; + /** @var helper_plugin_extension_gui */ + protected $gui; + + /** + * Constructor + * + * loads additional helpers + */ + public function __construct(){ + $this->gui = plugin_load('helper', 'extension_gui'); + } /** * @return int sort number in admin menu @@ -40,7 +51,7 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin { $repository->init(); if(!$repository->hasAccess()){ - $url = helper_plugin_extension_list::tabURL('', array('purge'=>1)); + $url = $this->gui->tabURL('', array('purge'=>1)); msg('The DokuWiki extension repository can not be reached currently. Online Features are not available. [retry]', -1); @@ -109,21 +120,35 @@ class admin_plugin_extension extends DokuWiki_Admin_Plugin { public function html() { /* @var Doku_Plugin_Controller $plugin_controller */ global $plugin_controller; + global $INPUT; ptln('

'.$this->getLang('menu').'

'); ptln('
'); - $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); - $list->add_row($extension, $name == $this->infoFor); + $this->gui->tabNavigation(); + + switch($INPUT->str('tab','plugins')){ + case 'search': + echo 'search interface'; + break; + case 'plugins': + default: + // FIXME move to function? + + $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); + $list->add_row($extension, $name == $this->infoFor); + } + $list->end_form(); + $list->render(); } - $list->end_form(); - $list->render(); + + ptln('
'); } } diff --git a/lib/plugins/extension/helper/gui.php b/lib/plugins/extension/helper/gui.php new file mode 100644 index 000000000..eba5fbc7f --- /dev/null +++ b/lib/plugins/extension/helper/gui.php @@ -0,0 +1,71 @@ + + */ + +// must be run within Dokuwiki +if(!defined('DOKU_INC')) die(); + +/** + * Class helper_plugin_extension_list takes care of the overall GUI + */ +class helper_plugin_extension_gui extends DokuWiki_Plugin { + + protected $tabs = array('plugins', 'templates', 'search'); + + /** + * Print the tab navigation + * + * @fixme style active one + */ + public function tabNavigation() { + echo ''; + } + + /** + * Return the currently selected tab + * + * @return string + */ + public function currentTab() { + global $INPUT; + + $tab = $INPUT->str('tab', 'plugins', true); + if(!in_array($tab, $this->tabs)) $tab = 'plugins'; + return $tab; + } + + /** + * Create an URL inside the extension manager + * + * @param string $tab tab to load, empty for current tab + * @param array $params associative array of parameter to set + * + * @return string + */ + public function tabURL($tab = '', $params = array()) { + global $ID; + + if(!$tab) $tab = $this->currentTab(); + $defaults = array( + 'do' => 'admin', + 'page' => 'extension', + 'tab' => $tab, + ); + return wl($ID, array_merge($defaults, $params)); + } + +} diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 816d4a444..1c337176d 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -14,6 +14,17 @@ if(!defined('DOKU_INC')) die(); */ class helper_plugin_extension_list extends DokuWiki_Plugin { protected $form = ''; + /** @var helper_plugin_extension_gui */ + protected $gui; + + /** + * Constructor + * + * loads additional helpers + */ + public function __construct(){ + $this->gui = plugin_load('helper', 'extension_gui'); + } function start_form() { $this->form .= '
'; @@ -152,7 +163,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { $mailid = $extension->getEmailID(); if($mailid){ - $url = $this->tabURL('search', array('q' => 'mailid:'.$mailid)); + $url = $this->gui->tabURL('search', array('q' => 'mailid:'.$mailid)); return ''.hsc($extension->getAuthor()).''; }else{ return ''.hsc($extension->getAuthor()).''; @@ -239,7 +250,7 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { }else{ $first = false; } - $url = $this->tabURL('search', array('q' => 'tag:'.$tag)); + $url = $this->gui->tabURL('search', array('q' => 'tag:'.$tag)); $return .= ''.hsc($tag).''; } echo ''; @@ -484,24 +495,4 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { return ''; } - - /** - * Create an URL inside the extension manager - * - * @param string tab tb to load, empty for current tab - * @param array $params associative array of parameter to set - * @return string - */ - static public function tabURL($tab='', $params=array()){ - global $ID; - global $INPUT; - - if(!$tab) $tab = $INPUT->str('tab', 'installed', true); - $defaults = array( - 'do' => 'admin', - 'page' => 'extension', - 'tab' => $tab, - ); - return wl($ID, array_merge($defaults, $params)); - } } diff --git a/lib/plugins/extension/lang/en/lang.php b/lib/plugins/extension/lang/en/lang.php index b3a451ecc..4439db879 100644 --- a/lib/plugins/extension/lang/en/lang.php +++ b/lib/plugins/extension/lang/en/lang.php @@ -7,7 +7,11 @@ */ // menu entry for admin plugins -$lang['menu'] = 'Extension manager'; +$lang['menu'] = 'Extension Manager'; + +$lang['tab_plugins'] = 'Installed Plugins'; +$lang['tab_templates'] = 'Installed Templates'; +$lang['tab_search'] = 'Search and Install'; // custom language strings for the plugin $lang['notimplemented'] = 'This feature hasn\'t been implemented yet'; -- cgit v1.2.3