xref: /dokuwiki/inc/html.php (revision a06884abe180891c09730983f2b8d13662c3fd34)
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
9ed7b5f09Sandiif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
10e226efe1SAndreas Gohrif(!defined('NL')) define('NL',"\n");
116bbae538Sandirequire_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>
455b62573aSAndreas Gohr * @triggers HTML_LOGINFORM_INJECTION
46f3f0262cSandi */
47f3f0262cSandifunction html_login(){
48f3f0262cSandi  global $lang;
49f3f0262cSandi  global $conf;
50f3f0262cSandi  global $ID;
51cd52f92dSchris  global $auth;
52f3f0262cSandi
53c112d578Sandi  print p_locale_xhtml('login');
54f3f0262cSandi  ?>
5596331712SAnika Henke    <div class="centeralign">
568d975344SAndreas Gohr    <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"
571440e523SAnika Henke          method="post" id="dw__login">
58f3f0262cSandi      <fieldset>
594da078a3Smatthiasgrimm        <legend><?php echo $lang['btn_login']?></legend>
604da078a3Smatthiasgrimm        <input type="hidden" name="id" value="<?php echo $ID?>" />
61f3f0262cSandi        <input type="hidden" name="do" value="login" />
62b6912aeaSAndreas Gohr        <label class="block">
634da078a3Smatthiasgrimm          <span><?php echo $lang['user']?></span>
648d975344SAndreas Gohr          <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>"
658d975344SAndreas Gohr                 class="edit" id="focus__this" />
66f3f0262cSandi        </label><br />
67b6912aeaSAndreas Gohr        <label class="block">
684da078a3Smatthiasgrimm          <span><?php echo $lang['pass']?></span>
69f3f0262cSandi          <input type="password" name="p" class="edit" />
70f3f0262cSandi        </label><br />
715b62573aSAndreas Gohr
725b62573aSAndreas Gohr        <?php //bad and dirty event insert hook
735b62573aSAndreas Gohr        $evdata = array();
745b62573aSAndreas Gohr        trigger_event('HTML_LOGINFORM_INJECTION', $evdata);
755b62573aSAndreas Gohr        ?>
765b62573aSAndreas Gohr
770c1887a0SAndreas Gohr        <label for="remember__me" class="simple">
784d6f545eSAndreas Gohr          <input type="checkbox" name="r" id="remember__me" value="1" />
794da078a3Smatthiasgrimm          <span><?php echo $lang['remember']?></span>
80132bdbfeSandi        </label>
818d975344SAndreas Gohr        <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" />
82f3f0262cSandi      </fieldset>
83f3f0262cSandi    </form>
844da078a3Smatthiasgrimm  <?php
856957b2eaSAndreas Gohr    if($auth && $auth->canDo('addUser') && actionOK('register')){
86f3f0262cSandi      print '<p>';
87f3f0262cSandi      print $lang['reghere'];
881d5856cfSAndreas Gohr      print ': <a href="'.wl($ID,'do=register').'" rel="nofollow" class="wikilink1">'.$lang['register'].'</a>';
89f3f0262cSandi      print '</p>';
90f3f0262cSandi    }
918b06d178Schris
926957b2eaSAndreas Gohr    if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) {
938b06d178Schris      print '<p>';
948b06d178Schris      print $lang['pwdforget'];
951d5856cfSAndreas Gohr      print ': <a href="'.wl($ID,'do=resendpwd').'" rel="nofollow" class="wikilink1">'.$lang['btn_resendpwd'].'</a>';
968b06d178Schris      print '</p>';
978b06d178Schris    }
98f3f0262cSandi  ?>
99f3f0262cSandi    </div>
1004da078a3Smatthiasgrimm  <?php
1016bbae538Sandi/*
1026bbae538Sandi FIXME provide new hook
103f3f0262cSandi  if(@file_exists('includes/login.txt')){
104f3f0262cSandi    print io_cacheParse('includes/login.txt');
105f3f0262cSandi  }
1066bbae538Sandi*/
107f3f0262cSandi}
108f3f0262cSandi
109f3f0262cSandi/**
11015fae107Sandi * prints a section editing button
11135dae8b0SBen Coburn * used as a callback in html_secedit
11215fae107Sandi *
11315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
11415fae107Sandi */
11535dae8b0SBen Coburnfunction html_secedit_button($matches){
116f3f0262cSandi  global $ID;
117041d7a86SBen Coburn  global $INFO;
118041d7a86SBen Coburn
119041d7a86SBen Coburn  $section = $matches[2];
120041d7a86SBen Coburn  $name = $matches[1];
121041d7a86SBen Coburn
122f3f0262cSandi  $secedit  = '';
123f3f0262cSandi  $secedit .= '<div class="secedit">';
124f3f0262cSandi  $secedit .= html_btn('secedit',$ID,'',
125f3f0262cSandi                        array('do'      => 'edit',
126306b2c85SDenis Simakov                              'lines'   => "$section",
127306b2c85SDenis Simakov                              'rev' => $INFO['lastmod']),
12835dae8b0SBen Coburn                              'post', $name);
129f3f0262cSandi  $secedit .= '</div>';
130f3f0262cSandi  return $secedit;
131f3f0262cSandi}
132f3f0262cSandi
13315fae107Sandi/**
13415fae107Sandi * inserts section edit buttons if wanted or removes the markers
13515fae107Sandi *
13615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
13715fae107Sandi */
138f3f0262cSandifunction html_secedit($text,$show=true){
139f3f0262cSandi  global $INFO;
14035dae8b0SBen Coburn
141c112d578Sandi  if($INFO['writable'] && $show && !$INFO['rev']){
14235dae8b0SBen Coburn    $text = preg_replace_callback('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#',
14335dae8b0SBen Coburn                         'html_secedit_button', $text);
144f3f0262cSandi  }else{
14535dae8b0SBen Coburn    $text = preg_replace('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#','',$text);
146f3f0262cSandi  }
14735dae8b0SBen Coburn
148f3f0262cSandi  return $text;
149f3f0262cSandi}
150f3f0262cSandi
151f3f0262cSandi/**
152d6c9c552Smatthiasgrimm * Just the back to top button (in its own form)
1536b13307fSandi *
1546b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
1556b13307fSandi */
1566b13307fSandifunction html_topbtn(){
1576b13307fSandi  global $lang;
1586b13307fSandi
1596b13307fSandi  $ret  = '';
16011ea018fSAndreas Gohr  $ret  = '<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" title="'.$lang['btn_top'].'" /></a>';
161df7b6005Sandi
1626b13307fSandi  return $ret;
1636b13307fSandi}
1646b13307fSandi
1656b13307fSandi/**
166d67ca2c0Smatthiasgrimm * Displays a button (using its own form)
16735dae8b0SBen Coburn * If tooltip exists, the access key tooltip is replaced.
16815fae107Sandi *
16915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
170f3f0262cSandi */
17135dae8b0SBen Coburnfunction html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){
172f3f0262cSandi  global $conf;
173f3f0262cSandi  global $lang;
174f3f0262cSandi
175f3f0262cSandi  $label = $lang['btn_'.$name];
176f3f0262cSandi
177f3f0262cSandi  $ret = '';
17835dae8b0SBen Coburn  $tip = '';
179f3f0262cSandi
18049c713a3Sandi  //filter id (without urlencoding)
18149c713a3Sandi  $id = idfilter($id,false);
182f3f0262cSandi
183f3f0262cSandi  //make nice URLs even for buttons
1846c7843b5Sandi  if($conf['userewrite'] == 2){
1856c7843b5Sandi    $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
1866c7843b5Sandi  }elseif($conf['userewrite']){
1876c7843b5Sandi    $script = DOKU_BASE.$id;
1886c7843b5Sandi  }else{
1898b00ebcfSandi    $script = DOKU_BASE.DOKU_SCRIPT;
190f3f0262cSandi    $params['id'] = $id;
191f3f0262cSandi  }
192f3f0262cSandi
1934beabca9SAnika Henke  $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">';
194f3f0262cSandi
19506a4bf8fSAndreas Gohr  if(is_array($params)){
196f3f0262cSandi    reset($params);
197f3f0262cSandi    while (list($key, $val) = each($params)) {
198f3f0262cSandi      $ret .= '<input type="hidden" name="'.$key.'" ';
199f3f0262cSandi      $ret .= 'value="'.htmlspecialchars($val).'" />';
200f3f0262cSandi    }
20106a4bf8fSAndreas Gohr  }
202f3f0262cSandi
20335dae8b0SBen Coburn  if ($tooltip!='') {
20435dae8b0SBen Coburn      $tip = htmlspecialchars($tooltip);
20511ea018fSAndreas Gohr  }else{
20611ea018fSAndreas Gohr      $tip = htmlspecialchars($label);
20711ea018fSAndreas Gohr  }
20811ea018fSAndreas Gohr
20911ea018fSAndreas Gohr  $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
21011ea018fSAndreas Gohr  if($akey){
21111ea018fSAndreas Gohr    $tip .= ' [ALT+'.strtoupper($akey).']';
21211ea018fSAndreas Gohr    $ret .= 'accesskey="'.$akey.'" ';
21335dae8b0SBen Coburn  }
21435dae8b0SBen Coburn  $ret .= 'title="'.$tip.'" ';
215f3f0262cSandi  $ret .= '/>';
2164beabca9SAnika Henke  $ret .= '</div></form>';
217f3f0262cSandi
218f3f0262cSandi  return $ret;
219f3f0262cSandi}
220f3f0262cSandi
221f3f0262cSandi/**
22215fae107Sandi * show a wiki page
22315fae107Sandi *
22415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
22515fae107Sandi */
2266bbae538Sandifunction html_show($txt=''){
227f3f0262cSandi  global $ID;
228f3f0262cSandi  global $REV;
229f3f0262cSandi  global $HIGH;
230f3f0262cSandi  //disable section editing for old revisions or in preview
2315400331dSandi  if($txt || $REV){
2326bbae538Sandi    $secedit = false;
2336bbae538Sandi  }else{
2346bbae538Sandi    $secedit = true;
235f3f0262cSandi  }
236f3f0262cSandi
2376bbae538Sandi  if ($txt){
238f3f0262cSandi    //PreviewHeader
23950835be7SAndreas Gohr    print '<br id="scroll__here" />';
240c112d578Sandi    print p_locale_xhtml('preview');
241f3f0262cSandi    print '<div class="preview">';
2429dc2c2afSandi    print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
24346723c19SAndreas Gohr    print '<div class="clearer"></div>';
244f3f0262cSandi    print '</div>';
2456bbae538Sandi
246f3f0262cSandi  }else{
247c112d578Sandi    if ($REV) print p_locale_xhtml('showrev');
248c112d578Sandi    $html = p_wiki_xhtml($ID,$REV,true);
2496bbae538Sandi    $html = html_secedit($html,$secedit);
250f3f0262cSandi    print html_hilight($html,$HIGH);
251f3f0262cSandi  }
252f3f0262cSandi}
253f3f0262cSandi
254f3f0262cSandi/**
255ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft
256ee4c4a1bSAndreas Gohr *
257ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
258ee4c4a1bSAndreas Gohr */
259ee4c4a1bSAndreas Gohrfunction html_draft(){
260ee4c4a1bSAndreas Gohr  global $INFO;
261ee4c4a1bSAndreas Gohr  global $ID;
262ee4c4a1bSAndreas Gohr  global $lang;
263ee4c4a1bSAndreas Gohr  global $conf;
264ee4c4a1bSAndreas Gohr  $draft = unserialize(io_readFile($INFO['draft'],false));
265ee4c4a1bSAndreas Gohr  $text  = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true));
266ee4c4a1bSAndreas Gohr
267ee4c4a1bSAndreas Gohr  echo p_locale_xhtml('draft');
268ee4c4a1bSAndreas Gohr  ?>
269ee4c4a1bSAndreas Gohr  <form id="dw__editform" method="post" action="<?php echo script()?>"
270ee4c4a1bSAndreas Gohr   accept-charset="<?php echo $lang['encoding']?>"><div class="no">
271ee4c4a1bSAndreas Gohr    <input type="hidden" name="id"   value="<?php echo $ID?>" />
272ee4c4a1bSAndreas Gohr    <input type="hidden" name="date" value="<?php echo $draft['date']?>" /></div>
273ee4c4a1bSAndreas Gohr    <textarea name="wikitext" id="wiki__text" readonly="readonly" cols="80" rows="10" class="edit"><?php echo "\n".formText($text)?></textarea>
274ee4c4a1bSAndreas Gohr
275ee4c4a1bSAndreas Gohr    <div id="draft__status"><?php echo $lang['draftdate'].' '.date($conf['dformat'],filemtime($INFO['draft']))?></div>
276ee4c4a1bSAndreas Gohr
27718829381SAndreas Gohr    <input class="button" type="submit" name="do[recover]" value="<?php echo $lang['btn_recover']?>" tabindex="1" />
27818829381SAndreas Gohr    <input class="button" type="submit" name="do[draftdel]" value="<?php echo $lang['btn_draftdel']?>" tabindex="2" />
27918829381SAndreas Gohr    <input class="button" type="submit" name="do[show]" value="<?php echo $lang['btn_cancel']?>" tabindex="3" />
280ee4c4a1bSAndreas Gohr  </form>
281ee4c4a1bSAndreas Gohr  <?php
282ee4c4a1bSAndreas Gohr}
283ee4c4a1bSAndreas Gohr
284ee4c4a1bSAndreas Gohr/**
285f3f0262cSandi * Highlights searchqueries in HTML code
28615fae107Sandi *
28715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
2887209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
289f3f0262cSandi */
290f3f0262cSandifunction html_hilight($html,$query){
2917209be23SAndreas Gohr  //split at common delimiters
2929d9c165eSAndreas Gohr  $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY);
293f3f0262cSandi  foreach ($queries as $q){
294f3f0262cSandi     $q = preg_quote($q,'/');
2957209be23SAndreas Gohr     $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html);
296f3f0262cSandi  }
297f3f0262cSandi  return $html;
298f3f0262cSandi}
299f3f0262cSandi
300f3f0262cSandi/**
3017209be23SAndreas Gohr * Callback used by html_hilight()
3027209be23SAndreas Gohr *
3037209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
3047209be23SAndreas Gohr */
3057209be23SAndreas Gohrfunction html_hilight_callback($m) {
3067209be23SAndreas Gohr  $hlight = unslash($m[0]);
3077209be23SAndreas Gohr  if ( !isset($m[2])) {
308688774a0SAnika Henke    $hlight = '<span class="search_hit">'.$hlight.'</span>';
3097209be23SAndreas Gohr  }
3107209be23SAndreas Gohr  return $hlight;
3117209be23SAndreas Gohr}
3127209be23SAndreas Gohr
3137209be23SAndreas Gohr/**
31415fae107Sandi * Run a search and display the result
31515fae107Sandi *
31615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
317f3f0262cSandi */
318f3f0262cSandifunction html_search(){
319ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
320506fa893SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
321f3f0262cSandi  global $conf;
322f3f0262cSandi  global $QUERY;
323f3f0262cSandi  global $ID;
324f3f0262cSandi  global $lang;
325f3f0262cSandi
326c112d578Sandi  print p_locale_xhtml('searchpage');
327f3f0262cSandi  flush();
328f3f0262cSandi
329d0ab54f6SMichael Klier chi@chimeric.de  //check if search is restricted to namespace
330d0ab54f6SMichael Klier chi@chimeric.de  if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) {
331d0ab54f6SMichael Klier chi@chimeric.de      $id = cleanID($match[1]);
332d0ab54f6SMichael Klier chi@chimeric.de      if(empty($id)) {
333d0ab54f6SMichael Klier chi@chimeric.de        print '<div class="nothing">'.$lang['nothingfound'].'</div>';
334d0ab54f6SMichael Klier chi@chimeric.de        flush();
335d0ab54f6SMichael Klier chi@chimeric.de        return;
336d0ab54f6SMichael Klier chi@chimeric.de      }
337d0ab54f6SMichael Klier chi@chimeric.de  } else {
338d0ab54f6SMichael Klier chi@chimeric.de      $id = cleanID($QUERY);
339d0ab54f6SMichael Klier chi@chimeric.de  }
340d0ab54f6SMichael Klier chi@chimeric.de
3414d9ff3d5Sandi  //show progressbar
342e226efe1SAndreas Gohr  print '<div class="centeralign" id="dw__loading">'.NL;
343e226efe1SAndreas Gohr  print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
344e226efe1SAndreas Gohr  print 'showLoadBar();'.NL;
345e226efe1SAndreas Gohr  print '//--><!]]></script>'.NL;
346e226efe1SAndreas Gohr  print '<br /></div>'.NL;
3479edac8a8SAndreas Gohr  flush();
3484d9ff3d5Sandi
349f3f0262cSandi  //do quick pagesearch
350f3f0262cSandi  $data = array();
351d0ab54f6SMichael Klier chi@chimeric.de
352d0ab54f6SMichael Klier chi@chimeric.de  $data = ft_pageLookup($id);
353f3f0262cSandi  if(count($data)){
354f3f0262cSandi    sort($data);
355f3f0262cSandi    print '<div class="search_quickresult">';
356746855cfSBen Coburn    print '<h3>'.$lang['quickhits'].':</h3>';
3574f732f0eSAnika Henke    print '<ul class="search_quickhits">';
358140c93f3SAnika Henke    foreach($data as $id){
3594f732f0eSAnika Henke      print '<li> ';
360506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id);
3614f732f0eSAnika Henke      print '</li> ';
362f3f0262cSandi    }
363140c93f3SAnika Henke    print '</ul> ';
364f3f0262cSandi    //clear float (see http://www.complexspiral.com/publications/containing-floats/)
365f3f0262cSandi    print '<div class="clearer">&nbsp;</div>';
366f3f0262cSandi    print '</div>';
367f3f0262cSandi  }
368f3f0262cSandi  flush();
369f3f0262cSandi
370f3f0262cSandi  //do fulltext search
371506fa893SAndreas Gohr  $data = ft_pageSearch($QUERY,$poswords);
372f3f0262cSandi  if(count($data)){
373506fa893SAndreas Gohr    $num = 1;
374506fa893SAndreas Gohr    foreach($data as $id => $cnt){
375f3f0262cSandi      print '<div class="search_result">';
376506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords);
377506fa893SAndreas Gohr      print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
378506fa893SAndreas Gohr      if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
379506fa893SAndreas Gohr        print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>';
380506fa893SAndreas Gohr      }
381f3f0262cSandi      print '</div>';
382506fa893SAndreas Gohr      flush();
383506fa893SAndreas Gohr      $num++;
384f3f0262cSandi    }
385f3f0262cSandi  }else{
386820fa24bSandi    print '<div class="nothing">'.$lang['nothingfound'].'</div>';
387f3f0262cSandi  }
3884d9ff3d5Sandi
3894d9ff3d5Sandi  //hide progressbar
390e226efe1SAndreas Gohr  print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL;
391e226efe1SAndreas Gohr  print 'hideLoadBar("dw__loading");'.NL;
392e226efe1SAndreas Gohr  print '//--><!]]></script>'.NL;
3939edac8a8SAndreas Gohr  flush();
394f3f0262cSandi}
395f3f0262cSandi
39615fae107Sandi/**
39715fae107Sandi * Display error on locked pages
39815fae107Sandi *
39915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
40015fae107Sandi */
401ee20e7d1Sandifunction html_locked(){
402f3f0262cSandi  global $ID;
403f3f0262cSandi  global $conf;
404f3f0262cSandi  global $lang;
40588f522e9Sandi  global $INFO;
406f3f0262cSandi
407c9b4bd1eSBen Coburn  $locktime = filemtime(wikiLockFN($ID));
408f3f0262cSandi  $expire = @date($conf['dformat'], $locktime + $conf['locktime'] );
409f3f0262cSandi  $min    = round(($conf['locktime'] - (time() - $locktime) )/60);
410f3f0262cSandi
411c112d578Sandi  print p_locale_xhtml('locked');
412f3f0262cSandi  print '<ul>';
4130c6b58a8SAndreas Gohr  print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>';
4140c6b58a8SAndreas Gohr  print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>';
415f3f0262cSandi  print '</ul>';
416f3f0262cSandi}
417f3f0262cSandi
41815fae107Sandi/**
41915fae107Sandi * list old revisions
42015fae107Sandi *
42115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
42271726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net>
42315fae107Sandi */
42471726d78SBen Coburnfunction html_revisions($first=0){
425f3f0262cSandi  global $ID;
426f3f0262cSandi  global $INFO;
427f3f0262cSandi  global $conf;
428f3f0262cSandi  global $lang;
42971726d78SBen Coburn  /* we need to get one additionally log entry to be able to
43071726d78SBen Coburn   * decide if this is the last page or is there another one.
43171726d78SBen Coburn   * see html_recent()
43271726d78SBen Coburn   */
43371726d78SBen Coburn  $revisions = getRevisions($ID, $first, $conf['recent']+1);
43471726d78SBen Coburn  if(count($revisions)==0 && $first!=0){
43571726d78SBen Coburn    $first=0;
43671726d78SBen Coburn    $revisions = getRevisions($ID, $first, $conf['recent']+1);;
43771726d78SBen Coburn  }
43871726d78SBen Coburn  $hasNext = false;
43971726d78SBen Coburn  if (count($revisions)>$conf['recent']) {
44071726d78SBen Coburn    $hasNext = true;
44171726d78SBen Coburn    array_pop($revisions); // remove extra log entry
44271726d78SBen Coburn  }
44371726d78SBen Coburn
444f3f0262cSandi  $date = @date($conf['dformat'],$INFO['lastmod']);
445f3f0262cSandi
446c112d578Sandi  print p_locale_xhtml('revisions');
447f3f0262cSandi  print '<ul>';
44871726d78SBen Coburn  if($INFO['exists'] && $first==0){
449ebf1501fSBen Coburn    print (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
4500c6b58a8SAndreas Gohr    print '<div class="li">';
451f9b2fe70Sandi
452f9b2fe70Sandi    print $date;
453f9b2fe70Sandi
45402e51121SAnika Henke    print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> ';
455cffcc403Sandi
456f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ';
457652610a2Sandi
45841396b71SAndreas Gohr    print ' &ndash; ';
459652610a2Sandi    print $INFO['sum'];
46088f522e9Sandi    print ' <span class="user">';
4615aa52fafSBen Coburn    print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):$INFO['editor'];
46288f522e9Sandi    print '</span> ';
463652610a2Sandi
464652610a2Sandi    print '('.$lang['current'].')';
4650c6b58a8SAndreas Gohr    print '</div>';
466652610a2Sandi    print '</li>';
467f3f0262cSandi  }
468f3f0262cSandi
469f3f0262cSandi  foreach($revisions as $rev){
470f3f0262cSandi    $date = date($conf['dformat'],$rev);
471fb53bfe2SBen Coburn    $info = getRevisionInfo($ID,$rev,true);
472652610a2Sandi
473ebf1501fSBen Coburn    print ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
4740c6b58a8SAndreas Gohr    print '<div class="li">';
475f9b2fe70Sandi    print $date;
476f9b2fe70Sandi
47741396b71SAndreas Gohr    if(@file_exists(wikiFN($ID,$rev))){
478cffcc403Sandi      print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
479d94f4568SAndreas Gohr      $p = array();
480d94f4568SAndreas Gohr      $p['src']    = DOKU_BASE.'lib/images/diff.png';
481d94f4568SAndreas Gohr      $p['width']  = 15;
482d94f4568SAndreas Gohr      $p['height'] = 11;
483d94f4568SAndreas Gohr      $p['title']  = $lang['diff'];
484d94f4568SAndreas Gohr      $p['alt']    = $lang['diff'];
485d94f4568SAndreas Gohr      $att = buildAttributes($p);
486d94f4568SAndreas Gohr      print "<img $att />";
487cffcc403Sandi      print '</a> ';
488cffcc403Sandi
489f9b2fe70Sandi      print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a>';
49041396b71SAndreas Gohr    }else{
49141396b71SAndreas Gohr      print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> ';
49241396b71SAndreas Gohr      print $ID;
49341396b71SAndreas Gohr    }
494f9b2fe70Sandi
49541396b71SAndreas Gohr    print ' &ndash; ';
496f243a77fSandi    print htmlspecialchars($info['sum']);
49788f522e9Sandi    print ' <span class="user">';
49888f522e9Sandi    if($info['user']){
49988f522e9Sandi      print $info['user'];
50088f522e9Sandi    }else{
501652610a2Sandi      print $info['ip'];
50288f522e9Sandi    }
50388f522e9Sandi    print '</span>';
504652610a2Sandi
5050c6b58a8SAndreas Gohr    print '</div>';
506f3f0262cSandi    print '</li>';
507f3f0262cSandi  }
508f3f0262cSandi  print '</ul>';
50971726d78SBen Coburn
51071726d78SBen Coburn  print '<div class="pagenav">';
51171726d78SBen Coburn  $last = $first + $conf['recent'];
51271726d78SBen Coburn  if ($first > 0) {
51371726d78SBen Coburn    $first -= $conf['recent'];
51471726d78SBen Coburn    if ($first < 0) $first = 0;
51571726d78SBen Coburn    print '<div class="pagenav-prev">';
516eeb83e57SBen Coburn    print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first));
51771726d78SBen Coburn    print '</div>';
51871726d78SBen Coburn  }
51971726d78SBen Coburn  if ($hasNext) {
52071726d78SBen Coburn    print '<div class="pagenav-next">';
521eeb83e57SBen Coburn    print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last));
52271726d78SBen Coburn    print '</div>';
52371726d78SBen Coburn  }
52471726d78SBen Coburn  print '</div>';
52571726d78SBen Coburn
526f3f0262cSandi}
527f3f0262cSandi
52815fae107Sandi/**
52915fae107Sandi * display recent changes
53015fae107Sandi *
53115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
5325749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
53371726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net>
53415fae107Sandi */
535a39955b0Smatthiasgrimmfunction html_recent($first=0){
536f3f0262cSandi  global $conf;
537cffcc403Sandi  global $lang;
538dbb00abcSEsther Brunner  global $ID;
5395749f1ceSmatthiasgrimm  /* we need to get one additionally log entry to be able to
5405749f1ceSmatthiasgrimm   * decide if this is the last page or is there another one.
5415749f1ceSmatthiasgrimm   * This is the cheapest solution to get this information.
5425749f1ceSmatthiasgrimm   */
543b6912aeaSAndreas Gohr  $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
5445749f1ceSmatthiasgrimm  if(count($recents) == 0 && $first != 0){
5455749f1ceSmatthiasgrimm    $first=0;
54671726d78SBen Coburn    $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
5475749f1ceSmatthiasgrimm  }
54871726d78SBen Coburn  $hasNext = false;
54971726d78SBen Coburn  if (count($recents)>$conf['recent']) {
55071726d78SBen Coburn    $hasNext = true;
55171726d78SBen Coburn    array_pop($recents); // remove extra log entry
55271726d78SBen Coburn  }
553f3f0262cSandi
554c112d578Sandi  print p_locale_xhtml('recent');
555f3f0262cSandi  print '<ul>';
556a39955b0Smatthiasgrimm
557d437bcc4SAndreas Gohr  foreach($recents as $recent){
558d437bcc4SAndreas Gohr    $date = date($conf['dformat'],$recent['date']);
559ebf1501fSBen Coburn    print ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>';
5600c6b58a8SAndreas Gohr    print '<div class="li">';
561cffcc403Sandi
562f9b2fe70Sandi    print $date.' ';
563f9b2fe70Sandi
564d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=diff").'">';
565d94f4568SAndreas Gohr    $p = array();
566d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
567d94f4568SAndreas Gohr    $p['width']  = 15;
568d94f4568SAndreas Gohr    $p['height'] = 11;
569d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
570d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
571d94f4568SAndreas Gohr    $att = buildAttributes($p);
572d94f4568SAndreas Gohr    print "<img $att />";
573cffcc403Sandi    print '</a> ';
574cffcc403Sandi
575d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=revisions").'">';
576d94f4568SAndreas Gohr    $p = array();
577d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/history.png';
578d94f4568SAndreas Gohr    $p['width']  = 12;
579d94f4568SAndreas Gohr    $p['height'] = 14;
580d94f4568SAndreas Gohr    $p['title']  = $lang['btn_revs'];
581d94f4568SAndreas Gohr    $p['alt']    = $lang['btn_revs'];
582d94f4568SAndreas Gohr    $att = buildAttributes($p);
583d94f4568SAndreas Gohr    print "<img $att />";
584cffcc403Sandi    print '</a> ';
585cffcc403Sandi
586d437bcc4SAndreas Gohr    print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
58741396b71SAndreas Gohr    print ' &ndash; '.htmlspecialchars($recent['sum']);
588b6912aeaSAndreas Gohr
58988f522e9Sandi    print ' <span class="user">';
590d437bcc4SAndreas Gohr    if($recent['user']){
591d437bcc4SAndreas Gohr      print $recent['user'];
59288f522e9Sandi    }else{
593d437bcc4SAndreas Gohr      print $recent['ip'];
59488f522e9Sandi    }
59588f522e9Sandi    print '</span>';
596cffcc403Sandi
5970c6b58a8SAndreas Gohr    print '</div>';
598f3f0262cSandi    print '</li>';
599f3f0262cSandi  }
600f3f0262cSandi  print '</ul>';
601a39955b0Smatthiasgrimm
602a39955b0Smatthiasgrimm  print '<div class="pagenav">';
6035749f1ceSmatthiasgrimm  $last = $first + $conf['recent'];
604a39955b0Smatthiasgrimm  if ($first > 0) {
605a39955b0Smatthiasgrimm    $first -= $conf['recent'];
606a39955b0Smatthiasgrimm    if ($first < 0) $first = 0;
607a39955b0Smatthiasgrimm    print '<div class="pagenav-prev">';
6085749f1ceSmatthiasgrimm    print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
609a39955b0Smatthiasgrimm    print '</div>';
610a39955b0Smatthiasgrimm  }
61171726d78SBen Coburn  if ($hasNext) {
612a39955b0Smatthiasgrimm    print '<div class="pagenav-next">';
6135749f1ceSmatthiasgrimm    print html_btn('older','',"n",array('do' => 'recent', 'first' => $last));
614a39955b0Smatthiasgrimm    print '</div>';
615a39955b0Smatthiasgrimm  }
616a39955b0Smatthiasgrimm  print '</div>';
617f3f0262cSandi}
618f3f0262cSandi
61915fae107Sandi/**
62015fae107Sandi * Display page index
62115fae107Sandi *
62215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
62315fae107Sandi */
624f3f0262cSandifunction html_index($ns){
625ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
626f3f0262cSandi  global $conf;
627f3f0262cSandi  global $ID;
628f3f0262cSandi  $dir = $conf['datadir'];
629f3f0262cSandi  $ns  = cleanID($ns);
63030f1737dSandi  #fixme use appropriate function
631f3f0262cSandi  if(empty($ns)){
632f3f0262cSandi    $ns = dirname(str_replace(':','/',$ID));
633f3f0262cSandi    if($ns == '.') $ns ='';
634f3f0262cSandi  }
63588d3a917Sandi  $ns  = utf8_encodeFN(str_replace(':','/',$ns));
636f3f0262cSandi
637*a06884abSAndreas Gohr  echo p_locale_xhtml('index');
638*a06884abSAndreas Gohr  echo '<div id="index__tree">';
639f3f0262cSandi
640f3f0262cSandi  $data = array();
641f3f0262cSandi  search($data,$conf['datadir'],'search_index',array('ns' => $ns));
642*a06884abSAndreas Gohr  echo html_buildlist($data,'idx','html_list_index','html_li_index');
643*a06884abSAndreas Gohr
644*a06884abSAndreas Gohr  echo '</div>';
645f3f0262cSandi}
646f3f0262cSandi
647f3f0262cSandi/**
64815fae107Sandi * Index item formatter
64915fae107Sandi *
650f3f0262cSandi * User function for html_buildlist()
65115fae107Sandi *
65215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
653f3f0262cSandi */
654f3f0262cSandifunction html_list_index($item){
655d98d4540SBen Coburn  global $ID;
656f3f0262cSandi  $ret = '';
657f3f0262cSandi  $base = ':'.$item['id'];
658f3f0262cSandi  $base = substr($base,strrpos($base,':')+1);
659f3f0262cSandi  if($item['type']=='d'){
660ed7ecb79SAnika Henke    $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir"><strong>';
661f3f0262cSandi    $ret .= $base;
662ed7ecb79SAnika Henke    $ret .= '</strong></a>';
663f3f0262cSandi  }else{
664f3f0262cSandi    $ret .= html_wikilink(':'.$item['id']);
665f3f0262cSandi  }
666f3f0262cSandi  return $ret;
667f3f0262cSandi}
668f3f0262cSandi
669f3f0262cSandi/**
670cb70c441Sandi * Index List item
671cb70c441Sandi *
672cb70c441Sandi * This user function is used in html_build_lidt to build the
673cb70c441Sandi * <li> tags for namespaces when displaying the page index
674cb70c441Sandi * it gives different classes to opened or closed "folders"
675cb70c441Sandi *
676cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
677cb70c441Sandi */
678cb70c441Sandifunction html_li_index($item){
679cb70c441Sandi  if($item['type'] == "f"){
680cb70c441Sandi    return '<li class="level'.$item['level'].'">';
681cb70c441Sandi  }elseif($item['open']){
682cb70c441Sandi    return '<li class="open">';
683cb70c441Sandi  }else{
684cb70c441Sandi    return '<li class="closed">';
685cb70c441Sandi  }
686cb70c441Sandi}
687cb70c441Sandi
688cb70c441Sandi/**
689cb70c441Sandi * Default List item
690cb70c441Sandi *
691cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
692cb70c441Sandi */
693cb70c441Sandifunction html_li_default($item){
694cb70c441Sandi  return '<li class="level'.$item['level'].'">';
695cb70c441Sandi}
696cb70c441Sandi
697cb70c441Sandi/**
69815fae107Sandi * Build an unordered list
69915fae107Sandi *
700f3f0262cSandi * Build an unordered list from the given $data array
701f3f0262cSandi * Each item in the array has to have a 'level' property
702f3f0262cSandi * the item itself gets printed by the given $func user
703cb70c441Sandi * function. The second and optional function is used to
704cb70c441Sandi * print the <li> tag. Both user function need to accept
705cb70c441Sandi * a single item.
70615fae107Sandi *
707c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to
708c5a8fd96SAndreas Gohr * a member of an object.
709c5a8fd96SAndreas Gohr *
71015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
711f3f0262cSandi */
712cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){
713f3f0262cSandi  $level = 0;
714f3f0262cSandi  $opens = 0;
715f3f0262cSandi  $ret   = '';
716f3f0262cSandi
717f3f0262cSandi  foreach ($data as $item){
718f3f0262cSandi
719f3f0262cSandi    if( $item['level'] > $level ){
720f3f0262cSandi      //open new list
721df52d0feSandi      for($i=0; $i<($item['level'] - $level); $i++){
722df52d0feSandi        if ($i) $ret .= "<li class=\"clear\">\n";
723f3f0262cSandi        $ret .= "\n<ul class=\"$class\">\n";
724df52d0feSandi      }
725f3f0262cSandi    }elseif( $item['level'] < $level ){
726f3f0262cSandi      //close last item
727f3f0262cSandi      $ret .= "</li>\n";
728f3f0262cSandi      for ($i=0; $i<($level - $item['level']); $i++){
729f3f0262cSandi        //close higher lists
730f3f0262cSandi        $ret .= "</ul>\n</li>\n";
731f3f0262cSandi      }
732f3f0262cSandi    }else{
733f3f0262cSandi      //close last item
734f3f0262cSandi      $ret .= "</li>\n";
735f3f0262cSandi    }
736f3f0262cSandi
737f3f0262cSandi    //remember current level
738f3f0262cSandi    $level = $item['level'];
739f3f0262cSandi
740f3f0262cSandi    //print item
74134dbe711Schris    $ret .= call_user_func($lifunc,$item);
7420c6b58a8SAndreas Gohr    $ret .= '<div class="li">';
74334dbe711Schris
74434dbe711Schris    $ret .= call_user_func($func,$item);
7450c6b58a8SAndreas Gohr    $ret .= '</div>';
746f3f0262cSandi  }
747f3f0262cSandi
748f3f0262cSandi  //close remaining items and lists
749f3f0262cSandi  for ($i=0; $i < $level; $i++){
750f3f0262cSandi    $ret .= "</li></ul>\n";
751f3f0262cSandi  }
752f3f0262cSandi
753f3f0262cSandi  return $ret;
754f3f0262cSandi}
755f3f0262cSandi
75615fae107Sandi/**
75715fae107Sandi * display backlinks
75815fae107Sandi *
75915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
76015fae107Sandi */
761f3f0262cSandifunction html_backlinks(){
76254f4c056SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
763f3f0262cSandi  global $ID;
764f3f0262cSandi  global $conf;
765f3f0262cSandi
766c112d578Sandi  print p_locale_xhtml('backlinks');
767f3f0262cSandi
76854f4c056SAndreas Gohr  $data = ft_backlinks($ID);
769f3f0262cSandi
770f3f0262cSandi  print '<ul class="idx">';
77154f4c056SAndreas Gohr  foreach($data as $blink){
7720c6b58a8SAndreas Gohr    print '<li><div class="li">';
77354f4c056SAndreas Gohr    print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink);
7740c6b58a8SAndreas Gohr    print '</div></li>';
775f3f0262cSandi  }
776f3f0262cSandi  print '</ul>';
777f3f0262cSandi}
778f3f0262cSandi
77915fae107Sandi/**
78015fae107Sandi * show diff
78115fae107Sandi *
78215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
78315fae107Sandi */
784f3f0262cSandifunction html_diff($text='',$intro=true){
785ed7b5f09Sandi  require_once(DOKU_INC.'inc/DifferenceEngine.php');
786f3f0262cSandi  global $ID;
787f3f0262cSandi  global $REV;
788f3f0262cSandi  global $lang;
789f3f0262cSandi  global $conf;
790e1bd90ffSAndreas Gohr
791f3f0262cSandi  if($text){
792e1bd90ffSAndreas Gohr    $df  = new Diff(explode("\n",htmlspecialchars(rawWiki($ID,''))),
793e1bd90ffSAndreas Gohr                    explode("\n",htmlspecialchars(cleanText($text))));
794f3f0262cSandi    $left  = '<a class="wikilink1" href="'.wl($ID).'">'.
795f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'.
796f3f0262cSandi              $lang['current'];
797f3f0262cSandi    $right = $lang['yours'];
798f3f0262cSandi  }else{
7992a355ffaSDavid Lorentsen    //check if current revision exist
8002a355ffaSDavid Lorentsen    if(!@file_exists(wikiFN($ID))){
8012a355ffaSDavid Lorentsen      $revs = getRevisions($ID, 0, 2);
8022a355ffaSDavid Lorentsen      $rc = $revs[1];
8032a355ffaSDavid Lorentsen    }
8044d58bd99Sandi    if($REV){
8054d58bd99Sandi      $r = $REV;
8064d58bd99Sandi    }else{
8072a355ffaSDavid Lorentsen      if(empty($revs)){
8084d58bd99Sandi        //use last revision if none given
80971726d78SBen Coburn        $revs = getRevisions($ID, 0, 1);
8102a355ffaSDavid Lorentsen      }
8114d58bd99Sandi      $r = $revs[0];
8124d58bd99Sandi    }
8134d58bd99Sandi
814e1bd90ffSAndreas Gohr    if($r){
815e1bd90ffSAndreas Gohr      $df  = new Diff(explode("\n",htmlspecialchars(rawWiki($ID,$r))),
816e1bd90ffSAndreas Gohr                      explode("\n",htmlspecialchars(rawWiki($ID,''))));
8174d58bd99Sandi      $left  = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'.
8182a355ffaSDavid Lorentsen                $ID.' '.date($conf['dformat'],(isset($rc) ? $rc : $r)).'</a>';
819e1bd90ffSAndreas Gohr    }else{
820e1bd90ffSAndreas Gohr      $df  = new Diff(array(''),
821e1bd90ffSAndreas Gohr                      explode("\n",htmlspecialchars(rawWiki($ID,''))));
822e1bd90ffSAndreas Gohr      $left  = '<a class="wikilink1" href="'.wl($ID).'">'.
823e1bd90ffSAndreas Gohr                $ID.'</a>';
824e1bd90ffSAndreas Gohr    }
825f3f0262cSandi    $right = '<a class="wikilink1" href="'.wl($ID).'">'.
8262a355ffaSDavid Lorentsen              $ID.' '.date($conf['dformat'],(isset($rc) ? $r : @filemtime(wikiFN($ID)))).'</a> '.
827f3f0262cSandi              $lang['current'];
828f3f0262cSandi  }
829f3f0262cSandi  $tdf = new TableDiffFormatter();
830c112d578Sandi  if($intro) print p_locale_xhtml('diff');
831f3f0262cSandi  ?>
832daf4ca4eSAnika Henke    <table class="diff">
833f3f0262cSandi      <tr>
834daf4ca4eSAnika Henke        <th colspan="2">
8354da078a3Smatthiasgrimm          <?php echo $left?>
836daf4ca4eSAnika Henke        </th>
837daf4ca4eSAnika Henke        <th colspan="2">
8384da078a3Smatthiasgrimm          <?php echo $right?>
839daf4ca4eSAnika Henke        </th>
840f3f0262cSandi      </tr>
8414da078a3Smatthiasgrimm      <?php echo $tdf->format($df)?>
842f3f0262cSandi    </table>
8434da078a3Smatthiasgrimm  <?php
844f3f0262cSandi}
845f3f0262cSandi
84615fae107Sandi/**
84715fae107Sandi * show warning on conflict detection
84815fae107Sandi *
84915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
85015fae107Sandi */
851f3f0262cSandifunction html_conflict($text,$summary){
852f3f0262cSandi  global $ID;
853f3f0262cSandi  global $lang;
854f3f0262cSandi
855c112d578Sandi  print p_locale_xhtml('conflict');
856f3f0262cSandi  ?>
8571dd0c202SAnika Henke  <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
85896331712SAnika Henke  <div class="centeralign">
8594da078a3Smatthiasgrimm    <input type="hidden" name="id" value="<?php echo $ID?>" />
8604da078a3Smatthiasgrimm    <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" />
8614da078a3Smatthiasgrimm    <input type="hidden" name="summary" value="<?php echo formText($summary)?>" />
862f3f0262cSandi
86318829381SAndreas Gohr    <input class="button" type="submit" name="do[save]" value="<?php echo $lang['btn_save']?>" accesskey="s" title="<?php echo $lang['btn_save']?> [ALT+S]" />
86418829381SAndreas Gohr    <input class="button" type="submit" name="do[cancel]" value="<?php echo $lang['btn_cancel']?>" />
865f3f0262cSandi  </div>
866f3f0262cSandi  </form>
867f3f0262cSandi  <br /><br /><br /><br />
8684da078a3Smatthiasgrimm  <?php
869f3f0262cSandi}
870f3f0262cSandi
871f3f0262cSandi/**
87215fae107Sandi * Prints the global message array
87315fae107Sandi *
87415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
875f3f0262cSandi */
876f3f0262cSandifunction html_msgarea(){
877f3f0262cSandi  global $MSG;
878f3f0262cSandi
879f3f0262cSandi  if(!isset($MSG)) return;
880f3f0262cSandi
881f3f0262cSandi  foreach($MSG as $msg){
882f3f0262cSandi    print '<div class="'.$msg['lvl'].'">';
883f3f0262cSandi    print $msg['msg'];
884f3f0262cSandi    print '</div>';
885f3f0262cSandi  }
886f3f0262cSandi}
887f3f0262cSandi
888f3f0262cSandi/**
889f3f0262cSandi * Prints the registration form
89015fae107Sandi *
89115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
892c9570649SAndreas Gohr * @triggers HTML_REGISTERFORM_INJECTION
893f3f0262cSandi */
894f3f0262cSandifunction html_register(){
895f3f0262cSandi  global $lang;
896cab2716aSmatthias.grimm  global $conf;
897f3f0262cSandi  global $ID;
898f3f0262cSandi
899c112d578Sandi  print p_locale_xhtml('register');
900f3f0262cSandi?>
90196331712SAnika Henke  <div class="centeralign">
9021dd0c202SAnika Henke  <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
90396331712SAnika Henke  <fieldset>
904f3f0262cSandi    <input type="hidden" name="do" value="register" />
905f3f0262cSandi    <input type="hidden" name="save" value="1" />
90696331712SAnika Henke
9074da078a3Smatthiasgrimm    <legend><?php echo $lang['register']?></legend>
908b6912aeaSAndreas Gohr    <label class="block">
9094da078a3Smatthiasgrimm      <?php echo $lang['user']?>
9104da078a3Smatthiasgrimm      <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
911f3f0262cSandi    </label><br />
912cab2716aSmatthias.grimm
913cab2716aSmatthias.grimm    <?php
914cab2716aSmatthias.grimm      if (!$conf['autopasswd']) {
915cab2716aSmatthias.grimm    ?>
916b6912aeaSAndreas Gohr      <label class="block">
9174da078a3Smatthiasgrimm        <?php echo $lang['pass']?>
918cab2716aSmatthias.grimm        <input type="password" name="pass" class="edit" size="50" />
919cab2716aSmatthias.grimm      </label><br />
920b6912aeaSAndreas Gohr      <label class="block">
9214da078a3Smatthiasgrimm        <?php echo $lang['passchk']?>
922cab2716aSmatthias.grimm        <input type="password" name="passchk" class="edit" size="50" />
923cab2716aSmatthias.grimm      </label><br />
924cab2716aSmatthias.grimm    <?php
925cab2716aSmatthias.grimm      }
926cab2716aSmatthias.grimm    ?>
927cab2716aSmatthias.grimm
928b6912aeaSAndreas Gohr    <label class="block">
9294da078a3Smatthiasgrimm      <?php echo $lang['fullname']?>
9304da078a3Smatthiasgrimm      <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
931f3f0262cSandi    </label><br />
932b6912aeaSAndreas Gohr    <label class="block">
9334da078a3Smatthiasgrimm      <?php echo $lang['email']?>
9344da078a3Smatthiasgrimm      <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
935f3f0262cSandi    </label><br />
936c9570649SAndreas Gohr    <?php //bad and dirty event insert hook
937c9570649SAndreas Gohr    $evdata = array();
938c9570649SAndreas Gohr    trigger_event('HTML_REGISTERFORM_INJECTION', $evdata);
939c9570649SAndreas Gohr    ?>
9404da078a3Smatthiasgrimm    <input type="submit" class="button" value="<?php echo $lang['register']?>" />
941f3f0262cSandi  </fieldset>
942f3f0262cSandi  </form>
943f3f0262cSandi  </div>
9444da078a3Smatthiasgrimm<?php
945f3f0262cSandi}
946f3f0262cSandi
947f3f0262cSandi/**
9488b06d178Schris * Print the update profile form
9498b06d178Schris *
9508b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk>
9518b06d178Schris * @author Andreas Gohr <andi@splitbrain.org>
9528b06d178Schris */
9538b06d178Schrisfunction html_updateprofile(){
9548b06d178Schris  global $lang;
9558b06d178Schris  global $conf;
9568b06d178Schris  global $ID;
9578b06d178Schris  global $INFO;
95882fd59b6SAndreas Gohr  global $auth;
9598b06d178Schris
9608b06d178Schris  print p_locale_xhtml('updateprofile');
9618b06d178Schris
9628b06d178Schris  if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
9638b06d178Schris  if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
9648b06d178Schris?>
96596331712SAnika Henke  <div class="centeralign">
9661dd0c202SAnika Henke  <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
96796331712SAnika Henke  <fieldset style="width: 80%;">
9688b06d178Schris    <input type="hidden" name="do" value="profile" />
9698b06d178Schris    <input type="hidden" name="save" value="1" />
97096331712SAnika Henke
9718b06d178Schris    <legend><?php echo $lang['profile']?></legend>
9728b06d178Schris    <label class="block">
9738b06d178Schris      <?php echo $lang['user']?>
9748b06d178Schris      <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" />
9758b06d178Schris    </label><br />
9768b06d178Schris    <label class="block">
9778b06d178Schris      <?php echo $lang['fullname']?>
97882fd59b6SAndreas Gohr      <input type="text" name="fullname" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
9798b06d178Schris    </label><br />
9808b06d178Schris    <label class="block">
9818b06d178Schris      <?php echo $lang['email']?>
98282fd59b6SAndreas Gohr      <input type="text" name="email" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
9838b06d178Schris    </label><br /><br />
98482fd59b6SAndreas Gohr
98582fd59b6SAndreas Gohr    <?php if($auth->canDo('modPass')) { ?>
9868b06d178Schris    <label class="block">
9878b06d178Schris      <?php echo $lang['newpass']?>
9888b06d178Schris      <input type="password" name="newpass" class="edit" size="50" />
9898b06d178Schris    </label><br />
9908b06d178Schris    <label class="block">
9918b06d178Schris      <?php echo $lang['passchk']?>
9928b06d178Schris      <input type="password" name="passchk" class="edit" size="50" />
9938b06d178Schris    </label><br />
99482fd59b6SAndreas Gohr    <?php } ?>
9958b06d178Schris
9968b06d178Schris    <?php if ($conf['profileconfirm']) { ?>
9978b06d178Schris      <br />
9988b06d178Schris      <label class="block">
9998b06d178Schris      <?php echo $lang['oldpass']?>
10008b06d178Schris      <input type="password" name="oldpass" class="edit" size="50" />
10018b06d178Schris    </label><br />
10028b06d178Schris    <?php } ?>
100328a97b17SEsther Brunner    <?php //bad and dirty event insert hook
100428a97b17SEsther Brunner    $evdata = array();
100528a97b17SEsther Brunner    trigger_event('HTML_PROFILEFORM_INJECTION', $evdata);
100628a97b17SEsther Brunner    ?>
10074cb79657SMatthias Grimm    <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" />
10088b06d178Schris    <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" />
10098b06d178Schris  </fieldset>
10108b06d178Schris  </form>
10118b06d178Schris  </div>
10128b06d178Schris<?php
10138b06d178Schris}
10148b06d178Schris
10158b06d178Schris/**
1016f3f0262cSandi * This displays the edit form (lots of logic included)
101715fae107Sandi *
10187146cee2SAndreas Gohr * @fixme    this is a huge lump of code and should be modularized
1019016b6153SAndreas Gohr * @triggers HTML_PAGE_FROMTEMPLATE
1020c9570649SAndreas Gohr * @triggers HTML_EDITFORM_INJECTION
102115fae107Sandi * @author   Andreas Gohr <andi@splitbrain.org>
1022f3f0262cSandi */
1023f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed?
1024f3f0262cSandi  global $ID;
1025f3f0262cSandi  global $REV;
1026f3f0262cSandi  global $DATE;
1027f3f0262cSandi  global $RANGE;
1028f3f0262cSandi  global $PRE;
1029f3f0262cSandi  global $SUF;
1030f3f0262cSandi  global $INFO;
1031f3f0262cSandi  global $SUM;
1032f3f0262cSandi  global $lang;
1033f3f0262cSandi  global $conf;
1034f3f0262cSandi
1035f3f0262cSandi  //set summary default
1036f3f0262cSandi  if(!$SUM){
1037f3f0262cSandi    if($REV){
1038f3f0262cSandi      $SUM = $lang['restored'];
1039f3f0262cSandi    }elseif(!$INFO['exists']){
1040f3f0262cSandi      $SUM = $lang['created'];
1041f3f0262cSandi    }
1042f3f0262cSandi  }
1043f3f0262cSandi
1044f3f0262cSandi  //no text? Load it!
1045f3f0262cSandi  if(!isset($text)){
1046f3f0262cSandi    $pr = false; //no preview mode
10477146cee2SAndreas Gohr    if($INFO['exists']){
1048f3f0262cSandi      if($RANGE){
1049f3f0262cSandi        list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
1050f3f0262cSandi      }else{
1051f3f0262cSandi        $text = rawWiki($ID,$REV);
1052f3f0262cSandi      }
10538fe3bb00STom N Harris      $check = md5($text);
10548fe3bb00STom N Harris      $mod = false;
1055f3f0262cSandi    }else{
10567146cee2SAndreas Gohr      //try to load a pagetemplate
1057b7d5a5f0SAndreas Gohr      $data = array($ID);
1058016b6153SAndreas Gohr      $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true);
10598fe3bb00STom N Harris      $check = md5('');
10608fe3bb00STom N Harris      $mod = $text!=='';
10617146cee2SAndreas Gohr    }
10627146cee2SAndreas Gohr  }else{
1063f3f0262cSandi    $pr = true; //preview mode
10648fe3bb00STom N Harris    if (isset($_REQUEST['changecheck'])) {
10658fe3bb00STom N Harris      $check = $_REQUEST['changecheck'];
10668fe3bb00STom N Harris      $mod = md5($text)!==$check;
10678fe3bb00STom N Harris    } else {
10688fe3bb00STom N Harris      // Why? Assume default text is unmodified.
10698fe3bb00STom N Harris      $check = md5($text);
10708fe3bb00STom N Harris      $mod = false;
10718fe3bb00STom N Harris    }
1072f3f0262cSandi  }
1073f3f0262cSandi
1074f3f0262cSandi  $wr = $INFO['writable'];
1075f3f0262cSandi  if($wr){
1076c112d578Sandi    if ($REV) print p_locale_xhtml('editrev');
1077c112d578Sandi    print p_locale_xhtml($include);
1078d98d4540SBen Coburn    $ro=false;
1079f3f0262cSandi  }else{
1080409d7af7SAndreas Gohr    // check pseudo action 'source'
1081409d7af7SAndreas Gohr    if(!actionOK('source')){
1082409d7af7SAndreas Gohr      msg('Command disabled: source',-1);
1083409d7af7SAndreas Gohr      return;
1084409d7af7SAndreas Gohr    }
1085c112d578Sandi    print p_locale_xhtml('read');
1086f3f0262cSandi    $ro='readonly="readonly"';
1087f3f0262cSandi  }
1088f3f0262cSandi  if(!$DATE) $DATE = $INFO['lastmod'];
1089dc57ef04Sandi
1090dc57ef04Sandi
1091f3f0262cSandi?>
109263afe2a6SAnika Henke  <div style="width:99%;">
109342c7abd6SAndreas Gohr
109463afe2a6SAnika Henke   <div class="toolbar">
1095bb4866bdSchris      <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.date($conf['dformat']);?></div>
1096409d7af7SAndreas Gohr      <div id="tool__bar"><?php if(!$ro){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>"
1097409d7af7SAndreas Gohr      target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div>
109820d062caSAndreas Gohr
10994da078a3Smatthiasgrimm      <?php if($wr){?>
1100e226efe1SAndreas Gohr      <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--
11014da078a3Smatthiasgrimm        <?php /* sets changed to true when previewed */?>
11028fe3bb00STom N Harris        textChanged = <?php ($mod) ? print 'true' : print 'false' ?>;
1103e226efe1SAndreas Gohr      //--><!]]></script>
110424a33b42SAndreas Gohr      <span id="spell__action"></span>
110524a33b42SAndreas Gohr      <div id="spell__suggest"></div>
1106ee4c4a1bSAndreas Gohr      <?php } ?>
110763afe2a6SAnika Henke   </div>
110824a33b42SAndreas Gohr   <div id="spell__result"></div>
110963afe2a6SAnika Henke
111042c7abd6SAndreas Gohr
111142c7abd6SAndreas Gohr   <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"><div class="no">
111242c7abd6SAndreas Gohr      <input type="hidden" name="id"   value="<?php echo $ID?>" />
111342c7abd6SAndreas Gohr      <input type="hidden" name="rev"  value="<?php echo $REV?>" />
111442c7abd6SAndreas Gohr      <input type="hidden" name="date" value="<?php echo $DATE?>" />
111542c7abd6SAndreas Gohr      <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" />
111642c7abd6SAndreas Gohr      <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" />
11178fe3bb00STom N Harris      <input type="hidden" name="changecheck" value="<?php echo $check?>" />
111842c7abd6SAndreas Gohr    </div>
111942c7abd6SAndreas Gohr
112024a33b42SAndreas Gohr    <textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea>
112163afe2a6SAnika Henke
112288e6a4f2SAndreas Gohr    <?php //bad and dirty event insert hook
112388e6a4f2SAndreas Gohr    $evdata = array('writable' => $wr);
112488e6a4f2SAndreas Gohr    trigger_event('HTML_EDITFORM_INJECTION', $evdata);
112588e6a4f2SAndreas Gohr    ?>
112688e6a4f2SAndreas Gohr
112724a33b42SAndreas Gohr    <div id="wiki__editbar">
112824a33b42SAndreas Gohr      <div id="size__ctl"></div>
11294da078a3Smatthiasgrimm      <?php if($wr){?>
1130fa24fadbSAnika Henke         <div class="editButtons">
113118829381SAndreas Gohr            <input class="button" id="edbtn__save" type="submit" name="do[save]" value="<?php echo $lang['btn_save']?>" accesskey="s" title="<?php echo $lang['btn_save']?> [ALT+S]" tabindex="4" />
113218829381SAndreas Gohr            <input class="button" id="edbtn__preview" type="submit" name="do[preview]" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="<?php echo $lang['btn_preview']?> [ALT+P]" tabindex="5" />
113342c7abd6SAndreas Gohr            <input class="button" type="submit" name="do[draftdel]" value="<?php echo $lang['btn_cancel']?>" tabindex="6" />
1134fa24fadbSAnika Henke         </div>
11354da078a3Smatthiasgrimm      <?php } ?>
11364da078a3Smatthiasgrimm      <?php if($wr){ ?>
1137fa24fadbSAnika Henke        <div class="summary">
113824a33b42SAndreas Gohr           <label for="edit__summary" class="nowrap"><?php echo $lang['summary']?>:</label>
113924a33b42SAndreas Gohr           <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" />
1140b6912aeaSAndreas Gohr           <?php html_minoredit()?>
1141fa24fadbSAnika Henke        </div>
11424da078a3Smatthiasgrimm      <?php }?>
114363afe2a6SAnika Henke    </div>
114442c7abd6SAndreas Gohr  </form>
114563afe2a6SAnika Henke  </div>
11464da078a3Smatthiasgrimm<?php
1147f3f0262cSandi}
1148f3f0262cSandi
1149f3f0262cSandi/**
1150b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users
1151b6912aeaSAndreas Gohr *
1152b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org>
1153b6912aeaSAndreas Gohr */
1154b6912aeaSAndreas Gohrfunction html_minoredit(){
1155b6912aeaSAndreas Gohr  global $conf;
1156b6912aeaSAndreas Gohr  global $lang;
1157b6912aeaSAndreas Gohr  // minor edits are for logged in users only
1158b6912aeaSAndreas Gohr  if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
1159b6912aeaSAndreas Gohr    return;
1160b6912aeaSAndreas Gohr  }
1161b6912aeaSAndreas Gohr
1162b6912aeaSAndreas Gohr  $p = array();
1163b6912aeaSAndreas Gohr  $p['name']     = 'minor';
1164b6912aeaSAndreas Gohr  $p['type']     = 'checkbox';
1165b6912aeaSAndreas Gohr  $p['id']       = 'minoredit';
1166b6912aeaSAndreas Gohr  $p['tabindex'] = 3;
1167b6912aeaSAndreas Gohr  $p['value']    = '1';
1168bb4866bdSchris  if(!empty($_REQUEST['minor'])) $p['checked']='checked';
1169b6912aeaSAndreas Gohr  $att = buildAttributes($p);
1170b6912aeaSAndreas Gohr
1171fa24fadbSAnika Henke  print '<span class="nowrap">';
1172b6912aeaSAndreas Gohr  print "<input $att />";
1173b6912aeaSAndreas Gohr  print '<label for="minoredit">';
1174b6912aeaSAndreas Gohr  print $lang['minoredit'];
1175b6912aeaSAndreas Gohr  print '</label>';
1176fa24fadbSAnika Henke  print '</span>';
1177b6912aeaSAndreas Gohr}
1178b6912aeaSAndreas Gohr
1179b6912aeaSAndreas Gohr/**
1180f3f0262cSandi * prints some debug info
118115fae107Sandi *
118215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
1183f3f0262cSandi */
1184f3f0262cSandifunction html_debug(){
1185f3f0262cSandi  global $conf;
1186d16a4edaSandi  global $lang;
11875298a619SAndreas Gohr  global $auth;
1188100a97e3SAndreas Gohr  global $INFO;
1189100a97e3SAndreas Gohr
119028fb55ffSandi  //remove sensitive data
119128fb55ffSandi  $cnf = $conf;
119228fb55ffSandi  $cnf['auth']='***';
119328fb55ffSandi  $cnf['notify']='***';
11943dc3a5f1Sandi  $cnf['ftp']='***';
1195100a97e3SAndreas Gohr  $nfo = $INFO;
1196100a97e3SAndreas Gohr  $nfo['userinfo'] = '***';
1197100a97e3SAndreas Gohr  $ses = $_SESSION;
1198100a97e3SAndreas Gohr  $ses[$conf['title']]['auth'] = '***';
1199f3f0262cSandi
1200f3f0262cSandi  print '<html><body>';
1201f3f0262cSandi
1202f3f0262cSandi  print '<p>When reporting bugs please send all the following ';
1203f3f0262cSandi  print 'output as a mail to andi@splitbrain.org ';
1204f3f0262cSandi  print 'The best way to do this is to save this page in your browser</p>';
1205f3f0262cSandi
1206100a97e3SAndreas Gohr  print '<b>$INFO:</b><pre>';
1207100a97e3SAndreas Gohr  print_r($nfo);
1208100a97e3SAndreas Gohr  print '</pre>';
1209100a97e3SAndreas Gohr
1210f3f0262cSandi  print '<b>$_SERVER:</b><pre>';
1211f3f0262cSandi  print_r($_SERVER);
1212f3f0262cSandi  print '</pre>';
1213f3f0262cSandi
1214f3f0262cSandi  print '<b>$conf:</b><pre>';
121528fb55ffSandi  print_r($cnf);
1216f3f0262cSandi  print '</pre>';
1217f3f0262cSandi
1218ed7b5f09Sandi  print '<b>DOKU_BASE:</b><pre>';
1219ed7b5f09Sandi  print DOKU_BASE;
1220f3f0262cSandi  print '</pre>';
1221f3f0262cSandi
1222ed7b5f09Sandi  print '<b>abs DOKU_BASE:</b><pre>';
1223ed7b5f09Sandi  print DOKU_URL;
1224ed7b5f09Sandi  print '</pre>';
1225ed7b5f09Sandi
1226ed7b5f09Sandi  print '<b>rel DOKU_BASE:</b><pre>';
1227f3f0262cSandi  print dirname($_SERVER['PHP_SELF']).'/';
1228f3f0262cSandi  print '</pre>';
1229f3f0262cSandi
1230f3f0262cSandi  print '<b>PHP Version:</b><pre>';
1231f3f0262cSandi  print phpversion();
1232f3f0262cSandi  print '</pre>';
1233f3f0262cSandi
1234f3f0262cSandi  print '<b>locale:</b><pre>';
1235f3f0262cSandi  print setlocale(LC_ALL,0);
1236f3f0262cSandi  print '</pre>';
1237f3f0262cSandi
1238d16a4edaSandi  print '<b>encoding:</b><pre>';
1239d16a4edaSandi  print $lang['encoding'];
1240d16a4edaSandi  print '</pre>';
1241d16a4edaSandi
12425298a619SAndreas Gohr  if($auth){
12435298a619SAndreas Gohr    print '<b>Auth backend capabilities:</b><pre>';
12445298a619SAndreas Gohr    print_r($auth->cando);
12455298a619SAndreas Gohr    print '</pre>';
12465298a619SAndreas Gohr  }
12475298a619SAndreas Gohr
12483aa54d7cSAndreas Gohr  print '<b>$_SESSION:</b><pre>';
1249100a97e3SAndreas Gohr  print_r($ses);
12503aa54d7cSAndreas Gohr  print '</pre>';
12513aa54d7cSAndreas Gohr
1252f3f0262cSandi  print '<b>Environment:</b><pre>';
1253f3f0262cSandi  print_r($_ENV);
1254f3f0262cSandi  print '</pre>';
1255f3f0262cSandi
1256f3f0262cSandi  print '<b>PHP settings:</b><pre>';
1257f3f0262cSandi  $inis = ini_get_all();
1258f3f0262cSandi  print_r($inis);
1259f3f0262cSandi  print '</pre>';
1260f3f0262cSandi
1261f3f0262cSandi  print '</body></html>';
1262f3f0262cSandi}
1263f3f0262cSandi
1264c19fe9c0Sandifunction html_admin(){
1265c19fe9c0Sandi  global $ID;
1266f8cc712eSAndreas Gohr  global $INFO;
1267c19fe9c0Sandi  global $lang;
1268ca3a6df1SMatthias Grimm  global $conf;
1269c19fe9c0Sandi
1270c112d578Sandi  print p_locale_xhtml('admin');
1271c19fe9c0Sandi
127211e2ce22Schris  // build menu of admin functions from the plugins that handle them
127311e2ce22Schris  $pluginlist = plugin_list('admin');
127411e2ce22Schris  $menu = array();
127511e2ce22Schris  foreach ($pluginlist as $p) {
127611e2ce22Schris    if($obj =& plugin_load('admin',$p) === NULL) continue;
1277f8cc712eSAndreas Gohr
1278f8cc712eSAndreas Gohr    // check permissions
1279f8cc712eSAndreas Gohr    if($obj->forAdminOnly() && !$INFO['isadmin']) continue;
1280f8cc712eSAndreas Gohr
128111e2ce22Schris    $menu[] = array('plugin' => $p,
128211e2ce22Schris                    'prompt' => $obj->getMenuText($conf['lang']),
128311e2ce22Schris                    'sort' => $obj->getMenuSort()
128411e2ce22Schris                   );
128511e2ce22Schris  }
128611e2ce22Schris
1287746855cfSBen Coburn  usort($menu, 'p_sort_modes');
128811e2ce22Schris
128911e2ce22Schris  // output the menu
129011e2ce22Schris  ptln('<ul>');
129111e2ce22Schris
129211e2ce22Schris  foreach ($menu as $item) {
129311e2ce22Schris    if (!$item['prompt']) continue;
12940c6b58a8SAndreas Gohr    ptln('  <li><div class="li"><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>');
129511e2ce22Schris  }
129611e2ce22Schris
129711e2ce22Schris  ptln('</ul>');
1298ca3a6df1SMatthias Grimm}
1299c19fe9c0Sandi
13008b06d178Schris/**
13018b06d178Schris * Form to request a new password for an existing account
13028b06d178Schris *
13038b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info>
130411e2ce22Schris */
13058b06d178Schrisfunction html_resendpwd() {
13068b06d178Schris  global $lang;
13078b06d178Schris  global $conf;
13088b06d178Schris  global $ID;
1309c19fe9c0Sandi
13108b06d178Schris  print p_locale_xhtml('resendpwd');
13118b06d178Schris?>
131296331712SAnika Henke  <div class="centeralign">
13131dd0c202SAnika Henke  <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post">
13148b06d178Schris    <fieldset>
13158b06d178Schris      <br />
1316753d5abfSMatthias Grimm      <legend><?php echo $lang['resendpwd']?></legend>
13178b06d178Schris      <input type="hidden" name="do" value="resendpwd" />
13188b06d178Schris      <input type="hidden" name="save" value="1" />
13198b06d178Schris      <label class="block">
13208b06d178Schris        <span><?php echo $lang['user']?></span>
13218b06d178Schris        <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br />
13228b06d178Schris      </label><br />
13238b06d178Schris      <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" />
13248b06d178Schris    </fieldset>
13258b06d178Schris  </form>
13268b06d178Schris  </div>
13278b06d178Schris<?php
13288b06d178Schris}
1329340756e4Sandi
1330340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 :
1331