summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2015-05-16 19:07:23 +0200
committerChristopher Smith <chris@jalakai.co.uk>2015-05-16 19:07:23 +0200
commita61966c55d9d0ac4b800d65cfc6ee1aea44899b5 (patch)
treeac4dc0bb88c5efe6e0fdcb834f3a185eb6741fe7 /inc/template.php
parentc248bda1dcbef2068071904057b8410aa1eb0200 (diff)
downloadrpg-a61966c55d9d0ac4b800d65cfc6ee1aea44899b5.tar.gz
rpg-a61966c55d9d0ac4b800d65cfc6ee1aea44899b5.tar.bz2
Provide a function to return admin plugin for the page request.
This was previously carried out in three separate places. Refactor that code to use the new function. Update tpl_pageTitle test to use a manager level admin plugin.
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php30
1 files changed, 7 insertions, 23 deletions
diff --git a/inc/template.php b/inc/template.php
index 39d06e895..95dc52deb 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -218,18 +218,9 @@ function tpl_toc($return = false) {
$toc = array();
}
} elseif($ACT == 'admin') {
- // try to load admin plugin TOC FIXME: duplicates code from tpl_admin
- $plugin = null;
- $class = $INPUT->str('page');
- if(!empty($class)) {
- $pluginlist = plugin_list('admin');
- if(in_array($class, $pluginlist)) {
- // attempt to load the plugin
- /** @var $plugin DokuWiki_Admin_Plugin */
- $plugin = plugin_load('admin', $class);
- }
- }
- if( ($plugin !== null) && (!$plugin->forAdminOnly() || $INFO['isadmin']) ) {
+ // try to load admin plugin TOC
+ /** @var $plugin DokuWiki_Admin_Plugin */
+ if ($plugin = plugin_getRequestAdminPlugin()) {
$toc = $plugin->getTOC();
$TOC = $toc; // avoid later rebuild
}
@@ -1054,17 +1045,10 @@ function tpl_pagetitle($id = null, $ret = false) {
case 'admin' :
$page_title = $lang['btn_admin'];
// try to get the plugin name
- // retrieve admin plugin name from $_REQUEST['page']
- if (($page = $INPUT->str('page', '', true)) != '') {
- $pluginlist = plugin_list('admin');
- if (in_array($page, $pluginlist)) {
- // attempt to load the plugin
-
- if (($plugin = plugin_load('admin',$page)) !== null){
- $plugin_title = $plugin->getMenuText($conf['lang']);
- $page_title = $plugin_title ? $plugin_title : $page;
- }
- }
+ /** @var $plugin DokuWiki_Admin_Plugin */
+ if ($plugin = plugin_getRequestAdminPlugin()){
+ $plugin_title = $plugin->getMenuText($conf['lang']);
+ $page_title = $plugin_title ? $plugin_title : $plugin->getPluginName();
}
break;