xref: /dokuwiki/inc/html.php (revision c9b4bd1e30a047b11d0beaa4458204126e0c1b92)
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">
558d975344SAndreas Gohr    <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"
568d975344SAndreas Gohr          method="post" name="login">
57f3f0262cSandi      <fieldset>
584da078a3Smatthiasgrimm        <legend><?php echo $lang['btn_login']?></legend>
594da078a3Smatthiasgrimm        <input type="hidden" name="id" value="<?php echo $ID?>" />
60f3f0262cSandi        <input type="hidden" name="do" value="login" />
61b6912aeaSAndreas Gohr        <label class="block">
624da078a3Smatthiasgrimm          <span><?php echo $lang['user']?></span>
638d975344SAndreas Gohr          <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>"
648d975344SAndreas Gohr                 class="edit" id="focus__this" />
65f3f0262cSandi        </label><br />
66b6912aeaSAndreas Gohr        <label class="block">
674da078a3Smatthiasgrimm          <span><?php echo $lang['pass']?></span>
68f3f0262cSandi          <input type="password" name="p" class="edit" />
69f3f0262cSandi        </label><br />
700c1887a0SAndreas Gohr        <label for="remember__me" class="simple">
714d6f545eSAndreas Gohr          <input type="checkbox" name="r" id="remember__me" value="1" />
724da078a3Smatthiasgrimm          <span><?php echo $lang['remember']?></span>
73132bdbfeSandi        </label>
748d975344SAndreas Gohr        <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" />
75f3f0262cSandi      </fieldset>
76f3f0262cSandi    </form>
774da078a3Smatthiasgrimm  <?php
78409d7af7SAndreas Gohr    if($auth->canDo('addUser') && actionOK('register')){
79f3f0262cSandi      print '<p>';
80f3f0262cSandi      print $lang['reghere'];
81f3f0262cSandi      print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>';
82f3f0262cSandi      print '</p>';
83f3f0262cSandi    }
848b06d178Schris
85409d7af7SAndreas Gohr    if ($auth->canDo('modPass') && actionOK('resendpwd')) {
868b06d178Schris      print '<p>';
878b06d178Schris      print $lang['pwdforget'];
88753d5abfSMatthias Grimm      print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['btn_resendpwd'].'</a>';
898b06d178Schris      print '</p>';
908b06d178Schris    }
91f3f0262cSandi  ?>
92f3f0262cSandi    </div>
934da078a3Smatthiasgrimm  <?php
946bbae538Sandi/*
956bbae538Sandi FIXME provide new hook
96f3f0262cSandi  if(@file_exists('includes/login.txt')){
97f3f0262cSandi    print io_cacheParse('includes/login.txt');
98f3f0262cSandi  }
996bbae538Sandi*/
100f3f0262cSandi}
101f3f0262cSandi
102f3f0262cSandi/**
10315fae107Sandi * prints a section editing button
10435dae8b0SBen Coburn * used as a callback in html_secedit
10515fae107Sandi *
10615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
10715fae107Sandi */
10835dae8b0SBen Coburnfunction html_secedit_button($matches){
109f3f0262cSandi  global $ID;
110041d7a86SBen Coburn  global $INFO;
111041d7a86SBen Coburn
112041d7a86SBen Coburn  $section = $matches[2];
113041d7a86SBen Coburn  $name = $matches[1];
114041d7a86SBen Coburn
115f3f0262cSandi  $secedit  = '';
116f3f0262cSandi  $secedit .= '<div class="secedit">';
117f3f0262cSandi  $secedit .= html_btn('secedit',$ID,'',
118f3f0262cSandi                        array('do'      => 'edit',
119306b2c85SDenis Simakov                              'lines'   => "$section",
120306b2c85SDenis Simakov                              'rev' => $INFO['lastmod']),
12135dae8b0SBen Coburn                              'post', $name);
122f3f0262cSandi  $secedit .= '</div>';
123f3f0262cSandi  return $secedit;
124f3f0262cSandi}
125f3f0262cSandi
12615fae107Sandi/**
12715fae107Sandi * inserts section edit buttons if wanted or removes the markers
12815fae107Sandi *
12915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
13015fae107Sandi */
131f3f0262cSandifunction html_secedit($text,$show=true){
132f3f0262cSandi  global $INFO;
13335dae8b0SBen Coburn
134c112d578Sandi  if($INFO['writable'] && $show && !$INFO['rev']){
13535dae8b0SBen Coburn    $text = preg_replace_callback('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#',
13635dae8b0SBen Coburn                         'html_secedit_button', $text);
137f3f0262cSandi  }else{
13835dae8b0SBen Coburn    $text = preg_replace('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#','',$text);
139f3f0262cSandi  }
14035dae8b0SBen Coburn
141f3f0262cSandi  return $text;
142f3f0262cSandi}
143f3f0262cSandi
144f3f0262cSandi/**
145d6c9c552Smatthiasgrimm * Just the back to top button (in its own form)
1466b13307fSandi *
1476b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
1486b13307fSandi */
1496b13307fSandifunction html_topbtn(){
1506b13307fSandi  global $lang;
1516b13307fSandi
1526b13307fSandi  $ret  = '';
1530e99f6d7SBen Coburn  $ret  = '<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>';
154df7b6005Sandi
1556b13307fSandi  return $ret;
1566b13307fSandi}
1576b13307fSandi
1586b13307fSandi/**
159d67ca2c0Smatthiasgrimm * Just the back to media window button in its own form
160d67ca2c0Smatthiasgrimm *
161d67ca2c0Smatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
162d67ca2c0Smatthiasgrimm */
163d67ca2c0Smatthiasgrimmfunction html_backtomedia_button($params,$akey=''){
164d67ca2c0Smatthiasgrimm  global $conf;
165d67ca2c0Smatthiasgrimm  global $lang;
166d67ca2c0Smatthiasgrimm
1673df72098SAndreas Gohr  $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/mediamanager.php"><div class="no">';
168d67ca2c0Smatthiasgrimm
169d67ca2c0Smatthiasgrimm  reset($params);
170d67ca2c0Smatthiasgrimm  while (list($key, $val) = each($params)) {
171d67ca2c0Smatthiasgrimm    $ret .= '<input type="hidden" name="'.$key.'" ';
172d67ca2c0Smatthiasgrimm    $ret .= 'value="'.htmlspecialchars($val).'" />';
173d67ca2c0Smatthiasgrimm  }
174d67ca2c0Smatthiasgrimm
175d67ca2c0Smatthiasgrimm  $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" ';
176d67ca2c0Smatthiasgrimm  if($akey){
177d67ca2c0Smatthiasgrimm    $ret .= 'title="ALT+'.strtoupper($akey).'" ';
178d67ca2c0Smatthiasgrimm    $ret .= 'accesskey="'.$akey.'" ';
179d67ca2c0Smatthiasgrimm  }
180d67ca2c0Smatthiasgrimm  $ret .= '/>';
1814beabca9SAnika Henke  $ret .= '</div></form>';
182d67ca2c0Smatthiasgrimm
183d67ca2c0Smatthiasgrimm  return $ret;
184d67ca2c0Smatthiasgrimm}
185d67ca2c0Smatthiasgrimm
186d67ca2c0Smatthiasgrimm/**
187d67ca2c0Smatthiasgrimm * Displays a button (using its own form)
18835dae8b0SBen Coburn * If tooltip exists, the access key tooltip is replaced.
18915fae107Sandi *
19015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
191f3f0262cSandi */
19235dae8b0SBen Coburnfunction html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){
193f3f0262cSandi  global $conf;
194f3f0262cSandi  global $lang;
195f3f0262cSandi
196f3f0262cSandi  $label = $lang['btn_'.$name];
197f3f0262cSandi
198f3f0262cSandi  $ret = '';
19935dae8b0SBen Coburn  $tip = '';
200f3f0262cSandi
20149c713a3Sandi  //filter id (without urlencoding)
20249c713a3Sandi  $id = idfilter($id,false);
203f3f0262cSandi
204f3f0262cSandi  //make nice URLs even for buttons
2056c7843b5Sandi  if($conf['userewrite'] == 2){
2066c7843b5Sandi    $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
2076c7843b5Sandi  }elseif($conf['userewrite']){
2086c7843b5Sandi    $script = DOKU_BASE.$id;
2096c7843b5Sandi  }else{
2108b00ebcfSandi    $script = DOKU_BASE.DOKU_SCRIPT;
211f3f0262cSandi    $params['id'] = $id;
212f3f0262cSandi  }
213f3f0262cSandi
2144beabca9SAnika Henke  $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">';
215f3f0262cSandi
21606a4bf8fSAndreas Gohr  if(is_array($params)){
217f3f0262cSandi    reset($params);
218f3f0262cSandi    while (list($key, $val) = each($params)) {
219f3f0262cSandi      $ret .= '<input type="hidden" name="'.$key.'" ';
220f3f0262cSandi      $ret .= 'value="'.htmlspecialchars($val).'" />';
221f3f0262cSandi    }
22206a4bf8fSAndreas Gohr  }
223f3f0262cSandi
224f3f0262cSandi  $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
225f3f0262cSandi  if($akey){
22635dae8b0SBen Coburn    $tip = '[ALT+'.strtoupper($akey).']';
227f3f0262cSandi    $ret .= 'accesskey="'.$akey.'" ';
228f3f0262cSandi  }
22935dae8b0SBen Coburn  if ($tooltip!='') {
23035dae8b0SBen Coburn      $tip = htmlspecialchars($tooltip);
23135dae8b0SBen Coburn  }
23235dae8b0SBen Coburn  $ret .= 'title="'.$tip.'" ';
233f3f0262cSandi  $ret .= '/>';
2344beabca9SAnika Henke  $ret .= '</div></form>';
235f3f0262cSandi
236f3f0262cSandi  return $ret;
237f3f0262cSandi}
238f3f0262cSandi
239f3f0262cSandi/**
24015fae107Sandi * show a wiki page
24115fae107Sandi *
24215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
24315fae107Sandi */
2446bbae538Sandifunction html_show($txt=''){
245f3f0262cSandi  global $ID;
246f3f0262cSandi  global $REV;
247f3f0262cSandi  global $HIGH;
248f3f0262cSandi  //disable section editing for old revisions or in preview
2495400331dSandi  if($txt || $REV){
2506bbae538Sandi    $secedit = false;
2516bbae538Sandi  }else{
2526bbae538Sandi    $secedit = true;
253f3f0262cSandi  }
254f3f0262cSandi
2556bbae538Sandi  if ($txt){
256f3f0262cSandi    //PreviewHeader
25750835be7SAndreas Gohr    print '<br id="scroll__here" />';
258c112d578Sandi    print p_locale_xhtml('preview');
259f3f0262cSandi    print '<div class="preview">';
2609dc2c2afSandi    print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
26146723c19SAndreas Gohr    print '<div class="clearer"></div>';
262f3f0262cSandi    print '</div>';
2636bbae538Sandi
264f3f0262cSandi  }else{
265c112d578Sandi    if ($REV) print p_locale_xhtml('showrev');
266c112d578Sandi    $html = p_wiki_xhtml($ID,$REV,true);
2676bbae538Sandi    $html = html_secedit($html,$secedit);
268f3f0262cSandi    print html_hilight($html,$HIGH);
269f3f0262cSandi  }
270f3f0262cSandi}
271f3f0262cSandi
272f3f0262cSandi/**
273ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft
274ee4c4a1bSAndreas Gohr *
275ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
276ee4c4a1bSAndreas Gohr */
277ee4c4a1bSAndreas Gohrfunction html_draft(){
278ee4c4a1bSAndreas Gohr  global $INFO;
279ee4c4a1bSAndreas Gohr  global $ID;
280ee4c4a1bSAndreas Gohr  global $lang;
281ee4c4a1bSAndreas Gohr  global $conf;
282ee4c4a1bSAndreas Gohr  $draft = unserialize(io_readFile($INFO['draft'],false));
283ee4c4a1bSAndreas Gohr  $text  = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true));
284ee4c4a1bSAndreas Gohr
285ee4c4a1bSAndreas Gohr  echo p_locale_xhtml('draft');
286ee4c4a1bSAndreas Gohr  ?>
287ee4c4a1bSAndreas Gohr  <form id="dw__editform" method="post" action="<?php echo script()?>"
288ee4c4a1bSAndreas Gohr   accept-charset="<?php echo $lang['encoding']?>"><div class="no">
289ee4c4a1bSAndreas Gohr    <input type="hidden" name="id"   value="<?php echo $ID?>" />
290ee4c4a1bSAndreas Gohr    <input type="hidden" name="date" value="<?php echo $draft['date']?>" /></div>
291ee4c4a1bSAndreas Gohr    <textarea name="wikitext" id="wiki__text" readonly="readonly" cols="80" rows="10" class="edit"><?php echo "\n".formText($text)?></textarea>
292ee4c4a1bSAndreas Gohr
293ee4c4a1bSAndreas Gohr    <div id="draft__status"><?php echo $lang['draftdate'].' '.date($conf['dformat'],filemtime($INFO['draft']))?></div>
294ee4c4a1bSAndreas Gohr
295ee4c4a1bSAndreas Gohr    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_recover']?>" tabindex="1" />
296ee4c4a1bSAndreas Gohr    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_draftdel']?>" tabindex="2" />
297ee4c4a1bSAndreas Gohr    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="3" />
298ee4c4a1bSAndreas Gohr  </form>
299ee4c4a1bSAndreas Gohr  <?php
300ee4c4a1bSAndreas Gohr}
301ee4c4a1bSAndreas Gohr
302ee4c4a1bSAndreas Gohr/**
303f3f0262cSandi * Highlights searchqueries in HTML code
30415fae107Sandi *
30515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
3067209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
307f3f0262cSandi */
308f3f0262cSandifunction html_hilight($html,$query){
3097209be23SAndreas Gohr  //split at common delimiters
3109d9c165eSAndreas Gohr  $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY);
311f3f0262cSandi  foreach ($queries as $q){
312f3f0262cSandi     $q = preg_quote($q,'/');
3137209be23SAndreas Gohr     $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html);
314f3f0262cSandi  }
315f3f0262cSandi  return $html;
316f3f0262cSandi}
317f3f0262cSandi
318f3f0262cSandi/**
3197209be23SAndreas Gohr * Callback used by html_hilight()
3207209be23SAndreas Gohr *
3217209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com>
3227209be23SAndreas Gohr */
3237209be23SAndreas Gohrfunction html_hilight_callback($m) {
3247209be23SAndreas Gohr  $hlight = unslash($m[0]);
3257209be23SAndreas Gohr  if ( !isset($m[2])) {
3267209be23SAndreas Gohr    $hlight = '<span class="search_hit">'.$hlight.'</span>';
3277209be23SAndreas Gohr  }
3287209be23SAndreas Gohr  return $hlight;
3297209be23SAndreas Gohr}
3307209be23SAndreas Gohr
3317209be23SAndreas Gohr/**
33215fae107Sandi * Run a search and display the result
33315fae107Sandi *
33415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
335f3f0262cSandi */
336f3f0262cSandifunction html_search(){
337ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
338506fa893SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
339f3f0262cSandi  global $conf;
340f3f0262cSandi  global $QUERY;
341f3f0262cSandi  global $ID;
342f3f0262cSandi  global $lang;
343f3f0262cSandi
344c112d578Sandi  print p_locale_xhtml('searchpage');
345f3f0262cSandi  flush();
346f3f0262cSandi
347d0ab54f6SMichael Klier chi@chimeric.de  //check if search is restricted to namespace
348d0ab54f6SMichael Klier chi@chimeric.de  if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) {
349d0ab54f6SMichael Klier chi@chimeric.de      $id = cleanID($match[1]);
350d0ab54f6SMichael Klier chi@chimeric.de      if(empty($id)) {
351d0ab54f6SMichael Klier chi@chimeric.de        print '<div class="nothing">'.$lang['nothingfound'].'</div>';
352d0ab54f6SMichael Klier chi@chimeric.de        flush();
353d0ab54f6SMichael Klier chi@chimeric.de        return;
354d0ab54f6SMichael Klier chi@chimeric.de      }
355d0ab54f6SMichael Klier chi@chimeric.de  } else {
356d0ab54f6SMichael Klier chi@chimeric.de      $id = cleanID($QUERY);
357d0ab54f6SMichael Klier chi@chimeric.de  }
358d0ab54f6SMichael Klier chi@chimeric.de
3594d9ff3d5Sandi  //show progressbar
3609edac8a8SAndreas Gohr  print '<div class="centeralign" id="dw__loading">';
3614d9ff3d5Sandi  print '<br /></div>';
3629edac8a8SAndreas Gohr  print '<script type="text/javascript" charset="utf-8">';
3639edac8a8SAndreas Gohr  print 'showLoadBar("dw__loading");';
3649edac8a8SAndreas Gohr  print '</script>';
3659edac8a8SAndreas Gohr  flush();
3664d9ff3d5Sandi
367f3f0262cSandi  //do quick pagesearch
368f3f0262cSandi  $data = array();
369d0ab54f6SMichael Klier chi@chimeric.de
370d0ab54f6SMichael Klier chi@chimeric.de  $data = ft_pageLookup($id);
371f3f0262cSandi  if(count($data)){
372f3f0262cSandi    sort($data);
373f3f0262cSandi    print '<div class="search_quickresult">';
3744f732f0eSAnika Henke    print '<h3>'.$lang[quickhits].':</h3>';
3754f732f0eSAnika Henke    print '<ul class="search_quickhits">';
376140c93f3SAnika Henke    foreach($data as $id){
3774f732f0eSAnika Henke      print '<li> ';
378506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id);
3794f732f0eSAnika Henke      print '</li> ';
380f3f0262cSandi    }
381140c93f3SAnika Henke    print '</ul> ';
382f3f0262cSandi    //clear float (see http://www.complexspiral.com/publications/containing-floats/)
383f3f0262cSandi    print '<div class="clearer">&nbsp;</div>';
384f3f0262cSandi    print '</div>';
385f3f0262cSandi  }
386f3f0262cSandi  flush();
387f3f0262cSandi
388f3f0262cSandi  //do fulltext search
389506fa893SAndreas Gohr  $data = ft_pageSearch($QUERY,$poswords);
390f3f0262cSandi  if(count($data)){
391506fa893SAndreas Gohr    $num = 1;
392506fa893SAndreas Gohr    foreach($data as $id => $cnt){
393f3f0262cSandi      print '<div class="search_result">';
394506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords);
395506fa893SAndreas Gohr      print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
396506fa893SAndreas Gohr      if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
397506fa893SAndreas Gohr        print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>';
398506fa893SAndreas Gohr      }
399f3f0262cSandi      print '</div>';
400506fa893SAndreas Gohr      flush();
401506fa893SAndreas Gohr      $num++;
402f3f0262cSandi    }
403f3f0262cSandi  }else{
404820fa24bSandi    print '<div class="nothing">'.$lang['nothingfound'].'</div>';
405f3f0262cSandi  }
4064d9ff3d5Sandi
4074d9ff3d5Sandi  //hide progressbar
4084beabca9SAnika Henke  print '<script type="text/javascript" charset="utf-8">';
4099edac8a8SAndreas Gohr  print 'hideLoadBar("dw__loading");';
4104d9ff3d5Sandi  print '</script>';
4119edac8a8SAndreas Gohr  flush();
412f3f0262cSandi}
413f3f0262cSandi
41415fae107Sandi/**
41515fae107Sandi * Display error on locked pages
41615fae107Sandi *
41715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
41815fae107Sandi */
419ee20e7d1Sandifunction html_locked(){
420f3f0262cSandi  global $ID;
421f3f0262cSandi  global $conf;
422f3f0262cSandi  global $lang;
42388f522e9Sandi  global $INFO;
424f3f0262cSandi
425*c9b4bd1eSBen Coburn  $locktime = filemtime(wikiLockFN($ID));
426f3f0262cSandi  $expire = @date($conf['dformat'], $locktime + $conf['locktime'] );
427f3f0262cSandi  $min    = round(($conf['locktime'] - (time() - $locktime) )/60);
428f3f0262cSandi
429c112d578Sandi  print p_locale_xhtml('locked');
430f3f0262cSandi  print '<ul>';
4310c6b58a8SAndreas Gohr  print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>';
4320c6b58a8SAndreas Gohr  print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>';
433f3f0262cSandi  print '</ul>';
434f3f0262cSandi}
435f3f0262cSandi
43615fae107Sandi/**
43715fae107Sandi * list old revisions
43815fae107Sandi *
43915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
44015fae107Sandi */
441f3f0262cSandifunction html_revisions(){
442f3f0262cSandi  global $ID;
443f3f0262cSandi  global $INFO;
444f3f0262cSandi  global $conf;
445f3f0262cSandi  global $lang;
446f3f0262cSandi  $revisions = getRevisions($ID);
447f3f0262cSandi  $date = @date($conf['dformat'],$INFO['lastmod']);
448f3f0262cSandi
449c112d578Sandi  print p_locale_xhtml('revisions');
450f3f0262cSandi  print '<ul>';
451f3f0262cSandi  if($INFO['exists']){
452b6912aeaSAndreas Gohr    print ($INFO['minor']) ? '<li class="minor">' : '<li>';
4530c6b58a8SAndreas Gohr    print '<div class="li">';
454f9b2fe70Sandi
455f9b2fe70Sandi    print $date;
456f9b2fe70Sandi
45702e51121SAnika Henke    print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> ';
458cffcc403Sandi
459f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ';
460652610a2Sandi
461652610a2Sandi    print $INFO['sum'];
46288f522e9Sandi    print ' <span class="user">';
46388f522e9Sandi    print $INFO['editor'];
46488f522e9Sandi    print '</span> ';
465652610a2Sandi
466652610a2Sandi    print '('.$lang['current'].')';
4670c6b58a8SAndreas Gohr    print '</div>';
468652610a2Sandi    print '</li>';
469f3f0262cSandi  }
470f3f0262cSandi
471f3f0262cSandi  foreach($revisions as $rev){
472f3f0262cSandi    $date = date($conf['dformat'],$rev);
473fb53bfe2SBen Coburn    $info = getRevisionInfo($ID,$rev,true);
474652610a2Sandi
475b6912aeaSAndreas Gohr    print ($info['minor']) ? '<li class="minor">' : '<li>';
4760c6b58a8SAndreas Gohr    print '<div class="li">';
477f9b2fe70Sandi    print $date;
478f9b2fe70Sandi
479cffcc403Sandi    print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
480d94f4568SAndreas Gohr    $p = array();
481d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
482d94f4568SAndreas Gohr    $p['width']  = 15;
483d94f4568SAndreas Gohr    $p['height'] = 11;
484d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
485d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
486d94f4568SAndreas Gohr    $att = buildAttributes($p);
487d94f4568SAndreas Gohr    print "<img $att />";
488cffcc403Sandi    print '</a> ';
489cffcc403Sandi
490f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> ';
491f9b2fe70Sandi
492f243a77fSandi    print htmlspecialchars($info['sum']);
49388f522e9Sandi    print ' <span class="user">';
49488f522e9Sandi    if($info['user']){
49588f522e9Sandi      print $info['user'];
49688f522e9Sandi    }else{
497652610a2Sandi      print $info['ip'];
49888f522e9Sandi    }
49988f522e9Sandi    print '</span>';
500652610a2Sandi
5010c6b58a8SAndreas Gohr    print '</div>';
502f3f0262cSandi    print '</li>';
503f3f0262cSandi  }
504f3f0262cSandi  print '</ul>';
505f3f0262cSandi}
506f3f0262cSandi
50715fae107Sandi/**
50815fae107Sandi * display recent changes
50915fae107Sandi *
51015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
5115749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
51215fae107Sandi */
513a39955b0Smatthiasgrimmfunction html_recent($first=0){
514f3f0262cSandi  global $conf;
515cffcc403Sandi  global $lang;
516dbb00abcSEsther Brunner  global $ID;
5175749f1ceSmatthiasgrimm  /* we need to get one additionally log entry to be able to
5185749f1ceSmatthiasgrimm   * decide if this is the last page or is there another one.
5195749f1ceSmatthiasgrimm   * This is the cheapest solution to get this information.
5205749f1ceSmatthiasgrimm   */
521b6912aeaSAndreas Gohr  $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
5225749f1ceSmatthiasgrimm  if(count($recents) == 0 && $first != 0){
5235749f1ceSmatthiasgrimm    $first=0;
524b6912aeaSAndreas Gohr    $recents = getRecents(0,$conf['recent'] + 1,getNS($ID));
5255749f1ceSmatthiasgrimm  }
5265749f1ceSmatthiasgrimm  $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
527f3f0262cSandi
528c112d578Sandi  print p_locale_xhtml('recent');
529f3f0262cSandi  print '<ul>';
530a39955b0Smatthiasgrimm
531d437bcc4SAndreas Gohr  foreach($recents as $recent){
532d437bcc4SAndreas Gohr    $date = date($conf['dformat'],$recent['date']);
533b6912aeaSAndreas Gohr    print ($recent['minor']) ? '<li class="minor">' : '<li>';
5340c6b58a8SAndreas Gohr    print '<div class="li">';
535cffcc403Sandi
536f9b2fe70Sandi    print $date.' ';
537f9b2fe70Sandi
538d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=diff").'">';
539d94f4568SAndreas Gohr    $p = array();
540d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
541d94f4568SAndreas Gohr    $p['width']  = 15;
542d94f4568SAndreas Gohr    $p['height'] = 11;
543d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
544d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
545d94f4568SAndreas Gohr    $att = buildAttributes($p);
546d94f4568SAndreas Gohr    print "<img $att />";
547cffcc403Sandi    print '</a> ';
548cffcc403Sandi
549d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=revisions").'">';
550d94f4568SAndreas Gohr    $p = array();
551d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/history.png';
552d94f4568SAndreas Gohr    $p['width']  = 12;
553d94f4568SAndreas Gohr    $p['height'] = 14;
554d94f4568SAndreas Gohr    $p['title']  = $lang['btn_revs'];
555d94f4568SAndreas Gohr    $p['alt']    = $lang['btn_revs'];
556d94f4568SAndreas Gohr    $att = buildAttributes($p);
557d94f4568SAndreas Gohr    print "<img $att />";
558cffcc403Sandi    print '</a> ';
559cffcc403Sandi
560d437bcc4SAndreas Gohr    print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
561d437bcc4SAndreas Gohr    print ' '.htmlspecialchars($recent['sum']);
562b6912aeaSAndreas Gohr
56388f522e9Sandi    print ' <span class="user">';
564d437bcc4SAndreas Gohr    if($recent['user']){
565d437bcc4SAndreas Gohr      print $recent['user'];
56688f522e9Sandi    }else{
567d437bcc4SAndreas Gohr      print $recent['ip'];
56888f522e9Sandi    }
56988f522e9Sandi    print '</span>';
570cffcc403Sandi
5710c6b58a8SAndreas Gohr    print '</div>';
572f3f0262cSandi    print '</li>';
573f3f0262cSandi  }
574f3f0262cSandi  print '</ul>';
575a39955b0Smatthiasgrimm
576a39955b0Smatthiasgrimm  print '<div class="pagenav">';
5775749f1ceSmatthiasgrimm  $last = $first + $conf['recent'];
578a39955b0Smatthiasgrimm  if ($first > 0) {
579a39955b0Smatthiasgrimm    $first -= $conf['recent'];
580a39955b0Smatthiasgrimm    if ($first < 0) $first = 0;
581a39955b0Smatthiasgrimm    print '<div class="pagenav-prev">';
5825749f1ceSmatthiasgrimm    print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
583a39955b0Smatthiasgrimm    print '</div>';
584a39955b0Smatthiasgrimm  }
5855749f1ceSmatthiasgrimm  if ($conf['recent'] < count($recents)) {
586a39955b0Smatthiasgrimm    print '<div class="pagenav-next">';
5875749f1ceSmatthiasgrimm    print html_btn('older','',"n",array('do' => 'recent', 'first' => $last));
588a39955b0Smatthiasgrimm    print '</div>';
589a39955b0Smatthiasgrimm  }
590a39955b0Smatthiasgrimm  print '</div>';
591f3f0262cSandi}
592f3f0262cSandi
59315fae107Sandi/**
59415fae107Sandi * Display page index
59515fae107Sandi *
59615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
59715fae107Sandi */
598f3f0262cSandifunction html_index($ns){
599ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
600f3f0262cSandi  global $conf;
601f3f0262cSandi  global $ID;
602f3f0262cSandi  $dir = $conf['datadir'];
603f3f0262cSandi  $ns  = cleanID($ns);
60430f1737dSandi  #fixme use appropriate function
605f3f0262cSandi  if(empty($ns)){
606f3f0262cSandi    $ns = dirname(str_replace(':','/',$ID));
607f3f0262cSandi    if($ns == '.') $ns ='';
608f3f0262cSandi  }
60988d3a917Sandi  $ns  = utf8_encodeFN(str_replace(':','/',$ns));
610f3f0262cSandi
611c112d578Sandi  print p_locale_xhtml('index');
612f3f0262cSandi
613f3f0262cSandi  $data = array();
614f3f0262cSandi  search($data,$conf['datadir'],'search_index',array('ns' => $ns));
615cb70c441Sandi  print html_buildlist($data,'idx','html_list_index','html_li_index');
616f3f0262cSandi}
617f3f0262cSandi
618f3f0262cSandi/**
61915fae107Sandi * Index item formatter
62015fae107Sandi *
621f3f0262cSandi * User function for html_buildlist()
62215fae107Sandi *
62315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
624f3f0262cSandi */
625f3f0262cSandifunction html_list_index($item){
626f3f0262cSandi  $ret = '';
627f3f0262cSandi  $base = ':'.$item['id'];
628f3f0262cSandi  $base = substr($base,strrpos($base,':')+1);
629f3f0262cSandi  if($item['type']=='d'){
630f3f0262cSandi    $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">';
631f3f0262cSandi    $ret .= $base;
632f3f0262cSandi    $ret .= '</a>';
633f3f0262cSandi  }else{
634f3f0262cSandi    $ret .= html_wikilink(':'.$item['id']);
635f3f0262cSandi  }
636f3f0262cSandi  return $ret;
637f3f0262cSandi}
638f3f0262cSandi
639f3f0262cSandi/**
640cb70c441Sandi * Index List item
641cb70c441Sandi *
642cb70c441Sandi * This user function is used in html_build_lidt to build the
643cb70c441Sandi * <li> tags for namespaces when displaying the page index
644cb70c441Sandi * it gives different classes to opened or closed "folders"
645cb70c441Sandi *
646cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
647cb70c441Sandi */
648cb70c441Sandifunction html_li_index($item){
649cb70c441Sandi  if($item['type'] == "f"){
650cb70c441Sandi    return '<li class="level'.$item['level'].'">';
651cb70c441Sandi  }elseif($item['open']){
652cb70c441Sandi    return '<li class="open">';
653cb70c441Sandi  }else{
654cb70c441Sandi    return '<li class="closed">';
655cb70c441Sandi  }
656cb70c441Sandi}
657cb70c441Sandi
658cb70c441Sandi/**
659cb70c441Sandi * Default List item
660cb70c441Sandi *
661cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
662cb70c441Sandi */
663cb70c441Sandifunction html_li_default($item){
664cb70c441Sandi  return '<li class="level'.$item['level'].'">';
665cb70c441Sandi}
666cb70c441Sandi
667cb70c441Sandi/**
66815fae107Sandi * Build an unordered list
66915fae107Sandi *
670f3f0262cSandi * Build an unordered list from the given $data array
671f3f0262cSandi * Each item in the array has to have a 'level' property
672f3f0262cSandi * the item itself gets printed by the given $func user
673cb70c441Sandi * function. The second and optional function is used to
674cb70c441Sandi * print the <li> tag. Both user function need to accept
675cb70c441Sandi * a single item.
67615fae107Sandi *
677c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to
678c5a8fd96SAndreas Gohr * a member of an object.
679c5a8fd96SAndreas Gohr *
68015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
681f3f0262cSandi */
682cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){
683f3f0262cSandi  $level = 0;
684f3f0262cSandi  $opens = 0;
685f3f0262cSandi  $ret   = '';
686f3f0262cSandi
687f3f0262cSandi  foreach ($data as $item){
688f3f0262cSandi
689f3f0262cSandi    if( $item['level'] > $level ){
690f3f0262cSandi      //open new list
691df52d0feSandi      for($i=0; $i<($item['level'] - $level); $i++){
692df52d0feSandi        if ($i) $ret .= "<li class=\"clear\">\n";
693f3f0262cSandi        $ret .= "\n<ul class=\"$class\">\n";
694df52d0feSandi      }
695f3f0262cSandi    }elseif( $item['level'] < $level ){
696f3f0262cSandi      //close last item
697f3f0262cSandi      $ret .= "</li>\n";
698f3f0262cSandi      for ($i=0; $i<($level - $item['level']); $i++){
699f3f0262cSandi        //close higher lists
700f3f0262cSandi        $ret .= "</ul>\n</li>\n";
701f3f0262cSandi      }
702f3f0262cSandi    }else{
703f3f0262cSandi      //close last item
704f3f0262cSandi      $ret .= "</li>\n";
705f3f0262cSandi    }
706f3f0262cSandi
707f3f0262cSandi    //remember current level
708f3f0262cSandi    $level = $item['level'];
709f3f0262cSandi
710f3f0262cSandi    //print item
711c5a8fd96SAndreas Gohr    if(is_array($lifunc)){
712c5a8fd96SAndreas Gohr      $ret .= $lifunc[0]->$lifunc[1]($item); //user object method
713c5a8fd96SAndreas Gohr    }else{
714cb70c441Sandi      $ret .= $lifunc($item); //user function
715c5a8fd96SAndreas Gohr    }
7160c6b58a8SAndreas Gohr    $ret .= '<div class="li">';
717c5a8fd96SAndreas Gohr    if(is_array($func)){
718c5a8fd96SAndreas Gohr      $ret .= $func[0]->$func[1]($item); //user object method
719c5a8fd96SAndreas Gohr    }else{
720f3f0262cSandi    $ret .= $func($item); //user function
721c5a8fd96SAndreas Gohr    }
7220c6b58a8SAndreas Gohr    $ret .= '</div>';
723f3f0262cSandi  }
724f3f0262cSandi
725f3f0262cSandi  //close remaining items and lists
726f3f0262cSandi  for ($i=0; $i < $level; $i++){
727f3f0262cSandi    $ret .= "</li></ul>\n";
728f3f0262cSandi  }
729f3f0262cSandi
730f3f0262cSandi  return $ret;
731f3f0262cSandi}
732f3f0262cSandi
73315fae107Sandi/**
73415fae107Sandi * display backlinks
73515fae107Sandi *
73615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
73715fae107Sandi */
738f3f0262cSandifunction html_backlinks(){
73954f4c056SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
740f3f0262cSandi  global $ID;
741f3f0262cSandi  global $conf;
742f3f0262cSandi
743c112d578Sandi  print p_locale_xhtml('backlinks');
744f3f0262cSandi
74554f4c056SAndreas Gohr  $data = ft_backlinks($ID);
746f3f0262cSandi
747f3f0262cSandi  print '<ul class="idx">';
74854f4c056SAndreas Gohr  foreach($data as $blink){
7490c6b58a8SAndreas Gohr    print '<li><div class="li">';
75054f4c056SAndreas Gohr    print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink);
7510c6b58a8SAndreas Gohr    print '</div></li>';
752f3f0262cSandi  }
753f3f0262cSandi  print '</ul>';
754f3f0262cSandi}
755f3f0262cSandi
75615fae107Sandi/**
75715fae107Sandi * show diff
75815fae107Sandi *
75915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
76015fae107Sandi */
761f3f0262cSandifunction html_diff($text='',$intro=true){
762ed7b5f09Sandi  require_once(DOKU_INC.'inc/DifferenceEngine.php');
763f3f0262cSandi  global $ID;
764f3f0262cSandi  global $REV;
765f3f0262cSandi  global $lang;
766f3f0262cSandi  global $conf;
767f3f0262cSandi  if($text){
768f3f0262cSandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))),
769f3f0262cSandi                    split("\n",htmlspecialchars(cleanText($text))));
770f3f0262cSandi    $left  = '<a class="wikilink1" href="'.wl($ID).'">'.
771f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'.
772f3f0262cSandi              $lang['current'];
773f3f0262cSandi    $right = $lang['yours'];
774f3f0262cSandi  }else{
7754d58bd99Sandi    if($REV){
7764d58bd99Sandi      $r = $REV;
7774d58bd99Sandi    }else{
7784d58bd99Sandi      //use last revision if none given
7794d58bd99Sandi      $revs = getRevisions($ID);
7804d58bd99Sandi      $r = $revs[0];
7814d58bd99Sandi    }
7824d58bd99Sandi
7834d58bd99Sandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))),
784f3f0262cSandi                    split("\n",htmlspecialchars(rawWiki($ID,''))));
7854d58bd99Sandi    $left  = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'.
7864d58bd99Sandi              $ID.' '.date($conf['dformat'],$r).'</a>';
787f3f0262cSandi    $right = '<a class="wikilink1" href="'.wl($ID).'">'.
788f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '.
789f3f0262cSandi              $lang['current'];
790f3f0262cSandi  }
791f3f0262cSandi  $tdf = new TableDiffFormatter();
792c112d578Sandi  if($intro) print p_locale_xhtml('diff');
793f3f0262cSandi  ?>
794daf4ca4eSAnika Henke    <table class="diff">
795f3f0262cSandi      <tr>
796daf4ca4eSAnika Henke        <th colspan="2">
7974da078a3Smatthiasgrimm          <?php echo $left?>
798daf4ca4eSAnika Henke        </th>
799daf4ca4eSAnika Henke        <th colspan="2">
8004da078a3Smatthiasgrimm          <?php echo $right?>
801daf4ca4eSAnika Henke        </th>
802f3f0262cSandi      </tr>
8034da078a3Smatthiasgrimm      <?php echo $tdf->format($df)?>
804f3f0262cSandi    </table>
8054da078a3Smatthiasgrimm  <?php
806f3f0262cSandi}
807f3f0262cSandi
80815fae107Sandi/**
80915fae107Sandi * show warning on conflict detection
81015fae107Sandi *
81115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
81215fae107Sandi */
813f3f0262cSandifunction html_conflict($text,$summary){
814f3f0262cSandi  global $ID;
815f3f0262cSandi  global $lang;
816f3f0262cSandi
817c112d578Sandi  print p_locale_xhtml('conflict');
818f3f0262cSandi  ?>
8191dd0c202SAnika Henke  <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
82096331712SAnika Henke  <div class="centeralign">
8214da078a3Smatthiasgrimm    <input type="hidden" name="id" value="<?php echo $ID?>" />
8224da078a3Smatthiasgrimm    <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" />
8234da078a3Smatthiasgrimm    <input type="hidden" name="summary" value="<?php echo formText($summary)?>" />
824f3f0262cSandi
8254da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" />
8264da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" />
827f3f0262cSandi  </div>
828f3f0262cSandi  </form>
829f3f0262cSandi  <br /><br /><br /><br />
8304da078a3Smatthiasgrimm  <?php
831f3f0262cSandi}
832f3f0262cSandi
833f3f0262cSandi/**
83415fae107Sandi * Prints the global message array
83515fae107Sandi *
83615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
837f3f0262cSandi */
838f3f0262cSandifunction html_msgarea(){
839f3f0262cSandi  global $MSG;
840f3f0262cSandi
841f3f0262cSandi  if(!isset($MSG)) return;
842f3f0262cSandi
843f3f0262cSandi  foreach($MSG as $msg){
844f3f0262cSandi    print '<div class="'.$msg['lvl'].'">';
845f3f0262cSandi    print $msg['msg'];
846f3f0262cSandi    print '</div>';
847f3f0262cSandi  }
848f3f0262cSandi}
849f3f0262cSandi
850f3f0262cSandi/**
851f3f0262cSandi * Prints the registration form
85215fae107Sandi *
85315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
854f3f0262cSandi */
855f3f0262cSandifunction html_register(){
856f3f0262cSandi  global $lang;
857cab2716aSmatthias.grimm  global $conf;
858f3f0262cSandi  global $ID;
859f3f0262cSandi
860c112d578Sandi  print p_locale_xhtml('register');
861f3f0262cSandi?>
86296331712SAnika Henke  <div class="centeralign">
8631dd0c202SAnika Henke  <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
86496331712SAnika Henke  <fieldset>
865f3f0262cSandi    <input type="hidden" name="do" value="register" />
866f3f0262cSandi    <input type="hidden" name="save" value="1" />
86796331712SAnika Henke
8684da078a3Smatthiasgrimm    <legend><?php echo $lang['register']?></legend>
869b6912aeaSAndreas Gohr    <label class="block">
8704da078a3Smatthiasgrimm      <?php echo $lang['user']?>
8714da078a3Smatthiasgrimm      <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
872f3f0262cSandi    </label><br />
873cab2716aSmatthias.grimm
874cab2716aSmatthias.grimm    <?php
875cab2716aSmatthias.grimm      if (!$conf['autopasswd']) {
876cab2716aSmatthias.grimm    ?>
877b6912aeaSAndreas Gohr      <label class="block">
8784da078a3Smatthiasgrimm        <?php echo $lang['pass']?>
879cab2716aSmatthias.grimm        <input type="password" name="pass" class="edit" size="50" />
880cab2716aSmatthias.grimm      </label><br />
881b6912aeaSAndreas Gohr      <label class="block">
8824da078a3Smatthiasgrimm        <?php echo $lang['passchk']?>
883cab2716aSmatthias.grimm        <input type="password" name="passchk" class="edit" size="50" />
884cab2716aSmatthias.grimm      </label><br />
885cab2716aSmatthias.grimm    <?php
886cab2716aSmatthias.grimm      }
887cab2716aSmatthias.grimm    ?>
888cab2716aSmatthias.grimm
889b6912aeaSAndreas Gohr    <label class="block">
8904da078a3Smatthiasgrimm      <?php echo $lang['fullname']?>
8914da078a3Smatthiasgrimm      <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
892f3f0262cSandi    </label><br />
893b6912aeaSAndreas Gohr    <label class="block">
8944da078a3Smatthiasgrimm      <?php echo $lang['email']?>
8954da078a3Smatthiasgrimm      <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
896f3f0262cSandi    </label><br />
8974da078a3Smatthiasgrimm    <input type="submit" class="button" value="<?php echo $lang['register']?>" />
898f3f0262cSandi  </fieldset>
899f3f0262cSandi  </form>
900f3f0262cSandi  </div>
9014da078a3Smatthiasgrimm<?php
902f3f0262cSandi}
903f3f0262cSandi
904f3f0262cSandi/**
9058b06d178Schris * Print the update profile form
9068b06d178Schris *
9078b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk>
9088b06d178Schris * @author Andreas Gohr <andi@splitbrain.org>
9098b06d178Schris */
9108b06d178Schrisfunction html_updateprofile(){
9118b06d178Schris  global $lang;
9128b06d178Schris  global $conf;
9138b06d178Schris  global $ID;
9148b06d178Schris  global $INFO;
91582fd59b6SAndreas Gohr  global $auth;
9168b06d178Schris
9178b06d178Schris  print p_locale_xhtml('updateprofile');
9188b06d178Schris
9198b06d178Schris  if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
9208b06d178Schris  if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
9218b06d178Schris?>
92296331712SAnika Henke  <div class="centeralign">
9231dd0c202SAnika Henke  <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
92496331712SAnika Henke  <fieldset style="width: 80%;">
9258b06d178Schris    <input type="hidden" name="do" value="profile" />
9268b06d178Schris    <input type="hidden" name="save" value="1" />
92796331712SAnika Henke
9288b06d178Schris    <legend><?php echo $lang['profile']?></legend>
9298b06d178Schris    <label class="block">
9308b06d178Schris      <?php echo $lang['user']?>
9318b06d178Schris      <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" />
9328b06d178Schris    </label><br />
9338b06d178Schris    <label class="block">
9348b06d178Schris      <?php echo $lang['fullname']?>
93582fd59b6SAndreas Gohr      <input type="text" name="fullname" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
9368b06d178Schris    </label><br />
9378b06d178Schris    <label class="block">
9388b06d178Schris      <?php echo $lang['email']?>
93982fd59b6SAndreas Gohr      <input type="text" name="email" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
9408b06d178Schris    </label><br /><br />
94182fd59b6SAndreas Gohr
94282fd59b6SAndreas Gohr    <?php if($auth->canDo('modPass')) { ?>
9438b06d178Schris    <label class="block">
9448b06d178Schris      <?php echo $lang['newpass']?>
9458b06d178Schris      <input type="password" name="newpass" class="edit" size="50" />
9468b06d178Schris    </label><br />
9478b06d178Schris    <label class="block">
9488b06d178Schris      <?php echo $lang['passchk']?>
9498b06d178Schris      <input type="password" name="passchk" class="edit" size="50" />
9508b06d178Schris    </label><br />
95182fd59b6SAndreas Gohr    <?php } ?>
9528b06d178Schris
9538b06d178Schris    <?php if ($conf['profileconfirm']) { ?>
9548b06d178Schris      <br />
9558b06d178Schris      <label class="block">
9568b06d178Schris      <?php echo $lang['oldpass']?>
9578b06d178Schris      <input type="password" name="oldpass" class="edit" size="50" />
9588b06d178Schris    </label><br />
9598b06d178Schris    <?php } ?>
9608b06d178Schris
9614cb79657SMatthias Grimm    <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" />
9628b06d178Schris    <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" />
9638b06d178Schris  </fieldset>
9648b06d178Schris  </form>
9658b06d178Schris  </div>
9668b06d178Schris<?php
9678b06d178Schris}
9688b06d178Schris
9698b06d178Schris/**
970f3f0262cSandi * This displays the edit form (lots of logic included)
97115fae107Sandi *
9727146cee2SAndreas Gohr * @fixme  this is a huge lump of code and should be modularized
97315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
974f3f0262cSandi */
975f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed?
976f3f0262cSandi  global $ID;
977f3f0262cSandi  global $REV;
978f3f0262cSandi  global $DATE;
979f3f0262cSandi  global $RANGE;
980f3f0262cSandi  global $PRE;
981f3f0262cSandi  global $SUF;
982f3f0262cSandi  global $INFO;
983f3f0262cSandi  global $SUM;
984f3f0262cSandi  global $lang;
985f3f0262cSandi  global $conf;
986f3f0262cSandi
987f3f0262cSandi  //set summary default
988f3f0262cSandi  if(!$SUM){
989f3f0262cSandi    if($REV){
990f3f0262cSandi      $SUM = $lang['restored'];
991f3f0262cSandi    }elseif(!$INFO['exists']){
992f3f0262cSandi      $SUM = $lang['created'];
993f3f0262cSandi    }
994f3f0262cSandi  }
995f3f0262cSandi
996f3f0262cSandi  //no text? Load it!
997f3f0262cSandi  if(!isset($text)){
998f3f0262cSandi    $pr = false; //no preview mode
9997146cee2SAndreas Gohr    if($INFO['exists']){
1000f3f0262cSandi      if($RANGE){
1001f3f0262cSandi        list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
1002f3f0262cSandi      }else{
1003f3f0262cSandi        $text = rawWiki($ID,$REV);
1004f3f0262cSandi      }
1005f3f0262cSandi    }else{
10067146cee2SAndreas Gohr      //try to load a pagetemplate
10077146cee2SAndreas Gohr      $text = pageTemplate($ID);
10087146cee2SAndreas Gohr    }
10097146cee2SAndreas Gohr  }else{
1010f3f0262cSandi    $pr = true; //preview mode
1011f3f0262cSandi  }
1012f3f0262cSandi
1013f3f0262cSandi  $wr = $INFO['writable'];
1014f3f0262cSandi  if($wr){
1015c112d578Sandi    if ($REV) print p_locale_xhtml('editrev');
1016c112d578Sandi    print p_locale_xhtml($include);
1017f3f0262cSandi  }else{
1018409d7af7SAndreas Gohr    // check pseudo action 'source'
1019409d7af7SAndreas Gohr    if(!actionOK('source')){
1020409d7af7SAndreas Gohr      msg('Command disabled: source',-1);
1021409d7af7SAndreas Gohr      return;
1022409d7af7SAndreas Gohr    }
1023c112d578Sandi    print p_locale_xhtml('read');
1024f3f0262cSandi    $ro='readonly="readonly"';
1025f3f0262cSandi  }
1026f3f0262cSandi  if(!$DATE) $DATE = $INFO['lastmod'];
1027dc57ef04Sandi
1028dc57ef04Sandi
1029f3f0262cSandi?>
103063afe2a6SAnika Henke  <div style="width:99%;">
103142c7abd6SAndreas Gohr
103263afe2a6SAnika Henke   <div class="toolbar">
1033ee4c4a1bSAndreas Gohr      <div id="draft__status"><?php if($INFO['draft']) echo $lang['draftdate'].' '.date($conf['dformat']);?></div>
1034409d7af7SAndreas Gohr      <div id="tool__bar"><?php if(!$ro){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>"
1035409d7af7SAndreas Gohr      target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div>
103620d062caSAndreas Gohr
10374da078a3Smatthiasgrimm      <?php if($wr){?>
10384beabca9SAnika Henke      <script type="text/javascript" charset="utf-8">
10394da078a3Smatthiasgrimm        <?php /* sets changed to true when previewed */?>
10404da078a3Smatthiasgrimm        textChanged = <?php ($pr) ? print 'true' : print 'false' ?>;
1041f3f0262cSandi      </script>
104224a33b42SAndreas Gohr      <span id="spell__action"></span>
104324a33b42SAndreas Gohr      <div id="spell__suggest"></div>
1044ee4c4a1bSAndreas Gohr      <?php } ?>
104563afe2a6SAnika Henke   </div>
104624a33b42SAndreas Gohr   <div id="spell__result"></div>
104763afe2a6SAnika Henke
104842c7abd6SAndreas Gohr
104942c7abd6SAndreas Gohr   <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"><div class="no">
105042c7abd6SAndreas Gohr      <input type="hidden" name="id"   value="<?php echo $ID?>" />
105142c7abd6SAndreas Gohr      <input type="hidden" name="rev"  value="<?php echo $REV?>" />
105242c7abd6SAndreas Gohr      <input type="hidden" name="date" value="<?php echo $DATE?>" />
105342c7abd6SAndreas Gohr      <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" />
105442c7abd6SAndreas Gohr      <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" />
105542c7abd6SAndreas Gohr    </div>
105642c7abd6SAndreas Gohr
105724a33b42SAndreas Gohr    <textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea>
105863afe2a6SAnika Henke
105924a33b42SAndreas Gohr    <div id="wiki__editbar">
106024a33b42SAndreas Gohr      <div id="size__ctl"></div>
10614da078a3Smatthiasgrimm      <?php if($wr){?>
1062fa24fadbSAnika Henke         <div class="editButtons">
106324a33b42SAndreas Gohr            <input class="button" id="edbtn__save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" />
106424a33b42SAndreas Gohr            <input class="button" id="edbtn__preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" />
106542c7abd6SAndreas Gohr            <input class="button" type="submit" name="do[draftdel]" value="<?php echo $lang['btn_cancel']?>" tabindex="6" />
1066fa24fadbSAnika Henke         </div>
10674da078a3Smatthiasgrimm      <?php } ?>
10684da078a3Smatthiasgrimm      <?php if($wr){ ?>
1069fa24fadbSAnika Henke        <div class="summary">
107024a33b42SAndreas Gohr           <label for="edit__summary" class="nowrap"><?php echo $lang['summary']?>:</label>
107124a33b42SAndreas Gohr           <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" />
1072b6912aeaSAndreas Gohr           <?php html_minoredit()?>
1073fa24fadbSAnika Henke        </div>
10744da078a3Smatthiasgrimm      <?php }?>
107563afe2a6SAnika Henke    </div>
107642c7abd6SAndreas Gohr  </form>
107763afe2a6SAnika Henke  </div>
10784da078a3Smatthiasgrimm<?php
1079f3f0262cSandi}
1080f3f0262cSandi
1081f3f0262cSandi/**
1082b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users
1083b6912aeaSAndreas Gohr *
1084b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org>
1085b6912aeaSAndreas Gohr */
1086b6912aeaSAndreas Gohrfunction html_minoredit(){
1087b6912aeaSAndreas Gohr  global $conf;
1088b6912aeaSAndreas Gohr  global $lang;
1089b6912aeaSAndreas Gohr  // minor edits are for logged in users only
1090b6912aeaSAndreas Gohr  if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
1091b6912aeaSAndreas Gohr    return;
1092b6912aeaSAndreas Gohr  }
1093b6912aeaSAndreas Gohr
1094b6912aeaSAndreas Gohr  $p = array();
1095b6912aeaSAndreas Gohr  $p['name']     = 'minor';
1096b6912aeaSAndreas Gohr  $p['type']     = 'checkbox';
1097b6912aeaSAndreas Gohr  $p['id']       = 'minoredit';
1098b6912aeaSAndreas Gohr  $p['tabindex'] = 3;
1099b6912aeaSAndreas Gohr  $p['value']    = '1';
1100b6912aeaSAndreas Gohr  if($_REQUEST['minor']) $p['checked']='checked';
1101b6912aeaSAndreas Gohr  $att = buildAttributes($p);
1102b6912aeaSAndreas Gohr
1103fa24fadbSAnika Henke  print '<span class="nowrap">';
1104b6912aeaSAndreas Gohr  print "<input $att />";
1105b6912aeaSAndreas Gohr  print '<label for="minoredit">';
1106b6912aeaSAndreas Gohr  print $lang['minoredit'];
1107b6912aeaSAndreas Gohr  print '</label>';
1108fa24fadbSAnika Henke  print '</span>';
1109b6912aeaSAndreas Gohr}
1110b6912aeaSAndreas Gohr
1111b6912aeaSAndreas Gohr/**
1112f3f0262cSandi * prints some debug info
111315fae107Sandi *
111415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
1115f3f0262cSandi */
1116f3f0262cSandifunction html_debug(){
1117f3f0262cSandi  global $conf;
1118d16a4edaSandi  global $lang;
11195298a619SAndreas Gohr  global $auth;
112028fb55ffSandi  //remove sensitive data
112128fb55ffSandi  $cnf = $conf;
112228fb55ffSandi  $cnf['auth']='***';
112328fb55ffSandi  $cnf['notify']='***';
11243dc3a5f1Sandi  $cnf['ftp']='***';
1125f3f0262cSandi
1126f3f0262cSandi  print '<html><body>';
1127f3f0262cSandi
1128f3f0262cSandi  print '<p>When reporting bugs please send all the following ';
1129f3f0262cSandi  print 'output as a mail to andi@splitbrain.org ';
1130f3f0262cSandi  print 'The best way to do this is to save this page in your browser</p>';
1131f3f0262cSandi
1132f3f0262cSandi  print '<b>$_SERVER:</b><pre>';
1133f3f0262cSandi  print_r($_SERVER);
1134f3f0262cSandi  print '</pre>';
1135f3f0262cSandi
1136f3f0262cSandi  print '<b>$conf:</b><pre>';
113728fb55ffSandi  print_r($cnf);
1138f3f0262cSandi  print '</pre>';
1139f3f0262cSandi
1140ed7b5f09Sandi  print '<b>DOKU_BASE:</b><pre>';
1141ed7b5f09Sandi  print DOKU_BASE;
1142f3f0262cSandi  print '</pre>';
1143f3f0262cSandi
1144ed7b5f09Sandi  print '<b>abs DOKU_BASE:</b><pre>';
1145ed7b5f09Sandi  print DOKU_URL;
1146ed7b5f09Sandi  print '</pre>';
1147ed7b5f09Sandi
1148ed7b5f09Sandi  print '<b>rel DOKU_BASE:</b><pre>';
1149f3f0262cSandi  print dirname($_SERVER['PHP_SELF']).'/';
1150f3f0262cSandi  print '</pre>';
1151f3f0262cSandi
1152f3f0262cSandi  print '<b>PHP Version:</b><pre>';
1153f3f0262cSandi  print phpversion();
1154f3f0262cSandi  print '</pre>';
1155f3f0262cSandi
1156f3f0262cSandi  print '<b>locale:</b><pre>';
1157f3f0262cSandi  print setlocale(LC_ALL,0);
1158f3f0262cSandi  print '</pre>';
1159f3f0262cSandi
1160d16a4edaSandi  print '<b>encoding:</b><pre>';
1161d16a4edaSandi  print $lang['encoding'];
1162d16a4edaSandi  print '</pre>';
1163d16a4edaSandi
11645298a619SAndreas Gohr  if($auth){
11655298a619SAndreas Gohr    print '<b>Auth backend capabilities:</b><pre>';
11665298a619SAndreas Gohr    print_r($auth->cando);
11675298a619SAndreas Gohr    print '</pre>';
11685298a619SAndreas Gohr  }
11695298a619SAndreas Gohr
11703aa54d7cSAndreas Gohr  print '<b>$_SESSION:</b><pre>';
11713aa54d7cSAndreas Gohr  print_r($_SESSION);
11723aa54d7cSAndreas Gohr  print '</pre>';
11733aa54d7cSAndreas Gohr
1174f3f0262cSandi  print '<b>Environment:</b><pre>';
1175f3f0262cSandi  print_r($_ENV);
1176f3f0262cSandi  print '</pre>';
1177f3f0262cSandi
1178f3f0262cSandi  print '<b>PHP settings:</b><pre>';
1179f3f0262cSandi  $inis = ini_get_all();
1180f3f0262cSandi  print_r($inis);
1181f3f0262cSandi  print '</pre>';
1182f3f0262cSandi
1183f3f0262cSandi  print '</body></html>';
1184f3f0262cSandi}
1185f3f0262cSandi
1186c19fe9c0Sandifunction html_admin(){
1187c19fe9c0Sandi  global $ID;
1188c19fe9c0Sandi  global $lang;
1189ca3a6df1SMatthias Grimm  global $conf;
1190c19fe9c0Sandi
1191c112d578Sandi  print p_locale_xhtml('admin');
1192c19fe9c0Sandi
119311e2ce22Schris  // build menu of admin functions from the plugins that handle them
119411e2ce22Schris  $pluginlist = plugin_list('admin');
119511e2ce22Schris  $menu = array();
119611e2ce22Schris  foreach ($pluginlist as $p) {
119711e2ce22Schris    if($obj =& plugin_load('admin',$p) === NULL) continue;
119811e2ce22Schris    $menu[] = array('plugin' => $p,
119911e2ce22Schris                    'prompt' => $obj->getMenuText($conf['lang']),
120011e2ce22Schris                    'sort' => $obj->getMenuSort()
120111e2ce22Schris                   );
120211e2ce22Schris  }
120311e2ce22Schris
120411e2ce22Schris  usort($menu, p_sort_modes);
120511e2ce22Schris
120611e2ce22Schris  // output the menu
120711e2ce22Schris  ptln('<ul>');
120811e2ce22Schris
120911e2ce22Schris  foreach ($menu as $item) {
121011e2ce22Schris    if (!$item['prompt']) continue;
12110c6b58a8SAndreas Gohr    ptln('  <li><div class="li"><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>');
121211e2ce22Schris  }
121311e2ce22Schris
121411e2ce22Schris  ptln('</ul>');
1215ca3a6df1SMatthias Grimm}
1216c19fe9c0Sandi
12178b06d178Schris/**
12188b06d178Schris * Form to request a new password for an existing account
12198b06d178Schris *
12208b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info>
122111e2ce22Schris */
12228b06d178Schrisfunction html_resendpwd() {
12238b06d178Schris  global $lang;
12248b06d178Schris  global $conf;
12258b06d178Schris  global $ID;
1226c19fe9c0Sandi
12278b06d178Schris  print p_locale_xhtml('resendpwd');
12288b06d178Schris?>
122996331712SAnika Henke  <div class="centeralign">
12301dd0c202SAnika Henke  <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post">
12318b06d178Schris    <fieldset>
12328b06d178Schris      <br />
1233753d5abfSMatthias Grimm      <legend><?php echo $lang['resendpwd']?></legend>
12348b06d178Schris      <input type="hidden" name="do" value="resendpwd" />
12358b06d178Schris      <input type="hidden" name="save" value="1" />
12368b06d178Schris      <label class="block">
12378b06d178Schris        <span><?php echo $lang['user']?></span>
12388b06d178Schris        <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br />
12398b06d178Schris      </label><br />
12408b06d178Schris      <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" />
12418b06d178Schris    </fieldset>
12428b06d178Schris  </form>
12438b06d178Schris  </div>
12448b06d178Schris<?php
12458b06d178Schris}
1246340756e4Sandi
1247340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 :
1248