Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 222 lines (190 sloc) 6.18 kb
0230bd5 initial release
Michael Klier authored
1 <?php
2 /**
82a8f9e added option to move sidebar to the right
Michael Klier authored
3 * Template functions for DokuBook template
0230bd5 initial release
Michael Klier authored
4 *
5 * @license: GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author: Michael Klier <chi@chimeric.de>
7 */
3237a0c added custom footer per namespace feature
Michael Klier authored
8 // must be run within DokuWiki
9 if(!defined('DOKU_INC')) die();
10 if(!defined('DOKU_LF')) define('DOKU_LF', "\n");
0230bd5 initial release
Michael Klier authored
11
0091bc8 fixed logo link and added support for different file types
Michael Klier authored
12 // load language files
87736cb removed wrong function from templateconfhelper branch
ai authored
13 require_once(DOKU_TPLINC.'lang/en/lang.php');
14 if(@file_exists(DOKU_TPLINC.'lang/'.$conf['lang'].'/lang.php')) {
15 require_once(DOKU_TPLINC.'lang/'.$conf['lang'].'/lang.php');
0230bd5 initial release
Michael Klier authored
16 }
17
5f74f74 angua update
ai authored
18 function html_list_index_navigation($item){
19 global $ID;
20 $ret = '';
21 $base = ':'.$item['id'];
22 $base = substr($base,strrpos($base,':')+1);
23 if($item['type']=='d'){
24 $ret .= '<a href="'.wl($item['id']).'/" class="idx_dir"><strong>';
25 $ret .= $base;
26 $ret .= '</strong></a>';
27 }else{
28 $ret .= html_wikilink(':'.$item['id']);
29 }
30 return $ret;
31 }
32
33
0230bd5 initial release
Michael Klier authored
34 /**
35 * checks if a file called logo.png or logo.jpg exists
36 * and uses it as logo, uses the dokuwiki logo by default
37 *
38 * @author Michael Klier <chi@chimeric.de>
39 */
40 function tpl_logo() {
41 global $conf;
42
43 $out = '';
44
0091bc8 fixed logo link and added support for different file types
Michael Klier authored
45 switch(true) {
94169ce added logo configuration option - closes #5
Michael Klier authored
46 case(tpl_getConf('logo')):
47 $logo = tpl_getconf('logo');
48 break;
87736cb removed wrong function from templateconfhelper branch
ai authored
49 case(@file_exists(DOKU_TPLINC.'images/logo.jpg')):
50 $logo = DOKU_TPL.'images/logo.jpg';
0091bc8 fixed logo link and added support for different file types
Michael Klier authored
51 break;
87736cb removed wrong function from templateconfhelper branch
ai authored
52 case(@file_exists(DOKU_TPLINC.'images/logo.jpeg')):
53 $logo = DOKU_TPL.'images/logo.jpeg';
0091bc8 fixed logo link and added support for different file types
Michael Klier authored
54 break;
87736cb removed wrong function from templateconfhelper branch
ai authored
55 case(@file_exists(DOKU_TPLINC.'images/logo.png')):
56 $logo = DOKU_TPL.'images/logo.png';
0091bc8 fixed logo link and added support for different file types
Michael Klier authored
57 break;
58 default:
87736cb removed wrong function from templateconfhelper branch
ai authored
59 $logo = DOKU_TPL.'images/dokuwiki-128.png';
0091bc8 fixed logo link and added support for different file types
Michael Klier authored
60 break;
0230bd5 initial release
Michael Klier authored
61 }
62
0091bc8 fixed logo link and added support for different file types
Michael Klier authored
63 $out .= '<a href="' . DOKU_BASE . '" name="dokuwiki__top" id="dokuwiki__top" accesskey="h" title="[ALT+H]">';
5f74f74 angua update
ai authored
64 if( $logo ) {
65 $out .= ' <img class="logo" src="' . $logo . '" alt="' . $conf['title'] . '" />' . DOKU_LF;
66 }
67 $out .= '</a>' . DOKU_LF;
0230bd5 initial release
Michael Klier authored
68
69 print ($out);
70 }
71
72 /**
73 * generates the sidebar contents
74 *
75 * @author Michael Klier <chi@chimeric.de>
76 */
77 function tpl_sidebar() {
78 global $lang;
79 global $ID;
0f9be98 added option closedwiki
Michael Klier authored
80 global $INFO;
0230bd5 initial release
Michael Klier authored
81
9534ddd added support for namespace navigation
Michael Klier authored
82 $svID = cleanID($ID);
3237a0c added custom footer per namespace feature
Michael Klier authored
83 $navpn = tpl_getConf('sb_pagename');
ca56c69 restructured tpl_functions.php
Michael Klier authored
84 $path = explode(':',$svID);
85 $found = false;
86 $sb = '';
9534ddd added support for namespace navigation
Michael Klier authored
87
0f9be98 added option closedwiki
Michael Klier authored
88 if(tpl_getConf('closedwiki') && empty($INFO['userinfo'])) {
3237a0c added custom footer per namespace feature
Michael Klier authored
89 print '<span class="sb_label">' . $lang['toolbox'] . '</span>' . DOKU_LF;
90 print '<div id="toolbox" class="sidebar_box">' . DOKU_LF;
0f9be98 added option closedwiki
Michael Klier authored
91 tpl_actionlink('login');
3237a0c added custom footer per namespace feature
Michael Klier authored
92 print '</div>' . DOKU_LF;
0f9be98 added option closedwiki
Michael Klier authored
93 return;
94 }
95
0230bd5 initial release
Michael Klier authored
96 // main navigation
3237a0c added custom footer per namespace feature
Michael Klier authored
97 print '<span class="sb_label">' . $lang['navigation'] . '</span>' . DOKU_LF;
98 print '<div id="navigation" class="sidebar_box">' . DOKU_LF;
9534ddd added support for namespace navigation
Michael Klier authored
99
100 while(!$found && count($path) > 0) {
101 $sb = implode(':', $path) . ':' . $navpn;
102 $found = @file_exists(wikiFN($sb));
103 array_pop($path);
104 }
105
ca56c69 restructured tpl_functions.php
Michael Klier authored
106 if(!$found && @file_exists(wikiFN($navpn))) $sb = $navpn;
107
f247a59 fixed bug with sidebar index
Michael Klier authored
108 if(@file_exists(wikiFN($sb)) && auth_quickaclcheck($sb) >= AUTH_READ) {
3237a0c added custom footer per namespace feature
Michael Klier authored
109 print p_dokubook_xhtml($sb);
0230bd5 initial release
Michael Klier authored
110 } else {
6f00a41 enhanced sidebar index
Michael Klier authored
111 print p_index_xhtml(cleanID($svID));
9534ddd added support for namespace navigation
Michael Klier authored
112 }
113
3237a0c added custom footer per namespace feature
Michael Klier authored
114 print '</div>' . DOKU_LF;
0230bd5 initial release
Michael Klier authored
115
116 // generate the searchbox
3237a0c added custom footer per namespace feature
Michael Klier authored
117 print '<span class="sb_label">' . strtolower($lang['btn_search']) . '</span>' . DOKU_LF;
118 print '<div id="search">' . DOKU_LF;
0230bd5 initial release
Michael Klier authored
119 tpl_searchform();
3237a0c added custom footer per namespace feature
Michael Klier authored
120 print '</div>' . DOKU_LF;
0230bd5 initial release
Michael Klier authored
121
122 // generate the toolbox
3237a0c added custom footer per namespace feature
Michael Klier authored
123 print '<span class="sb_label">' . $lang['toolbox'] . '</span>' . DOKU_LF;
124 print '<div id="toolbox" class="sidebar_box">' . DOKU_LF;
0230bd5 initial release
Michael Klier authored
125 tpl_actionlink('admin');
126 tpl_actionlink('index');
bb6832a mediamangerlink and icon
ai authored
127 tpl_actionlink('media');
0230bd5 initial release
Michael Klier authored
128 tpl_actionlink('recent');
129 tpl_actionlink('backlink');
130 tpl_actionlink('profile');
131 tpl_actionlink('login');
3237a0c added custom footer per namespace feature
Michael Klier authored
132 print '</div>' . DOKU_LF;
133
134 // restore ID just in case
0a21fdd @paps Very minor typos corrected.
paps authored
135 $ID = $svID;
3237a0c added custom footer per namespace feature
Michael Klier authored
136 }
137
138 /**
139 * prints a custom page footer
140 *
141 * @author Michael Klier <chi@chimeric.de>
142 */
143 function tpl_footer() {
144 global $ID;
145
146 $svID = $ID;
147 $ftpn = tpl_getConf('ft_pagename');
148 $path = explode(':',$svID);
149 $found = false;
150 $ft = '';
151
152 while(!$found && count($path) > 0) {
153 $ft = implode(':', $path) . ':' . $ftpn;
154 $found = @file_exists(wikiFN($ft));
155 array_pop($path);
156 }
157
158 if(!$found && @file_exists(wikiFN($ftpn))) $ft = $ftpn;
159
160 if(@file_exists(wikiFN($ft)) && auth_quickaclcheck($ft) >= AUTH_READ) {
161 print '<div id="footer">' . DOKU_LF;
162 print p_dokubook_xhtml($ft);
163 print '</div>' . DOKU_LF;
164 }
165
166 // restore ID just in case
167 $ID = $svID;
0230bd5 initial release
Michael Klier authored
168 }
169
170 /**
3237a0c added custom footer per namespace feature
Michael Klier authored
171 * removes the TOC of the sidebar-pages and shows
172 * a edit-button if user has enough rights
0230bd5 initial release
Michael Klier authored
173 *
174 * @author Michael Klier <chi@chimeric.de>
175 */
3237a0c added custom footer per namespace feature
Michael Klier authored
176 function p_dokubook_xhtml($wp) {
177 $data = p_wiki_xhtml($wp,'',false);
178 if(auth_quickaclcheck($wp) >= AUTH_EDIT) {
179 $data .= '<div class="secedit">' . html_btn('secedit',$wp,'',array('do'=>'edit','rev'=>'','post')) . '</div>';
0230bd5 initial release
Michael Klier authored
180 }
fcbd636 ensure sidebar headlines do not break XHTML compliance
Michael Klier authored
181 // strip TOC
182 $data = preg_replace('/<div class="toc">.*?(<\/div>\n<\/div>)/s', '', $data);
183 // replace headline ids for XHTML compliance
ae77061 implement FS#107
Michael Klier authored
184 $data = preg_replace('/(<h.*?><a.*?name=")(.*?)(".*?id=")(.*?)(">.*?<\/a><\/h.*?>)/','\1sb_\2\3sb_\4\5', $data);
fcbd636 ensure sidebar headlines do not break XHTML compliance
Michael Klier authored
185 return ($data);
0230bd5 initial release
Michael Klier authored
186 }
6f00a41 enhanced sidebar index
Michael Klier authored
187
188 /**
189 * Renders the Index
190 *
191 * copy of html_index located in /inc/html.php
192 *
193 * @author Andreas Gohr <andi@splitbrain.org>
194 * @author Michael Klier <chi@chimeric.de>
195 */
196 function p_index_xhtml($ns) {
197 require_once(DOKU_INC.'inc/search.php');
198 global $conf;
199 global $ID;
200 $dir = $conf['datadir'];
201 $ns = cleanID($ns);
202 #fixme use appropriate function
203 if(empty($ns)){
204 $ns = dirname(str_replace(':','/',$ID));
205 if($ns == '.') $ns ='';
206 }
207 $ns = utf8_encodeFN(str_replace(':','/',$ns));
208
209 // only extract headline
210 preg_match('/<h1>.*?<\/h1>/', p_locale_xhtml('index'), $match);
211 print $match[0];
212
213 $data = array();
214 search($data,$conf['datadir'],'search_index',array('ns' => $ns));
f1fb2c6 use enhanced AJAX index in sidebar
Michael Klier authored
215
216 print '<div id="sb__index__tree">' . DOKU_LF;
87736cb removed wrong function from templateconfhelper branch
ai authored
217 print html_buildlist($data,'idx','html_list_index','html_li_index');
f1fb2c6 use enhanced AJAX index in sidebar
Michael Klier authored
218 print '</div>' . DOKU_LF;
6f00a41 enhanced sidebar index
Michael Klier authored
219 }
87736cb removed wrong function from templateconfhelper branch
ai authored
220
398a268 removed obsolete index formatting function
Michael Klier authored
221 // vim:ts=2:sw=2:enc=utf-8:
Something went wrong with that request. Please try again.