xref: /dokuwiki/inc/html.php (revision d437bcc4a25f62fad65e625f4bc13cab8873f994)
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" />
59f3f0262cSandi        <label>
604da078a3Smatthiasgrimm          <span><?php echo $lang['user']?></span>
614da078a3Smatthiasgrimm          <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" />
62f3f0262cSandi        </label><br />
63f3f0262cSandi        <label>
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']){
395652610a2Sandi    print '<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
416f3f0262cSandi    print '<li>';
417f9b2fe70Sandi
418f9b2fe70Sandi    print $date;
419f9b2fe70Sandi
420cffcc403Sandi    print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">';
421d94f4568SAndreas Gohr    $p = array();
422d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
423d94f4568SAndreas Gohr    $p['border'] = 0;
424d94f4568SAndreas Gohr    $p['width']  = 15;
425d94f4568SAndreas Gohr    $p['height'] = 11;
426d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
427d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
428d94f4568SAndreas Gohr    $att = buildAttributes($p);
429d94f4568SAndreas Gohr    print "<img $att />";
430cffcc403Sandi    print '</a> ';
431cffcc403Sandi
432f9b2fe70Sandi    print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> ';
433f9b2fe70Sandi
434f243a77fSandi    print htmlspecialchars($info['sum']);
43588f522e9Sandi    print ' <span class="user">';
43688f522e9Sandi    if($info['user']){
43788f522e9Sandi      print $info['user'];
43888f522e9Sandi    }else{
439652610a2Sandi      print $info['ip'];
44088f522e9Sandi    }
44188f522e9Sandi    print '</span>';
442652610a2Sandi
443f3f0262cSandi    print '</li>';
444f3f0262cSandi  }
445f3f0262cSandi  print '</ul>';
446f3f0262cSandi}
447f3f0262cSandi
44815fae107Sandi/**
44915fae107Sandi * display recent changes
45015fae107Sandi *
45115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
4525749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
45315fae107Sandi */
454a39955b0Smatthiasgrimmfunction html_recent($first=0){
455f3f0262cSandi  global $conf;
456cffcc403Sandi  global $lang;
457dbb00abcSEsther Brunner  global $ID;
4585749f1ceSmatthiasgrimm  /* we need to get one additionally log entry to be able to
4595749f1ceSmatthiasgrimm   * decide if this is the last page or is there another one.
4605749f1ceSmatthiasgrimm   * This is the cheapest solution to get this information.
4615749f1ceSmatthiasgrimm   */
462dbb00abcSEsther Brunner  $recents = getRecents($first,$conf['recent'] + 1,true,getNS($ID));
4635749f1ceSmatthiasgrimm  if(count($recents) == 0 && $first != 0){
4645749f1ceSmatthiasgrimm    $first=0;
465dbb00abcSEsther Brunner    $recents = getRecents(0,$conf['recent'] + 1,true,getNS($ID));
4665749f1ceSmatthiasgrimm  }
4675749f1ceSmatthiasgrimm  $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent'];
468f3f0262cSandi
469c112d578Sandi  print p_locale_xhtml('recent');
470f3f0262cSandi  print '<ul>';
471a39955b0Smatthiasgrimm
472*d437bcc4SAndreas Gohr  foreach($recents as $recent){
473*d437bcc4SAndreas Gohr    $date = date($conf['dformat'],$recent['date']);
474f3f0262cSandi    print '<li>';
475cffcc403Sandi
476f9b2fe70Sandi    print $date.' ';
477f9b2fe70Sandi
478*d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=diff").'">';
479d94f4568SAndreas Gohr    $p = array();
480d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/diff.png';
481d94f4568SAndreas Gohr    $p['border'] = 0;
482d94f4568SAndreas Gohr    $p['width']  = 15;
483d94f4568SAndreas Gohr    $p['height'] = 11;
484d94f4568SAndreas Gohr    $p['title']  = $lang['diff'];
485d94f4568SAndreas Gohr    $p['alt']    = $lang['diff'];
486d94f4568SAndreas Gohr    $att = buildAttributes($p);
487d94f4568SAndreas Gohr    print "<img $att />";
488cffcc403Sandi    print '</a> ';
489cffcc403Sandi
490*d437bcc4SAndreas Gohr    print '<a href="'.wl($recent['id'],"do=revisions").'">';
491d94f4568SAndreas Gohr    $p = array();
492d94f4568SAndreas Gohr    $p['src']    = DOKU_BASE.'lib/images/history.png';
493d94f4568SAndreas Gohr    $p['border'] = 0;
494d94f4568SAndreas Gohr    $p['width']  = 12;
495d94f4568SAndreas Gohr    $p['height'] = 14;
496d94f4568SAndreas Gohr    $p['title']  = $lang['btn_revs'];
497d94f4568SAndreas Gohr    $p['alt']    = $lang['btn_revs'];
498d94f4568SAndreas Gohr    $att = buildAttributes($p);
499d94f4568SAndreas Gohr    print "<img $att />";
500cffcc403Sandi    print '</a> ';
501cffcc403Sandi
502*d437bcc4SAndreas Gohr    print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']);
503cffcc403Sandi
504*d437bcc4SAndreas Gohr    print ' '.htmlspecialchars($recent['sum']);
50588f522e9Sandi    print ' <span class="user">';
506*d437bcc4SAndreas Gohr    if($recent['user']){
507*d437bcc4SAndreas Gohr      print $recent['user'];
50888f522e9Sandi    }else{
509*d437bcc4SAndreas Gohr      print $recent['ip'];
51088f522e9Sandi    }
51188f522e9Sandi    print '</span>';
512cffcc403Sandi
513f3f0262cSandi    print '</li>';
514f3f0262cSandi  }
515f3f0262cSandi  print '</ul>';
516a39955b0Smatthiasgrimm
517a39955b0Smatthiasgrimm  print '<div class="pagenav">';
5185749f1ceSmatthiasgrimm  $last = $first + $conf['recent'];
519a39955b0Smatthiasgrimm  if ($first > 0) {
520a39955b0Smatthiasgrimm    $first -= $conf['recent'];
521a39955b0Smatthiasgrimm    if ($first < 0) $first = 0;
522a39955b0Smatthiasgrimm    print '<div class="pagenav-prev">';
5235749f1ceSmatthiasgrimm    print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first));
524a39955b0Smatthiasgrimm    print '</div>';
525a39955b0Smatthiasgrimm  }
5265749f1ceSmatthiasgrimm  if ($conf['recent'] < count($recents)) {
527a39955b0Smatthiasgrimm    print '<div class="pagenav-next">';
5285749f1ceSmatthiasgrimm    print html_btn('older','',"n",array('do' => 'recent', 'first' => $last));
529a39955b0Smatthiasgrimm    print '</div>';
530a39955b0Smatthiasgrimm  }
531a39955b0Smatthiasgrimm  print '</div>';
532f3f0262cSandi}
533f3f0262cSandi
53415fae107Sandi/**
53515fae107Sandi * Display page index
53615fae107Sandi *
53715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
53815fae107Sandi */
539f3f0262cSandifunction html_index($ns){
540ed7b5f09Sandi  require_once(DOKU_INC.'inc/search.php');
541f3f0262cSandi  global $conf;
542f3f0262cSandi  global $ID;
543f3f0262cSandi  $dir = $conf['datadir'];
544f3f0262cSandi  $ns  = cleanID($ns);
54530f1737dSandi  #fixme use appropriate function
546f3f0262cSandi  if(empty($ns)){
547f3f0262cSandi    $ns = dirname(str_replace(':','/',$ID));
548f3f0262cSandi    if($ns == '.') $ns ='';
549f3f0262cSandi  }
55088d3a917Sandi  $ns  = utf8_encodeFN(str_replace(':','/',$ns));
551f3f0262cSandi
552c112d578Sandi  print p_locale_xhtml('index');
553f3f0262cSandi
554f3f0262cSandi  $data = array();
555f3f0262cSandi  search($data,$conf['datadir'],'search_index',array('ns' => $ns));
556cb70c441Sandi  print html_buildlist($data,'idx','html_list_index','html_li_index');
557f3f0262cSandi}
558f3f0262cSandi
559f3f0262cSandi/**
56015fae107Sandi * Index item formatter
56115fae107Sandi *
562f3f0262cSandi * User function for html_buildlist()
56315fae107Sandi *
56415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
565f3f0262cSandi */
566f3f0262cSandifunction html_list_index($item){
567f3f0262cSandi  $ret = '';
568f3f0262cSandi  $base = ':'.$item['id'];
569f3f0262cSandi  $base = substr($base,strrpos($base,':')+1);
570f3f0262cSandi  if($item['type']=='d'){
571f3f0262cSandi    $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">';
572f3f0262cSandi    $ret .= $base;
573f3f0262cSandi    $ret .= '</a>';
574f3f0262cSandi  }else{
575f3f0262cSandi    $ret .= html_wikilink(':'.$item['id']);
576f3f0262cSandi  }
577f3f0262cSandi  return $ret;
578f3f0262cSandi}
579f3f0262cSandi
580f3f0262cSandi/**
581cb70c441Sandi * Index List item
582cb70c441Sandi *
583cb70c441Sandi * This user function is used in html_build_lidt to build the
584cb70c441Sandi * <li> tags for namespaces when displaying the page index
585cb70c441Sandi * it gives different classes to opened or closed "folders"
586cb70c441Sandi *
587cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
588cb70c441Sandi */
589cb70c441Sandifunction html_li_index($item){
590cb70c441Sandi  if($item['type'] == "f"){
591cb70c441Sandi    return '<li class="level'.$item['level'].'">';
592cb70c441Sandi  }elseif($item['open']){
593cb70c441Sandi    return '<li class="open">';
594cb70c441Sandi  }else{
595cb70c441Sandi    return '<li class="closed">';
596cb70c441Sandi  }
597cb70c441Sandi}
598cb70c441Sandi
599cb70c441Sandi/**
600cb70c441Sandi * Default List item
601cb70c441Sandi *
602cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org>
603cb70c441Sandi */
604cb70c441Sandifunction html_li_default($item){
605cb70c441Sandi  return '<li class="level'.$item['level'].'">';
606cb70c441Sandi}
607cb70c441Sandi
608cb70c441Sandi/**
60915fae107Sandi * Build an unordered list
61015fae107Sandi *
611f3f0262cSandi * Build an unordered list from the given $data array
612f3f0262cSandi * Each item in the array has to have a 'level' property
613f3f0262cSandi * the item itself gets printed by the given $func user
614cb70c441Sandi * function. The second and optional function is used to
615cb70c441Sandi * print the <li> tag. Both user function need to accept
616cb70c441Sandi * a single item.
61715fae107Sandi *
61815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
619f3f0262cSandi */
620cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){
621f3f0262cSandi  $level = 0;
622f3f0262cSandi  $opens = 0;
623f3f0262cSandi  $ret   = '';
624f3f0262cSandi
625f3f0262cSandi  foreach ($data as $item){
626f3f0262cSandi
627f3f0262cSandi    if( $item['level'] > $level ){
628f3f0262cSandi      //open new list
629df52d0feSandi      for($i=0; $i<($item['level'] - $level); $i++){
630df52d0feSandi        if ($i) $ret .= "<li class=\"clear\">\n";
631f3f0262cSandi        $ret .= "\n<ul class=\"$class\">\n";
632df52d0feSandi      }
633f3f0262cSandi    }elseif( $item['level'] < $level ){
634f3f0262cSandi      //close last item
635f3f0262cSandi      $ret .= "</li>\n";
636f3f0262cSandi      for ($i=0; $i<($level - $item['level']); $i++){
637f3f0262cSandi        //close higher lists
638f3f0262cSandi        $ret .= "</ul>\n</li>\n";
639f3f0262cSandi      }
640f3f0262cSandi    }else{
641f3f0262cSandi      //close last item
642f3f0262cSandi      $ret .= "</li>\n";
643f3f0262cSandi    }
644f3f0262cSandi
645f3f0262cSandi    //remember current level
646f3f0262cSandi    $level = $item['level'];
647f3f0262cSandi
648f3f0262cSandi    //print item
649cb70c441Sandi    $ret .= $lifunc($item); //user function
650f3f0262cSandi    $ret .= '<span class="li">';
651f3f0262cSandi    $ret .= $func($item); //user function
652f3f0262cSandi    $ret .= '</span>';
653f3f0262cSandi  }
654f3f0262cSandi
655f3f0262cSandi  //close remaining items and lists
656f3f0262cSandi  for ($i=0; $i < $level; $i++){
657f3f0262cSandi    $ret .= "</li></ul>\n";
658f3f0262cSandi  }
659f3f0262cSandi
660f3f0262cSandi  return $ret;
661f3f0262cSandi}
662f3f0262cSandi
66315fae107Sandi/**
66415fae107Sandi * display backlinks
66515fae107Sandi *
66615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
66715fae107Sandi */
668f3f0262cSandifunction html_backlinks(){
66954f4c056SAndreas Gohr  require_once(DOKU_INC.'inc/fulltext.php');
670f3f0262cSandi  global $ID;
671f3f0262cSandi  global $conf;
672f3f0262cSandi
673c112d578Sandi  print p_locale_xhtml('backlinks');
674f3f0262cSandi
67554f4c056SAndreas Gohr  $data = ft_backlinks($ID);
676f3f0262cSandi
677f3f0262cSandi  print '<ul class="idx">';
67854f4c056SAndreas Gohr  foreach($data as $blink){
679f3f0262cSandi    print '<li>';
68054f4c056SAndreas Gohr    print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink);
681f3f0262cSandi    print '</li>';
682f3f0262cSandi  }
683f3f0262cSandi  print '</ul>';
684f3f0262cSandi}
685f3f0262cSandi
68615fae107Sandi/**
68715fae107Sandi * show diff
68815fae107Sandi *
68915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
69015fae107Sandi */
691f3f0262cSandifunction html_diff($text='',$intro=true){
692ed7b5f09Sandi  require_once(DOKU_INC.'inc/DifferenceEngine.php');
693f3f0262cSandi  global $ID;
694f3f0262cSandi  global $REV;
695f3f0262cSandi  global $lang;
696f3f0262cSandi  global $conf;
697f3f0262cSandi  if($text){
698f3f0262cSandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))),
699f3f0262cSandi                    split("\n",htmlspecialchars(cleanText($text))));
700f3f0262cSandi    $left  = '<a class="wikilink1" href="'.wl($ID).'">'.
701f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'.
702f3f0262cSandi              $lang['current'];
703f3f0262cSandi    $right = $lang['yours'];
704f3f0262cSandi  }else{
7054d58bd99Sandi    if($REV){
7064d58bd99Sandi      $r = $REV;
7074d58bd99Sandi    }else{
7084d58bd99Sandi      //use last revision if none given
7094d58bd99Sandi      $revs = getRevisions($ID);
7104d58bd99Sandi      $r = $revs[0];
7114d58bd99Sandi    }
7124d58bd99Sandi
7134d58bd99Sandi    $df  = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))),
714f3f0262cSandi                    split("\n",htmlspecialchars(rawWiki($ID,''))));
7154d58bd99Sandi    $left  = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'.
7164d58bd99Sandi              $ID.' '.date($conf['dformat'],$r).'</a>';
717f3f0262cSandi    $right = '<a class="wikilink1" href="'.wl($ID).'">'.
718f3f0262cSandi              $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '.
719f3f0262cSandi              $lang['current'];
720f3f0262cSandi  }
721f3f0262cSandi  $tdf = new TableDiffFormatter();
722c112d578Sandi  if($intro) print p_locale_xhtml('diff');
723f3f0262cSandi  ?>
724f3f0262cSandi    <table class="diff" width="100%">
725f3f0262cSandi      <tr>
726f3f0262cSandi        <td colspan="2" width="50%" class="diff-header">
7274da078a3Smatthiasgrimm          <?php echo $left?>
728f3f0262cSandi        </td>
729f3f0262cSandi        <td colspan="2" width="50%" class="diff-header">
7304da078a3Smatthiasgrimm          <?php echo $right?>
731f3f0262cSandi        </td>
732f3f0262cSandi      </tr>
7334da078a3Smatthiasgrimm      <?php echo $tdf->format($df)?>
734f3f0262cSandi    </table>
7354da078a3Smatthiasgrimm  <?php
736f3f0262cSandi}
737f3f0262cSandi
73815fae107Sandi/**
73915fae107Sandi * show warning on conflict detection
74015fae107Sandi *
74115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
74215fae107Sandi */
743f3f0262cSandifunction html_conflict($text,$summary){
744f3f0262cSandi  global $ID;
745f3f0262cSandi  global $lang;
746f3f0262cSandi
747c112d578Sandi  print p_locale_xhtml('conflict');
748f3f0262cSandi  ?>
7494da078a3Smatthiasgrimm  <form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>">
7504da078a3Smatthiasgrimm  <input type="hidden" name="id" value="<?php echo $ID?>" />
7514da078a3Smatthiasgrimm  <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" />
7524da078a3Smatthiasgrimm  <input type="hidden" name="summary" value="<?php echo formText($summary)?>" />
753f3f0262cSandi
754f3f0262cSandi  <div align="center">
7554da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" />
7564da078a3Smatthiasgrimm    <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" />
757f3f0262cSandi  </div>
758f3f0262cSandi  </form>
759f3f0262cSandi  <br /><br /><br /><br />
7604da078a3Smatthiasgrimm  <?php
761f3f0262cSandi}
762f3f0262cSandi
763f3f0262cSandi/**
76415fae107Sandi * Prints the global message array
76515fae107Sandi *
76615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
767f3f0262cSandi */
768f3f0262cSandifunction html_msgarea(){
769f3f0262cSandi  global $MSG;
770f3f0262cSandi
771f3f0262cSandi  if(!isset($MSG)) return;
772f3f0262cSandi
773f3f0262cSandi  foreach($MSG as $msg){
774f3f0262cSandi    print '<div class="'.$msg['lvl'].'">';
775f3f0262cSandi    print $msg['msg'];
776f3f0262cSandi    print '</div>';
777f3f0262cSandi  }
778f3f0262cSandi}
779f3f0262cSandi
780f3f0262cSandi/**
781f3f0262cSandi * Prints the registration form
78215fae107Sandi *
78315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
784f3f0262cSandi */
785f3f0262cSandifunction html_register(){
786f3f0262cSandi  global $lang;
787cab2716aSmatthias.grimm  global $conf;
788f3f0262cSandi  global $ID;
789f3f0262cSandi
790c112d578Sandi  print p_locale_xhtml('register');
791f3f0262cSandi?>
792f3f0262cSandi  <div align="center">
7934da078a3Smatthiasgrimm  <form name="register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>">
794f3f0262cSandi  <input type="hidden" name="do" value="register" />
795f3f0262cSandi  <input type="hidden" name="save" value="1" />
796f3f0262cSandi  <fieldset>
7974da078a3Smatthiasgrimm    <legend><?php echo $lang['register']?></legend>
798f3f0262cSandi    <label>
7994da078a3Smatthiasgrimm      <?php echo $lang['user']?>
8004da078a3Smatthiasgrimm      <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" />
801f3f0262cSandi    </label><br />
802cab2716aSmatthias.grimm
803cab2716aSmatthias.grimm    <?php
804cab2716aSmatthias.grimm      if (!$conf['autopasswd']) {
805cab2716aSmatthias.grimm    ?>
806cab2716aSmatthias.grimm      <label>
8074da078a3Smatthiasgrimm        <?php echo $lang['pass']?>
808cab2716aSmatthias.grimm        <input type="password" name="pass" class="edit" size="50" />
809cab2716aSmatthias.grimm      </label><br />
810cab2716aSmatthias.grimm      <label>
8114da078a3Smatthiasgrimm        <?php echo $lang['passchk']?>
812cab2716aSmatthias.grimm        <input type="password" name="passchk" class="edit" size="50" />
813cab2716aSmatthias.grimm      </label><br />
814cab2716aSmatthias.grimm    <?php
815cab2716aSmatthias.grimm      }
816cab2716aSmatthias.grimm    ?>
817cab2716aSmatthias.grimm
818f3f0262cSandi    <label>
8194da078a3Smatthiasgrimm      <?php echo $lang['fullname']?>
8204da078a3Smatthiasgrimm      <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" />
821f3f0262cSandi    </label><br />
822f3f0262cSandi    <label>
8234da078a3Smatthiasgrimm      <?php echo $lang['email']?>
8244da078a3Smatthiasgrimm      <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" />
825f3f0262cSandi    </label><br />
8264da078a3Smatthiasgrimm    <input type="submit" class="button" value="<?php echo $lang['register']?>" />
827f3f0262cSandi  </fieldset>
828f3f0262cSandi  </form>
829f3f0262cSandi  </div>
8304da078a3Smatthiasgrimm<?php
831f3f0262cSandi}
832f3f0262cSandi
833f3f0262cSandi/**
834f3f0262cSandi * This displays the edit form (lots of logic included)
83515fae107Sandi *
8367146cee2SAndreas Gohr * @fixme  this is a huge lump of code and should be modularized
83715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
838f3f0262cSandi */
839f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed?
840f3f0262cSandi  global $ID;
841f3f0262cSandi  global $REV;
842f3f0262cSandi  global $DATE;
843f3f0262cSandi  global $RANGE;
844f3f0262cSandi  global $PRE;
845f3f0262cSandi  global $SUF;
846f3f0262cSandi  global $INFO;
847f3f0262cSandi  global $SUM;
848f3f0262cSandi  global $lang;
849f3f0262cSandi  global $conf;
850f3f0262cSandi
851f3f0262cSandi  //set summary default
852f3f0262cSandi  if(!$SUM){
853f3f0262cSandi    if($REV){
854f3f0262cSandi      $SUM = $lang['restored'];
855f3f0262cSandi    }elseif(!$INFO['exists']){
856f3f0262cSandi      $SUM = $lang['created'];
857f3f0262cSandi    }
858f3f0262cSandi  }
859f3f0262cSandi
860f3f0262cSandi  //no text? Load it!
861f3f0262cSandi  if(!isset($text)){
862f3f0262cSandi    $pr = false; //no preview mode
8637146cee2SAndreas Gohr    if($INFO['exists']){
864f3f0262cSandi      if($RANGE){
865f3f0262cSandi        list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
866f3f0262cSandi      }else{
867f3f0262cSandi        $text = rawWiki($ID,$REV);
868f3f0262cSandi      }
869f3f0262cSandi    }else{
8707146cee2SAndreas Gohr      //try to load a pagetemplate
8717146cee2SAndreas Gohr      $text = pageTemplate($ID);
8727146cee2SAndreas Gohr    }
8737146cee2SAndreas Gohr  }else{
874f3f0262cSandi    $pr = true; //preview mode
875f3f0262cSandi  }
876f3f0262cSandi
877f3f0262cSandi  $wr = $INFO['writable'];
878f3f0262cSandi  if($wr){
879c112d578Sandi    if ($REV) print p_locale_xhtml('editrev');
880c112d578Sandi    print p_locale_xhtml($include);
881f3f0262cSandi  }else{
882c112d578Sandi    print p_locale_xhtml('read');
883f3f0262cSandi    $ro='readonly="readonly"';
884f3f0262cSandi  }
885f3f0262cSandi  if(!$DATE) $DATE = $INFO['lastmod'];
886dc57ef04Sandi
887dc57ef04Sandi
888f3f0262cSandi?>
8894da078a3Smatthiasgrimm  <form name="editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" onsubmit="return svchk()">
8904da078a3Smatthiasgrimm  <input type="hidden" name="id"   value="<?php echo $ID?>" />
8914da078a3Smatthiasgrimm  <input type="hidden" name="rev"  value="<?php echo $REV?>" />
8924da078a3Smatthiasgrimm  <input type="hidden" name="date" value="<?php echo $DATE?>" />
8934da078a3Smatthiasgrimm  <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" />
8944da078a3Smatthiasgrimm  <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" />
895f3f0262cSandi  <table style="width:99%">
896f3f0262cSandi    <tr>
897dc57ef04Sandi      <td class="toolbar" colspan="2">
8984da078a3Smatthiasgrimm        <?php if($wr){?>
899ea2eed85Sandi        <script language="javascript" type="text/javascript" charset="utf-8">
9004da078a3Smatthiasgrimm          <?php /* sets changed to true when previewed */?>
9014da078a3Smatthiasgrimm          textChanged = <?php ($pr) ? print 'true' : print 'false' ?>;
902f3f0262cSandi
9034da078a3Smatthiasgrimm          formatButton('bold.png','<?php echo $lang['qb_bold']?>','**','**','<?php echo $lang['qb_bold']?>','b');
9044da078a3Smatthiasgrimm          formatButton('italic.png','<?php echo $lang['qb_italic']?>',"\/\/","\/\/",'<?php echo $lang['qb_italic']?>','i');
9054da078a3Smatthiasgrimm          formatButton('underline.png','<?php echo $lang['qb_underl']?>','__','__','<?php echo $lang['qb_underl']?>','u');
9064da078a3Smatthiasgrimm          formatButton('code.png','<?php echo $lang['qb_code']?>','\'\'','\'\'','<?php echo $lang['qb_code']?>','c');
90731b5aa75SAndreas Gohr          formatButton('strike.png','<?php echo $lang['qb_strike']?>','&lt;del&gt;','&lt;\/del&gt;','<?php echo $lang['qb_strike']?>','d');
908f3f0262cSandi
9094da078a3Smatthiasgrimm          formatButton('fonth1.png','<?php echo $lang['qb_h1']?>','====== ',' ======\n','<?php echo $lang['qb_h1']?>','1');
9104da078a3Smatthiasgrimm          formatButton('fonth2.png','<?php echo $lang['qb_h2']?>','===== ',' =====\n','<?php echo $lang['qb_h2']?>','2');
9114da078a3Smatthiasgrimm          formatButton('fonth3.png','<?php echo $lang['qb_h3']?>','==== ',' ====\n','<?php echo $lang['qb_h3']?>','3');
9124da078a3Smatthiasgrimm          formatButton('fonth4.png','<?php echo $lang['qb_h4']?>','=== ',' ===\n','<?php echo $lang['qb_h4']?>','4');
9134da078a3Smatthiasgrimm          formatButton('fonth5.png','<?php echo $lang['qb_h5']?>','== ',' ==\n','<?php echo $lang['qb_h5']?>','5');
914f3f0262cSandi
9154da078a3Smatthiasgrimm          formatButton('link.png','<?php echo $lang['qb_link']?>','[[',']]','<?php echo $lang['qb_link']?>','l');
9164da078a3Smatthiasgrimm          formatButton('extlink.png','<?php echo $lang['qb_extlink']?>','[[',']]','http://www.example.com|<?php echo $lang['qb_extlink']?>');
917f3f0262cSandi
9184da078a3Smatthiasgrimm          formatButton('list.png','<?php echo $lang['qb_ol']?>','  - ','\n','<?php echo $lang['qb_ol']?>');
9194da078a3Smatthiasgrimm          formatButton('list_ul.png','<?php echo $lang['qb_ul']?>','  * ','\n','<?php echo $lang['qb_ul']?>');
920f3f0262cSandi
9214da078a3Smatthiasgrimm          insertButton('rule.png','<?php echo $lang['qb_hr']?>','----\n');
9224da078a3Smatthiasgrimm          mediaButton('image.png','<?php echo $lang['qb_media']?>','m','<?php echo $INFO['namespace']?>');
923f3f0262cSandi
9244da078a3Smatthiasgrimm          <?php
925f3f0262cSandi          if($conf['useacl'] && $_SERVER['REMOTE_USER']){
926f62ea8a1Sandi            echo "insertButton('sig.png','".$lang['qb_sig']."','".html_signature()."','y');";
927f3f0262cSandi          }
928f3f0262cSandi          ?>
929f3f0262cSandi        </script>
93058bef989Smatthiasgrimm        <span id="spell_action"></span>
9314da078a3Smatthiasgrimm        <?php } ?>
932f3f0262cSandi      </td>
933dc57ef04Sandi      <td>
934dc57ef04Sandi        <div id="spell_suggest"></div>
935f3f0262cSandi      </td>
936f3f0262cSandi    </tr>
937f3f0262cSandi    <tr>
938dc57ef04Sandi      <td colspan="3">
939dc57ef04Sandi        <div id="spell_result"></div>
9404da078a3Smatthiasgrimm        <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>
941dc57ef04Sandi      </td>
942dc57ef04Sandi    </tr>
943dc57ef04Sandi    <tr id="wikieditbar">
944f3f0262cSandi      <td>
9454da078a3Smatthiasgrimm      <?php if($wr){?>
9464da078a3Smatthiasgrimm        <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="3" />
9474da078a3Smatthiasgrimm        <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="4" />
9484da078a3Smatthiasgrimm        <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" />
9494da078a3Smatthiasgrimm      <?php } ?>
950f3f0262cSandi      </td>
951f3f0262cSandi      <td>
9524da078a3Smatthiasgrimm      <?php if($wr){ ?>
9534da078a3Smatthiasgrimm        <?php echo $lang['summary']?>:
9544da078a3Smatthiasgrimm        <input type="text" class="edit" name="summary" id="summary" size="50" onkeyup="summaryCheck();" value="<?php echo formText($SUM)?>" tabindex="2" />
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/**
979f3f0262cSandi * prepares the signature string as configured in the config
98015fae107Sandi *
98115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
982f3f0262cSandi */
983f3f0262cSandifunction html_signature(){
984f3f0262cSandi  global $conf;
985f3f0262cSandi  global $INFO;
986f3f0262cSandi
987f3f0262cSandi  $sig = $conf['signature'];
988f3f0262cSandi  $sig = strftime($sig);
989f3f0262cSandi  $sig = str_replace('@USER@',$_SERVER['REMOTE_USER'],$sig);
990f3f0262cSandi  $sig = str_replace('@NAME@',$INFO['userinfo']['name'],$sig);
991f3f0262cSandi  $sig = str_replace('@MAIL@',$INFO['userinfo']['mail'],$sig);
992f3f0262cSandi  $sig = str_replace('@DATE@',date($conf['dformat']),$sig);
993cad5d88aSEsther Brunner  return addslashes($sig);
994f3f0262cSandi}
995f3f0262cSandi
996f3f0262cSandi/**
997f3f0262cSandi * prints some debug info
99815fae107Sandi *
99915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org>
1000f3f0262cSandi */
1001f3f0262cSandifunction html_debug(){
1002f3f0262cSandi  global $conf;
1003d16a4edaSandi  global $lang;
100428fb55ffSandi  //remove sensitive data
100528fb55ffSandi  $cnf = $conf;
100628fb55ffSandi  $cnf['auth']='***';
100728fb55ffSandi  $cnf['notify']='***';
10083dc3a5f1Sandi  $cnf['ftp']='***';
1009f3f0262cSandi
1010f3f0262cSandi  print '<html><body>';
1011f3f0262cSandi
1012f3f0262cSandi  print '<p>When reporting bugs please send all the following ';
1013f3f0262cSandi  print 'output as a mail to andi@splitbrain.org ';
1014f3f0262cSandi  print 'The best way to do this is to save this page in your browser</p>';
1015f3f0262cSandi
1016f3f0262cSandi  print '<b>$_SERVER:</b><pre>';
1017f3f0262cSandi  print_r($_SERVER);
1018f3f0262cSandi  print '</pre>';
1019f3f0262cSandi
1020f3f0262cSandi  print '<b>$conf:</b><pre>';
102128fb55ffSandi  print_r($cnf);
1022f3f0262cSandi  print '</pre>';
1023f3f0262cSandi
1024ed7b5f09Sandi  print '<b>DOKU_BASE:</b><pre>';
1025ed7b5f09Sandi  print DOKU_BASE;
1026f3f0262cSandi  print '</pre>';
1027f3f0262cSandi
1028ed7b5f09Sandi  print '<b>abs DOKU_BASE:</b><pre>';
1029ed7b5f09Sandi  print DOKU_URL;
1030ed7b5f09Sandi  print '</pre>';
1031ed7b5f09Sandi
1032ed7b5f09Sandi  print '<b>rel DOKU_BASE:</b><pre>';
1033f3f0262cSandi  print dirname($_SERVER['PHP_SELF']).'/';
1034f3f0262cSandi  print '</pre>';
1035f3f0262cSandi
1036f3f0262cSandi  print '<b>PHP Version:</b><pre>';
1037f3f0262cSandi  print phpversion();
1038f3f0262cSandi  print '</pre>';
1039f3f0262cSandi
1040f3f0262cSandi  print '<b>locale:</b><pre>';
1041f3f0262cSandi  print setlocale(LC_ALL,0);
1042f3f0262cSandi  print '</pre>';
1043f3f0262cSandi
1044d16a4edaSandi  print '<b>encoding:</b><pre>';
1045d16a4edaSandi  print $lang['encoding'];
1046d16a4edaSandi  print '</pre>';
1047d16a4edaSandi
1048f3f0262cSandi  print '<b>Environment:</b><pre>';
1049f3f0262cSandi  print_r($_ENV);
1050f3f0262cSandi  print '</pre>';
1051f3f0262cSandi
1052f3f0262cSandi  print '<b>PHP settings:</b><pre>';
1053f3f0262cSandi  $inis = ini_get_all();
1054f3f0262cSandi  print_r($inis);
1055f3f0262cSandi  print '</pre>';
1056f3f0262cSandi
1057f3f0262cSandi  print '</body></html>';
1058f3f0262cSandi}
1059f3f0262cSandi
1060c19fe9c0Sandifunction html_admin(){
1061c19fe9c0Sandi  global $ID;
1062c19fe9c0Sandi  global $lang;
1063ca3a6df1SMatthias Grimm  global $conf;
1064c19fe9c0Sandi
1065c112d578Sandi  print p_locale_xhtml('admin');
1066c19fe9c0Sandi
106711e2ce22Schris  // build menu of admin functions from the plugins that handle them
106811e2ce22Schris  $pluginlist = plugin_list('admin');
106911e2ce22Schris  $menu = array();
107011e2ce22Schris  foreach ($pluginlist as $p) {
107111e2ce22Schris    if($obj =& plugin_load('admin',$p) === NULL) continue;
107211e2ce22Schris    $menu[] = array('plugin' => $p,
107311e2ce22Schris                    'prompt' => $obj->getMenuText($conf['lang']),
107411e2ce22Schris                    'sort' => $obj->getMenuSort()
107511e2ce22Schris                   );
107611e2ce22Schris  }
107711e2ce22Schris
107811e2ce22Schris  usort($menu, p_sort_modes);
107911e2ce22Schris
108011e2ce22Schris  // output the menu
108111e2ce22Schris  ptln('<ul>');
108211e2ce22Schris
108311e2ce22Schris  foreach ($menu as $item) {
108411e2ce22Schris    if (!$item['prompt']) continue;
108511e2ce22Schris    ptln('  <li><a href="'.wl($ID, 'do=admin&amp;page='.$item['plugin']).'">'.$item['prompt'].'</a></li>');
108611e2ce22Schris  }
108711e2ce22Schris
108811e2ce22Schris  // add in non-plugin functions
108911e2ce22Schris  if (!$conf['openregister']){
109011e2ce22Schris    ptln('<li><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></li>');
109111e2ce22Schris  }
109211e2ce22Schris
109311e2ce22Schris  ptln('</ul>');
109411e2ce22Schris
109511e2ce22Schris/*
109611e2ce22Schris  ptln('<ul>');  ptln('<ul class="admin">');
1097c19fe9c0Sandi
1098c19fe9c0Sandi  // currently ACL only - more to come
10997879fd27Sandi  ptln('<li><a href="'.wl($ID,'do=admin&amp;page=acl').'">'.$lang['admin_acl'].'</a></li>');
1100ca3a6df1SMatthias Grimm  if (!$conf['openregister']){
11015e199953Smatthiasgrimm    ptln('<li><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></li>');
1102ca3a6df1SMatthias Grimm  }
1103c19fe9c0Sandi
1104c19fe9c0Sandi  ptln('</ul>');
110511e2ce22Schris*/
1106c19fe9c0Sandi}
1107c19fe9c0Sandi
1108340756e4Sandi
1109340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 :
1110