1<?php 2/** 3 * HTML output functions 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/'); 10if(!defined('NL')) define('NL',"\n"); 11require_once(DOKU_INC.'inc/parserutils.php'); 12require_once(DOKU_INC.'inc/form.php'); 13 14/** 15 * Convenience function to quickly build a wikilink 16 * 17 * @author Andreas Gohr <andi@splitbrain.org> 18 */ 19function html_wikilink($id,$name=NULL,$search=''){ 20 static $xhtml_renderer = NULL; 21 if(is_null($xhtml_renderer)){ 22 require_once(DOKU_INC.'inc/parser/xhtml.php'); 23 $xhtml_renderer = new Doku_Renderer_xhtml(); 24 } 25 26 return $xhtml_renderer->internallink($id,$name,$search,true); 27} 28 29/** 30 * Helps building long attribute lists 31 * 32 * @author Andreas Gohr <andi@splitbrain.org> 33 */ 34function html_attbuild($attributes){ 35 $ret = ''; 36 foreach ( $attributes as $key => $value ) { 37 $ret .= $key.'="'.formtext($value).'" '; 38 } 39 return trim($ret); 40} 41 42/** 43 * The loginform 44 * 45 * @author Andreas Gohr <andi@splitbrain.org> 46 */ 47function html_login(){ 48 global $lang; 49 global $conf; 50 global $ID; 51 global $auth; 52 53 print p_locale_xhtml('login'); 54 print '<div class="centeralign">'.NL; 55 $form = new Doku_Form('dw__login'); 56 $form->startFieldset($lang['btn_login']); 57 $form->addHidden('id', $ID); 58 $form->addHidden('do', 'login'); 59 $form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block')); 60 $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); 61 if($conf['rememberme']) { 62 $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); 63 } 64 $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); 65 $form->endFieldset(); 66 html_form('login', $form); 67 68 if($auth && $auth->canDo('addUser') && actionOK('register')){ 69 print '<p>'; 70 print $lang['reghere']; 71 print ': <a href="'.wl($ID,'do=register').'" rel="nofollow" class="wikilink1">'.$lang['register'].'</a>'; 72 print '</p>'; 73 } 74 75 if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { 76 print '<p>'; 77 print $lang['pwdforget']; 78 print ': <a href="'.wl($ID,'do=resendpwd').'" rel="nofollow" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'; 79 print '</p>'; 80 } 81 print '</div>'.NL; 82} 83 84/** 85 * prints a section editing button 86 * used as a callback in html_secedit 87 * 88 * @author Andreas Gohr <andi@splitbrain.org> 89 */ 90function html_secedit_button($matches){ 91 global $ID; 92 global $INFO; 93 94 $section = $matches[2]; 95 $name = $matches[1]; 96 97 $secedit = ''; 98 $secedit .= '<div class="secedit">'; 99 $secedit .= html_btn('secedit',$ID,'', 100 array('do' => 'edit', 101 'lines' => "$section", 102 'rev' => $INFO['lastmod']), 103 'post', $name); 104 $secedit .= '</div>'; 105 return $secedit; 106} 107 108/** 109 * inserts section edit buttons if wanted or removes the markers 110 * 111 * @author Andreas Gohr <andi@splitbrain.org> 112 */ 113function html_secedit($text,$show=true){ 114 global $INFO; 115 116 if($INFO['writable'] && $show && !$INFO['rev']){ 117 $text = preg_replace_callback('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#', 118 'html_secedit_button', $text); 119 }else{ 120 $text = preg_replace('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#','',$text); 121 } 122 123 return $text; 124} 125 126/** 127 * Just the back to top button (in its own form) 128 * 129 * @author Andreas Gohr <andi@splitbrain.org> 130 */ 131function html_topbtn(){ 132 global $lang; 133 134 $ret = ''; 135 $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>'; 136 137 return $ret; 138} 139 140/** 141 * Displays a button (using its own form) 142 * If tooltip exists, the access key tooltip is replaced. 143 * 144 * @author Andreas Gohr <andi@splitbrain.org> 145 */ 146function html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ 147 global $conf; 148 global $lang; 149 150 $label = $lang['btn_'.$name]; 151 152 $ret = ''; 153 $tip = ''; 154 155 //filter id (without urlencoding) 156 $id = idfilter($id,false); 157 158 //make nice URLs even for buttons 159 if($conf['userewrite'] == 2){ 160 $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 161 }elseif($conf['userewrite']){ 162 $script = DOKU_BASE.$id; 163 }else{ 164 $script = DOKU_BASE.DOKU_SCRIPT; 165 $params['id'] = $id; 166 } 167 168 $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">'; 169 170 if(is_array($params)){ 171 reset($params); 172 while (list($key, $val) = each($params)) { 173 $ret .= '<input type="hidden" name="'.$key.'" '; 174 $ret .= 'value="'.htmlspecialchars($val).'" />'; 175 } 176 } 177 178 if ($tooltip!='') { 179 $tip = htmlspecialchars($tooltip); 180 }else{ 181 $tip = htmlspecialchars($label); 182 } 183 184 $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; 185 if($akey){ 186 $tip .= ' ['.strtoupper($akey).']'; 187 $ret .= 'accesskey="'.htmlspecialchars($label).' '.$akey.'" '; 188 } 189 $ret .= 'title="'.$tip.'" '; 190 $ret .= '/>'; 191 $ret .= '</div></form>'; 192 193 return $ret; 194} 195 196/** 197 * show a wiki page 198 * 199 * @author Andreas Gohr <andi@splitbrain.org> 200 */ 201function html_show($txt=''){ 202 global $ID; 203 global $REV; 204 global $HIGH; 205 global $INFO; 206 //disable section editing for old revisions or in preview 207 if($txt || $REV){ 208 $secedit = false; 209 }else{ 210 $secedit = true; 211 } 212 213 if ($txt){ 214 //PreviewHeader 215 echo '<br id="scroll__here" />'; 216 echo p_locale_xhtml('preview'); 217 echo '<div class="preview">'; 218 $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 219 if($INFO['prependTOC']) $html = tpl_toc(true).$html; 220 echo $html; 221 echo '<div class="clearer"></div>'; 222 echo '</div>'; 223 224 }else{ 225 if ($REV) print p_locale_xhtml('showrev'); 226 $html = p_wiki_xhtml($ID,$REV,true); 227 $html = html_secedit($html,$secedit); 228 if($INFO['prependTOC']) $html = tpl_toc(true).$html; 229 $html = html_hilight($html,$HIGH); 230 echo $html; 231 } 232} 233 234/** 235 * ask the user about how to handle an exisiting draft 236 * 237 * @author Andreas Gohr <andi@splitbrain.org> 238 */ 239function html_draft(){ 240 global $INFO; 241 global $ID; 242 global $lang; 243 global $conf; 244 $draft = unserialize(io_readFile($INFO['draft'],false)); 245 $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); 246 247 print p_locale_xhtml('draft'); 248 $form = new Doku_Form('dw__editform'); 249 $form->addHidden('id', $ID); 250 $form->addHidden('date', $draft['date']); 251 $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); 252 $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); 253 $form->addElement($lang['draftdate'].' '. strftime($conf['dformat'],filemtime($INFO['draft']))); 254 $form->addElement(form_makeCloseTag('div')); 255 $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); 256 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); 257 $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); 258 html_form('draft', $form); 259} 260 261/** 262 * Highlights searchqueries in HTML code 263 * 264 * @author Andreas Gohr <andi@splitbrain.org> 265 * @author Harry Fuecks <hfuecks@gmail.com> 266 */ 267function html_hilight($html,$phrases){ 268 $regex = join('|',array_map('preg_quote_cb',array_filter((array) $phrases))); 269 270 if ($regex === '') return $html; 271 $html = preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); 272 return $html; 273} 274 275/** 276 * Callback used by html_hilight() 277 * 278 * @author Harry Fuecks <hfuecks@gmail.com> 279 */ 280function html_hilight_callback($m) { 281 $hlight = unslash($m[0]); 282 if ( !isset($m[2])) { 283 $hlight = '<span class="search_hit">'.$hlight.'</span>'; 284 } 285 return $hlight; 286} 287 288/** 289 * Run a search and display the result 290 * 291 * @author Andreas Gohr <andi@splitbrain.org> 292 */ 293function html_search(){ 294 require_once(DOKU_INC.'inc/search.php'); 295 require_once(DOKU_INC.'inc/fulltext.php'); 296 global $conf; 297 global $QUERY; 298 global $ID; 299 global $lang; 300 301 print p_locale_xhtml('searchpage'); 302 flush(); 303 304 //check if search is restricted to namespace 305 if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) { 306 $id = cleanID($match[1]); 307 if(empty($id)) { 308 print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 309 flush(); 310 return; 311 } 312 } else { 313 $id = cleanID($QUERY); 314 } 315 316 //show progressbar 317 print '<div class="centeralign" id="dw__loading">'.NL; 318 print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 319 print 'showLoadBar();'.NL; 320 print '//--><!]]></script>'.NL; 321 print '<br /></div>'.NL; 322 flush(); 323 324 //do quick pagesearch 325 $data = array(); 326 327 $data = ft_pageLookup($id); 328 if(count($data)){ 329 print '<div class="search_quickresult">'; 330 print '<h3>'.$lang['quickhits'].':</h3>'; 331 print '<ul class="search_quickhits">'; 332 foreach($data as $id){ 333 print '<li> '; 334 $ns = getNS($id); 335 if($ns){ 336 $name = shorten(noNS($id), ' ('.$ns.')',30); 337 }else{ 338 $name = $id; 339 } 340 print html_wikilink(':'.$id,$name); 341 print '</li> '; 342 } 343 print '</ul> '; 344 //clear float (see http://www.complexspiral.com/publications/containing-floats/) 345 print '<div class="clearer"> </div>'; 346 print '</div>'; 347 } 348 flush(); 349 350 //do fulltext search 351 $data = ft_pageSearch($QUERY,$regex); 352 if(count($data)){ 353 $num = 1; 354 foreach($data as $id => $cnt){ 355 print '<div class="search_result">'; 356 print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$regex); 357 print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 358 if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 359 print '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>'; 360 } 361 print '</div>'; 362 flush(); 363 $num++; 364 } 365 }else{ 366 print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 367 } 368 369 //hide progressbar 370 print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 371 print 'hideLoadBar("dw__loading");'.NL; 372 print '//--><!]]></script>'.NL; 373 flush(); 374} 375 376/** 377 * Display error on locked pages 378 * 379 * @author Andreas Gohr <andi@splitbrain.org> 380 */ 381function html_locked(){ 382 global $ID; 383 global $conf; 384 global $lang; 385 global $INFO; 386 387 $locktime = filemtime(wikiLockFN($ID)); 388 $expire = @strftime($conf['dformat'], $locktime + $conf['locktime'] ); 389 $min = round(($conf['locktime'] - (time() - $locktime) )/60); 390 391 print p_locale_xhtml('locked'); 392 print '<ul>'; 393 print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</div></li>'; 394 print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 395 print '</ul>'; 396} 397 398/** 399 * list old revisions 400 * 401 * @author Andreas Gohr <andi@splitbrain.org> 402 * @author Ben Coburn <btcoburn@silicodon.net> 403 */ 404function html_revisions($first=0){ 405 global $ID; 406 global $INFO; 407 global $conf; 408 global $lang; 409 /* we need to get one additionally log entry to be able to 410 * decide if this is the last page or is there another one. 411 * see html_recent() 412 */ 413 $revisions = getRevisions($ID, $first, $conf['recent']+1); 414 if(count($revisions)==0 && $first!=0){ 415 $first=0; 416 $revisions = getRevisions($ID, $first, $conf['recent']+1);; 417 } 418 $hasNext = false; 419 if (count($revisions)>$conf['recent']) { 420 $hasNext = true; 421 array_pop($revisions); // remove extra log entry 422 } 423 424 $date = @strftime($conf['dformat'],$INFO['lastmod']); 425 426 print p_locale_xhtml('revisions'); 427 print '<form action="'.wl($ID).'" method="post" id="page__revisions">'; 428 print '<ul>'; 429 if($INFO['exists'] && $first==0){ 430 print (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>'; 431 print '<div class="li">'; 432 print '<input type="checkbox" name="rev2[]" value="current" /> '; 433 434 print $date; 435 436 print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 437 438 print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> '; 439 440 print ' – '; 441 print htmlspecialchars($INFO['sum']); 442 print ' <span class="user">'; 443 print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor']); 444 print '</span> '; 445 446 print '('.$lang['current'].')'; 447 print '</div>'; 448 print '</li>'; 449 } 450 451 foreach($revisions as $rev){ 452 $date = strftime($conf['dformat'],$rev); 453 $info = getRevisionInfo($ID,$rev,true); 454 $exists = page_exists($ID,$rev); 455 456 print ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>'; 457 print '<div class="li">'; 458 if($exists){ 459 print '<input type="checkbox" name="rev2[]" value="'.$rev.'" /> '; 460 }else{ 461 print '<img src="'.DOKU_BASE.'lib/images/blank.gif" width="14" height="11" alt="" /> '; 462 } 463 print $date; 464 465 if($exists){ 466 print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">'; 467 $p = array(); 468 $p['src'] = DOKU_BASE.'lib/images/diff.png'; 469 $p['width'] = 15; 470 $p['height'] = 11; 471 $p['title'] = $lang['diff']; 472 $p['alt'] = $lang['diff']; 473 $att = buildAttributes($p); 474 print "<img $att />"; 475 print '</a> '; 476 477 print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a>'; 478 }else{ 479 print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 480 print $ID; 481 } 482 483 print ' – '; 484 print htmlspecialchars($info['sum']); 485 print ' <span class="user">'; 486 if($info['user']){ 487 print editorinfo($info['user']); 488 }else{ 489 print $info['ip']; 490 } 491 print '</span>'; 492 493 print '</div>'; 494 print '</li>'; 495 } 496 print '</ul>'; 497 print '<input name="do[diff]" type="submit" value="'.$lang['diff2'].'" class="button" />'; 498 print '</form>'; 499 500 print '<div class="pagenav">'; 501 $last = $first + $conf['recent']; 502 if ($first > 0) { 503 $first -= $conf['recent']; 504 if ($first < 0) $first = 0; 505 print '<div class="pagenav-prev">'; 506 print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first)); 507 print '</div>'; 508 } 509 if ($hasNext) { 510 print '<div class="pagenav-next">'; 511 print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last)); 512 print '</div>'; 513 } 514 print '</div>'; 515 516} 517 518/** 519 * display recent changes 520 * 521 * @author Andreas Gohr <andi@splitbrain.org> 522 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 523 * @author Ben Coburn <btcoburn@silicodon.net> 524 */ 525function html_recent($first=0){ 526 global $conf; 527 global $lang; 528 global $ID; 529 /* we need to get one additionally log entry to be able to 530 * decide if this is the last page or is there another one. 531 * This is the cheapest solution to get this information. 532 */ 533 $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 534 if(count($recents) == 0 && $first != 0){ 535 $first=0; 536 $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 537 } 538 $hasNext = false; 539 if (count($recents)>$conf['recent']) { 540 $hasNext = true; 541 array_pop($recents); // remove extra log entry 542 } 543 544 print p_locale_xhtml('recent'); 545 546 if (getNS($ID) != '') 547 print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>'; 548 549 $form = new Doku_Form('dw__recent', script(), 'get'); 550 $form->addHidden('sectok', null); 551 $form->addHidden('do', 'recent'); 552 $form->addHidden('id', $ID); 553 $form->addElement(form_makeOpenTag('ul')); 554 555 foreach($recents as $recent){ 556 $date = strftime($conf['dformat'],$recent['date']); 557 if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 558 $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 559 else 560 $form->addElement(form_makeOpenTag('li')); 561 562 $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 563 564 $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 565 $form->addElement($date); 566 $form->addElement(form_makeCloseTag('span')); 567 568 $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => wl($recent['id'],"do=diff")))); 569 $form->addElement(form_makeTag('img', array( 570 'src' => DOKU_BASE.'lib/images/diff.png', 571 'width' => 15, 572 'height'=> 11, 573 'title' => $lang['diff'], 574 'alt' => $lang['diff'] 575 ))); 576 $form->addElement(form_makeCloseTag('a')); 577 578 $form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => wl($recent['id'],"do=revisions")))); 579 $form->addElement(form_makeTag('img', array( 580 'src' => DOKU_BASE.'lib/images/history.png', 581 'width' => 12, 582 'height'=> 14, 583 'title' => $lang['btn_revs'], 584 'alt' => $lang['btn_revs'] 585 ))); 586 $form->addElement(form_makeCloseTag('a')); 587 588 $form->addElement(html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id'])); 589 590 $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 591 $form->addElement(' – '.htmlspecialchars($recent['sum'])); 592 $form->addElement(form_makeCloseTag('span')); 593 594 $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 595 if($recent['user']){ 596 $form->addElement(editorinfo($recent['user'])); 597 }else{ 598 $form->addElement($recent['ip']); 599 } 600 $form->addElement(form_makeCloseTag('span')); 601 602 $form->addElement(form_makeCloseTag('div')); 603 $form->addElement(form_makeCloseTag('li')); 604 } 605 $form->addElement(form_makeCloseTag('ul')); 606 607 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav'))); 608 $last = $first + $conf['recent']; 609 if ($first > 0) { 610 $first -= $conf['recent']; 611 if ($first < 0) $first = 0; 612 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev'))); 613 $form->addElement(form_makeTag('input', array( 614 'type' => 'submit', 615 'name' => 'first['.$first.']', 616 'value' => $lang['btn_newer'] 617 ))); 618 $form->addElement(form_makeCloseTag('div')); 619 } 620 if ($hasNext) { 621 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next'))); 622 $form->addElement(form_makeTag('input', array( 623 'type' => 'submit', 624 'name' => 'first['.$last.']', 625 'value' => $lang['btn_older'] 626 ))); 627 $form->addElement(form_makeCloseTag('div')); 628 } 629 $form->addElement(form_makeCloseTag('div')); 630 html_form('recent', $form); 631} 632 633/** 634 * Display page index 635 * 636 * @author Andreas Gohr <andi@splitbrain.org> 637 */ 638function html_index($ns){ 639 require_once(DOKU_INC.'inc/search.php'); 640 global $conf; 641 global $ID; 642 $dir = $conf['datadir']; 643 $ns = cleanID($ns); 644 #fixme use appropriate function 645 if(empty($ns)){ 646 $ns = dirname(str_replace(':','/',$ID)); 647 if($ns == '.') $ns =''; 648 } 649 $ns = utf8_encodeFN(str_replace(':','/',$ns)); 650 651 echo p_locale_xhtml('index'); 652 echo '<div id="index__tree">'; 653 654 $data = array(); 655 search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 656 echo html_buildlist($data,'idx','html_list_index','html_li_index'); 657 658 echo '</div>'; 659} 660 661/** 662 * Index item formatter 663 * 664 * User function for html_buildlist() 665 * 666 * @author Andreas Gohr <andi@splitbrain.org> 667 */ 668function html_list_index($item){ 669 global $ID; 670 $ret = ''; 671 $base = ':'.$item['id']; 672 $base = substr($base,strrpos($base,':')+1); 673 if($item['type']=='d'){ 674 $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>'; 675 $ret .= $base; 676 $ret .= '</strong></a>'; 677 }else{ 678 $ret .= html_wikilink(':'.$item['id']); 679 } 680 return $ret; 681} 682 683/** 684 * Index List item 685 * 686 * This user function is used in html_build_lidt to build the 687 * <li> tags for namespaces when displaying the page index 688 * it gives different classes to opened or closed "folders" 689 * 690 * @author Andreas Gohr <andi@splitbrain.org> 691 */ 692function html_li_index($item){ 693 if($item['type'] == "f"){ 694 return '<li class="level'.$item['level'].'">'; 695 }elseif($item['open']){ 696 return '<li class="open">'; 697 }else{ 698 return '<li class="closed">'; 699 } 700} 701 702/** 703 * Default List item 704 * 705 * @author Andreas Gohr <andi@splitbrain.org> 706 */ 707function html_li_default($item){ 708 return '<li class="level'.$item['level'].'">'; 709} 710 711/** 712 * Build an unordered list 713 * 714 * Build an unordered list from the given $data array 715 * Each item in the array has to have a 'level' property 716 * the item itself gets printed by the given $func user 717 * function. The second and optional function is used to 718 * print the <li> tag. Both user function need to accept 719 * a single item. 720 * 721 * Both user functions can be given as array to point to 722 * a member of an object. 723 * 724 * @author Andreas Gohr <andi@splitbrain.org> 725 */ 726function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 727 $level = 0; 728 $opens = 0; 729 $ret = ''; 730 731 foreach ($data as $item){ 732 733 if( $item['level'] > $level ){ 734 //open new list 735 for($i=0; $i<($item['level'] - $level); $i++){ 736 if ($i) $ret .= "<li class=\"clear\">\n"; 737 $ret .= "\n<ul class=\"$class\">\n"; 738 } 739 }elseif( $item['level'] < $level ){ 740 //close last item 741 $ret .= "</li>\n"; 742 for ($i=0; $i<($level - $item['level']); $i++){ 743 //close higher lists 744 $ret .= "</ul>\n</li>\n"; 745 } 746 }else{ 747 //close last item 748 $ret .= "</li>\n"; 749 } 750 751 //remember current level 752 $level = $item['level']; 753 754 //print item 755 $ret .= call_user_func($lifunc,$item); 756 $ret .= '<div class="li">'; 757 758 $ret .= call_user_func($func,$item); 759 $ret .= '</div>'; 760 } 761 762 //close remaining items and lists 763 for ($i=0; $i < $level; $i++){ 764 $ret .= "</li></ul>\n"; 765 } 766 767 return $ret; 768} 769 770/** 771 * display backlinks 772 * 773 * @author Andreas Gohr <andi@splitbrain.org> 774 * @author Michael Klier <chi@chimeric.de> 775 */ 776function html_backlinks(){ 777 require_once(DOKU_INC.'inc/fulltext.php'); 778 global $ID; 779 global $conf; 780 global $lang; 781 782 print p_locale_xhtml('backlinks'); 783 784 $data = ft_backlinks($ID); 785 786 if(!empty($data)) { 787 print '<ul class="idx">'; 788 foreach($data as $blink){ 789 print '<li><div class="li">'; 790 print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 791 print '</div></li>'; 792 } 793 print '</ul>'; 794 } else { 795 print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>'; 796 } 797} 798 799/** 800 * show diff 801 * 802 * @author Andreas Gohr <andi@splitbrain.org> 803 */ 804function html_diff($text='',$intro=true){ 805 require_once(DOKU_INC.'inc/DifferenceEngine.php'); 806 global $ID; 807 global $REV; 808 global $lang; 809 global $conf; 810 811 // we're trying to be clever here, revisions to compare can be either 812 // given as rev and rev2 parameters, with rev2 being optional. Or in an 813 // array in rev2. 814 $rev1 = $REV; 815 816 if(is_array($_REQUEST['rev2'])){ 817 $rev1 = (int) $_REQUEST['rev2'][0]; 818 $rev2 = (int) $_REQUEST['rev2'][1]; 819 820 if(!$rev1){ 821 $rev1 = $rev2; 822 unset($rev2); 823 } 824 }else{ 825 $rev2 = (int) $_REQUEST['rev2']; 826 } 827 828 if($text){ // compare text to the most current revision 829 $l_rev = ''; 830 $l_text = rawWiki($ID,''); 831 $l_head = '<a class="wikilink1" href="'.wl($ID).'">'. 832 $ID.' '.strftime($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 833 $lang['current']; 834 835 $r_rev = ''; 836 $r_text = cleanText($text); 837 $r_head = $lang['yours']; 838 }else{ 839 if($rev1 && $rev2){ // two specific revisions wanted 840 // make sure order is correct (older on the left) 841 if($rev1 < $rev2){ 842 $l_rev = $rev1; 843 $r_rev = $rev2; 844 }else{ 845 $l_rev = $rev2; 846 $r_rev = $rev1; 847 } 848 }elseif($rev1){ // single revision given, compare to current 849 $r_rev = ''; 850 $l_rev = $rev1; 851 }else{ // no revision was given, compare previous to current 852 $r_rev = ''; 853 $revs = getRevisions($ID, 0, 1); 854 $l_rev = $revs[0]; 855 } 856 857 // when both revisions are empty then the page was created just now 858 if(!$l_rev && !$r_rev){ 859 $l_text = ''; 860 }else{ 861 $l_text = rawWiki($ID,$l_rev); 862 } 863 $r_text = rawWiki($ID,$r_rev); 864 865 866 if(!$l_rev){ 867 $l_head = '—'; 868 }else{ 869 $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'. 870 $ID.' '.strftime($conf['dformat'],$l_rev).'</a>'; 871 } 872 873 if($r_rev){ 874 $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'. 875 $ID.' '.strftime($conf['dformat'],$r_rev).'</a>'; 876 }elseif($_rev = @filemtime(wikiFN($ID))){ 877 $r_head = '<a class="wikilink1" href="'.wl($ID).'">'. 878 $ID.' '.strftime($conf['dformat'],$_rev).'</a> '. 879 $lang['current']; 880 }else{ 881 $r_head = '— '.$lang['current']; 882 } 883 } 884 885 $df = new Diff(explode("\n",htmlspecialchars($l_text)), 886 explode("\n",htmlspecialchars($r_text))); 887 888 $tdf = new TableDiffFormatter(); 889 if($intro) print p_locale_xhtml('diff'); 890 ?> 891 <table class="diff"> 892 <tr> 893 <th colspan="2"> 894 <?php echo $l_head?> 895 </th> 896 <th colspan="2"> 897 <?php echo $r_head?> 898 </th> 899 </tr> 900 <?php echo $tdf->format($df)?> 901 </table> 902 <?php 903} 904 905/** 906 * show warning on conflict detection 907 * 908 * @author Andreas Gohr <andi@splitbrain.org> 909 */ 910function html_conflict($text,$summary){ 911 global $ID; 912 global $lang; 913 914 print p_locale_xhtml('conflict'); 915 $form = new Doku_Form('dw__editform'); 916 $form->addHidden('id', $ID); 917 $form->addHidden('wikitext', $text); 918 $form->addHidden('summary', $summary); 919 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s'))); 920 $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'])); 921 html_form('conflict', $form); 922 print '<br /><br /><br /><br />'.NL; 923} 924 925/** 926 * Prints the global message array 927 * 928 * @author Andreas Gohr <andi@splitbrain.org> 929 */ 930function html_msgarea(){ 931 global $MSG; 932 933 if(!isset($MSG)) return; 934 935 foreach($MSG as $msg){ 936 print '<div class="'.$msg['lvl'].'">'; 937 print $msg['msg']; 938 print '</div>'; 939 } 940} 941 942/** 943 * Prints the registration form 944 * 945 * @author Andreas Gohr <andi@splitbrain.org> 946 */ 947function html_register(){ 948 global $lang; 949 global $conf; 950 global $ID; 951 952 print p_locale_xhtml('register'); 953 print '<div class="centeralign">'.NL; 954 $form = new Doku_Form('dw__register', wl($ID)); 955 $form->startFieldset($lang['register']); 956 $form->addHidden('do', 'register'); 957 $form->addHidden('save', '1'); 958 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], null, 'block', array('size'=>'50'))); 959 if (!$conf['autopasswd']) { 960 $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50'))); 961 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 962 } 963 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', array('size'=>'50'))); 964 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', array('size'=>'50'))); 965 $form->addElement(form_makeButton('submit', '', $lang['register'])); 966 $form->endFieldset(); 967 html_form('register', $form); 968 969 print '</div>'.NL; 970} 971 972/** 973 * Print the update profile form 974 * 975 * @author Christopher Smith <chris@jalakai.co.uk> 976 * @author Andreas Gohr <andi@splitbrain.org> 977 */ 978function html_updateprofile(){ 979 global $lang; 980 global $conf; 981 global $ID; 982 global $INFO; 983 global $auth; 984 985 print p_locale_xhtml('updateprofile'); 986 987 if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 988 if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 989 print '<div class="centeralign">'.NL; 990 $form = new Doku_Form('dw__register', wl($ID)); 991 $form->startFieldset($lang['profile']); 992 $form->addHidden('do', 'profile'); 993 $form->addHidden('save', '1'); 994 $form->addElement(form_makeTextField('fullname', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled'))); 995 $attr = array('size'=>'50'); 996 if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; 997 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', $attr)); 998 $attr = array('size'=>'50'); 999 if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled'; 1000 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', $attr)); 1001 $form->addElement(form_makeTag('br')); 1002 if ($auth->canDo('modPass')) { 1003 $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50'))); 1004 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1005 } 1006 if ($conf['profileconfirm']) { 1007 $form->addElement(form_makeTag('br')); 1008 $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50'))); 1009 } 1010 $form->addElement(form_makeButton('submit', '', $lang['btn_save'])); 1011 $form->addElement(form_makeButton('reset', '', $lang['btn_reset'])); 1012 $form->endFieldset(); 1013 html_form('updateprofile', $form); 1014 print '</div>'.NL; 1015} 1016 1017/** 1018 * This displays the edit form (lots of logic included) 1019 * 1020 * @fixme this is a huge lump of code and should be modularized 1021 * @triggers HTML_PAGE_FROMTEMPLATE 1022 * @triggers HTML_EDITFORM_INJECTION 1023 * @author Andreas Gohr <andi@splitbrain.org> 1024 */ 1025function html_edit($text=null,$include='edit'){ //FIXME: include needed? 1026 global $ID; 1027 global $REV; 1028 global $DATE; 1029 global $RANGE; 1030 global $PRE; 1031 global $SUF; 1032 global $INFO; 1033 global $SUM; 1034 global $lang; 1035 global $conf; 1036 global $license; 1037 1038 //set summary default 1039 if(!$SUM){ 1040 if($REV){ 1041 $SUM = $lang['restored']; 1042 }elseif(!$INFO['exists']){ 1043 $SUM = $lang['created']; 1044 } 1045 } 1046 1047 //no text? Load it! 1048 if(!isset($text)){ 1049 $pr = false; //no preview mode 1050 if($INFO['exists']){ 1051 if($RANGE){ 1052 list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 1053 }else{ 1054 $text = rawWiki($ID,$REV); 1055 } 1056 $check = md5($text); 1057 $mod = false; 1058 }else{ 1059 //try to load a pagetemplate 1060 $data = array($ID); 1061 $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); 1062 $check = md5(''); 1063 $mod = $text!==''; 1064 } 1065 }else{ 1066 $pr = true; //preview mode 1067 if (isset($_REQUEST['changecheck'])) { 1068 $check = $_REQUEST['changecheck']; 1069 $mod = md5($text)!==$check; 1070 } else { 1071 // Why? Assume default text is unmodified. 1072 $check = md5($text); 1073 $mod = false; 1074 } 1075 } 1076 1077 $wr = $INFO['writable']; 1078 if($wr){ 1079 if ($REV) print p_locale_xhtml('editrev'); 1080 print p_locale_xhtml($include); 1081 }else{ 1082 // check pseudo action 'source' 1083 if(!actionOK('source')){ 1084 msg('Command disabled: source',-1); 1085 return; 1086 } 1087 print p_locale_xhtml('read'); 1088 } 1089 if(!$DATE) $DATE = $INFO['lastmod']; 1090 1091 1092?> 1093 <div style="width:99%;"> 1094 1095 <div class="toolbar"> 1096 <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.strftime($conf['dformat']);?></div> 1097 <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 1098 target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> 1099 1100 <?php if($wr){?> 1101 <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- 1102 <?php /* sets changed to true when previewed */?> 1103 textChanged = <?php ($mod) ? print 'true' : print 'false' ?>; 1104 //--><!]]></script> 1105 <span id="spell__action"></span> 1106 <div id="spell__suggest"></div> 1107 <?php } ?> 1108 </div> 1109 <div id="spell__result"></div> 1110<?php 1111 $form = new Doku_Form('dw__editform'); 1112 $form->addHidden('id', $ID); 1113 $form->addHidden('rev', $REV); 1114 $form->addHidden('date', $DATE); 1115 $form->addHidden('prefix', $PRE); 1116 $form->addHidden('suffix', $SUF); 1117 $form->addHidden('changecheck', $check); 1118 $attr = array('tabindex'=>'1'); 1119 if (!$wr) $attr['readonly'] = 'readonly'; 1120 $form->addElement(form_makeWikiText($text, $attr)); 1121 $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); 1122 $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); 1123 $form->addElement(form_makeCloseTag('div')); 1124 if ($wr) { 1125 $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); 1126 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); 1127 $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); 1128 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); 1129 $form->addElement(form_makeCloseTag('div')); 1130 $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); 1131 $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); 1132 $elem = html_minoredit(); 1133 if ($elem) $form->addElement($elem); 1134 $form->addElement(form_makeCloseTag('div')); 1135 } 1136 $form->addElement(form_makeCloseTag('div')); 1137 if($conf['license']){ 1138 $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); 1139 $out = $lang['licenseok']; 1140 $out .= '<a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"'; 1141 if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1142 $out .= '> '.$license[$conf['license']]['name'].'</a>'; 1143 $form->addElement($out); 1144 $form->addElement(form_makeCloseTag('div')); 1145 } 1146 html_form('edit', $form); 1147 print '</div>'.NL; 1148} 1149 1150/** 1151 * Adds a checkbox for minor edits for logged in users 1152 * 1153 * @author Andrea Gohr <andi@splitbrain.org> 1154 */ 1155function html_minoredit(){ 1156 global $conf; 1157 global $lang; 1158 // minor edits are for logged in users only 1159 if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1160 return false; 1161 } 1162 1163 $p = array(); 1164 $p['tabindex'] = 3; 1165 if(!empty($_REQUEST['minor'])) $p['checked']='checked'; 1166 return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p); 1167} 1168 1169/** 1170 * prints some debug info 1171 * 1172 * @author Andreas Gohr <andi@splitbrain.org> 1173 */ 1174function html_debug(){ 1175 global $conf; 1176 global $lang; 1177 global $auth; 1178 global $INFO; 1179 1180 //remove sensitive data 1181 $cnf = $conf; 1182 debug_guard($cnf); 1183 $nfo = $INFO; 1184 debug_guard($nfo); 1185 $ses = $_SESSION; 1186 debug_guard($ses); 1187 1188 print '<html><body>'; 1189 1190 print '<p>When reporting bugs please send all the following '; 1191 print 'output as a mail to andi@splitbrain.org '; 1192 print 'The best way to do this is to save this page in your browser</p>'; 1193 1194 print '<b>$INFO:</b><pre>'; 1195 print_r($nfo); 1196 print '</pre>'; 1197 1198 print '<b>$_SERVER:</b><pre>'; 1199 print_r($_SERVER); 1200 print '</pre>'; 1201 1202 print '<b>$conf:</b><pre>'; 1203 print_r($cnf); 1204 print '</pre>'; 1205 1206 print '<b>DOKU_BASE:</b><pre>'; 1207 print DOKU_BASE; 1208 print '</pre>'; 1209 1210 print '<b>abs DOKU_BASE:</b><pre>'; 1211 print DOKU_URL; 1212 print '</pre>'; 1213 1214 print '<b>rel DOKU_BASE:</b><pre>'; 1215 print dirname($_SERVER['PHP_SELF']).'/'; 1216 print '</pre>'; 1217 1218 print '<b>PHP Version:</b><pre>'; 1219 print phpversion(); 1220 print '</pre>'; 1221 1222 print '<b>locale:</b><pre>'; 1223 print setlocale(LC_ALL,0); 1224 print '</pre>'; 1225 1226 print '<b>encoding:</b><pre>'; 1227 print $lang['encoding']; 1228 print '</pre>'; 1229 1230 if($auth){ 1231 print '<b>Auth backend capabilities:</b><pre>'; 1232 print_r($auth->cando); 1233 print '</pre>'; 1234 } 1235 1236 print '<b>$_SESSION:</b><pre>'; 1237 print_r($ses); 1238 print '</pre>'; 1239 1240 print '<b>Environment:</b><pre>'; 1241 print_r($_ENV); 1242 print '</pre>'; 1243 1244 print '<b>PHP settings:</b><pre>'; 1245 $inis = ini_get_all(); 1246 print_r($inis); 1247 print '</pre>'; 1248 1249 print '</body></html>'; 1250} 1251 1252function html_admin(){ 1253 global $ID; 1254 global $INFO; 1255 global $lang; 1256 global $conf; 1257 1258 print p_locale_xhtml('admin'); 1259 1260 // build menu of admin functions from the plugins that handle them 1261 $pluginlist = plugin_list('admin'); 1262 $menu = array(); 1263 foreach ($pluginlist as $p) { 1264 if($obj =& plugin_load('admin',$p) === NULL) continue; 1265 1266 // check permissions 1267 if($obj->forAdminOnly() && !$INFO['isadmin']) continue; 1268 1269 $menu[] = array('plugin' => $p, 1270 'prompt' => $obj->getMenuText($conf['lang']), 1271 'sort' => $obj->getMenuSort() 1272 ); 1273 } 1274 1275 usort($menu, 'p_sort_modes'); 1276 1277 // output the menu 1278 ptln('<ul>'); 1279 1280 foreach ($menu as $item) { 1281 if (!$item['prompt']) continue; 1282 ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 1283 } 1284 1285 ptln('</ul>'); 1286} 1287 1288/** 1289 * Form to request a new password for an existing account 1290 * 1291 * @author Benoit Chesneau <benoit@bchesneau.info> 1292 */ 1293function html_resendpwd() { 1294 global $lang; 1295 global $conf; 1296 global $ID; 1297 1298 print p_locale_xhtml('resendpwd'); 1299 print '<div class="centeralign">'.NL; 1300 $form = new Doku_Form('dw__resendpwd', wl($ID)); 1301 $form->startFieldset($lang['resendpwd']); 1302 $form->addHidden('do', 'resendpwd'); 1303 $form->addHidden('save', '1'); 1304 $form->addElement(form_makeTag('br')); 1305 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block')); 1306 $form->addElement(form_makeTag('br')); 1307 $form->addElement(form_makeTag('br')); 1308 $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 1309 $form->endFieldset(); 1310 html_form('resendpwd', $form); 1311 print '</div>'.NL; 1312} 1313 1314/** 1315 * Return the TOC rendered to XHTML 1316 * 1317 * @author Andreas Gohr <andi@splitbrain.org> 1318 */ 1319function html_TOC($toc){ 1320 if(!count($toc)) return ''; 1321 global $lang; 1322 $out = '<!-- TOC START -->'.DOKU_LF; 1323 $out .= '<div class="toc">'.DOKU_LF; 1324 $out .= '<div class="tocheader toctoggle" id="toc__header">'; 1325 $out .= $lang['toc']; 1326 $out .= '</div>'.DOKU_LF; 1327 $out .= '<div id="toc__inside">'.DOKU_LF; 1328 $out .= html_buildlist($toc,'toc','html_list_toc'); 1329 $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 1330 $out .= '<!-- TOC END -->'.DOKU_LF; 1331 return $out; } 1332 1333/** 1334 * Callback for html_buildlist 1335 */ 1336function html_list_toc($item){ 1337 if($item['hid']){ 1338 $link = '#'.$item['hid']; 1339 }else{ 1340 $link = $item['link']; 1341 } 1342 1343 return '<span class="li"><a href="'.$link.'" class="toc">'. 1344 hsc($item['title']).'</a></span>'; 1345} 1346 1347/** 1348 * Helper function to build TOC items 1349 * 1350 * Returns an array ready to be added to a TOC array 1351 * 1352 * @param string $link - where to link (if $hash set to '#' it's a local anchor) 1353 * @param string $text - what to display in the TOC 1354 * @param int $level - nesting level 1355 * @param string $hash - is prepended to the given $link, set blank if you want full links 1356 */ 1357function html_mktocitem($link, $text, $level, $hash='#'){ 1358 global $conf; 1359 return array( 'link' => $hash.$link, 1360 'title' => $text, 1361 'type' => 'ul', 1362 'level' => $level); 1363} 1364 1365/** 1366 * Output a Doku_Form object. 1367 * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 1368 * 1369 * @author Tom N Harris <tnharris@whoopdedo.org> 1370 */ 1371function html_form($name, &$form) { 1372 // Safety check in case the caller forgets. 1373 $form->endFieldset(); 1374 trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 1375} 1376 1377/** 1378 * Form print function. 1379 * Just calls printForm() on the data object. 1380 */ 1381function html_form_output($data) { 1382 $data->printForm(); 1383} 1384 1385//Setup VIM: ex: et ts=2 enc=utf-8 : 1386