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", false, '&')))); 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",false,'&')))); 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 'accesskey' => 'n', 618 'title' => '[ALT+N]' 619 ))); 620 $form->addElement(form_makeCloseTag('div')); 621 } 622 if ($hasNext) { 623 $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next'))); 624 $form->addElement(form_makeTag('input', array( 625 'type' => 'submit', 626 'name' => 'first['.$last.']', 627 'value' => $lang['btn_older'], 628 'accesskey' => 'p', 629 'title' => '[ALT+P]' 630 ))); 631 $form->addElement(form_makeCloseTag('div')); 632 } 633 $form->addElement(form_makeCloseTag('div')); 634 html_form('recent', $form); 635} 636 637/** 638 * Display page index 639 * 640 * @author Andreas Gohr <andi@splitbrain.org> 641 */ 642function html_index($ns){ 643 require_once(DOKU_INC.'inc/search.php'); 644 global $conf; 645 global $ID; 646 $dir = $conf['datadir']; 647 $ns = cleanID($ns); 648 #fixme use appropriate function 649 if(empty($ns)){ 650 $ns = dirname(str_replace(':','/',$ID)); 651 if($ns == '.') $ns =''; 652 } 653 $ns = utf8_encodeFN(str_replace(':','/',$ns)); 654 655 echo p_locale_xhtml('index'); 656 echo '<div id="index__tree">'; 657 658 $data = array(); 659 search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 660 echo html_buildlist($data,'idx','html_list_index','html_li_index'); 661 662 echo '</div>'; 663} 664 665/** 666 * Index item formatter 667 * 668 * User function for html_buildlist() 669 * 670 * @author Andreas Gohr <andi@splitbrain.org> 671 */ 672function html_list_index($item){ 673 global $ID; 674 $ret = ''; 675 $base = ':'.$item['id']; 676 $base = substr($base,strrpos($base,':')+1); 677 if($item['type']=='d'){ 678 $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>'; 679 $ret .= $base; 680 $ret .= '</strong></a>'; 681 }else{ 682 $ret .= html_wikilink(':'.$item['id']); 683 } 684 return $ret; 685} 686 687/** 688 * Index List item 689 * 690 * This user function is used in html_build_lidt to build the 691 * <li> tags for namespaces when displaying the page index 692 * it gives different classes to opened or closed "folders" 693 * 694 * @author Andreas Gohr <andi@splitbrain.org> 695 */ 696function html_li_index($item){ 697 if($item['type'] == "f"){ 698 return '<li class="level'.$item['level'].'">'; 699 }elseif($item['open']){ 700 return '<li class="open">'; 701 }else{ 702 return '<li class="closed">'; 703 } 704} 705 706/** 707 * Default List item 708 * 709 * @author Andreas Gohr <andi@splitbrain.org> 710 */ 711function html_li_default($item){ 712 return '<li class="level'.$item['level'].'">'; 713} 714 715/** 716 * Build an unordered list 717 * 718 * Build an unordered list from the given $data array 719 * Each item in the array has to have a 'level' property 720 * the item itself gets printed by the given $func user 721 * function. The second and optional function is used to 722 * print the <li> tag. Both user function need to accept 723 * a single item. 724 * 725 * Both user functions can be given as array to point to 726 * a member of an object. 727 * 728 * @author Andreas Gohr <andi@splitbrain.org> 729 */ 730function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 731 $level = 0; 732 $opens = 0; 733 $ret = ''; 734 735 foreach ($data as $item){ 736 737 if( $item['level'] > $level ){ 738 //open new list 739 for($i=0; $i<($item['level'] - $level); $i++){ 740 if ($i) $ret .= "<li class=\"clear\">\n"; 741 $ret .= "\n<ul class=\"$class\">\n"; 742 } 743 }elseif( $item['level'] < $level ){ 744 //close last item 745 $ret .= "</li>\n"; 746 for ($i=0; $i<($level - $item['level']); $i++){ 747 //close higher lists 748 $ret .= "</ul>\n</li>\n"; 749 } 750 }else{ 751 //close last item 752 $ret .= "</li>\n"; 753 } 754 755 //remember current level 756 $level = $item['level']; 757 758 //print item 759 $ret .= call_user_func($lifunc,$item); 760 $ret .= '<div class="li">'; 761 762 $ret .= call_user_func($func,$item); 763 $ret .= '</div>'; 764 } 765 766 //close remaining items and lists 767 for ($i=0; $i < $level; $i++){ 768 $ret .= "</li></ul>\n"; 769 } 770 771 return $ret; 772} 773 774/** 775 * display backlinks 776 * 777 * @author Andreas Gohr <andi@splitbrain.org> 778 * @author Michael Klier <chi@chimeric.de> 779 */ 780function html_backlinks(){ 781 require_once(DOKU_INC.'inc/fulltext.php'); 782 global $ID; 783 global $conf; 784 global $lang; 785 786 print p_locale_xhtml('backlinks'); 787 788 $data = ft_backlinks($ID); 789 790 if(!empty($data)) { 791 print '<ul class="idx">'; 792 foreach($data as $blink){ 793 print '<li><div class="li">'; 794 print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 795 print '</div></li>'; 796 } 797 print '</ul>'; 798 } else { 799 print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>'; 800 } 801} 802 803/** 804 * show diff 805 * 806 * @author Andreas Gohr <andi@splitbrain.org> 807 */ 808function html_diff($text='',$intro=true){ 809 require_once(DOKU_INC.'inc/DifferenceEngine.php'); 810 global $ID; 811 global $REV; 812 global $lang; 813 global $conf; 814 815 // we're trying to be clever here, revisions to compare can be either 816 // given as rev and rev2 parameters, with rev2 being optional. Or in an 817 // array in rev2. 818 $rev1 = $REV; 819 820 if(is_array($_REQUEST['rev2'])){ 821 $rev1 = (int) $_REQUEST['rev2'][0]; 822 $rev2 = (int) $_REQUEST['rev2'][1]; 823 824 if(!$rev1){ 825 $rev1 = $rev2; 826 unset($rev2); 827 } 828 }else{ 829 $rev2 = (int) $_REQUEST['rev2']; 830 } 831 832 if($text){ // compare text to the most current revision 833 $l_rev = ''; 834 $l_text = rawWiki($ID,''); 835 $l_head = '<a class="wikilink1" href="'.wl($ID).'">'. 836 $ID.' '.strftime($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 837 $lang['current']; 838 839 $r_rev = ''; 840 $r_text = cleanText($text); 841 $r_head = $lang['yours']; 842 }else{ 843 if($rev1 && $rev2){ // two specific revisions wanted 844 // make sure order is correct (older on the left) 845 if($rev1 < $rev2){ 846 $l_rev = $rev1; 847 $r_rev = $rev2; 848 }else{ 849 $l_rev = $rev2; 850 $r_rev = $rev1; 851 } 852 }elseif($rev1){ // single revision given, compare to current 853 $r_rev = ''; 854 $l_rev = $rev1; 855 }else{ // no revision was given, compare previous to current 856 $r_rev = ''; 857 $revs = getRevisions($ID, 0, 1); 858 $l_rev = $revs[0]; 859 } 860 861 // when both revisions are empty then the page was created just now 862 if(!$l_rev && !$r_rev){ 863 $l_text = ''; 864 }else{ 865 $l_text = rawWiki($ID,$l_rev); 866 } 867 $r_text = rawWiki($ID,$r_rev); 868 869 870 if(!$l_rev){ 871 $l_head = '—'; 872 }else{ 873 $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'. 874 $ID.' '.strftime($conf['dformat'],$l_rev).'</a>'; 875 } 876 877 if($r_rev){ 878 $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'. 879 $ID.' '.strftime($conf['dformat'],$r_rev).'</a>'; 880 }elseif($_rev = @filemtime(wikiFN($ID))){ 881 $r_head = '<a class="wikilink1" href="'.wl($ID).'">'. 882 $ID.' '.strftime($conf['dformat'],$_rev).'</a> '. 883 $lang['current']; 884 }else{ 885 $r_head = '— '.$lang['current']; 886 } 887 } 888 889 $df = new Diff(explode("\n",htmlspecialchars($l_text)), 890 explode("\n",htmlspecialchars($r_text))); 891 892 $tdf = new TableDiffFormatter(); 893 if($intro) print p_locale_xhtml('diff'); 894 ?> 895 <table class="diff"> 896 <tr> 897 <th colspan="2"> 898 <?php echo $l_head?> 899 </th> 900 <th colspan="2"> 901 <?php echo $r_head?> 902 </th> 903 </tr> 904 <?php echo $tdf->format($df)?> 905 </table> 906 <?php 907} 908 909/** 910 * show warning on conflict detection 911 * 912 * @author Andreas Gohr <andi@splitbrain.org> 913 */ 914function html_conflict($text,$summary){ 915 global $ID; 916 global $lang; 917 918 print p_locale_xhtml('conflict'); 919 $form = new Doku_Form('dw__editform'); 920 $form->addHidden('id', $ID); 921 $form->addHidden('wikitext', $text); 922 $form->addHidden('summary', $summary); 923 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s'))); 924 $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'])); 925 html_form('conflict', $form); 926 print '<br /><br /><br /><br />'.NL; 927} 928 929/** 930 * Prints the global message array 931 * 932 * @author Andreas Gohr <andi@splitbrain.org> 933 */ 934function html_msgarea(){ 935 global $MSG; 936 937 if(!isset($MSG)) return; 938 939 foreach($MSG as $msg){ 940 print '<div class="'.$msg['lvl'].'">'; 941 print $msg['msg']; 942 print '</div>'; 943 } 944} 945 946/** 947 * Prints the registration form 948 * 949 * @author Andreas Gohr <andi@splitbrain.org> 950 */ 951function html_register(){ 952 global $lang; 953 global $conf; 954 global $ID; 955 956 print p_locale_xhtml('register'); 957 print '<div class="centeralign">'.NL; 958 $form = new Doku_Form('dw__register', wl($ID)); 959 $form->startFieldset($lang['register']); 960 $form->addHidden('do', 'register'); 961 $form->addHidden('save', '1'); 962 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], null, 'block', array('size'=>'50'))); 963 if (!$conf['autopasswd']) { 964 $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50'))); 965 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 966 } 967 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', array('size'=>'50'))); 968 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', array('size'=>'50'))); 969 $form->addElement(form_makeButton('submit', '', $lang['register'])); 970 $form->endFieldset(); 971 html_form('register', $form); 972 973 print '</div>'.NL; 974} 975 976/** 977 * Print the update profile form 978 * 979 * @author Christopher Smith <chris@jalakai.co.uk> 980 * @author Andreas Gohr <andi@splitbrain.org> 981 */ 982function html_updateprofile(){ 983 global $lang; 984 global $conf; 985 global $ID; 986 global $INFO; 987 global $auth; 988 989 print p_locale_xhtml('updateprofile'); 990 991 if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 992 if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 993 print '<div class="centeralign">'.NL; 994 $form = new Doku_Form('dw__register', wl($ID)); 995 $form->startFieldset($lang['profile']); 996 $form->addHidden('do', 'profile'); 997 $form->addHidden('save', '1'); 998 $form->addElement(form_makeTextField('fullname', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled'))); 999 $attr = array('size'=>'50'); 1000 if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; 1001 $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', $attr)); 1002 $attr = array('size'=>'50'); 1003 if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled'; 1004 $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', $attr)); 1005 $form->addElement(form_makeTag('br')); 1006 if ($auth->canDo('modPass')) { 1007 $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50'))); 1008 $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1009 } 1010 if ($conf['profileconfirm']) { 1011 $form->addElement(form_makeTag('br')); 1012 $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50'))); 1013 } 1014 $form->addElement(form_makeButton('submit', '', $lang['btn_save'])); 1015 $form->addElement(form_makeButton('reset', '', $lang['btn_reset'])); 1016 $form->endFieldset(); 1017 html_form('updateprofile', $form); 1018 print '</div>'.NL; 1019} 1020 1021/** 1022 * This displays the edit form (lots of logic included) 1023 * 1024 * @fixme this is a huge lump of code and should be modularized 1025 * @triggers HTML_PAGE_FROMTEMPLATE 1026 * @triggers HTML_EDITFORM_INJECTION 1027 * @author Andreas Gohr <andi@splitbrain.org> 1028 */ 1029function html_edit($text=null,$include='edit'){ //FIXME: include needed? 1030 global $ID; 1031 global $REV; 1032 global $DATE; 1033 global $RANGE; 1034 global $PRE; 1035 global $SUF; 1036 global $INFO; 1037 global $SUM; 1038 global $lang; 1039 global $conf; 1040 global $license; 1041 1042 //set summary default 1043 if(!$SUM){ 1044 if($REV){ 1045 $SUM = $lang['restored']; 1046 }elseif(!$INFO['exists']){ 1047 $SUM = $lang['created']; 1048 } 1049 } 1050 1051 //no text? Load it! 1052 if(!isset($text)){ 1053 $pr = false; //no preview mode 1054 if($INFO['exists']){ 1055 if($RANGE){ 1056 list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 1057 }else{ 1058 $text = rawWiki($ID,$REV); 1059 } 1060 $check = md5($text); 1061 $mod = false; 1062 }else{ 1063 //try to load a pagetemplate 1064 $data = array($ID); 1065 $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); 1066 $check = md5(''); 1067 $mod = $text!==''; 1068 } 1069 }else{ 1070 $pr = true; //preview mode 1071 if (isset($_REQUEST['changecheck'])) { 1072 $check = $_REQUEST['changecheck']; 1073 $mod = md5($text)!==$check; 1074 } else { 1075 // Why? Assume default text is unmodified. 1076 $check = md5($text); 1077 $mod = false; 1078 } 1079 } 1080 1081 $wr = $INFO['writable'] && !$INFO['locked']; 1082 if($wr){ 1083 if ($REV) print p_locale_xhtml('editrev'); 1084 print p_locale_xhtml($include); 1085 }else{ 1086 // check pseudo action 'source' 1087 if(!actionOK('source')){ 1088 msg('Command disabled: source',-1); 1089 return; 1090 } 1091 print p_locale_xhtml('read'); 1092 } 1093 if(!$DATE) $DATE = $INFO['lastmod']; 1094 1095 1096?> 1097 <div style="width:99%;"> 1098 1099 <div class="toolbar"> 1100 <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.strftime($conf['dformat']);?></div> 1101 <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 1102 target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> 1103 1104 <?php if($wr){?> 1105 <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- 1106 <?php /* sets changed to true when previewed */?> 1107 textChanged = <?php ($mod) ? print 'true' : print 'false' ?>; 1108 //--><!]]></script> 1109 <span id="spell__action"></span> 1110 <div id="spell__suggest"></div> 1111 <?php } ?> 1112 </div> 1113 <div id="spell__result"></div> 1114<?php 1115 $form = new Doku_Form('dw__editform'); 1116 $form->addHidden('id', $ID); 1117 $form->addHidden('rev', $REV); 1118 $form->addHidden('date', $DATE); 1119 $form->addHidden('prefix', $PRE); 1120 $form->addHidden('suffix', $SUF); 1121 $form->addHidden('changecheck', $check); 1122 $attr = array('tabindex'=>'1'); 1123 if (!$wr) $attr['readonly'] = 'readonly'; 1124 $form->addElement(form_makeWikiText($text, $attr)); 1125 $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); 1126 $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); 1127 $form->addElement(form_makeCloseTag('div')); 1128 if ($wr) { 1129 $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); 1130 $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); 1131 $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); 1132 $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); 1133 $form->addElement(form_makeCloseTag('div')); 1134 $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); 1135 $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); 1136 $elem = html_minoredit(); 1137 if ($elem) $form->addElement($elem); 1138 $form->addElement(form_makeCloseTag('div')); 1139 } 1140 $form->addElement(form_makeCloseTag('div')); 1141 if($conf['license']){ 1142 $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); 1143 $out = $lang['licenseok']; 1144 $out .= '<a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"'; 1145 if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1146 $out .= '> '.$license[$conf['license']]['name'].'</a>'; 1147 $form->addElement($out); 1148 $form->addElement(form_makeCloseTag('div')); 1149 } 1150 html_form('edit', $form); 1151 print '</div>'.NL; 1152} 1153 1154/** 1155 * Adds a checkbox for minor edits for logged in users 1156 * 1157 * @author Andrea Gohr <andi@splitbrain.org> 1158 */ 1159function html_minoredit(){ 1160 global $conf; 1161 global $lang; 1162 // minor edits are for logged in users only 1163 if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1164 return false; 1165 } 1166 1167 $p = array(); 1168 $p['tabindex'] = 3; 1169 if(!empty($_REQUEST['minor'])) $p['checked']='checked'; 1170 return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p); 1171} 1172 1173/** 1174 * prints some debug info 1175 * 1176 * @author Andreas Gohr <andi@splitbrain.org> 1177 */ 1178function html_debug(){ 1179 global $conf; 1180 global $lang; 1181 global $auth; 1182 global $INFO; 1183 1184 //remove sensitive data 1185 $cnf = $conf; 1186 debug_guard($cnf); 1187 $nfo = $INFO; 1188 debug_guard($nfo); 1189 $ses = $_SESSION; 1190 debug_guard($ses); 1191 1192 print '<html><body>'; 1193 1194 print '<p>When reporting bugs please send all the following '; 1195 print 'output as a mail to andi@splitbrain.org '; 1196 print 'The best way to do this is to save this page in your browser</p>'; 1197 1198 print '<b>$INFO:</b><pre>'; 1199 print_r($nfo); 1200 print '</pre>'; 1201 1202 print '<b>$_SERVER:</b><pre>'; 1203 print_r($_SERVER); 1204 print '</pre>'; 1205 1206 print '<b>$conf:</b><pre>'; 1207 print_r($cnf); 1208 print '</pre>'; 1209 1210 print '<b>DOKU_BASE:</b><pre>'; 1211 print DOKU_BASE; 1212 print '</pre>'; 1213 1214 print '<b>abs DOKU_BASE:</b><pre>'; 1215 print DOKU_URL; 1216 print '</pre>'; 1217 1218 print '<b>rel DOKU_BASE:</b><pre>'; 1219 print dirname($_SERVER['PHP_SELF']).'/'; 1220 print '</pre>'; 1221 1222 print '<b>PHP Version:</b><pre>'; 1223 print phpversion(); 1224 print '</pre>'; 1225 1226 print '<b>locale:</b><pre>'; 1227 print setlocale(LC_ALL,0); 1228 print '</pre>'; 1229 1230 print '<b>encoding:</b><pre>'; 1231 print $lang['encoding']; 1232 print '</pre>'; 1233 1234 if($auth){ 1235 print '<b>Auth backend capabilities:</b><pre>'; 1236 print_r($auth->cando); 1237 print '</pre>'; 1238 } 1239 1240 print '<b>$_SESSION:</b><pre>'; 1241 print_r($ses); 1242 print '</pre>'; 1243 1244 print '<b>Environment:</b><pre>'; 1245 print_r($_ENV); 1246 print '</pre>'; 1247 1248 print '<b>PHP settings:</b><pre>'; 1249 $inis = ini_get_all(); 1250 print_r($inis); 1251 print '</pre>'; 1252 1253 print '</body></html>'; 1254} 1255 1256function html_admin(){ 1257 global $ID; 1258 global $INFO; 1259 global $lang; 1260 global $conf; 1261 1262 print p_locale_xhtml('admin'); 1263 1264 // build menu of admin functions from the plugins that handle them 1265 $pluginlist = plugin_list('admin'); 1266 $menu = array(); 1267 foreach ($pluginlist as $p) { 1268 if($obj =& plugin_load('admin',$p) === NULL) continue; 1269 1270 // check permissions 1271 if($obj->forAdminOnly() && !$INFO['isadmin']) continue; 1272 1273 $menu[] = array('plugin' => $p, 1274 'prompt' => $obj->getMenuText($conf['lang']), 1275 'sort' => $obj->getMenuSort() 1276 ); 1277 } 1278 1279 usort($menu, 'p_sort_modes'); 1280 1281 // output the menu 1282 ptln('<ul>'); 1283 1284 foreach ($menu as $item) { 1285 if (!$item['prompt']) continue; 1286 ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 1287 } 1288 1289 ptln('</ul>'); 1290} 1291 1292/** 1293 * Form to request a new password for an existing account 1294 * 1295 * @author Benoit Chesneau <benoit@bchesneau.info> 1296 */ 1297function html_resendpwd() { 1298 global $lang; 1299 global $conf; 1300 global $ID; 1301 1302 print p_locale_xhtml('resendpwd'); 1303 print '<div class="centeralign">'.NL; 1304 $form = new Doku_Form('dw__resendpwd', wl($ID)); 1305 $form->startFieldset($lang['resendpwd']); 1306 $form->addHidden('do', 'resendpwd'); 1307 $form->addHidden('save', '1'); 1308 $form->addElement(form_makeTag('br')); 1309 $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block')); 1310 $form->addElement(form_makeTag('br')); 1311 $form->addElement(form_makeTag('br')); 1312 $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 1313 $form->endFieldset(); 1314 html_form('resendpwd', $form); 1315 print '</div>'.NL; 1316} 1317 1318/** 1319 * Return the TOC rendered to XHTML 1320 * 1321 * @author Andreas Gohr <andi@splitbrain.org> 1322 */ 1323function html_TOC($toc){ 1324 if(!count($toc)) return ''; 1325 global $lang; 1326 $out = '<!-- TOC START -->'.DOKU_LF; 1327 $out .= '<div class="toc">'.DOKU_LF; 1328 $out .= '<div class="tocheader toctoggle" id="toc__header">'; 1329 $out .= $lang['toc']; 1330 $out .= '</div>'.DOKU_LF; 1331 $out .= '<div id="toc__inside">'.DOKU_LF; 1332 $out .= html_buildlist($toc,'toc','html_list_toc'); 1333 $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 1334 $out .= '<!-- TOC END -->'.DOKU_LF; 1335 return $out; } 1336 1337/** 1338 * Callback for html_buildlist 1339 */ 1340function html_list_toc($item){ 1341 if($item['hid']){ 1342 $link = '#'.$item['hid']; 1343 }else{ 1344 $link = $item['link']; 1345 } 1346 1347 return '<span class="li"><a href="'.$link.'" class="toc">'. 1348 hsc($item['title']).'</a></span>'; 1349} 1350 1351/** 1352 * Helper function to build TOC items 1353 * 1354 * Returns an array ready to be added to a TOC array 1355 * 1356 * @param string $link - where to link (if $hash set to '#' it's a local anchor) 1357 * @param string $text - what to display in the TOC 1358 * @param int $level - nesting level 1359 * @param string $hash - is prepended to the given $link, set blank if you want full links 1360 */ 1361function html_mktocitem($link, $text, $level, $hash='#'){ 1362 global $conf; 1363 return array( 'link' => $hash.$link, 1364 'title' => $text, 1365 'type' => 'ul', 1366 'level' => $level); 1367} 1368 1369/** 1370 * Output a Doku_Form object. 1371 * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 1372 * 1373 * @author Tom N Harris <tnharris@whoopdedo.org> 1374 */ 1375function html_form($name, &$form) { 1376 // Safety check in case the caller forgets. 1377 $form->endFieldset(); 1378 trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 1379} 1380 1381/** 1382 * Form print function. 1383 * Just calls printForm() on the data object. 1384 */ 1385function html_form_output($data) { 1386 $data->printForm(); 1387} 1388 1389//Setup VIM: ex: et ts=2 enc=utf-8 : 1390