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