* @author Christopher Smith */ if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'action.php'); class action_plugin_sidebar extends DokuWiki_Action_Plugin { protected static $done = false; /** * return some info */ function getInfo(){ return confToHash(dirname(__FILE__).'/INFO.txt'); } /* * plugin should use this method to register its handlers with the dokuwiki's event controller */ function register(&$controller) { $controller->register_hook('TPL_ACT_RENDER', 'AFTER', $this, '_output'); } function _debug(&$event, $param) { ptln($param); ptln(''); } function _output(&$event, $param) { if (!$this->getConf('enable') || self::$done) return; self::$done = true; // prevent recursive calls when doing tpl_content() later on $bodyClass = 'sidebar sidebar_' . $this->getConf('layout') . '_' . $this->getConf('orientation'); ptln('', 2); // close the main content area ptln('', 2); ptln('', 2); ptln(' for closing the "sidebar"-div will be provided by DokuWiki main template } // recursive function to establish best sidebar file to be used function getSidebarFN($ns, $file) { // check for wiki page = $ns:$file (or $file where no namespace) $nsFile = ($ns) ? "$ns:$file" : $file; if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile)) return $nsFile; // no namespace left, exit with no file found if (!$ns) return ''; // remove deepest namespace level and call function recursively $i = strrpos($ns, ":"); $ns = ($i) ? substr($ns, 0, $i) : false; return $this->getSidebarFN($ns, $file); } // print a sidebar edit button - if appropriate function tpl_sidebar_editbtn() { global $ID; // check sidebar configuration if (!$this->getConf('showeditbtn') || !$this->getConf('page')) return; // check sidebar page exists $fileSidebar = $this->getSidebarFN(getNS($ID), $this->getConf('page')); if (!$fileSidebar) return; // check user has edit permission for the sidebar page if (auth_quickaclcheck($fileSidebar) < AUTH_EDIT) return; ptln('
', 6); ptln('
', 8); ptln('', 10); ptln('', 10); ptln('', 10); ptln('', 10); ptln('
', 8); ptln('
', 6); } // display the sidebar function tpl_sidebar_content() { global $ID, $REV, $ACT, $conf; // save globals $saveID = $ID; $saveREV = $REV; $saveACT = $ACT; // discover file to be displayed in navigation sidebar $fileSidebar = ''; if ($this->getConf('page')) { $fileSidebar = $this->getSidebarFN(getNS($ID), $this->getConf('page')); } // determine what to display if ($fileSidebar) { $ID = $fileSidebar; $REV = ''; $ACT = 'show'; // ptln(p_wiki_xhtml($ID, $REV, false)); tpl_content(); } else { # global $IDX; # html_index($IDX); # $ID = getNS($ID); $REV = ''; $ACT = 'index'; tpl_content(); } // restore globals $ID = $saveID; $REV = $saveREV; $ACT = $saveACT; } }