xref: /dokuwiki/inc/html.php (revision 4beabca98b78dc832f53bb31d96a2afe55bc0303)
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  require_once(DOKU_INC.'inc/parser/xhtml.php');
20723d78dbSandi  static $xhtml_renderer = NULL;
21723d78dbSandi  if(is_null($xhtml_renderer)){
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;
50f3f0262cSandi
51c112d578Sandi  print p_locale_xhtml('login');
52f3f0262cSandi  ?>
53f3f0262cSandi    <div align="center">
544da078a3Smatthiasgrimm    <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" method="post">
55f3f0262cSandi      <fieldset>
564da078a3Smatthiasgrimm        <legend><?php echo $lang['btn_login']?></legend>
574da078a3Smatthiasgrimm        <input type="hidden" name="id" value="<?php echo $ID?>" />
58f3f0262cSandi        <input type="hidden" name="do" value="login" />
59b6912aeaSAndreas Gohr        <label class="block">
604da078a3Smatthiasgrimm          <span><?php echo $lang['user']?></span>
614da078a3Smatthiasgrimm          <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" />
62f3f0262cSandi        </label><br />
63b6912aeaSAndreas Gohr        <label class="block">
644da078a3Smatthiasgrimm          <span><?php echo $lang['pass']?></span>
65f3f0262cSandi          <input type="password" name="p" class="edit" />
66f3f0262cSandi        </label><br />
674da078a3Smatthiasgrimm        <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" />
68132bdbfeSandi        <label for="remember" class="simple">
69132bdbfeSandi          <input type="checkbox" name="r" id="remember" value="1" />
704da078a3Smatthiasgrimm          <span><?php echo $lang['remember']?></span>
71132bdbfeSandi        </label>
72f3f0262cSandi      </fieldset>
73f3f0262cSandi    </form>
744da078a3Smatthiasgrimm  <?php
75f3f0262cSandi    if($conf['openregister']){
76f3f0262cSandi      print '<p>';
77f3f0262cSandi      print $lang['reghere'];
78f3f0262cSandi      print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>';
79f3f0262cSandi      print '</p>';
80f3f0262cSandi    }
818b06d178Schris
82753d5abfSMatthias Grimm    if (auth_canDo('modifyUser')) {
838b06d178Schris      print '<p>';
848b06d178Schris      print $lang['pwdforget'];
85753d5abfSMatthias Grimm      print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['btn_resendpwd'].'</a>';
868b06d178Schris      print '</p>';
878b06d178Schris    }
88f3f0262cSandi  ?>
89f3f0262cSandi    </div>
904da078a3Smatthiasgrimm  <?php
916bbae538Sandi/*
926bbae538Sandi FIXME provide new hook
93f3f0262cSandi  if(@file_exists('includes/login.txt')){
94f3f0262cSandi    print io_cacheParse('includes/login.txt');
95f3f0262cSandi  }
966bbae538Sandi*/
97f3f0262cSandi}
98f3f0262cSandi
99f3f0262cSandi/**
100f3f0262cSandi * shows the edit/source/show button dependent on current mode
10115fae107Sandi *
10215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
103f3f0262cSandi */
104f3f0262cSandifunction html_editbutton(){
105f3f0262cSandi  global $ID;
106f3f0262cSandi  global $REV;
107f3f0262cSandi  global $ACT;
108f3f0262cSandi  global $INFO;
109f3f0262cSandi
110f3f0262cSandi  if($ACT == 'show' || $ACT == 'search'){
111f3f0262cSandi    if($INFO['writable']){
112f3f0262cSandi      if($INFO['exists']){
113f3f0262cSandi        $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
114f3f0262cSandi      }else{
115f3f0262cSandi        $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
116f3f0262cSandi      }
117f3f0262cSandi    }else{
118f3f0262cSandi      $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post');
119f3f0262cSandi    }
120f3f0262cSandi  }else{
121f3f0262cSandi    $r = html_btn('show',$ID,'v',array('do' => 'show'));
122f3f0262cSandi  }
123f3f0262cSandi  return $r;
124f3f0262cSandi}
125f3f0262cSandi
12615fae107Sandi/**
12715fae107Sandi * prints a section editing button
12815fae107Sandi *
12915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
13015fae107Sandi */
131f3f0262cSandifunction html_secedit_button($section,$p){
132f3f0262cSandi  global $ID;
133f3f0262cSandi  global $lang;
134f3f0262cSandi  $secedit  = '';
135506ae684Sandi#  if($p) $secedit .= "</p>\n";
136f3f0262cSandi  $secedit .= '<div class="secedit">';
137f3f0262cSandi  $secedit .= html_btn('secedit',$ID,'',
138f3f0262cSandi                        array('do'      => 'edit',
139f3f0262cSandi                              'lines'   => "$section"),
140f3f0262cSandi                              'post');
141f3f0262cSandi  $secedit .= '</div>';
142506ae684Sandi#  if($p) $secedit .= "\n<p>";
143f3f0262cSandi  return $secedit;
144f3f0262cSandi}
145f3f0262cSandi
14615fae107Sandi/**
14715fae107Sandi * inserts section edit buttons if wanted or removes the markers
14815fae107Sandi *
14915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
15015fae107Sandi */
151f3f0262cSandifunction html_secedit($text,$show=true){
152f3f0262cSandi  global $INFO;
153c112d578Sandi  if($INFO['writable'] && $show && !$INFO['rev']){
154f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e',
155f3f0262cSandi                         "html_secedit_button('\\1',true)",
156f3f0262cSandi                         $text);
157f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e',
158f3f0262cSandi                         "html_secedit_button('\\1',false)",
159f3f0262cSandi                         $text);
160f3f0262cSandi  }else{
161f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text);
162f3f0262cSandi  }
163f3f0262cSandi  return $text;
164f3f0262cSandi}
165f3f0262cSandi
166f3f0262cSandi/**
167d6c9c552Smatthiasgrimm * Just the back to top button (in its own form)
1686b13307fSandi *
1696b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
1706b13307fSandi */
1716b13307fSandifunction html_topbtn(){
1726b13307fSandi  global $lang;
1736b13307fSandi
1746b13307fSandi  $ret  = '';
175265e3787Sandi  $ret  = '<a href="#top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>';
176df7b6005Sandi
1776b13307fSandi  return $ret;
1786b13307fSandi}
1796b13307fSandi
1806b13307fSandi/**
181d67ca2c0Smatthiasgrimm * Just the back to media window button in its own form
182d67ca2c0Smatthiasgrimm *
183d67ca2c0Smatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
184d67ca2c0Smatthiasgrimm */
185d67ca2c0Smatthiasgrimmfunction html_backtomedia_button($params,$akey=''){
186d67ca2c0Smatthiasgrimm  global $conf;
187d67ca2c0Smatthiasgrimm  global $lang;
188d67ca2c0Smatthiasgrimm
189*4beabca9SAnika Henke  $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php"><div class="no">';
190d67ca2c0Smatthiasgrimm
191d67ca2c0Smatthiasgrimm  reset($params);
192d67ca2c0Smatthiasgrimm  while (list($key, $val) = each($params)) {
193d67ca2c0Smatthiasgrimm    $ret .= '<input type="hidden" name="'.$key.'" ';
194d67ca2c0Smatthiasgrimm    $ret .= 'value="'.htmlspecialchars($val).'" />';
195d67ca2c0Smatthiasgrimm  }
196d67ca2c0Smatthiasgrimm
197d67ca2c0Smatthiasgrimm  $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" ';
198d67ca2c0Smatthiasgrimm  if($akey){
199d67ca2c0Smatthiasgrimm    $ret .= 'title="ALT+'.strtoupper($akey).'" ';
200d67ca2c0Smatthiasgrimm    $ret .= 'accesskey="'.$akey.'" ';
201d67ca2c0Smatthiasgrimm  }
202d67ca2c0Smatthiasgrimm  $ret .= '/>';
203*4beabca9SAnika Henke  $ret .= '</div></form>';
204d67ca2c0Smatthiasgrimm
205d67ca2c0Smatthiasgrimm  return $ret;
206d67ca2c0Smatthiasgrimm}
207d67ca2c0Smatthiasgrimm
208d67ca2c0Smatthiasgrimm/**
209d67ca2c0Smatthiasgrimm * Displays a button (using its own form)
21015fae107Sandi *
21115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
212f3f0262cSandi */
213f3f0262cSandifunction html_btn($name,$id,$akey,$params,$method='get'){
214f3f0262cSandi  global $conf;
215f3f0262cSandi  global $lang;
216f3f0262cSandi
217f3f0262cSandi  $label = $lang['btn_'.$name];
218f3f0262cSandi
219f3f0262cSandi  $ret = '';
220f3f0262cSandi
22149c713a3Sandi  //filter id (without urlencoding)
22249c713a3Sandi  $id = idfilter($id,false);
223f3f0262cSandi
224f3f0262cSandi  //make nice URLs even for buttons
2256c7843b5Sandi  if($conf['userewrite'] == 2){
2266c7843b5Sandi    $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
2276c7843b5Sandi  }elseif($conf['userewrite']){
2286c7843b5Sandi    $script = DOKU_BASE.$id;
2296c7843b5Sandi  }else{
2308b00ebcfSandi    $script = DOKU_BASE.DOKU_SCRIPT;
231f3f0262cSandi    $params['id'] = $id;
232f3f0262cSandi  }
233f3f0262cSandi
234*4beabca9SAnika Henke  $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">';
235f3f0262cSandi
236f3f0262cSandi  reset($params);
237f3f0262cSandi  while (list($key, $val) = each($params)) {
238f3f0262cSandi    $ret .= '<input type="hidden" name="'.$key.'" ';
239f3f0262cSandi    $ret .= 'value="'.htmlspecialchars($val).'" />';
240f3f0262cSandi  }
241f3f0262cSandi
242f3f0262cSandi  $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
243f3f0262cSandi  if($akey){
244f3f0262cSandi    $ret .= 'title="ALT+'.strtoupper($akey).'" ';
245f3f0262cSandi    $ret .= 'accesskey="'.$akey.'" ';
246f3f0262cSandi  }
247f3f0262cSandi  $ret .= '/>';
248*4beabca9SAnika Henke  $ret .= '</div></form>';
249f3f0262cSandi
250f3f0262cSandi  return $ret;
251f3f0262cSandi}
252f3f0262cSandi
253f3f0262cSandi/**
25415fae107Sandi * show a wiki page
25515fae107Sandi *
25615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
25715fae107Sandi */
2586bbae538Sandifunction html_show($txt=''){
259f3f0262cSandi  global $ID;
260f3f0262cSandi  global $REV;
261f3f0262cSandi  global $HIGH;
262f3f0262cSandi  //disable section editing for old revisions or in preview
2635400331dSandi  if($txt || $REV){
2646bbae538Sandi    $secedit = false;
2656bbae538Sandi  }else{
2666bbae538Sandi    $secedit = true;
267f3f0262cSandi  }
268f3f0262cSandi
2696bbae538Sandi  if ($txt){
270f3f0262cSandi    //PreviewHeader
271c112d578Sandi    print p_locale_xhtml('preview');
272f3f0262cSandi    print '<div class="preview">';
2739dc2c2afSandi    print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
274f3f0262cSandi    print '</div>';
2756bbae538Sandi
276f3f0262cSandi  }else{
277c112d578Sandi    if ($REV) print p_locale_xhtml('showrev');
278c112d578Sandi    $html = p_wiki_xhtml($ID,$REV,true);
2796bbae538Sandi    $html = html_secedit($html,$secedit);
280f3f0262cSandi    print html_hilight($html,$HIGH);
281f3f0262cSandi  }
282f3f0262cSandi}
283f3f0262cSandi
284f3f0262cSandi/**
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])) {
3087209be23SAndreas Gohr    $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
3294d9ff3d5Sandi  //show progressbar
330*4beabca9SAnika Henke  print '<div class="centeralign">';
331*4beabca9SAnika Henke  print '<script type="text/javascript" charset="utf-8">';
3324d9ff3d5Sandi  print 'showLoadBar();';
3334d9ff3d5Sandi  print '</script>';
3344d9ff3d5Sandi  print '<br /></div>';
3354d9ff3d5Sandi
336f3f0262cSandi  //do quick pagesearch
337f3f0262cSandi  $data = array();
338506fa893SAndreas Gohr  $data = ft_pageLookup(cleanID($QUERY));
339f3f0262cSandi  if(count($data)){
340f3f0262cSandi    sort($data);
341f3f0262cSandi    print '<div class="search_quickresult">';
342f3f0262cSandi    print '<b>'.$lang[quickhits].':</b><br />';
343506fa893SAndreas Gohr    foreach($data as $id){
344f3f0262cSandi      print '<div class="search_quickhits">';
345506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id);
346f3f0262cSandi      print '</div> ';
347f3f0262cSandi    }
348f3f0262cSandi    //clear float (see http://www.complexspiral.com/publications/containing-floats/)
349f3f0262cSandi    print '<div class="clearer">&nbsp;</div>';
350f3f0262cSandi    print '</div>';
351f3f0262cSandi  }
352f3f0262cSandi  flush();
353f3f0262cSandi
354f3f0262cSandi  //do fulltext search
355506fa893SAndreas Gohr  $data = ft_pageSearch($QUERY,$poswords);
356f3f0262cSandi  if(count($data)){
357506fa893SAndreas Gohr    $num = 1;
358506fa893SAndreas Gohr    foreach($data as $id => $cnt){
359f3f0262cSandi      print '<div class="search_result">';
360506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords);
361506fa893SAndreas Gohr      print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
362506fa893SAndreas Gohr      if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
363506fa893SAndreas Gohr        print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>';
364506fa893SAndreas Gohr      }
365f3f0262cSandi      print '</div>';
366506fa893SAndreas Gohr      flush();
367506fa893SAndreas Gohr      $num++;
368f3f0262cSandi    }
369f3f0262cSandi  }else{
370820fa24bSandi    print '<div class="nothing">'.$lang['nothingfound'].'</div>';
371f3f0262cSandi  }
3724d9ff3d5Sandi
3734d9ff3d5Sandi  //hide progressbar
374*4beabca9SAnika Henke  print '<script type="text/javascript" charset="utf-8">';
3754d9ff3d5Sandi  print 'hideLoadBar();';
3764d9ff3d5Sandi  print '</script>';
377f3f0262cSandi}
378f3f0262cSandi
37915fae107Sandi/**
38015fae107Sandi * Display error on locked pages
38115fae107Sandi *
38215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
38315fae107Sandi */
384ee20e7d1Sandifunction html_locked(){
385f3f0262cSandi  global $ID;
386f3f0262cSandi  global $conf;
387f3f0262cSandi  global $lang;
38888f522e9Sandi  global $INFO;
389f3f0262cSandi
390f3f0262cSandi  $locktime = filemtime(wikiFN($ID).'.lock');
391f3f0262cSandi  $expire = @date($conf['dformat'], $locktime + $conf['locktime'] );
392f3f0262cSandi  $min    = round(($conf['locktime'] - (time() - $locktime) )/60);
393f3f0262cSandi
394c112d578Sandi  print p_locale_xhtml('locked');
395f3f0262cSandi  print '<ul>';
39688f522e9Sandi  print '<li><b>'.$lang['lockedby'].':</b> '.$INFO['locked'].'</li>';
397f3f0262cSandi  print '<li><b>'.$lang['lockexpire'].':</b> '.$expire.' ('.$min.' min)</li>';
398f3f0262cSandi  print '</ul>';
399f3f0262cSandi}
400f3f0262cSandi
40115fae107Sandi/**
40215fae107Sandi * list old revisions
40315fae107Sandi *
40415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
40515fae107Sandi */
406f3f0262cSandifunction html_revisions(){
407f3f0262cSandi  global $ID;
408f3f0262cSandi  global $INFO;
409f3f0262cSandi  global $conf;
410f3f0262cSandi  global $lang;
411f3f0262cSandi  $revisions = getRevisions($ID);
412f3f0262cSandi  $date = @date($conf['dformat'],$INFO['lastmod']);
413f3f0262cSandi
414c112d578Sandi  print p_locale_xhtml('revisions');
415f3f0262cSandi  print '<ul>';
416f3f0262cSandi  if($INFO['exists']){
417b6912aeaSAndreas Gohr    print ($INFO['minor']) ? '<li class="minor">' : '<li>';
418f9b2fe70Sandi
419f9b2fe70Sandi    print $date;
420f9b2fe70Sandi
421f62ea8a1Sandi    print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" border="0" width="15" height="11" alt="" /> ';
422cffcc403Sandi
423f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ';
424652610a2Sandi
425652610a2Sandi    print $INFO['sum'];
42688f522e9Sandi    print ' <span class="user">';
42788f522e9Sandi    print $INFO['editor'];
42888f522e9Sandi    print '</span> ';
429652610a2Sandi
430652610a2Sandi    print '('.$lang['current'].')';
431652610a2Sandi    print '</li>';
432f3f0262cSandi  }
433f3f0262cSandi
434f3f0262cSandi  foreach($revisions as $rev){
435f3f0262cSandi    $date = date($conf['dformat'],$rev);
436652610a2Sandi    $info = getRevisionInfo($ID,$rev);
437652610a2Sandi
438b6912aeaSAndreas Gohr    print ($info['minor']) ? '<li class="minor">' : '<li>';
439f9b2fe70Sandi    print $date;
440f9b2fe70Sandi
441cffcc403Sandi    print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
442d94f4568SAndreas Gohr    $p = array();
443d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
444d94f4568SAndreas Gohr    $p['border'] = 0;
445d94f4568SAndreas Gohr    $p['width']  = 15;
446d94f4568SAndreas Gohr    $p['height'] = 11;
447d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
448d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
449d94f4568SAndreas Gohr    $att = buildAttributes($p);
450d94f4568SAndreas Gohr    print "<img $att />";
451cffcc403Sandi    print '</a> ';
452cffcc403Sandi
453f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> ';
454f9b2fe70Sandi
455f243a77fSandi    print htmlspecialchars($info['sum']);
45688f522e9Sandi    print ' <span class="user">';
45788f522e9Sandi    if($info['user']){
45888f522e9Sandi      print $info['user'];
45988f522e9Sandi    }else{
460652610a2Sandi      print $info['ip'];
46188f522e9Sandi    }
46288f522e9Sandi    print '</span>';
463652610a2Sandi
464f3f0262cSandi    print '</li>';
465f3f0262cSandi  }
466f3f0262cSandi  print '</ul>';
467f3f0262cSandi}
468f3f0262cSandi
46915fae107Sandi/**
47015fae107Sandi * display recent changes
47115fae107Sandi *
47215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
4735749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
47415fae107Sandi */
475a39955b0Smatthiasgrimmfunction html_recent($first=0){
476f3f0262cSandi  global $conf;
477cffcc403Sandi  global $lang;
478dbb00abcSEsther Brunner  global $ID;
4795749f1ceSmatthiasgrimm  /* we need to get one additionally log entry to be able to
4805749f1ceSmatthiasgrimm   * decide if this is the last page or is there another one.
4815749f1ceSmatthiasgrimm   * This is the cheapest solution to get this information.
4825749f1ceSmatthiasgrimm   */
483b6912aeaSAndreas Gohr  $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
4845749f1ceSmatthiasgrimm  if(count($recents) == 0 && $first != 0){
4855749f1ceSmatthiasgrimm    $first=0;
486b6912aeaSAndreas Gohr    $recents = getRecents(0,$conf['recent'] + 1,getNS($ID));
4875749f1ceSmatthiasgrimm  }
4885749f1ceSmatthiasgrimm  $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
489f3f0262cSandi
490c112d578Sandi  print p_locale_xhtml('recent');
491f3f0262cSandi  print '<ul>';
492a39955b0Smatthiasgrimm
493d437bcc4SAndreas Gohr  foreach($recents as $recent){
494d437bcc4SAndreas Gohr    $date = date($conf['dformat'],$recent['date']);
495b6912aeaSAndreas Gohr    print ($recent['minor']) ? '<li class="minor">' : '<li>';
496cffcc403Sandi
497f9b2fe70Sandi    print $date.' ';
498f9b2fe70Sandi
499d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=diff").'">';
500d94f4568SAndreas Gohr    $p = array();
501d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
502d94f4568SAndreas Gohr    $p['border'] = 0;
503d94f4568SAndreas Gohr    $p['width']  = 15;
504d94f4568SAndreas Gohr    $p['height'] = 11;
505d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
506d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
507d94f4568SAndreas Gohr    $att = buildAttributes($p);
508d94f4568SAndreas Gohr    print "<img $att />";
509cffcc403Sandi    print '</a> ';
510cffcc403Sandi
511d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=revisions").'">';
512d94f4568SAndreas Gohr    $p = array();
513d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/history.png';
514d94f4568SAndreas Gohr    $p['border'] = 0;
515d94f4568SAndreas Gohr    $p['width']  = 12;
516d94f4568SAndreas Gohr    $p['height'] = 14;
517d94f4568SAndreas Gohr    $p['title']  = $lang['btn_revs'];
518d94f4568SAndreas Gohr    $p['alt']    = $lang['btn_revs'];
519d94f4568SAndreas Gohr    $att = buildAttributes($p);
520d94f4568SAndreas Gohr    print "<img $att />";
521cffcc403Sandi    print '</a> ';
522cffcc403Sandi
523d437bcc4SAndreas Gohr    print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
524d437bcc4SAndreas Gohr    print ' '.htmlspecialchars($recent['sum']);
525b6912aeaSAndreas Gohr
52688f522e9Sandi    print ' <span class="user">';
527d437bcc4SAndreas Gohr    if($recent['user']){
528d437bcc4SAndreas Gohr      print $recent['user'];
52988f522e9Sandi    }else{
530d437bcc4SAndreas Gohr      print $recent['ip'];
53188f522e9Sandi    }
53288f522e9Sandi    print '</span>';
533cffcc403Sandi
534f3f0262cSandi    print '</li>';
535f3f0262cSandi  }
536f3f0262cSandi  print '</ul>';
537a39955b0Smatthiasgrimm
538a39955b0Smatthiasgrimm  print '<div class="pagenav">';
5395749f1ceSmatthiasgrimm  $last = $first + $conf['recent'];
540a39955b0Smatthiasgrimm  if ($first > 0) {
541a39955b0Smatthiasgrimm    $first -= $conf['recent'];
542a39955b0Smatthiasgrimm    if ($first < 0) $first = 0;
543a39955b0Smatthiasgrimm    print '<div class="pagenav-prev">';
5445749f1ceSmatthiasgrimm    print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
545a39955b0Smatthiasgrimm    print '</div>';
546a39955b0Smatthiasgrimm  }
5475749f1ceSmatthiasgrimm  if ($conf['recent'] < count($recents)) {
548a39955b0Smatthiasgrimm    print '<div class="pagenav-next">';
5495749f1ceSmatthiasgrimm    print html_btn('older','',"n",array('do' => 'recent', 'first' => $last));
550a39955b0Smatthiasgrimm    print '</div>';
551a39955b0Smatthiasgrimm  }
552a39955b0Smatthiasgrimm  print '</div>';
553f3f0262cSandi}
554f3f0262cSandi
55515fae107Sandi/**
55615fae107Sandi * Display page index
55715fae107Sandi *
55815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
55915fae107Sandi */
560f3f0262cSandifunction html_index($ns){
561ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
562f3f0262cSandi  global $conf;
563f3f0262cSandi  global $ID;
564f3f0262cSandi  $dir = $conf['datadir'];
565f3f0262cSandi  $ns  = cleanID($ns);
56630f1737dSandi  #fixme use appropriate function
567f3f0262cSandi  if(empty($ns)){
568f3f0262cSandi    $ns = dirname(str_replace(':','/',$ID));
569f3f0262cSandi    if($ns == '.') $ns ='';
570f3f0262cSandi  }
57188d3a917Sandi  $ns  = utf8_encodeFN(str_replace(':','/',$ns));
572f3f0262cSandi
573c112d578Sandi  print p_locale_xhtml('index');
574f3f0262cSandi
575f3f0262cSandi  $data = array();
576f3f0262cSandi  search($data,$conf['datadir'],'search_index',array('ns' => $ns));
577cb70c441Sandi  print html_buildlist($data,'idx','html_list_index','html_li_index');
578f3f0262cSandi}
579f3f0262cSandi
580f3f0262cSandi/**
58115fae107Sandi * Index item formatter
58215fae107Sandi *
583f3f0262cSandi * User function for html_buildlist()
58415fae107Sandi *
58515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
586f3f0262cSandi */
587f3f0262cSandifunction html_list_index($item){
588f3f0262cSandi  $ret = '';
589f3f0262cSandi  $base = ':'.$item['id'];
590f3f0262cSandi  $base = substr($base,strrpos($base,':')+1);
591f3f0262cSandi  if($item['type']=='d'){
592f3f0262cSandi    $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">';
593f3f0262cSandi    $ret .= $base;
594f3f0262cSandi    $ret .= '</a>';
595f3f0262cSandi  }else{
596f3f0262cSandi    $ret .= html_wikilink(':'.$item['id']);
597f3f0262cSandi  }
598f3f0262cSandi  return $ret;
599f3f0262cSandi}
600f3f0262cSandi
601f3f0262cSandi/**
602cb70c441Sandi * Index List item
603cb70c441Sandi *
604cb70c441Sandi * This user function is used in html_build_lidt to build the
605cb70c441Sandi * <li> tags for namespaces when displaying the page index
606cb70c441Sandi * it gives different classes to opened or closed "folders"
607cb70c441Sandi *
608cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
609cb70c441Sandi */
610cb70c441Sandifunction html_li_index($item){
611cb70c441Sandi  if($item['type'] == "f"){
612cb70c441Sandi    return '<li class="level'.$item['level'].'">';
613cb70c441Sandi  }elseif($item['open']){
614cb70c441Sandi    return '<li class="open">';
615cb70c441Sandi  }else{
616cb70c441Sandi    return '<li class="closed">';
617cb70c441Sandi  }
618cb70c441Sandi}
619cb70c441Sandi
620cb70c441Sandi/**
621cb70c441Sandi * Default List item
622cb70c441Sandi *
623cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
624cb70c441Sandi */
625cb70c441Sandifunction html_li_default($item){
626cb70c441Sandi  return '<li class="level'.$item['level'].'">';
627cb70c441Sandi}
628cb70c441Sandi
629cb70c441Sandi/**
63015fae107Sandi * Build an unordered list
63115fae107Sandi *
632f3f0262cSandi * Build an unordered list from the given $data array
633f3f0262cSandi * Each item in the array has to have a 'level' property
634f3f0262cSandi * the item itself gets printed by the given $func user
635cb70c441Sandi * function. The second and optional function is used to
636cb70c441Sandi * print the <li> tag. Both user function need to accept
637cb70c441Sandi * a single item.
63815fae107Sandi *
63915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
640f3f0262cSandi */
641cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){
642f3f0262cSandi  $level = 0;
643f3f0262cSandi  $opens = 0;
644f3f0262cSandi  $ret   = '';
645f3f0262cSandi
646f3f0262cSandi  foreach ($data as $item){
647f3f0262cSandi
648f3f0262cSandi    if( $item['level'] > $level ){
649f3f0262cSandi      //open new list
650df52d0feSandi      for($i=0; $i<($item['level'] - $level); $i++){
651df52d0feSandi        if ($i) $ret .= "<li class=\"clear\">\n";
652f3f0262cSandi        $ret .= "\n<ul class=\"$class\">\n";
653df52d0feSandi      }
654f3f0262cSandi    }elseif( $item['level'] < $level ){
655f3f0262cSandi      //close last item
656f3f0262cSandi      $ret .= "</li>\n";
657f3f0262cSandi      for ($i=0; $i<($level - $item['level']); $i++){
658f3f0262cSandi        //close higher lists
659f3f0262cSandi        $ret .= "</ul>\n</li>\n";
660f3f0262cSandi      }
661f3f0262cSandi    }else{
662f3f0262cSandi      //close last item
663f3f0262cSandi      $ret .= "</li>\n";
664f3f0262cSandi    }
665f3f0262cSandi
666f3f0262cSandi    //remember current level
667f3f0262cSandi    $level = $item['level'];
668f3f0262cSandi
669f3f0262cSandi    //print item
670cb70c441Sandi    $ret .= $lifunc($item); //user function
671f3f0262cSandi    $ret .= '<span class="li">';
672f3f0262cSandi    $ret .= $func($item); //user function
673f3f0262cSandi    $ret .= '</span>';
674f3f0262cSandi  }
675f3f0262cSandi
676f3f0262cSandi  //close remaining items and lists
677f3f0262cSandi  for ($i=0; $i < $level; $i++){
678f3f0262cSandi    $ret .= "</li></ul>\n";
679f3f0262cSandi  }
680f3f0262cSandi
681f3f0262cSandi  return $ret;
682f3f0262cSandi}
683f3f0262cSandi
68415fae107Sandi/**
68515fae107Sandi * display backlinks
68615fae107Sandi *
68715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
68815fae107Sandi */
689f3f0262cSandifunction html_backlinks(){
69054f4c056SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
691f3f0262cSandi  global $ID;
692f3f0262cSandi  global $conf;
693f3f0262cSandi
694c112d578Sandi  print p_locale_xhtml('backlinks');
695f3f0262cSandi
69654f4c056SAndreas Gohr  $data = ft_backlinks($ID);
697f3f0262cSandi
698f3f0262cSandi  print '<ul class="idx">';
69954f4c056SAndreas Gohr  foreach($data as $blink){
700f3f0262cSandi    print '<li>';
70154f4c056SAndreas Gohr    print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink);
702f3f0262cSandi    print '</li>';
703f3f0262cSandi  }
704f3f0262cSandi  print '</ul>';
705f3f0262cSandi}
706f3f0262cSandi
70715fae107Sandi/**
70815fae107Sandi * show diff
70915fae107Sandi *
71015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
71115fae107Sandi */
712f3f0262cSandifunction html_diff($text='',$intro=true){
713ed7b5f09Sandi  require_once(DOKU_INC.'inc/DifferenceEngine.php');
714f3f0262cSandi  global $ID;
715f3f0262cSandi  global $REV;
716f3f0262cSandi  global $lang;
717f3f0262cSandi  global $conf;
718f3f0262cSandi  if($text){
719f3f0262cSandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))),
720f3f0262cSandi                    split("\n",htmlspecialchars(cleanText($text))));
721f3f0262cSandi    $left  = '<a class="wikilink1" href="'.wl($ID).'">'.
722f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'.
723f3f0262cSandi              $lang['current'];
724f3f0262cSandi    $right = $lang['yours'];
725f3f0262cSandi  }else{
7264d58bd99Sandi    if($REV){
7274d58bd99Sandi      $r = $REV;
7284d58bd99Sandi    }else{
7294d58bd99Sandi      //use last revision if none given
7304d58bd99Sandi      $revs = getRevisions($ID);
7314d58bd99Sandi      $r = $revs[0];
7324d58bd99Sandi    }
7334d58bd99Sandi
7344d58bd99Sandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))),
735f3f0262cSandi                    split("\n",htmlspecialchars(rawWiki($ID,''))));
7364d58bd99Sandi    $left  = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'.
7374d58bd99Sandi              $ID.' '.date($conf['dformat'],$r).'</a>';
738f3f0262cSandi    $right = '<a class="wikilink1" href="'.wl($ID).'">'.
739f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '.
740f3f0262cSandi              $lang['current'];
741f3f0262cSandi  }
742f3f0262cSandi  $tdf = new TableDiffFormatter();
743c112d578Sandi  if($intro) print p_locale_xhtml('diff');
744f3f0262cSandi  ?>
745f3f0262cSandi    <table class="diff" width="100%">
746f3f0262cSandi      <tr>
747f3f0262cSandi        <td colspan="2" width="50%" class="diff-header">
7484da078a3Smatthiasgrimm          <?php echo $left?>
749f3f0262cSandi        </td>
750f3f0262cSandi        <td colspan="2" width="50%" class="diff-header">
7514da078a3Smatthiasgrimm          <?php echo $right?>
752f3f0262cSandi        </td>
753f3f0262cSandi      </tr>
7544da078a3Smatthiasgrimm      <?php echo $tdf->format($df)?>
755f3f0262cSandi    </table>
7564da078a3Smatthiasgrimm  <?php
757f3f0262cSandi}
758f3f0262cSandi
75915fae107Sandi/**
76015fae107Sandi * show warning on conflict detection
76115fae107Sandi *
76215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
76315fae107Sandi */
764f3f0262cSandifunction html_conflict($text,$summary){
765f3f0262cSandi  global $ID;
766f3f0262cSandi  global $lang;
767f3f0262cSandi
768c112d578Sandi  print p_locale_xhtml('conflict');
769f3f0262cSandi  ?>
7704da078a3Smatthiasgrimm  <form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
7714da078a3Smatthiasgrimm  <input type="hidden" name="id" value="<?php echo $ID?>" />
7724da078a3Smatthiasgrimm  <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" />
7734da078a3Smatthiasgrimm  <input type="hidden" name="summary" value="<?php echo formText($summary)?>" />
774f3f0262cSandi
775f3f0262cSandi  <div align="center">
7764da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" />
7774da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" />
778f3f0262cSandi  </div>
779f3f0262cSandi  </form>
780f3f0262cSandi  <br /><br /><br /><br />
7814da078a3Smatthiasgrimm  <?php
782f3f0262cSandi}
783f3f0262cSandi
784f3f0262cSandi/**
78515fae107Sandi * Prints the global message array
78615fae107Sandi *
78715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
788f3f0262cSandi */
789f3f0262cSandifunction html_msgarea(){
790f3f0262cSandi  global $MSG;
791f3f0262cSandi
792f3f0262cSandi  if(!isset($MSG)) return;
793f3f0262cSandi
794f3f0262cSandi  foreach($MSG as $msg){
795f3f0262cSandi    print '<div class="'.$msg['lvl'].'">';
796f3f0262cSandi    print $msg['msg'];
797f3f0262cSandi    print '</div>';
798f3f0262cSandi  }
799f3f0262cSandi}
800f3f0262cSandi
801f3f0262cSandi/**
802f3f0262cSandi * Prints the registration form
80315fae107Sandi *
80415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
805f3f0262cSandi */
806f3f0262cSandifunction html_register(){
807f3f0262cSandi  global $lang;
808cab2716aSmatthias.grimm  global $conf;
809f3f0262cSandi  global $ID;
810f3f0262cSandi
811c112d578Sandi  print p_locale_xhtml('register');
812f3f0262cSandi?>
813f3f0262cSandi  <div align="center">
8144da078a3Smatthiasgrimm  <form name="register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
815f3f0262cSandi  <input type="hidden" name="do" value="register" />
816f3f0262cSandi  <input type="hidden" name="save" value="1" />
817f3f0262cSandi  <fieldset>
8184da078a3Smatthiasgrimm    <legend><?php echo $lang['register']?></legend>
819b6912aeaSAndreas Gohr    <label class="block">
8204da078a3Smatthiasgrimm      <?php echo $lang['user']?>
8214da078a3Smatthiasgrimm      <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
822f3f0262cSandi    </label><br />
823cab2716aSmatthias.grimm
824cab2716aSmatthias.grimm    <?php
825cab2716aSmatthias.grimm      if (!$conf['autopasswd']) {
826cab2716aSmatthias.grimm    ?>
827b6912aeaSAndreas Gohr      <label class="block">
8284da078a3Smatthiasgrimm        <?php echo $lang['pass']?>
829cab2716aSmatthias.grimm        <input type="password" name="pass" class="edit" size="50" />
830cab2716aSmatthias.grimm      </label><br />
831b6912aeaSAndreas Gohr      <label class="block">
8324da078a3Smatthiasgrimm        <?php echo $lang['passchk']?>
833cab2716aSmatthias.grimm        <input type="password" name="passchk" class="edit" size="50" />
834cab2716aSmatthias.grimm      </label><br />
835cab2716aSmatthias.grimm    <?php
836cab2716aSmatthias.grimm      }
837cab2716aSmatthias.grimm    ?>
838cab2716aSmatthias.grimm
839b6912aeaSAndreas Gohr    <label class="block">
8404da078a3Smatthiasgrimm      <?php echo $lang['fullname']?>
8414da078a3Smatthiasgrimm      <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
842f3f0262cSandi    </label><br />
843b6912aeaSAndreas Gohr    <label class="block">
8444da078a3Smatthiasgrimm      <?php echo $lang['email']?>
8454da078a3Smatthiasgrimm      <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
846f3f0262cSandi    </label><br />
8474da078a3Smatthiasgrimm    <input type="submit" class="button" value="<?php echo $lang['register']?>" />
848f3f0262cSandi  </fieldset>
849f3f0262cSandi  </form>
850f3f0262cSandi  </div>
8514da078a3Smatthiasgrimm<?php
852f3f0262cSandi}
853f3f0262cSandi
854f3f0262cSandi/**
8558b06d178Schris * Print the update profile form
8568b06d178Schris *
8578b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk>
8588b06d178Schris * @author Andreas Gohr <andi@splitbrain.org>
8598b06d178Schris */
8608b06d178Schrisfunction html_updateprofile(){
8618b06d178Schris  global $lang;
8628b06d178Schris  global $conf;
8638b06d178Schris  global $ID;
8648b06d178Schris  global $INFO;
8658b06d178Schris
8668b06d178Schris  print p_locale_xhtml('updateprofile');
8678b06d178Schris
8688b06d178Schris  if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name'];
8698b06d178Schris  if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail'];
8708b06d178Schris?>
8718b06d178Schris  <div align="center">
8728b06d178Schris  <form name="register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
8738b06d178Schris  <input type="hidden" name="do" value="profile" />
8748b06d178Schris  <input type="hidden" name="save" value="1" />
8758b06d178Schris  <fieldset style="width: 80%;">
8768b06d178Schris    <legend><?php echo $lang['profile']?></legend>
8778b06d178Schris    <label class="block">
8788b06d178Schris      <?php echo $lang['user']?>
8798b06d178Schris      <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" />
8808b06d178Schris    </label><br />
8818b06d178Schris    <label class="block">
8828b06d178Schris      <?php echo $lang['fullname']?>
8838b06d178Schris      <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
8848b06d178Schris    </label><br />
8858b06d178Schris    <label class="block">
8868b06d178Schris      <?php echo $lang['email']?>
8878b06d178Schris      <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
8888b06d178Schris    </label><br /><br />
8898b06d178Schris    <label class="block">
8908b06d178Schris      <?php echo $lang['newpass']?>
8918b06d178Schris      <input type="password" name="newpass" class="edit" size="50" />
8928b06d178Schris    </label><br />
8938b06d178Schris    <label class="block">
8948b06d178Schris      <?php echo $lang['passchk']?>
8958b06d178Schris      <input type="password" name="passchk" class="edit" size="50" />
8968b06d178Schris    </label><br />
8978b06d178Schris
8988b06d178Schris    <?php if ($conf['profileconfirm']) { ?>
8998b06d178Schris      <br />
9008b06d178Schris      <label class="block">
9018b06d178Schris      <?php echo $lang['oldpass']?>
9028b06d178Schris      <input type="password" name="oldpass" class="edit" size="50" />
9038b06d178Schris    </label><br />
9048b06d178Schris    <?php } ?>
9058b06d178Schris
9064cb79657SMatthias Grimm    <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" />
9078b06d178Schris    <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" />
9088b06d178Schris  </fieldset>
9098b06d178Schris  </form>
9108b06d178Schris  </div>
9118b06d178Schris<?php
9128b06d178Schris}
9138b06d178Schris
9148b06d178Schris/**
915f3f0262cSandi * This displays the edit form (lots of logic included)
91615fae107Sandi *
9177146cee2SAndreas Gohr * @fixme  this is a huge lump of code and should be modularized
91815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
919f3f0262cSandi */
920f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed?
921f3f0262cSandi  global $ID;
922f3f0262cSandi  global $REV;
923f3f0262cSandi  global $DATE;
924f3f0262cSandi  global $RANGE;
925f3f0262cSandi  global $PRE;
926f3f0262cSandi  global $SUF;
927f3f0262cSandi  global $INFO;
928f3f0262cSandi  global $SUM;
929f3f0262cSandi  global $lang;
930f3f0262cSandi  global $conf;
931f3f0262cSandi
932f3f0262cSandi  //set summary default
933f3f0262cSandi  if(!$SUM){
934f3f0262cSandi    if($REV){
935f3f0262cSandi      $SUM = $lang['restored'];
936f3f0262cSandi    }elseif(!$INFO['exists']){
937f3f0262cSandi      $SUM = $lang['created'];
938f3f0262cSandi    }
939f3f0262cSandi  }
940f3f0262cSandi
941f3f0262cSandi  //no text? Load it!
942f3f0262cSandi  if(!isset($text)){
943f3f0262cSandi    $pr = false; //no preview mode
9447146cee2SAndreas Gohr    if($INFO['exists']){
945f3f0262cSandi      if($RANGE){
946f3f0262cSandi        list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
947f3f0262cSandi      }else{
948f3f0262cSandi        $text = rawWiki($ID,$REV);
949f3f0262cSandi      }
950f3f0262cSandi    }else{
9517146cee2SAndreas Gohr      //try to load a pagetemplate
9527146cee2SAndreas Gohr      $text = pageTemplate($ID);
9537146cee2SAndreas Gohr    }
9547146cee2SAndreas Gohr  }else{
955f3f0262cSandi    $pr = true; //preview mode
956f3f0262cSandi  }
957f3f0262cSandi
958f3f0262cSandi  $wr = $INFO['writable'];
959f3f0262cSandi  if($wr){
960c112d578Sandi    if ($REV) print p_locale_xhtml('editrev');
961c112d578Sandi    print p_locale_xhtml($include);
962f3f0262cSandi  }else{
963c112d578Sandi    print p_locale_xhtml('read');
964f3f0262cSandi    $ro='readonly="readonly"';
965f3f0262cSandi  }
966f3f0262cSandi  if(!$DATE) $DATE = $INFO['lastmod'];
967dc57ef04Sandi
968dc57ef04Sandi
969f3f0262cSandi?>
9705e163278SAndreas Gohr  <form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
9714da078a3Smatthiasgrimm  <input type="hidden" name="id"   value="<?php echo $ID?>" />
9724da078a3Smatthiasgrimm  <input type="hidden" name="rev"  value="<?php echo $REV?>" />
9734da078a3Smatthiasgrimm  <input type="hidden" name="date" value="<?php echo $DATE?>" />
9744da078a3Smatthiasgrimm  <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" />
9754da078a3Smatthiasgrimm  <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" />
976f3f0262cSandi  <table style="width:99%">
977f3f0262cSandi    <tr>
978dc57ef04Sandi      <td class="toolbar" colspan="2">
97920d062caSAndreas Gohr        <div id="toolbar"></div>
98020d062caSAndreas Gohr
9814da078a3Smatthiasgrimm        <?php if($wr){?>
982*4beabca9SAnika Henke        <script type="text/javascript" charset="utf-8">
9834da078a3Smatthiasgrimm          <?php /* sets changed to true when previewed */?>
9844da078a3Smatthiasgrimm          textChanged = <?php ($pr) ? print 'true' : print 'false' ?>;
985f3f0262cSandi        </script>
98658bef989Smatthiasgrimm        <span id="spell_action"></span>
9874da078a3Smatthiasgrimm        <?php } ?>
988f3f0262cSandi      </td>
989dc57ef04Sandi      <td>
990dc57ef04Sandi        <div id="spell_suggest"></div>
991f3f0262cSandi      </td>
992f3f0262cSandi    </tr>
993f3f0262cSandi    <tr>
994dc57ef04Sandi      <td colspan="3">
995dc57ef04Sandi        <div id="spell_result"></div>
9965e163278SAndreas Gohr        <textarea name="wikitext" id="wikitext" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea>
997dc57ef04Sandi      </td>
998dc57ef04Sandi    </tr>
999dc57ef04Sandi    <tr id="wikieditbar">
1000f3f0262cSandi      <td>
10014da078a3Smatthiasgrimm      <?php if($wr){?>
10025e163278SAndreas Gohr        <input class="button" id="edbtn_save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" />
10035e163278SAndreas Gohr        <input class="button" id="edbtn_preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" />
10044da078a3Smatthiasgrimm        <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" />
10054da078a3Smatthiasgrimm      <?php } ?>
1006f3f0262cSandi      </td>
1007f3f0262cSandi      <td>
10084da078a3Smatthiasgrimm      <?php if($wr){ ?>
10094da078a3Smatthiasgrimm        <?php echo $lang['summary']?>:
10105e163278SAndreas Gohr        <input type="text" class="edit" name="summary" id="summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" />
1011b6912aeaSAndreas Gohr        <?php html_minoredit()?>
10124da078a3Smatthiasgrimm      <?php }?>
1013f3f0262cSandi      </td>
1014f3f0262cSandi      <td align="right">
101520d062caSAndreas Gohr        <div id="sizectl"></div>
1016f3f0262cSandi      </td>
1017f3f0262cSandi    </tr>
1018f3f0262cSandi  </table>
1019f3f0262cSandi  </form>
10204da078a3Smatthiasgrimm<?php
1021f3f0262cSandi}
1022f3f0262cSandi
1023f3f0262cSandi/**
1024b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users
1025b6912aeaSAndreas Gohr *
1026b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org>
1027b6912aeaSAndreas Gohr */
1028b6912aeaSAndreas Gohrfunction html_minoredit(){
1029b6912aeaSAndreas Gohr  global $conf;
1030b6912aeaSAndreas Gohr  global $lang;
1031b6912aeaSAndreas Gohr  // minor edits are for logged in users only
1032b6912aeaSAndreas Gohr  if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
1033b6912aeaSAndreas Gohr    return;
1034b6912aeaSAndreas Gohr  }
1035b6912aeaSAndreas Gohr
1036b6912aeaSAndreas Gohr  $p = array();
1037b6912aeaSAndreas Gohr  $p['name']     = 'minor';
1038b6912aeaSAndreas Gohr  $p['type']     = 'checkbox';
1039b6912aeaSAndreas Gohr  $p['id']       = 'minoredit';
1040b6912aeaSAndreas Gohr  $p['tabindex'] = 3;
1041b6912aeaSAndreas Gohr  $p['value']    = '1';
1042b6912aeaSAndreas Gohr  if($_REQUEST['minor']) $p['checked']='checked';
1043b6912aeaSAndreas Gohr  $att = buildAttributes($p);
1044b6912aeaSAndreas Gohr
1045b6912aeaSAndreas Gohr  print "<input $att />";
1046b6912aeaSAndreas Gohr  print '<label for="minoredit">';
1047b6912aeaSAndreas Gohr  print $lang['minoredit'];
1048b6912aeaSAndreas Gohr  print '</label>';
1049b6912aeaSAndreas Gohr}
1050b6912aeaSAndreas Gohr
1051b6912aeaSAndreas Gohr/**
1052f3f0262cSandi * prints some debug info
105315fae107Sandi *
105415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
1055f3f0262cSandi */
1056f3f0262cSandifunction html_debug(){
1057f3f0262cSandi  global $conf;
1058d16a4edaSandi  global $lang;
105928fb55ffSandi  //remove sensitive data
106028fb55ffSandi  $cnf = $conf;
106128fb55ffSandi  $cnf['auth']='***';
106228fb55ffSandi  $cnf['notify']='***';
10633dc3a5f1Sandi  $cnf['ftp']='***';
1064f3f0262cSandi
1065f3f0262cSandi  print '<html><body>';
1066f3f0262cSandi
1067f3f0262cSandi  print '<p>When reporting bugs please send all the following ';
1068f3f0262cSandi  print 'output as a mail to andi@splitbrain.org ';
1069f3f0262cSandi  print 'The best way to do this is to save this page in your browser</p>';
1070f3f0262cSandi
1071f3f0262cSandi  print '<b>$_SERVER:</b><pre>';
1072f3f0262cSandi  print_r($_SERVER);
1073f3f0262cSandi  print '</pre>';
1074f3f0262cSandi
1075f3f0262cSandi  print '<b>$conf:</b><pre>';
107628fb55ffSandi  print_r($cnf);
1077f3f0262cSandi  print '</pre>';
1078f3f0262cSandi
1079ed7b5f09Sandi  print '<b>DOKU_BASE:</b><pre>';
1080ed7b5f09Sandi  print DOKU_BASE;
1081f3f0262cSandi  print '</pre>';
1082f3f0262cSandi
1083ed7b5f09Sandi  print '<b>abs DOKU_BASE:</b><pre>';
1084ed7b5f09Sandi  print DOKU_URL;
1085ed7b5f09Sandi  print '</pre>';
1086ed7b5f09Sandi
1087ed7b5f09Sandi  print '<b>rel DOKU_BASE:</b><pre>';
1088f3f0262cSandi  print dirname($_SERVER['PHP_SELF']).'/';
1089f3f0262cSandi  print '</pre>';
1090f3f0262cSandi
1091f3f0262cSandi  print '<b>PHP Version:</b><pre>';
1092f3f0262cSandi  print phpversion();
1093f3f0262cSandi  print '</pre>';
1094f3f0262cSandi
1095f3f0262cSandi  print '<b>locale:</b><pre>';
1096f3f0262cSandi  print setlocale(LC_ALL,0);
1097f3f0262cSandi  print '</pre>';
1098f3f0262cSandi
1099d16a4edaSandi  print '<b>encoding:</b><pre>';
1100d16a4edaSandi  print $lang['encoding'];
1101d16a4edaSandi  print '</pre>';
1102d16a4edaSandi
1103f3f0262cSandi  print '<b>Environment:</b><pre>';
1104f3f0262cSandi  print_r($_ENV);
1105f3f0262cSandi  print '</pre>';
1106f3f0262cSandi
1107f3f0262cSandi  print '<b>PHP settings:</b><pre>';
1108f3f0262cSandi  $inis = ini_get_all();
1109f3f0262cSandi  print_r($inis);
1110f3f0262cSandi  print '</pre>';
1111f3f0262cSandi
1112f3f0262cSandi  print '</body></html>';
1113f3f0262cSandi}
1114f3f0262cSandi
1115c19fe9c0Sandifunction html_admin(){
1116c19fe9c0Sandi  global $ID;
1117c19fe9c0Sandi  global $lang;
1118ca3a6df1SMatthias Grimm  global $conf;
1119c19fe9c0Sandi
1120c112d578Sandi  print p_locale_xhtml('admin');
1121c19fe9c0Sandi
112211e2ce22Schris  // build menu of admin functions from the plugins that handle them
112311e2ce22Schris  $pluginlist = plugin_list('admin');
112411e2ce22Schris  $menu = array();
112511e2ce22Schris  foreach ($pluginlist as $p) {
112611e2ce22Schris    if($obj =& plugin_load('admin',$p) === NULL) continue;
112711e2ce22Schris    $menu[] = array('plugin' => $p,
112811e2ce22Schris                    'prompt' => $obj->getMenuText($conf['lang']),
112911e2ce22Schris                    'sort' => $obj->getMenuSort()
113011e2ce22Schris                   );
113111e2ce22Schris  }
113211e2ce22Schris
113311e2ce22Schris  usort($menu, p_sort_modes);
113411e2ce22Schris
113511e2ce22Schris  // output the menu
113611e2ce22Schris  ptln('<ul>');
113711e2ce22Schris
113811e2ce22Schris  foreach ($menu as $item) {
113911e2ce22Schris    if (!$item['prompt']) continue;
114011e2ce22Schris    ptln('  <li><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></li>');
114111e2ce22Schris  }
114211e2ce22Schris
114311e2ce22Schris  // add in non-plugin functions
114411e2ce22Schris  if (!$conf['openregister']){
114511e2ce22Schris    ptln('<li><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></li>');
114611e2ce22Schris  }
114711e2ce22Schris
114811e2ce22Schris  ptln('</ul>');
1149ca3a6df1SMatthias Grimm}
1150c19fe9c0Sandi
11518b06d178Schris/**
11528b06d178Schris * Form to request a new password for an existing account
11538b06d178Schris *
11548b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info>
115511e2ce22Schris */
11568b06d178Schrisfunction html_resendpwd() {
11578b06d178Schris  global $lang;
11588b06d178Schris  global $conf;
11598b06d178Schris  global $ID;
1160c19fe9c0Sandi
11618b06d178Schris  print p_locale_xhtml('resendpwd');
11628b06d178Schris?>
11638b06d178Schris  <div align="center">
11648b06d178Schris  <form name="resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post">
11658b06d178Schris    <fieldset>
11668b06d178Schris      <br />
1167753d5abfSMatthias Grimm      <legend><?php echo $lang['resendpwd']?></legend>
11688b06d178Schris      <input type="hidden" name="do" value="resendpwd" />
11698b06d178Schris      <input type="hidden" name="save" value="1" />
11708b06d178Schris      <label class="block">
11718b06d178Schris        <span><?php echo $lang['user']?></span>
11728b06d178Schris        <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br />
11738b06d178Schris      </label><br />
11748b06d178Schris      <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" />
11758b06d178Schris    </fieldset>
11768b06d178Schris  </form>
11778b06d178Schris  </div>
11788b06d178Schris<?php
11798b06d178Schris}
1180340756e4Sandi
1181340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 :
1182