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