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 | * @author Christopher Smith <[email protected]>
|
---|
8 | * @author Don Bowman <[email protected]>
|
---|
9 | */
|
---|
10 |
|
---|
11 | /****** sidebar configuration settings ******/
|
---|
12 | tpl_loadConfig();
|
---|
13 |
|
---|
14 | /****** determine the sidebar class ******/
|
---|
15 | $sidebar_class =
|
---|
16 | "sidebar sidebar_".tpl_getConf('layout').'_'.tpl_getConf('orientation');
|
---|
17 |
|
---|
18 |
|
---|
19 | /*
|
---|
20 | * recursive function to establish best sidebar file to be used
|
---|
21 | */
|
---|
22 | function getSidebarFN($ns, $file) {//func
|
---|
23 |
|
---|
24 | /****** check for wiki page = $ns:$file (or $file where no namespace) ******/
|
---|
25 | $nsFile = ($ns) ? "$ns:$file" : $file;
|
---|
26 | if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile))
|
---|
27 | return $nsFile;
|
---|
28 |
|
---|
29 | /****** no namespace left, exit with no file found ******/
|
---|
30 | if (!$ns)
|
---|
31 | return '';
|
---|
32 |
|
---|
33 | /****** remove deepest namespace level and call function recursively ******/
|
---|
34 | $i = strrpos($ns, ":");
|
---|
35 | $ns = ($i) ? substr($ns, 0, $i) : false;
|
---|
36 | return getSidebarFN($ns, $file);
|
---|
37 |
|
---|
38 | }//function getSidebarFN($ns, $file)
|
---|
39 |
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * print a sidebar edit button - if appropriate
|
---|
43 | */
|
---|
44 | function tpl_sidebar_editbtn() {//func
|
---|
45 |
|
---|
46 | /****** declare global variables ******/
|
---|
47 | global $ID, $conf, $lang;
|
---|
48 |
|
---|
49 | /****** check if button wanted ******/
|
---|
50 | if (!tpl_getConf('rb_showeditbtn'))
|
---|
51 | return;
|
---|
52 |
|
---|
53 | /****** check if sidebar page exists ******/
|
---|
54 | $fileSidebar = getSidebarFN(getNS($ID), 'sidebar');
|
---|
55 | if (!$fileSidebar)
|
---|
56 | return;
|
---|
57 |
|
---|
58 | /****** check if user has edit permission for the sidebar page ******/
|
---|
59 | if (auth_quickaclcheck($fileSidebar) < AUTH_EDIT)
|
---|
60 | return;
|
---|
61 |
|
---|
62 | /****** generate button ******/
|
---|
63 | ?>
|
---|
64 | <div class="secedit">
|
---|
65 | <form class="button" method="post" action="<?php echo wl($fileSidebar,'do=edit'); ?>"
|
---|
66 | onsubmit="return svchk()">
|
---|
67 | <input type="hidden" name="do" value="edit" />
|
---|
68 | <input type="hidden" name="rev" value="" />
|
---|
69 | <input type="hidden" name="id" value="<?php echo $fileSidebar; ?>" />
|
---|
70 | <input type="submit" value="<?php echo $lang['btn_sidebaredit']; ?>" class="button" />
|
---|
71 | </form>
|
---|
72 | </div>
|
---|
73 | <?php
|
---|
74 |
|
---|
75 | }//function tpl_sidebar_editbtn()
|
---|
76 |
|
---|
77 |
|
---|
78 | /*
|
---|
79 | * display the sidebar
|
---|
80 | */
|
---|
81 | function tpl_sidebar_content() {//func
|
---|
82 |
|
---|
83 | /****** declare global variables ******/
|
---|
84 | global $ID, $REV, $ACT, $conf;
|
---|
85 |
|
---|
86 | /****** save global variables ******/
|
---|
87 | $saveID = $ID;
|
---|
88 | $saveREV = $REV;
|
---|
89 | $saveACT = $ACT;
|
---|
90 |
|
---|
91 | /****** find file to be displayed in navigation sidebar ******/
|
---|
92 | $fileSidebar = '';
|
---|
93 | $fileSidebar = getSidebarFN(getNS($ID), 'sidebar');
|
---|
94 |
|
---|
95 | /****** show main sidebar if necessary ******/
|
---|
96 | if (tpl_getConf('rb_main_sidebar') && $fileSidebar != 'sidebar') {//do
|
---|
97 | $ID = 'sidebar';
|
---|
98 | $REV = '';
|
---|
99 | $ACT = 'show';
|
---|
100 | tpl_content(false);
|
---|
101 | if (tpl_getConf('rb_showeditbtn')) {//do
|
---|
102 | tpl_sidebar_editbtn();
|
---|
103 | echo "<br>";
|
---|
104 | }//if (tpl_getConf('rb_showeditbtn'))
|
---|
105 | echo "<hr>";
|
---|
106 | }//if (tpl_getConf('rb_main_sidebar') && $fileSidebar != 'sidebar')
|
---|
107 |
|
---|
108 | /****** show current sidebar ******/
|
---|
109 | if ($fileSidebar) {//do
|
---|
110 | $ID = $fileSidebar;
|
---|
111 | $REV = '';
|
---|
112 | $ACT = 'show';
|
---|
113 | tpl_content(false);
|
---|
114 | if (tpl_getConf('rb_showeditbtn'))
|
---|
115 | tpl_sidebar_editbtn();
|
---|
116 | }//if ($fileSidebar)
|
---|
117 |
|
---|
118 | /****** show index ******/
|
---|
119 | else {//if (!$fileSidebar)
|
---|
120 | $REV = '';
|
---|
121 | $ACT = 'index';
|
---|
122 | tpl_content(false);
|
---|
123 | }//if (!$fileSidebar)
|
---|
124 |
|
---|
125 | /****** restore global variables ******/
|
---|
126 | $ID = $saveID;
|
---|
127 | $REV = $saveREV;
|
---|
128 | $ACT = $saveACT;
|
---|
129 |
|
---|
130 | }//function tpl_sidebar_content()
|
---|