1ed7b5f09Sandi<?php 215fae107Sandi/** 315fae107Sandi * HTML output functions 415fae107Sandi * 515fae107Sandi * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 715fae107Sandi */ 815fae107Sandi 9ed7b5f09Sandi if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 10f3f0262cSandi 116bbae538Sandi require_once(DOKU_INC.'inc/parserutils.php'); 126bbae538Sandi 13f3f0262cSandi/** 14f3f0262cSandi * Convenience function to quickly build a wikilink 1515fae107Sandi * 1615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 17f3f0262cSandi */ 1830f1737dSandifunction html_wikilink($id,$name=NULL,$search=''){ 19723d78dbSandi static $xhtml_renderer = NULL; 20723d78dbSandi if(is_null($xhtml_renderer)){ 21fdf3dcb9SMatthias Urlichs require_once(DOKU_INC.'inc/parser/xhtml.php'); 22723d78dbSandi $xhtml_renderer = new Doku_Renderer_xhtml(); 23f3f0262cSandi } 24f3f0262cSandi 25cffcc403Sandi return $xhtml_renderer->internallink($id,$name,$search,true); 26f3f0262cSandi} 27f3f0262cSandi 28f3f0262cSandi/** 29c19fe9c0Sandi * Helps building long attribute lists 30c19fe9c0Sandi * 31c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 32c19fe9c0Sandi */ 33c19fe9c0Sandifunction html_attbuild($attributes){ 34c19fe9c0Sandi $ret = ''; 35c19fe9c0Sandi foreach ( $attributes as $key => $value ) { 36c19fe9c0Sandi $ret .= $key.'="'.formtext($value).'" '; 37c19fe9c0Sandi } 38c19fe9c0Sandi return trim($ret); 39c19fe9c0Sandi} 40c19fe9c0Sandi 41c19fe9c0Sandi/** 42f3f0262cSandi * The loginform 4315fae107Sandi * 4415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 45f3f0262cSandi */ 46f3f0262cSandifunction html_login(){ 47f3f0262cSandi global $lang; 48f3f0262cSandi global $conf; 49f3f0262cSandi global $ID; 50cd52f92dSchris global $auth; 51f3f0262cSandi 52c112d578Sandi print p_locale_xhtml('login'); 53f3f0262cSandi ?> 5496331712SAnika Henke <div class="centeralign"> 554da078a3Smatthiasgrimm <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 56f3f0262cSandi <fieldset> 574da078a3Smatthiasgrimm <legend><?php echo $lang['btn_login']?></legend> 584da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 59f3f0262cSandi <input type="hidden" name="do" value="login" /> 60b6912aeaSAndreas Gohr <label class="block"> 614da078a3Smatthiasgrimm <span><?php echo $lang['user']?></span> 624da078a3Smatthiasgrimm <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" /> 63f3f0262cSandi </label><br /> 64b6912aeaSAndreas Gohr <label class="block"> 654da078a3Smatthiasgrimm <span><?php echo $lang['pass']?></span> 66f3f0262cSandi <input type="password" name="p" class="edit" /> 67f3f0262cSandi </label><br /> 684da078a3Smatthiasgrimm <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" /> 690c1887a0SAndreas Gohr <label for="remember__me" class="simple"> 704d6f545eSAndreas Gohr <input type="checkbox" name="r" id="remember__me" value="1" /> 714da078a3Smatthiasgrimm <span><?php echo $lang['remember']?></span> 72132bdbfeSandi </label> 73f3f0262cSandi </fieldset> 74f3f0262cSandi </form> 754da078a3Smatthiasgrimm <?php 7682fd59b6SAndreas Gohr if($auth->canDo('addUser') && $conf['openregister']){ 77f3f0262cSandi print '<p>'; 78f3f0262cSandi print $lang['reghere']; 79f3f0262cSandi print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>'; 80f3f0262cSandi print '</p>'; 81f3f0262cSandi } 828b06d178Schris 8382fd59b6SAndreas Gohr if ($auth->canDo('modPass') && $conf['resendpasswd']) { 848b06d178Schris print '<p>'; 858b06d178Schris print $lang['pwdforget']; 86753d5abfSMatthias Grimm print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'; 878b06d178Schris print '</p>'; 888b06d178Schris } 89f3f0262cSandi ?> 90f3f0262cSandi </div> 914da078a3Smatthiasgrimm <?php 926bbae538Sandi/* 936bbae538Sandi FIXME provide new hook 94f3f0262cSandi if(@file_exists('includes/login.txt')){ 95f3f0262cSandi print io_cacheParse('includes/login.txt'); 96f3f0262cSandi } 976bbae538Sandi*/ 98f3f0262cSandi} 99f3f0262cSandi 100f3f0262cSandi/** 101ee4c4a1bSAndreas Gohr * shows the edit/source/show/draft button dependent on current mode 10215fae107Sandi * 10315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 104f3f0262cSandi */ 105f3f0262cSandifunction html_editbutton(){ 106f3f0262cSandi global $ID; 107f3f0262cSandi global $REV; 108f3f0262cSandi global $ACT; 109f3f0262cSandi global $INFO; 110f3f0262cSandi 111f3f0262cSandi if($ACT == 'show' || $ACT == 'search'){ 112f3f0262cSandi if($INFO['writable']){ 113ee4c4a1bSAndreas Gohr if($INFO['draft']){ 114ee4c4a1bSAndreas Gohr $r = html_btn('draft',$ID,'e',array('do' => 'draft'),'post'); 115ee4c4a1bSAndreas Gohr }else{ 116f3f0262cSandi if($INFO['exists']){ 117f3f0262cSandi $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 118f3f0262cSandi }else{ 119f3f0262cSandi $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 120f3f0262cSandi } 121ee4c4a1bSAndreas Gohr } 122f3f0262cSandi }else{ 123f3f0262cSandi $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 124f3f0262cSandi } 125f3f0262cSandi }else{ 126f3f0262cSandi $r = html_btn('show',$ID,'v',array('do' => 'show')); 127f3f0262cSandi } 128f3f0262cSandi return $r; 129f3f0262cSandi} 130f3f0262cSandi 13115fae107Sandi/** 13215fae107Sandi * prints a section editing button 13315fae107Sandi * 13415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 13515fae107Sandi */ 136f3f0262cSandifunction html_secedit_button($section,$p){ 137f3f0262cSandi global $ID; 138f3f0262cSandi global $lang; 139f3f0262cSandi $secedit = ''; 140506ae684Sandi# if($p) $secedit .= "</p>\n"; 141f3f0262cSandi $secedit .= '<div class="secedit">'; 142f3f0262cSandi $secedit .= html_btn('secedit',$ID,'', 143f3f0262cSandi array('do' => 'edit', 144f3f0262cSandi 'lines' => "$section"), 145f3f0262cSandi 'post'); 146f3f0262cSandi $secedit .= '</div>'; 147506ae684Sandi# if($p) $secedit .= "\n<p>"; 148f3f0262cSandi return $secedit; 149f3f0262cSandi} 150f3f0262cSandi 15115fae107Sandi/** 15215fae107Sandi * inserts section edit buttons if wanted or removes the markers 15315fae107Sandi * 15415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 15515fae107Sandi */ 156f3f0262cSandifunction html_secedit($text,$show=true){ 157f3f0262cSandi global $INFO; 158c112d578Sandi if($INFO['writable'] && $show && !$INFO['rev']){ 159f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e', 160f3f0262cSandi "html_secedit_button('\\1',true)", 161f3f0262cSandi $text); 162f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e', 163f3f0262cSandi "html_secedit_button('\\1',false)", 164f3f0262cSandi $text); 165f3f0262cSandi }else{ 166f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text); 167f3f0262cSandi } 168f3f0262cSandi return $text; 169f3f0262cSandi} 170f3f0262cSandi 171f3f0262cSandi/** 172d6c9c552Smatthiasgrimm * Just the back to top button (in its own form) 1736b13307fSandi * 1746b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 1756b13307fSandi */ 1766b13307fSandifunction html_topbtn(){ 1776b13307fSandi global $lang; 1786b13307fSandi 1796b13307fSandi $ret = ''; 1800e99f6d7SBen Coburn $ret = '<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>'; 181df7b6005Sandi 1826b13307fSandi return $ret; 1836b13307fSandi} 1846b13307fSandi 1856b13307fSandi/** 186d67ca2c0Smatthiasgrimm * Just the back to media window button in its own form 187d67ca2c0Smatthiasgrimm * 188d67ca2c0Smatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 189d67ca2c0Smatthiasgrimm */ 190d67ca2c0Smatthiasgrimmfunction html_backtomedia_button($params,$akey=''){ 191d67ca2c0Smatthiasgrimm global $conf; 192d67ca2c0Smatthiasgrimm global $lang; 193d67ca2c0Smatthiasgrimm 1943df72098SAndreas Gohr $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/mediamanager.php"><div class="no">'; 195d67ca2c0Smatthiasgrimm 196d67ca2c0Smatthiasgrimm reset($params); 197d67ca2c0Smatthiasgrimm while (list($key, $val) = each($params)) { 198d67ca2c0Smatthiasgrimm $ret .= '<input type="hidden" name="'.$key.'" '; 199d67ca2c0Smatthiasgrimm $ret .= 'value="'.htmlspecialchars($val).'" />'; 200d67ca2c0Smatthiasgrimm } 201d67ca2c0Smatthiasgrimm 202d67ca2c0Smatthiasgrimm $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" '; 203d67ca2c0Smatthiasgrimm if($akey){ 204d67ca2c0Smatthiasgrimm $ret .= 'title="ALT+'.strtoupper($akey).'" '; 205d67ca2c0Smatthiasgrimm $ret .= 'accesskey="'.$akey.'" '; 206d67ca2c0Smatthiasgrimm } 207d67ca2c0Smatthiasgrimm $ret .= '/>'; 2084beabca9SAnika Henke $ret .= '</div></form>'; 209d67ca2c0Smatthiasgrimm 210d67ca2c0Smatthiasgrimm return $ret; 211d67ca2c0Smatthiasgrimm} 212d67ca2c0Smatthiasgrimm 213d67ca2c0Smatthiasgrimm/** 214d67ca2c0Smatthiasgrimm * Displays a button (using its own form) 21515fae107Sandi * 21615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 217f3f0262cSandi */ 218f3f0262cSandifunction html_btn($name,$id,$akey,$params,$method='get'){ 219f3f0262cSandi global $conf; 220f3f0262cSandi global $lang; 221f3f0262cSandi 222f3f0262cSandi $label = $lang['btn_'.$name]; 223f3f0262cSandi 224f3f0262cSandi $ret = ''; 225f3f0262cSandi 22649c713a3Sandi //filter id (without urlencoding) 22749c713a3Sandi $id = idfilter($id,false); 228f3f0262cSandi 229f3f0262cSandi //make nice URLs even for buttons 2306c7843b5Sandi if($conf['userewrite'] == 2){ 2316c7843b5Sandi $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 2326c7843b5Sandi }elseif($conf['userewrite']){ 2336c7843b5Sandi $script = DOKU_BASE.$id; 2346c7843b5Sandi }else{ 2358b00ebcfSandi $script = DOKU_BASE.DOKU_SCRIPT; 236f3f0262cSandi $params['id'] = $id; 237f3f0262cSandi } 238f3f0262cSandi 2394beabca9SAnika Henke $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">'; 240f3f0262cSandi 24106a4bf8fSAndreas Gohr if(is_array($params)){ 242f3f0262cSandi reset($params); 243f3f0262cSandi while (list($key, $val) = each($params)) { 244f3f0262cSandi $ret .= '<input type="hidden" name="'.$key.'" '; 245f3f0262cSandi $ret .= 'value="'.htmlspecialchars($val).'" />'; 246f3f0262cSandi } 24706a4bf8fSAndreas Gohr } 248f3f0262cSandi 249f3f0262cSandi $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; 250f3f0262cSandi if($akey){ 251b1112787SBen Coburn $ret .= 'title="[ALT+'.strtoupper($akey).']" '; 252f3f0262cSandi $ret .= 'accesskey="'.$akey.'" '; 253f3f0262cSandi } 254f3f0262cSandi $ret .= '/>'; 2554beabca9SAnika Henke $ret .= '</div></form>'; 256f3f0262cSandi 257f3f0262cSandi return $ret; 258f3f0262cSandi} 259f3f0262cSandi 260f3f0262cSandi/** 26115fae107Sandi * show a wiki page 26215fae107Sandi * 26315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 26415fae107Sandi */ 2656bbae538Sandifunction html_show($txt=''){ 266f3f0262cSandi global $ID; 267f3f0262cSandi global $REV; 268f3f0262cSandi global $HIGH; 269f3f0262cSandi //disable section editing for old revisions or in preview 2705400331dSandi if($txt || $REV){ 2716bbae538Sandi $secedit = false; 2726bbae538Sandi }else{ 2736bbae538Sandi $secedit = true; 274f3f0262cSandi } 275f3f0262cSandi 2766bbae538Sandi if ($txt){ 277f3f0262cSandi //PreviewHeader 27850835be7SAndreas Gohr print '<br id="scroll__here" />'; 279c112d578Sandi print p_locale_xhtml('preview'); 280f3f0262cSandi print '<div class="preview">'; 2819dc2c2afSandi print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 28246723c19SAndreas Gohr print '<div class="clearer"></div>'; 283f3f0262cSandi print '</div>'; 2846bbae538Sandi 285f3f0262cSandi }else{ 286c112d578Sandi if ($REV) print p_locale_xhtml('showrev'); 287c112d578Sandi $html = p_wiki_xhtml($ID,$REV,true); 2886bbae538Sandi $html = html_secedit($html,$secedit); 289f3f0262cSandi print html_hilight($html,$HIGH); 290f3f0262cSandi } 291f3f0262cSandi} 292f3f0262cSandi 293f3f0262cSandi/** 294ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft 295ee4c4a1bSAndreas Gohr * 296ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 297ee4c4a1bSAndreas Gohr */ 298ee4c4a1bSAndreas Gohrfunction html_draft(){ 299ee4c4a1bSAndreas Gohr global $INFO; 300ee4c4a1bSAndreas Gohr global $ID; 301ee4c4a1bSAndreas Gohr global $lang; 302ee4c4a1bSAndreas Gohr global $conf; 303ee4c4a1bSAndreas Gohr $draft = unserialize(io_readFile($INFO['draft'],false)); 304ee4c4a1bSAndreas Gohr $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); 305ee4c4a1bSAndreas Gohr 306ee4c4a1bSAndreas Gohr echo p_locale_xhtml('draft'); 307ee4c4a1bSAndreas Gohr ?> 308ee4c4a1bSAndreas Gohr <form id="dw__editform" method="post" action="<?php echo script()?>" 309ee4c4a1bSAndreas Gohr accept-charset="<?php echo $lang['encoding']?>"><div class="no"> 310ee4c4a1bSAndreas Gohr <input type="hidden" name="id" value="<?php echo $ID?>" /> 311ee4c4a1bSAndreas Gohr <input type="hidden" name="date" value="<?php echo $draft['date']?>" /></div> 312ee4c4a1bSAndreas Gohr <textarea name="wikitext" id="wiki__text" readonly="readonly" cols="80" rows="10" class="edit"><?php echo "\n".formText($text)?></textarea> 313ee4c4a1bSAndreas Gohr 314ee4c4a1bSAndreas Gohr <div id="draft__status"><?php echo $lang['draftdate'].' '.date($conf['dformat'],filemtime($INFO['draft']))?></div> 315ee4c4a1bSAndreas Gohr 316ee4c4a1bSAndreas Gohr <input class="button" type="submit" name="do" value="<?php echo $lang['btn_recover']?>" tabindex="1" /> 317ee4c4a1bSAndreas Gohr <input class="button" type="submit" name="do" value="<?php echo $lang['btn_draftdel']?>" tabindex="2" /> 318ee4c4a1bSAndreas Gohr <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="3" /> 319ee4c4a1bSAndreas Gohr </form> 320ee4c4a1bSAndreas Gohr <?php 321ee4c4a1bSAndreas Gohr} 322ee4c4a1bSAndreas Gohr 323ee4c4a1bSAndreas Gohr/** 324f3f0262cSandi * Highlights searchqueries in HTML code 32515fae107Sandi * 32615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 3277209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 328f3f0262cSandi */ 329f3f0262cSandifunction html_hilight($html,$query){ 3307209be23SAndreas Gohr //split at common delimiters 3319d9c165eSAndreas Gohr $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY); 332f3f0262cSandi foreach ($queries as $q){ 333f3f0262cSandi $q = preg_quote($q,'/'); 3347209be23SAndreas Gohr $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html); 335f3f0262cSandi } 336f3f0262cSandi return $html; 337f3f0262cSandi} 338f3f0262cSandi 339f3f0262cSandi/** 3407209be23SAndreas Gohr * Callback used by html_hilight() 3417209be23SAndreas Gohr * 3427209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 3437209be23SAndreas Gohr */ 3447209be23SAndreas Gohrfunction html_hilight_callback($m) { 3457209be23SAndreas Gohr $hlight = unslash($m[0]); 3467209be23SAndreas Gohr if ( !isset($m[2])) { 3477209be23SAndreas Gohr $hlight = '<span class="search_hit">'.$hlight.'</span>'; 3487209be23SAndreas Gohr } 3497209be23SAndreas Gohr return $hlight; 3507209be23SAndreas Gohr} 3517209be23SAndreas Gohr 3527209be23SAndreas Gohr/** 35315fae107Sandi * Run a search and display the result 35415fae107Sandi * 35515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 356f3f0262cSandi */ 357f3f0262cSandifunction html_search(){ 358ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 359506fa893SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 360f3f0262cSandi global $conf; 361f3f0262cSandi global $QUERY; 362f3f0262cSandi global $ID; 363f3f0262cSandi global $lang; 364f3f0262cSandi 365c112d578Sandi print p_locale_xhtml('searchpage'); 366f3f0262cSandi flush(); 367f3f0262cSandi 368d0ab54f6SMichael Klier chi@chimeric.de //check if search is restricted to namespace 369d0ab54f6SMichael Klier chi@chimeric.de if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) { 370d0ab54f6SMichael Klier chi@chimeric.de $id = cleanID($match[1]); 371d0ab54f6SMichael Klier chi@chimeric.de if(empty($id)) { 372d0ab54f6SMichael Klier chi@chimeric.de print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 373d0ab54f6SMichael Klier chi@chimeric.de flush(); 374d0ab54f6SMichael Klier chi@chimeric.de return; 375d0ab54f6SMichael Klier chi@chimeric.de } 376d0ab54f6SMichael Klier chi@chimeric.de } else { 377d0ab54f6SMichael Klier chi@chimeric.de $id = cleanID($QUERY); 378d0ab54f6SMichael Klier chi@chimeric.de } 379d0ab54f6SMichael Klier chi@chimeric.de 3804d9ff3d5Sandi //show progressbar 3819edac8a8SAndreas Gohr print '<div class="centeralign" id="dw__loading">'; 3824d9ff3d5Sandi print '<br /></div>'; 3839edac8a8SAndreas Gohr print '<script type="text/javascript" charset="utf-8">'; 3849edac8a8SAndreas Gohr print 'showLoadBar("dw__loading");'; 3859edac8a8SAndreas Gohr print '</script>'; 3869edac8a8SAndreas Gohr flush(); 3874d9ff3d5Sandi 388f3f0262cSandi //do quick pagesearch 389f3f0262cSandi $data = array(); 390d0ab54f6SMichael Klier chi@chimeric.de 391d0ab54f6SMichael Klier chi@chimeric.de $data = ft_pageLookup($id); 392f3f0262cSandi if(count($data)){ 393f3f0262cSandi sort($data); 394f3f0262cSandi print '<div class="search_quickresult">'; 3954f732f0eSAnika Henke print '<h3>'.$lang[quickhits].':</h3>'; 3964f732f0eSAnika Henke print '<ul class="search_quickhits">'; 397140c93f3SAnika Henke foreach($data as $id){ 3984f732f0eSAnika Henke print '<li> '; 399506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id); 4004f732f0eSAnika Henke print '</li> '; 401f3f0262cSandi } 402140c93f3SAnika Henke print '</ul> '; 403f3f0262cSandi //clear float (see http://www.complexspiral.com/publications/containing-floats/) 404f3f0262cSandi print '<div class="clearer"> </div>'; 405f3f0262cSandi print '</div>'; 406f3f0262cSandi } 407f3f0262cSandi flush(); 408f3f0262cSandi 409f3f0262cSandi //do fulltext search 410506fa893SAndreas Gohr $data = ft_pageSearch($QUERY,$poswords); 411f3f0262cSandi if(count($data)){ 412506fa893SAndreas Gohr $num = 1; 413506fa893SAndreas Gohr foreach($data as $id => $cnt){ 414f3f0262cSandi print '<div class="search_result">'; 415506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); 416506fa893SAndreas Gohr print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 417506fa893SAndreas Gohr if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 418506fa893SAndreas Gohr print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; 419506fa893SAndreas Gohr } 420f3f0262cSandi print '</div>'; 421506fa893SAndreas Gohr flush(); 422506fa893SAndreas Gohr $num++; 423f3f0262cSandi } 424f3f0262cSandi }else{ 425820fa24bSandi print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 426f3f0262cSandi } 4274d9ff3d5Sandi 4284d9ff3d5Sandi //hide progressbar 4294beabca9SAnika Henke print '<script type="text/javascript" charset="utf-8">'; 4309edac8a8SAndreas Gohr print 'hideLoadBar("dw__loading");'; 4314d9ff3d5Sandi print '</script>'; 4329edac8a8SAndreas Gohr flush(); 433f3f0262cSandi} 434f3f0262cSandi 43515fae107Sandi/** 43615fae107Sandi * Display error on locked pages 43715fae107Sandi * 43815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 43915fae107Sandi */ 440ee20e7d1Sandifunction html_locked(){ 441f3f0262cSandi global $ID; 442f3f0262cSandi global $conf; 443f3f0262cSandi global $lang; 44488f522e9Sandi global $INFO; 445f3f0262cSandi 446f3f0262cSandi $locktime = filemtime(wikiFN($ID).'.lock'); 447f3f0262cSandi $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); 448f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 449f3f0262cSandi 450c112d578Sandi print p_locale_xhtml('locked'); 451f3f0262cSandi print '<ul>'; 4520c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>'; 4530c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 454f3f0262cSandi print '</ul>'; 455f3f0262cSandi} 456f3f0262cSandi 45715fae107Sandi/** 45815fae107Sandi * list old revisions 45915fae107Sandi * 46015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 46115fae107Sandi */ 462f3f0262cSandifunction html_revisions(){ 463f3f0262cSandi global $ID; 464f3f0262cSandi global $INFO; 465f3f0262cSandi global $conf; 466f3f0262cSandi global $lang; 467f3f0262cSandi $revisions = getRevisions($ID); 468f3f0262cSandi $date = @date($conf['dformat'],$INFO['lastmod']); 469f3f0262cSandi 470c112d578Sandi print p_locale_xhtml('revisions'); 471f3f0262cSandi print '<ul>'; 472f3f0262cSandi if($INFO['exists']){ 473b6912aeaSAndreas Gohr print ($INFO['minor']) ? '<li class="minor">' : '<li>'; 4740c6b58a8SAndreas Gohr print '<div class="li">'; 475f9b2fe70Sandi 476f9b2fe70Sandi print $date; 477f9b2fe70Sandi 47802e51121SAnika Henke print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 479cffcc403Sandi 480f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> '; 481652610a2Sandi 482652610a2Sandi print $INFO['sum']; 48388f522e9Sandi print ' <span class="user">'; 48488f522e9Sandi print $INFO['editor']; 48588f522e9Sandi print '</span> '; 486652610a2Sandi 487652610a2Sandi print '('.$lang['current'].')'; 4880c6b58a8SAndreas Gohr print '</div>'; 489652610a2Sandi print '</li>'; 490f3f0262cSandi } 491f3f0262cSandi 492f3f0262cSandi foreach($revisions as $rev){ 493f3f0262cSandi $date = date($conf['dformat'],$rev); 494652610a2Sandi $info = getRevisionInfo($ID,$rev); 495652610a2Sandi 496b6912aeaSAndreas Gohr print ($info['minor']) ? '<li class="minor">' : '<li>'; 4970c6b58a8SAndreas Gohr print '<div class="li">'; 498f9b2fe70Sandi print $date; 499f9b2fe70Sandi 500cffcc403Sandi print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">'; 501d94f4568SAndreas Gohr $p = array(); 502d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 503d94f4568SAndreas Gohr $p['width'] = 15; 504d94f4568SAndreas Gohr $p['height'] = 11; 505d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 506d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 507d94f4568SAndreas Gohr $att = buildAttributes($p); 508d94f4568SAndreas Gohr print "<img $att />"; 509cffcc403Sandi print '</a> '; 510cffcc403Sandi 511f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> '; 512f9b2fe70Sandi 513f243a77fSandi print htmlspecialchars($info['sum']); 51488f522e9Sandi print ' <span class="user">'; 51588f522e9Sandi if($info['user']){ 51688f522e9Sandi print $info['user']; 51788f522e9Sandi }else{ 518652610a2Sandi print $info['ip']; 51988f522e9Sandi } 52088f522e9Sandi print '</span>'; 521652610a2Sandi 5220c6b58a8SAndreas Gohr print '</div>'; 523f3f0262cSandi print '</li>'; 524f3f0262cSandi } 525f3f0262cSandi print '</ul>'; 526f3f0262cSandi} 527f3f0262cSandi 52815fae107Sandi/** 52915fae107Sandi * display recent changes 53015fae107Sandi * 53115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 5325749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 53315fae107Sandi */ 534a39955b0Smatthiasgrimmfunction html_recent($first=0){ 535f3f0262cSandi global $conf; 536cffcc403Sandi global $lang; 537dbb00abcSEsther Brunner global $ID; 5385749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 5395749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 5405749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 5415749f1ceSmatthiasgrimm */ 542b6912aeaSAndreas Gohr $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 5435749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0){ 5445749f1ceSmatthiasgrimm $first=0; 545b6912aeaSAndreas Gohr $recents = getRecents(0,$conf['recent'] + 1,getNS($ID)); 5465749f1ceSmatthiasgrimm } 5475749f1ceSmatthiasgrimm $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; 548f3f0262cSandi 549c112d578Sandi print p_locale_xhtml('recent'); 550f3f0262cSandi print '<ul>'; 551a39955b0Smatthiasgrimm 552d437bcc4SAndreas Gohr foreach($recents as $recent){ 553d437bcc4SAndreas Gohr $date = date($conf['dformat'],$recent['date']); 554b6912aeaSAndreas Gohr print ($recent['minor']) ? '<li class="minor">' : '<li>'; 5550c6b58a8SAndreas Gohr print '<div class="li">'; 556cffcc403Sandi 557f9b2fe70Sandi print $date.' '; 558f9b2fe70Sandi 559d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=diff").'">'; 560d94f4568SAndreas Gohr $p = array(); 561d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 562d94f4568SAndreas Gohr $p['width'] = 15; 563d94f4568SAndreas Gohr $p['height'] = 11; 564d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 565d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 566d94f4568SAndreas Gohr $att = buildAttributes($p); 567d94f4568SAndreas Gohr print "<img $att />"; 568cffcc403Sandi print '</a> '; 569cffcc403Sandi 570d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=revisions").'">'; 571d94f4568SAndreas Gohr $p = array(); 572d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/history.png'; 573d94f4568SAndreas Gohr $p['width'] = 12; 574d94f4568SAndreas Gohr $p['height'] = 14; 575d94f4568SAndreas Gohr $p['title'] = $lang['btn_revs']; 576d94f4568SAndreas Gohr $p['alt'] = $lang['btn_revs']; 577d94f4568SAndreas Gohr $att = buildAttributes($p); 578d94f4568SAndreas Gohr print "<img $att />"; 579cffcc403Sandi print '</a> '; 580cffcc403Sandi 581d437bcc4SAndreas Gohr print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 582d437bcc4SAndreas Gohr print ' '.htmlspecialchars($recent['sum']); 583b6912aeaSAndreas Gohr 58488f522e9Sandi print ' <span class="user">'; 585d437bcc4SAndreas Gohr if($recent['user']){ 586d437bcc4SAndreas Gohr print $recent['user']; 58788f522e9Sandi }else{ 588d437bcc4SAndreas Gohr print $recent['ip']; 58988f522e9Sandi } 59088f522e9Sandi print '</span>'; 591cffcc403Sandi 5920c6b58a8SAndreas Gohr print '</div>'; 593f3f0262cSandi print '</li>'; 594f3f0262cSandi } 595f3f0262cSandi print '</ul>'; 596a39955b0Smatthiasgrimm 597a39955b0Smatthiasgrimm print '<div class="pagenav">'; 5985749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 599a39955b0Smatthiasgrimm if ($first > 0) { 600a39955b0Smatthiasgrimm $first -= $conf['recent']; 601a39955b0Smatthiasgrimm if ($first < 0) $first = 0; 602a39955b0Smatthiasgrimm print '<div class="pagenav-prev">'; 6035749f1ceSmatthiasgrimm print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); 604a39955b0Smatthiasgrimm print '</div>'; 605a39955b0Smatthiasgrimm } 6065749f1ceSmatthiasgrimm if ($conf['recent'] < count($recents)) { 607a39955b0Smatthiasgrimm print '<div class="pagenav-next">'; 6085749f1ceSmatthiasgrimm print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); 609a39955b0Smatthiasgrimm print '</div>'; 610a39955b0Smatthiasgrimm } 611a39955b0Smatthiasgrimm print '</div>'; 612f3f0262cSandi} 613f3f0262cSandi 61415fae107Sandi/** 61515fae107Sandi * Display page index 61615fae107Sandi * 61715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 61815fae107Sandi */ 619f3f0262cSandifunction html_index($ns){ 620ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 621f3f0262cSandi global $conf; 622f3f0262cSandi global $ID; 623f3f0262cSandi $dir = $conf['datadir']; 624f3f0262cSandi $ns = cleanID($ns); 62530f1737dSandi #fixme use appropriate function 626f3f0262cSandi if(empty($ns)){ 627f3f0262cSandi $ns = dirname(str_replace(':','/',$ID)); 628f3f0262cSandi if($ns == '.') $ns =''; 629f3f0262cSandi } 63088d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 631f3f0262cSandi 632c112d578Sandi print p_locale_xhtml('index'); 633f3f0262cSandi 634f3f0262cSandi $data = array(); 635f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 636cb70c441Sandi print html_buildlist($data,'idx','html_list_index','html_li_index'); 637f3f0262cSandi} 638f3f0262cSandi 639f3f0262cSandi/** 64015fae107Sandi * Index item formatter 64115fae107Sandi * 642f3f0262cSandi * User function for html_buildlist() 64315fae107Sandi * 64415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 645f3f0262cSandi */ 646f3f0262cSandifunction html_list_index($item){ 647f3f0262cSandi $ret = ''; 648f3f0262cSandi $base = ':'.$item['id']; 649f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 650f3f0262cSandi if($item['type']=='d'){ 651f3f0262cSandi $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">'; 652f3f0262cSandi $ret .= $base; 653f3f0262cSandi $ret .= '</a>'; 654f3f0262cSandi }else{ 655f3f0262cSandi $ret .= html_wikilink(':'.$item['id']); 656f3f0262cSandi } 657f3f0262cSandi return $ret; 658f3f0262cSandi} 659f3f0262cSandi 660f3f0262cSandi/** 661cb70c441Sandi * Index List item 662cb70c441Sandi * 663cb70c441Sandi * This user function is used in html_build_lidt to build the 664cb70c441Sandi * <li> tags for namespaces when displaying the page index 665cb70c441Sandi * it gives different classes to opened or closed "folders" 666cb70c441Sandi * 667cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 668cb70c441Sandi */ 669cb70c441Sandifunction html_li_index($item){ 670cb70c441Sandi if($item['type'] == "f"){ 671cb70c441Sandi return '<li class="level'.$item['level'].'">'; 672cb70c441Sandi }elseif($item['open']){ 673cb70c441Sandi return '<li class="open">'; 674cb70c441Sandi }else{ 675cb70c441Sandi return '<li class="closed">'; 676cb70c441Sandi } 677cb70c441Sandi} 678cb70c441Sandi 679cb70c441Sandi/** 680cb70c441Sandi * Default List item 681cb70c441Sandi * 682cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 683cb70c441Sandi */ 684cb70c441Sandifunction html_li_default($item){ 685cb70c441Sandi return '<li class="level'.$item['level'].'">'; 686cb70c441Sandi} 687cb70c441Sandi 688cb70c441Sandi/** 68915fae107Sandi * Build an unordered list 69015fae107Sandi * 691f3f0262cSandi * Build an unordered list from the given $data array 692f3f0262cSandi * Each item in the array has to have a 'level' property 693f3f0262cSandi * the item itself gets printed by the given $func user 694cb70c441Sandi * function. The second and optional function is used to 695cb70c441Sandi * print the <li> tag. Both user function need to accept 696cb70c441Sandi * a single item. 69715fae107Sandi * 698c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to 699c5a8fd96SAndreas Gohr * a member of an object. 700c5a8fd96SAndreas Gohr * 70115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 702f3f0262cSandi */ 703cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 704f3f0262cSandi $level = 0; 705f3f0262cSandi $opens = 0; 706f3f0262cSandi $ret = ''; 707f3f0262cSandi 708f3f0262cSandi foreach ($data as $item){ 709f3f0262cSandi 710f3f0262cSandi if( $item['level'] > $level ){ 711f3f0262cSandi //open new list 712df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 713df52d0feSandi if ($i) $ret .= "<li class=\"clear\">\n"; 714f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 715df52d0feSandi } 716f3f0262cSandi }elseif( $item['level'] < $level ){ 717f3f0262cSandi //close last item 718f3f0262cSandi $ret .= "</li>\n"; 719f3f0262cSandi for ($i=0; $i<($level - $item['level']); $i++){ 720f3f0262cSandi //close higher lists 721f3f0262cSandi $ret .= "</ul>\n</li>\n"; 722f3f0262cSandi } 723f3f0262cSandi }else{ 724f3f0262cSandi //close last item 725f3f0262cSandi $ret .= "</li>\n"; 726f3f0262cSandi } 727f3f0262cSandi 728f3f0262cSandi //remember current level 729f3f0262cSandi $level = $item['level']; 730f3f0262cSandi 731f3f0262cSandi //print item 732c5a8fd96SAndreas Gohr if(is_array($lifunc)){ 733c5a8fd96SAndreas Gohr $ret .= $lifunc[0]->$lifunc[1]($item); //user object method 734c5a8fd96SAndreas Gohr }else{ 735cb70c441Sandi $ret .= $lifunc($item); //user function 736c5a8fd96SAndreas Gohr } 7370c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 738c5a8fd96SAndreas Gohr if(is_array($func)){ 739c5a8fd96SAndreas Gohr $ret .= $func[0]->$func[1]($item); //user object method 740c5a8fd96SAndreas Gohr }else{ 741f3f0262cSandi $ret .= $func($item); //user function 742c5a8fd96SAndreas Gohr } 7430c6b58a8SAndreas Gohr $ret .= '</div>'; 744f3f0262cSandi } 745f3f0262cSandi 746f3f0262cSandi //close remaining items and lists 747f3f0262cSandi for ($i=0; $i < $level; $i++){ 748f3f0262cSandi $ret .= "</li></ul>\n"; 749f3f0262cSandi } 750f3f0262cSandi 751f3f0262cSandi return $ret; 752f3f0262cSandi} 753f3f0262cSandi 75415fae107Sandi/** 75515fae107Sandi * display backlinks 75615fae107Sandi * 75715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 75815fae107Sandi */ 759f3f0262cSandifunction html_backlinks(){ 76054f4c056SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 761f3f0262cSandi global $ID; 762f3f0262cSandi global $conf; 763f3f0262cSandi 764c112d578Sandi print p_locale_xhtml('backlinks'); 765f3f0262cSandi 76654f4c056SAndreas Gohr $data = ft_backlinks($ID); 767f3f0262cSandi 768f3f0262cSandi print '<ul class="idx">'; 76954f4c056SAndreas Gohr foreach($data as $blink){ 7700c6b58a8SAndreas Gohr print '<li><div class="li">'; 77154f4c056SAndreas Gohr print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 7720c6b58a8SAndreas Gohr print '</div></li>'; 773f3f0262cSandi } 774f3f0262cSandi print '</ul>'; 775f3f0262cSandi} 776f3f0262cSandi 77715fae107Sandi/** 77815fae107Sandi * show diff 77915fae107Sandi * 78015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 78115fae107Sandi */ 782f3f0262cSandifunction html_diff($text='',$intro=true){ 783ed7b5f09Sandi require_once(DOKU_INC.'inc/DifferenceEngine.php'); 784f3f0262cSandi global $ID; 785f3f0262cSandi global $REV; 786f3f0262cSandi global $lang; 787f3f0262cSandi global $conf; 788f3f0262cSandi if($text){ 789f3f0262cSandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), 790f3f0262cSandi split("\n",htmlspecialchars(cleanText($text)))); 791f3f0262cSandi $left = '<a class="wikilink1" href="'.wl($ID).'">'. 792f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'. 793f3f0262cSandi $lang['current']; 794f3f0262cSandi $right = $lang['yours']; 795f3f0262cSandi }else{ 7964d58bd99Sandi if($REV){ 7974d58bd99Sandi $r = $REV; 7984d58bd99Sandi }else{ 7994d58bd99Sandi //use last revision if none given 8004d58bd99Sandi $revs = getRevisions($ID); 8014d58bd99Sandi $r = $revs[0]; 8024d58bd99Sandi } 8034d58bd99Sandi 8044d58bd99Sandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))), 805f3f0262cSandi split("\n",htmlspecialchars(rawWiki($ID,'')))); 8064d58bd99Sandi $left = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'. 8074d58bd99Sandi $ID.' '.date($conf['dformat'],$r).'</a>'; 808f3f0262cSandi $right = '<a class="wikilink1" href="'.wl($ID).'">'. 809f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 810f3f0262cSandi $lang['current']; 811f3f0262cSandi } 812f3f0262cSandi $tdf = new TableDiffFormatter(); 813c112d578Sandi if($intro) print p_locale_xhtml('diff'); 814f3f0262cSandi ?> 815daf4ca4eSAnika Henke <table class="diff"> 816f3f0262cSandi <tr> 817daf4ca4eSAnika Henke <th colspan="2"> 8184da078a3Smatthiasgrimm <?php echo $left?> 819daf4ca4eSAnika Henke </th> 820daf4ca4eSAnika Henke <th colspan="2"> 8214da078a3Smatthiasgrimm <?php echo $right?> 822daf4ca4eSAnika Henke </th> 823f3f0262cSandi </tr> 8244da078a3Smatthiasgrimm <?php echo $tdf->format($df)?> 825f3f0262cSandi </table> 8264da078a3Smatthiasgrimm <?php 827f3f0262cSandi} 828f3f0262cSandi 82915fae107Sandi/** 83015fae107Sandi * show warning on conflict detection 83115fae107Sandi * 83215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 83315fae107Sandi */ 834f3f0262cSandifunction html_conflict($text,$summary){ 835f3f0262cSandi global $ID; 836f3f0262cSandi global $lang; 837f3f0262cSandi 838c112d578Sandi print p_locale_xhtml('conflict'); 839f3f0262cSandi ?> 8401dd0c202SAnika Henke <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 84196331712SAnika Henke <div class="centeralign"> 8424da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 8434da078a3Smatthiasgrimm <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" /> 8444da078a3Smatthiasgrimm <input type="hidden" name="summary" value="<?php echo formText($summary)?>" /> 845f3f0262cSandi 8464da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" /> 8474da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" /> 848f3f0262cSandi </div> 849f3f0262cSandi </form> 850f3f0262cSandi <br /><br /><br /><br /> 8514da078a3Smatthiasgrimm <?php 852f3f0262cSandi} 853f3f0262cSandi 854f3f0262cSandi/** 85515fae107Sandi * Prints the global message array 85615fae107Sandi * 85715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 858f3f0262cSandi */ 859f3f0262cSandifunction html_msgarea(){ 860f3f0262cSandi global $MSG; 861f3f0262cSandi 862f3f0262cSandi if(!isset($MSG)) return; 863f3f0262cSandi 864f3f0262cSandi foreach($MSG as $msg){ 865f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 866f3f0262cSandi print $msg['msg']; 867f3f0262cSandi print '</div>'; 868f3f0262cSandi } 869f3f0262cSandi} 870f3f0262cSandi 871f3f0262cSandi/** 872f3f0262cSandi * Prints the registration form 87315fae107Sandi * 87415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 875f3f0262cSandi */ 876f3f0262cSandifunction html_register(){ 877f3f0262cSandi global $lang; 878cab2716aSmatthias.grimm global $conf; 879f3f0262cSandi global $ID; 880f3f0262cSandi 881c112d578Sandi print p_locale_xhtml('register'); 882f3f0262cSandi?> 88396331712SAnika Henke <div class="centeralign"> 8841dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 88596331712SAnika Henke <fieldset> 886f3f0262cSandi <input type="hidden" name="do" value="register" /> 887f3f0262cSandi <input type="hidden" name="save" value="1" /> 88896331712SAnika Henke 8894da078a3Smatthiasgrimm <legend><?php echo $lang['register']?></legend> 890b6912aeaSAndreas Gohr <label class="block"> 8914da078a3Smatthiasgrimm <?php echo $lang['user']?> 8924da078a3Smatthiasgrimm <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" /> 893f3f0262cSandi </label><br /> 894cab2716aSmatthias.grimm 895cab2716aSmatthias.grimm <?php 896cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 897cab2716aSmatthias.grimm ?> 898b6912aeaSAndreas Gohr <label class="block"> 8994da078a3Smatthiasgrimm <?php echo $lang['pass']?> 900cab2716aSmatthias.grimm <input type="password" name="pass" class="edit" size="50" /> 901cab2716aSmatthias.grimm </label><br /> 902b6912aeaSAndreas Gohr <label class="block"> 9034da078a3Smatthiasgrimm <?php echo $lang['passchk']?> 904cab2716aSmatthias.grimm <input type="password" name="passchk" class="edit" size="50" /> 905cab2716aSmatthias.grimm </label><br /> 906cab2716aSmatthias.grimm <?php 907cab2716aSmatthias.grimm } 908cab2716aSmatthias.grimm ?> 909cab2716aSmatthias.grimm 910b6912aeaSAndreas Gohr <label class="block"> 9114da078a3Smatthiasgrimm <?php echo $lang['fullname']?> 9124da078a3Smatthiasgrimm <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 913f3f0262cSandi </label><br /> 914b6912aeaSAndreas Gohr <label class="block"> 9154da078a3Smatthiasgrimm <?php echo $lang['email']?> 9164da078a3Smatthiasgrimm <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 917f3f0262cSandi </label><br /> 9184da078a3Smatthiasgrimm <input type="submit" class="button" value="<?php echo $lang['register']?>" /> 919f3f0262cSandi </fieldset> 920f3f0262cSandi </form> 921f3f0262cSandi </div> 9224da078a3Smatthiasgrimm<?php 923f3f0262cSandi} 924f3f0262cSandi 925f3f0262cSandi/** 9268b06d178Schris * Print the update profile form 9278b06d178Schris * 9288b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 9298b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 9308b06d178Schris */ 9318b06d178Schrisfunction html_updateprofile(){ 9328b06d178Schris global $lang; 9338b06d178Schris global $conf; 9348b06d178Schris global $ID; 9358b06d178Schris global $INFO; 93682fd59b6SAndreas Gohr global $auth; 9378b06d178Schris 9388b06d178Schris print p_locale_xhtml('updateprofile'); 9398b06d178Schris 9408b06d178Schris if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 9418b06d178Schris if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 9428b06d178Schris?> 94396331712SAnika Henke <div class="centeralign"> 9441dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 94596331712SAnika Henke <fieldset style="width: 80%;"> 9468b06d178Schris <input type="hidden" name="do" value="profile" /> 9478b06d178Schris <input type="hidden" name="save" value="1" /> 94896331712SAnika Henke 9498b06d178Schris <legend><?php echo $lang['profile']?></legend> 9508b06d178Schris <label class="block"> 9518b06d178Schris <?php echo $lang['user']?> 9528b06d178Schris <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" /> 9538b06d178Schris </label><br /> 9548b06d178Schris <label class="block"> 9558b06d178Schris <?php echo $lang['fullname']?> 95682fd59b6SAndreas Gohr <input type="text" name="fullname" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 9578b06d178Schris </label><br /> 9588b06d178Schris <label class="block"> 9598b06d178Schris <?php echo $lang['email']?> 96082fd59b6SAndreas Gohr <input type="text" name="email" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 9618b06d178Schris </label><br /><br /> 96282fd59b6SAndreas Gohr 96382fd59b6SAndreas Gohr <?php if($auth->canDo('modPass')) { ?> 9648b06d178Schris <label class="block"> 9658b06d178Schris <?php echo $lang['newpass']?> 9668b06d178Schris <input type="password" name="newpass" class="edit" size="50" /> 9678b06d178Schris </label><br /> 9688b06d178Schris <label class="block"> 9698b06d178Schris <?php echo $lang['passchk']?> 9708b06d178Schris <input type="password" name="passchk" class="edit" size="50" /> 9718b06d178Schris </label><br /> 97282fd59b6SAndreas Gohr <?php } ?> 9738b06d178Schris 9748b06d178Schris <?php if ($conf['profileconfirm']) { ?> 9758b06d178Schris <br /> 9768b06d178Schris <label class="block"> 9778b06d178Schris <?php echo $lang['oldpass']?> 9788b06d178Schris <input type="password" name="oldpass" class="edit" size="50" /> 9798b06d178Schris </label><br /> 9808b06d178Schris <?php } ?> 9818b06d178Schris 9824cb79657SMatthias Grimm <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" /> 9838b06d178Schris <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" /> 9848b06d178Schris </fieldset> 9858b06d178Schris </form> 9868b06d178Schris </div> 9878b06d178Schris<?php 9888b06d178Schris} 9898b06d178Schris 9908b06d178Schris/** 991f3f0262cSandi * This displays the edit form (lots of logic included) 99215fae107Sandi * 9937146cee2SAndreas Gohr * @fixme this is a huge lump of code and should be modularized 99415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 995f3f0262cSandi */ 996f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed? 997f3f0262cSandi global $ID; 998f3f0262cSandi global $REV; 999f3f0262cSandi global $DATE; 1000f3f0262cSandi global $RANGE; 1001f3f0262cSandi global $PRE; 1002f3f0262cSandi global $SUF; 1003f3f0262cSandi global $INFO; 1004f3f0262cSandi global $SUM; 1005f3f0262cSandi global $lang; 1006f3f0262cSandi global $conf; 1007f3f0262cSandi 1008f3f0262cSandi //set summary default 1009f3f0262cSandi if(!$SUM){ 1010f3f0262cSandi if($REV){ 1011f3f0262cSandi $SUM = $lang['restored']; 1012f3f0262cSandi }elseif(!$INFO['exists']){ 1013f3f0262cSandi $SUM = $lang['created']; 1014f3f0262cSandi } 1015f3f0262cSandi } 1016f3f0262cSandi 1017f3f0262cSandi //no text? Load it! 1018f3f0262cSandi if(!isset($text)){ 1019f3f0262cSandi $pr = false; //no preview mode 10207146cee2SAndreas Gohr if($INFO['exists']){ 1021f3f0262cSandi if($RANGE){ 1022f3f0262cSandi list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 1023f3f0262cSandi }else{ 1024f3f0262cSandi $text = rawWiki($ID,$REV); 1025f3f0262cSandi } 1026f3f0262cSandi }else{ 10277146cee2SAndreas Gohr //try to load a pagetemplate 10287146cee2SAndreas Gohr $text = pageTemplate($ID); 10297146cee2SAndreas Gohr } 10307146cee2SAndreas Gohr }else{ 1031f3f0262cSandi $pr = true; //preview mode 1032f3f0262cSandi } 1033f3f0262cSandi 1034f3f0262cSandi $wr = $INFO['writable']; 1035f3f0262cSandi if($wr){ 1036c112d578Sandi if ($REV) print p_locale_xhtml('editrev'); 1037c112d578Sandi print p_locale_xhtml($include); 1038f3f0262cSandi }else{ 1039c112d578Sandi print p_locale_xhtml('read'); 1040f3f0262cSandi $ro='readonly="readonly"'; 1041f3f0262cSandi } 1042f3f0262cSandi if(!$DATE) $DATE = $INFO['lastmod']; 1043dc57ef04Sandi 1044dc57ef04Sandi 1045f3f0262cSandi?> 104663afe2a6SAnika Henke <div style="width:99%;"> 104742c7abd6SAndreas Gohr 104863afe2a6SAnika Henke <div class="toolbar"> 1049ee4c4a1bSAndreas Gohr <div id="draft__status"><?php if($INFO['draft']) echo $lang['draftdate'].' '.date($conf['dformat']);?></div> 1050*ee379fa4SAndreas Gohr <div id="tool__bar"><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 105172f0e11fSAndreas Gohr target="_blank"><?php echo $lang['mediaselect'] ?></a></div> 105220d062caSAndreas Gohr 10534da078a3Smatthiasgrimm <?php if($wr){?> 10544beabca9SAnika Henke <script type="text/javascript" charset="utf-8"> 10554da078a3Smatthiasgrimm <?php /* sets changed to true when previewed */?> 10564da078a3Smatthiasgrimm textChanged = <?php ($pr) ? print 'true' : print 'false' ?>; 1057f3f0262cSandi </script> 105824a33b42SAndreas Gohr <span id="spell__action"></span> 105924a33b42SAndreas Gohr <div id="spell__suggest"></div> 1060ee4c4a1bSAndreas Gohr <?php } ?> 106163afe2a6SAnika Henke </div> 106224a33b42SAndreas Gohr <div id="spell__result"></div> 106363afe2a6SAnika Henke 106442c7abd6SAndreas Gohr 106542c7abd6SAndreas Gohr <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"><div class="no"> 106642c7abd6SAndreas Gohr <input type="hidden" name="id" value="<?php echo $ID?>" /> 106742c7abd6SAndreas Gohr <input type="hidden" name="rev" value="<?php echo $REV?>" /> 106842c7abd6SAndreas Gohr <input type="hidden" name="date" value="<?php echo $DATE?>" /> 106942c7abd6SAndreas Gohr <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" /> 107042c7abd6SAndreas Gohr <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" /> 107142c7abd6SAndreas Gohr </div> 107242c7abd6SAndreas Gohr 107324a33b42SAndreas Gohr <textarea name="wikitext" id="wiki__text" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea> 107463afe2a6SAnika Henke 107524a33b42SAndreas Gohr <div id="wiki__editbar"> 107624a33b42SAndreas Gohr <div id="size__ctl"></div> 10774da078a3Smatthiasgrimm <?php if($wr){?> 1078fa24fadbSAnika Henke <div class="editButtons"> 107924a33b42SAndreas Gohr <input class="button" id="edbtn__save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" /> 108024a33b42SAndreas Gohr <input class="button" id="edbtn__preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" /> 108142c7abd6SAndreas Gohr <input class="button" type="submit" name="do[draftdel]" value="<?php echo $lang['btn_cancel']?>" tabindex="6" /> 1082fa24fadbSAnika Henke </div> 10834da078a3Smatthiasgrimm <?php } ?> 10844da078a3Smatthiasgrimm <?php if($wr){ ?> 1085fa24fadbSAnika Henke <div class="summary"> 108624a33b42SAndreas Gohr <label for="edit__summary" class="nowrap"><?php echo $lang['summary']?>:</label> 108724a33b42SAndreas Gohr <input type="text" class="edit" name="summary" id="edit__summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" /> 1088b6912aeaSAndreas Gohr <?php html_minoredit()?> 1089fa24fadbSAnika Henke </div> 10904da078a3Smatthiasgrimm <?php }?> 109163afe2a6SAnika Henke </div> 109242c7abd6SAndreas Gohr </form> 109363afe2a6SAnika Henke </div> 10944da078a3Smatthiasgrimm<?php 1095f3f0262cSandi} 1096f3f0262cSandi 1097f3f0262cSandi/** 1098b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1099b6912aeaSAndreas Gohr * 1100b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org> 1101b6912aeaSAndreas Gohr */ 1102b6912aeaSAndreas Gohrfunction html_minoredit(){ 1103b6912aeaSAndreas Gohr global $conf; 1104b6912aeaSAndreas Gohr global $lang; 1105b6912aeaSAndreas Gohr // minor edits are for logged in users only 1106b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1107b6912aeaSAndreas Gohr return; 1108b6912aeaSAndreas Gohr } 1109b6912aeaSAndreas Gohr 1110b6912aeaSAndreas Gohr $p = array(); 1111b6912aeaSAndreas Gohr $p['name'] = 'minor'; 1112b6912aeaSAndreas Gohr $p['type'] = 'checkbox'; 1113b6912aeaSAndreas Gohr $p['id'] = 'minoredit'; 1114b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1115b6912aeaSAndreas Gohr $p['value'] = '1'; 1116b6912aeaSAndreas Gohr if($_REQUEST['minor']) $p['checked']='checked'; 1117b6912aeaSAndreas Gohr $att = buildAttributes($p); 1118b6912aeaSAndreas Gohr 1119fa24fadbSAnika Henke print '<span class="nowrap">'; 1120b6912aeaSAndreas Gohr print "<input $att />"; 1121b6912aeaSAndreas Gohr print '<label for="minoredit">'; 1122b6912aeaSAndreas Gohr print $lang['minoredit']; 1123b6912aeaSAndreas Gohr print '</label>'; 1124fa24fadbSAnika Henke print '</span>'; 1125b6912aeaSAndreas Gohr} 1126b6912aeaSAndreas Gohr 1127b6912aeaSAndreas Gohr/** 1128f3f0262cSandi * prints some debug info 112915fae107Sandi * 113015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1131f3f0262cSandi */ 1132f3f0262cSandifunction html_debug(){ 1133f3f0262cSandi global $conf; 1134d16a4edaSandi global $lang; 11355298a619SAndreas Gohr global $auth; 113628fb55ffSandi //remove sensitive data 113728fb55ffSandi $cnf = $conf; 113828fb55ffSandi $cnf['auth']='***'; 113928fb55ffSandi $cnf['notify']='***'; 11403dc3a5f1Sandi $cnf['ftp']='***'; 1141f3f0262cSandi 1142f3f0262cSandi print '<html><body>'; 1143f3f0262cSandi 1144f3f0262cSandi print '<p>When reporting bugs please send all the following '; 1145f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 1146f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 1147f3f0262cSandi 1148f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 1149f3f0262cSandi print_r($_SERVER); 1150f3f0262cSandi print '</pre>'; 1151f3f0262cSandi 1152f3f0262cSandi print '<b>$conf:</b><pre>'; 115328fb55ffSandi print_r($cnf); 1154f3f0262cSandi print '</pre>'; 1155f3f0262cSandi 1156ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 1157ed7b5f09Sandi print DOKU_BASE; 1158f3f0262cSandi print '</pre>'; 1159f3f0262cSandi 1160ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 1161ed7b5f09Sandi print DOKU_URL; 1162ed7b5f09Sandi print '</pre>'; 1163ed7b5f09Sandi 1164ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 1165f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 1166f3f0262cSandi print '</pre>'; 1167f3f0262cSandi 1168f3f0262cSandi print '<b>PHP Version:</b><pre>'; 1169f3f0262cSandi print phpversion(); 1170f3f0262cSandi print '</pre>'; 1171f3f0262cSandi 1172f3f0262cSandi print '<b>locale:</b><pre>'; 1173f3f0262cSandi print setlocale(LC_ALL,0); 1174f3f0262cSandi print '</pre>'; 1175f3f0262cSandi 1176d16a4edaSandi print '<b>encoding:</b><pre>'; 1177d16a4edaSandi print $lang['encoding']; 1178d16a4edaSandi print '</pre>'; 1179d16a4edaSandi 11805298a619SAndreas Gohr if($auth){ 11815298a619SAndreas Gohr print '<b>Auth backend capabilities:</b><pre>'; 11825298a619SAndreas Gohr print_r($auth->cando); 11835298a619SAndreas Gohr print '</pre>'; 11845298a619SAndreas Gohr } 11855298a619SAndreas Gohr 11863aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 11873aa54d7cSAndreas Gohr print_r($_SESSION); 11883aa54d7cSAndreas Gohr print '</pre>'; 11893aa54d7cSAndreas Gohr 1190f3f0262cSandi print '<b>Environment:</b><pre>'; 1191f3f0262cSandi print_r($_ENV); 1192f3f0262cSandi print '</pre>'; 1193f3f0262cSandi 1194f3f0262cSandi print '<b>PHP settings:</b><pre>'; 1195f3f0262cSandi $inis = ini_get_all(); 1196f3f0262cSandi print_r($inis); 1197f3f0262cSandi print '</pre>'; 1198f3f0262cSandi 1199f3f0262cSandi print '</body></html>'; 1200f3f0262cSandi} 1201f3f0262cSandi 1202c19fe9c0Sandifunction html_admin(){ 1203c19fe9c0Sandi global $ID; 1204c19fe9c0Sandi global $lang; 1205ca3a6df1SMatthias Grimm global $conf; 1206c19fe9c0Sandi 1207c112d578Sandi print p_locale_xhtml('admin'); 1208c19fe9c0Sandi 120911e2ce22Schris // build menu of admin functions from the plugins that handle them 121011e2ce22Schris $pluginlist = plugin_list('admin'); 121111e2ce22Schris $menu = array(); 121211e2ce22Schris foreach ($pluginlist as $p) { 121311e2ce22Schris if($obj =& plugin_load('admin',$p) === NULL) continue; 121411e2ce22Schris $menu[] = array('plugin' => $p, 121511e2ce22Schris 'prompt' => $obj->getMenuText($conf['lang']), 121611e2ce22Schris 'sort' => $obj->getMenuSort() 121711e2ce22Schris ); 121811e2ce22Schris } 121911e2ce22Schris 122011e2ce22Schris usort($menu, p_sort_modes); 122111e2ce22Schris 122211e2ce22Schris // output the menu 122311e2ce22Schris ptln('<ul>'); 122411e2ce22Schris 122511e2ce22Schris foreach ($menu as $item) { 122611e2ce22Schris if (!$item['prompt']) continue; 12270c6b58a8SAndreas Gohr ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 122811e2ce22Schris } 122911e2ce22Schris 123011e2ce22Schris // add in non-plugin functions 123111e2ce22Schris if (!$conf['openregister']){ 12320c6b58a8SAndreas Gohr ptln('<li><div class="li"><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></div></li>'); 123311e2ce22Schris } 123411e2ce22Schris 123511e2ce22Schris ptln('</ul>'); 1236ca3a6df1SMatthias Grimm} 1237c19fe9c0Sandi 12388b06d178Schris/** 12398b06d178Schris * Form to request a new password for an existing account 12408b06d178Schris * 12418b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 124211e2ce22Schris */ 12438b06d178Schrisfunction html_resendpwd() { 12448b06d178Schris global $lang; 12458b06d178Schris global $conf; 12468b06d178Schris global $ID; 1247c19fe9c0Sandi 12488b06d178Schris print p_locale_xhtml('resendpwd'); 12498b06d178Schris?> 125096331712SAnika Henke <div class="centeralign"> 12511dd0c202SAnika Henke <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 12528b06d178Schris <fieldset> 12538b06d178Schris <br /> 1254753d5abfSMatthias Grimm <legend><?php echo $lang['resendpwd']?></legend> 12558b06d178Schris <input type="hidden" name="do" value="resendpwd" /> 12568b06d178Schris <input type="hidden" name="save" value="1" /> 12578b06d178Schris <label class="block"> 12588b06d178Schris <span><?php echo $lang['user']?></span> 12598b06d178Schris <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br /> 12608b06d178Schris </label><br /> 12618b06d178Schris <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" /> 12628b06d178Schris </fieldset> 12638b06d178Schris </form> 12648b06d178Schris </div> 12658b06d178Schris<?php 12668b06d178Schris} 1267340756e4Sandi 1268340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 : 1269