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