1 | <?php
|
---|
2 | /**
|
---|
3 | * HTML output functions
|
---|
4 | *
|
---|
5 | * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
---|
6 | * @author Andreas Gohr <[email protected]>
|
---|
7 | */
|
---|
8 |
|
---|
9 | if(!defined('DOKU_INC')) die('meh.');
|
---|
10 | if(!defined('NL')) define('NL',"\n");
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Convenience function to quickly build a wikilink
|
---|
14 | *
|
---|
15 | * @author Andreas Gohr <[email protected]>
|
---|
16 | */
|
---|
17 | function html_wikilink($id,$name=null,$search=''){
|
---|
18 | static $xhtml_renderer = null;
|
---|
19 | if(is_null($xhtml_renderer)){
|
---|
20 | $xhtml_renderer = p_get_renderer('xhtml');
|
---|
21 | }
|
---|
22 |
|
---|
23 | return $xhtml_renderer->internallink($id,$name,$search,true,'navigation');
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Helps building long attribute lists
|
---|
28 | *
|
---|
29 | * @deprecated Use buildAttributes instead
|
---|
30 | * @author Andreas Gohr <[email protected]>
|
---|
31 | */
|
---|
32 | function html_attbuild($attributes){
|
---|
33 | $ret = '';
|
---|
34 | foreach ( $attributes as $key => $value ) {
|
---|
35 | $ret .= $key.'="'.formText($value).'" ';
|
---|
36 | }
|
---|
37 | return trim($ret);
|
---|
38 | }
|
---|
39 |
|
---|
40 | /**
|
---|
41 | * The loginform
|
---|
42 | *
|
---|
43 | * @author Andreas Gohr <[email protected]>
|
---|
44 | */
|
---|
45 | function html_login(){
|
---|
46 | global $lang;
|
---|
47 | global $conf;
|
---|
48 | global $ID;
|
---|
49 |
|
---|
50 | print p_locale_xhtml('login');
|
---|
51 | print '<div class="centeralign">'.NL;
|
---|
52 | $form = new Doku_Form(array('id' => 'dw__login'));
|
---|
53 | $form->startFieldset($lang['btn_login']);
|
---|
54 | $form->addHidden('id', $ID);
|
---|
55 | $form->addHidden('do', 'login');
|
---|
56 | $form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block'));
|
---|
57 | $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block'));
|
---|
58 | if($conf['rememberme']) {
|
---|
59 | $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple'));
|
---|
60 | }
|
---|
61 | $form->addElement(form_makeButton('submit', '', $lang['btn_login']));
|
---|
62 | $form->endFieldset();
|
---|
63 |
|
---|
64 | if(actionOK('register')){
|
---|
65 | $form->addElement('<p>'.$lang['reghere'].': '.tpl_actionlink('register','','','',true).'</p>');
|
---|
66 | }
|
---|
67 |
|
---|
68 | if (actionOK('resendpwd')) {
|
---|
69 | $form->addElement('<p>'.$lang['pwdforget'].': '.tpl_actionlink('resendpwd','','','',true).'</p>');
|
---|
70 | }
|
---|
71 |
|
---|
72 | html_form('login', $form);
|
---|
73 | print '</div>'.NL;
|
---|
74 | }
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * inserts section edit buttons if wanted or removes the markers
|
---|
78 | *
|
---|
79 | * @author Andreas Gohr <[email protected]>
|
---|
80 | */
|
---|
81 | function html_secedit($text,$show=true){
|
---|
82 | global $INFO;
|
---|
83 |
|
---|
84 | $regexp = '#<!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->#';
|
---|
85 |
|
---|
86 | if(!$INFO['writable'] || !$show || $INFO['rev']){
|
---|
87 | return preg_replace($regexp,'',$text);
|
---|
88 | }
|
---|
89 |
|
---|
90 | return preg_replace_callback($regexp,
|
---|
91 | 'html_secedit_button', $text);
|
---|
92 | }
|
---|
93 |
|
---|
94 | /**
|
---|
95 | * prepares section edit button data for event triggering
|
---|
96 | * used as a callback in html_secedit
|
---|
97 | *
|
---|
98 | * @triggers HTML_SECEDIT_BUTTON
|
---|
99 | * @author Andreas Gohr <[email protected]>
|
---|
100 | */
|
---|
101 | function html_secedit_button($matches){
|
---|
102 | $data = array('secid' => $matches[1],
|
---|
103 | 'target' => strtolower($matches[2]),
|
---|
104 | 'range' => $matches[count($matches) - 1]);
|
---|
105 | if (count($matches) === 5) {
|
---|
106 | $data['name'] = $matches[3];
|
---|
107 | }
|
---|
108 |
|
---|
109 | return trigger_event('HTML_SECEDIT_BUTTON', $data,
|
---|
110 | 'html_secedit_get_button');
|
---|
111 | }
|
---|
112 |
|
---|
113 | /**
|
---|
114 | * prints a section editing button
|
---|
115 | * used as default action form HTML_SECEDIT_BUTTON
|
---|
116 | *
|
---|
117 | * @author Adrian Lang <[email protected]>
|
---|
118 | */
|
---|
119 | function html_secedit_get_button($data) {
|
---|
120 | global $ID;
|
---|
121 | global $INFO;
|
---|
122 |
|
---|
123 | if (!isset($data['name']) || $data['name'] === '') return;
|
---|
124 |
|
---|
125 | $name = $data['name'];
|
---|
126 | unset($data['name']);
|
---|
127 |
|
---|
128 | $secid = $data['secid'];
|
---|
129 | unset($data['secid']);
|
---|
130 |
|
---|
131 | return "<div class='secedit editbutton_" . $data['target'] .
|
---|
132 | " editbutton_" . $secid . "'>" .
|
---|
133 | html_btn('secedit', $ID, '',
|
---|
134 | array_merge(array('do' => 'edit',
|
---|
135 | 'rev' => $INFO['lastmod'],
|
---|
136 | 'summary' => '['.$name.'] '), $data),
|
---|
137 | 'post', $name) . '</div>';
|
---|
138 | }
|
---|
139 |
|
---|
140 | /**
|
---|
141 | * Just the back to top button (in its own form)
|
---|
142 | *
|
---|
143 | * @author Andreas Gohr <[email protected]>
|
---|
144 | */
|
---|
145 | function html_topbtn(){
|
---|
146 | global $lang;
|
---|
147 |
|
---|
148 | $ret = '';
|
---|
149 | $ret = '<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" title="'.$lang['btn_top'].'" /></a>';
|
---|
150 |
|
---|
151 | return $ret;
|
---|
152 | }
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Displays a button (using its own form)
|
---|
156 | * If tooltip exists, the access key tooltip is replaced.
|
---|
157 | *
|
---|
158 | * @author Andreas Gohr <[email protected]>
|
---|
159 | */
|
---|
160 | function html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false){
|
---|
161 | global $conf;
|
---|
162 | global $lang;
|
---|
163 |
|
---|
164 | if (!$label)
|
---|
165 | $label = $lang['btn_'.$name];
|
---|
166 |
|
---|
167 | $ret = '';
|
---|
168 | $tip = '';
|
---|
169 |
|
---|
170 | //filter id (without urlencoding)
|
---|
171 | $id = idfilter($id,false);
|
---|
172 |
|
---|
173 | //make nice URLs even for buttons
|
---|
174 | if($conf['userewrite'] == 2){
|
---|
175 | $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
|
---|
176 | }elseif($conf['userewrite']){
|
---|
177 | $script = DOKU_BASE.$id;
|
---|
178 | }else{
|
---|
179 | $script = DOKU_BASE.DOKU_SCRIPT;
|
---|
180 | $params['id'] = $id;
|
---|
181 | }
|
---|
182 |
|
---|
183 | $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">';
|
---|
184 |
|
---|
185 | if(is_array($params)){
|
---|
186 | reset($params);
|
---|
187 | while (list($key, $val) = each($params)) {
|
---|
188 | $ret .= '<input type="hidden" name="'.$key.'" ';
|
---|
189 | $ret .= 'value="'.htmlspecialchars($val).'" />';
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | if ($tooltip!='') {
|
---|
194 | $tip = htmlspecialchars($tooltip);
|
---|
195 | }else{
|
---|
196 | $tip = htmlspecialchars($label);
|
---|
197 | }
|
---|
198 |
|
---|
199 | $ret .= '<input type="submit" value="'.hsc($label).'" class="button" ';
|
---|
200 | if($akey){
|
---|
201 | $tip .= ' ['.strtoupper($akey).']';
|
---|
202 | $ret .= 'accesskey="'.$akey.'" ';
|
---|
203 | }
|
---|
204 | $ret .= 'title="'.$tip.'" ';
|
---|
205 | $ret .= '/>';
|
---|
206 | $ret .= '</div></form>';
|
---|
207 |
|
---|
208 | return $ret;
|
---|
209 | }
|
---|
210 |
|
---|
211 | /**
|
---|
212 | * show a wiki page
|
---|
213 | *
|
---|
214 | * @author Andreas Gohr <[email protected]>
|
---|
215 | */
|
---|
216 | function html_show($txt=null){
|
---|
217 | global $ID;
|
---|
218 | global $REV;
|
---|
219 | global $HIGH;
|
---|
220 | global $INFO;
|
---|
221 | //disable section editing for old revisions or in preview
|
---|
222 | if($txt || $REV){
|
---|
223 | $secedit = false;
|
---|
224 | }else{
|
---|
225 | $secedit = true;
|
---|
226 | }
|
---|
227 |
|
---|
228 | if (!is_null($txt)){
|
---|
229 | //PreviewHeader
|
---|
230 | echo '<br id="scroll__here" />';
|
---|
231 | echo p_locale_xhtml('preview');
|
---|
232 | echo '<div class="preview">';
|
---|
233 | $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
|
---|
234 | if($INFO['prependTOC']) $html = tpl_toc(true).$html;
|
---|
235 | echo $html;
|
---|
236 | echo '<div class="clearer"></div>';
|
---|
237 | echo '</div>';
|
---|
238 |
|
---|
239 | }else{
|
---|
240 | if ($REV) print p_locale_xhtml('showrev');
|
---|
241 | $html = p_wiki_xhtml($ID,$REV,true);
|
---|
242 | $html = html_secedit($html,$secedit);
|
---|
243 | if($INFO['prependTOC']) $html = tpl_toc(true).$html;
|
---|
244 | $html = html_hilight($html,$HIGH);
|
---|
245 | echo $html;
|
---|
246 | }
|
---|
247 | }
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * ask the user about how to handle an exisiting draft
|
---|
251 | *
|
---|
252 | * @author Andreas Gohr <[email protected]>
|
---|
253 | */
|
---|
254 | function html_draft(){
|
---|
255 | global $INFO;
|
---|
256 | global $ID;
|
---|
257 | global $lang;
|
---|
258 | global $conf;
|
---|
259 | $draft = unserialize(io_readFile($INFO['draft'],false));
|
---|
260 | $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true));
|
---|
261 |
|
---|
262 | print p_locale_xhtml('draft');
|
---|
263 | $form = new Doku_Form(array('id' => 'dw__editform'));
|
---|
264 | $form->addHidden('id', $ID);
|
---|
265 | $form->addHidden('date', $draft['date']);
|
---|
266 | $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly')));
|
---|
267 | $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status')));
|
---|
268 | $form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft'])));
|
---|
269 | $form->addElement(form_makeCloseTag('div'));
|
---|
270 | $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1')));
|
---|
271 | $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2')));
|
---|
272 | $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3')));
|
---|
273 | html_form('draft', $form);
|
---|
274 | }
|
---|
275 |
|
---|
276 | /**
|
---|
277 | * Highlights searchqueries in HTML code
|
---|
278 | *
|
---|
279 | * @author Andreas Gohr <[email protected]>
|
---|
280 | * @author Harry Fuecks <[email protected]>
|
---|
281 | */
|
---|
282 | function html_hilight($html,$phrases){
|
---|
283 | $phrases = array_filter((array) $phrases);
|
---|
284 | $regex = join('|',array_map('ft_snippet_re_preprocess', array_map('preg_quote_cb',$phrases)));
|
---|
285 |
|
---|
286 | if ($regex === '') return $html;
|
---|
287 | if (!utf8_check($regex)) return $html;
|
---|
288 | $html = @preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html);
|
---|
289 | return $html;
|
---|
290 | }
|
---|
291 |
|
---|
292 | /**
|
---|
293 | * Callback used by html_hilight()
|
---|
294 | *
|
---|
295 | * @author Harry Fuecks <[email protected]>
|
---|
296 | */
|
---|
297 | function html_hilight_callback($m) {
|
---|
298 | $hlight = unslash($m[0]);
|
---|
299 | if ( !isset($m[2])) {
|
---|
300 | $hlight = '<span class="search_hit">'.$hlight.'</span>';
|
---|
301 | }
|
---|
302 | return $hlight;
|
---|
303 | }
|
---|
304 |
|
---|
305 | /**
|
---|
306 | * Run a search and display the result
|
---|
307 | *
|
---|
308 | * @author Andreas Gohr <[email protected]>
|
---|
309 | */
|
---|
310 | function html_search(){
|
---|
311 | global $conf;
|
---|
312 | global $QUERY;
|
---|
313 | global $ID;
|
---|
314 | global $lang;
|
---|
315 |
|
---|
316 | $intro = p_locale_xhtml('searchpage');
|
---|
317 | // allow use of placeholder in search intro
|
---|
318 | $intro = str_replace(
|
---|
319 | array('@QUERY@','@SEARCH@'),
|
---|
320 | array(hsc(rawurlencode($QUERY)),hsc($QUERY)),
|
---|
321 | $intro);
|
---|
322 | echo $intro;
|
---|
323 | flush();
|
---|
324 |
|
---|
325 | //show progressbar
|
---|
326 | print '<div class="centeralign" id="dw__loading">'.NL;
|
---|
327 | print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
|
---|
328 | print 'showLoadBar();'.NL;
|
---|
329 | print '//--><!]]></script>'.NL;
|
---|
330 | print '<br /></div>'.NL;
|
---|
331 | flush();
|
---|
332 |
|
---|
333 | //do quick pagesearch
|
---|
334 | $data = array();
|
---|
335 |
|
---|
336 | $data = ft_pageLookup($QUERY,true,useHeading('navigation'));
|
---|
337 | if(count($data)){
|
---|
338 | print '<div class="search_quickresult">';
|
---|
339 | print '<h3>'.$lang['quickhits'].':</h3>';
|
---|
340 | print '<ul class="search_quickhits">';
|
---|
341 | foreach($data as $id => $title){
|
---|
342 | print '<li> ';
|
---|
343 | if (useHeading('navigation')) {
|
---|
344 | $name = $title;
|
---|
345 | }else{
|
---|
346 | $ns = getNS($id);
|
---|
347 | if($ns){
|
---|
348 | $name = shorten(noNS($id), ' ('.$ns.')',30);
|
---|
349 | }else{
|
---|
350 | $name = $id;
|
---|
351 | }
|
---|
352 | }
|
---|
353 | print html_wikilink(':'.$id,$name);
|
---|
354 | print '</li> ';
|
---|
355 | }
|
---|
356 | print '</ul> ';
|
---|
357 | //clear float (see http://www.complexspiral.com/publications/containing-floats/)
|
---|
358 | print '<div class="clearer"></div>';
|
---|
359 | print '</div>';
|
---|
360 | }
|
---|
361 | flush();
|
---|
362 |
|
---|
363 | //do fulltext search
|
---|
364 | $data = ft_pageSearch($QUERY,$regex);
|
---|
365 | if(count($data)){
|
---|
366 | $num = 1;
|
---|
367 | foreach($data as $id => $cnt){
|
---|
368 | print '<div class="search_result">';
|
---|
369 | print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex);
|
---|
370 | if($cnt !== 0){
|
---|
371 | print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
|
---|
372 | if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only
|
---|
373 | print '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>';
|
---|
374 | }
|
---|
375 | $num++;
|
---|
376 | }
|
---|
377 | print '</div>';
|
---|
378 | flush();
|
---|
379 | }
|
---|
380 | }else{
|
---|
381 | print '<div class="nothing">'.$lang['nothingfound'].'</div>';
|
---|
382 | }
|
---|
383 |
|
---|
384 | //hide progressbar
|
---|
385 | print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
|
---|
386 | print 'hideLoadBar("dw__loading");'.NL;
|
---|
387 | print '//--><!]]></script>'.NL;
|
---|
388 | flush();
|
---|
389 | }
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Display error on locked pages
|
---|
393 | *
|
---|
394 | * @author Andreas Gohr <[email protected]>
|
---|
395 | */
|
---|
396 | function html_locked(){
|
---|
397 | global $ID;
|
---|
398 | global $conf;
|
---|
399 | global $lang;
|
---|
400 | global $INFO;
|
---|
401 |
|
---|
402 | $locktime = filemtime(wikiLockFN($ID));
|
---|
403 | $expire = dformat($locktime + $conf['locktime']);
|
---|
404 | $min = round(($conf['locktime'] - (time() - $locktime) )/60);
|
---|
405 |
|
---|
406 | print p_locale_xhtml('locked');
|
---|
407 | print '<ul>';
|
---|
408 | print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.editorinfo($INFO['locked']).'</div></li>';
|
---|
409 | print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>';
|
---|
410 | print '</ul>';
|
---|
411 | }
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * list old revisions
|
---|
415 | *
|
---|
416 | * @author Andreas Gohr <[email protected]>
|
---|
417 | * @author Ben Coburn <[email protected]>
|
---|
418 | */
|
---|
419 | function html_revisions($first=0){
|
---|
420 | global $ID;
|
---|
421 | global $INFO;
|
---|
422 | global $conf;
|
---|
423 | global $lang;
|
---|
424 | /* we need to get one additionally log entry to be able to
|
---|
425 | * decide if this is the last page or is there another one.
|
---|
426 | * see html_recent()
|
---|
427 | */
|
---|
428 | $revisions = getRevisions($ID, $first, $conf['recent']+1);
|
---|
429 | if(count($revisions)==0 && $first!=0){
|
---|
430 | $first=0;
|
---|
431 | $revisions = getRevisions($ID, $first, $conf['recent']+1);;
|
---|
432 | }
|
---|
433 | $hasNext = false;
|
---|
434 | if (count($revisions)>$conf['recent']) {
|
---|
435 | $hasNext = true;
|
---|
436 | array_pop($revisions); // remove extra log entry
|
---|
437 | }
|
---|
438 |
|
---|
439 | $date = dformat($INFO['lastmod']);
|
---|
440 |
|
---|
441 | print p_locale_xhtml('revisions');
|
---|
442 |
|
---|
443 | $form = new Doku_Form(array('id' => 'page__revisions'));
|
---|
444 | $form->addElement(form_makeOpenTag('ul'));
|
---|
445 | if($INFO['exists'] && $first==0){
|
---|
446 | if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
|
---|
447 | $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
|
---|
448 | else
|
---|
449 | $form->addElement(form_makeOpenTag('li'));
|
---|
450 | $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
|
---|
451 | $form->addElement(form_makeTag('input', array(
|
---|
452 | 'type' => 'checkbox',
|
---|
453 | 'name' => 'rev2[]',
|
---|
454 | 'value' => 'current')));
|
---|
455 |
|
---|
456 | $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
|
---|
457 | $form->addElement($date);
|
---|
458 | $form->addElement(form_makeCloseTag('span'));
|
---|
459 |
|
---|
460 | $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
|
---|
461 |
|
---|
462 | $form->addElement(form_makeOpenTag('a', array(
|
---|
463 | 'class' => 'wikilink1',
|
---|
464 | 'href' => wl($ID))));
|
---|
465 | $form->addElement($ID);
|
---|
466 | $form->addElement(form_makeCloseTag('a'));
|
---|
467 |
|
---|
468 | $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
|
---|
469 | $form->addElement(' – ');
|
---|
470 | $form->addElement(htmlspecialchars($INFO['sum']));
|
---|
471 | $form->addElement(form_makeCloseTag('span'));
|
---|
472 |
|
---|
473 | $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
|
---|
474 | $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor']));
|
---|
475 | $form->addElement(form_makeCloseTag('span'));
|
---|
476 |
|
---|
477 | $form->addElement('('.$lang['current'].')');
|
---|
478 | $form->addElement(form_makeCloseTag('div'));
|
---|
479 | $form->addElement(form_makeCloseTag('li'));
|
---|
480 | }
|
---|
481 |
|
---|
482 | foreach($revisions as $rev){
|
---|
483 | $date = dformat($rev);
|
---|
484 | $info = getRevisionInfo($ID,$rev,true);
|
---|
485 | $exists = page_exists($ID,$rev);
|
---|
486 |
|
---|
487 | if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
|
---|
488 | $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
|
---|
489 | else
|
---|
490 | $form->addElement(form_makeOpenTag('li'));
|
---|
491 | $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
|
---|
492 | if($exists){
|
---|
493 | $form->addElement(form_makeTag('input', array(
|
---|
494 | 'type' => 'checkbox',
|
---|
495 | 'name' => 'rev2[]',
|
---|
496 | 'value' => $rev)));
|
---|
497 | }else{
|
---|
498 | $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
|
---|
499 | }
|
---|
500 |
|
---|
501 | $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
|
---|
502 | $form->addElement($date);
|
---|
503 | $form->addElement(form_makeCloseTag('span'));
|
---|
504 |
|
---|
505 | if($exists){
|
---|
506 | $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link')));
|
---|
507 | $form->addElement(form_makeTag('img', array(
|
---|
508 | 'src' => DOKU_BASE.'lib/images/diff.png',
|
---|
509 | 'width' => 15,
|
---|
510 | 'height' => 11,
|
---|
511 | 'title' => $lang['diff'],
|
---|
512 | 'alt' => $lang['diff'])));
|
---|
513 | $form->addElement(form_makeCloseTag('a'));
|
---|
514 |
|
---|
515 | $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1')));
|
---|
516 | $form->addElement($ID);
|
---|
517 | $form->addElement(form_makeCloseTag('a'));
|
---|
518 | }else{
|
---|
519 | $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
|
---|
520 | $form->addElement($ID);
|
---|
521 | }
|
---|
522 |
|
---|
523 | $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
|
---|
524 | $form->addElement(' – ');
|
---|
525 | $form->addElement(htmlspecialchars($info['sum']));
|
---|
526 | $form->addElement(form_makeCloseTag('span'));
|
---|
527 |
|
---|
528 | $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
|
---|
529 | if($info['user']){
|
---|
530 | $form->addElement(editorinfo($info['user']));
|
---|
531 | if(auth_ismanager()){
|
---|
532 | $form->addElement(' ('.$info['ip'].')');
|
---|
533 | }
|
---|
534 | }else{
|
---|
535 | $form->addElement($info['ip']);
|
---|
536 | }
|
---|
537 | $form->addElement(form_makeCloseTag('span'));
|
---|
538 |
|
---|
539 | $form->addElement(form_makeCloseTag('div'));
|
---|
540 | $form->addElement(form_makeCloseTag('li'));
|
---|
541 | }
|
---|
542 | $form->addElement(form_makeCloseTag('ul'));
|
---|
543 | $form->addElement(form_makeButton('submit', 'diff', $lang['diff2']));
|
---|
544 | html_form('revisions', $form);
|
---|
545 |
|
---|
546 | print '<div class="pagenav">';
|
---|
547 | $last = $first + $conf['recent'];
|
---|
548 | if ($first > 0) {
|
---|
549 | $first -= $conf['recent'];
|
---|
550 | if ($first < 0) $first = 0;
|
---|
551 | print '<div class="pagenav-prev">';
|
---|
552 | print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first));
|
---|
553 | print '</div>';
|
---|
554 | }
|
---|
555 | if ($hasNext) {
|
---|
556 | print '<div class="pagenav-next">';
|
---|
557 | print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last));
|
---|
558 | print '</div>';
|
---|
559 | }
|
---|
560 | print '</div>';
|
---|
561 |
|
---|
562 | }
|
---|
563 |
|
---|
564 | /**
|
---|
565 | * display recent changes
|
---|
566 | *
|
---|
567 | * @author Andreas Gohr <[email protected]>
|
---|
568 | * @author Matthias Grimm <[email protected]>
|
---|
569 | * @author Ben Coburn <[email protected]>
|
---|
570 | */
|
---|
571 | function html_recent($first=0){
|
---|
572 | global $conf;
|
---|
573 | global $lang;
|
---|
574 | global $ID;
|
---|
575 | /* we need to get one additionally log entry to be able to
|
---|
576 | * decide if this is the last page or is there another one.
|
---|
577 | * This is the cheapest solution to get this information.
|
---|
578 | */
|
---|
579 | $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
|
---|
580 | if(count($recents) == 0 && $first != 0){
|
---|
581 | $first=0;
|
---|
582 | $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
|
---|
583 | }
|
---|
584 | $hasNext = false;
|
---|
585 | if (count($recents)>$conf['recent']) {
|
---|
586 | $hasNext = true;
|
---|
587 | array_pop($recents); // remove extra log entry
|
---|
588 | }
|
---|
589 |
|
---|
590 | print p_locale_xhtml('recent');
|
---|
591 |
|
---|
592 | if (getNS($ID) != '')
|
---|
593 | print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>';
|
---|
594 |
|
---|
595 | $form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET'));
|
---|
596 | $form->addHidden('sectok', null);
|
---|
597 | $form->addHidden('do', 'recent');
|
---|
598 | $form->addHidden('id', $ID);
|
---|
599 | $form->addElement(form_makeOpenTag('ul'));
|
---|
600 |
|
---|
601 | foreach($recents as $recent){
|
---|
602 | $date = dformat($recent['date']);
|
---|
603 | if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
|
---|
604 | $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
|
---|
605 | else
|
---|
606 | $form->addElement(form_makeOpenTag('li'));
|
---|
607 |
|
---|
608 | $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
|
---|
609 |
|
---|
610 | $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
|
---|
611 | $form->addElement($date);
|
---|
612 | $form->addElement(form_makeCloseTag('span'));
|
---|
613 |
|
---|
614 | $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => wl($recent['id'],"do=diff", false, '&'))));
|
---|
615 | $form->addElement(form_makeTag('img', array(
|
---|
616 | 'src' => DOKU_BASE.'lib/images/diff.png',
|
---|
617 | 'width' => 15,
|
---|
618 | 'height'=> 11,
|
---|
619 | 'title' => $lang['diff'],
|
---|
620 | 'alt' => $lang['diff']
|
---|
621 | )));
|
---|
622 | $form->addElement(form_makeCloseTag('a'));
|
---|
623 |
|
---|
624 | $form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => wl($recent['id'],"do=revisions",false,'&'))));
|
---|
625 | $form->addElement(form_makeTag('img', array(
|
---|
626 | 'src' => DOKU_BASE.'lib/images/history.png',
|
---|
627 | 'width' => 12,
|
---|
628 | 'height'=> 14,
|
---|
629 | 'title' => $lang['btn_revs'],
|
---|
630 | 'alt' => $lang['btn_revs']
|
---|
631 | )));
|
---|
632 | $form->addElement(form_makeCloseTag('a'));
|
---|
633 |
|
---|
634 | $form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?null:$recent['id']));
|
---|
635 |
|
---|
636 | $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
|
---|
637 | $form->addElement(' – '.htmlspecialchars($recent['sum']));
|
---|
638 | $form->addElement(form_makeCloseTag('span'));
|
---|
639 |
|
---|
640 | $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
|
---|
641 | if($recent['user']){
|
---|
642 | $form->addElement(editorinfo($recent['user']));
|
---|
643 | if(auth_ismanager()){
|
---|
644 | $form->addElement(' ('.$recent['ip'].')');
|
---|
645 | }
|
---|
646 | }else{
|
---|
647 | $form->addElement($recent['ip']);
|
---|
648 | }
|
---|
649 | $form->addElement(form_makeCloseTag('span'));
|
---|
650 |
|
---|
651 | $form->addElement(form_makeCloseTag('div'));
|
---|
652 | $form->addElement(form_makeCloseTag('li'));
|
---|
653 | }
|
---|
654 | $form->addElement(form_makeCloseTag('ul'));
|
---|
655 |
|
---|
656 | $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav')));
|
---|
657 | $last = $first + $conf['recent'];
|
---|
658 | if ($first > 0) {
|
---|
659 | $first -= $conf['recent'];
|
---|
660 | if ($first < 0) $first = 0;
|
---|
661 | $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev')));
|
---|
662 | $form->addElement(form_makeTag('input', array(
|
---|
663 | 'type' => 'submit',
|
---|
664 | 'name' => 'first['.$first.']',
|
---|
665 | 'value' => $lang['btn_newer'],
|
---|
666 | 'accesskey' => 'n',
|
---|
667 | 'title' => $lang['btn_newer'].' [N]',
|
---|
668 | 'class' => 'button'
|
---|
669 | )));
|
---|
670 | $form->addElement(form_makeCloseTag('div'));
|
---|
671 | }
|
---|
672 | if ($hasNext) {
|
---|
673 | $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next')));
|
---|
674 | $form->addElement(form_makeTag('input', array(
|
---|
675 | 'type' => 'submit',
|
---|
676 | 'name' => 'first['.$last.']',
|
---|
677 | 'value' => $lang['btn_older'],
|
---|
678 | 'accesskey' => 'p',
|
---|
679 | 'title' => $lang['btn_older'].' [P]',
|
---|
680 | 'class' => 'button'
|
---|
681 | )));
|
---|
682 | $form->addElement(form_makeCloseTag('div'));
|
---|
683 | }
|
---|
684 | $form->addElement(form_makeCloseTag('div'));
|
---|
685 | html_form('recent', $form);
|
---|
686 | }
|
---|
687 |
|
---|
688 | /**
|
---|
689 | * Display page index
|
---|
690 | *
|
---|
691 | * @author Andreas Gohr <[email protected]>
|
---|
692 | */
|
---|
693 | function html_index($ns){
|
---|
694 | global $conf;
|
---|
695 | global $ID;
|
---|
696 | $dir = $conf['datadir'];
|
---|
697 | $ns = cleanID($ns);
|
---|
698 | #fixme use appropriate function
|
---|
699 | if(empty($ns)){
|
---|
700 | $ns = dirname(str_replace(':','/',$ID));
|
---|
701 | if($ns == '.') $ns ='';
|
---|
702 | }
|
---|
703 | $ns = utf8_encodeFN(str_replace(':','/',$ns));
|
---|
704 |
|
---|
705 | echo p_locale_xhtml('index');
|
---|
706 | echo '<div id="index__tree">';
|
---|
707 |
|
---|
708 | $data = array();
|
---|
709 | search($data,$conf['datadir'],'search_index',array('ns' => $ns));
|
---|
710 | echo html_buildlist($data,'idx','html_list_index','html_li_index');
|
---|
711 |
|
---|
712 | echo '</div>';
|
---|
713 | }
|
---|
714 |
|
---|
715 | /**
|
---|
716 | * Index item formatter
|
---|
717 | *
|
---|
718 | * User function for html_buildlist()
|
---|
719 | *
|
---|
720 | * @author Andreas Gohr <[email protected]>
|
---|
721 | */
|
---|
722 | function html_list_index($item){
|
---|
723 | global $ID;
|
---|
724 | $ret = '';
|
---|
725 | $base = ':'.$item['id'];
|
---|
726 | $base = substr($base,strrpos($base,':')+1);
|
---|
727 | if($item['type']=='d'){
|
---|
728 | $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>';
|
---|
729 | $ret .= $base;
|
---|
730 | $ret .= '</strong></a>';
|
---|
731 | }else{
|
---|
732 | $ret .= html_wikilink(':'.$item['id']);
|
---|
733 | }
|
---|
734 | return $ret;
|
---|
735 | }
|
---|
736 |
|
---|
737 | /**
|
---|
738 | * Index List item
|
---|
739 | *
|
---|
740 | * This user function is used in html_build_lidt to build the
|
---|
741 | * <li> tags for namespaces when displaying the page index
|
---|
742 | * it gives different classes to opened or closed "folders"
|
---|
743 | *
|
---|
744 | * @author Andreas Gohr <[email protected]>
|
---|
745 | */
|
---|
746 | function html_li_index($item){
|
---|
747 | if($item['type'] == "f"){
|
---|
748 | return '<li class="level'.$item['level'].'">';
|
---|
749 | }elseif($item['open']){
|
---|
750 | return '<li class="open">';
|
---|
751 | }else{
|
---|
752 | return '<li class="closed">';
|
---|
753 | }
|
---|
754 | }
|
---|
755 |
|
---|
756 | /**
|
---|
757 | * Default List item
|
---|
758 | *
|
---|
759 | * @author Andreas Gohr <[email protected]>
|
---|
760 | */
|
---|
761 | function html_li_default($item){
|
---|
762 | return '<li class="level'.$item['level'].'">';
|
---|
763 | }
|
---|
764 |
|
---|
765 | /**
|
---|
766 | * Build an unordered list
|
---|
767 | *
|
---|
768 | * Build an unordered list from the given $data array
|
---|
769 | * Each item in the array has to have a 'level' property
|
---|
770 | * the item itself gets printed by the given $func user
|
---|
771 | * function. The second and optional function is used to
|
---|
772 | * print the <li> tag. Both user function need to accept
|
---|
773 | * a single item.
|
---|
774 | *
|
---|
775 | * Both user functions can be given as array to point to
|
---|
776 | * a member of an object.
|
---|
777 | *
|
---|
778 | * @author Andreas Gohr <[email protected]>
|
---|
779 | */
|
---|
780 | function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
|
---|
781 | $level = 0;
|
---|
782 | $opens = 0;
|
---|
783 | $ret = '';
|
---|
784 |
|
---|
785 | foreach ($data as $item){
|
---|
786 |
|
---|
787 | if( $item['level'] > $level ){
|
---|
788 | //open new list
|
---|
789 | for($i=0; $i<($item['level'] - $level); $i++){
|
---|
790 | if ($i) $ret .= "<li class=\"clear\">\n";
|
---|
791 | $ret .= "\n<ul class=\"$class\">\n";
|
---|
792 | }
|
---|
793 | }elseif( $item['level'] < $level ){
|
---|
794 | //close last item
|
---|
795 | $ret .= "</li>\n";
|
---|
796 | for ($i=0; $i<($level - $item['level']); $i++){
|
---|
797 | //close higher lists
|
---|
798 | $ret .= "</ul>\n</li>\n";
|
---|
799 | }
|
---|
800 | }else{
|
---|
801 | //close last item
|
---|
802 | $ret .= "</li>\n";
|
---|
803 | }
|
---|
804 |
|
---|
805 | //remember current level
|
---|
806 | $level = $item['level'];
|
---|
807 |
|
---|
808 | //print item
|
---|
809 | $ret .= call_user_func($lifunc,$item);
|
---|
810 | $ret .= '<div class="li">';
|
---|
811 |
|
---|
812 | $ret .= call_user_func($func,$item);
|
---|
813 | $ret .= '</div>';
|
---|
814 | }
|
---|
815 |
|
---|
816 | //close remaining items and lists
|
---|
817 | for ($i=0; $i < $level; $i++){
|
---|
818 | $ret .= "</li></ul>\n";
|
---|
819 | }
|
---|
820 |
|
---|
821 | return $ret;
|
---|
822 | }
|
---|
823 |
|
---|
824 | /**
|
---|
825 | * display backlinks
|
---|
826 | *
|
---|
827 | * @author Andreas Gohr <[email protected]>
|
---|
828 | * @author Michael Klier <[email protected]>
|
---|
829 | */
|
---|
830 | function html_backlinks(){
|
---|
831 | global $ID;
|
---|
832 | global $conf;
|
---|
833 | global $lang;
|
---|
834 |
|
---|
835 | print p_locale_xhtml('backlinks');
|
---|
836 |
|
---|
837 | $data = ft_backlinks($ID);
|
---|
838 |
|
---|
839 | if(!empty($data)) {
|
---|
840 | print '<ul class="idx">';
|
---|
841 | foreach($data as $blink){
|
---|
842 | print '<li><div class="li">';
|
---|
843 | print html_wikilink(':'.$blink,useHeading('navigation')?null:$blink);
|
---|
844 | print '</div></li>';
|
---|
845 | }
|
---|
846 | print '</ul>';
|
---|
847 | } else {
|
---|
848 | print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>';
|
---|
849 | }
|
---|
850 | }
|
---|
851 |
|
---|
852 | /**
|
---|
853 | * show diff
|
---|
854 | *
|
---|
855 | * @author Andreas Gohr <[email protected]>
|
---|
856 | * @param string $text - compare with this text with most current version
|
---|
857 | * @param bool $intr - display the intro text
|
---|
858 | */
|
---|
859 | function html_diff($text='',$intro=true,$type=null){
|
---|
860 | global $ID;
|
---|
861 | global $REV;
|
---|
862 | global $lang;
|
---|
863 | global $conf;
|
---|
864 |
|
---|
865 | if(!$type) $type = $_REQUEST['difftype'];
|
---|
866 | if($type != 'inline') $type = 'sidebyside';
|
---|
867 |
|
---|
868 | // we're trying to be clever here, revisions to compare can be either
|
---|
869 | // given as rev and rev2 parameters, with rev2 being optional. Or in an
|
---|
870 | // array in rev2.
|
---|
871 | $rev1 = $REV;
|
---|
872 |
|
---|
873 | if(is_array($_REQUEST['rev2'])){
|
---|
874 | $rev1 = (int) $_REQUEST['rev2'][0];
|
---|
875 | $rev2 = (int) $_REQUEST['rev2'][1];
|
---|
876 |
|
---|
877 | if(!$rev1){
|
---|
878 | $rev1 = $rev2;
|
---|
879 | unset($rev2);
|
---|
880 | }
|
---|
881 | }else{
|
---|
882 | $rev2 = (int) $_REQUEST['rev2'];
|
---|
883 | }
|
---|
884 |
|
---|
885 | $r_minor = '';
|
---|
886 | $l_minor = '';
|
---|
887 |
|
---|
888 | if($text){ // compare text to the most current revision
|
---|
889 | $l_rev = '';
|
---|
890 | $l_text = rawWiki($ID,'');
|
---|
891 | $l_head = '<a class="wikilink1" href="'.wl($ID).'">'.
|
---|
892 | $ID.' '.dformat((int) @filemtime(wikiFN($ID))).'</a> '.
|
---|
893 | $lang['current'];
|
---|
894 |
|
---|
895 | $r_rev = '';
|
---|
896 | $r_text = cleanText($text);
|
---|
897 | $r_head = $lang['yours'];
|
---|
898 | }else{
|
---|
899 | if($rev1 && $rev2){ // two specific revisions wanted
|
---|
900 | // make sure order is correct (older on the left)
|
---|
901 | if($rev1 < $rev2){
|
---|
902 | $l_rev = $rev1;
|
---|
903 | $r_rev = $rev2;
|
---|
904 | }else{
|
---|
905 | $l_rev = $rev2;
|
---|
906 | $r_rev = $rev1;
|
---|
907 | }
|
---|
908 | }elseif($rev1){ // single revision given, compare to current
|
---|
909 | $r_rev = '';
|
---|
910 | $l_rev = $rev1;
|
---|
911 | }else{ // no revision was given, compare previous to current
|
---|
912 | $r_rev = '';
|
---|
913 | $revs = getRevisions($ID, 0, 1);
|
---|
914 | $l_rev = $revs[0];
|
---|
915 | $REV = $l_rev; // store revision back in $REV
|
---|
916 | }
|
---|
917 |
|
---|
918 | // when both revisions are empty then the page was created just now
|
---|
919 | if(!$l_rev && !$r_rev){
|
---|
920 | $l_text = '';
|
---|
921 | }else{
|
---|
922 | $l_text = rawWiki($ID,$l_rev);
|
---|
923 | }
|
---|
924 | $r_text = rawWiki($ID,$r_rev);
|
---|
925 |
|
---|
926 | if(!$l_rev){
|
---|
927 | $l_head = '—';
|
---|
928 | }else{
|
---|
929 | $l_info = getRevisionInfo($ID,$l_rev,true);
|
---|
930 | if($l_info['user']){
|
---|
931 | $l_user = editorinfo($l_info['user']);
|
---|
932 | if(auth_ismanager()) $l_user .= ' ('.$l_info['ip'].')';
|
---|
933 | } else {
|
---|
934 | $l_user = $l_info['ip'];
|
---|
935 | }
|
---|
936 | $l_user = '<span class="user">'.$l_user.'</span>';
|
---|
937 | $l_sum = ($l_info['sum']) ? '<span class="sum">'.hsc($l_info['sum']).'</span>' : '';
|
---|
938 | if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $l_minor = 'class="minor"';
|
---|
939 |
|
---|
940 | $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'.
|
---|
941 | $ID.' ['.dformat($l_rev).']</a>'.
|
---|
942 | '<br />'.$l_user.' '.$l_sum;
|
---|
943 | }
|
---|
944 |
|
---|
945 | if($r_rev){
|
---|
946 | $r_info = getRevisionInfo($ID,$r_rev,true);
|
---|
947 | if($r_info['user']){
|
---|
948 | $r_user = editorinfo($r_info['user']);
|
---|
949 | if(auth_ismanager()) $r_user .= ' ('.$r_info['ip'].')';
|
---|
950 | } else {
|
---|
951 | $r_user = $r_info['ip'];
|
---|
952 | }
|
---|
953 | $r_user = '<span class="user">'.$r_user.'</span>';
|
---|
954 | $r_sum = ($r_info['sum']) ? '<span class="sum">'.hsc($r_info['sum']).'</span>' : '';
|
---|
955 | if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"';
|
---|
956 |
|
---|
957 | $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'.
|
---|
958 | $ID.' ['.dformat($r_rev).']</a>'.
|
---|
959 | '<br />'.$r_user.' '.$r_sum;
|
---|
960 | }elseif($_rev = @filemtime(wikiFN($ID))){
|
---|
961 | $_info = getRevisionInfo($ID,$_rev,true);
|
---|
962 | if($_info['user']){
|
---|
963 | $_user = editorinfo($_info['user']);
|
---|
964 | if(auth_ismanager()) $_user .= ' ('.$_info['ip'].')';
|
---|
965 | } else {
|
---|
966 | $_user = $_info['ip'];
|
---|
967 | }
|
---|
968 | $_user = '<span class="user">'.$_user.'</span>';
|
---|
969 | $_sum = ($_info['sum']) ? '<span class="sum">'.hsc($_info['sum']).'</span>' : '';
|
---|
970 | if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"';
|
---|
971 |
|
---|
972 | $r_head = '<a class="wikilink1" href="'.wl($ID).'">'.
|
---|
973 | $ID.' ['.dformat($_rev).']</a> '.
|
---|
974 | '('.$lang['current'].')'.
|
---|
975 | '<br />'.$_user.' '.$_sum;
|
---|
976 | }else{
|
---|
977 | $r_head = '— ('.$lang['current'].')';
|
---|
978 | }
|
---|
979 | }
|
---|
980 |
|
---|
981 | $df = new Diff(explode("\n",htmlspecialchars($l_text)),
|
---|
982 | explode("\n",htmlspecialchars($r_text)));
|
---|
983 |
|
---|
984 | if($type == 'inline'){
|
---|
985 | $tdf = new InlineDiffFormatter();
|
---|
986 | } else {
|
---|
987 | $tdf = new TableDiffFormatter();
|
---|
988 | }
|
---|
989 |
|
---|
990 |
|
---|
991 |
|
---|
992 | if($intro) print p_locale_xhtml('diff');
|
---|
993 |
|
---|
994 | if (!$text) {
|
---|
995 | ptln('<div class="diffoptions">');
|
---|
996 |
|
---|
997 | $form = new Doku_Form(array('action'=>wl()));
|
---|
998 | $form->addHidden('id',$ID);
|
---|
999 | $form->addHidden('rev2[0]',$l_rev);
|
---|
1000 | $form->addHidden('rev2[1]',$r_rev);
|
---|
1001 | $form->addHidden('do','diff');
|
---|
1002 | $form->addElement(form_makeListboxField(
|
---|
1003 | 'difftype',
|
---|
1004 | array(
|
---|
1005 | 'sidebyside' => $lang['diff_side'],
|
---|
1006 | 'inline' => $lang['diff_inline']),
|
---|
1007 | $type,
|
---|
1008 | $lang['diff_type'],
|
---|
1009 | '','',
|
---|
1010 | array('class'=>'quickselect')));
|
---|
1011 | $form->addElement(form_makeButton('submit', 'diff','Go'));
|
---|
1012 | $form->printForm();
|
---|
1013 |
|
---|
1014 |
|
---|
1015 | $diffurl = wl($ID, array(
|
---|
1016 | 'do' => 'diff',
|
---|
1017 | 'rev2[0]' => $l_rev,
|
---|
1018 | 'rev2[1]' => $r_rev,
|
---|
1019 | 'difftype' => $type,
|
---|
1020 | ));
|
---|
1021 | ptln('<p><a class="wikilink1" href="'.$diffurl.'">'.$lang['difflink'].'</a></p>');
|
---|
1022 | ptln('</div>');
|
---|
1023 | }
|
---|
1024 | ?>
|
---|
1025 | <table class="diff diff_<?php echo $type?>">
|
---|
1026 | <tr>
|
---|
1027 | <th colspan="2" <?php echo $l_minor?>>
|
---|
1028 | <?php echo $l_head?>
|
---|
1029 | </th>
|
---|
1030 | <th colspan="2" <?php echo $r_minor?>>
|
---|
1031 | <?php echo $r_head?>
|
---|
1032 | </th>
|
---|
1033 | </tr>
|
---|
1034 | <?php echo $tdf->format($df)?>
|
---|
1035 | </table>
|
---|
1036 | <?php
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | /**
|
---|
1040 | * show warning on conflict detection
|
---|
1041 | *
|
---|
1042 | * @author Andreas Gohr <[email protected]>
|
---|
1043 | */
|
---|
1044 | function html_conflict($text,$summary){
|
---|
1045 | global $ID;
|
---|
1046 | global $lang;
|
---|
1047 |
|
---|
1048 | print p_locale_xhtml('conflict');
|
---|
1049 | $form = new Doku_Form(array('id' => 'dw__editform'));
|
---|
1050 | $form->addHidden('id', $ID);
|
---|
1051 | $form->addHidden('wikitext', $text);
|
---|
1052 | $form->addHidden('summary', $summary);
|
---|
1053 | $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s')));
|
---|
1054 | $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel']));
|
---|
1055 | html_form('conflict', $form);
|
---|
1056 | print '<br /><br /><br /><br />'.NL;
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | /**
|
---|
1060 | * Prints the global message array
|
---|
1061 | *
|
---|
1062 | * @author Andreas Gohr <[email protected]>
|
---|
1063 | */
|
---|
1064 | function html_msgarea(){
|
---|
1065 | global $MSG, $MSG_shown;
|
---|
1066 | // store if the global $MSG has already been shown and thus HTML output has been started
|
---|
1067 | $MSG_shown = true;
|
---|
1068 |
|
---|
1069 | if(!isset($MSG)) return;
|
---|
1070 |
|
---|
1071 | $shown = array();
|
---|
1072 | foreach($MSG as $msg){
|
---|
1073 | $hash = md5($msg['msg']);
|
---|
1074 | if(isset($shown[$hash])) continue; // skip double messages
|
---|
1075 | print '<div class="'.$msg['lvl'].'">';
|
---|
1076 | print $msg['msg'];
|
---|
1077 | print '</div>';
|
---|
1078 | $shown[$hash] = 1;
|
---|
1079 | }
|
---|
1080 |
|
---|
1081 | unset($GLOBALS['MSG']);
|
---|
1082 | }
|
---|
1083 |
|
---|
1084 | /**
|
---|
1085 | * Prints the registration form
|
---|
1086 | *
|
---|
1087 | * @author Andreas Gohr <[email protected]>
|
---|
1088 | */
|
---|
1089 | function html_register(){
|
---|
1090 | global $lang;
|
---|
1091 | global $conf;
|
---|
1092 | global $ID;
|
---|
1093 |
|
---|
1094 | print p_locale_xhtml('register');
|
---|
1095 | print '<div class="centeralign">'.NL;
|
---|
1096 | $form = new Doku_Form(array('id' => 'dw__register'));
|
---|
1097 | $form->startFieldset($lang['btn_register']);
|
---|
1098 | $form->addHidden('do', 'register');
|
---|
1099 | $form->addHidden('save', '1');
|
---|
1100 | $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block', array('size'=>'50')));
|
---|
1101 | if (!$conf['autopasswd']) {
|
---|
1102 | $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50')));
|
---|
1103 | $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50')));
|
---|
1104 | }
|
---|
1105 | $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', array('size'=>'50')));
|
---|
1106 | $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', array('size'=>'50')));
|
---|
1107 | $form->addElement(form_makeButton('submit', '', $lang['btn_register']));
|
---|
1108 | $form->endFieldset();
|
---|
1109 | html_form('register', $form);
|
---|
1110 |
|
---|
1111 | print '</div>'.NL;
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | /**
|
---|
1115 | * Print the update profile form
|
---|
1116 | *
|
---|
1117 | * @author Christopher Smith <[email protected]>
|
---|
1118 | * @author Andreas Gohr <[email protected]>
|
---|
1119 | */
|
---|
1120 | function html_updateprofile(){
|
---|
1121 | global $lang;
|
---|
1122 | global $conf;
|
---|
1123 | global $ID;
|
---|
1124 | global $INFO;
|
---|
1125 | global $auth;
|
---|
1126 |
|
---|
1127 | print p_locale_xhtml('updateprofile');
|
---|
1128 |
|
---|
1129 | if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
|
---|
1130 | if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
|
---|
1131 | print '<div class="centeralign">'.NL;
|
---|
1132 | $form = new Doku_Form(array('id' => 'dw__register'));
|
---|
1133 | $form->startFieldset($lang['profile']);
|
---|
1134 | $form->addHidden('do', 'profile');
|
---|
1135 | $form->addHidden('save', '1');
|
---|
1136 | $form->addElement(form_makeTextField('fullname', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled')));
|
---|
1137 | $attr = array('size'=>'50');
|
---|
1138 | if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled';
|
---|
1139 | $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', $attr));
|
---|
1140 | $attr = array('size'=>'50');
|
---|
1141 | if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled';
|
---|
1142 | $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', $attr));
|
---|
1143 | $form->addElement(form_makeTag('br'));
|
---|
1144 | if ($auth->canDo('modPass')) {
|
---|
1145 | $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50')));
|
---|
1146 | $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50')));
|
---|
1147 | }
|
---|
1148 | if ($conf['profileconfirm']) {
|
---|
1149 | $form->addElement(form_makeTag('br'));
|
---|
1150 | $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50')));
|
---|
1151 | }
|
---|
1152 | $form->addElement(form_makeButton('submit', '', $lang['btn_save']));
|
---|
1153 | $form->addElement(form_makeButton('reset', '', $lang['btn_reset']));
|
---|
1154 | $form->endFieldset();
|
---|
1155 | html_form('updateprofile', $form);
|
---|
1156 | print '</div>'.NL;
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 | /**
|
---|
1160 | * Preprocess edit form data
|
---|
1161 | *
|
---|
1162 | * @author Andreas Gohr <[email protected]>
|
---|
1163 | *
|
---|
1164 | * @triggers HTML_EDITFORM_OUTPUT
|
---|
1165 | */
|
---|
1166 | function html_edit(){
|
---|
1167 | global $ID;
|
---|
1168 | global $REV;
|
---|
1169 | global $DATE;
|
---|
1170 | global $PRE;
|
---|
1171 | global $SUF;
|
---|
1172 | global $INFO;
|
---|
1173 | global $SUM;
|
---|
1174 | global $lang;
|
---|
1175 | global $conf;
|
---|
1176 | global $TEXT;
|
---|
1177 | global $RANGE;
|
---|
1178 |
|
---|
1179 | if (isset($_REQUEST['changecheck'])) {
|
---|
1180 | $check = $_REQUEST['changecheck'];
|
---|
1181 | } elseif(!$INFO['exists']){
|
---|
1182 | // $TEXT has been loaded from page template
|
---|
1183 | $check = md5('');
|
---|
1184 | } else {
|
---|
1185 | $check = md5($TEXT);
|
---|
1186 | }
|
---|
1187 | $mod = md5($TEXT) !== $check;
|
---|
1188 |
|
---|
1189 | $wr = $INFO['writable'] && !$INFO['locked'];
|
---|
1190 | $include = 'edit';
|
---|
1191 | if($wr){
|
---|
1192 | if ($REV) $include = 'editrev';
|
---|
1193 | }else{
|
---|
1194 | // check pseudo action 'source'
|
---|
1195 | if(!actionOK('source')){
|
---|
1196 | msg('Command disabled: source',-1);
|
---|
1197 | return;
|
---|
1198 | }
|
---|
1199 | $include = 'read';
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | global $license;
|
---|
1203 |
|
---|
1204 | $form = new Doku_Form(array('id' => 'dw__editform'));
|
---|
1205 | $form->addHidden('id', $ID);
|
---|
1206 | $form->addHidden('rev', $REV);
|
---|
1207 | $form->addHidden('date', $DATE);
|
---|
1208 | $form->addHidden('prefix', $PRE . '.');
|
---|
1209 | $form->addHidden('suffix', $SUF);
|
---|
1210 | $form->addHidden('changecheck', $check);
|
---|
1211 |
|
---|
1212 | $data = array('form' => $form,
|
---|
1213 | 'wr' => $wr,
|
---|
1214 | 'media_manager' => true,
|
---|
1215 | 'target' => (isset($_REQUEST['target']) && $wr &&
|
---|
1216 | $RANGE !== '') ? $_REQUEST['target'] : 'section',
|
---|
1217 | 'intro_locale' => $include);
|
---|
1218 |
|
---|
1219 | if ($data['target'] !== 'section') {
|
---|
1220 | // Only emit event if page is writable, section edit data is valid and
|
---|
1221 | // edit target is not section.
|
---|
1222 | trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true);
|
---|
1223 | } else {
|
---|
1224 | html_edit_form($data);
|
---|
1225 | }
|
---|
1226 | if (isset($data['intro_locale'])) {
|
---|
1227 | echo p_locale_xhtml($data['intro_locale']);
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | $form->addHidden('target', $data['target']);
|
---|
1231 | $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar')));
|
---|
1232 | $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl')));
|
---|
1233 | $form->addElement(form_makeCloseTag('div'));
|
---|
1234 | if ($wr) {
|
---|
1235 | $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons')));
|
---|
1236 | $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4')));
|
---|
1237 | $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5')));
|
---|
1238 | $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6')));
|
---|
1239 | $form->addElement(form_makeCloseTag('div'));
|
---|
1240 | $form->addElement(form_makeOpenTag('div', array('class'=>'summary')));
|
---|
1241 | $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2')));
|
---|
1242 | $elem = html_minoredit();
|
---|
1243 | if ($elem) $form->addElement($elem);
|
---|
1244 | $form->addElement(form_makeCloseTag('div'));
|
---|
1245 | }
|
---|
1246 | $form->addElement(form_makeCloseTag('div'));
|
---|
1247 | if($wr && $conf['license']){
|
---|
1248 | $form->addElement(form_makeOpenTag('div', array('class'=>'license')));
|
---|
1249 | $out = $lang['licenseok'];
|
---|
1250 | $out .= ' <a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"';
|
---|
1251 | if(isset($conf['target']['extern'])) $out .= ' target="'.$conf['target']['extern'].'"';
|
---|
1252 | $out .= '>'.$license[$conf['license']]['name'].'</a>';
|
---|
1253 | $form->addElement($out);
|
---|
1254 | $form->addElement(form_makeCloseTag('div'));
|
---|
1255 | }
|
---|
1256 |
|
---|
1257 | if ($wr) {
|
---|
1258 | // sets changed to true when previewed
|
---|
1259 | echo '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'. NL;
|
---|
1260 | echo 'textChanged = ' . ($mod ? 'true' : 'false');
|
---|
1261 | echo '//--><!]]></script>' . NL;
|
---|
1262 | } ?>
|
---|
1263 | <div style="width:99%;">
|
---|
1264 |
|
---|
1265 | <div class="toolbar">
|
---|
1266 | <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.dformat();?></div>
|
---|
1267 | <div id="tool__bar"><?php if ($wr && $data['media_manager']){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>"
|
---|
1268 | target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div>
|
---|
1269 |
|
---|
1270 | </div>
|
---|
1271 | <?php
|
---|
1272 |
|
---|
1273 | html_form('edit', $form);
|
---|
1274 | print '</div>'.NL;
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | /**
|
---|
1278 | * Display the default edit form
|
---|
1279 | *
|
---|
1280 | * Is the default action for HTML_EDIT_FORMSELECTION.
|
---|
1281 | */
|
---|
1282 | function html_edit_form($param) {
|
---|
1283 | global $TEXT;
|
---|
1284 |
|
---|
1285 | if ($param['target'] !== 'section') {
|
---|
1286 | msg('No editor for edit target ' . $param['target'] . ' found.', -1);
|
---|
1287 | }
|
---|
1288 |
|
---|
1289 | $attr = array('tabindex'=>'1');
|
---|
1290 | if (!$param['wr']) $attr['readonly'] = 'readonly';
|
---|
1291 |
|
---|
1292 | $param['form']->addElement(form_makeWikiText($TEXT, $attr));
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | /**
|
---|
1296 | * Adds a checkbox for minor edits for logged in users
|
---|
1297 | *
|
---|
1298 | * @author Andreas Gohr <[email protected]>
|
---|
1299 | */
|
---|
1300 | function html_minoredit(){
|
---|
1301 | global $conf;
|
---|
1302 | global $lang;
|
---|
1303 | // minor edits are for logged in users only
|
---|
1304 | if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
|
---|
1305 | return false;
|
---|
1306 | }
|
---|
1307 |
|
---|
1308 | $p = array();
|
---|
1309 | $p['tabindex'] = 3;
|
---|
1310 | if(!empty($_REQUEST['minor'])) $p['checked']='checked';
|
---|
1311 | return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p);
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 | /**
|
---|
1315 | * prints some debug info
|
---|
1316 | *
|
---|
1317 | * @author Andreas Gohr <[email protected]>
|
---|
1318 | */
|
---|
1319 | function html_debug(){
|
---|
1320 | global $conf;
|
---|
1321 | global $lang;
|
---|
1322 | global $auth;
|
---|
1323 | global $INFO;
|
---|
1324 |
|
---|
1325 | //remove sensitive data
|
---|
1326 | $cnf = $conf;
|
---|
1327 | debug_guard($cnf);
|
---|
1328 | $nfo = $INFO;
|
---|
1329 | debug_guard($nfo);
|
---|
1330 | $ses = $_SESSION;
|
---|
1331 | debug_guard($ses);
|
---|
1332 |
|
---|
1333 | print '<html><body>';
|
---|
1334 |
|
---|
1335 | print '<p>When reporting bugs please send all the following ';
|
---|
1336 | print 'output as a mail to [email protected] ';
|
---|
1337 | print 'The best way to do this is to save this page in your browser</p>';
|
---|
1338 |
|
---|
1339 | print '<b>$INFO:</b><pre>';
|
---|
1340 | print_r($nfo);
|
---|
1341 | print '</pre>';
|
---|
1342 |
|
---|
1343 | print '<b>$_SERVER:</b><pre>';
|
---|
1344 | print_r($_SERVER);
|
---|
1345 | print '</pre>';
|
---|
1346 |
|
---|
1347 | print '<b>$conf:</b><pre>';
|
---|
1348 | print_r($cnf);
|
---|
1349 | print '</pre>';
|
---|
1350 |
|
---|
1351 | print '<b>DOKU_BASE:</b><pre>';
|
---|
1352 | print DOKU_BASE;
|
---|
1353 | print '</pre>';
|
---|
1354 |
|
---|
1355 | print '<b>abs DOKU_BASE:</b><pre>';
|
---|
1356 | print DOKU_URL;
|
---|
1357 | print '</pre>';
|
---|
1358 |
|
---|
1359 | print '<b>rel DOKU_BASE:</b><pre>';
|
---|
1360 | print dirname($_SERVER['PHP_SELF']).'/';
|
---|
1361 | print '</pre>';
|
---|
1362 |
|
---|
1363 | print '<b>PHP Version:</b><pre>';
|
---|
1364 | print phpversion();
|
---|
1365 | print '</pre>';
|
---|
1366 |
|
---|
1367 | print '<b>locale:</b><pre>';
|
---|
1368 | print setlocale(LC_ALL,0);
|
---|
1369 | print '</pre>';
|
---|
1370 |
|
---|
1371 | print '<b>encoding:</b><pre>';
|
---|
1372 | print $lang['encoding'];
|
---|
1373 | print '</pre>';
|
---|
1374 |
|
---|
1375 | if($auth){
|
---|
1376 | print '<b>Auth backend capabilities:</b><pre>';
|
---|
1377 | print_r($auth->cando);
|
---|
1378 | print '</pre>';
|
---|
1379 | }
|
---|
1380 |
|
---|
1381 | print '<b>$_SESSION:</b><pre>';
|
---|
1382 | print_r($ses);
|
---|
1383 | print '</pre>';
|
---|
1384 |
|
---|
1385 | print '<b>Environment:</b><pre>';
|
---|
1386 | print_r($_ENV);
|
---|
1387 | print '</pre>';
|
---|
1388 |
|
---|
1389 | print '<b>PHP settings:</b><pre>';
|
---|
1390 | $inis = ini_get_all();
|
---|
1391 | print_r($inis);
|
---|
1392 | print '</pre>';
|
---|
1393 |
|
---|
1394 | print '</body></html>';
|
---|
1395 | }
|
---|
1396 |
|
---|
1397 | /**
|
---|
1398 | * List available Administration Tasks
|
---|
1399 | *
|
---|
1400 | * @author Andreas Gohr <[email protected]>
|
---|
1401 | * @author HÃ¥kan Sandell <[email protected]>
|
---|
1402 | */
|
---|
1403 | function html_admin(){
|
---|
1404 | global $ID;
|
---|
1405 | global $INFO;
|
---|
1406 | global $lang;
|
---|
1407 | global $conf;
|
---|
1408 | global $auth;
|
---|
1409 |
|
---|
1410 | // build menu of admin functions from the plugins that handle them
|
---|
1411 | $pluginlist = plugin_list('admin');
|
---|
1412 | $menu = array();
|
---|
1413 | foreach ($pluginlist as $p) {
|
---|
1414 | if($obj =& plugin_load('admin',$p) === null) continue;
|
---|
1415 |
|
---|
1416 | // check permissions
|
---|
1417 | if($obj->forAdminOnly() && !$INFO['isadmin']) continue;
|
---|
1418 |
|
---|
1419 | $menu[$p] = array('plugin' => $p,
|
---|
1420 | 'prompt' => $obj->getMenuText($conf['lang']),
|
---|
1421 | 'sort' => $obj->getMenuSort()
|
---|
1422 | );
|
---|
1423 | }
|
---|
1424 |
|
---|
1425 | // data security check
|
---|
1426 | // @todo: could be checked and only displayed if $conf['savedir'] is under the web root
|
---|
1427 | echo '<a style="border:none; float:right;"
|
---|
1428 | href="http://www.dokuwiki.org/security#web_access_security">
|
---|
1429 | <img src="data/security.png" alt="Your data directory seems to be protected properly."
|
---|
1430 | onerror="this.parentNode.style.display=\'none\'" /></a>';
|
---|
1431 |
|
---|
1432 | print p_locale_xhtml('admin');
|
---|
1433 |
|
---|
1434 | // Admin Tasks
|
---|
1435 | if($INFO['isadmin']){
|
---|
1436 | ptln('<ul class="admin_tasks">');
|
---|
1437 |
|
---|
1438 | if($menu['usermanager'] && $auth && $auth->canDo('getUsers')){
|
---|
1439 | ptln(' <li class="admin_usermanager"><div class="li">'.
|
---|
1440 | '<a href="'.wl($ID, array('do' => 'admin','page' => 'usermanager')).'">'.
|
---|
1441 | $menu['usermanager']['prompt'].'</a></div></li>');
|
---|
1442 | }
|
---|
1443 | unset($menu['usermanager']);
|
---|
1444 |
|
---|
1445 | if($menu['acl']){
|
---|
1446 | ptln(' <li class="admin_acl"><div class="li">'.
|
---|
1447 | '<a href="'.wl($ID, array('do' => 'admin','page' => 'acl')).'">'.
|
---|
1448 | $menu['acl']['prompt'].'</a></div></li>');
|
---|
1449 | }
|
---|
1450 | unset($menu['acl']);
|
---|
1451 |
|
---|
1452 | if($menu['plugin']){
|
---|
1453 | ptln(' <li class="admin_plugin"><div class="li">'.
|
---|
1454 | '<a href="'.wl($ID, array('do' => 'admin','page' => 'plugin')).'">'.
|
---|
1455 | $menu['plugin']['prompt'].'</a></div></li>');
|
---|
1456 | }
|
---|
1457 | unset($menu['plugin']);
|
---|
1458 |
|
---|
1459 | if($menu['config']){
|
---|
1460 | ptln(' <li class="admin_config"><div class="li">'.
|
---|
1461 | '<a href="'.wl($ID, array('do' => 'admin','page' => 'config')).'">'.
|
---|
1462 | $menu['config']['prompt'].'</a></div></li>');
|
---|
1463 | }
|
---|
1464 | unset($menu['config']);
|
---|
1465 | }
|
---|
1466 | ptln('</ul>');
|
---|
1467 |
|
---|
1468 | // Manager Tasks
|
---|
1469 | ptln('<ul class="admin_tasks">');
|
---|
1470 |
|
---|
1471 | if($menu['revert']){
|
---|
1472 | ptln(' <li class="admin_revert"><div class="li">'.
|
---|
1473 | '<a href="'.wl($ID, array('do' => 'admin','page' => 'revert')).'">'.
|
---|
1474 | $menu['revert']['prompt'].'</a></div></li>');
|
---|
1475 | }
|
---|
1476 | unset($menu['revert']);
|
---|
1477 |
|
---|
1478 | if($menu['popularity']){
|
---|
1479 | ptln(' <li class="admin_popularity"><div class="li">'.
|
---|
1480 | '<a href="'.wl($ID, array('do' => 'admin','page' => 'popularity')).'">'.
|
---|
1481 | $menu['popularity']['prompt'].'</a></div></li>');
|
---|
1482 | }
|
---|
1483 | unset($menu['popularity']);
|
---|
1484 |
|
---|
1485 | // print DokuWiki version:
|
---|
1486 | ptln('</ul>');
|
---|
1487 | echo '<div id="admin__version">';
|
---|
1488 | echo getVersion();
|
---|
1489 | echo '</div>';
|
---|
1490 |
|
---|
1491 | // print the rest as sorted list
|
---|
1492 | if(count($menu)){
|
---|
1493 | usort($menu, 'p_sort_modes');
|
---|
1494 | // output the menu
|
---|
1495 | ptln('<div class="clearer"></div>');
|
---|
1496 | print p_locale_xhtml('adminplugins');
|
---|
1497 | ptln('<ul>');
|
---|
1498 | foreach ($menu as $item) {
|
---|
1499 | if (!$item['prompt']) continue;
|
---|
1500 | ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>');
|
---|
1501 | }
|
---|
1502 | ptln('</ul>');
|
---|
1503 | }
|
---|
1504 | }
|
---|
1505 |
|
---|
1506 | /**
|
---|
1507 | * Form to request a new password for an existing account
|
---|
1508 | *
|
---|
1509 | * @author Benoit Chesneau <[email protected]>
|
---|
1510 | */
|
---|
1511 | function html_resendpwd() {
|
---|
1512 | global $lang;
|
---|
1513 | global $conf;
|
---|
1514 | global $ID;
|
---|
1515 |
|
---|
1516 | print p_locale_xhtml('resendpwd');
|
---|
1517 | print '<div class="centeralign">'.NL;
|
---|
1518 | $form = new Doku_Form(array('id' => 'dw__resendpwd'));
|
---|
1519 | $form->startFieldset($lang['resendpwd']);
|
---|
1520 | $form->addHidden('do', 'resendpwd');
|
---|
1521 | $form->addHidden('save', '1');
|
---|
1522 | $form->addElement(form_makeTag('br'));
|
---|
1523 | $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block'));
|
---|
1524 | $form->addElement(form_makeTag('br'));
|
---|
1525 | $form->addElement(form_makeTag('br'));
|
---|
1526 | $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd']));
|
---|
1527 | $form->endFieldset();
|
---|
1528 | html_form('resendpwd', $form);
|
---|
1529 | print '</div>'.NL;
|
---|
1530 | }
|
---|
1531 |
|
---|
1532 | /**
|
---|
1533 | * Return the TOC rendered to XHTML
|
---|
1534 | *
|
---|
1535 | * @author Andreas Gohr <[email protected]>
|
---|
1536 | */
|
---|
1537 | function html_TOC($toc){
|
---|
1538 | if(!count($toc)) return '';
|
---|
1539 | global $lang;
|
---|
1540 | $out = '<!-- TOC START -->'.DOKU_LF;
|
---|
1541 | $out .= '<div class="toc">'.DOKU_LF;
|
---|
1542 | $out .= '<div class="tocheader toctoggle" id="toc__header">';
|
---|
1543 | $out .= $lang['toc'];
|
---|
1544 | $out .= '</div>'.DOKU_LF;
|
---|
1545 | $out .= '<div id="toc__inside">'.DOKU_LF;
|
---|
1546 | $out .= html_buildlist($toc,'toc','html_list_toc');
|
---|
1547 | $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
|
---|
1548 | $out .= '<!-- TOC END -->'.DOKU_LF;
|
---|
1549 | return $out;
|
---|
1550 | }
|
---|
1551 |
|
---|
1552 | /**
|
---|
1553 | * Callback for html_buildlist
|
---|
1554 | */
|
---|
1555 | function html_list_toc($item){
|
---|
1556 | if(isset($item['hid'])){
|
---|
1557 | $link = '#'.$item['hid'];
|
---|
1558 | }else{
|
---|
1559 | $link = $item['link'];
|
---|
1560 | }
|
---|
1561 |
|
---|
1562 | return '<span class="li"><a href="'.$link.'" class="toc">'.
|
---|
1563 | hsc($item['title']).'</a></span>';
|
---|
1564 | }
|
---|
1565 |
|
---|
1566 | /**
|
---|
1567 | * Helper function to build TOC items
|
---|
1568 | *
|
---|
1569 | * Returns an array ready to be added to a TOC array
|
---|
1570 | *
|
---|
1571 | * @param string $link - where to link (if $hash set to '#' it's a local anchor)
|
---|
1572 | * @param string $text - what to display in the TOC
|
---|
1573 | * @param int $level - nesting level
|
---|
1574 | * @param string $hash - is prepended to the given $link, set blank if you want full links
|
---|
1575 | */
|
---|
1576 | function html_mktocitem($link, $text, $level, $hash='#'){
|
---|
1577 | global $conf;
|
---|
1578 | return array( 'link' => $hash.$link,
|
---|
1579 | 'title' => $text,
|
---|
1580 | 'type' => 'ul',
|
---|
1581 | 'level' => $level);
|
---|
1582 | }
|
---|
1583 |
|
---|
1584 | /**
|
---|
1585 | * Output a Doku_Form object.
|
---|
1586 | * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT
|
---|
1587 | *
|
---|
1588 | * @author Tom N Harris <[email protected]>
|
---|
1589 | */
|
---|
1590 | function html_form($name, &$form) {
|
---|
1591 | // Safety check in case the caller forgets.
|
---|
1592 | $form->endFieldset();
|
---|
1593 | trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false);
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 | /**
|
---|
1597 | * Form print function.
|
---|
1598 | * Just calls printForm() on the data object.
|
---|
1599 | */
|
---|
1600 | function html_form_output($data) {
|
---|
1601 | $data->printForm();
|
---|
1602 | }
|
---|
1603 |
|
---|
1604 | /**
|
---|
1605 | * Embed a flash object in HTML
|
---|
1606 | *
|
---|
1607 | * This will create the needed HTML to embed a flash movie in a cross browser
|
---|
1608 | * compatble way using valid XHTML
|
---|
1609 | *
|
---|
1610 | * The parameters $params, $flashvars and $atts need to be associative arrays.
|
---|
1611 | * No escaping needs to be done for them. The alternative content *has* to be
|
---|
1612 | * escaped because it is used as is. If no alternative content is given
|
---|
1613 | * $lang['noflash'] is used.
|
---|
1614 | *
|
---|
1615 | * @author Andreas Gohr <[email protected]>
|
---|
1616 | * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml
|
---|
1617 | *
|
---|
1618 | * @param string $swf - the SWF movie to embed
|
---|
1619 | * @param int $width - width of the flash movie in pixels
|
---|
1620 | * @param int $height - height of the flash movie in pixels
|
---|
1621 | * @param array $params - additional parameters (<param>)
|
---|
1622 | * @param array $flashvars - parameters to be passed in the flashvar parameter
|
---|
1623 | * @param array $atts - additional attributes for the <object> tag
|
---|
1624 | * @param string $alt - alternative content (is NOT automatically escaped!)
|
---|
1625 | * @returns string - the XHTML markup
|
---|
1626 | */
|
---|
1627 | function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){
|
---|
1628 | global $lang;
|
---|
1629 |
|
---|
1630 | $out = '';
|
---|
1631 |
|
---|
1632 | // prepare the object attributes
|
---|
1633 | if(is_null($atts)) $atts = array();
|
---|
1634 | $atts['width'] = (int) $width;
|
---|
1635 | $atts['height'] = (int) $height;
|
---|
1636 | if(!$atts['width']) $atts['width'] = 425;
|
---|
1637 | if(!$atts['height']) $atts['height'] = 350;
|
---|
1638 |
|
---|
1639 | // add object attributes for standard compliant browsers
|
---|
1640 | $std = $atts;
|
---|
1641 | $std['type'] = 'application/x-shockwave-flash';
|
---|
1642 | $std['data'] = $swf;
|
---|
1643 |
|
---|
1644 | // add object attributes for IE
|
---|
1645 | $ie = $atts;
|
---|
1646 | $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
|
---|
1647 |
|
---|
1648 | // open object (with conditional comments)
|
---|
1649 | $out .= '<!--[if !IE]> -->'.NL;
|
---|
1650 | $out .= '<object '.buildAttributes($std).'>'.NL;
|
---|
1651 | $out .= '<!-- <![endif]-->'.NL;
|
---|
1652 | $out .= '<!--[if IE]>'.NL;
|
---|
1653 | $out .= '<object '.buildAttributes($ie).'>'.NL;
|
---|
1654 | $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL;
|
---|
1655 | $out .= '<!--><!-- -->'.NL;
|
---|
1656 |
|
---|
1657 | // print params
|
---|
1658 | if(is_array($params)) foreach($params as $key => $val){
|
---|
1659 | $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL;
|
---|
1660 | }
|
---|
1661 |
|
---|
1662 | // add flashvars
|
---|
1663 | if(is_array($flashvars)){
|
---|
1664 | $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL;
|
---|
1665 | }
|
---|
1666 |
|
---|
1667 | // alternative content
|
---|
1668 | if($alt){
|
---|
1669 | $out .= $alt.NL;
|
---|
1670 | }else{
|
---|
1671 | $out .= $lang['noflash'].NL;
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | // finish
|
---|
1675 | $out .= '</object>'.NL;
|
---|
1676 | $out .= '<!-- <![endif]-->'.NL;
|
---|
1677 |
|
---|
1678 | return $out;
|
---|
1679 | }
|
---|
1680 |
|
---|