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