1<?php 2/* 3 * Provide navigation sidebar functionality to Dokuwiki Templates 4 * 5 * This is not currently part of the official Dokuwiki release 6 * 7 * @link http://wiki.jalakai.co.uk/dokuwiki/doku.php?id=tutorials:dev:navigation_sidebar 8 * @author Christopher Smith <chris@jalakai.co.uk> 9 */ 10 11// sidebar configuration settings 12tpl_loadConfig(); 13 14// determine the sidebar class 15$sidebar_class = "sidebar sidebar_".tpl_getConf('layout').'_'.tpl_getConf('orientation'); 16 17// recursive function to establish best sidebar file to be used 18function getSidebarFN($ns, $file) { 19 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; 23 24// remove deepest namespace level and call function recursively 25 26 // no namespace left, exit with no file found 27 if (!$ns) return ''; 28 29 $i = strrpos($ns, ":"); 30 $ns = ($i) ? substr($ns, 0, $i) : false; 31 return getSidebarFN($ns, $file); 32} 33 34// print a sidebar edit button - if appropriate 35function tpl_sidebar_editbtn() { 36 global $ID, $conf, $lang; 37 38 // check sidebar configuration 39 if (!tpl_getConf('showeditbtn') || !tpl_getConf('page')) return; 40 41 // check sidebar page exists 42 $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page')); 43 if (!$fileSidebar) return; 44 45 // check user has edit permission for the sidebar page 46 if (auth_quickaclcheck($fileSidebar) < AUTH_EDIT) return; 47 48?> 49 <div class="secedit"> 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" /> 55 </form> 56 </div> 57<?php 58} 59 60// display the sidebar 61function tpl_sidebar_content() { 62 global $ID, $REV, $ACT, $conf; 63 64 // save globals 65 $saveID = $ID; 66 $saveREV = $REV; 67 $saveACT = $ACT; 68 69 // discover file to be displayed in navigation sidebar 70 $fileSidebar = ''; 71 72 if (tpl_getConf('page')) { 73 $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page')); 74 } 75 76 // determine what to display 77 if ($fileSidebar) { 78 $ID = $fileSidebar; 79 $REV = ''; 80 $ACT = 'show'; 81# print p_wiki_xhtml($fileSidebar,'',false); 82 tpl_content(); 83 } 84 else { 85# global $IDX; 86# html_index($IDX); 87# $ID = getNS($ID); 88 $REV = ''; 89 $ACT = 'index'; 90 91 tpl_content(); 92 } 93 94 // restore globals 95 $ID = $saveID; 96 $REV = $saveREV; 97 $ACT = $saveACT; 98} 99