first commit. dokuwiki.
[h2N7SspZmY.git] / lib / tpl / sidebar / tplfn_sidebar.php
blob6c378c38594d1f2a53544fa8912b631ba691857b
1 <?php
2 /*
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>
9 */
11 // sidebar configuration settings
12 tpl_loadConfig();
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
27 if (!$ns) return '';
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;
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
60 // display the sidebar
61 function tpl_sidebar_content() {
62 global $ID, $REV, $ACT, $conf;
64 // save globals
65 $saveID = $ID;
66 $saveREV = $REV;
67 $saveACT = $ACT;
69 // discover file to be displayed in navigation sidebar
70 $fileSidebar = '';
72 if (tpl_getConf('page')) {
73 $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page'));
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();
84 else {
85 # global $IDX;
86 # html_index($IDX);
87 # $ID = getNS($ID);
88 $REV = '';
89 $ACT = 'index';
91 tpl_content();
94 // restore globals
95 $ID = $saveID;
96 $REV = $saveREV;
97 $ACT = $saveACT;