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 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 450 */ 451function html_recent($first=0){ 452 global $conf; 453 global $lang; 454 455 /* we need to get one additionally log entry to be able to 456 * decide if this is the last page or is there another one. 457 * This is the cheapest solution to get this information. 458 */ 459 $recents = getRecents($first,$conf['recent'] + 1,true); 460 if(count($recents) == 0 && $first != 0){ 461 $first=0; 462 $recents = getRecents(0,$conf['recent'] + 1,true); 463 } 464 $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; 465 466 print p_locale_xhtml('recent'); 467 print '<ul>'; 468 469 $keys = array_keys($recents); 470 for ($n=0; $n < $cnt; $n++){ 471 $id = $keys[$n]; 472 $date = date($conf['dformat'],$recents[$id]['date']); 473 print '<li>'; 474 475 print $date.' '; 476 477 print '<a href="'.wl($id,"do=diff").'">'; 478 print '<img src="'.DOKU_BASE.'images/diff.png" border="0" width="15" height="11" title="'.$lang['diff'].'" />'; 479 print '</a> '; 480 481 print '<a href="'.wl($id,"do=revisions").'">'; 482 print '<img src="'.DOKU_BASE.'images/history.png" border="0" width="12" height="14" title="'.$lang['btn_revs'].'" />'; 483 print '</a> '; 484 485 print html_wikilink($id,$id); 486 487 print ' '.htmlspecialchars($recents[$id]['sum']); 488 print ' <span class="user">'; 489 if($recents[$id]['user']){ 490 print $recents[$id]['user']; 491 }else{ 492 print $recents[$id]['ip']; 493 } 494 print '</span>'; 495 496 print '</li>'; 497 } 498 print '</ul>'; 499 500 print '<div class="pagenav">'; 501 $last = $first + $conf['recent']; 502 if ($first > 0) { 503 $first -= $conf['recent']; 504 if ($first < 0) $first = 0; 505 print '<div class="pagenav-prev">'; 506 print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); 507 print '</div>'; 508 } 509 if ($conf['recent'] < count($recents)) { 510 print '<div class="pagenav-next">'; 511 print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); 512 print '</div>'; 513 } 514 print '</div>'; 515} 516 517/** 518 * Display page index 519 * 520 * @author Andreas Gohr <andi@splitbrain.org> 521 */ 522function html_index($ns){ 523 require_once(DOKU_INC.'inc/search.php'); 524 global $conf; 525 global $ID; 526 $dir = $conf['datadir']; 527 $ns = cleanID($ns); 528 #fixme use appropriate function 529 if(empty($ns)){ 530 $ns = dirname(str_replace(':','/',$ID)); 531 if($ns == '.') $ns =''; 532 } 533 $ns = utf8_encodeFN(str_replace(':','/',$ns)); 534 535 print p_locale_xhtml('index'); 536 537 $data = array(); 538 search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 539 print html_buildlist($data,'idx','html_list_index','html_li_index'); 540} 541 542/** 543 * Index item formatter 544 * 545 * User function for html_buildlist() 546 * 547 * @author Andreas Gohr <andi@splitbrain.org> 548 */ 549function html_list_index($item){ 550 $ret = ''; 551 $base = ':'.$item['id']; 552 $base = substr($base,strrpos($base,':')+1); 553 if($item['type']=='d'){ 554 $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">'; 555 $ret .= $base; 556 $ret .= '</a>'; 557 }else{ 558 $ret .= html_wikilink(':'.$item['id']); 559 } 560 return $ret; 561} 562 563/** 564 * Index List item 565 * 566 * This user function is used in html_build_lidt to build the 567 * <li> tags for namespaces when displaying the page index 568 * it gives different classes to opened or closed "folders" 569 * 570 * @author Andreas Gohr <andi@splitbrain.org> 571 */ 572function html_li_index($item){ 573 if($item['type'] == "f"){ 574 return '<li class="level'.$item['level'].'">'; 575 }elseif($item['open']){ 576 return '<li class="open">'; 577 }else{ 578 return '<li class="closed">'; 579 } 580} 581 582/** 583 * Default List item 584 * 585 * @author Andreas Gohr <andi@splitbrain.org> 586 */ 587function html_li_default($item){ 588 return '<li class="level'.$item['level'].'">'; 589} 590 591/** 592 * Build an unordered list 593 * 594 * Build an unordered list from the given $data array 595 * Each item in the array has to have a 'level' property 596 * the item itself gets printed by the given $func user 597 * function. The second and optional function is used to 598 * print the <li> tag. Both user function need to accept 599 * a single item. 600 * 601 * @author Andreas Gohr <andi@splitbrain.org> 602 */ 603function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 604 $level = 0; 605 $opens = 0; 606 $ret = ''; 607 608 foreach ($data as $item){ 609 610 if( $item['level'] > $level ){ 611 //open new list 612 for($i=0; $i<($item['level'] - $level); $i++){ 613 if ($i) $ret .= "<li class=\"clear\">\n"; 614 $ret .= "\n<ul class=\"$class\">\n"; 615 } 616 }elseif( $item['level'] < $level ){ 617 //close last item 618 $ret .= "</li>\n"; 619 for ($i=0; $i<($level - $item['level']); $i++){ 620 //close higher lists 621 $ret .= "</ul>\n</li>\n"; 622 } 623 }else{ 624 //close last item 625 $ret .= "</li>\n"; 626 } 627 628 //remember current level 629 $level = $item['level']; 630 631 //print item 632 $ret .= $lifunc($item); //user function 633 $ret .= '<span class="li">'; 634 $ret .= $func($item); //user function 635 $ret .= '</span>'; 636 } 637 638 //close remaining items and lists 639 for ($i=0; $i < $level; $i++){ 640 $ret .= "</li></ul>\n"; 641 } 642 643 return $ret; 644} 645 646/** 647 * display backlinks 648 * 649 * @author Andreas Gohr <andi@splitbrain.org> 650 */ 651function html_backlinks(){ 652 require_once(DOKU_INC.'inc/search.php'); 653 global $ID; 654 global $conf; 655 656 if(preg_match('#^(.*):(.*)$#',$ID,$matches)){ 657 $opts['ns'] = $matches[1]; 658 $opts['name'] = $matches[2]; 659 }else{ 660 $opts['ns'] = ''; 661 $opts['name'] = $ID; 662 } 663 664 print p_locale_xhtml('backlinks'); 665 666 $data = array(); 667 search($data,$conf['datadir'],'search_backlinks',$opts); 668 sort($data); 669 670 print '<ul class="idx">'; 671 foreach($data as $row){ 672 print '<li>'; 673 print html_wikilink(':'.$row['id'],$row['id']); 674 print '</li>'; 675 } 676 print '</ul>'; 677} 678 679/** 680 * show diff 681 * 682 * @author Andreas Gohr <andi@splitbrain.org> 683 */ 684function html_diff($text='',$intro=true){ 685 require_once(DOKU_INC.'inc/DifferenceEngine.php'); 686 global $ID; 687 global $REV; 688 global $lang; 689 global $conf; 690 if($text){ 691 $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), 692 split("\n",htmlspecialchars(cleanText($text)))); 693 $left = '<a class="wikilink1" href="'.wl($ID).'">'. 694 $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'. 695 $lang['current']; 696 $right = $lang['yours']; 697 }else{ 698 if($REV){ 699 $r = $REV; 700 }else{ 701 //use last revision if none given 702 $revs = getRevisions($ID); 703 $r = $revs[0]; 704 } 705 706 $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))), 707 split("\n",htmlspecialchars(rawWiki($ID,'')))); 708 $left = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'. 709 $ID.' '.date($conf['dformat'],$r).'</a>'; 710 $right = '<a class="wikilink1" href="'.wl($ID).'">'. 711 $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 712 $lang['current']; 713 } 714 $tdf = new TableDiffFormatter(); 715 if($intro) print p_locale_xhtml('diff'); 716 ?> 717 <table class="diff" width="100%"> 718 <tr> 719 <td colspan="2" width="50%" class="diff-header"> 720 <?=$left?> 721 </td> 722 <td colspan="2" width="50%" class="diff-header"> 723 <?=$right?> 724 </td> 725 </tr> 726 <?=$tdf->format($df)?> 727 </table> 728 <? 729} 730 731/** 732 * show warning on conflict detection 733 * 734 * @author Andreas Gohr <andi@splitbrain.org> 735 */ 736function html_conflict($text,$summary){ 737 global $ID; 738 global $lang; 739 740 print p_locale_xhtml('conflict'); 741 ?> 742 <form name="editform" method="post" action="<?=script()?>" accept-charset="<?=$lang['encoding']?>"> 743 <input type="hidden" name="id" value="<?=$ID?>" /> 744 <input type="hidden" name="wikitext" value="<?=formText($text)?>" /> 745 <input type="hidden" name="summary" value="<?=formText($summary)?>" /> 746 747 <div align="center"> 748 <input class="button" type="submit" name="do" value="<?=$lang['btn_save']?>" accesskey="s" title="[ALT+S]" /> 749 <input class="button" type="submit" name="do" value="<?=$lang['btn_cancel']?>" /> 750 </div> 751 </form> 752 <br /><br /><br /><br /> 753 <? 754} 755 756/** 757 * Prints the global message array 758 * 759 * @author Andreas Gohr <andi@splitbrain.org> 760 */ 761function html_msgarea(){ 762 global $MSG; 763 764 if(!isset($MSG)) return; 765 766 foreach($MSG as $msg){ 767 print '<div class="'.$msg['lvl'].'">'; 768 print $msg['msg']; 769 print '</div>'; 770 } 771} 772 773/** 774 * Prints the registration form 775 * 776 * @author Andreas Gohr <andi@splitbrain.org> 777 */ 778function html_register(){ 779 global $lang; 780 global $conf; 781 global $ID; 782 783 print p_locale_xhtml('register'); 784?> 785 <div align="center"> 786 <form name="register" method="post" action="<?=wl($ID)?>" accept-charset="<?=$lang['encoding']?>"> 787 <input type="hidden" name="do" value="register" /> 788 <input type="hidden" name="save" value="1" /> 789 <fieldset> 790 <legend><?=$lang['register']?></legend> 791 <label> 792 <?=$lang['user']?> 793 <input type="text" name="login" class="edit" size="50" value="<?=formText($_POST['login'])?>" /> 794 </label><br /> 795 796 <?php 797 if (!$conf['autopasswd']) { 798 ?> 799 <label> 800 <?=$lang['pass']?> 801 <input type="password" name="pass" class="edit" size="50" /> 802 </label><br /> 803 <label> 804 <?=$lang['passchk']?> 805 <input type="password" name="passchk" class="edit" size="50" /> 806 </label><br /> 807 <?php 808 } 809 ?> 810 811 <label> 812 <?=$lang['fullname']?> 813 <input type="text" name="fullname" class="edit" size="50" value="<?=formText($_POST['fullname'])?>" /> 814 </label><br /> 815 <label> 816 <?=$lang['email']?> 817 <input type="text" name="email" class="edit" size="50" value="<?=formText($_POST['email'])?>" /> 818 </label><br /> 819 <input type="submit" class="button" value="<?=$lang['register']?>" /> 820 </fieldset> 821 </form> 822 </div> 823<? 824} 825 826/** 827 * This displays the edit form (lots of logic included) 828 * 829 * @author Andreas Gohr <andi@splitbrain.org> 830 */ 831function html_edit($text=null,$include='edit'){ //FIXME: include needed? 832 global $ID; 833 global $REV; 834 global $DATE; 835 global $RANGE; 836 global $PRE; 837 global $SUF; 838 global $INFO; 839 global $SUM; 840 global $lang; 841 global $conf; 842 843 //set summary default 844 if(!$SUM){ 845 if($REV){ 846 $SUM = $lang['restored']; 847 }elseif(!$INFO['exists']){ 848 $SUM = $lang['created']; 849 } 850 } 851 852 //no text? Load it! 853 if(!isset($text)){ 854 $pr = false; //no preview mode 855 if($RANGE){ 856 list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 857 }else{ 858 $text = rawWiki($ID,$REV); 859 } 860 }else{ 861 $pr = true; //preview mode 862 } 863 864 $wr = $INFO['writable']; 865 if($wr){ 866 if ($REV) print p_locale_xhtml('editrev'); 867 print p_locale_xhtml($include); 868 }else{ 869 print p_locale_xhtml('read'); 870 $ro='readonly="readonly"'; 871 } 872 if(!$DATE) $DATE = $INFO['lastmod']; 873?> 874 <form name="editform" method="post" action="<?=script()?>" accept-charset="<?=$lang['encoding']?>" onsubmit="return svchk()"> 875 <input type="hidden" name="id" value="<?=$ID?>" /> 876 <input type="hidden" name="rev" value="<?=$REV?>" /> 877 <input type="hidden" name="date" value="<?=$DATE?>" /> 878 <input type="hidden" name="prefix" value="<?=formText($PRE)?>" /> 879 <input type="hidden" name="suffix" value="<?=formText($SUF)?>" /> 880 <table style="width:99%"> 881 <tr> 882 <td class="toolbar" colspan="3"> 883 <?if($wr){?> 884 <script language="JavaScript" type="text/javascript"> 885 <?/* sets changed to true when previewed */?> 886 textChanged = <? ($pr) ? print 'true' : print 'false' ?>; 887 888 formatButton('images/bold.png','<?=$lang['qb_bold']?>','**','**','<?=$lang['qb_bold']?>','b'); 889 formatButton('images/italic.png','<?=$lang['qb_italic']?>',"\/\/","\/\/",'<?=$lang['qb_italic']?>','i'); 890 formatButton('images/underline.png','<?=$lang['qb_underl']?>','__','__','<?=$lang['qb_underl']?>','u'); 891 formatButton('images/code.png','<?=$lang['qb_code']?>','\'\'','\'\'','<?=$lang['qb_code']?>','c'); 892 893 formatButton('images/fonth1.png','<?=$lang['qb_h1']?>','====== ',' ======\n','<?=$lang['qb_h1']?>','1'); 894 formatButton('images/fonth2.png','<?=$lang['qb_h2']?>','===== ',' =====\n','<?=$lang['qb_h2']?>','2'); 895 formatButton('images/fonth3.png','<?=$lang['qb_h3']?>','==== ',' ====\n','<?=$lang['qb_h3']?>','3'); 896 formatButton('images/fonth4.png','<?=$lang['qb_h4']?>','=== ',' ===\n','<?=$lang['qb_h4']?>','4'); 897 formatButton('images/fonth5.png','<?=$lang['qb_h5']?>','== ',' ==\n','<?=$lang['qb_h5']?>','5'); 898 899 formatButton('images/link.png','<?=$lang['qb_link']?>','[[',']]','<?=$lang['qb_link']?>','l'); 900 formatButton('images/extlink.png','<?=$lang['qb_extlink']?>','[[',']]','http://www.example.com|<?=$lang['qb_extlink']?>'); 901 902 formatButton('images/list.png','<?=$lang['qb_ol']?>',' - ','\n','<?=$lang['qb_ol']?>'); 903 formatButton('images/list_ul.png','<?=$lang['qb_ul']?>',' * ','\n','<?=$lang['qb_ul']?>'); 904 905 insertButton('images/rule.png','<?=$lang['qb_hr']?>','----\n'); 906 mediaButton('images/image.png','<?=$lang['qb_media']?>','m','<?=$INFO['namespace']?>'); 907 908 <? 909 if($conf['useacl'] && $_SERVER['REMOTE_USER']){ 910 echo "insertButton('images/sig.png','".$lang['qb_sig']."','".html_signature()."','y');"; 911 } 912 ?> 913 </script> 914 <?}?> 915 </td> 916 </tr> 917 <tr> 918 <td colspan="3"> 919 <textarea name="wikitext" id="wikitext" <?=$ro?> cols="80" rows="10" class="edit" onchange="textChanged = true;" onkeyup="summaryCheck();" tabindex="1"><?="\n".formText($text)?></textarea> 920 </td> 921 </tr> 922 <tr> 923 <td> 924 <?if($wr){?> 925 <input class="button" type="submit" name="do" value="<?=$lang['btn_save']?>" accesskey="s" title="[ALT+S]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="3" /> 926 <input class="button" type="submit" name="do" value="<?=$lang['btn_preview']?>" accesskey="p" title="[ALT+P]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="4" /> 927 <input class="button" type="submit" name="do" value="<?=$lang['btn_cancel']?>" tabindex="5" /> 928 <?}?> 929 </td> 930 <td> 931 <?if($wr){?> 932 <?=$lang['summary']?>: 933 <input type="text" class="edit" name="summary" id="summary" size="50" onkeyup="summaryCheck();" value="<?=formText($SUM)?>" tabindex="2" /> 934 <?}?> 935 </td> 936 <td align="right"> 937 <script type="text/javascript"> 938 showSizeCtl(); 939 <?if($wr){?> 940 init_locktimer(<?=$conf['locktime']-60?>,'<?=$lang['willexpire']?>'); 941 document.editform.wikitext.focus(); 942 <?}?> 943 </script> 944 </td> 945 </tr> 946 </table> 947 </form> 948<? 949} 950 951/** 952 * prepares the signature string as configured in the config 953 * 954 * @author Andreas Gohr <andi@splitbrain.org> 955 */ 956function html_signature(){ 957 global $conf; 958 global $INFO; 959 960 $sig = $conf['signature']; 961 $sig = strftime($sig); 962 $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig); 963 $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig); 964 $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig); 965 $sig = str_replace('@DATE@',date($conf['dformat']),$sig); 966 return $sig; 967} 968 969/** 970 * prints some debug info 971 * 972 * @author Andreas Gohr <andi@splitbrain.org> 973 */ 974function html_debug(){ 975 global $conf; 976 global $lang; 977 //remove sensitive data 978 $cnf = $conf; 979 $cnf['auth']='***'; 980 $cnf['notify']='***'; 981 $cnf['ftp']='***'; 982 983 print '<html><body>'; 984 985 print '<p>When reporting bugs please send all the following '; 986 print 'output as a mail to andi@splitbrain.org '; 987 print 'The best way to do this is to save this page in your browser</p>'; 988 989 print '<b>$_SERVER:</b><pre>'; 990 print_r($_SERVER); 991 print '</pre>'; 992 993 print '<b>$conf:</b><pre>'; 994 print_r($cnf); 995 print '</pre>'; 996 997 print '<b>DOKU_BASE:</b><pre>'; 998 print DOKU_BASE; 999 print '</pre>'; 1000 1001 print '<b>abs DOKU_BASE:</b><pre>'; 1002 print DOKU_URL; 1003 print '</pre>'; 1004 1005 print '<b>rel DOKU_BASE:</b><pre>'; 1006 print dirname($_SERVER['PHP_SELF']).'/'; 1007 print '</pre>'; 1008 1009 print '<b>PHP Version:</b><pre>'; 1010 print phpversion(); 1011 print '</pre>'; 1012 1013 print '<b>locale:</b><pre>'; 1014 print setlocale(LC_ALL,0); 1015 print '</pre>'; 1016 1017 print '<b>encoding:</b><pre>'; 1018 print $lang['encoding']; 1019 print '</pre>'; 1020 1021 print '<b>Environment:</b><pre>'; 1022 print_r($_ENV); 1023 print '</pre>'; 1024 1025 print '<b>PHP settings:</b><pre>'; 1026 $inis = ini_get_all(); 1027 print_r($inis); 1028 print '</pre>'; 1029 1030 print '</body></html>'; 1031} 1032 1033/** 1034 * Print the admin overview page 1035 * 1036 * @author Andreas Gohr <andi@splitbrain.org> 1037 */ 1038function html_admin(){ 1039 global $ID; 1040 global $lang; 1041 global $conf; 1042 1043 print p_locale_xhtml('admin'); 1044 1045 ptln('<ul class="admin">'); 1046 1047 // currently ACL only - more to come 1048 ptln('<li><a href="'.wl($ID,'do=admin&page=acl').'">'.$lang['admin_acl'].'</a></li>'); 1049 if (!$conf['openregister']){ 1050 ptln('<li><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></li>'); 1051 } 1052 1053 ptln('</ul>'); 1054} 1055 1056 1057//Setup VIM: ex: et ts=2 enc=utf-8 : 1058