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