French language update
[dokuwiki/radio.git] / inc / html.php
blob04bb986c5dddd09c355ded5886509a6577664f05
1 <?php
2 /**
3 * HTML output functions
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Andreas Gohr <andi@splitbrain.org>
7 */
9 if(!defined('DOKU_INC')) die('meh.');
10 if(!defined('NL')) define('NL',"\n");
11 require_once(DOKU_INC.'inc/parserutils.php');
12 require_once(DOKU_INC.'inc/form.php');
14 /**
15 * Convenience function to quickly build a wikilink
17 * @author Andreas Gohr <andi@splitbrain.org>
19 function html_wikilink($id,$name=null,$search=''){
20 static $xhtml_renderer = null;
21 if(is_null($xhtml_renderer)){
22 $xhtml_renderer = p_get_renderer('xhtml');
25 return $xhtml_renderer->internallink($id,$name,$search,true,'navigation');
28 /**
29 * Helps building long attribute lists
31 * @author Andreas Gohr <andi@splitbrain.org>
33 function html_attbuild($attributes){
34 $ret = '';
35 foreach ( $attributes as $key => $value ) {
36 $ret .= $key.'="'.formText($value).'" ';
38 return trim($ret);
41 /**
42 * The loginform
44 * @author Andreas Gohr <andi@splitbrain.org>
46 function html_login(){
47 global $lang;
48 global $conf;
49 global $ID;
50 global $auth;
52 print p_locale_xhtml('login');
53 print '<div class="centeralign">'.NL;
54 $form = new Doku_Form(array('id' => 'dw__login'));
55 $form->startFieldset($lang['btn_login']);
56 $form->addHidden('id', $ID);
57 $form->addHidden('do', 'login');
58 $form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block'));
59 $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block'));
60 if($conf['rememberme']) {
61 $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple'));
63 $form->addElement(form_makeButton('submit', '', $lang['btn_login']));
64 $form->endFieldset();
66 if($auth && $auth->canDo('addUser') && actionOK('register')){
67 $form->addElement('<p>'
68 . $lang['reghere']
69 . ': <a href="'.wl($ID,'do=register').'" rel="nofollow" class="wikilink1">'.$lang['register'].'</a>'
70 . '</p>');
73 if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) {
74 $form->addElement('<p>'
75 . $lang['pwdforget']
76 . ': <a href="'.wl($ID,'do=resendpwd').'" rel="nofollow" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'
77 . '</p>');
80 html_form('login', $form);
81 print '</div>'.NL;
84 /**
85 * inserts section edit buttons if wanted or removes the markers
87 * @author Andreas Gohr <andi@splitbrain.org>
89 function html_secedit($text,$show=true){
90 global $INFO;
92 $regexp = '#<!-- EDIT(\d+) ([A-Z]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->#';
94 if(!$INFO['writable'] || !$show || $INFO['rev']){
95 return preg_replace($regexp,'',$text);
98 return preg_replace_callback($regexp,
99 'html_secedit_button', $text);
103 * prepares section edit button data for event triggering
104 * used as a callback in html_secedit
106 * @triggers HTML_SECEDIT_BUTTON
107 * @author Andreas Gohr <andi@splitbrain.org>
109 function html_secedit_button($matches){
110 $data = array('secid' => $matches[1],
111 'target' => strtolower($matches[2]),
112 'range' => $matches[count($matches) - 1]);
113 if (count($matches) === 5) {
114 $data['name'] = $matches[3];
117 return trigger_event('HTML_SECEDIT_BUTTON', $data,
118 'html_secedit_get_button');
122 * prints a section editing button
123 * used as default action form HTML_SECEDIT_BUTTON
125 * @author Adrian Lang <lang@cosmocode.de>
127 function html_secedit_get_button($data) {
128 global $ID;
129 global $INFO;
131 if (!isset($data['name']) || $data['name'] === '') return;
133 $name = $data['name'];
134 unset($data['name']);
136 $secid = $data['secid'];
137 unset($data['secid']);
139 return "<div class='secedit editbutton_" . $data['target'] .
140 " editbutton_" . $secid . "'>" .
141 html_btn('secedit', $ID, '',
142 array_merge(array('do' => 'edit',
143 'rev' => $INFO['lastmod']), $data),
144 'post', $name) . '</div>';
148 * Just the back to top button (in its own form)
150 * @author Andreas Gohr <andi@splitbrain.org>
152 function html_topbtn(){
153 global $lang;
155 $ret = '';
156 $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>';
158 return $ret;
162 * Displays a button (using its own form)
163 * If tooltip exists, the access key tooltip is replaced.
165 * @author Andreas Gohr <andi@splitbrain.org>
167 function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){
168 global $conf;
169 global $lang;
171 $label = $lang['btn_'.$name];
173 $ret = '';
174 $tip = '';
176 //filter id (without urlencoding)
177 $id = idfilter($id,false);
179 //make nice URLs even for buttons
180 if($conf['userewrite'] == 2){
181 $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
182 }elseif($conf['userewrite']){
183 $script = DOKU_BASE.$id;
184 }else{
185 $script = DOKU_BASE.DOKU_SCRIPT;
186 $params['id'] = $id;
189 $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">';
191 if(is_array($params)){
192 reset($params);
193 while (list($key, $val) = each($params)) {
194 $ret .= '<input type="hidden" name="'.$key.'" ';
195 $ret .= 'value="'.htmlspecialchars($val).'" />';
199 if ($tooltip!='') {
200 $tip = htmlspecialchars($tooltip);
201 }else{
202 $tip = htmlspecialchars($label);
205 $ret .= '<input type="submit" value="'.hsc($label).'" class="button" ';
206 if($akey){
207 $tip .= ' ['.strtoupper($akey).']';
208 $ret .= 'accesskey="'.$akey.'" ';
210 $ret .= 'title="'.$tip.'" ';
211 $ret .= '/>';
212 $ret .= '</div></form>';
214 return $ret;
218 * show a wiki page
220 * @author Andreas Gohr <andi@splitbrain.org>
222 function html_show($txt=''){
223 global $ID;
224 global $REV;
225 global $HIGH;
226 global $INFO;
227 //disable section editing for old revisions or in preview
228 if($txt || $REV){
229 $secedit = false;
230 }else{
231 $secedit = true;
234 if ($txt){
235 //PreviewHeader
236 echo '<br id="scroll__here" />';
237 echo p_locale_xhtml('preview');
238 echo '<div class="preview">';
239 $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
240 if($INFO['prependTOC']) $html = tpl_toc(true).$html;
241 echo $html;
242 echo '<div class="clearer"></div>';
243 echo '</div>';
245 }else{
246 if ($REV) print p_locale_xhtml('showrev');
247 $html = p_wiki_xhtml($ID,$REV,true);
248 $html = html_secedit($html,$secedit);
249 if($INFO['prependTOC']) $html = tpl_toc(true).$html;
250 $html = html_hilight($html,$HIGH);
251 echo $html;
256 * ask the user about how to handle an exisiting draft
258 * @author Andreas Gohr <andi@splitbrain.org>
260 function html_draft(){
261 global $INFO;
262 global $ID;
263 global $lang;
264 global $conf;
265 $draft = unserialize(io_readFile($INFO['draft'],false));
266 $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true));
268 print p_locale_xhtml('draft');
269 $form = new Doku_Form(array('id' => 'dw__editform'));
270 $form->addHidden('id', $ID);
271 $form->addHidden('date', $draft['date']);
272 $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly')));
273 $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status')));
274 $form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft'])));
275 $form->addElement(form_makeCloseTag('div'));
276 $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1')));
277 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2')));
278 $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3')));
279 html_form('draft', $form);
283 * Highlights searchqueries in HTML code
285 * @author Andreas Gohr <andi@splitbrain.org>
286 * @author Harry Fuecks <hfuecks@gmail.com>
288 function html_hilight($html,$phrases){
289 $phrases = array_filter((array) $phrases);
290 $regex = join('|',array_map('preg_quote_cb',$phrases));
292 if ($regex === '') return $html;
293 $html = preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html);
294 return $html;
298 * Callback used by html_hilight()
300 * @author Harry Fuecks <hfuecks@gmail.com>
302 function html_hilight_callback($m) {
303 $hlight = unslash($m[0]);
304 if ( !isset($m[2])) {
305 $hlight = '<span class="search_hit">'.$hlight.'</span>';
307 return $hlight;
311 * Run a search and display the result
313 * @author Andreas Gohr <andi@splitbrain.org>
315 function html_search(){
316 require_once(DOKU_INC.'inc/search.php');
317 require_once(DOKU_INC.'inc/fulltext.php');
318 global $conf;
319 global $QUERY;
320 global $ID;
321 global $lang;
323 print p_locale_xhtml('searchpage');
324 flush();
326 //check if search is restricted to namespace
327 if(preg_match('/@([^@]*)/',$QUERY,$match)) {
328 $id = cleanID($match[1]);
329 } else {
330 $id = cleanID($QUERY);
333 //show progressbar
334 print '<div class="centeralign" id="dw__loading">'.NL;
335 print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
336 print 'showLoadBar();'.NL;
337 print '//--><!]]></script>'.NL;
338 print '<br /></div>'.NL;
339 flush();
341 //do quick pagesearch
342 $data = array();
344 if($id) $data = ft_pageLookup($id);
345 if(count($data)){
346 print '<div class="search_quickresult">';
347 print '<h3>'.$lang['quickhits'].':</h3>';
348 print '<ul class="search_quickhits">';
349 foreach($data as $id){
350 print '<li> ';
351 $ns = getNS($id);
352 if($ns){
353 $name = shorten(noNS($id), ' ('.$ns.')',30);
354 }else{
355 $name = $id;
357 print html_wikilink(':'.$id,$name);
358 print '</li> ';
360 print '</ul> ';
361 //clear float (see http://www.complexspiral.com/publications/containing-floats/)
362 print '<div class="clearer">&nbsp;</div>';
363 print '</div>';
365 flush();
367 //do fulltext search
368 $data = ft_pageSearch($QUERY,$regex);
369 if(count($data)){
370 $num = 1;
371 foreach($data as $id => $cnt){
372 print '<div class="search_result">';
373 print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex);
374 if($cnt !== 0){
375 print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
376 if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
377 print '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>';
379 $num++;
381 print '</div>';
382 flush();
384 }else{
385 print '<div class="nothing">'.$lang['nothingfound'].'</div>';
388 //hide progressbar
389 print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
390 print 'hideLoadBar("dw__loading");'.NL;
391 print '//--><!]]></script>'.NL;
392 flush();
396 * Display error on locked pages
398 * @author Andreas Gohr <andi@splitbrain.org>
400 function html_locked(){
401 global $ID;
402 global $conf;
403 global $lang;
404 global $INFO;
406 $locktime = filemtime(wikiLockFN($ID));
407 $expire = dformat($locktime + $conf['locktime']);
408 $min = round(($conf['locktime'] - (time() - $locktime) )/60);
410 print p_locale_xhtml('locked');
411 print '<ul>';
412 print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.editorinfo($INFO['locked']).'</div></li>';
413 print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>';
414 print '</ul>';
418 * list old revisions
420 * @author Andreas Gohr <andi@splitbrain.org>
421 * @author Ben Coburn <btcoburn@silicodon.net>
423 function html_revisions($first=0){
424 global $ID;
425 global $INFO;
426 global $conf;
427 global $lang;
428 /* we need to get one additionally log entry to be able to
429 * decide if this is the last page or is there another one.
430 * see html_recent()
432 $revisions = getRevisions($ID, $first, $conf['recent']+1);
433 if(count($revisions)==0 && $first!=0){
434 $first=0;
435 $revisions = getRevisions($ID, $first, $conf['recent']+1);;
437 $hasNext = false;
438 if (count($revisions)>$conf['recent']) {
439 $hasNext = true;
440 array_pop($revisions); // remove extra log entry
443 $date = dformat($INFO['lastmod']);
445 print p_locale_xhtml('revisions');
447 $form = new Doku_Form(array('id' => 'page__revisions'));
448 $form->addElement(form_makeOpenTag('ul'));
449 if($INFO['exists'] && $first==0){
450 if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
451 $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
452 else
453 $form->addElement(form_makeOpenTag('li'));
454 $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
455 $form->addElement(form_makeTag('input', array(
456 'type' => 'checkbox',
457 'name' => 'rev2[]',
458 'value' => 'current')));
460 $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
461 $form->addElement($date);
462 $form->addElement(form_makeCloseTag('span'));
464 $form->addElement(form_makeTag('img', array(
465 'src' => DOKU_BASE.'lib/images/blank.gif',
466 'width' => '15',
467 'height' => '11',
468 'alt' => '')));
470 $form->addElement(form_makeOpenTag('a', array(
471 'class' => 'wikilink1',
472 'href' => wl($ID))));
473 $form->addElement($ID);
474 $form->addElement(form_makeCloseTag('a'));
476 $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
477 $form->addElement(' &ndash; ');
478 $form->addElement(htmlspecialchars($INFO['sum']));
479 $form->addElement(form_makeCloseTag('span'));
481 $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
482 $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor']));
483 $form->addElement(form_makeCloseTag('span'));
485 $form->addElement('('.$lang['current'].')');
486 $form->addElement(form_makeCloseTag('div'));
487 $form->addElement(form_makeCloseTag('li'));
490 foreach($revisions as $rev){
491 $date = dformat($rev);
492 $info = getRevisionInfo($ID,$rev,true);
493 $exists = page_exists($ID,$rev);
495 if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
496 $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
497 else
498 $form->addElement(form_makeOpenTag('li'));
499 $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
500 if($exists){
501 $form->addElement(form_makeTag('input', array(
502 'type' => 'checkbox',
503 'name' => 'rev2[]',
504 'value' => $rev)));
505 }else{
506 $form->addElement(form_makeTag('img', array(
507 'src' => DOKU_BASE.'lib/images/blank.gif',
508 'width' => 14,
509 'height' => 11,
510 'alt' => '')));
513 $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
514 $form->addElement($date);
515 $form->addElement(form_makeCloseTag('span'));
517 if($exists){
518 $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link')));
519 $form->addElement(form_makeTag('img', array(
520 'src' => DOKU_BASE.'lib/images/diff.png',
521 'width' => 15,
522 'height' => 11,
523 'title' => $lang['diff'],
524 'alt' => $lang['diff'])));
525 $form->addElement(form_makeCloseTag('a'));
527 $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1')));
528 $form->addElement($ID);
529 $form->addElement(form_makeCloseTag('a'));
530 }else{
531 $form->addElement(form_makeTag('img', array(
532 'src' => DOKU_BASE.'lib/images/blank.gif',
533 'width' => '15',
534 'height' => '11',
535 'alt' => '')));
536 $form->addElement($ID);
539 $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
540 $form->addElement(' &ndash; ');
541 $form->addElement(htmlspecialchars($info['sum']));
542 $form->addElement(form_makeCloseTag('span'));
544 $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
545 if($info['user']){
546 $form->addElement(editorinfo($info['user']));
547 if(auth_ismanager()){
548 $form->addElement(' ('.$info['ip'].')');
550 }else{
551 $form->addElement($info['ip']);
553 $form->addElement(form_makeCloseTag('span'));
555 $form->addElement(form_makeCloseTag('div'));
556 $form->addElement(form_makeCloseTag('li'));
558 $form->addElement(form_makeCloseTag('ul'));
559 $form->addElement(form_makeButton('submit', 'diff', $lang['diff2']));
560 html_form('revisions', $form);
562 print '<div class="pagenav">';
563 $last = $first + $conf['recent'];
564 if ($first > 0) {
565 $first -= $conf['recent'];
566 if ($first < 0) $first = 0;
567 print '<div class="pagenav-prev">';
568 print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first));
569 print '</div>';
571 if ($hasNext) {
572 print '<div class="pagenav-next">';
573 print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last));
574 print '</div>';
576 print '</div>';
581 * display recent changes
583 * @author Andreas Gohr <andi@splitbrain.org>
584 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
585 * @author Ben Coburn <btcoburn@silicodon.net>
587 function html_recent($first=0){
588 global $conf;
589 global $lang;
590 global $ID;
591 /* we need to get one additionally log entry to be able to
592 * decide if this is the last page or is there another one.
593 * This is the cheapest solution to get this information.
595 $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
596 if(count($recents) == 0 && $first != 0){
597 $first=0;
598 $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
600 $hasNext = false;
601 if (count($recents)>$conf['recent']) {
602 $hasNext = true;
603 array_pop($recents); // remove extra log entry
606 print p_locale_xhtml('recent');
608 if (getNS($ID) != '')
609 print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>';
611 $form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET'));
612 $form->addHidden('sectok', null);
613 $form->addHidden('do', 'recent');
614 $form->addHidden('id', $ID);
615 $form->addElement(form_makeOpenTag('ul'));
617 foreach($recents as $recent){
618 $date = dformat($recent['date']);
619 if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT)
620 $form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
621 else
622 $form->addElement(form_makeOpenTag('li'));
624 $form->addElement(form_makeOpenTag('div', array('class' => 'li')));
626 $form->addElement(form_makeOpenTag('span', array('class' => 'date')));
627 $form->addElement($date);
628 $form->addElement(form_makeCloseTag('span'));
630 $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => wl($recent['id'],"do=diff", false, '&'))));
631 $form->addElement(form_makeTag('img', array(
632 'src' => DOKU_BASE.'lib/images/diff.png',
633 'width' => 15,
634 'height'=> 11,
635 'title' => $lang['diff'],
636 'alt' => $lang['diff']
637 )));
638 $form->addElement(form_makeCloseTag('a'));
640 $form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => wl($recent['id'],"do=revisions",false,'&'))));
641 $form->addElement(form_makeTag('img', array(
642 'src' => DOKU_BASE.'lib/images/history.png',
643 'width' => 12,
644 'height'=> 14,
645 'title' => $lang['btn_revs'],
646 'alt' => $lang['btn_revs']
647 )));
648 $form->addElement(form_makeCloseTag('a'));
650 $form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?null:$recent['id']));
652 $form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
653 $form->addElement(' &ndash; '.htmlspecialchars($recent['sum']));
654 $form->addElement(form_makeCloseTag('span'));
656 $form->addElement(form_makeOpenTag('span', array('class' => 'user')));
657 if($recent['user']){
658 $form->addElement(editorinfo($recent['user']));
659 if(auth_ismanager()){
660 $form->addElement(' ('.$recent['ip'].')');
662 }else{
663 $form->addElement($recent['ip']);
665 $form->addElement(form_makeCloseTag('span'));
667 $form->addElement(form_makeCloseTag('div'));
668 $form->addElement(form_makeCloseTag('li'));
670 $form->addElement(form_makeCloseTag('ul'));
672 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav')));
673 $last = $first + $conf['recent'];
674 if ($first > 0) {
675 $first -= $conf['recent'];
676 if ($first < 0) $first = 0;
677 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev')));
678 $form->addElement(form_makeTag('input', array(
679 'type' => 'submit',
680 'name' => 'first['.$first.']',
681 'value' => $lang['btn_newer'],
682 'accesskey' => 'n',
683 'title' => $lang['btn_newer'].' [N]',
684 'class' => 'button'
685 )));
686 $form->addElement(form_makeCloseTag('div'));
688 if ($hasNext) {
689 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next')));
690 $form->addElement(form_makeTag('input', array(
691 'type' => 'submit',
692 'name' => 'first['.$last.']',
693 'value' => $lang['btn_older'],
694 'accesskey' => 'p',
695 'title' => $lang['btn_older'].' [P]',
696 'class' => 'button'
697 )));
698 $form->addElement(form_makeCloseTag('div'));
700 $form->addElement(form_makeCloseTag('div'));
701 html_form('recent', $form);
705 * Display page index
707 * @author Andreas Gohr <andi@splitbrain.org>
709 function html_index($ns){
710 require_once(DOKU_INC.'inc/search.php');
711 global $conf;
712 global $ID;
713 $dir = $conf['datadir'];
714 $ns = cleanID($ns);
715 #fixme use appropriate function
716 if(empty($ns)){
717 $ns = dirname(str_replace(':','/',$ID));
718 if($ns == '.') $ns ='';
720 $ns = utf8_encodeFN(str_replace(':','/',$ns));
722 echo p_locale_xhtml('index');
723 echo '<div id="index__tree">';
725 $data = array();
726 search($data,$conf['datadir'],'search_index',array('ns' => $ns));
727 echo html_buildlist($data,'idx','html_list_index','html_li_index');
729 echo '</div>';
733 * Index item formatter
735 * User function for html_buildlist()
737 * @author Andreas Gohr <andi@splitbrain.org>
739 function html_list_index($item){
740 global $ID;
741 $ret = '';
742 $base = ':'.$item['id'];
743 $base = substr($base,strrpos($base,':')+1);
744 if($item['type']=='d'){
745 $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>';
746 $ret .= $base;
747 $ret .= '</strong></a>';
748 }else{
749 $ret .= html_wikilink(':'.$item['id']);
751 return $ret;
755 * Index List item
757 * This user function is used in html_build_lidt to build the
758 * <li> tags for namespaces when displaying the page index
759 * it gives different classes to opened or closed "folders"
761 * @author Andreas Gohr <andi@splitbrain.org>
763 function html_li_index($item){
764 if($item['type'] == "f"){
765 return '<li class="level'.$item['level'].'">';
766 }elseif($item['open']){
767 return '<li class="open">';
768 }else{
769 return '<li class="closed">';
774 * Default List item
776 * @author Andreas Gohr <andi@splitbrain.org>
778 function html_li_default($item){
779 return '<li class="level'.$item['level'].'">';
783 * Build an unordered list
785 * Build an unordered list from the given $data array
786 * Each item in the array has to have a 'level' property
787 * the item itself gets printed by the given $func user
788 * function. The second and optional function is used to
789 * print the <li> tag. Both user function need to accept
790 * a single item.
792 * Both user functions can be given as array to point to
793 * a member of an object.
795 * @author Andreas Gohr <andi@splitbrain.org>
797 function html_buildlist($data,$class,$func,$lifunc='html_li_default'){
798 $level = 0;
799 $opens = 0;
800 $ret = '';
802 foreach ($data as $item){
804 if( $item['level'] > $level ){
805 //open new list
806 for($i=0; $i<($item['level'] - $level); $i++){
807 if ($i) $ret .= "<li class=\"clear\">\n";
808 $ret .= "\n<ul class=\"$class\">\n";
810 }elseif( $item['level'] < $level ){
811 //close last item
812 $ret .= "</li>\n";
813 for ($i=0; $i<($level - $item['level']); $i++){
814 //close higher lists
815 $ret .= "</ul>\n</li>\n";
817 }else{
818 //close last item
819 $ret .= "</li>\n";
822 //remember current level
823 $level = $item['level'];
825 //print item
826 $ret .= call_user_func($lifunc,$item);
827 $ret .= '<div class="li">';
829 $ret .= call_user_func($func,$item);
830 $ret .= '</div>';
833 //close remaining items and lists
834 for ($i=0; $i < $level; $i++){
835 $ret .= "</li></ul>\n";
838 return $ret;
842 * display backlinks
844 * @author Andreas Gohr <andi@splitbrain.org>
845 * @author Michael Klier <chi@chimeric.de>
847 function html_backlinks(){
848 require_once(DOKU_INC.'inc/fulltext.php');
849 global $ID;
850 global $conf;
851 global $lang;
853 print p_locale_xhtml('backlinks');
855 $data = ft_backlinks($ID);
857 if(!empty($data)) {
858 print '<ul class="idx">';
859 foreach($data as $blink){
860 print '<li><div class="li">';
861 print html_wikilink(':'.$blink,useHeading('navigation')?null:$blink);
862 print '</div></li>';
864 print '</ul>';
865 } else {
866 print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>';
871 * show diff
873 * @author Andreas Gohr <andi@splitbrain.org>
875 function html_diff($text='',$intro=true){
876 require_once(DOKU_INC.'inc/DifferenceEngine.php');
877 global $ID;
878 global $REV;
879 global $lang;
880 global $conf;
882 // we're trying to be clever here, revisions to compare can be either
883 // given as rev and rev2 parameters, with rev2 being optional. Or in an
884 // array in rev2.
885 $rev1 = $REV;
887 if(is_array($_REQUEST['rev2'])){
888 $rev1 = (int) $_REQUEST['rev2'][0];
889 $rev2 = (int) $_REQUEST['rev2'][1];
891 if(!$rev1){
892 $rev1 = $rev2;
893 unset($rev2);
895 }else{
896 $rev2 = (int) $_REQUEST['rev2'];
899 if($text){ // compare text to the most current revision
900 $l_rev = '';
901 $l_text = rawWiki($ID,'');
902 $l_head = '<a class="wikilink1" href="'.wl($ID).'">'.
903 $ID.' '.dformat((int) @filemtime(wikiFN($ID))).'</a> '.
904 $lang['current'];
906 $r_rev = '';
907 $r_text = cleanText($text);
908 $r_head = $lang['yours'];
909 }else{
910 if($rev1 && $rev2){ // two specific revisions wanted
911 // make sure order is correct (older on the left)
912 if($rev1 < $rev2){
913 $l_rev = $rev1;
914 $r_rev = $rev2;
915 }else{
916 $l_rev = $rev2;
917 $r_rev = $rev1;
919 }elseif($rev1){ // single revision given, compare to current
920 $r_rev = '';
921 $l_rev = $rev1;
922 }else{ // no revision was given, compare previous to current
923 $r_rev = '';
924 $revs = getRevisions($ID, 0, 1);
925 $l_rev = $revs[0];
926 $REV = $l_rev; // store revision back in $REV
929 // when both revisions are empty then the page was created just now
930 if(!$l_rev && !$r_rev){
931 $l_text = '';
932 }else{
933 $l_text = rawWiki($ID,$l_rev);
935 $r_text = rawWiki($ID,$r_rev);
937 if(!$l_rev){
938 $l_head = '&mdash;';
939 }else{
940 $l_info = getRevisionInfo($ID,$l_rev,true);
941 if($l_info['user']){
942 $l_user = editorinfo($l_info['user']);
943 if(auth_ismanager()) $l_user .= ' ('.$l_info['ip'].')';
944 } else {
945 $l_user = $l_info['ip'];
947 $l_user = '<span class="user">'.$l_user.'</span>';
948 $l_sum = ($l_info['sum']) ? '<span class="sum">'.hsc($l_info['sum']).'</span>' : '';
949 if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $l_minor = 'class="minor"';
951 $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'.
952 $ID.' ['.dformat($l_rev).']</a>'.
953 '<br />'.$l_user.' '.$l_sum;
956 if($r_rev){
957 $r_info = getRevisionInfo($ID,$r_rev,true);
958 if($r_info['user']){
959 $r_user = editorinfo($r_info['user']);
960 if(auth_ismanager()) $r_user .= ' ('.$r_info['ip'].')';
961 } else {
962 $r_user = $r_info['ip'];
964 $r_user = '<span class="user">'.$r_user.'</span>';
965 $r_sum = ($r_info['sum']) ? '<span class="sum">'.hsc($r_info['sum']).'</span>' : '';
966 if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"';
968 $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'.
969 $ID.' ['.dformat($r_rev).']</a>'.
970 '<br />'.$r_user.' '.$r_sum;
971 }elseif($_rev = @filemtime(wikiFN($ID))){
972 $_info = getRevisionInfo($ID,$_rev,true);
973 if($_info['user']){
974 $_user = editorinfo($_info['user']);
975 if(auth_ismanager()) $_user .= ' ('.$_info['ip'].')';
976 } else {
977 $_user = $_info['ip'];
979 $_user = '<span class="user">'.$_user.'</span>';
980 $_sum = ($_info['sum']) ? '<span class="sum">'.hsc($_info['sum']).'</span>' : '';
981 if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"';
983 $r_head = '<a class="wikilink1" href="'.wl($ID).'">'.
984 $ID.' ['.dformat($_rev).']</a> '.
985 '('.$lang['current'].')'.
986 '<br />'.$_user.' '.$_sum;
987 }else{
988 $r_head = '&mdash; ('.$lang['current'].')';
992 $df = new Diff(explode("\n",htmlspecialchars($l_text)),
993 explode("\n",htmlspecialchars($r_text)));
995 $tdf = new TableDiffFormatter();
996 if($intro) print p_locale_xhtml('diff');
998 <table class="diff">
999 <tr>
1000 <th colspan="2" <?php echo $l_minor?>>
1001 <?php echo $l_head?>
1002 </th>
1003 <th colspan="2" <?php echo $r_minor?>>
1004 <?php echo $r_head?>
1005 </th>
1006 </tr>
1007 <?php echo $tdf->format($df)?>
1008 </table>
1009 <?php
1013 * show warning on conflict detection
1015 * @author Andreas Gohr <andi@splitbrain.org>
1017 function html_conflict($text,$summary){
1018 global $ID;
1019 global $lang;
1021 print p_locale_xhtml('conflict');
1022 $form = new Doku_Form(array('id' => 'dw__editform'));
1023 $form->addHidden('id', $ID);
1024 $form->addHidden('wikitext', $text);
1025 $form->addHidden('summary', $summary);
1026 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s')));
1027 $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel']));
1028 html_form('conflict', $form);
1029 print '<br /><br /><br /><br />'.NL;
1033 * Prints the global message array
1035 * @author Andreas Gohr <andi@splitbrain.org>
1037 function html_msgarea(){
1038 global $MSG;
1039 if(!isset($MSG)) return;
1041 $shown = array();
1042 foreach($MSG as $msg){
1043 $hash = md5($msg['msg']);
1044 if(isset($shown[$hash])) continue; // skip double messages
1045 print '<div class="'.$msg['lvl'].'">';
1046 print $msg['msg'];
1047 print '</div>';
1048 $shown[$hash] = 1;
1053 * Prints the registration form
1055 * @author Andreas Gohr <andi@splitbrain.org>
1057 function html_register(){
1058 global $lang;
1059 global $conf;
1060 global $ID;
1062 print p_locale_xhtml('register');
1063 print '<div class="centeralign">'.NL;
1064 $form = new Doku_Form(array('id' => 'dw__register'));
1065 $form->startFieldset($lang['register']);
1066 $form->addHidden('do', 'register');
1067 $form->addHidden('save', '1');
1068 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], null, 'block', array('size'=>'50')));
1069 if (!$conf['autopasswd']) {
1070 $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50')));
1071 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50')));
1073 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', array('size'=>'50')));
1074 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', array('size'=>'50')));
1075 $form->addElement(form_makeButton('submit', '', $lang['register']));
1076 $form->endFieldset();
1077 html_form('register', $form);
1079 print '</div>'.NL;
1083 * Print the update profile form
1085 * @author Christopher Smith <chris@jalakai.co.uk>
1086 * @author Andreas Gohr <andi@splitbrain.org>
1088 function html_updateprofile(){
1089 global $lang;
1090 global $conf;
1091 global $ID;
1092 global $INFO;
1093 global $auth;
1095 print p_locale_xhtml('updateprofile');
1097 if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
1098 if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
1099 print '<div class="centeralign">'.NL;
1100 $form = new Doku_Form(array('id' => 'dw__register'));
1101 $form->startFieldset($lang['profile']);
1102 $form->addHidden('do', 'profile');
1103 $form->addHidden('save', '1');
1104 $form->addElement(form_makeTextField('fullname', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled')));
1105 $attr = array('size'=>'50');
1106 if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled';
1107 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', $attr));
1108 $attr = array('size'=>'50');
1109 if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled';
1110 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', $attr));
1111 $form->addElement(form_makeTag('br'));
1112 if ($auth->canDo('modPass')) {
1113 $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50')));
1114 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50')));
1116 if ($conf['profileconfirm']) {
1117 $form->addElement(form_makeTag('br'));
1118 $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50')));
1120 $form->addElement(form_makeButton('submit', '', $lang['btn_save']));
1121 $form->addElement(form_makeButton('reset', '', $lang['btn_reset']));
1122 $form->endFieldset();
1123 html_form('updateprofile', $form);
1124 print '</div>'.NL;
1128 * Preprocess edit form data
1130 * @triggers HTML_PAGE_FROMTEMPLATE
1131 * @author Andreas Gohr <andi@splitbrain.org>
1133 function html_edit($text=null,$include='edit'){ //FIXME: include needed?
1134 global $ID;
1135 global $REV;
1136 global $DATE;
1137 global $RANGE;
1138 global $PRE;
1139 global $SUF;
1140 global $INFO;
1141 global $SUM;
1142 global $lang;
1143 global $conf;
1145 //set summary default
1146 if(!$SUM){
1147 if($REV){
1148 $SUM = $lang['restored'];
1149 }elseif(!$INFO['exists']){
1150 $SUM = $lang['created'];
1154 //no text? Load it!
1155 if(!isset($text)){
1156 $pr = false; //no preview mode
1157 if($INFO['exists']){
1158 if($RANGE){
1159 list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
1160 }else{
1161 $text = rawWiki($ID,$REV);
1163 $check = md5($text);
1164 $mod = false;
1165 }else{
1166 //try to load a pagetemplate
1167 $data = array($ID);
1168 $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true);
1169 $check = md5('');
1170 $mod = $text!=='';
1172 }else{
1173 $pr = true; //preview mode
1174 if (isset($_REQUEST['changecheck'])) {
1175 $check = $_REQUEST['changecheck'];
1176 $mod = md5($text)!==$check;
1177 } else {
1178 // Why? Assume default text is unmodified.
1179 $check = md5($text);
1180 $mod = false;
1184 $wr = $INFO['writable'] && !$INFO['locked'];
1185 if($wr){
1186 if ($REV) print p_locale_xhtml('editrev');
1187 print p_locale_xhtml($include);
1188 }else{
1189 // check pseudo action 'source'
1190 if(!actionOK('source')){
1191 msg('Command disabled: source',-1);
1192 return;
1194 print p_locale_xhtml('read');
1196 if(!$DATE) $DATE = $INFO['lastmod'];
1198 $data = compact('wr', 'text', 'mod', 'check');
1199 trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true);
1203 * Display the default edit form
1205 * Is the default action for HTML_EDIT_FORMSELECTION.
1207 * @triggers HTML_EDITFORM_OUTPUT
1209 function html_edit_form($param) {
1210 extract($param);
1211 global $conf;
1212 global $license;
1213 global $lang;
1214 global $REV;
1215 global $DATE;
1216 global $PRE;
1217 global $SUF;
1218 global $INFO;
1219 global $SUM;
1220 global $ID;
1222 <?php if($wr){?>
1223 <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--
1224 <?php /* sets changed to true when previewed */?>
1225 textChanged = <?php ($mod) ? print 'true' : print 'false' ?>;
1226 //--><!]]></script>
1227 <?php } ?>
1228 <div style="width:99%;">
1230 <div class="toolbar">
1231 <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.dformat();?></div>
1232 <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>"
1233 target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div>
1235 </div>
1236 <?php
1237 $form = new Doku_Form(array('id' => 'dw__editform'));
1238 $form->addHidden('id', $ID);
1239 $form->addHidden('rev', $REV);
1240 $form->addHidden('date', $DATE);
1241 $form->addHidden('prefix', $PRE);
1242 $form->addHidden('suffix', $SUF);
1243 $form->addHidden('changecheck', $check);
1244 $attr = array('tabindex'=>'1');
1245 if (!$wr) $attr['readonly'] = 'readonly';
1246 $form->addElement(form_makeWikiText($text, $attr));
1247 $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar')));
1248 $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl')));
1249 $form->addElement(form_makeCloseTag('div'));
1250 if ($wr) {
1251 $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons')));
1252 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4')));
1253 $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5')));
1254 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6')));
1255 $form->addElement(form_makeCloseTag('div'));
1256 $form->addElement(form_makeOpenTag('div', array('class'=>'summary')));
1257 $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2')));
1258 $elem = html_minoredit();
1259 if ($elem) $form->addElement($elem);
1260 $form->addElement(form_makeCloseTag('div'));
1262 $form->addElement(form_makeCloseTag('div'));
1263 if($wr && $conf['license']){
1264 $form->addElement(form_makeOpenTag('div', array('class'=>'license')));
1265 $out = $lang['licenseok'];
1266 $out .= '<a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"';
1267 if(isset($conf['target']['external'])) $out .= ' target="'.$conf['target']['external'].'"';
1268 $out .= '> '.$license[$conf['license']]['name'].'</a>';
1269 $form->addElement($out);
1270 $form->addElement(form_makeCloseTag('div'));
1272 html_form('edit', $form);
1273 print '</div>'.NL;
1277 * Adds a checkbox for minor edits for logged in users
1279 * @author Andreas Gohr <andi@splitbrain.org>
1281 function html_minoredit(){
1282 global $conf;
1283 global $lang;
1284 // minor edits are for logged in users only
1285 if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
1286 return false;
1289 $p = array();
1290 $p['tabindex'] = 3;
1291 if(!empty($_REQUEST['minor'])) $p['checked']='checked';
1292 return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p);
1296 * prints some debug info
1298 * @author Andreas Gohr <andi@splitbrain.org>
1300 function html_debug(){
1301 global $conf;
1302 global $lang;
1303 global $auth;
1304 global $INFO;
1306 //remove sensitive data
1307 $cnf = $conf;
1308 debug_guard($cnf);
1309 $nfo = $INFO;
1310 debug_guard($nfo);
1311 $ses = $_SESSION;
1312 debug_guard($ses);
1314 print '<html><body>';
1316 print '<p>When reporting bugs please send all the following ';
1317 print 'output as a mail to andi@splitbrain.org ';
1318 print 'The best way to do this is to save this page in your browser</p>';
1320 print '<b>$INFO:</b><pre>';
1321 print_r($nfo);
1322 print '</pre>';
1324 print '<b>$_SERVER:</b><pre>';
1325 print_r($_SERVER);
1326 print '</pre>';
1328 print '<b>$conf:</b><pre>';
1329 print_r($cnf);
1330 print '</pre>';
1332 print '<b>DOKU_BASE:</b><pre>';
1333 print DOKU_BASE;
1334 print '</pre>';
1336 print '<b>abs DOKU_BASE:</b><pre>';
1337 print DOKU_URL;
1338 print '</pre>';
1340 print '<b>rel DOKU_BASE:</b><pre>';
1341 print dirname($_SERVER['PHP_SELF']).'/';
1342 print '</pre>';
1344 print '<b>PHP Version:</b><pre>';
1345 print phpversion();
1346 print '</pre>';
1348 print '<b>locale:</b><pre>';
1349 print setlocale(LC_ALL,0);
1350 print '</pre>';
1352 print '<b>encoding:</b><pre>';
1353 print $lang['encoding'];
1354 print '</pre>';
1356 if($auth){
1357 print '<b>Auth backend capabilities:</b><pre>';
1358 print_r($auth->cando);
1359 print '</pre>';
1362 print '<b>$_SESSION:</b><pre>';
1363 print_r($ses);
1364 print '</pre>';
1366 print '<b>Environment:</b><pre>';
1367 print_r($_ENV);
1368 print '</pre>';
1370 print '<b>PHP settings:</b><pre>';
1371 $inis = ini_get_all();
1372 print_r($inis);
1373 print '</pre>';
1375 print '</body></html>';
1379 * List available Administration Tasks
1381 * @author Andreas Gohr <andi@splitbrain.org>
1382 * @author HÃ¥kan Sandell <hakan.sandell@home.se>
1384 function html_admin(){
1385 global $ID;
1386 global $INFO;
1387 global $lang;
1388 global $conf;
1389 global $auth;
1391 // build menu of admin functions from the plugins that handle them
1392 $pluginlist = plugin_list('admin');
1393 $menu = array();
1394 foreach ($pluginlist as $p) {
1395 if($obj =& plugin_load('admin',$p) === null) continue;
1397 // check permissions
1398 if($obj->forAdminOnly() && !$INFO['isadmin']) continue;
1400 $menu[$p] = array('plugin' => $p,
1401 'prompt' => $obj->getMenuText($conf['lang']),
1402 'sort' => $obj->getMenuSort()
1406 print p_locale_xhtml('admin');
1408 // Admin Tasks
1409 if($INFO['isadmin']){
1410 ptln('<ul class="admin_tasks">');
1412 if($menu['usermanager'] && $auth && $auth->canDo('getUsers')){
1413 ptln(' <li class="admin_usermanager"><div class="li">'.
1414 '<a href="'.wl($ID, array('do' => 'admin','page' => 'usermanager')).'">'.
1415 $menu['usermanager']['prompt'].'</a></div></li>');
1417 unset($menu['usermanager']);
1419 if($menu['acl']){
1420 ptln(' <li class="admin_acl"><div class="li">'.
1421 '<a href="'.wl($ID, array('do' => 'admin','page' => 'acl')).'">'.
1422 $menu['acl']['prompt'].'</a></div></li>');
1424 unset($menu['acl']);
1426 if($menu['plugin']){
1427 ptln(' <li class="admin_plugin"><div class="li">'.
1428 '<a href="'.wl($ID, array('do' => 'admin','page' => 'plugin')).'">'.
1429 $menu['plugin']['prompt'].'</a></div></li>');
1431 unset($menu['plugin']);
1433 if($menu['config']){
1434 ptln(' <li class="admin_config"><div class="li">'.
1435 '<a href="'.wl($ID, array('do' => 'admin','page' => 'config')).'">'.
1436 $menu['config']['prompt'].'</a></div></li>');
1438 unset($menu['config']);
1440 ptln('</ul>');
1442 // Manager Tasks
1443 ptln('<ul class="admin_tasks">');
1445 if($menu['revert']){
1446 ptln(' <li class="admin_revert"><div class="li">'.
1447 '<a href="'.wl($ID, array('do' => 'admin','page' => 'revert')).'">'.
1448 $menu['revert']['prompt'].'</a></div></li>');
1450 unset($menu['revert']);
1452 if($menu['popularity']){
1453 ptln(' <li class="admin_popularity"><div class="li">'.
1454 '<a href="'.wl($ID, array('do' => 'admin','page' => 'popularity')).'">'.
1455 $menu['popularity']['prompt'].'</a></div></li>');
1457 unset($menu['popularity']);
1459 ptln('</ul>');
1461 // print the rest as sorted list
1462 if(count($menu)){
1463 usort($menu, 'p_sort_modes');
1464 // output the menu
1465 ptln('<div class="clearer"></div>');
1466 print p_locale_xhtml('adminplugins');
1467 ptln('<ul>');
1468 foreach ($menu as $item) {
1469 if (!$item['prompt']) continue;
1470 ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>');
1472 ptln('</ul>');
1477 * Form to request a new password for an existing account
1479 * @author Benoit Chesneau <benoit@bchesneau.info>
1481 function html_resendpwd() {
1482 global $lang;
1483 global $conf;
1484 global $ID;
1486 print p_locale_xhtml('resendpwd');
1487 print '<div class="centeralign">'.NL;
1488 $form = new Doku_Form(array('id' => 'dw__resendpwd'));
1489 $form->startFieldset($lang['resendpwd']);
1490 $form->addHidden('do', 'resendpwd');
1491 $form->addHidden('save', '1');
1492 $form->addElement(form_makeTag('br'));
1493 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block'));
1494 $form->addElement(form_makeTag('br'));
1495 $form->addElement(form_makeTag('br'));
1496 $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd']));
1497 $form->endFieldset();
1498 html_form('resendpwd', $form);
1499 print '</div>'.NL;
1503 * Return the TOC rendered to XHTML
1505 * @author Andreas Gohr <andi@splitbrain.org>
1507 function html_TOC($toc){
1508 if(!count($toc)) return '';
1509 global $lang;
1510 $out = '<!-- TOC START -->'.DOKU_LF;
1511 $out .= '<div class="toc">'.DOKU_LF;
1512 $out .= '<div class="tocheader toctoggle" id="toc__header">';
1513 $out .= $lang['toc'];
1514 $out .= '</div>'.DOKU_LF;
1515 $out .= '<div id="toc__inside">'.DOKU_LF;
1516 $out .= html_buildlist($toc,'toc','html_list_toc');
1517 $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
1518 $out .= '<!-- TOC END -->'.DOKU_LF;
1519 return $out;
1523 * Callback for html_buildlist
1525 function html_list_toc($item){
1526 if(isset($item['hid'])){
1527 $link = '#'.$item['hid'];
1528 }else{
1529 $link = $item['link'];
1532 return '<span class="li"><a href="'.$link.'" class="toc">'.
1533 hsc($item['title']).'</a></span>';
1537 * Helper function to build TOC items
1539 * Returns an array ready to be added to a TOC array
1541 * @param string $link - where to link (if $hash set to '#' it's a local anchor)
1542 * @param string $text - what to display in the TOC
1543 * @param int $level - nesting level
1544 * @param string $hash - is prepended to the given $link, set blank if you want full links
1546 function html_mktocitem($link, $text, $level, $hash='#'){
1547 global $conf;
1548 return array( 'link' => $hash.$link,
1549 'title' => $text,
1550 'type' => 'ul',
1551 'level' => $level);
1555 * Output a Doku_Form object.
1556 * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT
1558 * @author Tom N Harris <tnharris@whoopdedo.org>
1560 function html_form($name, &$form) {
1561 // Safety check in case the caller forgets.
1562 $form->endFieldset();
1563 trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false);
1567 * Form print function.
1568 * Just calls printForm() on the data object.
1570 function html_form_output($data) {
1571 $data->printForm();
1575 * Embed a flash object in HTML
1577 * This will create the needed HTML to embed a flash movie in a cross browser
1578 * compatble way using valid XHTML
1580 * The parameters $params, $flashvars and $atts need to be associative arrays.
1581 * No escaping needs to be done for them. The alternative content *has* to be
1582 * escaped because it is used as is. If no alternative content is given
1583 * $lang['noflash'] is used.
1585 * @author Andreas Gohr <andi@splitbrain.org>
1586 * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml
1588 * @param string $swf - the SWF movie to embed
1589 * @param int $width - width of the flash movie in pixels
1590 * @param int $height - height of the flash movie in pixels
1591 * @param array $params - additional parameters (<param>)
1592 * @param array $flashvars - parameters to be passed in the flashvar parameter
1593 * @param array $atts - additional attributes for the <object> tag
1594 * @param string $alt - alternative content (is NOT automatically escaped!)
1595 * @returns string - the XHTML markup
1597 function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){
1598 global $lang;
1600 $out = '';
1602 // prepare the object attributes
1603 if(is_null($atts)) $atts = array();
1604 $atts['width'] = (int) $width;
1605 $atts['height'] = (int) $height;
1606 if(!$atts['width']) $atts['width'] = 425;
1607 if(!$atts['height']) $atts['height'] = 350;
1609 // add object attributes for standard compliant browsers
1610 $std = $atts;
1611 $std['type'] = 'application/x-shockwave-flash';
1612 $std['data'] = $swf;
1614 // add object attributes for IE
1615 $ie = $atts;
1616 $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
1618 // open object (with conditional comments)
1619 $out .= '<!--[if !IE]> -->'.NL;
1620 $out .= '<object '.buildAttributes($std).'>'.NL;
1621 $out .= '<!-- <![endif]-->'.NL;
1622 $out .= '<!--[if IE]>'.NL;
1623 $out .= '<object '.buildAttributes($ie).'>'.NL;
1624 $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL;
1625 $out .= '<!--><!-- -->'.NL;
1627 // print params
1628 if(is_array($params)) foreach($params as $key => $val){
1629 $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL;
1632 // add flashvars
1633 if(is_array($flashvars)){
1634 $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL;
1637 // alternative content
1638 if($alt){
1639 $out .= $alt.NL;
1640 }else{
1641 $out .= $lang['noflash'].NL;
1644 // finish
1645 $out .= '</object>'.NL;
1646 $out .= '<!-- <![endif]-->'.NL;
1648 return $out;