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