diff options
author | sembrestels <sembrestels@riseup.net> | 2011-10-13 15:23:11 +0200 |
---|---|---|
committer | sembrestels <sembrestels@riseup.net> | 2011-10-13 15:23:11 +0200 |
commit | 74bd6999c5e5c23ebbf90dbb6bdaabbddd7594cf (patch) | |
tree | 834c120d692be288f261bcae169eedd3d6b31d74 /vendors/dokuwiki/lib/tpl/default/tplfn_sidebar.php | |
parent | f8be8643f0faadb2c0ce87d553b7b9d569af5afd (diff) | |
download | elgg-74bd6999c5e5c23ebbf90dbb6bdaabbddd7594cf.tar.gz elgg-74bd6999c5e5c23ebbf90dbb6bdaabbddd7594cf.tar.bz2 |
Rename lib/dokuwiki to vendors/dokuwiki
Diffstat (limited to 'vendors/dokuwiki/lib/tpl/default/tplfn_sidebar.php')
-rw-r--r-- | vendors/dokuwiki/lib/tpl/default/tplfn_sidebar.php | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/vendors/dokuwiki/lib/tpl/default/tplfn_sidebar.php b/vendors/dokuwiki/lib/tpl/default/tplfn_sidebar.php new file mode 100644 index 000000000..6c378c385 --- /dev/null +++ b/vendors/dokuwiki/lib/tpl/default/tplfn_sidebar.php @@ -0,0 +1,98 @@ +<?php +/* + * Provide navigation sidebar functionality to Dokuwiki Templates + * + * This is not currently part of the official Dokuwiki release + * + * @link http://wiki.jalakai.co.uk/dokuwiki/doku.php?id=tutorials:dev:navigation_sidebar + * @author Christopher Smith <chris@jalakai.co.uk> + */ + +// sidebar configuration settings +tpl_loadConfig(); + +// determine the sidebar class +$sidebar_class = "sidebar sidebar_".tpl_getConf('layout').'_'.tpl_getConf('orientation'); + +// 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; + +// remove deepest namespace level and call function recursively + + // no namespace left, exit with no file found + if (!$ns) return ''; + + $i = strrpos($ns, ":"); + $ns = ($i) ? substr($ns, 0, $i) : false; + return getSidebarFN($ns, $file); +} + +// print a sidebar edit button - if appropriate +function tpl_sidebar_editbtn() { + global $ID, $conf, $lang; + + // check sidebar configuration + if (!tpl_getConf('showeditbtn') || !tpl_getConf('page')) return; + + // check sidebar page exists + $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page')); + if (!$fileSidebar) return; + + // check user has edit permission for the sidebar page + if (auth_quickaclcheck($fileSidebar) < AUTH_EDIT) return; + +?> + <div class="secedit"> + <form class="button" method="post" action="<?php echo wl($fileSidebar,'do=edit'); ?>" onsubmit="return svchk()"> + <input type="hidden" name="do" value="edit" /> + <input type="hidden" name="rev" value="" /> + <input type="hidden" name="id" value="<?php echo $fileSidebar; ?>" /> + <input type="submit" value="<?php echo $lang['btn_sidebaredit']; ?>" class="button" /> + </form> + </div> +<?php +} + +// 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 (tpl_getConf('page')) { + $fileSidebar = getSidebarFN(getNS($ID), tpl_getConf('page')); + } + + // determine what to display + if ($fileSidebar) { + $ID = $fileSidebar; + $REV = ''; + $ACT = 'show'; +# print p_wiki_xhtml($fileSidebar,'',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; +} |