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 9 if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 10 11 require_once(DOKU_INC.'inc/parserutils.php'); 12 13/** 14 * Convenience function to quickly build a wikilink 15 * 16 * @author Andreas Gohr <andi@splitbrain.org> 17 */ 18function html_wikilink($id,$name=NULL,$search=''){ 19 require_once(DOKU_INC.'inc/parser/xhtml.php'); 20 static $xhtml_renderer = NULL; 21 if(is_null($xhtml_renderer)){ 22 $xhtml_renderer = new Doku_Renderer_xhtml(); 23 } 24 25 return $xhtml_renderer->internallink($id,$name,$search,true); 26} 27 28/** 29 * Helps building long attribute lists 30 * 31 * @author Andreas Gohr <andi@splitbrain.org> 32 */ 33function html_attbuild($attributes){ 34 $ret = ''; 35 foreach ( $attributes as $key => $value ) { 36 $ret .= $key.'="'.formtext($value).'" '; 37 } 38 return trim($ret); 39} 40 41/** 42 * The loginform 43 * 44 * @author Andreas Gohr <andi@splitbrain.org> 45 */ 46function html_login(){ 47 global $lang; 48 global $conf; 49 global $ID; 50 global $auth; 51 52 print p_locale_xhtml('login'); 53 ?> 54 <div class="centeralign"> 55 <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 56 <fieldset> 57 <legend><?php echo $lang['btn_login']?></legend> 58 <input type="hidden" name="id" value="<?php echo $ID?>" /> 59 <input type="hidden" name="do" value="login" /> 60 <label class="block"> 61 <span><?php echo $lang['user']?></span> 62 <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" /> 63 </label><br /> 64 <label class="block"> 65 <span><?php echo $lang['pass']?></span> 66 <input type="password" name="p" class="edit" /> 67 </label><br /> 68 <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" /> 69 <label for="remember" class="simple"> 70 <input type="checkbox" name="r" id="remember" value="1" /> 71 <span><?php echo $lang['remember']?></span> 72 </label> 73 </fieldset> 74 </form> 75 <?php 76 if($conf['openregister']){ 77 print '<p>'; 78 print $lang['reghere']; 79 print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>'; 80 print '</p>'; 81 } 82 83 if ($auth->canDo('modifyUser') && $conf['resendpasswd']) { 84 print '<p>'; 85 print $lang['pwdforget']; 86 print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'; 87 print '</p>'; 88 } 89 ?> 90 </div> 91 <?php 92/* 93 FIXME provide new hook 94 if(@file_exists('includes/login.txt')){ 95 print io_cacheParse('includes/login.txt'); 96 } 97*/ 98} 99 100/** 101 * shows the edit/source/show button dependent on current mode 102 * 103 * @author Andreas Gohr <andi@splitbrain.org> 104 */ 105function html_editbutton(){ 106 global $ID; 107 global $REV; 108 global $ACT; 109 global $INFO; 110 111 if($ACT == 'show' || $ACT == 'search'){ 112 if($INFO['writable']){ 113 if($INFO['exists']){ 114 $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 115 }else{ 116 $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 117 } 118 }else{ 119 $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 120 } 121 }else{ 122 $r = html_btn('show',$ID,'v',array('do' => 'show')); 123 } 124 return $r; 125} 126 127/** 128 * prints a section editing button 129 * 130 * @author Andreas Gohr <andi@splitbrain.org> 131 */ 132function html_secedit_button($section,$p){ 133 global $ID; 134 global $lang; 135 $secedit = ''; 136# if($p) $secedit .= "</p>\n"; 137 $secedit .= '<div class="secedit">'; 138 $secedit .= html_btn('secedit',$ID,'', 139 array('do' => 'edit', 140 'lines' => "$section"), 141 'post'); 142 $secedit .= '</div>'; 143# if($p) $secedit .= "\n<p>"; 144 return $secedit; 145} 146 147/** 148 * inserts section edit buttons if wanted or removes the markers 149 * 150 * @author Andreas Gohr <andi@splitbrain.org> 151 */ 152function html_secedit($text,$show=true){ 153 global $INFO; 154 if($INFO['writable'] && $show && !$INFO['rev']){ 155 $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e', 156 "html_secedit_button('\\1',true)", 157 $text); 158 $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e', 159 "html_secedit_button('\\1',false)", 160 $text); 161 }else{ 162 $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text); 163 } 164 return $text; 165} 166 167/** 168 * Just the back to top button (in its own form) 169 * 170 * @author Andreas Gohr <andi@splitbrain.org> 171 */ 172function html_topbtn(){ 173 global $lang; 174 175 $ret = ''; 176 $ret = '<a href="#top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>'; 177 178 return $ret; 179} 180 181/** 182 * Just the back to media window button in its own form 183 * 184 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 185 */ 186function html_backtomedia_button($params,$akey=''){ 187 global $conf; 188 global $lang; 189 190 $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php"><div class="no">'; 191 192 reset($params); 193 while (list($key, $val) = each($params)) { 194 $ret .= '<input type="hidden" name="'.$key.'" '; 195 $ret .= 'value="'.htmlspecialchars($val).'" />'; 196 } 197 198 $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" '; 199 if($akey){ 200 $ret .= 'title="ALT+'.strtoupper($akey).'" '; 201 $ret .= 'accesskey="'.$akey.'" '; 202 } 203 $ret .= '/>'; 204 $ret .= '</div></form>'; 205 206 return $ret; 207} 208 209/** 210 * Displays a button (using its own form) 211 * 212 * @author Andreas Gohr <andi@splitbrain.org> 213 */ 214function html_btn($name,$id,$akey,$params,$method='get'){ 215 global $conf; 216 global $lang; 217 218 $label = $lang['btn_'.$name]; 219 220 $ret = ''; 221 222 //filter id (without urlencoding) 223 $id = idfilter($id,false); 224 225 //make nice URLs even for buttons 226 if($conf['userewrite'] == 2){ 227 $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 228 }elseif($conf['userewrite']){ 229 $script = DOKU_BASE.$id; 230 }else{ 231 $script = DOKU_BASE.DOKU_SCRIPT; 232 $params['id'] = $id; 233 } 234 235 $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">'; 236 237 reset($params); 238 while (list($key, $val) = each($params)) { 239 $ret .= '<input type="hidden" name="'.$key.'" '; 240 $ret .= 'value="'.htmlspecialchars($val).'" />'; 241 } 242 243 $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; 244 if($akey){ 245 $ret .= 'title="ALT+'.strtoupper($akey).'" '; 246 $ret .= 'accesskey="'.$akey.'" '; 247 } 248 $ret .= '/>'; 249 $ret .= '</div></form>'; 250 251 return $ret; 252} 253 254/** 255 * show a wiki page 256 * 257 * @author Andreas Gohr <andi@splitbrain.org> 258 */ 259function html_show($txt=''){ 260 global $ID; 261 global $REV; 262 global $HIGH; 263 //disable section editing for old revisions or in preview 264 if($txt || $REV){ 265 $secedit = false; 266 }else{ 267 $secedit = true; 268 } 269 270 if ($txt){ 271 //PreviewHeader 272 print '<br id="scroll__here" />'; 273 print p_locale_xhtml('preview'); 274 print '<div class="preview">'; 275 print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 276 print '<div class="clearer"></div>'; 277 print '</div>'; 278 279 }else{ 280 if ($REV) print p_locale_xhtml('showrev'); 281 $html = p_wiki_xhtml($ID,$REV,true); 282 $html = html_secedit($html,$secedit); 283 print html_hilight($html,$HIGH); 284 } 285} 286 287/** 288 * Highlights searchqueries in HTML code 289 * 290 * @author Andreas Gohr <andi@splitbrain.org> 291 * @author Harry Fuecks <hfuecks@gmail.com> 292 */ 293function html_hilight($html,$query){ 294 //split at common delimiters 295 $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY); 296 foreach ($queries as $q){ 297 $q = preg_quote($q,'/'); 298 $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html); 299 } 300 return $html; 301} 302 303/** 304 * Callback used by html_hilight() 305 * 306 * @author Harry Fuecks <hfuecks@gmail.com> 307 */ 308function html_hilight_callback($m) { 309 $hlight = unslash($m[0]); 310 if ( !isset($m[2])) { 311 $hlight = '<span class="search_hit">'.$hlight.'</span>'; 312 } 313 return $hlight; 314} 315 316/** 317 * Run a search and display the result 318 * 319 * @author Andreas Gohr <andi@splitbrain.org> 320 */ 321function html_search(){ 322 require_once(DOKU_INC.'inc/search.php'); 323 require_once(DOKU_INC.'inc/fulltext.php'); 324 global $conf; 325 global $QUERY; 326 global $ID; 327 global $lang; 328 329 print p_locale_xhtml('searchpage'); 330 flush(); 331 332 //show progressbar 333 print '<div class="centeralign">'; 334 print '<script type="text/javascript" charset="utf-8">'; 335 print 'showLoadBar();'; 336 print '</script>'; 337 print '<br /></div>'; 338 339 //do quick pagesearch 340 $data = array(); 341 $data = ft_pageLookup(cleanID($QUERY)); 342 if(count($data)){ 343 sort($data); 344 print '<div class="search_quickresult">'; 345 print '<strong>'.$lang[quickhits].':</strong><br />'; 346 foreach($data as $id){ 347 print '<div class="search_quickhits">'; 348 print html_wikilink(':'.$id,$conf['useheading']?NULL:$id); 349 print '</div> '; 350 } 351 //clear float (see http://www.complexspiral.com/publications/containing-floats/) 352 print '<div class="clearer"> </div>'; 353 print '</div>'; 354 } 355 flush(); 356 357 //do fulltext search 358 $data = ft_pageSearch($QUERY,$poswords); 359 if(count($data)){ 360 $num = 1; 361 foreach($data as $id => $cnt){ 362 print '<div class="search_result">'; 363 print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); 364 print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 365 if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 366 print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; 367 } 368 print '</div>'; 369 flush(); 370 $num++; 371 } 372 }else{ 373 print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 374 } 375 376 //hide progressbar 377 print '<script type="text/javascript" charset="utf-8">'; 378 print 'hideLoadBar();'; 379 print '</script>'; 380} 381 382/** 383 * Display error on locked pages 384 * 385 * @author Andreas Gohr <andi@splitbrain.org> 386 */ 387function html_locked(){ 388 global $ID; 389 global $conf; 390 global $lang; 391 global $INFO; 392 393 $locktime = filemtime(wikiFN($ID).'.lock'); 394 $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); 395 $min = round(($conf['locktime'] - (time() - $locktime) )/60); 396 397 print p_locale_xhtml('locked'); 398 print '<ul>'; 399 print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>'; 400 print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 401 print '</ul>'; 402} 403 404/** 405 * list old revisions 406 * 407 * @author Andreas Gohr <andi@splitbrain.org> 408 */ 409function html_revisions(){ 410 global $ID; 411 global $INFO; 412 global $conf; 413 global $lang; 414 $revisions = getRevisions($ID); 415 $date = @date($conf['dformat'],$INFO['lastmod']); 416 417 print p_locale_xhtml('revisions'); 418 print '<ul>'; 419 if($INFO['exists']){ 420 print ($INFO['minor']) ? '<li class="minor">' : '<li>'; 421 print '<div class="li">'; 422 423 print $date; 424 425 print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 426 427 print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> '; 428 429 print $INFO['sum']; 430 print ' <span class="user">'; 431 print $INFO['editor']; 432 print '</span> '; 433 434 print '('.$lang['current'].')'; 435 print '</div>'; 436 print '</li>'; 437 } 438 439 foreach($revisions as $rev){ 440 $date = date($conf['dformat'],$rev); 441 $info = getRevisionInfo($ID,$rev); 442 443 print ($info['minor']) ? '<li class="minor">' : '<li>'; 444 print '<div class="li">'; 445 print $date; 446 447 print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">'; 448 $p = array(); 449 $p['src'] = DOKU_BASE.'lib/images/diff.png'; 450 $p['border'] = 0; 451 $p['width'] = 15; 452 $p['height'] = 11; 453 $p['title'] = $lang['diff']; 454 $p['alt'] = $lang['diff']; 455 $att = buildAttributes($p); 456 print "<img $att />"; 457 print '</a> '; 458 459 print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> '; 460 461 print htmlspecialchars($info['sum']); 462 print ' <span class="user">'; 463 if($info['user']){ 464 print $info['user']; 465 }else{ 466 print $info['ip']; 467 } 468 print '</span>'; 469 470 print '</div>'; 471 print '</li>'; 472 } 473 print '</ul>'; 474} 475 476/** 477 * display recent changes 478 * 479 * @author Andreas Gohr <andi@splitbrain.org> 480 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 481 */ 482function html_recent($first=0){ 483 global $conf; 484 global $lang; 485 global $ID; 486 /* we need to get one additionally log entry to be able to 487 * decide if this is the last page or is there another one. 488 * This is the cheapest solution to get this information. 489 */ 490 $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 491 if(count($recents) == 0 && $first != 0){ 492 $first=0; 493 $recents = getRecents(0,$conf['recent'] + 1,getNS($ID)); 494 } 495 $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; 496 497 print p_locale_xhtml('recent'); 498 print '<ul>'; 499 500 foreach($recents as $recent){ 501 $date = date($conf['dformat'],$recent['date']); 502 print ($recent['minor']) ? '<li class="minor">' : '<li>'; 503 print '<div class="li">'; 504 505 print $date.' '; 506 507 print '<a href="'.wl($recent['id'],"do=diff").'">'; 508 $p = array(); 509 $p['src'] = DOKU_BASE.'lib/images/diff.png'; 510 $p['border'] = 0; 511 $p['width'] = 15; 512 $p['height'] = 11; 513 $p['title'] = $lang['diff']; 514 $p['alt'] = $lang['diff']; 515 $att = buildAttributes($p); 516 print "<img $att />"; 517 print '</a> '; 518 519 print '<a href="'.wl($recent['id'],"do=revisions").'">'; 520 $p = array(); 521 $p['src'] = DOKU_BASE.'lib/images/history.png'; 522 $p['border'] = 0; 523 $p['width'] = 12; 524 $p['height'] = 14; 525 $p['title'] = $lang['btn_revs']; 526 $p['alt'] = $lang['btn_revs']; 527 $att = buildAttributes($p); 528 print "<img $att />"; 529 print '</a> '; 530 531 print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 532 print ' '.htmlspecialchars($recent['sum']); 533 534 print ' <span class="user">'; 535 if($recent['user']){ 536 print $recent['user']; 537 }else{ 538 print $recent['ip']; 539 } 540 print '</span>'; 541 542 print '</div>'; 543 print '</li>'; 544 } 545 print '</ul>'; 546 547 print '<div class="pagenav">'; 548 $last = $first + $conf['recent']; 549 if ($first > 0) { 550 $first -= $conf['recent']; 551 if ($first < 0) $first = 0; 552 print '<div class="pagenav-prev">'; 553 print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); 554 print '</div>'; 555 } 556 if ($conf['recent'] < count($recents)) { 557 print '<div class="pagenav-next">'; 558 print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); 559 print '</div>'; 560 } 561 print '</div>'; 562} 563 564/** 565 * Display page index 566 * 567 * @author Andreas Gohr <andi@splitbrain.org> 568 */ 569function html_index($ns){ 570 require_once(DOKU_INC.'inc/search.php'); 571 global $conf; 572 global $ID; 573 $dir = $conf['datadir']; 574 $ns = cleanID($ns); 575 #fixme use appropriate function 576 if(empty($ns)){ 577 $ns = dirname(str_replace(':','/',$ID)); 578 if($ns == '.') $ns =''; 579 } 580 $ns = utf8_encodeFN(str_replace(':','/',$ns)); 581 582 print p_locale_xhtml('index'); 583 584 $data = array(); 585 search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 586 print html_buildlist($data,'idx','html_list_index','html_li_index'); 587} 588 589/** 590 * Index item formatter 591 * 592 * User function for html_buildlist() 593 * 594 * @author Andreas Gohr <andi@splitbrain.org> 595 */ 596function html_list_index($item){ 597 $ret = ''; 598 $base = ':'.$item['id']; 599 $base = substr($base,strrpos($base,':')+1); 600 if($item['type']=='d'){ 601 $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">'; 602 $ret .= $base; 603 $ret .= '</a>'; 604 }else{ 605 $ret .= html_wikilink(':'.$item['id']); 606 } 607 return $ret; 608} 609 610/** 611 * Index List item 612 * 613 * This user function is used in html_build_lidt to build the 614 * <li> tags for namespaces when displaying the page index 615 * it gives different classes to opened or closed "folders" 616 * 617 * @author Andreas Gohr <andi@splitbrain.org> 618 */ 619function html_li_index($item){ 620 if($item['type'] == "f"){ 621 return '<li class="level'.$item['level'].'">'; 622 }elseif($item['open']){ 623 return '<li class="open">'; 624 }else{ 625 return '<li class="closed">'; 626 } 627} 628 629/** 630 * Default List item 631 * 632 * @author Andreas Gohr <andi@splitbrain.org> 633 */ 634function html_li_default($item){ 635 return '<li class="level'.$item['level'].'">'; 636} 637 638/** 639 * Build an unordered list 640 * 641 * Build an unordered list from the given $data array 642 * Each item in the array has to have a 'level' property 643 * the item itself gets printed by the given $func user 644 * function. The second and optional function is used to 645 * print the <li> tag. Both user function need to accept 646 * a single item. 647 * 648 * @author Andreas Gohr <andi@splitbrain.org> 649 */ 650function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 651 $level = 0; 652 $opens = 0; 653 $ret = ''; 654 655 foreach ($data as $item){ 656 657 if( $item['level'] > $level ){ 658 //open new list 659 for($i=0; $i<($item['level'] - $level); $i++){ 660 if ($i) $ret .= "<li class=\"clear\">\n"; 661 $ret .= "\n<ul class=\"$class\">\n"; 662 } 663 }elseif( $item['level'] < $level ){ 664 //close last item 665 $ret .= "</li>\n"; 666 for ($i=0; $i<($level - $item['level']); $i++){ 667 //close higher lists 668 $ret .= "</ul>\n</li>\n"; 669 } 670 }else{ 671 //close last item 672 $ret .= "</li>\n"; 673 } 674 675 //remember current level 676 $level = $item['level']; 677 678 //print item 679 $ret .= $lifunc($item); //user function 680 $ret .= '<div class="li">'; 681 $ret .= $func($item); //user function 682 $ret .= '</div>'; 683 } 684 685 //close remaining items and lists 686 for ($i=0; $i < $level; $i++){ 687 $ret .= "</li></ul>\n"; 688 } 689 690 return $ret; 691} 692 693/** 694 * display backlinks 695 * 696 * @author Andreas Gohr <andi@splitbrain.org> 697 */ 698function html_backlinks(){ 699 require_once(DOKU_INC.'inc/fulltext.php'); 700 global $ID; 701 global $conf; 702 703 print p_locale_xhtml('backlinks'); 704 705 $data = ft_backlinks($ID); 706 707 print '<ul class="idx">'; 708 foreach($data as $blink){ 709 print '<li><div class="li">'; 710 print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 711 print '</div></li>'; 712 } 713 print '</ul>'; 714} 715 716/** 717 * show diff 718 * 719 * @author Andreas Gohr <andi@splitbrain.org> 720 */ 721function html_diff($text='',$intro=true){ 722 require_once(DOKU_INC.'inc/DifferenceEngine.php'); 723 global $ID; 724 global $REV; 725 global $lang; 726 global $conf; 727 if($text){ 728 $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), 729 split("\n",htmlspecialchars(cleanText($text)))); 730 $left = '<a class="wikilink1" href="'.wl($ID).'">'. 731 $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'. 732 $lang['current']; 733 $right = $lang['yours']; 734 }else{ 735 if($REV){ 736 $r = $REV; 737 }else{ 738 //use last revision if none given 739 $revs = getRevisions($ID); 740 $r = $revs[0]; 741 } 742 743 $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))), 744 split("\n",htmlspecialchars(rawWiki($ID,'')))); 745 $left = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'. 746 $ID.' '.date($conf['dformat'],$r).'</a>'; 747 $right = '<a class="wikilink1" href="'.wl($ID).'">'. 748 $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 749 $lang['current']; 750 } 751 $tdf = new TableDiffFormatter(); 752 if($intro) print p_locale_xhtml('diff'); 753 ?> 754 <table class="diff" width="100%"> 755 <tr> 756 <td colspan="2" width="50%" class="diff-header"> 757 <?php echo $left?> 758 </td> 759 <td colspan="2" width="50%" class="diff-header"> 760 <?php echo $right?> 761 </td> 762 </tr> 763 <?php echo $tdf->format($df)?> 764 </table> 765 <?php 766} 767 768/** 769 * show warning on conflict detection 770 * 771 * @author Andreas Gohr <andi@splitbrain.org> 772 */ 773function html_conflict($text,$summary){ 774 global $ID; 775 global $lang; 776 777 print p_locale_xhtml('conflict'); 778 ?> 779 <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 780 <div class="centeralign"> 781 <input type="hidden" name="id" value="<?php echo $ID?>" /> 782 <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" /> 783 <input type="hidden" name="summary" value="<?php echo formText($summary)?>" /> 784 785 <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" /> 786 <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" /> 787 </div> 788 </form> 789 <br /><br /><br /><br /> 790 <?php 791} 792 793/** 794 * Prints the global message array 795 * 796 * @author Andreas Gohr <andi@splitbrain.org> 797 */ 798function html_msgarea(){ 799 global $MSG; 800 801 if(!isset($MSG)) return; 802 803 foreach($MSG as $msg){ 804 print '<div class="'.$msg['lvl'].'">'; 805 print $msg['msg']; 806 print '</div>'; 807 } 808} 809 810/** 811 * Prints the registration form 812 * 813 * @author Andreas Gohr <andi@splitbrain.org> 814 */ 815function html_register(){ 816 global $lang; 817 global $conf; 818 global $ID; 819 820 print p_locale_xhtml('register'); 821?> 822 <div class="centeralign"> 823 <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 824 <fieldset> 825 <input type="hidden" name="do" value="register" /> 826 <input type="hidden" name="save" value="1" /> 827 828 <legend><?php echo $lang['register']?></legend> 829 <label class="block"> 830 <?php echo $lang['user']?> 831 <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" /> 832 </label><br /> 833 834 <?php 835 if (!$conf['autopasswd']) { 836 ?> 837 <label class="block"> 838 <?php echo $lang['pass']?> 839 <input type="password" name="pass" class="edit" size="50" /> 840 </label><br /> 841 <label class="block"> 842 <?php echo $lang['passchk']?> 843 <input type="password" name="passchk" class="edit" size="50" /> 844 </label><br /> 845 <?php 846 } 847 ?> 848 849 <label class="block"> 850 <?php echo $lang['fullname']?> 851 <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 852 </label><br /> 853 <label class="block"> 854 <?php echo $lang['email']?> 855 <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 856 </label><br /> 857 <input type="submit" class="button" value="<?php echo $lang['register']?>" /> 858 </fieldset> 859 </form> 860 </div> 861<?php 862} 863 864/** 865 * Print the update profile form 866 * 867 * @author Christopher Smith <chris@jalakai.co.uk> 868 * @author Andreas Gohr <andi@splitbrain.org> 869 */ 870function html_updateprofile(){ 871 global $lang; 872 global $conf; 873 global $ID; 874 global $INFO; 875 876 print p_locale_xhtml('updateprofile'); 877 878 if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 879 if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 880?> 881 <div class="centeralign"> 882 <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 883 <fieldset style="width: 80%;"> 884 <input type="hidden" name="do" value="profile" /> 885 <input type="hidden" name="save" value="1" /> 886 887 <legend><?php echo $lang['profile']?></legend> 888 <label class="block"> 889 <?php echo $lang['user']?> 890 <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" /> 891 </label><br /> 892 <label class="block"> 893 <?php echo $lang['fullname']?> 894 <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 895 </label><br /> 896 <label class="block"> 897 <?php echo $lang['email']?> 898 <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 899 </label><br /><br /> 900 <label class="block"> 901 <?php echo $lang['newpass']?> 902 <input type="password" name="newpass" class="edit" size="50" /> 903 </label><br /> 904 <label class="block"> 905 <?php echo $lang['passchk']?> 906 <input type="password" name="passchk" class="edit" size="50" /> 907 </label><br /> 908 909 <?php if ($conf['profileconfirm']) { ?> 910 <br /> 911 <label class="block"> 912 <?php echo $lang['oldpass']?> 913 <input type="password" name="oldpass" class="edit" size="50" /> 914 </label><br /> 915 <?php } ?> 916 917 <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" /> 918 <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" /> 919 </fieldset> 920 </form> 921 </div> 922<?php 923} 924 925/** 926 * This displays the edit form (lots of logic included) 927 * 928 * @fixme this is a huge lump of code and should be modularized 929 * @author Andreas Gohr <andi@splitbrain.org> 930 */ 931function html_edit($text=null,$include='edit'){ //FIXME: include needed? 932 global $ID; 933 global $REV; 934 global $DATE; 935 global $RANGE; 936 global $PRE; 937 global $SUF; 938 global $INFO; 939 global $SUM; 940 global $lang; 941 global $conf; 942 943 //set summary default 944 if(!$SUM){ 945 if($REV){ 946 $SUM = $lang['restored']; 947 }elseif(!$INFO['exists']){ 948 $SUM = $lang['created']; 949 } 950 } 951 952 //no text? Load it! 953 if(!isset($text)){ 954 $pr = false; //no preview mode 955 if($INFO['exists']){ 956 if($RANGE){ 957 list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 958 }else{ 959 $text = rawWiki($ID,$REV); 960 } 961 }else{ 962 //try to load a pagetemplate 963 $text = pageTemplate($ID); 964 } 965 }else{ 966 $pr = true; //preview mode 967 } 968 969 $wr = $INFO['writable']; 970 if($wr){ 971 if ($REV) print p_locale_xhtml('editrev'); 972 print p_locale_xhtml($include); 973 }else{ 974 print p_locale_xhtml('read'); 975 $ro='readonly="readonly"'; 976 } 977 if(!$DATE) $DATE = $INFO['lastmod']; 978 979 980?> 981 <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 982 <table style="width:99%"> 983 <tr> 984 <td class="toolbar" colspan="2"> 985 <div id="toolbar"></div> 986 <input type="hidden" name="id" value="<?php echo $ID?>" /> 987 <input type="hidden" name="rev" value="<?php echo $REV?>" /> 988 <input type="hidden" name="date" value="<?php echo $DATE?>" /> 989 <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" /> 990 <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" /> 991 992 <?php if($wr){?> 993 <script type="text/javascript" charset="utf-8"> 994 <?php /* sets changed to true when previewed */?> 995 textChanged = <?php ($pr) ? print 'true' : print 'false' ?>; 996 </script> 997 <span id="spell_action"></span> 998 <?php } ?> 999 </td> 1000 <td> 1001 <div id="spell_suggest"></div> 1002 </td> 1003 </tr> 1004 <tr> 1005 <td colspan="3"> 1006 <div id="spell_result"></div> 1007 <textarea name="wikitext" id="wikitext" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea> 1008 </td> 1009 </tr> 1010 <tr id="wikieditbar"> 1011 <td> 1012 <?php if($wr){?> 1013 <input class="button" id="edbtn_save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" /> 1014 <input class="button" id="edbtn_preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" /> 1015 <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" /> 1016 <?php } ?> 1017 </td> 1018 <td> 1019 <?php if($wr){ ?> 1020 <?php echo $lang['summary']?>: 1021 <input type="text" class="edit" name="summary" id="summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" /> 1022 <?php html_minoredit()?> 1023 <?php }?> 1024 </td> 1025 <td class="rightalign"> 1026 <div id="sizectl"></div> 1027 </td> 1028 </tr> 1029 </table> 1030 </form> 1031<?php 1032} 1033 1034/** 1035 * Adds a checkbox for minor edits for logged in users 1036 * 1037 * @author Andrea Gohr <andi@splitbrain.org> 1038 */ 1039function html_minoredit(){ 1040 global $conf; 1041 global $lang; 1042 // minor edits are for logged in users only 1043 if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1044 return; 1045 } 1046 1047 $p = array(); 1048 $p['name'] = 'minor'; 1049 $p['type'] = 'checkbox'; 1050 $p['id'] = 'minoredit'; 1051 $p['tabindex'] = 3; 1052 $p['value'] = '1'; 1053 if($_REQUEST['minor']) $p['checked']='checked'; 1054 $att = buildAttributes($p); 1055 1056 print "<input $att />"; 1057 print '<label for="minoredit">'; 1058 print $lang['minoredit']; 1059 print '</label>'; 1060} 1061 1062/** 1063 * prints some debug info 1064 * 1065 * @author Andreas Gohr <andi@splitbrain.org> 1066 */ 1067function html_debug(){ 1068 global $conf; 1069 global $lang; 1070 //remove sensitive data 1071 $cnf = $conf; 1072 $cnf['auth']='***'; 1073 $cnf['notify']='***'; 1074 $cnf['ftp']='***'; 1075 1076 print '<html><body>'; 1077 1078 print '<p>When reporting bugs please send all the following '; 1079 print 'output as a mail to andi@splitbrain.org '; 1080 print 'The best way to do this is to save this page in your browser</p>'; 1081 1082 print '<b>$_SERVER:</b><pre>'; 1083 print_r($_SERVER); 1084 print '</pre>'; 1085 1086 print '<b>$conf:</b><pre>'; 1087 print_r($cnf); 1088 print '</pre>'; 1089 1090 print '<b>DOKU_BASE:</b><pre>'; 1091 print DOKU_BASE; 1092 print '</pre>'; 1093 1094 print '<b>abs DOKU_BASE:</b><pre>'; 1095 print DOKU_URL; 1096 print '</pre>'; 1097 1098 print '<b>rel DOKU_BASE:</b><pre>'; 1099 print dirname($_SERVER['PHP_SELF']).'/'; 1100 print '</pre>'; 1101 1102 print '<b>PHP Version:</b><pre>'; 1103 print phpversion(); 1104 print '</pre>'; 1105 1106 print '<b>locale:</b><pre>'; 1107 print setlocale(LC_ALL,0); 1108 print '</pre>'; 1109 1110 print '<b>encoding:</b><pre>'; 1111 print $lang['encoding']; 1112 print '</pre>'; 1113 1114 print '<b>$_SESSION:</b><pre>'; 1115 print_r($_SESSION); 1116 print '</pre>'; 1117 1118 print '<b>Environment:</b><pre>'; 1119 print_r($_ENV); 1120 print '</pre>'; 1121 1122 print '<b>PHP settings:</b><pre>'; 1123 $inis = ini_get_all(); 1124 print_r($inis); 1125 print '</pre>'; 1126 1127 print '</body></html>'; 1128} 1129 1130function html_admin(){ 1131 global $ID; 1132 global $lang; 1133 global $conf; 1134 1135 print p_locale_xhtml('admin'); 1136 1137 // build menu of admin functions from the plugins that handle them 1138 $pluginlist = plugin_list('admin'); 1139 $menu = array(); 1140 foreach ($pluginlist as $p) { 1141 if($obj =& plugin_load('admin',$p) === NULL) continue; 1142 $menu[] = array('plugin' => $p, 1143 'prompt' => $obj->getMenuText($conf['lang']), 1144 'sort' => $obj->getMenuSort() 1145 ); 1146 } 1147 1148 usort($menu, p_sort_modes); 1149 1150 // output the menu 1151 ptln('<ul>'); 1152 1153 foreach ($menu as $item) { 1154 if (!$item['prompt']) continue; 1155 ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 1156 } 1157 1158 // add in non-plugin functions 1159 if (!$conf['openregister']){ 1160 ptln('<li><div class="li"><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></div></li>'); 1161 } 1162 1163 ptln('</ul>'); 1164} 1165 1166/** 1167 * Form to request a new password for an existing account 1168 * 1169 * @author Benoit Chesneau <benoit@bchesneau.info> 1170 */ 1171function html_resendpwd() { 1172 global $lang; 1173 global $conf; 1174 global $ID; 1175 1176 print p_locale_xhtml('resendpwd'); 1177?> 1178 <div class="centeralign"> 1179 <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 1180 <fieldset> 1181 <br /> 1182 <legend><?php echo $lang['resendpwd']?></legend> 1183 <input type="hidden" name="do" value="resendpwd" /> 1184 <input type="hidden" name="save" value="1" /> 1185 <label class="block"> 1186 <span><?php echo $lang['user']?></span> 1187 <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br /> 1188 </label><br /> 1189 <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" /> 1190 </fieldset> 1191 </form> 1192 </div> 1193<?php 1194} 1195 1196//Setup VIM: ex: et ts=2 enc=utf-8 : 1197