xref: /dokuwiki/inc/html.php (revision 723d78db98a03f01d49b69501be9dc9cf2c52b50)
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    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$REV))),
637                    split("\n",htmlspecialchars(rawWiki($ID,''))));
638    $left  = '<a class="wikilink1" href="'.wl($ID,"rev=$REV").'">'.
639              $ID.' '.date($conf['dformat'],$REV).'</a>';
640    $right = '<a class="wikilink1" href="'.wl($ID).'">'.
641              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '.
642              $lang['current'];
643  }
644  $tdf = new TableDiffFormatter();
645  if($intro) print p_locale_xhtml('diff');
646  ?>
647    <table class="diff" width="100%">
648      <tr>
649        <td colspan="2" width="50%" class="diff-header">
650          <?=$left?>
651        </td>
652        <td colspan="2" width="50%" class="diff-header">
653          <?=$right?>
654        </td>
655      </tr>
656      <?=$tdf->format($df)?>
657    </table>
658  <?
659}
660
661/**
662 * show warning on conflict detection
663 *
664 * @author Andreas Gohr <andi@splitbrain.org>
665 */
666function html_conflict($text,$summary){
667  global $ID;
668  global $lang;
669
670  print p_locale_xhtml('conflict');
671  ?>
672  <form name="editform" method="post" action="<?=script()?>" accept-charset="<?=$lang['encoding']?>">
673  <input type="hidden" name="id" value="<?=$ID?>" />
674  <input type="hidden" name="wikitext" value="<?=formText($text)?>" />
675  <input type="hidden" name="summary" value="<?=formText($summary)?>" />
676
677  <div align="center">
678    <input class="button" type="submit" name="do" value="<?=$lang['btn_save']?>" accesskey="s" title="[ALT+S]" />
679    <input class="button" type="submit" name="do" value="<?=$lang['btn_cancel']?>" />
680  </div>
681  </form>
682  <br /><br /><br /><br />
683  <?
684}
685
686/**
687 * Prints the global message array
688 *
689 * @author Andreas Gohr <andi@splitbrain.org>
690 */
691function html_msgarea(){
692  global $MSG;
693
694  if(!isset($MSG)) return;
695
696  foreach($MSG as $msg){
697    print '<div class="'.$msg['lvl'].'">';
698    print $msg['msg'];
699    print '</div>';
700  }
701}
702
703/**
704 * Prints the registration form
705 *
706 * @author Andreas Gohr <andi@splitbrain.org>
707 */
708function html_register(){
709  global $lang;
710  global $ID;
711
712  print p_locale_xhtml('register');
713?>
714  <div align="center">
715  <form name="register" method="post" action="<?=wl($ID)?>" accept-charset="<?=$lang['encoding']?>">
716  <input type="hidden" name="do" value="register" />
717  <input type="hidden" name="save" value="1" />
718  <fieldset>
719    <legend><?=$lang['register']?></legend>
720    <label>
721      <?=$lang['user']?>
722      <input type="text" name="login" class="edit" size="50" value="<?=formText($_POST['login'])?>" />
723    </label><br />
724    <label>
725      <?=$lang['fullname']?>
726      <input type="text" name="fullname" class="edit" size="50" value="<?=formText($_POST['fullname'])?>" />
727    </label><br />
728    <label>
729      <?=$lang['email']?>
730      <input type="text" name="email" class="edit" size="50" value="<?=formText($_POST['email'])?>" />
731    </label><br />
732    <input type="submit" class="button" value="<?=$lang['register']?>" />
733  </fieldset>
734  </form>
735  </div>
736<?
737}
738
739/**
740 * This displays the edit form (lots of logic included)
741 *
742 * @author Andreas Gohr <andi@splitbrain.org>
743 */
744function html_edit($text=null,$include='edit'){ //FIXME: include needed?
745  global $ID;
746  global $REV;
747  global $DATE;
748  global $RANGE;
749  global $PRE;
750  global $SUF;
751  global $INFO;
752  global $SUM;
753  global $lang;
754  global $conf;
755
756  //set summary default
757  if(!$SUM){
758    if($REV){
759      $SUM = $lang['restored'];
760    }elseif(!$INFO['exists']){
761      $SUM = $lang['created'];
762    }
763  }
764
765  //no text? Load it!
766  if(!isset($text)){
767    $pr = false; //no preview mode
768    if($RANGE){
769      list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
770    }else{
771      $text = rawWiki($ID,$REV);
772    }
773  }else{
774    $pr = true; //preview mode
775  }
776
777  $wr = $INFO['writable'];
778  if($wr){
779    if ($REV) print p_locale_xhtml('editrev');
780    print p_locale_xhtml($include);
781  }else{
782    print p_locale_xhtml('read');
783    $ro='readonly="readonly"';
784  }
785  if(!$DATE) $DATE = $INFO['lastmod'];
786?>
787  <form name="editform" method="post" action="<?=script()?>" accept-charset="<?=$lang['encoding']?>" onsubmit="return svchk()">
788  <input type="hidden" name="id"   value="<?=$ID?>" />
789  <input type="hidden" name="rev"  value="<?=$REV?>" />
790  <input type="hidden" name="date" value="<?=$DATE?>" />
791  <input type="hidden" name="prefix" value="<?=formText($PRE)?>" />
792  <input type="hidden" name="suffix" value="<?=formText($SUF)?>" />
793  <table style="width:99%">
794    <tr>
795      <td class="toolbar" colspan="3">
796        <?if($wr){?>
797        <script language="JavaScript" type="text/javascript">
798          <?/* sets changed to true when previewed */?>
799          textChanged = <? ($pr) ? print 'true' : print 'false' ?>;
800
801          formatButton('images/bold.png','<?=$lang['qb_bold']?>','**','**','<?=$lang['qb_bold']?>','b');
802          formatButton('images/italic.png','<?=$lang['qb_italic']?>',"\/\/","\/\/",'<?=$lang['qb_italic']?>','i');
803          formatButton('images/underline.png','<?=$lang['qb_underl']?>','__','__','<?=$lang['qb_underl']?>','u');
804          formatButton('images/code.png','<?=$lang['qb_code']?>','\'\'','\'\'','<?=$lang['qb_code']?>','c');
805
806          formatButton('images/fonth1.png','<?=$lang['qb_h1']?>','====== ',' ======\n','<?=$lang['qb_h1']?>','1');
807          formatButton('images/fonth2.png','<?=$lang['qb_h2']?>','===== ',' =====\n','<?=$lang['qb_h2']?>','2');
808          formatButton('images/fonth3.png','<?=$lang['qb_h3']?>','==== ',' ====\n','<?=$lang['qb_h3']?>','3');
809          formatButton('images/fonth4.png','<?=$lang['qb_h4']?>','=== ',' ===\n','<?=$lang['qb_h4']?>','4');
810          formatButton('images/fonth5.png','<?=$lang['qb_h5']?>','== ',' ==\n','<?=$lang['qb_h5']?>','5');
811
812          formatButton('images/link.png','<?=$lang['qb_link']?>','[[',']]','<?=$lang['qb_link']?>','l');
813          formatButton('images/extlink.png','<?=$lang['qb_extlink']?>','[[',']]','http://www.example.com|<?=$lang['qb_extlink']?>');
814
815          formatButton('images/list.png','<?=$lang['qb_ol']?>','  - ','\n','<?=$lang['qb_ol']?>');
816          formatButton('images/list_ul.png','<?=$lang['qb_ul']?>','  * ','\n','<?=$lang['qb_ul']?>');
817
818          insertButton('images/rule.png','<?=$lang['qb_hr']?>','----\n');
819          mediaButton('images/image.png','<?=$lang['qb_media']?>','m','<?=$INFO['namespace']?>');
820
821          <?
822          if($conf['useacl'] && $_SERVER['REMOTE_USER']){
823            echo "insertButton('images/sig.png','".$lang['qb_sig']."','".html_signature()."','y');";
824          }
825          ?>
826        </script>
827        <?}?>
828      </td>
829    </tr>
830    <tr>
831      <td colspan="3">
832        <textarea name="wikitext" id="wikitext" <?=$ro?> cols="80" rows="10" class="edit" onchange="textChanged = true;" onkeyup="summaryCheck();" tabindex="1"><?="\n".formText($text)?></textarea>
833      </td>
834    </tr>
835    <tr>
836      <td>
837      <?if($wr){?>
838        <input class="button" type="submit" name="do" value="<?=$lang['btn_save']?>" accesskey="s" title="[ALT+S]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="3" />
839        <input class="button" type="submit" name="do" value="<?=$lang['btn_preview']?>" accesskey="p" title="[ALT+P]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="4" />
840        <input class="button" type="submit" name="do" value="<?=$lang['btn_cancel']?>" tabindex="5" />
841      <?}?>
842      </td>
843      <td>
844      <?if($wr){?>
845        <?=$lang['summary']?>:
846        <input type="text" class="edit" name="summary" id="summary" size="50" onkeyup="summaryCheck();" value="<?=formText($SUM)?>" tabindex="2" />
847      <?}?>
848      </td>
849      <td align="right">
850        <script type="text/javascript">
851          showSizeCtl();
852          <?if($wr){?>
853            init_locktimer(<?=$conf['locktime']-60?>,'<?=$lang['willexpire']?>');
854            document.editform.wikitext.focus();
855          <?}?>
856        </script>
857      </td>
858    </tr>
859  </table>
860  </form>
861<?
862}
863
864/**
865 * prepares the signature string as configured in the config
866 *
867 * @author Andreas Gohr <andi@splitbrain.org>
868 */
869function html_signature(){
870  global $conf;
871  global $INFO;
872
873  $sig = $conf['signature'];
874  $sig = strftime($sig);
875  $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig);
876  $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig);
877  $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig);
878  $sig = str_replace('@DATE@',date($conf['dformat']),$sig);
879  return $sig;
880}
881
882/**
883 * prints some debug info
884 *
885 * @author Andreas Gohr <andi@splitbrain.org>
886 */
887function html_debug(){
888  global $conf;
889  global $lang;
890  //remove sensitive data
891  $cnf = $conf;
892  $cnf['auth']='***';
893  $cnf['notify']='***';
894  $cnf['ftp']='***';
895
896  print '<html><body>';
897
898  print '<p>When reporting bugs please send all the following ';
899  print 'output as a mail to andi@splitbrain.org ';
900  print 'The best way to do this is to save this page in your browser</p>';
901
902  print '<b>$_SERVER:</b><pre>';
903  print_r($_SERVER);
904  print '</pre>';
905
906  print '<b>$conf:</b><pre>';
907  print_r($cnf);
908  print '</pre>';
909
910  print '<b>DOKU_BASE:</b><pre>';
911  print DOKU_BASE;
912  print '</pre>';
913
914  print '<b>abs DOKU_BASE:</b><pre>';
915  print DOKU_URL;
916  print '</pre>';
917
918  print '<b>rel DOKU_BASE:</b><pre>';
919  print dirname($_SERVER['PHP_SELF']).'/';
920  print '</pre>';
921
922  print '<b>PHP Version:</b><pre>';
923  print phpversion();
924  print '</pre>';
925
926  print '<b>locale:</b><pre>';
927  print setlocale(LC_ALL,0);
928  print '</pre>';
929
930  print '<b>encoding:</b><pre>';
931  print $lang['encoding'];
932  print '</pre>';
933
934  print '<b>Environment:</b><pre>';
935  print_r($_ENV);
936  print '</pre>';
937
938  print '<b>PHP settings:</b><pre>';
939  $inis = ini_get_all();
940  print_r($inis);
941  print '</pre>';
942
943  print '</body></html>';
944}
945
946/**
947 * Print the admin overview page
948 *
949 * @author  Andreas Gohr <andi@splitbrain.org>
950 */
951function html_admin(){
952  global $ID;
953  global $lang;
954
955  print p_locale_xhtml('admin');
956
957  ptln('<ul class="admin">');
958
959  // currently ACL only - more to come
960  ptln('<li><a href="'.wl($ID,'do=admin&page=acl').'">'.$lang['admin_acl'].'</a></li>');
961
962  ptln('</ul>');
963}
964
965
966//Setup VIM: ex: et ts=2 enc=utf-8 :
967