3 * Provide navigation sidebar functionality to Dokuwiki Templates
5 * This is not currently part of the official Dokuwiki release
7 * @link http://wiki.jalakai.co.uk/dokuwiki/doku.php?id=tutorials:dev:navigation_sidebar
8 * @author Christopher Smith <chris@jalakai.co.uk>
11 // sidebar configuration settings
14 // determine the sidebar class
15 $sidebar_class = "sidebar sidebar_".tpl_getConf('layout').'_'.tpl_getConf('orientation');
17 // recursive function to establish best sidebar file to be used
18 function getSidebarFN($ns, $file) {
20 // check for wiki page = $ns:$file (or $file where no namespace)
21 $nsFile = ($ns) ?
"$ns:$file" : $file;
22 if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile)) return $nsFile;
24 // remove deepest namespace level and call function recursively
26 // no namespace left, exit with no file found
29 $i = strrpos($ns, ":");
30 $ns = ($i) ?
substr($ns, 0, $i) : false;
31 return getSidebarFN($ns, $file);
34 // print a sidebar edit button - if appropriate
35 function tpl_sidebar_editbtn() {
36 global $ID, $conf, $lang;
38 // check sidebar configuration
39 if (!tpl_getConf('showeditbtn') ||
!tpl_getConf('page')) return;
41 // check sidebar page exists
42 $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page'));
43 if (!$fileSidebar) return;
45 // check user has edit permission for the sidebar page
46 if (auth_quickaclcheck($fileSidebar) < AUTH_EDIT
) return;
50 <form
class="button" method
="post" action
="<?php echo wl($fileSidebar,'do=edit'); ?>" onsubmit
="return svchk()">
51 <input type
="hidden" name
="do" value
="edit" />
52 <input type
="hidden" name
="rev" value
="" />
53 <input type
="hidden" name
="id" value
="<?php echo $fileSidebar; ?>" />
54 <input type
="submit" value
="<?php echo $lang['btn_sidebaredit']; ?>" class="button" />
60 // display the sidebar
61 function tpl_sidebar_content() {
62 global $ID, $REV, $ACT, $conf;
69 // discover file to be displayed in navigation sidebar
72 if (tpl_getConf('page')) {
73 $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page'));
76 // determine what to display
81 # print p_wiki_xhtml($fileSidebar,'',false);