xref: /dokuwiki/inc/html.php (revision b6912aeac771ef294377b8af071d28f6acfa7050)
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" />
59*b6912aeaSAndreas 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 />
63*b6912aeaSAndreas 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    }
81f3f0262cSandi  ?>
82f3f0262cSandi    </div>
834da078a3Smatthiasgrimm  <?php
846bbae538Sandi/*
856bbae538Sandi FIXME provide new hook
86f3f0262cSandi  if(@file_exists('includes/login.txt')){
87f3f0262cSandi    print io_cacheParse('includes/login.txt');
88f3f0262cSandi  }
896bbae538Sandi*/
90f3f0262cSandi}
91f3f0262cSandi
92f3f0262cSandi/**
93f3f0262cSandi * shows the edit/source/show button dependent on current mode
9415fae107Sandi *
9515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
96f3f0262cSandi */
97f3f0262cSandifunction html_editbutton(){
98f3f0262cSandi  global $ID;
99f3f0262cSandi  global $REV;
100f3f0262cSandi  global $ACT;
101f3f0262cSandi  global $INFO;
102f3f0262cSandi
103f3f0262cSandi  if($ACT == 'show' || $ACT == 'search'){
104f3f0262cSandi    if($INFO['writable']){
105f3f0262cSandi      if($INFO['exists']){
106f3f0262cSandi        $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
107f3f0262cSandi      }else{
108f3f0262cSandi        $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post');
109f3f0262cSandi      }
110f3f0262cSandi    }else{
111f3f0262cSandi      $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post');
112f3f0262cSandi    }
113f3f0262cSandi  }else{
114f3f0262cSandi    $r = html_btn('show',$ID,'v',array('do' => 'show'));
115f3f0262cSandi  }
116f3f0262cSandi  return $r;
117f3f0262cSandi}
118f3f0262cSandi
11915fae107Sandi/**
12015fae107Sandi * prints a section editing button
12115fae107Sandi *
12215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
12315fae107Sandi */
124f3f0262cSandifunction html_secedit_button($section,$p){
125f3f0262cSandi  global $ID;
126f3f0262cSandi  global $lang;
127f3f0262cSandi  $secedit  = '';
128506ae684Sandi#  if($p) $secedit .= "</p>\n";
129f3f0262cSandi  $secedit .= '<div class="secedit">';
130f3f0262cSandi  $secedit .= html_btn('secedit',$ID,'',
131f3f0262cSandi                        array('do'      => 'edit',
132f3f0262cSandi                              'lines'   => "$section"),
133f3f0262cSandi                              'post');
134f3f0262cSandi  $secedit .= '</div>';
135506ae684Sandi#  if($p) $secedit .= "\n<p>";
136f3f0262cSandi  return $secedit;
137f3f0262cSandi}
138f3f0262cSandi
13915fae107Sandi/**
14015fae107Sandi * inserts section edit buttons if wanted or removes the markers
14115fae107Sandi *
14215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
14315fae107Sandi */
144f3f0262cSandifunction html_secedit($text,$show=true){
145f3f0262cSandi  global $INFO;
146c112d578Sandi  if($INFO['writable'] && $show && !$INFO['rev']){
147f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e',
148f3f0262cSandi                         "html_secedit_button('\\1',true)",
149f3f0262cSandi                         $text);
150f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e',
151f3f0262cSandi                         "html_secedit_button('\\1',false)",
152f3f0262cSandi                         $text);
153f3f0262cSandi  }else{
154f3f0262cSandi    $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text);
155f3f0262cSandi  }
156f3f0262cSandi  return $text;
157f3f0262cSandi}
158f3f0262cSandi
159f3f0262cSandi/**
160d6c9c552Smatthiasgrimm * Just the back to top button (in its own form)
1616b13307fSandi *
1626b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
1636b13307fSandi */
1646b13307fSandifunction html_topbtn(){
1656b13307fSandi  global $lang;
1666b13307fSandi
1676b13307fSandi  $ret  = '';
168265e3787Sandi  $ret  = '<a href="#top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>';
169df7b6005Sandi
1706b13307fSandi  return $ret;
1716b13307fSandi}
1726b13307fSandi
1736b13307fSandi/**
174d67ca2c0Smatthiasgrimm * Just the back to media window button in its own form
175d67ca2c0Smatthiasgrimm *
176d67ca2c0Smatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
177d67ca2c0Smatthiasgrimm */
178d67ca2c0Smatthiasgrimmfunction html_backtomedia_button($params,$akey=''){
179d67ca2c0Smatthiasgrimm  global $conf;
180d67ca2c0Smatthiasgrimm  global $lang;
181d67ca2c0Smatthiasgrimm
182d67ca2c0Smatthiasgrimm  $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php">';
183d67ca2c0Smatthiasgrimm
184d67ca2c0Smatthiasgrimm  reset($params);
185d67ca2c0Smatthiasgrimm  while (list($key, $val) = each($params)) {
186d67ca2c0Smatthiasgrimm    $ret .= '<input type="hidden" name="'.$key.'" ';
187d67ca2c0Smatthiasgrimm    $ret .= 'value="'.htmlspecialchars($val).'" />';
188d67ca2c0Smatthiasgrimm  }
189d67ca2c0Smatthiasgrimm
190d67ca2c0Smatthiasgrimm  $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" ';
191d67ca2c0Smatthiasgrimm  if($akey){
192d67ca2c0Smatthiasgrimm    $ret .= 'title="ALT+'.strtoupper($akey).'" ';
193d67ca2c0Smatthiasgrimm    $ret .= 'accesskey="'.$akey.'" ';
194d67ca2c0Smatthiasgrimm  }
195d67ca2c0Smatthiasgrimm  $ret .= '/>';
196d67ca2c0Smatthiasgrimm  $ret .= '</form>';
197d67ca2c0Smatthiasgrimm
198d67ca2c0Smatthiasgrimm  return $ret;
199d67ca2c0Smatthiasgrimm}
200d67ca2c0Smatthiasgrimm
201d67ca2c0Smatthiasgrimm/**
202d67ca2c0Smatthiasgrimm * Displays a button (using its own form)
20315fae107Sandi *
20415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
205f3f0262cSandi */
206f3f0262cSandifunction html_btn($name,$id,$akey,$params,$method='get'){
207f3f0262cSandi  global $conf;
208f3f0262cSandi  global $lang;
209f3f0262cSandi
210f3f0262cSandi  $label = $lang['btn_'.$name];
211f3f0262cSandi
212f3f0262cSandi  $ret = '';
213f3f0262cSandi
21449c713a3Sandi  //filter id (without urlencoding)
21549c713a3Sandi  $id = idfilter($id,false);
216f3f0262cSandi
217f3f0262cSandi  //make nice URLs even for buttons
2186c7843b5Sandi  if($conf['userewrite'] == 2){
2196c7843b5Sandi    $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id;
2206c7843b5Sandi  }elseif($conf['userewrite']){
2216c7843b5Sandi    $script = DOKU_BASE.$id;
2226c7843b5Sandi  }else{
2238b00ebcfSandi    $script = DOKU_BASE.DOKU_SCRIPT;
224f3f0262cSandi    $params['id'] = $id;
225f3f0262cSandi  }
226f3f0262cSandi
227f3f0262cSandi  $ret .= '<form class="button" method="'.$method.'" action="'.$script.'" onsubmit="return svchk()">';
228f3f0262cSandi
229f3f0262cSandi  reset($params);
230f3f0262cSandi  while (list($key, $val) = each($params)) {
231f3f0262cSandi    $ret .= '<input type="hidden" name="'.$key.'" ';
232f3f0262cSandi    $ret .= 'value="'.htmlspecialchars($val).'" />';
233f3f0262cSandi  }
234f3f0262cSandi
235f3f0262cSandi  $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" ';
236f3f0262cSandi  if($akey){
237f3f0262cSandi    $ret .= 'title="ALT+'.strtoupper($akey).'" ';
238f3f0262cSandi    $ret .= 'accesskey="'.$akey.'" ';
239f3f0262cSandi  }
240f3f0262cSandi  $ret .= '/>';
241f3f0262cSandi  $ret .= '</form>';
242f3f0262cSandi
243f3f0262cSandi  return $ret;
244f3f0262cSandi}
245f3f0262cSandi
246f3f0262cSandi/**
24715fae107Sandi * show a wiki page
24815fae107Sandi *
24915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
25015fae107Sandi */
2516bbae538Sandifunction html_show($txt=''){
252f3f0262cSandi  global $ID;
253f3f0262cSandi  global $REV;
254f3f0262cSandi  global $HIGH;
255f3f0262cSandi  //disable section editing for old revisions or in preview
2565400331dSandi  if($txt || $REV){
2576bbae538Sandi    $secedit = false;
2586bbae538Sandi  }else{
2596bbae538Sandi    $secedit = true;
260f3f0262cSandi  }
261f3f0262cSandi
2626bbae538Sandi  if ($txt){
263f3f0262cSandi    //PreviewHeader
264c112d578Sandi    print p_locale_xhtml('preview');
265f3f0262cSandi    print '<div class="preview">';
2669dc2c2afSandi    print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
267f3f0262cSandi    print '</div>';
2686bbae538Sandi
269f3f0262cSandi  }else{
270c112d578Sandi    if ($REV) print p_locale_xhtml('showrev');
271c112d578Sandi    $html = p_wiki_xhtml($ID,$REV,true);
2726bbae538Sandi    $html = html_secedit($html,$secedit);
273f3f0262cSandi    print html_hilight($html,$HIGH);
274f3f0262cSandi  }
275f3f0262cSandi}
276f3f0262cSandi
277f3f0262cSandi/**
278f3f0262cSandi * Highlights searchqueries in HTML code
27915fae107Sandi *
28015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
281f3f0262cSandi */
282f3f0262cSandifunction html_hilight($html,$query){
283f3f0262cSandi  $queries = preg_split ("/\s/",$query,-1,PREG_SPLIT_NO_EMPTY);
284f3f0262cSandi  foreach ($queries as $q){
285f3f0262cSandi    $q = preg_quote($q,'/');
28689541d4bSAndreas Gohr    $html = preg_replace("/((<[^>]*)|$q)/ie", '"\2"=="\1"? unslash("\1"):"<span class=\"search_hit\">".unslash("\1")."</span>"', $html);
287f3f0262cSandi  }
288f3f0262cSandi  return $html;
289f3f0262cSandi}
290f3f0262cSandi
291f3f0262cSandi/**
29215fae107Sandi * Run a search and display the result
29315fae107Sandi *
29415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
295f3f0262cSandi */
296f3f0262cSandifunction html_search(){
297ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
298506fa893SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
299f3f0262cSandi  global $conf;
300f3f0262cSandi  global $QUERY;
301f3f0262cSandi  global $ID;
302f3f0262cSandi  global $lang;
303f3f0262cSandi
304c112d578Sandi  print p_locale_xhtml('searchpage');
305f3f0262cSandi  flush();
306f3f0262cSandi
3074d9ff3d5Sandi  //show progressbar
3084d9ff3d5Sandi  print '<div align="center">';
309ea2eed85Sandi  print '<script language="javascript" type="text/javascript" charset="utf-8">';
3104d9ff3d5Sandi  print 'showLoadBar();';
3114d9ff3d5Sandi  print '</script>';
3124d9ff3d5Sandi  print '<br /></div>';
3134d9ff3d5Sandi
314f3f0262cSandi  //do quick pagesearch
315f3f0262cSandi  $data = array();
316506fa893SAndreas Gohr  $data = ft_pageLookup(cleanID($QUERY));
317f3f0262cSandi  if(count($data)){
318f3f0262cSandi    sort($data);
319f3f0262cSandi    print '<div class="search_quickresult">';
320f3f0262cSandi    print '<b>'.$lang[quickhits].':</b><br />';
321506fa893SAndreas Gohr    foreach($data as $id){
322f3f0262cSandi      print '<div class="search_quickhits">';
323506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id);
324f3f0262cSandi      print '</div> ';
325f3f0262cSandi    }
326f3f0262cSandi    //clear float (see http://www.complexspiral.com/publications/containing-floats/)
327f3f0262cSandi    print '<div class="clearer">&nbsp;</div>';
328f3f0262cSandi    print '</div>';
329f3f0262cSandi  }
330f3f0262cSandi  flush();
331f3f0262cSandi
332f3f0262cSandi  //do fulltext search
333506fa893SAndreas Gohr  $data = ft_pageSearch($QUERY,$poswords);
334f3f0262cSandi  if(count($data)){
335506fa893SAndreas Gohr    $num = 1;
336506fa893SAndreas Gohr    foreach($data as $id => $cnt){
337f3f0262cSandi      print '<div class="search_result">';
338506fa893SAndreas Gohr      print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords);
339506fa893SAndreas Gohr      print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
340506fa893SAndreas Gohr      if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
341506fa893SAndreas Gohr        print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>';
342506fa893SAndreas Gohr      }
343f3f0262cSandi      print '</div>';
344506fa893SAndreas Gohr      flush();
345506fa893SAndreas Gohr      $num++;
346f3f0262cSandi    }
347f3f0262cSandi  }else{
348820fa24bSandi    print '<div class="nothing">'.$lang['nothingfound'].'</div>';
349f3f0262cSandi  }
3504d9ff3d5Sandi
3514d9ff3d5Sandi  //hide progressbar
352ea2eed85Sandi  print '<script language="javascript" type="text/javascript" charset="utf-8">';
3534d9ff3d5Sandi  print 'hideLoadBar();';
3544d9ff3d5Sandi  print '</script>';
355f3f0262cSandi}
356f3f0262cSandi
35715fae107Sandi/**
35815fae107Sandi * Display error on locked pages
35915fae107Sandi *
36015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
36115fae107Sandi */
362ee20e7d1Sandifunction html_locked(){
363f3f0262cSandi  global $ID;
364f3f0262cSandi  global $conf;
365f3f0262cSandi  global $lang;
36688f522e9Sandi  global $INFO;
367f3f0262cSandi
368f3f0262cSandi  $locktime = filemtime(wikiFN($ID).'.lock');
369f3f0262cSandi  $expire = @date($conf['dformat'], $locktime + $conf['locktime'] );
370f3f0262cSandi  $min    = round(($conf['locktime'] - (time() - $locktime) )/60);
371f3f0262cSandi
372c112d578Sandi  print p_locale_xhtml('locked');
373f3f0262cSandi  print '<ul>';
37488f522e9Sandi  print '<li><b>'.$lang['lockedby'].':</b> '.$INFO['locked'].'</li>';
375f3f0262cSandi  print '<li><b>'.$lang['lockexpire'].':</b> '.$expire.' ('.$min.' min)</li>';
376f3f0262cSandi  print '</ul>';
377f3f0262cSandi}
378f3f0262cSandi
37915fae107Sandi/**
38015fae107Sandi * list old revisions
38115fae107Sandi *
38215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
38315fae107Sandi */
384f3f0262cSandifunction html_revisions(){
385f3f0262cSandi  global $ID;
386f3f0262cSandi  global $INFO;
387f3f0262cSandi  global $conf;
388f3f0262cSandi  global $lang;
389f3f0262cSandi  $revisions = getRevisions($ID);
390f3f0262cSandi  $date = @date($conf['dformat'],$INFO['lastmod']);
391f3f0262cSandi
392c112d578Sandi  print p_locale_xhtml('revisions');
393f3f0262cSandi  print '<ul>';
394f3f0262cSandi  if($INFO['exists']){
395*b6912aeaSAndreas Gohr    print ($INFO['minor']) ? '<li class="minor">' : '<li>';
396f9b2fe70Sandi
397f9b2fe70Sandi    print $date;
398f9b2fe70Sandi
399f62ea8a1Sandi    print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" border="0" width="15" height="11" alt="" /> ';
400cffcc403Sandi
401f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> ';
402652610a2Sandi
403652610a2Sandi    print $INFO['sum'];
40488f522e9Sandi    print ' <span class="user">';
40588f522e9Sandi    print $INFO['editor'];
40688f522e9Sandi    print '</span> ';
407652610a2Sandi
408652610a2Sandi    print '('.$lang['current'].')';
409652610a2Sandi    print '</li>';
410f3f0262cSandi  }
411f3f0262cSandi
412f3f0262cSandi  foreach($revisions as $rev){
413f3f0262cSandi    $date = date($conf['dformat'],$rev);
414652610a2Sandi    $info = getRevisionInfo($ID,$rev);
415652610a2Sandi
416*b6912aeaSAndreas Gohr    print ($info['minor']) ? '<li class="minor">' : '<li>';
417f9b2fe70Sandi    print $date;
418f9b2fe70Sandi
419cffcc403Sandi    print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
420d94f4568SAndreas Gohr    $p = array();
421d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
422d94f4568SAndreas Gohr    $p['border'] = 0;
423d94f4568SAndreas Gohr    $p['width']  = 15;
424d94f4568SAndreas Gohr    $p['height'] = 11;
425d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
426d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
427d94f4568SAndreas Gohr    $att = buildAttributes($p);
428d94f4568SAndreas Gohr    print "<img $att />";
429cffcc403Sandi    print '</a> ';
430cffcc403Sandi
431f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> ';
432f9b2fe70Sandi
433f243a77fSandi    print htmlspecialchars($info['sum']);
43488f522e9Sandi    print ' <span class="user">';
43588f522e9Sandi    if($info['user']){
43688f522e9Sandi      print $info['user'];
43788f522e9Sandi    }else{
438652610a2Sandi      print $info['ip'];
43988f522e9Sandi    }
44088f522e9Sandi    print '</span>';
441652610a2Sandi
442f3f0262cSandi    print '</li>';
443f3f0262cSandi  }
444f3f0262cSandi  print '</ul>';
445f3f0262cSandi}
446f3f0262cSandi
44715fae107Sandi/**
44815fae107Sandi * display recent changes
44915fae107Sandi *
45015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
4515749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
45215fae107Sandi */
453a39955b0Smatthiasgrimmfunction html_recent($first=0){
454f3f0262cSandi  global $conf;
455cffcc403Sandi  global $lang;
456dbb00abcSEsther Brunner  global $ID;
4575749f1ceSmatthiasgrimm  /* we need to get one additionally log entry to be able to
4585749f1ceSmatthiasgrimm   * decide if this is the last page or is there another one.
4595749f1ceSmatthiasgrimm   * This is the cheapest solution to get this information.
4605749f1ceSmatthiasgrimm   */
461*b6912aeaSAndreas Gohr  $recents = getRecents($first,$conf['recent'] + 1,getNS($ID));
4625749f1ceSmatthiasgrimm  if(count($recents) == 0 && $first != 0){
4635749f1ceSmatthiasgrimm    $first=0;
464*b6912aeaSAndreas Gohr    $recents = getRecents(0,$conf['recent'] + 1,getNS($ID));
4655749f1ceSmatthiasgrimm  }
4665749f1ceSmatthiasgrimm  $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
467f3f0262cSandi
468c112d578Sandi  print p_locale_xhtml('recent');
469f3f0262cSandi  print '<ul>';
470a39955b0Smatthiasgrimm
471d437bcc4SAndreas Gohr  foreach($recents as $recent){
472d437bcc4SAndreas Gohr    $date = date($conf['dformat'],$recent['date']);
473*b6912aeaSAndreas Gohr    print ($recent['minor']) ? '<li class="minor">' : '<li>';
474cffcc403Sandi
475f9b2fe70Sandi    print $date.' ';
476f9b2fe70Sandi
477d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=diff").'">';
478d94f4568SAndreas Gohr    $p = array();
479d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
480d94f4568SAndreas Gohr    $p['border'] = 0;
481d94f4568SAndreas Gohr    $p['width']  = 15;
482d94f4568SAndreas Gohr    $p['height'] = 11;
483d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
484d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
485d94f4568SAndreas Gohr    $att = buildAttributes($p);
486d94f4568SAndreas Gohr    print "<img $att />";
487cffcc403Sandi    print '</a> ';
488cffcc403Sandi
489d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=revisions").'">';
490d94f4568SAndreas Gohr    $p = array();
491d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/history.png';
492d94f4568SAndreas Gohr    $p['border'] = 0;
493d94f4568SAndreas Gohr    $p['width']  = 12;
494d94f4568SAndreas Gohr    $p['height'] = 14;
495d94f4568SAndreas Gohr    $p['title']  = $lang['btn_revs'];
496d94f4568SAndreas Gohr    $p['alt']    = $lang['btn_revs'];
497d94f4568SAndreas Gohr    $att = buildAttributes($p);
498d94f4568SAndreas Gohr    print "<img $att />";
499cffcc403Sandi    print '</a> ';
500cffcc403Sandi
501d437bcc4SAndreas Gohr    print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
502d437bcc4SAndreas Gohr    print ' '.htmlspecialchars($recent['sum']);
503*b6912aeaSAndreas Gohr
50488f522e9Sandi    print ' <span class="user">';
505d437bcc4SAndreas Gohr    if($recent['user']){
506d437bcc4SAndreas Gohr      print $recent['user'];
50788f522e9Sandi    }else{
508d437bcc4SAndreas Gohr      print $recent['ip'];
50988f522e9Sandi    }
51088f522e9Sandi    print '</span>';
511cffcc403Sandi
512f3f0262cSandi    print '</li>';
513f3f0262cSandi  }
514f3f0262cSandi  print '</ul>';
515a39955b0Smatthiasgrimm
516a39955b0Smatthiasgrimm  print '<div class="pagenav">';
5175749f1ceSmatthiasgrimm  $last = $first + $conf['recent'];
518a39955b0Smatthiasgrimm  if ($first > 0) {
519a39955b0Smatthiasgrimm    $first -= $conf['recent'];
520a39955b0Smatthiasgrimm    if ($first < 0) $first = 0;
521a39955b0Smatthiasgrimm    print '<div class="pagenav-prev">';
5225749f1ceSmatthiasgrimm    print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
523a39955b0Smatthiasgrimm    print '</div>';
524a39955b0Smatthiasgrimm  }
5255749f1ceSmatthiasgrimm  if ($conf['recent'] < count($recents)) {
526a39955b0Smatthiasgrimm    print '<div class="pagenav-next">';
5275749f1ceSmatthiasgrimm    print html_btn('older','',"n",array('do' => 'recent', 'first' => $last));
528a39955b0Smatthiasgrimm    print '</div>';
529a39955b0Smatthiasgrimm  }
530a39955b0Smatthiasgrimm  print '</div>';
531f3f0262cSandi}
532f3f0262cSandi
53315fae107Sandi/**
53415fae107Sandi * Display page index
53515fae107Sandi *
53615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
53715fae107Sandi */
538f3f0262cSandifunction html_index($ns){
539ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
540f3f0262cSandi  global $conf;
541f3f0262cSandi  global $ID;
542f3f0262cSandi  $dir = $conf['datadir'];
543f3f0262cSandi  $ns  = cleanID($ns);
54430f1737dSandi  #fixme use appropriate function
545f3f0262cSandi  if(empty($ns)){
546f3f0262cSandi    $ns = dirname(str_replace(':','/',$ID));
547f3f0262cSandi    if($ns == '.') $ns ='';
548f3f0262cSandi  }
54988d3a917Sandi  $ns  = utf8_encodeFN(str_replace(':','/',$ns));
550f3f0262cSandi
551c112d578Sandi  print p_locale_xhtml('index');
552f3f0262cSandi
553f3f0262cSandi  $data = array();
554f3f0262cSandi  search($data,$conf['datadir'],'search_index',array('ns' => $ns));
555cb70c441Sandi  print html_buildlist($data,'idx','html_list_index','html_li_index');
556f3f0262cSandi}
557f3f0262cSandi
558f3f0262cSandi/**
55915fae107Sandi * Index item formatter
56015fae107Sandi *
561f3f0262cSandi * User function for html_buildlist()
56215fae107Sandi *
56315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
564f3f0262cSandi */
565f3f0262cSandifunction html_list_index($item){
566f3f0262cSandi  $ret = '';
567f3f0262cSandi  $base = ':'.$item['id'];
568f3f0262cSandi  $base = substr($base,strrpos($base,':')+1);
569f3f0262cSandi  if($item['type']=='d'){
570f3f0262cSandi    $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">';
571f3f0262cSandi    $ret .= $base;
572f3f0262cSandi    $ret .= '</a>';
573f3f0262cSandi  }else{
574f3f0262cSandi    $ret .= html_wikilink(':'.$item['id']);
575f3f0262cSandi  }
576f3f0262cSandi  return $ret;
577f3f0262cSandi}
578f3f0262cSandi
579f3f0262cSandi/**
580cb70c441Sandi * Index List item
581cb70c441Sandi *
582cb70c441Sandi * This user function is used in html_build_lidt to build the
583cb70c441Sandi * <li> tags for namespaces when displaying the page index
584cb70c441Sandi * it gives different classes to opened or closed "folders"
585cb70c441Sandi *
586cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
587cb70c441Sandi */
588cb70c441Sandifunction html_li_index($item){
589cb70c441Sandi  if($item['type'] == "f"){
590cb70c441Sandi    return '<li class="level'.$item['level'].'">';
591cb70c441Sandi  }elseif($item['open']){
592cb70c441Sandi    return '<li class="open">';
593cb70c441Sandi  }else{
594cb70c441Sandi    return '<li class="closed">';
595cb70c441Sandi  }
596cb70c441Sandi}
597cb70c441Sandi
598cb70c441Sandi/**
599cb70c441Sandi * Default List item
600cb70c441Sandi *
601cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
602cb70c441Sandi */
603cb70c441Sandifunction html_li_default($item){
604cb70c441Sandi  return '<li class="level'.$item['level'].'">';
605cb70c441Sandi}
606cb70c441Sandi
607cb70c441Sandi/**
60815fae107Sandi * Build an unordered list
60915fae107Sandi *
610f3f0262cSandi * Build an unordered list from the given $data array
611f3f0262cSandi * Each item in the array has to have a 'level' property
612f3f0262cSandi * the item itself gets printed by the given $func user
613cb70c441Sandi * function. The second and optional function is used to
614cb70c441Sandi * print the <li> tag. Both user function need to accept
615cb70c441Sandi * a single item.
61615fae107Sandi *
61715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
618f3f0262cSandi */
619cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){
620f3f0262cSandi  $level = 0;
621f3f0262cSandi  $opens = 0;
622f3f0262cSandi  $ret   = '';
623f3f0262cSandi
624f3f0262cSandi  foreach ($data as $item){
625f3f0262cSandi
626f3f0262cSandi    if( $item['level'] > $level ){
627f3f0262cSandi      //open new list
628df52d0feSandi      for($i=0; $i<($item['level'] - $level); $i++){
629df52d0feSandi        if ($i) $ret .= "<li class=\"clear\">\n";
630f3f0262cSandi        $ret .= "\n<ul class=\"$class\">\n";
631df52d0feSandi      }
632f3f0262cSandi    }elseif( $item['level'] < $level ){
633f3f0262cSandi      //close last item
634f3f0262cSandi      $ret .= "</li>\n";
635f3f0262cSandi      for ($i=0; $i<($level - $item['level']); $i++){
636f3f0262cSandi        //close higher lists
637f3f0262cSandi        $ret .= "</ul>\n</li>\n";
638f3f0262cSandi      }
639f3f0262cSandi    }else{
640f3f0262cSandi      //close last item
641f3f0262cSandi      $ret .= "</li>\n";
642f3f0262cSandi    }
643f3f0262cSandi
644f3f0262cSandi    //remember current level
645f3f0262cSandi    $level = $item['level'];
646f3f0262cSandi
647f3f0262cSandi    //print item
648cb70c441Sandi    $ret .= $lifunc($item); //user function
649f3f0262cSandi    $ret .= '<span class="li">';
650f3f0262cSandi    $ret .= $func($item); //user function
651f3f0262cSandi    $ret .= '</span>';
652f3f0262cSandi  }
653f3f0262cSandi
654f3f0262cSandi  //close remaining items and lists
655f3f0262cSandi  for ($i=0; $i < $level; $i++){
656f3f0262cSandi    $ret .= "</li></ul>\n";
657f3f0262cSandi  }
658f3f0262cSandi
659f3f0262cSandi  return $ret;
660f3f0262cSandi}
661f3f0262cSandi
66215fae107Sandi/**
66315fae107Sandi * display backlinks
66415fae107Sandi *
66515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
66615fae107Sandi */
667f3f0262cSandifunction html_backlinks(){
66854f4c056SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
669f3f0262cSandi  global $ID;
670f3f0262cSandi  global $conf;
671f3f0262cSandi
672c112d578Sandi  print p_locale_xhtml('backlinks');
673f3f0262cSandi
67454f4c056SAndreas Gohr  $data = ft_backlinks($ID);
675f3f0262cSandi
676f3f0262cSandi  print '<ul class="idx">';
67754f4c056SAndreas Gohr  foreach($data as $blink){
678f3f0262cSandi    print '<li>';
67954f4c056SAndreas Gohr    print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink);
680f3f0262cSandi    print '</li>';
681f3f0262cSandi  }
682f3f0262cSandi  print '</ul>';
683f3f0262cSandi}
684f3f0262cSandi
68515fae107Sandi/**
68615fae107Sandi * show diff
68715fae107Sandi *
68815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
68915fae107Sandi */
690f3f0262cSandifunction html_diff($text='',$intro=true){
691ed7b5f09Sandi  require_once(DOKU_INC.'inc/DifferenceEngine.php');
692f3f0262cSandi  global $ID;
693f3f0262cSandi  global $REV;
694f3f0262cSandi  global $lang;
695f3f0262cSandi  global $conf;
696f3f0262cSandi  if($text){
697f3f0262cSandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))),
698f3f0262cSandi                    split("\n",htmlspecialchars(cleanText($text))));
699f3f0262cSandi    $left  = '<a class="wikilink1" href="'.wl($ID).'">'.
700f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'.
701f3f0262cSandi              $lang['current'];
702f3f0262cSandi    $right = $lang['yours'];
703f3f0262cSandi  }else{
7044d58bd99Sandi    if($REV){
7054d58bd99Sandi      $r = $REV;
7064d58bd99Sandi    }else{
7074d58bd99Sandi      //use last revision if none given
7084d58bd99Sandi      $revs = getRevisions($ID);
7094d58bd99Sandi      $r = $revs[0];
7104d58bd99Sandi    }
7114d58bd99Sandi
7124d58bd99Sandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))),
713f3f0262cSandi                    split("\n",htmlspecialchars(rawWiki($ID,''))));
7144d58bd99Sandi    $left  = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'.
7154d58bd99Sandi              $ID.' '.date($conf['dformat'],$r).'</a>';
716f3f0262cSandi    $right = '<a class="wikilink1" href="'.wl($ID).'">'.
717f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '.
718f3f0262cSandi              $lang['current'];
719f3f0262cSandi  }
720f3f0262cSandi  $tdf = new TableDiffFormatter();
721c112d578Sandi  if($intro) print p_locale_xhtml('diff');
722f3f0262cSandi  ?>
723f3f0262cSandi    <table class="diff" width="100%">
724f3f0262cSandi      <tr>
725f3f0262cSandi        <td colspan="2" width="50%" class="diff-header">
7264da078a3Smatthiasgrimm          <?php echo $left?>
727f3f0262cSandi        </td>
728f3f0262cSandi        <td colspan="2" width="50%" class="diff-header">
7294da078a3Smatthiasgrimm          <?php echo $right?>
730f3f0262cSandi        </td>
731f3f0262cSandi      </tr>
7324da078a3Smatthiasgrimm      <?php echo $tdf->format($df)?>
733f3f0262cSandi    </table>
7344da078a3Smatthiasgrimm  <?php
735f3f0262cSandi}
736f3f0262cSandi
73715fae107Sandi/**
73815fae107Sandi * show warning on conflict detection
73915fae107Sandi *
74015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
74115fae107Sandi */
742f3f0262cSandifunction html_conflict($text,$summary){
743f3f0262cSandi  global $ID;
744f3f0262cSandi  global $lang;
745f3f0262cSandi
746c112d578Sandi  print p_locale_xhtml('conflict');
747f3f0262cSandi  ?>
7484da078a3Smatthiasgrimm  <form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
7494da078a3Smatthiasgrimm  <input type="hidden" name="id" value="<?php echo $ID?>" />
7504da078a3Smatthiasgrimm  <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" />
7514da078a3Smatthiasgrimm  <input type="hidden" name="summary" value="<?php echo formText($summary)?>" />
752f3f0262cSandi
753f3f0262cSandi  <div align="center">
7544da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" />
7554da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" />
756f3f0262cSandi  </div>
757f3f0262cSandi  </form>
758f3f0262cSandi  <br /><br /><br /><br />
7594da078a3Smatthiasgrimm  <?php
760f3f0262cSandi}
761f3f0262cSandi
762f3f0262cSandi/**
76315fae107Sandi * Prints the global message array
76415fae107Sandi *
76515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
766f3f0262cSandi */
767f3f0262cSandifunction html_msgarea(){
768f3f0262cSandi  global $MSG;
769f3f0262cSandi
770f3f0262cSandi  if(!isset($MSG)) return;
771f3f0262cSandi
772f3f0262cSandi  foreach($MSG as $msg){
773f3f0262cSandi    print '<div class="'.$msg['lvl'].'">';
774f3f0262cSandi    print $msg['msg'];
775f3f0262cSandi    print '</div>';
776f3f0262cSandi  }
777f3f0262cSandi}
778f3f0262cSandi
779f3f0262cSandi/**
780f3f0262cSandi * Prints the registration form
78115fae107Sandi *
78215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
783f3f0262cSandi */
784f3f0262cSandifunction html_register(){
785f3f0262cSandi  global $lang;
786cab2716aSmatthias.grimm  global $conf;
787f3f0262cSandi  global $ID;
788f3f0262cSandi
789c112d578Sandi  print p_locale_xhtml('register');
790f3f0262cSandi?>
791f3f0262cSandi  <div align="center">
7924da078a3Smatthiasgrimm  <form name="register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
793f3f0262cSandi  <input type="hidden" name="do" value="register" />
794f3f0262cSandi  <input type="hidden" name="save" value="1" />
795f3f0262cSandi  <fieldset>
7964da078a3Smatthiasgrimm    <legend><?php echo $lang['register']?></legend>
797*b6912aeaSAndreas Gohr    <label class="block">
7984da078a3Smatthiasgrimm      <?php echo $lang['user']?>
7994da078a3Smatthiasgrimm      <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
800f3f0262cSandi    </label><br />
801cab2716aSmatthias.grimm
802cab2716aSmatthias.grimm    <?php
803cab2716aSmatthias.grimm      if (!$conf['autopasswd']) {
804cab2716aSmatthias.grimm    ?>
805*b6912aeaSAndreas Gohr      <label class="block">
8064da078a3Smatthiasgrimm        <?php echo $lang['pass']?>
807cab2716aSmatthias.grimm        <input type="password" name="pass" class="edit" size="50" />
808cab2716aSmatthias.grimm      </label><br />
809*b6912aeaSAndreas Gohr      <label class="block">
8104da078a3Smatthiasgrimm        <?php echo $lang['passchk']?>
811cab2716aSmatthias.grimm        <input type="password" name="passchk" class="edit" size="50" />
812cab2716aSmatthias.grimm      </label><br />
813cab2716aSmatthias.grimm    <?php
814cab2716aSmatthias.grimm      }
815cab2716aSmatthias.grimm    ?>
816cab2716aSmatthias.grimm
817*b6912aeaSAndreas Gohr    <label class="block">
8184da078a3Smatthiasgrimm      <?php echo $lang['fullname']?>
8194da078a3Smatthiasgrimm      <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
820f3f0262cSandi    </label><br />
821*b6912aeaSAndreas Gohr    <label class="block">
8224da078a3Smatthiasgrimm      <?php echo $lang['email']?>
8234da078a3Smatthiasgrimm      <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
824f3f0262cSandi    </label><br />
8254da078a3Smatthiasgrimm    <input type="submit" class="button" value="<?php echo $lang['register']?>" />
826f3f0262cSandi  </fieldset>
827f3f0262cSandi  </form>
828f3f0262cSandi  </div>
8294da078a3Smatthiasgrimm<?php
830f3f0262cSandi}
831f3f0262cSandi
832f3f0262cSandi/**
833f3f0262cSandi * This displays the edit form (lots of logic included)
83415fae107Sandi *
8357146cee2SAndreas Gohr * @fixme  this is a huge lump of code and should be modularized
83615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
837f3f0262cSandi */
838f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed?
839f3f0262cSandi  global $ID;
840f3f0262cSandi  global $REV;
841f3f0262cSandi  global $DATE;
842f3f0262cSandi  global $RANGE;
843f3f0262cSandi  global $PRE;
844f3f0262cSandi  global $SUF;
845f3f0262cSandi  global $INFO;
846f3f0262cSandi  global $SUM;
847f3f0262cSandi  global $lang;
848f3f0262cSandi  global $conf;
849f3f0262cSandi
850f3f0262cSandi  //set summary default
851f3f0262cSandi  if(!$SUM){
852f3f0262cSandi    if($REV){
853f3f0262cSandi      $SUM = $lang['restored'];
854f3f0262cSandi    }elseif(!$INFO['exists']){
855f3f0262cSandi      $SUM = $lang['created'];
856f3f0262cSandi    }
857f3f0262cSandi  }
858f3f0262cSandi
859f3f0262cSandi  //no text? Load it!
860f3f0262cSandi  if(!isset($text)){
861f3f0262cSandi    $pr = false; //no preview mode
8627146cee2SAndreas Gohr    if($INFO['exists']){
863f3f0262cSandi      if($RANGE){
864f3f0262cSandi        list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
865f3f0262cSandi      }else{
866f3f0262cSandi        $text = rawWiki($ID,$REV);
867f3f0262cSandi      }
868f3f0262cSandi    }else{
8697146cee2SAndreas Gohr      //try to load a pagetemplate
8707146cee2SAndreas Gohr      $text = pageTemplate($ID);
8717146cee2SAndreas Gohr    }
8727146cee2SAndreas Gohr  }else{
873f3f0262cSandi    $pr = true; //preview mode
874f3f0262cSandi  }
875f3f0262cSandi
876f3f0262cSandi  $wr = $INFO['writable'];
877f3f0262cSandi  if($wr){
878c112d578Sandi    if ($REV) print p_locale_xhtml('editrev');
879c112d578Sandi    print p_locale_xhtml($include);
880f3f0262cSandi  }else{
881c112d578Sandi    print p_locale_xhtml('read');
882f3f0262cSandi    $ro='readonly="readonly"';
883f3f0262cSandi  }
884f3f0262cSandi  if(!$DATE) $DATE = $INFO['lastmod'];
885dc57ef04Sandi
886dc57ef04Sandi
887f3f0262cSandi?>
8884da078a3Smatthiasgrimm  <form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" onsubmit="return svchk()">
8894da078a3Smatthiasgrimm  <input type="hidden" name="id"   value="<?php echo $ID?>" />
8904da078a3Smatthiasgrimm  <input type="hidden" name="rev"  value="<?php echo $REV?>" />
8914da078a3Smatthiasgrimm  <input type="hidden" name="date" value="<?php echo $DATE?>" />
8924da078a3Smatthiasgrimm  <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" />
8934da078a3Smatthiasgrimm  <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" />
894f3f0262cSandi  <table style="width:99%">
895f3f0262cSandi    <tr>
896dc57ef04Sandi      <td class="toolbar" colspan="2">
8974da078a3Smatthiasgrimm        <?php if($wr){?>
898ea2eed85Sandi        <script language="javascript" type="text/javascript" charset="utf-8">
8994da078a3Smatthiasgrimm          <?php /* sets changed to true when previewed */?>
9004da078a3Smatthiasgrimm          textChanged = <?php ($pr) ? print 'true' : print 'false' ?>;
901f3f0262cSandi
9024da078a3Smatthiasgrimm          formatButton('bold.png','<?php echo $lang['qb_bold']?>','**','**','<?php echo $lang['qb_bold']?>','b');
9034da078a3Smatthiasgrimm          formatButton('italic.png','<?php echo $lang['qb_italic']?>',"\/\/","\/\/",'<?php echo $lang['qb_italic']?>','i');
9044da078a3Smatthiasgrimm          formatButton('underline.png','<?php echo $lang['qb_underl']?>','__','__','<?php echo $lang['qb_underl']?>','u');
9054da078a3Smatthiasgrimm          formatButton('code.png','<?php echo $lang['qb_code']?>','\'\'','\'\'','<?php echo $lang['qb_code']?>','c');
90631b5aa75SAndreas Gohr          formatButton('strike.png','<?php echo $lang['qb_strike']?>','&lt;del&gt;','&lt;\/del&gt;','<?php echo $lang['qb_strike']?>','d');
907f3f0262cSandi
9084da078a3Smatthiasgrimm          formatButton('fonth1.png','<?php echo $lang['qb_h1']?>','====== ',' ======\n','<?php echo $lang['qb_h1']?>','1');
9094da078a3Smatthiasgrimm          formatButton('fonth2.png','<?php echo $lang['qb_h2']?>','===== ',' =====\n','<?php echo $lang['qb_h2']?>','2');
9104da078a3Smatthiasgrimm          formatButton('fonth3.png','<?php echo $lang['qb_h3']?>','==== ',' ====\n','<?php echo $lang['qb_h3']?>','3');
9114da078a3Smatthiasgrimm          formatButton('fonth4.png','<?php echo $lang['qb_h4']?>','=== ',' ===\n','<?php echo $lang['qb_h4']?>','4');
9124da078a3Smatthiasgrimm          formatButton('fonth5.png','<?php echo $lang['qb_h5']?>','== ',' ==\n','<?php echo $lang['qb_h5']?>','5');
913f3f0262cSandi
9144da078a3Smatthiasgrimm          formatButton('link.png','<?php echo $lang['qb_link']?>','[[',']]','<?php echo $lang['qb_link']?>','l');
9154da078a3Smatthiasgrimm          formatButton('extlink.png','<?php echo $lang['qb_extlink']?>','[[',']]','http://www.example.com|<?php echo $lang['qb_extlink']?>');
916f3f0262cSandi
9174da078a3Smatthiasgrimm          formatButton('list.png','<?php echo $lang['qb_ol']?>','  - ','\n','<?php echo $lang['qb_ol']?>');
9184da078a3Smatthiasgrimm          formatButton('list_ul.png','<?php echo $lang['qb_ul']?>','  * ','\n','<?php echo $lang['qb_ul']?>');
919f3f0262cSandi
9204da078a3Smatthiasgrimm          insertButton('rule.png','<?php echo $lang['qb_hr']?>','----\n');
9214da078a3Smatthiasgrimm          mediaButton('image.png','<?php echo $lang['qb_media']?>','m','<?php echo $INFO['namespace']?>');
922f3f0262cSandi
9234da078a3Smatthiasgrimm          <?php
924f3f0262cSandi          if($conf['useacl'] && $_SERVER['REMOTE_USER']){
925f62ea8a1Sandi            echo "insertButton('sig.png','".$lang['qb_sig']."','".html_signature()."','y');";
926f3f0262cSandi          }
927f3f0262cSandi          ?>
928f3f0262cSandi        </script>
92958bef989Smatthiasgrimm        <span id="spell_action"></span>
9304da078a3Smatthiasgrimm        <?php } ?>
931f3f0262cSandi      </td>
932dc57ef04Sandi      <td>
933dc57ef04Sandi        <div id="spell_suggest"></div>
934f3f0262cSandi      </td>
935f3f0262cSandi    </tr>
936f3f0262cSandi    <tr>
937dc57ef04Sandi      <td colspan="3">
938dc57ef04Sandi        <div id="spell_result"></div>
9394da078a3Smatthiasgrimm        <textarea name="wikitext" id="wikitext" <?php echo $ro?> cols="80" rows="10" class="edit" onchange="textChanged = true;" onkeyup="summaryCheck();" tabindex="1"><?php echo "\n".formText($text)?></textarea>
940dc57ef04Sandi      </td>
941dc57ef04Sandi    </tr>
942dc57ef04Sandi    <tr id="wikieditbar">
943f3f0262cSandi      <td>
9444da078a3Smatthiasgrimm      <?php if($wr){?>
945*b6912aeaSAndreas Gohr        <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="4" />
946*b6912aeaSAndreas Gohr        <input class="button" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" onclick="textChanged=false" onkeypress="textChanged=false" tabindex="5" />
9474da078a3Smatthiasgrimm        <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" />
9484da078a3Smatthiasgrimm      <?php } ?>
949f3f0262cSandi      </td>
950f3f0262cSandi      <td>
9514da078a3Smatthiasgrimm      <?php if($wr){ ?>
9524da078a3Smatthiasgrimm        <?php echo $lang['summary']?>:
9534da078a3Smatthiasgrimm        <input type="text" class="edit" name="summary" id="summary" size="50" onkeyup="summaryCheck();" value="<?php echo formText($SUM)?>" tabindex="2" />
954*b6912aeaSAndreas Gohr        <?php html_minoredit()?>
9554da078a3Smatthiasgrimm      <?php }?>
956f3f0262cSandi      </td>
957f3f0262cSandi      <td align="right">
958ea2eed85Sandi        <script language="javascript" type="text/javascript" charset="utf-8">
959f3f0262cSandi          showSizeCtl();
9604da078a3Smatthiasgrimm          <?php if($wr){ ?>
9614da078a3Smatthiasgrimm            init_locktimer(<?php echo $conf['locktime']-60?>,'<?php echo $lang['willexpire']?>');
962dc57ef04Sandi
963dc57ef04Sandi            //initialize spellchecker
9644da078a3Smatthiasgrimm            <?php if($conf['spellchecker']){ ?>
9654da078a3Smatthiasgrimm              ajax_spell.init('<?php echo $lang['spell_start']?>','<?php echo $lang['spell_stop']?>','<?php echo $lang['spell_wait']?>','<?php echo $lang['spell_noerr']?>','<?php echo $lang['spell_nosug']?>','<?php echo $lang['spell_change']?>');
9664da078a3Smatthiasgrimm            <?php } ?>
967dc57ef04Sandi
968f3f0262cSandi            document.editform.wikitext.focus();
9694da078a3Smatthiasgrimm          <?php } ?>
970f3f0262cSandi        </script>
971f3f0262cSandi      </td>
972f3f0262cSandi    </tr>
973f3f0262cSandi  </table>
974f3f0262cSandi  </form>
9754da078a3Smatthiasgrimm<?php
976f3f0262cSandi}
977f3f0262cSandi
978f3f0262cSandi/**
979*b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users
980*b6912aeaSAndreas Gohr *
981*b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org>
982*b6912aeaSAndreas Gohr */
983*b6912aeaSAndreas Gohrfunction html_minoredit(){
984*b6912aeaSAndreas Gohr  global $conf;
985*b6912aeaSAndreas Gohr  global $lang;
986*b6912aeaSAndreas Gohr  // minor edits are for logged in users only
987*b6912aeaSAndreas Gohr  if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){
988*b6912aeaSAndreas Gohr    return;
989*b6912aeaSAndreas Gohr  }
990*b6912aeaSAndreas Gohr
991*b6912aeaSAndreas Gohr  $p = array();
992*b6912aeaSAndreas Gohr  $p['name']     = 'minor';
993*b6912aeaSAndreas Gohr  $p['type']     = 'checkbox';
994*b6912aeaSAndreas Gohr  $p['id']       = 'minoredit';
995*b6912aeaSAndreas Gohr  $p['tabindex'] = 3;
996*b6912aeaSAndreas Gohr  $p['value']    = '1';
997*b6912aeaSAndreas Gohr  if($_REQUEST['minor']) $p['checked']='checked';
998*b6912aeaSAndreas Gohr  $att = buildAttributes($p);
999*b6912aeaSAndreas Gohr
1000*b6912aeaSAndreas Gohr  print "<input $att />";
1001*b6912aeaSAndreas Gohr  print '<label for="minoredit">';
1002*b6912aeaSAndreas Gohr  print $lang['minoredit'];
1003*b6912aeaSAndreas Gohr  print '</label>';
1004*b6912aeaSAndreas Gohr}
1005*b6912aeaSAndreas Gohr
1006*b6912aeaSAndreas Gohr/**
1007f3f0262cSandi * prepares the signature string as configured in the config
100815fae107Sandi *
100915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
1010f3f0262cSandi */
1011f3f0262cSandifunction html_signature(){
1012f3f0262cSandi  global $conf;
1013f3f0262cSandi  global $INFO;
1014f3f0262cSandi
1015f3f0262cSandi  $sig = $conf['signature'];
1016f3f0262cSandi  $sig = strftime($sig);
1017f3f0262cSandi  $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig);
1018f3f0262cSandi  $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig);
1019f3f0262cSandi  $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig);
1020f3f0262cSandi  $sig = str_replace('@DATE@',date($conf['dformat']),$sig);
1021cad5d88aSEsther Brunner  return addslashes($sig);
1022f3f0262cSandi}
1023f3f0262cSandi
1024f3f0262cSandi/**
1025f3f0262cSandi * prints some debug info
102615fae107Sandi *
102715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
1028f3f0262cSandi */
1029f3f0262cSandifunction html_debug(){
1030f3f0262cSandi  global $conf;
1031d16a4edaSandi  global $lang;
103228fb55ffSandi  //remove sensitive data
103328fb55ffSandi  $cnf = $conf;
103428fb55ffSandi  $cnf['auth']='***';
103528fb55ffSandi  $cnf['notify']='***';
10363dc3a5f1Sandi  $cnf['ftp']='***';
1037f3f0262cSandi
1038f3f0262cSandi  print '<html><body>';
1039f3f0262cSandi
1040f3f0262cSandi  print '<p>When reporting bugs please send all the following ';
1041f3f0262cSandi  print 'output as a mail to andi@splitbrain.org ';
1042f3f0262cSandi  print 'The best way to do this is to save this page in your browser</p>';
1043f3f0262cSandi
1044f3f0262cSandi  print '<b>$_SERVER:</b><pre>';
1045f3f0262cSandi  print_r($_SERVER);
1046f3f0262cSandi  print '</pre>';
1047f3f0262cSandi
1048f3f0262cSandi  print '<b>$conf:</b><pre>';
104928fb55ffSandi  print_r($cnf);
1050f3f0262cSandi  print '</pre>';
1051f3f0262cSandi
1052ed7b5f09Sandi  print '<b>DOKU_BASE:</b><pre>';
1053ed7b5f09Sandi  print DOKU_BASE;
1054f3f0262cSandi  print '</pre>';
1055f3f0262cSandi
1056ed7b5f09Sandi  print '<b>abs DOKU_BASE:</b><pre>';
1057ed7b5f09Sandi  print DOKU_URL;
1058ed7b5f09Sandi  print '</pre>';
1059ed7b5f09Sandi
1060ed7b5f09Sandi  print '<b>rel DOKU_BASE:</b><pre>';
1061f3f0262cSandi  print dirname($_SERVER['PHP_SELF']).'/';
1062f3f0262cSandi  print '</pre>';
1063f3f0262cSandi
1064f3f0262cSandi  print '<b>PHP Version:</b><pre>';
1065f3f0262cSandi  print phpversion();
1066f3f0262cSandi  print '</pre>';
1067f3f0262cSandi
1068f3f0262cSandi  print '<b>locale:</b><pre>';
1069f3f0262cSandi  print setlocale(LC_ALL,0);
1070f3f0262cSandi  print '</pre>';
1071f3f0262cSandi
1072d16a4edaSandi  print '<b>encoding:</b><pre>';
1073d16a4edaSandi  print $lang['encoding'];
1074d16a4edaSandi  print '</pre>';
1075d16a4edaSandi
1076f3f0262cSandi  print '<b>Environment:</b><pre>';
1077f3f0262cSandi  print_r($_ENV);
1078f3f0262cSandi  print '</pre>';
1079f3f0262cSandi
1080f3f0262cSandi  print '<b>PHP settings:</b><pre>';
1081f3f0262cSandi  $inis = ini_get_all();
1082f3f0262cSandi  print_r($inis);
1083f3f0262cSandi  print '</pre>';
1084f3f0262cSandi
1085f3f0262cSandi  print '</body></html>';
1086f3f0262cSandi}
1087f3f0262cSandi
1088c19fe9c0Sandifunction html_admin(){
1089c19fe9c0Sandi  global $ID;
1090c19fe9c0Sandi  global $lang;
1091ca3a6df1SMatthias Grimm  global $conf;
1092c19fe9c0Sandi
1093c112d578Sandi  print p_locale_xhtml('admin');
1094c19fe9c0Sandi
109511e2ce22Schris  // build menu of admin functions from the plugins that handle them
109611e2ce22Schris  $pluginlist = plugin_list('admin');
109711e2ce22Schris  $menu = array();
109811e2ce22Schris  foreach ($pluginlist as $p) {
109911e2ce22Schris    if($obj =& plugin_load('admin',$p) === NULL) continue;
110011e2ce22Schris    $menu[] = array('plugin' => $p,
110111e2ce22Schris                    'prompt' => $obj->getMenuText($conf['lang']),
110211e2ce22Schris                    'sort' => $obj->getMenuSort()
110311e2ce22Schris                   );
110411e2ce22Schris  }
110511e2ce22Schris
110611e2ce22Schris  usort($menu, p_sort_modes);
110711e2ce22Schris
110811e2ce22Schris  // output the menu
110911e2ce22Schris  ptln('<ul>');
111011e2ce22Schris
111111e2ce22Schris  foreach ($menu as $item) {
111211e2ce22Schris    if (!$item['prompt']) continue;
111311e2ce22Schris    ptln('  <li><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></li>');
111411e2ce22Schris  }
111511e2ce22Schris
111611e2ce22Schris  // add in non-plugin functions
111711e2ce22Schris  if (!$conf['openregister']){
111811e2ce22Schris    ptln('<li><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></li>');
111911e2ce22Schris  }
112011e2ce22Schris
112111e2ce22Schris  ptln('</ul>');
112211e2ce22Schris
112311e2ce22Schris/*
112411e2ce22Schris  ptln('<ul>');  ptln('<ul class="admin">');
1125c19fe9c0Sandi
1126c19fe9c0Sandi  // currently ACL only - more to come
11277879fd27Sandi  ptln('<li><a href="'.wl($ID,'do=admin&amp;page=acl').'">'.$lang['admin_acl'].'</a></li>');
1128ca3a6df1SMatthias Grimm  if (!$conf['openregister']){
11295e199953Smatthiasgrimm    ptln('<li><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></li>');
1130ca3a6df1SMatthias Grimm  }
1131c19fe9c0Sandi
1132c19fe9c0Sandi  ptln('</ul>');
113311e2ce22Schris*/
1134c19fe9c0Sandi}
1135c19fe9c0Sandi
1136340756e4Sandi
1137340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 :
1138