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