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