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