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