xref: /dokuwiki/inc/html.php (revision daf4ca4eab09b934b46fb35293fcbfd854571ed4)
1ed7b5f09Sandi<?php
215fae107Sandi/**
315fae107Sandi * HTML output functions
415fae107Sandi *
515fae107Sandi * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
615fae107Sandi * @author     Andreas Gohr <andi@splitbrain.org>
715fae107Sandi */
815fae107Sandi
9ed7b5f09Sandi  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
10f3f0262cSandi
116bbae538Sandi  require_once(DOKU_INC.'inc/parserutils.php');
126bbae538Sandi
13f3f0262cSandi/**
14f3f0262cSandi * Convenience function to quickly build a wikilink
1515fae107Sandi *
1615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
17f3f0262cSandi */
1830f1737dSandifunction html_wikilink($id,$name=NULL,$search=''){
19723d78dbSandi  static $xhtml_renderer = NULL;
20723d78dbSandi  if(is_null($xhtml_renderer)){
21fdf3dcb9SMatthias Urlichs    require_once(DOKU_INC.'inc/parser/xhtml.php');
22723d78dbSandi    $xhtml_renderer = new Doku_Renderer_xhtml();
23f3f0262cSandi  }
24f3f0262cSandi
25cffcc403Sandi  return $xhtml_renderer->internallink($id,$name,$search,true);
26f3f0262cSandi}
27f3f0262cSandi
28f3f0262cSandi/**
29c19fe9c0Sandi * Helps building long attribute lists
30c19fe9c0Sandi *
31c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org>
32c19fe9c0Sandi */
33c19fe9c0Sandifunction html_attbuild($attributes){
34c19fe9c0Sandi  $ret = '';
35c19fe9c0Sandi  foreach ( $attributes as $key => $value ) {
36c19fe9c0Sandi    $ret .= $key.'="'.formtext($value).'" ';
37c19fe9c0Sandi  }
38c19fe9c0Sandi  return trim($ret);
39c19fe9c0Sandi}
40c19fe9c0Sandi
41c19fe9c0Sandi/**
42f3f0262cSandi * The loginform
4315fae107Sandi *
4415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
45f3f0262cSandi */
46f3f0262cSandifunction html_login(){
47f3f0262cSandi  global $lang;
48f3f0262cSandi  global $conf;
49f3f0262cSandi  global $ID;
50cd52f92dSchris  global $auth;
51f3f0262cSandi
52c112d578Sandi  print p_locale_xhtml('login');
53f3f0262cSandi  ?>
5496331712SAnika Henke    <div class="centeralign">
554da078a3Smatthiasgrimm    <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" method="post">
56f3f0262cSandi      <fieldset>
574da078a3Smatthiasgrimm        <legend><?php echo $lang['btn_login']?></legend>
584da078a3Smatthiasgrimm        <input type="hidden" name="id" value="<?php echo $ID?>" />
59f3f0262cSandi        <input type="hidden" name="do" value="login" />
60b6912aeaSAndreas Gohr        <label class="block">
614da078a3Smatthiasgrimm          <span><?php echo $lang['user']?></span>
624da078a3Smatthiasgrimm          <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" />
63f3f0262cSandi        </label><br />
64b6912aeaSAndreas Gohr        <label class="block">
654da078a3Smatthiasgrimm          <span><?php echo $lang['pass']?></span>
66f3f0262cSandi          <input type="password" name="p" class="edit" />
67f3f0262cSandi        </label><br />
684da078a3Smatthiasgrimm        <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" />
690c1887a0SAndreas Gohr        <label for="remember__me" class="simple">
704d6f545eSAndreas Gohr          <input type="checkbox" name="r" id="remember__me" value="1" />
714da078a3Smatthiasgrimm          <span><?php echo $lang['remember']?></span>
72132bdbfeSandi        </label>
73f3f0262cSandi      </fieldset>
74f3f0262cSandi    </form>
754da078a3Smatthiasgrimm  <?php
7682fd59b6SAndreas Gohr    if($auth->canDo('addUser') && $conf['openregister']){
77f3f0262cSandi      print '<p>';
78f3f0262cSandi      print $lang['reghere'];
79f3f0262cSandi      print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>';
80f3f0262cSandi      print '</p>';
81f3f0262cSandi    }
828b06d178Schris
8382fd59b6SAndreas Gohr    if ($auth->canDo('modPass') && $conf['resendpasswd']) {
848b06d178Schris      print '<p>';
858b06d178Schris      print $lang['pwdforget'];
86753d5abfSMatthias Grimm      print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['btn_resendpwd'].'</a>';
878b06d178Schris      print '</p>';
888b06d178Schris    }
89f3f0262cSandi  ?>
90f3f0262cSandi    </div>
914da078a3Smatthiasgrimm  <?php
926bbae538Sandi/*
936bbae538Sandi FIXME provide new hook
94f3f0262cSandi  if(@file_exists('includes/login.txt')){
95f3f0262cSandi    print io_cacheParse('includes/login.txt');
96f3f0262cSandi  }
976bbae538Sandi*/
98f3f0262cSandi}
99f3f0262cSandi
100f3f0262cSandi/**
101f3f0262cSandi * shows the edit/source/show button dependent on current mode
10215fae107Sandi *
10315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
104f3f0262cSandi */
105f3f0262cSandifunction html_editbutton(){
106f3f0262cSandi  global $ID;
107f3f0262cSandi  global $REV;
108f3f0262cSandi  global $ACT;
109f3f0262cSandi  global $INFO;
110f3f0262cSandi
111f3f0262cSandi  if($ACT == 'show' || $ACT == 'search'){
112f3f0262cSandi    if($INFO['writable']){
113f3f0262cSandi      if($INFO['exists']){
114f3f0262cSandi        $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
115f3f0262cSandi      }else{
116f3f0262cSandi        $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
117f3f0262cSandi      }
118f3f0262cSandi    }else{
119f3f0262cSandi      $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post');
120f3f0262cSandi    }
121f3f0262cSandi  }else{
122f3f0262cSandi    $r = html_btn('show',$ID,'v',array('do' => 'show'));
123f3f0262cSandi  }
124f3f0262cSandi  return $r;
125f3f0262cSandi}
126f3f0262cSandi
12715fae107Sandi/**
12815fae107Sandi * prints a section editing button
12915fae107Sandi *
13015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
13115fae107Sandi */
132f3f0262cSandifunction html_secedit_button($section,$p){
133f3f0262cSandi  global $ID;
134f3f0262cSandi  global $lang;
135f3f0262cSandi  $secedit  = '';
136506ae684Sandi#  if($p) $secedit .= "</p>\n";
137f3f0262cSandi  $secedit .= '<div class="secedit">';
138f3f0262cSandi  $secedit .= html_btn('secedit',$ID,'',
139f3f0262cSandi                        array('do'      => 'edit',
140f3f0262cSandi                              'lines'   => "$section"),
141f3f0262cSandi                              'post');
142f3f0262cSandi  $secedit .= '</div>';
143506ae684Sandi#  if($p) $secedit .= "\n<p>";
144f3f0262cSandi  return $secedit;
145f3f0262cSandi}
146f3f0262cSandi
14715fae107Sandi/**
14815fae107Sandi * inserts section edit buttons if wanted or removes the markers
14915fae107Sandi *
15015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
15115fae107Sandi */
152f3f0262cSandifunction html_secedit($text,$show=true){
153f3f0262cSandi  global $INFO;
154c112d578Sandi  if($INFO['writable'] && $show && !$INFO['rev']){
155f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e',
156f3f0262cSandi                         "html_secedit_button('\\1',true)",
157f3f0262cSandi                         $text);
158f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e',
159f3f0262cSandi                         "html_secedit_button('\\1',false)",
160f3f0262cSandi                         $text);
161f3f0262cSandi  }else{
162f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text);
163f3f0262cSandi  }
164f3f0262cSandi  return $text;
165f3f0262cSandi}
166f3f0262cSandi
167f3f0262cSandi/**
168d6c9c552Smatthiasgrimm * Just the back to top button (in its own form)
1696b13307fSandi *
1706b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
1716b13307fSandi */
1726b13307fSandifunction html_topbtn(){
1736b13307fSandi  global $lang;
1746b13307fSandi
1756b13307fSandi  $ret  = '';
176265e3787Sandi  $ret  = '<a href="#top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>';
177df7b6005Sandi
1786b13307fSandi  return $ret;
1796b13307fSandi}
1806b13307fSandi
1816b13307fSandi/**
182d67ca2c0Smatthiasgrimm * Just the back to media window button in its own form
183d67ca2c0Smatthiasgrimm *
184d67ca2c0Smatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
185d67ca2c0Smatthiasgrimm */
186d67ca2c0Smatthiasgrimmfunction html_backtomedia_button($params,$akey=''){
187d67ca2c0Smatthiasgrimm  global $conf;
188d67ca2c0Smatthiasgrimm  global $lang;
189d67ca2c0Smatthiasgrimm
1904beabca9SAnika Henke  $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php"><div class="no">';
191d67ca2c0Smatthiasgrimm
192d67ca2c0Smatthiasgrimm  reset($params);
193d67ca2c0Smatthiasgrimm  while (list($key, $val) = each($params)) {
194d67ca2c0Smatthiasgrimm    $ret .= '<input type="hidden" name="'.$key.'" ';
195d67ca2c0Smatthiasgrimm    $ret .= 'value="'.htmlspecialchars($val).'" />';
196d67ca2c0Smatthiasgrimm  }
197d67ca2c0Smatthiasgrimm
198d67ca2c0Smatthiasgrimm  $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" ';
199d67ca2c0Smatthiasgrimm  if($akey){
200d67ca2c0Smatthiasgrimm    $ret .= 'title="ALT+'.strtoupper($akey).'" ';
201d67ca2c0Smatthiasgrimm    $ret .= 'accesskey="'.$akey.'" ';
202d67ca2c0Smatthiasgrimm  }
203d67ca2c0Smatthiasgrimm  $ret .= '/>';
2044beabca9SAnika Henke  $ret .= '</div></form>';
205d67ca2c0Smatthiasgrimm
206d67ca2c0Smatthiasgrimm  return $ret;
207d67ca2c0Smatthiasgrimm}
208d67ca2c0Smatthiasgrimm
209d67ca2c0Smatthiasgrimm/**
210d67ca2c0Smatthiasgrimm * Displays a button (using its own form)
21115fae107Sandi *
21215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
213f3f0262cSandi */
214f3f0262cSandifunction html_btn($name,$id,$akey,$params,$method='get'){
215f3f0262cSandi  global $conf;
216f3f0262cSandi  global $lang;
217f3f0262cSandi
218f3f0262cSandi  $label = $lang['btn_'.$name];
219f3f0262cSandi
220f3f0262cSandi  $ret = '';
221f3f0262cSandi
22249c713a3Sandi  //filter id (without urlencoding)
22349c713a3Sandi  $id = idfilter($id,false);
224f3f0262cSandi
225f3f0262cSandi  //make nice URLs even for buttons
2266c7843b5Sandi  if($conf['userewrite'] == 2){
2276c7843b5Sandi    $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
2286c7843b5Sandi  }elseif($conf['userewrite']){
2296c7843b5Sandi    $script = DOKU_BASE.$id;
2306c7843b5Sandi  }else{
2318b00ebcfSandi    $script = DOKU_BASE.DOKU_SCRIPT;
232f3f0262cSandi    $params['id'] = $id;
233f3f0262cSandi  }
234f3f0262cSandi
2354beabca9SAnika Henke  $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">';
236f3f0262cSandi
23706a4bf8fSAndreas Gohr  if(is_array($params)){
238f3f0262cSandi    reset($params);
239f3f0262cSandi    while (list($key, $val) = each($params)) {
240f3f0262cSandi      $ret .= '<input type="hidden" name="'.$key.'" ';
241f3f0262cSandi      $ret .= 'value="'.htmlspecialchars($val).'" />';
242f3f0262cSandi    }
24306a4bf8fSAndreas Gohr  }
244f3f0262cSandi
245f3f0262cSandi  $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
246f3f0262cSandi  if($akey){
247f3f0262cSandi    $ret .= 'title="ALT+'.strtoupper($akey).'" ';
248f3f0262cSandi    $ret .= 'accesskey="'.$akey.'" ';
249f3f0262cSandi  }
250f3f0262cSandi  $ret .= '/>';
2514beabca9SAnika Henke  $ret .= '</div></form>';
252f3f0262cSandi
253f3f0262cSandi  return $ret;
254f3f0262cSandi}
255f3f0262cSandi
256f3f0262cSandi/**
25715fae107Sandi * show a wiki page
25815fae107Sandi *
25915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
26015fae107Sandi */
2616bbae538Sandifunction html_show($txt=''){
262f3f0262cSandi  global $ID;
263f3f0262cSandi  global $REV;
264f3f0262cSandi  global $HIGH;
265f3f0262cSandi  //disable section editing for old revisions or in preview
2665400331dSandi  if($txt || $REV){
2676bbae538Sandi    $secedit = false;
2686bbae538Sandi  }else{
2696bbae538Sandi    $secedit = true;
270f3f0262cSandi  }
271f3f0262cSandi
2726bbae538Sandi  if ($txt){
273f3f0262cSandi    //PreviewHeader
27450835be7SAndreas Gohr    print '<br id="scroll__here" />';
275c112d578Sandi    print p_locale_xhtml('preview');
276f3f0262cSandi    print '<div class="preview">';
2779dc2c2afSandi    print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
27846723c19SAndreas Gohr    print '<div class="clearer"></div>';
279f3f0262cSandi    print '</div>';
2806bbae538Sandi
281f3f0262cSandi  }else{
282c112d578Sandi    if ($REV) print p_locale_xhtml('showrev');
283c112d578Sandi    $html = p_wiki_xhtml($ID,$REV,true);
2846bbae538Sandi    $html = html_secedit($html,$secedit);
285f3f0262cSandi    print html_hilight($html,$HIGH);
286f3f0262cSandi  }
287f3f0262cSandi}
288f3f0262cSandi
289f3f0262cSandi/**
290f3f0262cSandi * Highlights searchqueries in HTML code
29115fae107Sandi *
29215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
2937209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
294f3f0262cSandi */
295f3f0262cSandifunction html_hilight($html,$query){
2967209be23SAndreas Gohr  //split at common delimiters
2979d9c165eSAndreas Gohr  $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY);
298f3f0262cSandi  foreach ($queries as $q){
299f3f0262cSandi     $q = preg_quote($q,'/');
3007209be23SAndreas Gohr     $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html);
301f3f0262cSandi  }
302f3f0262cSandi  return $html;
303f3f0262cSandi}
304f3f0262cSandi
305f3f0262cSandi/**
3067209be23SAndreas Gohr * Callback used by html_hilight()
3077209be23SAndreas Gohr *
3087209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
3097209be23SAndreas Gohr */
3107209be23SAndreas Gohrfunction html_hilight_callback($m) {
3117209be23SAndreas Gohr  $hlight = unslash($m[0]);
3127209be23SAndreas Gohr  if ( !isset($m[2])) {
3137209be23SAndreas Gohr    $hlight = '<span class="search_hit">'.$hlight.'</span>';
3147209be23SAndreas Gohr  }
3157209be23SAndreas Gohr  return $hlight;
3167209be23SAndreas Gohr}
3177209be23SAndreas Gohr
3187209be23SAndreas Gohr/**
31915fae107Sandi * Run a search and display the result
32015fae107Sandi *
32115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
322f3f0262cSandi */
323f3f0262cSandifunction html_search(){
324ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
325506fa893SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
326f3f0262cSandi  global $conf;
327f3f0262cSandi  global $QUERY;
328f3f0262cSandi  global $ID;
329f3f0262cSandi  global $lang;
330f3f0262cSandi
331c112d578Sandi  print p_locale_xhtml('searchpage');
332f3f0262cSandi  flush();
333f3f0262cSandi
3344d9ff3d5Sandi  //show progressbar
3359edac8a8SAndreas Gohr  print '<div class="centeralign" id="dw__loading">';
3364d9ff3d5Sandi  print '<br /></div>';
3379edac8a8SAndreas Gohr  print '<script type="text/javascript" charset="utf-8">';
3389edac8a8SAndreas Gohr  print 'showLoadBar("dw__loading");';
3399edac8a8SAndreas Gohr  print '</script>';
3409edac8a8SAndreas Gohr  flush();
3414d9ff3d5Sandi
342f3f0262cSandi  //do quick pagesearch
343f3f0262cSandi  $data = array();
344506fa893SAndreas Gohr  $data = ft_pageLookup(cleanID($QUERY));
345f3f0262cSandi  if(count($data)){
346f3f0262cSandi    sort($data);
347f3f0262cSandi    print '<div class="search_quickresult">';
3484f732f0eSAnika Henke    print '<h3>'.$lang[quickhits].':</h3>';
3494f732f0eSAnika Henke    print '<ul class="search_quickhits">';
350140c93f3SAnika Henke    foreach($data as $id){
3514f732f0eSAnika Henke      print '<li> ';
352506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id);
3534f732f0eSAnika Henke      print '</li> ';
354f3f0262cSandi    }
355140c93f3SAnika Henke    print '</ul> ';
356f3f0262cSandi    //clear float (see http://www.complexspiral.com/publications/containing-floats/)
357f3f0262cSandi    print '<div class="clearer">&nbsp;</div>';
358f3f0262cSandi    print '</div>';
359f3f0262cSandi  }
360f3f0262cSandi  flush();
361f3f0262cSandi
362f3f0262cSandi  //do fulltext search
363506fa893SAndreas Gohr  $data = ft_pageSearch($QUERY,$poswords);
364f3f0262cSandi  if(count($data)){
365506fa893SAndreas Gohr    $num = 1;
366506fa893SAndreas Gohr    foreach($data as $id => $cnt){
367f3f0262cSandi      print '<div class="search_result">';
368506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords);
369506fa893SAndreas Gohr      print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
370506fa893SAndreas Gohr      if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
371506fa893SAndreas Gohr        print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>';
372506fa893SAndreas Gohr      }
373f3f0262cSandi      print '</div>';
374506fa893SAndreas Gohr      flush();
375506fa893SAndreas Gohr      $num++;
376f3f0262cSandi    }
377f3f0262cSandi  }else{
378820fa24bSandi    print '<div class="nothing">'.$lang['nothingfound'].'</div>';
379f3f0262cSandi  }
3804d9ff3d5Sandi
3814d9ff3d5Sandi  //hide progressbar
3824beabca9SAnika Henke  print '<script type="text/javascript" charset="utf-8">';
3839edac8a8SAndreas Gohr  print 'hideLoadBar("dw__loading");';
3844d9ff3d5Sandi  print '</script>';
3859edac8a8SAndreas Gohr  flush();
386f3f0262cSandi}
387f3f0262cSandi
38815fae107Sandi/**
38915fae107Sandi * Display error on locked pages
39015fae107Sandi *
39115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
39215fae107Sandi */
393ee20e7d1Sandifunction html_locked(){
394f3f0262cSandi  global $ID;
395f3f0262cSandi  global $conf;
396f3f0262cSandi  global $lang;
39788f522e9Sandi  global $INFO;
398f3f0262cSandi
399f3f0262cSandi  $locktime = filemtime(wikiFN($ID).'.lock');
400f3f0262cSandi  $expire = @date($conf['dformat'], $locktime + $conf['locktime'] );
401f3f0262cSandi  $min    = round(($conf['locktime'] - (time() - $locktime) )/60);
402f3f0262cSandi
403c112d578Sandi  print p_locale_xhtml('locked');
404f3f0262cSandi  print '<ul>';
4050c6b58a8SAndreas Gohr  print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>';
4060c6b58a8SAndreas Gohr  print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>';
407f3f0262cSandi  print '</ul>';
408f3f0262cSandi}
409f3f0262cSandi
41015fae107Sandi/**
41115fae107Sandi * list old revisions
41215fae107Sandi *
41315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
41415fae107Sandi */
415f3f0262cSandifunction html_revisions(){
416f3f0262cSandi  global $ID;
417f3f0262cSandi  global $INFO;
418f3f0262cSandi  global $conf;
419f3f0262cSandi  global $lang;
420f3f0262cSandi  $revisions = getRevisions($ID);
421f3f0262cSandi  $date = @date($conf['dformat'],$INFO['lastmod']);
422f3f0262cSandi
423c112d578Sandi  print p_locale_xhtml('revisions');
424f3f0262cSandi  print '<ul>';
425f3f0262cSandi  if($INFO['exists']){
426b6912aeaSAndreas Gohr    print ($INFO['minor']) ? '<li class="minor">' : '<li>';
4270c6b58a8SAndreas Gohr    print '<div class="li">';
428f9b2fe70Sandi
429f9b2fe70Sandi    print $date;
430f9b2fe70Sandi
43102e51121SAnika Henke    print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> ';
432cffcc403Sandi
433f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ';
434652610a2Sandi
435652610a2Sandi    print $INFO['sum'];
43688f522e9Sandi    print ' <span class="user">';
43788f522e9Sandi    print $INFO['editor'];
43888f522e9Sandi    print '</span> ';
439652610a2Sandi
440652610a2Sandi    print '('.$lang['current'].')';
4410c6b58a8SAndreas Gohr    print '</div>';
442652610a2Sandi    print '</li>';
443f3f0262cSandi  }
444f3f0262cSandi
445f3f0262cSandi  foreach($revisions as $rev){
446f3f0262cSandi    $date = date($conf['dformat'],$rev);
447652610a2Sandi    $info = getRevisionInfo($ID,$rev);
448652610a2Sandi
449b6912aeaSAndreas Gohr    print ($info['minor']) ? '<li class="minor">' : '<li>';
4500c6b58a8SAndreas Gohr    print '<div class="li">';
451f9b2fe70Sandi    print $date;
452f9b2fe70Sandi
453cffcc403Sandi    print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
454d94f4568SAndreas Gohr    $p = array();
455d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
456d94f4568SAndreas Gohr    $p['width']  = 15;
457d94f4568SAndreas Gohr    $p['height'] = 11;
458d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
459d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
460d94f4568SAndreas Gohr    $att = buildAttributes($p);
461d94f4568SAndreas Gohr    print "<img $att />";
462cffcc403Sandi    print '</a> ';
463cffcc403Sandi
464f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> ';
465f9b2fe70Sandi
466f243a77fSandi    print htmlspecialchars($info['sum']);
46788f522e9Sandi    print ' <span class="user">';
46888f522e9Sandi    if($info['user']){
46988f522e9Sandi      print $info['user'];
47088f522e9Sandi    }else{
471652610a2Sandi      print $info['ip'];
47288f522e9Sandi    }
47388f522e9Sandi    print '</span>';
474652610a2Sandi
4750c6b58a8SAndreas Gohr    print '</div>';
476f3f0262cSandi    print '</li>';
477f3f0262cSandi  }
478f3f0262cSandi  print '</ul>';
479f3f0262cSandi}
480f3f0262cSandi
48115fae107Sandi/**
48215fae107Sandi * display recent changes
48315fae107Sandi *
48415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
4855749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
48615fae107Sandi */
487a39955b0Smatthiasgrimmfunction html_recent($first=0){
488f3f0262cSandi  global $conf;
489cffcc403Sandi  global $lang;
490dbb00abcSEsther Brunner  global $ID;
4915749f1ceSmatthiasgrimm  /* we need to get one additionally log entry to be able to
4925749f1ceSmatthiasgrimm   * decide if this is the last page or is there another one.
4935749f1ceSmatthiasgrimm   * This is the cheapest solution to get this information.
4945749f1ceSmatthiasgrimm   */
495b6912aeaSAndreas Gohr  $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
4965749f1ceSmatthiasgrimm  if(count($recents) == 0 && $first != 0){
4975749f1ceSmatthiasgrimm    $first=0;
498b6912aeaSAndreas Gohr    $recents = getRecents(0,$conf['recent'] + 1,getNS($ID));
4995749f1ceSmatthiasgrimm  }
5005749f1ceSmatthiasgrimm  $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
501f3f0262cSandi
502c112d578Sandi  print p_locale_xhtml('recent');
503f3f0262cSandi  print '<ul>';
504a39955b0Smatthiasgrimm
505d437bcc4SAndreas Gohr  foreach($recents as $recent){
506d437bcc4SAndreas Gohr    $date = date($conf['dformat'],$recent['date']);
507b6912aeaSAndreas Gohr    print ($recent['minor']) ? '<li class="minor">' : '<li>';
5080c6b58a8SAndreas Gohr    print '<div class="li">';
509cffcc403Sandi
510f9b2fe70Sandi    print $date.' ';
511f9b2fe70Sandi
512d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=diff").'">';
513d94f4568SAndreas Gohr    $p = array();
514d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
515d94f4568SAndreas Gohr    $p['width']  = 15;
516d94f4568SAndreas Gohr    $p['height'] = 11;
517d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
518d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
519d94f4568SAndreas Gohr    $att = buildAttributes($p);
520d94f4568SAndreas Gohr    print "<img $att />";
521cffcc403Sandi    print '</a> ';
522cffcc403Sandi
523d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=revisions").'">';
524d94f4568SAndreas Gohr    $p = array();
525d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/history.png';
526d94f4568SAndreas Gohr    $p['width']  = 12;
527d94f4568SAndreas Gohr    $p['height'] = 14;
528d94f4568SAndreas Gohr    $p['title']  = $lang['btn_revs'];
529d94f4568SAndreas Gohr    $p['alt']    = $lang['btn_revs'];
530d94f4568SAndreas Gohr    $att = buildAttributes($p);
531d94f4568SAndreas Gohr    print "<img $att />";
532cffcc403Sandi    print '</a> ';
533cffcc403Sandi
534d437bcc4SAndreas Gohr    print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
535d437bcc4SAndreas Gohr    print ' '.htmlspecialchars($recent['sum']);
536b6912aeaSAndreas Gohr
53788f522e9Sandi    print ' <span class="user">';
538d437bcc4SAndreas Gohr    if($recent['user']){
539d437bcc4SAndreas Gohr      print $recent['user'];
54088f522e9Sandi    }else{
541d437bcc4SAndreas Gohr      print $recent['ip'];
54288f522e9Sandi    }
54388f522e9Sandi    print '</span>';
544cffcc403Sandi
5450c6b58a8SAndreas Gohr    print '</div>';
546f3f0262cSandi    print '</li>';
547f3f0262cSandi  }
548f3f0262cSandi  print '</ul>';
549a39955b0Smatthiasgrimm
550a39955b0Smatthiasgrimm  print '<div class="pagenav">';
5515749f1ceSmatthiasgrimm  $last = $first + $conf['recent'];
552a39955b0Smatthiasgrimm  if ($first > 0) {
553a39955b0Smatthiasgrimm    $first -= $conf['recent'];
554a39955b0Smatthiasgrimm    if ($first < 0) $first = 0;
555a39955b0Smatthiasgrimm    print '<div class="pagenav-prev">';
5565749f1ceSmatthiasgrimm    print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
557a39955b0Smatthiasgrimm    print '</div>';
558a39955b0Smatthiasgrimm  }
5595749f1ceSmatthiasgrimm  if ($conf['recent'] < count($recents)) {
560a39955b0Smatthiasgrimm    print '<div class="pagenav-next">';
5615749f1ceSmatthiasgrimm    print html_btn('older','',"n",array('do' => 'recent', 'first' => $last));
562a39955b0Smatthiasgrimm    print '</div>';
563a39955b0Smatthiasgrimm  }
564a39955b0Smatthiasgrimm  print '</div>';
565f3f0262cSandi}
566f3f0262cSandi
56715fae107Sandi/**
56815fae107Sandi * Display page index
56915fae107Sandi *
57015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
57115fae107Sandi */
572f3f0262cSandifunction html_index($ns){
573ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
574f3f0262cSandi  global $conf;
575f3f0262cSandi  global $ID;
576f3f0262cSandi  $dir = $conf['datadir'];
577f3f0262cSandi  $ns  = cleanID($ns);
57830f1737dSandi  #fixme use appropriate function
579f3f0262cSandi  if(empty($ns)){
580f3f0262cSandi    $ns = dirname(str_replace(':','/',$ID));
581f3f0262cSandi    if($ns == '.') $ns ='';
582f3f0262cSandi  }
58388d3a917Sandi  $ns  = utf8_encodeFN(str_replace(':','/',$ns));
584f3f0262cSandi
585c112d578Sandi  print p_locale_xhtml('index');
586f3f0262cSandi
587f3f0262cSandi  $data = array();
588f3f0262cSandi  search($data,$conf['datadir'],'search_index',array('ns' => $ns));
589cb70c441Sandi  print html_buildlist($data,'idx','html_list_index','html_li_index');
590f3f0262cSandi}
591f3f0262cSandi
592f3f0262cSandi/**
59315fae107Sandi * Index item formatter
59415fae107Sandi *
595f3f0262cSandi * User function for html_buildlist()
59615fae107Sandi *
59715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
598f3f0262cSandi */
599f3f0262cSandifunction html_list_index($item){
600f3f0262cSandi  $ret = '';
601f3f0262cSandi  $base = ':'.$item['id'];
602f3f0262cSandi  $base = substr($base,strrpos($base,':')+1);
603f3f0262cSandi  if($item['type']=='d'){
604f3f0262cSandi    $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">';
605f3f0262cSandi    $ret .= $base;
606f3f0262cSandi    $ret .= '</a>';
607f3f0262cSandi  }else{
608f3f0262cSandi    $ret .= html_wikilink(':'.$item['id']);
609f3f0262cSandi  }
610f3f0262cSandi  return $ret;
611f3f0262cSandi}
612f3f0262cSandi
613f3f0262cSandi/**
614cb70c441Sandi * Index List item
615cb70c441Sandi *
616cb70c441Sandi * This user function is used in html_build_lidt to build the
617cb70c441Sandi * <li> tags for namespaces when displaying the page index
618cb70c441Sandi * it gives different classes to opened or closed "folders"
619cb70c441Sandi *
620cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
621cb70c441Sandi */
622cb70c441Sandifunction html_li_index($item){
623cb70c441Sandi  if($item['type'] == "f"){
624cb70c441Sandi    return '<li class="level'.$item['level'].'">';
625cb70c441Sandi  }elseif($item['open']){
626cb70c441Sandi    return '<li class="open">';
627cb70c441Sandi  }else{
628cb70c441Sandi    return '<li class="closed">';
629cb70c441Sandi  }
630cb70c441Sandi}
631cb70c441Sandi
632cb70c441Sandi/**
633cb70c441Sandi * Default List item
634cb70c441Sandi *
635cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
636cb70c441Sandi */
637cb70c441Sandifunction html_li_default($item){
638cb70c441Sandi  return '<li class="level'.$item['level'].'">';
639cb70c441Sandi}
640cb70c441Sandi
641cb70c441Sandi/**
64215fae107Sandi * Build an unordered list
64315fae107Sandi *
644f3f0262cSandi * Build an unordered list from the given $data array
645f3f0262cSandi * Each item in the array has to have a 'level' property
646f3f0262cSandi * the item itself gets printed by the given $func user
647cb70c441Sandi * function. The second and optional function is used to
648cb70c441Sandi * print the <li> tag. Both user function need to accept
649cb70c441Sandi * a single item.
65015fae107Sandi *
651c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to
652c5a8fd96SAndreas Gohr * a member of an object.
653c5a8fd96SAndreas Gohr *
65415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
655f3f0262cSandi */
656cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){
657f3f0262cSandi  $level = 0;
658f3f0262cSandi  $opens = 0;
659f3f0262cSandi  $ret   = '';
660f3f0262cSandi
661f3f0262cSandi  foreach ($data as $item){
662f3f0262cSandi
663f3f0262cSandi    if( $item['level'] > $level ){
664f3f0262cSandi      //open new list
665df52d0feSandi      for($i=0; $i<($item['level'] - $level); $i++){
666df52d0feSandi        if ($i) $ret .= "<li class=\"clear\">\n";
667f3f0262cSandi        $ret .= "\n<ul class=\"$class\">\n";
668df52d0feSandi      }
669f3f0262cSandi    }elseif( $item['level'] < $level ){
670f3f0262cSandi      //close last item
671f3f0262cSandi      $ret .= "</li>\n";
672f3f0262cSandi      for ($i=0; $i<($level - $item['level']); $i++){
673f3f0262cSandi        //close higher lists
674f3f0262cSandi        $ret .= "</ul>\n</li>\n";
675f3f0262cSandi      }
676f3f0262cSandi    }else{
677f3f0262cSandi      //close last item
678f3f0262cSandi      $ret .= "</li>\n";
679f3f0262cSandi    }
680f3f0262cSandi
681f3f0262cSandi    //remember current level
682f3f0262cSandi    $level = $item['level'];
683f3f0262cSandi
684f3f0262cSandi    //print item
685c5a8fd96SAndreas Gohr    if(is_array($lifunc)){
686c5a8fd96SAndreas Gohr      $ret .= $lifunc[0]->$lifunc[1]($item); //user object method
687c5a8fd96SAndreas Gohr    }else{
688cb70c441Sandi      $ret .= $lifunc($item); //user function
689c5a8fd96SAndreas Gohr    }
6900c6b58a8SAndreas Gohr    $ret .= '<div class="li">';
691c5a8fd96SAndreas Gohr    if(is_array($func)){
692c5a8fd96SAndreas Gohr      $ret .= $func[0]->$func[1]($item); //user object method
693c5a8fd96SAndreas Gohr    }else{
694f3f0262cSandi    $ret .= $func($item); //user function
695c5a8fd96SAndreas Gohr    }
6960c6b58a8SAndreas Gohr    $ret .= '</div>';
697f3f0262cSandi  }
698f3f0262cSandi
699f3f0262cSandi  //close remaining items and lists
700f3f0262cSandi  for ($i=0; $i < $level; $i++){
701f3f0262cSandi    $ret .= "</li></ul>\n";
702f3f0262cSandi  }
703f3f0262cSandi
704f3f0262cSandi  return $ret;
705f3f0262cSandi}
706f3f0262cSandi
70715fae107Sandi/**
70815fae107Sandi * display backlinks
70915fae107Sandi *
71015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
71115fae107Sandi */
712f3f0262cSandifunction html_backlinks(){
71354f4c056SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
714f3f0262cSandi  global $ID;
715f3f0262cSandi  global $conf;
716f3f0262cSandi
717c112d578Sandi  print p_locale_xhtml('backlinks');
718f3f0262cSandi
71954f4c056SAndreas Gohr  $data = ft_backlinks($ID);
720f3f0262cSandi
721f3f0262cSandi  print '<ul class="idx">';
72254f4c056SAndreas Gohr  foreach($data as $blink){
7230c6b58a8SAndreas Gohr    print '<li><div class="li">';
72454f4c056SAndreas Gohr    print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink);
7250c6b58a8SAndreas Gohr    print '</div></li>';
726f3f0262cSandi  }
727f3f0262cSandi  print '</ul>';
728f3f0262cSandi}
729f3f0262cSandi
73015fae107Sandi/**
73115fae107Sandi * show diff
73215fae107Sandi *
73315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
73415fae107Sandi */
735f3f0262cSandifunction html_diff($text='',$intro=true){
736ed7b5f09Sandi  require_once(DOKU_INC.'inc/DifferenceEngine.php');
737f3f0262cSandi  global $ID;
738f3f0262cSandi  global $REV;
739f3f0262cSandi  global $lang;
740f3f0262cSandi  global $conf;
741f3f0262cSandi  if($text){
742f3f0262cSandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))),
743f3f0262cSandi                    split("\n",htmlspecialchars(cleanText($text))));
744f3f0262cSandi    $left  = '<a class="wikilink1" href="'.wl($ID).'">'.
745f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'.
746f3f0262cSandi              $lang['current'];
747f3f0262cSandi    $right = $lang['yours'];
748f3f0262cSandi  }else{
7494d58bd99Sandi    if($REV){
7504d58bd99Sandi      $r = $REV;
7514d58bd99Sandi    }else{
7524d58bd99Sandi      //use last revision if none given
7534d58bd99Sandi      $revs = getRevisions($ID);
7544d58bd99Sandi      $r = $revs[0];
7554d58bd99Sandi    }
7564d58bd99Sandi
7574d58bd99Sandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))),
758f3f0262cSandi                    split("\n",htmlspecialchars(rawWiki($ID,''))));
7594d58bd99Sandi    $left  = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'.
7604d58bd99Sandi              $ID.' '.date($conf['dformat'],$r).'</a>';
761f3f0262cSandi    $right = '<a class="wikilink1" href="'.wl($ID).'">'.
762f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '.
763f3f0262cSandi              $lang['current'];
764f3f0262cSandi  }
765f3f0262cSandi  $tdf = new TableDiffFormatter();
766c112d578Sandi  if($intro) print p_locale_xhtml('diff');
767f3f0262cSandi  ?>
768*daf4ca4eSAnika Henke    <table class="diff">
769f3f0262cSandi      <tr>
770*daf4ca4eSAnika Henke        <th colspan="2">
7714da078a3Smatthiasgrimm          <?php echo $left?>
772*daf4ca4eSAnika Henke        </th>
773*daf4ca4eSAnika Henke        <th colspan="2">
7744da078a3Smatthiasgrimm          <?php echo $right?>
775*daf4ca4eSAnika Henke        </th>
776f3f0262cSandi      </tr>
7774da078a3Smatthiasgrimm      <?php echo $tdf->format($df)?>
778f3f0262cSandi    </table>
7794da078a3Smatthiasgrimm  <?php
780f3f0262cSandi}
781f3f0262cSandi
78215fae107Sandi/**
78315fae107Sandi * show warning on conflict detection
78415fae107Sandi *
78515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
78615fae107Sandi */
787f3f0262cSandifunction html_conflict($text,$summary){
788f3f0262cSandi  global $ID;
789f3f0262cSandi  global $lang;
790f3f0262cSandi
791c112d578Sandi  print p_locale_xhtml('conflict');
792f3f0262cSandi  ?>
7931dd0c202SAnika Henke  <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
79496331712SAnika Henke  <div class="centeralign">
7954da078a3Smatthiasgrimm    <input type="hidden" name="id" value="<?php echo $ID?>" />
7964da078a3Smatthiasgrimm    <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" />
7974da078a3Smatthiasgrimm    <input type="hidden" name="summary" value="<?php echo formText($summary)?>" />
798f3f0262cSandi
7994da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" />
8004da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" />
801f3f0262cSandi  </div>
802f3f0262cSandi  </form>
803f3f0262cSandi  <br /><br /><br /><br />
8044da078a3Smatthiasgrimm  <?php
805f3f0262cSandi}
806f3f0262cSandi
807f3f0262cSandi/**
80815fae107Sandi * Prints the global message array
80915fae107Sandi *
81015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
811f3f0262cSandi */
812f3f0262cSandifunction html_msgarea(){
813f3f0262cSandi  global $MSG;
814f3f0262cSandi
815f3f0262cSandi  if(!isset($MSG)) return;
816f3f0262cSandi
817f3f0262cSandi  foreach($MSG as $msg){
818f3f0262cSandi    print '<div class="'.$msg['lvl'].'">';
819f3f0262cSandi    print $msg['msg'];
820f3f0262cSandi    print '</div>';
821f3f0262cSandi  }
822f3f0262cSandi}
823f3f0262cSandi
824f3f0262cSandi/**
825f3f0262cSandi * Prints the registration form
82615fae107Sandi *
82715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
828f3f0262cSandi */
829f3f0262cSandifunction html_register(){
830f3f0262cSandi  global $lang;
831cab2716aSmatthias.grimm  global $conf;
832f3f0262cSandi  global $ID;
833f3f0262cSandi
834c112d578Sandi  print p_locale_xhtml('register');
835f3f0262cSandi?>
83696331712SAnika Henke  <div class="centeralign">
8371dd0c202SAnika Henke  <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
83896331712SAnika Henke  <fieldset>
839f3f0262cSandi    <input type="hidden" name="do" value="register" />
840f3f0262cSandi    <input type="hidden" name="save" value="1" />
84196331712SAnika Henke
8424da078a3Smatthiasgrimm    <legend><?php echo $lang['register']?></legend>
843b6912aeaSAndreas Gohr    <label class="block">
8444da078a3Smatthiasgrimm      <?php echo $lang['user']?>
8454da078a3Smatthiasgrimm      <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
846f3f0262cSandi    </label><br />
847cab2716aSmatthias.grimm
848cab2716aSmatthias.grimm    <?php
849cab2716aSmatthias.grimm      if (!$conf['autopasswd']) {
850cab2716aSmatthias.grimm    ?>
851b6912aeaSAndreas Gohr      <label class="block">
8524da078a3Smatthiasgrimm        <?php echo $lang['pass']?>
853cab2716aSmatthias.grimm        <input type="password" name="pass" class="edit" size="50" />
854cab2716aSmatthias.grimm      </label><br />
855b6912aeaSAndreas Gohr      <label class="block">
8564da078a3Smatthiasgrimm        <?php echo $lang['passchk']?>
857cab2716aSmatthias.grimm        <input type="password" name="passchk" class="edit" size="50" />
858cab2716aSmatthias.grimm      </label><br />
859cab2716aSmatthias.grimm    <?php
860cab2716aSmatthias.grimm      }
861cab2716aSmatthias.grimm    ?>
862cab2716aSmatthias.grimm
863b6912aeaSAndreas Gohr    <label class="block">
8644da078a3Smatthiasgrimm      <?php echo $lang['fullname']?>
8654da078a3Smatthiasgrimm      <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
866f3f0262cSandi    </label><br />
867b6912aeaSAndreas Gohr    <label class="block">
8684da078a3Smatthiasgrimm      <?php echo $lang['email']?>
8694da078a3Smatthiasgrimm      <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
870f3f0262cSandi    </label><br />
8714da078a3Smatthiasgrimm    <input type="submit" class="button" value="<?php echo $lang['register']?>" />
872f3f0262cSandi  </fieldset>
873f3f0262cSandi  </form>
874f3f0262cSandi  </div>
8754da078a3Smatthiasgrimm<?php
876f3f0262cSandi}
877f3f0262cSandi
878f3f0262cSandi/**
8798b06d178Schris * Print the update profile form
8808b06d178Schris *
8818b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk>
8828b06d178Schris * @author Andreas Gohr <andi@splitbrain.org>
8838b06d178Schris */
8848b06d178Schrisfunction html_updateprofile(){
8858b06d178Schris  global $lang;
8868b06d178Schris  global $conf;
8878b06d178Schris  global $ID;
8888b06d178Schris  global $INFO;
88982fd59b6SAndreas Gohr  global $auth;
8908b06d178Schris
8918b06d178Schris  print p_locale_xhtml('updateprofile');
8928b06d178Schris
8938b06d178Schris  if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
8948b06d178Schris  if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
8958b06d178Schris?>
89696331712SAnika Henke  <div class="centeralign">
8971dd0c202SAnika Henke  <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
89896331712SAnika Henke  <fieldset style="width: 80%;">
8998b06d178Schris    <input type="hidden" name="do" value="profile" />
9008b06d178Schris    <input type="hidden" name="save" value="1" />
90196331712SAnika Henke
9028b06d178Schris    <legend><?php echo $lang['profile']?></legend>
9038b06d178Schris    <label class="block">
9048b06d178Schris      <?php echo $lang['user']?>
9058b06d178Schris      <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" />
9068b06d178Schris    </label><br />
9078b06d178Schris    <label class="block">
9088b06d178Schris      <?php echo $lang['fullname']?>
90982fd59b6SAndreas Gohr      <input type="text" name="fullname" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
9108b06d178Schris    </label><br />
9118b06d178Schris    <label class="block">
9128b06d178Schris      <?php echo $lang['email']?>
91382fd59b6SAndreas Gohr      <input type="text" name="email" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
9148b06d178Schris    </label><br /><br />
91582fd59b6SAndreas Gohr
91682fd59b6SAndreas Gohr    <?php if($auth->canDo('modPass')) { ?>
9178b06d178Schris    <label class="block">
9188b06d178Schris      <?php echo $lang['newpass']?>
9198b06d178Schris      <input type="password" name="newpass" class="edit" size="50" />
9208b06d178Schris    </label><br />
9218b06d178Schris    <label class="block">
9228b06d178Schris      <?php echo $lang['passchk']?>
9238b06d178Schris      <input type="password" name="passchk" class="edit" size="50" />
9248b06d178Schris    </label><br />
92582fd59b6SAndreas Gohr    <?php } ?>
9268b06d178Schris
9278b06d178Schris    <?php if ($conf['profileconfirm']) { ?>
9288b06d178Schris      <br />
9298b06d178Schris      <label class="block">
9308b06d178Schris      <?php echo $lang['oldpass']?>
9318b06d178Schris      <input type="password" name="oldpass" class="edit" size="50" />
9328b06d178Schris    </label><br />
9338b06d178Schris    <?php } ?>
9348b06d178Schris
9354cb79657SMatthias Grimm    <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" />
9368b06d178Schris    <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" />
9378b06d178Schris  </fieldset>
9388b06d178Schris  </form>
9398b06d178Schris  </div>
9408b06d178Schris<?php
9418b06d178Schris}
9428b06d178Schris
9438b06d178Schris/**
944f3f0262cSandi * This displays the edit form (lots of logic included)
94515fae107Sandi *
9467146cee2SAndreas Gohr * @fixme  this is a huge lump of code and should be modularized
94715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
948f3f0262cSandi */
949f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed?
950f3f0262cSandi  global $ID;
951f3f0262cSandi  global $REV;
952f3f0262cSandi  global $DATE;
953f3f0262cSandi  global $RANGE;
954f3f0262cSandi  global $PRE;
955f3f0262cSandi  global $SUF;
956f3f0262cSandi  global $INFO;
957f3f0262cSandi  global $SUM;
958f3f0262cSandi  global $lang;
959f3f0262cSandi  global $conf;
960f3f0262cSandi
961f3f0262cSandi  //set summary default
962f3f0262cSandi  if(!$SUM){
963f3f0262cSandi    if($REV){
964f3f0262cSandi      $SUM = $lang['restored'];
965f3f0262cSandi    }elseif(!$INFO['exists']){
966f3f0262cSandi      $SUM = $lang['created'];
967f3f0262cSandi    }
968f3f0262cSandi  }
969f3f0262cSandi
970f3f0262cSandi  //no text? Load it!
971f3f0262cSandi  if(!isset($text)){
972f3f0262cSandi    $pr = false; //no preview mode
9737146cee2SAndreas Gohr    if($INFO['exists']){
974f3f0262cSandi      if($RANGE){
975f3f0262cSandi        list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
976f3f0262cSandi      }else{
977f3f0262cSandi        $text = rawWiki($ID,$REV);
978f3f0262cSandi      }
979f3f0262cSandi    }else{
9807146cee2SAndreas Gohr      //try to load a pagetemplate
9817146cee2SAndreas Gohr      $text = pageTemplate($ID);
9827146cee2SAndreas Gohr    }
9837146cee2SAndreas Gohr  }else{
984f3f0262cSandi    $pr = true; //preview mode
985f3f0262cSandi  }
986f3f0262cSandi
987f3f0262cSandi  $wr = $INFO['writable'];
988f3f0262cSandi  if($wr){
989c112d578Sandi    if ($REV) print p_locale_xhtml('editrev');
990c112d578Sandi    print p_locale_xhtml($include);
991f3f0262cSandi  }else{
992c112d578Sandi    print p_locale_xhtml('read');
993f3f0262cSandi    $ro='readonly="readonly"';
994f3f0262cSandi  }
995f3f0262cSandi  if(!$DATE) $DATE = $INFO['lastmod'];
996dc57ef04Sandi
997dc57ef04Sandi
998f3f0262cSandi?>
99963afe2a6SAnika Henke  <div style="width:99%;">
100063afe2a6SAnika Henke  <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"><div class="no">
100163afe2a6SAnika Henke     <div class="toolbar">
100224a33b42SAndreas Gohr        <div id="tool__bar"></div>
10034da078a3Smatthiasgrimm        <input type="hidden" name="id"   value="<?php echo $ID?>" />
10044da078a3Smatthiasgrimm        <input type="hidden" name="rev"  value="<?php echo $REV?>" />
10054da078a3Smatthiasgrimm        <input type="hidden" name="date" value="<?php echo $DATE?>" />
10064da078a3Smatthiasgrimm        <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" />
10074da078a3Smatthiasgrimm        <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" />
100820d062caSAndreas Gohr
10094da078a3Smatthiasgrimm        <?php if($wr){?>
10104beabca9SAnika Henke        <script type="text/javascript" charset="utf-8">
10114da078a3Smatthiasgrimm          <?php /* sets changed to true when previewed */?>
10124da078a3Smatthiasgrimm          textChanged = <?php ($pr) ? print 'true' : print 'false' ?>;
1013f3f0262cSandi        </script>
101424a33b42SAndreas Gohr        <span id="spell__action"></span>
10154da078a3Smatthiasgrimm        <?php } ?>
101624a33b42SAndreas Gohr        <div id="spell__suggest"></div>
101763afe2a6SAnika Henke    </div>
101824a33b42SAndreas Gohr    <div id="spell__result"></div>
101963afe2a6SAnika Henke
102024a33b42SAndreas Gohr    <textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea>
102163afe2a6SAnika Henke
102224a33b42SAndreas Gohr    <div id="wiki__editbar">
102324a33b42SAndreas Gohr      <div id="size__ctl"></div>
10244da078a3Smatthiasgrimm      <?php if($wr){?>
1025fa24fadbSAnika Henke         <div class="editButtons">
102624a33b42SAndreas Gohr            <input class="button" id="edbtn__save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" />
102724a33b42SAndreas Gohr            <input class="button" id="edbtn__preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" />
10284da078a3Smatthiasgrimm            <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" />
1029fa24fadbSAnika Henke         </div>
10304da078a3Smatthiasgrimm      <?php } ?>
10314da078a3Smatthiasgrimm      <?php if($wr){ ?>
1032fa24fadbSAnika Henke        <div class="summary">
103324a33b42SAndreas Gohr           <label for="edit__summary" class="nowrap"><?php echo $lang['summary']?>:</label>
103424a33b42SAndreas Gohr           <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" />
1035b6912aeaSAndreas Gohr           <?php html_minoredit()?>
1036fa24fadbSAnika Henke        </div>
10374da078a3Smatthiasgrimm      <?php }?>
103863afe2a6SAnika Henke    </div>
103963afe2a6SAnika Henke  </div></form>
104063afe2a6SAnika Henke  </div>
10414da078a3Smatthiasgrimm<?php
1042f3f0262cSandi}
1043f3f0262cSandi
1044f3f0262cSandi/**
1045b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users
1046b6912aeaSAndreas Gohr *
1047b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org>
1048b6912aeaSAndreas Gohr */
1049b6912aeaSAndreas Gohrfunction html_minoredit(){
1050b6912aeaSAndreas Gohr  global $conf;
1051b6912aeaSAndreas Gohr  global $lang;
1052b6912aeaSAndreas Gohr  // minor edits are for logged in users only
1053b6912aeaSAndreas Gohr  if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
1054b6912aeaSAndreas Gohr    return;
1055b6912aeaSAndreas Gohr  }
1056b6912aeaSAndreas Gohr
1057b6912aeaSAndreas Gohr  $p = array();
1058b6912aeaSAndreas Gohr  $p['name']     = 'minor';
1059b6912aeaSAndreas Gohr  $p['type']     = 'checkbox';
1060b6912aeaSAndreas Gohr  $p['id']       = 'minoredit';
1061b6912aeaSAndreas Gohr  $p['tabindex'] = 3;
1062b6912aeaSAndreas Gohr  $p['value']    = '1';
1063b6912aeaSAndreas Gohr  if($_REQUEST['minor']) $p['checked']='checked';
1064b6912aeaSAndreas Gohr  $att = buildAttributes($p);
1065b6912aeaSAndreas Gohr
1066fa24fadbSAnika Henke  print '<span class="nowrap">';
1067b6912aeaSAndreas Gohr  print "<input $att />";
1068b6912aeaSAndreas Gohr  print '<label for="minoredit">';
1069b6912aeaSAndreas Gohr  print $lang['minoredit'];
1070b6912aeaSAndreas Gohr  print '</label>';
1071fa24fadbSAnika Henke  print '</span>';
1072b6912aeaSAndreas Gohr}
1073b6912aeaSAndreas Gohr
1074b6912aeaSAndreas Gohr/**
1075f3f0262cSandi * prints some debug info
107615fae107Sandi *
107715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
1078f3f0262cSandi */
1079f3f0262cSandifunction html_debug(){
1080f3f0262cSandi  global $conf;
1081d16a4edaSandi  global $lang;
10825298a619SAndreas Gohr  global $auth;
108328fb55ffSandi  //remove sensitive data
108428fb55ffSandi  $cnf = $conf;
108528fb55ffSandi  $cnf['auth']='***';
108628fb55ffSandi  $cnf['notify']='***';
10873dc3a5f1Sandi  $cnf['ftp']='***';
1088f3f0262cSandi
1089f3f0262cSandi  print '<html><body>';
1090f3f0262cSandi
1091f3f0262cSandi  print '<p>When reporting bugs please send all the following ';
1092f3f0262cSandi  print 'output as a mail to andi@splitbrain.org ';
1093f3f0262cSandi  print 'The best way to do this is to save this page in your browser</p>';
1094f3f0262cSandi
1095f3f0262cSandi  print '<b>$_SERVER:</b><pre>';
1096f3f0262cSandi  print_r($_SERVER);
1097f3f0262cSandi  print '</pre>';
1098f3f0262cSandi
1099f3f0262cSandi  print '<b>$conf:</b><pre>';
110028fb55ffSandi  print_r($cnf);
1101f3f0262cSandi  print '</pre>';
1102f3f0262cSandi
1103ed7b5f09Sandi  print '<b>DOKU_BASE:</b><pre>';
1104ed7b5f09Sandi  print DOKU_BASE;
1105f3f0262cSandi  print '</pre>';
1106f3f0262cSandi
1107ed7b5f09Sandi  print '<b>abs DOKU_BASE:</b><pre>';
1108ed7b5f09Sandi  print DOKU_URL;
1109ed7b5f09Sandi  print '</pre>';
1110ed7b5f09Sandi
1111ed7b5f09Sandi  print '<b>rel DOKU_BASE:</b><pre>';
1112f3f0262cSandi  print dirname($_SERVER['PHP_SELF']).'/';
1113f3f0262cSandi  print '</pre>';
1114f3f0262cSandi
1115f3f0262cSandi  print '<b>PHP Version:</b><pre>';
1116f3f0262cSandi  print phpversion();
1117f3f0262cSandi  print '</pre>';
1118f3f0262cSandi
1119f3f0262cSandi  print '<b>locale:</b><pre>';
1120f3f0262cSandi  print setlocale(LC_ALL,0);
1121f3f0262cSandi  print '</pre>';
1122f3f0262cSandi
1123d16a4edaSandi  print '<b>encoding:</b><pre>';
1124d16a4edaSandi  print $lang['encoding'];
1125d16a4edaSandi  print '</pre>';
1126d16a4edaSandi
11275298a619SAndreas Gohr  if($auth){
11285298a619SAndreas Gohr    print '<b>Auth backend capabilities:</b><pre>';
11295298a619SAndreas Gohr    print_r($auth->cando);
11305298a619SAndreas Gohr    print '</pre>';
11315298a619SAndreas Gohr  }
11325298a619SAndreas Gohr
11333aa54d7cSAndreas Gohr  print '<b>$_SESSION:</b><pre>';
11343aa54d7cSAndreas Gohr  print_r($_SESSION);
11353aa54d7cSAndreas Gohr  print '</pre>';
11363aa54d7cSAndreas Gohr
1137f3f0262cSandi  print '<b>Environment:</b><pre>';
1138f3f0262cSandi  print_r($_ENV);
1139f3f0262cSandi  print '</pre>';
1140f3f0262cSandi
1141f3f0262cSandi  print '<b>PHP settings:</b><pre>';
1142f3f0262cSandi  $inis = ini_get_all();
1143f3f0262cSandi  print_r($inis);
1144f3f0262cSandi  print '</pre>';
1145f3f0262cSandi
1146f3f0262cSandi  print '</body></html>';
1147f3f0262cSandi}
1148f3f0262cSandi
1149c19fe9c0Sandifunction html_admin(){
1150c19fe9c0Sandi  global $ID;
1151c19fe9c0Sandi  global $lang;
1152ca3a6df1SMatthias Grimm  global $conf;
1153c19fe9c0Sandi
1154c112d578Sandi  print p_locale_xhtml('admin');
1155c19fe9c0Sandi
115611e2ce22Schris  // build menu of admin functions from the plugins that handle them
115711e2ce22Schris  $pluginlist = plugin_list('admin');
115811e2ce22Schris  $menu = array();
115911e2ce22Schris  foreach ($pluginlist as $p) {
116011e2ce22Schris    if($obj =& plugin_load('admin',$p) === NULL) continue;
116111e2ce22Schris    $menu[] = array('plugin' => $p,
116211e2ce22Schris                    'prompt' => $obj->getMenuText($conf['lang']),
116311e2ce22Schris                    'sort' => $obj->getMenuSort()
116411e2ce22Schris                   );
116511e2ce22Schris  }
116611e2ce22Schris
116711e2ce22Schris  usort($menu, p_sort_modes);
116811e2ce22Schris
116911e2ce22Schris  // output the menu
117011e2ce22Schris  ptln('<ul>');
117111e2ce22Schris
117211e2ce22Schris  foreach ($menu as $item) {
117311e2ce22Schris    if (!$item['prompt']) continue;
11740c6b58a8SAndreas Gohr    ptln('  <li><div class="li"><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>');
117511e2ce22Schris  }
117611e2ce22Schris
117711e2ce22Schris  // add in non-plugin functions
117811e2ce22Schris  if (!$conf['openregister']){
11790c6b58a8SAndreas Gohr    ptln('<li><div class="li"><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></div></li>');
118011e2ce22Schris  }
118111e2ce22Schris
118211e2ce22Schris  ptln('</ul>');
1183ca3a6df1SMatthias Grimm}
1184c19fe9c0Sandi
11858b06d178Schris/**
11868b06d178Schris * Form to request a new password for an existing account
11878b06d178Schris *
11888b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info>
118911e2ce22Schris */
11908b06d178Schrisfunction html_resendpwd() {
11918b06d178Schris  global $lang;
11928b06d178Schris  global $conf;
11938b06d178Schris  global $ID;
1194c19fe9c0Sandi
11958b06d178Schris  print p_locale_xhtml('resendpwd');
11968b06d178Schris?>
119796331712SAnika Henke  <div class="centeralign">
11981dd0c202SAnika Henke  <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post">
11998b06d178Schris    <fieldset>
12008b06d178Schris      <br />
1201753d5abfSMatthias Grimm      <legend><?php echo $lang['resendpwd']?></legend>
12028b06d178Schris      <input type="hidden" name="do" value="resendpwd" />
12038b06d178Schris      <input type="hidden" name="save" value="1" />
12048b06d178Schris      <label class="block">
12058b06d178Schris        <span><?php echo $lang['user']?></span>
12068b06d178Schris        <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br />
12078b06d178Schris      </label><br />
12088b06d178Schris      <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" />
12098b06d178Schris    </fieldset>
12108b06d178Schris  </form>
12118b06d178Schris  </div>
12128b06d178Schris<?php
12138b06d178Schris}
1214340756e4Sandi
1215340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 :
1216