To fit in with current Dokuwiki structure there needs to be four separate entry points to the plugin.
act_dispatch(), any processing is done here, …handle() method, no parameterstpl_admin(), html generation is done here, …html() method, no parametershtml_admin(), supply text prompt and sort order for admin menu, …getMenuText() method, one parameter, current languagegetMenuSort() method, no parametersgetInfo() method, no parametersReturn hash containing summary information about the plugin (identical to method and hash used for syntax plugins.
Return text prompt to be displayed on the main administration menu.
return an integer used to determine order of display on main administration menu.
Do all processing not required by html generation.
Output the html required.
inc/actions.php act_dispatch() #67, replace current if ($ACT == 'admin') { } block with below
//handle admin tasks if($ACT == 'admin'){ // retrieve admin plugin name from $_REQUEST['page'] if ($_REQUEST['page']) { $pluginlist = plugin_list('admin'); if (in_array($_REQUEST['page'], $pluginlist)) { // attempt to load the plugin if ($plugin =& plugin_load('admin',$_REQUEST['page']) !== NULL) $plugin->handle(); } } }
inc/template.php
function tpl_admin() { $plugin = NULL; if ($_REQUEST['page']) { $pluginlist = plugin_list('admin'); if (in_array($_REQUEST['page'], $pluginlist)) { $plugin =& plugin_load('admin',$_REQUEST['page']); } } if ($plugin !== NULL) $plugin->html(); else html_admin(); }
inc/html.php html_admin()
/** * Print the admin overview page * * @author Andreas Gohr <andi@splitbrain.org> */ function html_admin(){ global $ID; global $lang; global $conf; print p_locale_xhtml('admin'); // build menu of admin functions from the plugins that handle them $pluginlist = plugin_list('admin'); $menu = array(); foreach ($pluginlist as $p) { if($obj =& plugin_load('admin',$p) === NULL) continue; $menu[] = array('plugin' => $p, 'prompt' => $obj->getMenuText($conf['lang']), 'sort' => $obj->getMenuSort() ); } usort($menu, p_sort_modes); // output the menu ptln('<ul>'); foreach ($menu as $item) { ptln(' <li><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></li>'); } // add in non-plugin functions if (!$conf['openregister']){ ptln('<li><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></li>'); } ptln('</ul>'); }
Unable to display file "dokuwiki/lib/plugins/admin.php": It may not exist, or permission may be denied.
Admin Plugin Skeleton
<?php if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'admin.php'); /** * All DokuWiki plugins to extend the admin function * need to inherit from this class */ class admin_plugin_skeleton extends DokuWiki_Admin_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'me', 'email' => 'me@somesite.com', 'date' => '20yy-mm-dd', 'name' => 'admin plugin skeleton', 'desc' => 'demonstration skeleton', 'url' => 'http://wiki.splitbrain.org/plugin:admin', ); } /** * return sort order for position in admin menu */ function getMenuSort() { return 999; } /** * handle user request */ function handle() { } /** * output appropriate html */ function html() { } }
Converted from the current inc/admin_acl.php file. Its a really simple conversion, rename two functions (admin_acl_handler() → handle() & admin_acl_html → html()) and prefix all internal function calls with $this-> and add in the three one liner methods, getInfo(), getMenuText() and getMenuSort().
Unable to display file "dokuwiki/lib/plugins/acl/admin.php": It may not exist, or permission may be denied.