1ed7b5f09Sandi<?php 215fae107Sandi/** 315fae107Sandi * HTML output functions 415fae107Sandi * 515fae107Sandi * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 715fae107Sandi */ 815fae107Sandi 9ed7b5f09Sandi if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 10f3f0262cSandi 116bbae538Sandi require_once(DOKU_INC.'inc/parserutils.php'); 126bbae538Sandi 13f3f0262cSandi/** 14f3f0262cSandi * Convenience function to quickly build a wikilink 1515fae107Sandi * 1615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 17f3f0262cSandi */ 1830f1737dSandifunction html_wikilink($id,$name=NULL,$search=''){ 19723d78dbSandi require_once(DOKU_INC.'inc/parser/xhtml.php'); 20723d78dbSandi static $xhtml_renderer = NULL; 21723d78dbSandi if(is_null($xhtml_renderer)){ 22723d78dbSandi $xhtml_renderer = new Doku_Renderer_xhtml(); 23f3f0262cSandi } 24f3f0262cSandi 25cffcc403Sandi return $xhtml_renderer->internallink($id,$name,$search,true); 26f3f0262cSandi} 27f3f0262cSandi 28f3f0262cSandi/** 29c19fe9c0Sandi * Helps building long attribute lists 30c19fe9c0Sandi * 31c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 32c19fe9c0Sandi */ 33c19fe9c0Sandifunction html_attbuild($attributes){ 34c19fe9c0Sandi $ret = ''; 35c19fe9c0Sandi foreach ( $attributes as $key => $value ) { 36c19fe9c0Sandi $ret .= $key.'="'.formtext($value).'" '; 37c19fe9c0Sandi } 38c19fe9c0Sandi return trim($ret); 39c19fe9c0Sandi} 40c19fe9c0Sandi 41c19fe9c0Sandi/** 42f3f0262cSandi * The loginform 4315fae107Sandi * 4415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 45f3f0262cSandi */ 46f3f0262cSandifunction html_login(){ 47f3f0262cSandi global $lang; 48f3f0262cSandi global $conf; 49f3f0262cSandi global $ID; 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" /> 69132bdbfeSandi <label for="remember" class="simple"> 70132bdbfeSandi <input type="checkbox" name="r" id="remember" value="1" /> 714da078a3Smatthiasgrimm <span><?php echo $lang['remember']?></span> 72132bdbfeSandi </label> 73f3f0262cSandi </fieldset> 74f3f0262cSandi </form> 754da078a3Smatthiasgrimm <?php 76f3f0262cSandi if($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 83cd52f92dSchris if ($auth->canDo('modifyUser')) { 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/** 101f3f0262cSandi * shows the edit/source/show 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']){ 113f3f0262cSandi if($INFO['exists']){ 114f3f0262cSandi $r = html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 115f3f0262cSandi }else{ 116f3f0262cSandi $r = html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 117f3f0262cSandi } 118f3f0262cSandi }else{ 119f3f0262cSandi $r = html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 120f3f0262cSandi } 121f3f0262cSandi }else{ 122f3f0262cSandi $r = html_btn('show',$ID,'v',array('do' => 'show')); 123f3f0262cSandi } 124f3f0262cSandi return $r; 125f3f0262cSandi} 126f3f0262cSandi 12715fae107Sandi/** 12815fae107Sandi * prints a section editing button 12915fae107Sandi * 13015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 13115fae107Sandi */ 132f3f0262cSandifunction html_secedit_button($section,$p){ 133f3f0262cSandi global $ID; 134f3f0262cSandi global $lang; 135f3f0262cSandi $secedit = ''; 136506ae684Sandi# if($p) $secedit .= "</p>\n"; 137f3f0262cSandi $secedit .= '<div class="secedit">'; 138f3f0262cSandi $secedit .= html_btn('secedit',$ID,'', 139f3f0262cSandi array('do' => 'edit', 140f3f0262cSandi 'lines' => "$section"), 141f3f0262cSandi 'post'); 142f3f0262cSandi $secedit .= '</div>'; 143506ae684Sandi# if($p) $secedit .= "\n<p>"; 144f3f0262cSandi return $secedit; 145f3f0262cSandi} 146f3f0262cSandi 14715fae107Sandi/** 14815fae107Sandi * inserts section edit buttons if wanted or removes the markers 14915fae107Sandi * 15015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 15115fae107Sandi */ 152f3f0262cSandifunction html_secedit($text,$show=true){ 153f3f0262cSandi global $INFO; 154c112d578Sandi if($INFO['writable'] && $show && !$INFO['rev']){ 155f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d+-\d+)\] -->#e', 156f3f0262cSandi "html_secedit_button('\\1',true)", 157f3f0262cSandi $text); 158f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d+-)\] -->#e', 159f3f0262cSandi "html_secedit_button('\\1',false)", 160f3f0262cSandi $text); 161f3f0262cSandi }else{ 162f3f0262cSandi $text = preg_replace('#<!-- SECTION \[(\d*-\d*)\] -->#e','',$text); 163f3f0262cSandi } 164f3f0262cSandi return $text; 165f3f0262cSandi} 166f3f0262cSandi 167f3f0262cSandi/** 168d6c9c552Smatthiasgrimm * Just the back to top button (in its own form) 1696b13307fSandi * 1706b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 1716b13307fSandi */ 1726b13307fSandifunction html_topbtn(){ 1736b13307fSandi global $lang; 1746b13307fSandi 1756b13307fSandi $ret = ''; 176265e3787Sandi $ret = '<a href="#top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" /></a>'; 177df7b6005Sandi 1786b13307fSandi return $ret; 1796b13307fSandi} 1806b13307fSandi 1816b13307fSandi/** 182d67ca2c0Smatthiasgrimm * Just the back to media window button in its own form 183d67ca2c0Smatthiasgrimm * 184d67ca2c0Smatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 185d67ca2c0Smatthiasgrimm */ 186d67ca2c0Smatthiasgrimmfunction html_backtomedia_button($params,$akey=''){ 187d67ca2c0Smatthiasgrimm global $conf; 188d67ca2c0Smatthiasgrimm global $lang; 189d67ca2c0Smatthiasgrimm 1904beabca9SAnika Henke $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php"><div class="no">'; 191d67ca2c0Smatthiasgrimm 192d67ca2c0Smatthiasgrimm reset($params); 193d67ca2c0Smatthiasgrimm while (list($key, $val) = each($params)) { 194d67ca2c0Smatthiasgrimm $ret .= '<input type="hidden" name="'.$key.'" '; 195d67ca2c0Smatthiasgrimm $ret .= 'value="'.htmlspecialchars($val).'" />'; 196d67ca2c0Smatthiasgrimm } 197d67ca2c0Smatthiasgrimm 198d67ca2c0Smatthiasgrimm $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" '; 199d67ca2c0Smatthiasgrimm if($akey){ 200d67ca2c0Smatthiasgrimm $ret .= 'title="ALT+'.strtoupper($akey).'" '; 201d67ca2c0Smatthiasgrimm $ret .= 'accesskey="'.$akey.'" '; 202d67ca2c0Smatthiasgrimm } 203d67ca2c0Smatthiasgrimm $ret .= '/>'; 2044beabca9SAnika Henke $ret .= '</div></form>'; 205d67ca2c0Smatthiasgrimm 206d67ca2c0Smatthiasgrimm return $ret; 207d67ca2c0Smatthiasgrimm} 208d67ca2c0Smatthiasgrimm 209d67ca2c0Smatthiasgrimm/** 210d67ca2c0Smatthiasgrimm * Displays a button (using its own form) 21115fae107Sandi * 21215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 213f3f0262cSandi */ 214f3f0262cSandifunction html_btn($name,$id,$akey,$params,$method='get'){ 215f3f0262cSandi global $conf; 216f3f0262cSandi global $lang; 217f3f0262cSandi 218f3f0262cSandi $label = $lang['btn_'.$name]; 219f3f0262cSandi 220f3f0262cSandi $ret = ''; 221f3f0262cSandi 22249c713a3Sandi //filter id (without urlencoding) 22349c713a3Sandi $id = idfilter($id,false); 224f3f0262cSandi 225f3f0262cSandi //make nice URLs even for buttons 2266c7843b5Sandi if($conf['userewrite'] == 2){ 2276c7843b5Sandi $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 2286c7843b5Sandi }elseif($conf['userewrite']){ 2296c7843b5Sandi $script = DOKU_BASE.$id; 2306c7843b5Sandi }else{ 2318b00ebcfSandi $script = DOKU_BASE.DOKU_SCRIPT; 232f3f0262cSandi $params['id'] = $id; 233f3f0262cSandi } 234f3f0262cSandi 2354beabca9SAnika Henke $ret .= '<form class="button" method="'.$method.'" action="'.$script.'"><div class="no">'; 236f3f0262cSandi 237f3f0262cSandi reset($params); 238f3f0262cSandi while (list($key, $val) = each($params)) { 239f3f0262cSandi $ret .= '<input type="hidden" name="'.$key.'" '; 240f3f0262cSandi $ret .= 'value="'.htmlspecialchars($val).'" />'; 241f3f0262cSandi } 242f3f0262cSandi 243f3f0262cSandi $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; 244f3f0262cSandi if($akey){ 245f3f0262cSandi $ret .= 'title="ALT+'.strtoupper($akey).'" '; 246f3f0262cSandi $ret .= 'accesskey="'.$akey.'" '; 247f3f0262cSandi } 248f3f0262cSandi $ret .= '/>'; 2494beabca9SAnika Henke $ret .= '</div></form>'; 250f3f0262cSandi 251f3f0262cSandi return $ret; 252f3f0262cSandi} 253f3f0262cSandi 254f3f0262cSandi/** 25515fae107Sandi * show a wiki page 25615fae107Sandi * 25715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 25815fae107Sandi */ 2596bbae538Sandifunction html_show($txt=''){ 260f3f0262cSandi global $ID; 261f3f0262cSandi global $REV; 262f3f0262cSandi global $HIGH; 263f3f0262cSandi //disable section editing for old revisions or in preview 2645400331dSandi if($txt || $REV){ 2656bbae538Sandi $secedit = false; 2666bbae538Sandi }else{ 2676bbae538Sandi $secedit = true; 268f3f0262cSandi } 269f3f0262cSandi 2706bbae538Sandi if ($txt){ 271f3f0262cSandi //PreviewHeader 272*50835be7SAndreas Gohr print '<br id="scroll__here" />'; 273c112d578Sandi print p_locale_xhtml('preview'); 274f3f0262cSandi print '<div class="preview">'; 2759dc2c2afSandi print html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 27646723c19SAndreas Gohr print '<div class="clearer"></div>'; 277f3f0262cSandi print '</div>'; 2786bbae538Sandi 279f3f0262cSandi }else{ 280c112d578Sandi if ($REV) print p_locale_xhtml('showrev'); 281c112d578Sandi $html = p_wiki_xhtml($ID,$REV,true); 2826bbae538Sandi $html = html_secedit($html,$secedit); 283f3f0262cSandi print html_hilight($html,$HIGH); 284f3f0262cSandi } 285f3f0262cSandi} 286f3f0262cSandi 287f3f0262cSandi/** 288f3f0262cSandi * Highlights searchqueries in HTML code 28915fae107Sandi * 29015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 2917209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 292f3f0262cSandi */ 293f3f0262cSandifunction html_hilight($html,$query){ 2947209be23SAndreas Gohr //split at common delimiters 2959d9c165eSAndreas Gohr $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY); 296f3f0262cSandi foreach ($queries as $q){ 297f3f0262cSandi $q = preg_quote($q,'/'); 2987209be23SAndreas Gohr $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html); 299f3f0262cSandi } 300f3f0262cSandi return $html; 301f3f0262cSandi} 302f3f0262cSandi 303f3f0262cSandi/** 3047209be23SAndreas Gohr * Callback used by html_hilight() 3057209be23SAndreas Gohr * 3067209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 3077209be23SAndreas Gohr */ 3087209be23SAndreas Gohrfunction html_hilight_callback($m) { 3097209be23SAndreas Gohr $hlight = unslash($m[0]); 3107209be23SAndreas Gohr if ( !isset($m[2])) { 3117209be23SAndreas Gohr $hlight = '<span class="search_hit">'.$hlight.'</span>'; 3127209be23SAndreas Gohr } 3137209be23SAndreas Gohr return $hlight; 3147209be23SAndreas Gohr} 3157209be23SAndreas Gohr 3167209be23SAndreas Gohr/** 31715fae107Sandi * Run a search and display the result 31815fae107Sandi * 31915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 320f3f0262cSandi */ 321f3f0262cSandifunction html_search(){ 322ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 323506fa893SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 324f3f0262cSandi global $conf; 325f3f0262cSandi global $QUERY; 326f3f0262cSandi global $ID; 327f3f0262cSandi global $lang; 328f3f0262cSandi 329c112d578Sandi print p_locale_xhtml('searchpage'); 330f3f0262cSandi flush(); 331f3f0262cSandi 3324d9ff3d5Sandi //show progressbar 3334beabca9SAnika Henke print '<div class="centeralign">'; 3344beabca9SAnika Henke print '<script type="text/javascript" charset="utf-8">'; 3354d9ff3d5Sandi print 'showLoadBar();'; 3364d9ff3d5Sandi print '</script>'; 3374d9ff3d5Sandi print '<br /></div>'; 3384d9ff3d5Sandi 339f3f0262cSandi //do quick pagesearch 340f3f0262cSandi $data = array(); 341506fa893SAndreas Gohr $data = ft_pageLookup(cleanID($QUERY)); 342f3f0262cSandi if(count($data)){ 343f3f0262cSandi sort($data); 344f3f0262cSandi print '<div class="search_quickresult">'; 34596331712SAnika Henke print '<strong>'.$lang[quickhits].':</strong><br />'; 346506fa893SAndreas Gohr foreach($data as $id){ 347f3f0262cSandi print '<div class="search_quickhits">'; 348506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id); 349f3f0262cSandi print '</div> '; 350f3f0262cSandi } 351f3f0262cSandi //clear float (see http://www.complexspiral.com/publications/containing-floats/) 352f3f0262cSandi print '<div class="clearer"> </div>'; 353f3f0262cSandi print '</div>'; 354f3f0262cSandi } 355f3f0262cSandi flush(); 356f3f0262cSandi 357f3f0262cSandi //do fulltext search 358506fa893SAndreas Gohr $data = ft_pageSearch($QUERY,$poswords); 359f3f0262cSandi if(count($data)){ 360506fa893SAndreas Gohr $num = 1; 361506fa893SAndreas Gohr foreach($data as $id => $cnt){ 362f3f0262cSandi print '<div class="search_result">'; 363506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); 364506fa893SAndreas Gohr print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 365506fa893SAndreas Gohr if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 366506fa893SAndreas Gohr print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; 367506fa893SAndreas Gohr } 368f3f0262cSandi print '</div>'; 369506fa893SAndreas Gohr flush(); 370506fa893SAndreas Gohr $num++; 371f3f0262cSandi } 372f3f0262cSandi }else{ 373820fa24bSandi print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 374f3f0262cSandi } 3754d9ff3d5Sandi 3764d9ff3d5Sandi //hide progressbar 3774beabca9SAnika Henke print '<script type="text/javascript" charset="utf-8">'; 3784d9ff3d5Sandi print 'hideLoadBar();'; 3794d9ff3d5Sandi print '</script>'; 380f3f0262cSandi} 381f3f0262cSandi 38215fae107Sandi/** 38315fae107Sandi * Display error on locked pages 38415fae107Sandi * 38515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 38615fae107Sandi */ 387ee20e7d1Sandifunction html_locked(){ 388f3f0262cSandi global $ID; 389f3f0262cSandi global $conf; 390f3f0262cSandi global $lang; 39188f522e9Sandi global $INFO; 392f3f0262cSandi 393f3f0262cSandi $locktime = filemtime(wikiFN($ID).'.lock'); 394f3f0262cSandi $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); 395f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 396f3f0262cSandi 397c112d578Sandi print p_locale_xhtml('locked'); 398f3f0262cSandi print '<ul>'; 3990c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>'; 4000c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 401f3f0262cSandi print '</ul>'; 402f3f0262cSandi} 403f3f0262cSandi 40415fae107Sandi/** 40515fae107Sandi * list old revisions 40615fae107Sandi * 40715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 40815fae107Sandi */ 409f3f0262cSandifunction html_revisions(){ 410f3f0262cSandi global $ID; 411f3f0262cSandi global $INFO; 412f3f0262cSandi global $conf; 413f3f0262cSandi global $lang; 414f3f0262cSandi $revisions = getRevisions($ID); 415f3f0262cSandi $date = @date($conf['dformat'],$INFO['lastmod']); 416f3f0262cSandi 417c112d578Sandi print p_locale_xhtml('revisions'); 418f3f0262cSandi print '<ul>'; 419f3f0262cSandi if($INFO['exists']){ 420b6912aeaSAndreas Gohr print ($INFO['minor']) ? '<li class="minor">' : '<li>'; 4210c6b58a8SAndreas Gohr print '<div class="li">'; 422f9b2fe70Sandi 423f9b2fe70Sandi print $date; 424f9b2fe70Sandi 42502e51121SAnika Henke print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 426cffcc403Sandi 427f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> '; 428652610a2Sandi 429652610a2Sandi print $INFO['sum']; 43088f522e9Sandi print ' <span class="user">'; 43188f522e9Sandi print $INFO['editor']; 43288f522e9Sandi print '</span> '; 433652610a2Sandi 434652610a2Sandi print '('.$lang['current'].')'; 4350c6b58a8SAndreas Gohr print '</div>'; 436652610a2Sandi print '</li>'; 437f3f0262cSandi } 438f3f0262cSandi 439f3f0262cSandi foreach($revisions as $rev){ 440f3f0262cSandi $date = date($conf['dformat'],$rev); 441652610a2Sandi $info = getRevisionInfo($ID,$rev); 442652610a2Sandi 443b6912aeaSAndreas Gohr print ($info['minor']) ? '<li class="minor">' : '<li>'; 4440c6b58a8SAndreas Gohr print '<div class="li">'; 445f9b2fe70Sandi print $date; 446f9b2fe70Sandi 447cffcc403Sandi print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">'; 448d94f4568SAndreas Gohr $p = array(); 449d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 450d94f4568SAndreas Gohr $p['border'] = 0; 451d94f4568SAndreas Gohr $p['width'] = 15; 452d94f4568SAndreas Gohr $p['height'] = 11; 453d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 454d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 455d94f4568SAndreas Gohr $att = buildAttributes($p); 456d94f4568SAndreas Gohr print "<img $att />"; 457cffcc403Sandi print '</a> '; 458cffcc403Sandi 459f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> '; 460f9b2fe70Sandi 461f243a77fSandi print htmlspecialchars($info['sum']); 46288f522e9Sandi print ' <span class="user">'; 46388f522e9Sandi if($info['user']){ 46488f522e9Sandi print $info['user']; 46588f522e9Sandi }else{ 466652610a2Sandi print $info['ip']; 46788f522e9Sandi } 46888f522e9Sandi print '</span>'; 469652610a2Sandi 4700c6b58a8SAndreas Gohr print '</div>'; 471f3f0262cSandi print '</li>'; 472f3f0262cSandi } 473f3f0262cSandi print '</ul>'; 474f3f0262cSandi} 475f3f0262cSandi 47615fae107Sandi/** 47715fae107Sandi * display recent changes 47815fae107Sandi * 47915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 4805749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 48115fae107Sandi */ 482a39955b0Smatthiasgrimmfunction html_recent($first=0){ 483f3f0262cSandi global $conf; 484cffcc403Sandi global $lang; 485dbb00abcSEsther Brunner global $ID; 4865749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 4875749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 4885749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 4895749f1ceSmatthiasgrimm */ 490b6912aeaSAndreas Gohr $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 4915749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0){ 4925749f1ceSmatthiasgrimm $first=0; 493b6912aeaSAndreas Gohr $recents = getRecents(0,$conf['recent'] + 1,getNS($ID)); 4945749f1ceSmatthiasgrimm } 4955749f1ceSmatthiasgrimm $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; 496f3f0262cSandi 497c112d578Sandi print p_locale_xhtml('recent'); 498f3f0262cSandi print '<ul>'; 499a39955b0Smatthiasgrimm 500d437bcc4SAndreas Gohr foreach($recents as $recent){ 501d437bcc4SAndreas Gohr $date = date($conf['dformat'],$recent['date']); 502b6912aeaSAndreas Gohr print ($recent['minor']) ? '<li class="minor">' : '<li>'; 5030c6b58a8SAndreas Gohr print '<div class="li">'; 504cffcc403Sandi 505f9b2fe70Sandi print $date.' '; 506f9b2fe70Sandi 507d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=diff").'">'; 508d94f4568SAndreas Gohr $p = array(); 509d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 510d94f4568SAndreas Gohr $p['border'] = 0; 511d94f4568SAndreas Gohr $p['width'] = 15; 512d94f4568SAndreas Gohr $p['height'] = 11; 513d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 514d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 515d94f4568SAndreas Gohr $att = buildAttributes($p); 516d94f4568SAndreas Gohr print "<img $att />"; 517cffcc403Sandi print '</a> '; 518cffcc403Sandi 519d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=revisions").'">'; 520d94f4568SAndreas Gohr $p = array(); 521d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/history.png'; 522d94f4568SAndreas Gohr $p['border'] = 0; 523d94f4568SAndreas Gohr $p['width'] = 12; 524d94f4568SAndreas Gohr $p['height'] = 14; 525d94f4568SAndreas Gohr $p['title'] = $lang['btn_revs']; 526d94f4568SAndreas Gohr $p['alt'] = $lang['btn_revs']; 527d94f4568SAndreas Gohr $att = buildAttributes($p); 528d94f4568SAndreas Gohr print "<img $att />"; 529cffcc403Sandi print '</a> '; 530cffcc403Sandi 531d437bcc4SAndreas Gohr print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 532d437bcc4SAndreas Gohr print ' '.htmlspecialchars($recent['sum']); 533b6912aeaSAndreas Gohr 53488f522e9Sandi print ' <span class="user">'; 535d437bcc4SAndreas Gohr if($recent['user']){ 536d437bcc4SAndreas Gohr print $recent['user']; 53788f522e9Sandi }else{ 538d437bcc4SAndreas Gohr print $recent['ip']; 53988f522e9Sandi } 54088f522e9Sandi print '</span>'; 541cffcc403Sandi 5420c6b58a8SAndreas Gohr print '</div>'; 543f3f0262cSandi print '</li>'; 544f3f0262cSandi } 545f3f0262cSandi print '</ul>'; 546a39955b0Smatthiasgrimm 547a39955b0Smatthiasgrimm print '<div class="pagenav">'; 5485749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 549a39955b0Smatthiasgrimm if ($first > 0) { 550a39955b0Smatthiasgrimm $first -= $conf['recent']; 551a39955b0Smatthiasgrimm if ($first < 0) $first = 0; 552a39955b0Smatthiasgrimm print '<div class="pagenav-prev">'; 5535749f1ceSmatthiasgrimm print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); 554a39955b0Smatthiasgrimm print '</div>'; 555a39955b0Smatthiasgrimm } 5565749f1ceSmatthiasgrimm if ($conf['recent'] < count($recents)) { 557a39955b0Smatthiasgrimm print '<div class="pagenav-next">'; 5585749f1ceSmatthiasgrimm print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); 559a39955b0Smatthiasgrimm print '</div>'; 560a39955b0Smatthiasgrimm } 561a39955b0Smatthiasgrimm print '</div>'; 562f3f0262cSandi} 563f3f0262cSandi 56415fae107Sandi/** 56515fae107Sandi * Display page index 56615fae107Sandi * 56715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 56815fae107Sandi */ 569f3f0262cSandifunction html_index($ns){ 570ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 571f3f0262cSandi global $conf; 572f3f0262cSandi global $ID; 573f3f0262cSandi $dir = $conf['datadir']; 574f3f0262cSandi $ns = cleanID($ns); 57530f1737dSandi #fixme use appropriate function 576f3f0262cSandi if(empty($ns)){ 577f3f0262cSandi $ns = dirname(str_replace(':','/',$ID)); 578f3f0262cSandi if($ns == '.') $ns =''; 579f3f0262cSandi } 58088d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 581f3f0262cSandi 582c112d578Sandi print p_locale_xhtml('index'); 583f3f0262cSandi 584f3f0262cSandi $data = array(); 585f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 586cb70c441Sandi print html_buildlist($data,'idx','html_list_index','html_li_index'); 587f3f0262cSandi} 588f3f0262cSandi 589f3f0262cSandi/** 59015fae107Sandi * Index item formatter 59115fae107Sandi * 592f3f0262cSandi * User function for html_buildlist() 59315fae107Sandi * 59415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 595f3f0262cSandi */ 596f3f0262cSandifunction html_list_index($item){ 597f3f0262cSandi $ret = ''; 598f3f0262cSandi $base = ':'.$item['id']; 599f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 600f3f0262cSandi if($item['type']=='d'){ 601f3f0262cSandi $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">'; 602f3f0262cSandi $ret .= $base; 603f3f0262cSandi $ret .= '</a>'; 604f3f0262cSandi }else{ 605f3f0262cSandi $ret .= html_wikilink(':'.$item['id']); 606f3f0262cSandi } 607f3f0262cSandi return $ret; 608f3f0262cSandi} 609f3f0262cSandi 610f3f0262cSandi/** 611cb70c441Sandi * Index List item 612cb70c441Sandi * 613cb70c441Sandi * This user function is used in html_build_lidt to build the 614cb70c441Sandi * <li> tags for namespaces when displaying the page index 615cb70c441Sandi * it gives different classes to opened or closed "folders" 616cb70c441Sandi * 617cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 618cb70c441Sandi */ 619cb70c441Sandifunction html_li_index($item){ 620cb70c441Sandi if($item['type'] == "f"){ 621cb70c441Sandi return '<li class="level'.$item['level'].'">'; 622cb70c441Sandi }elseif($item['open']){ 623cb70c441Sandi return '<li class="open">'; 624cb70c441Sandi }else{ 625cb70c441Sandi return '<li class="closed">'; 626cb70c441Sandi } 627cb70c441Sandi} 628cb70c441Sandi 629cb70c441Sandi/** 630cb70c441Sandi * Default List item 631cb70c441Sandi * 632cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 633cb70c441Sandi */ 634cb70c441Sandifunction html_li_default($item){ 635cb70c441Sandi return '<li class="level'.$item['level'].'">'; 636cb70c441Sandi} 637cb70c441Sandi 638cb70c441Sandi/** 63915fae107Sandi * Build an unordered list 64015fae107Sandi * 641f3f0262cSandi * Build an unordered list from the given $data array 642f3f0262cSandi * Each item in the array has to have a 'level' property 643f3f0262cSandi * the item itself gets printed by the given $func user 644cb70c441Sandi * function. The second and optional function is used to 645cb70c441Sandi * print the <li> tag. Both user function need to accept 646cb70c441Sandi * a single item. 64715fae107Sandi * 64815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 649f3f0262cSandi */ 650cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 651f3f0262cSandi $level = 0; 652f3f0262cSandi $opens = 0; 653f3f0262cSandi $ret = ''; 654f3f0262cSandi 655f3f0262cSandi foreach ($data as $item){ 656f3f0262cSandi 657f3f0262cSandi if( $item['level'] > $level ){ 658f3f0262cSandi //open new list 659df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 660df52d0feSandi if ($i) $ret .= "<li class=\"clear\">\n"; 661f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 662df52d0feSandi } 663f3f0262cSandi }elseif( $item['level'] < $level ){ 664f3f0262cSandi //close last item 665f3f0262cSandi $ret .= "</li>\n"; 666f3f0262cSandi for ($i=0; $i<($level - $item['level']); $i++){ 667f3f0262cSandi //close higher lists 668f3f0262cSandi $ret .= "</ul>\n</li>\n"; 669f3f0262cSandi } 670f3f0262cSandi }else{ 671f3f0262cSandi //close last item 672f3f0262cSandi $ret .= "</li>\n"; 673f3f0262cSandi } 674f3f0262cSandi 675f3f0262cSandi //remember current level 676f3f0262cSandi $level = $item['level']; 677f3f0262cSandi 678f3f0262cSandi //print item 679cb70c441Sandi $ret .= $lifunc($item); //user function 6800c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 681f3f0262cSandi $ret .= $func($item); //user function 6820c6b58a8SAndreas Gohr $ret .= '</div>'; 683f3f0262cSandi } 684f3f0262cSandi 685f3f0262cSandi //close remaining items and lists 686f3f0262cSandi for ($i=0; $i < $level; $i++){ 687f3f0262cSandi $ret .= "</li></ul>\n"; 688f3f0262cSandi } 689f3f0262cSandi 690f3f0262cSandi return $ret; 691f3f0262cSandi} 692f3f0262cSandi 69315fae107Sandi/** 69415fae107Sandi * display backlinks 69515fae107Sandi * 69615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 69715fae107Sandi */ 698f3f0262cSandifunction html_backlinks(){ 69954f4c056SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 700f3f0262cSandi global $ID; 701f3f0262cSandi global $conf; 702f3f0262cSandi 703c112d578Sandi print p_locale_xhtml('backlinks'); 704f3f0262cSandi 70554f4c056SAndreas Gohr $data = ft_backlinks($ID); 706f3f0262cSandi 707f3f0262cSandi print '<ul class="idx">'; 70854f4c056SAndreas Gohr foreach($data as $blink){ 7090c6b58a8SAndreas Gohr print '<li><div class="li">'; 71054f4c056SAndreas Gohr print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 7110c6b58a8SAndreas Gohr print '</div></li>'; 712f3f0262cSandi } 713f3f0262cSandi print '</ul>'; 714f3f0262cSandi} 715f3f0262cSandi 71615fae107Sandi/** 71715fae107Sandi * show diff 71815fae107Sandi * 71915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 72015fae107Sandi */ 721f3f0262cSandifunction html_diff($text='',$intro=true){ 722ed7b5f09Sandi require_once(DOKU_INC.'inc/DifferenceEngine.php'); 723f3f0262cSandi global $ID; 724f3f0262cSandi global $REV; 725f3f0262cSandi global $lang; 726f3f0262cSandi global $conf; 727f3f0262cSandi if($text){ 728f3f0262cSandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), 729f3f0262cSandi split("\n",htmlspecialchars(cleanText($text)))); 730f3f0262cSandi $left = '<a class="wikilink1" href="'.wl($ID).'">'. 731f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'. 732f3f0262cSandi $lang['current']; 733f3f0262cSandi $right = $lang['yours']; 734f3f0262cSandi }else{ 7354d58bd99Sandi if($REV){ 7364d58bd99Sandi $r = $REV; 7374d58bd99Sandi }else{ 7384d58bd99Sandi //use last revision if none given 7394d58bd99Sandi $revs = getRevisions($ID); 7404d58bd99Sandi $r = $revs[0]; 7414d58bd99Sandi } 7424d58bd99Sandi 7434d58bd99Sandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))), 744f3f0262cSandi split("\n",htmlspecialchars(rawWiki($ID,'')))); 7454d58bd99Sandi $left = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'. 7464d58bd99Sandi $ID.' '.date($conf['dformat'],$r).'</a>'; 747f3f0262cSandi $right = '<a class="wikilink1" href="'.wl($ID).'">'. 748f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 749f3f0262cSandi $lang['current']; 750f3f0262cSandi } 751f3f0262cSandi $tdf = new TableDiffFormatter(); 752c112d578Sandi if($intro) print p_locale_xhtml('diff'); 753f3f0262cSandi ?> 754f3f0262cSandi <table class="diff" width="100%"> 755f3f0262cSandi <tr> 756f3f0262cSandi <td colspan="2" width="50%" class="diff-header"> 7574da078a3Smatthiasgrimm <?php echo $left?> 758f3f0262cSandi </td> 759f3f0262cSandi <td colspan="2" width="50%" class="diff-header"> 7604da078a3Smatthiasgrimm <?php echo $right?> 761f3f0262cSandi </td> 762f3f0262cSandi </tr> 7634da078a3Smatthiasgrimm <?php echo $tdf->format($df)?> 764f3f0262cSandi </table> 7654da078a3Smatthiasgrimm <?php 766f3f0262cSandi} 767f3f0262cSandi 76815fae107Sandi/** 76915fae107Sandi * show warning on conflict detection 77015fae107Sandi * 77115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 77215fae107Sandi */ 773f3f0262cSandifunction html_conflict($text,$summary){ 774f3f0262cSandi global $ID; 775f3f0262cSandi global $lang; 776f3f0262cSandi 777c112d578Sandi print p_locale_xhtml('conflict'); 778f3f0262cSandi ?> 7791dd0c202SAnika Henke <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 78096331712SAnika Henke <div class="centeralign"> 7814da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 7824da078a3Smatthiasgrimm <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" /> 7834da078a3Smatthiasgrimm <input type="hidden" name="summary" value="<?php echo formText($summary)?>" /> 784f3f0262cSandi 7854da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" /> 7864da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" /> 787f3f0262cSandi </div> 788f3f0262cSandi </form> 789f3f0262cSandi <br /><br /><br /><br /> 7904da078a3Smatthiasgrimm <?php 791f3f0262cSandi} 792f3f0262cSandi 793f3f0262cSandi/** 79415fae107Sandi * Prints the global message array 79515fae107Sandi * 79615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 797f3f0262cSandi */ 798f3f0262cSandifunction html_msgarea(){ 799f3f0262cSandi global $MSG; 800f3f0262cSandi 801f3f0262cSandi if(!isset($MSG)) return; 802f3f0262cSandi 803f3f0262cSandi foreach($MSG as $msg){ 804f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 805f3f0262cSandi print $msg['msg']; 806f3f0262cSandi print '</div>'; 807f3f0262cSandi } 808f3f0262cSandi} 809f3f0262cSandi 810f3f0262cSandi/** 811f3f0262cSandi * Prints the registration form 81215fae107Sandi * 81315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 814f3f0262cSandi */ 815f3f0262cSandifunction html_register(){ 816f3f0262cSandi global $lang; 817cab2716aSmatthias.grimm global $conf; 818f3f0262cSandi global $ID; 819f3f0262cSandi 820c112d578Sandi print p_locale_xhtml('register'); 821f3f0262cSandi?> 82296331712SAnika Henke <div class="centeralign"> 8231dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 82496331712SAnika Henke <fieldset> 825f3f0262cSandi <input type="hidden" name="do" value="register" /> 826f3f0262cSandi <input type="hidden" name="save" value="1" /> 82796331712SAnika Henke 8284da078a3Smatthiasgrimm <legend><?php echo $lang['register']?></legend> 829b6912aeaSAndreas Gohr <label class="block"> 8304da078a3Smatthiasgrimm <?php echo $lang['user']?> 8314da078a3Smatthiasgrimm <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" /> 832f3f0262cSandi </label><br /> 833cab2716aSmatthias.grimm 834cab2716aSmatthias.grimm <?php 835cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 836cab2716aSmatthias.grimm ?> 837b6912aeaSAndreas Gohr <label class="block"> 8384da078a3Smatthiasgrimm <?php echo $lang['pass']?> 839cab2716aSmatthias.grimm <input type="password" name="pass" class="edit" size="50" /> 840cab2716aSmatthias.grimm </label><br /> 841b6912aeaSAndreas Gohr <label class="block"> 8424da078a3Smatthiasgrimm <?php echo $lang['passchk']?> 843cab2716aSmatthias.grimm <input type="password" name="passchk" class="edit" size="50" /> 844cab2716aSmatthias.grimm </label><br /> 845cab2716aSmatthias.grimm <?php 846cab2716aSmatthias.grimm } 847cab2716aSmatthias.grimm ?> 848cab2716aSmatthias.grimm 849b6912aeaSAndreas Gohr <label class="block"> 8504da078a3Smatthiasgrimm <?php echo $lang['fullname']?> 8514da078a3Smatthiasgrimm <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 852f3f0262cSandi </label><br /> 853b6912aeaSAndreas Gohr <label class="block"> 8544da078a3Smatthiasgrimm <?php echo $lang['email']?> 8554da078a3Smatthiasgrimm <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 856f3f0262cSandi </label><br /> 8574da078a3Smatthiasgrimm <input type="submit" class="button" value="<?php echo $lang['register']?>" /> 858f3f0262cSandi </fieldset> 859f3f0262cSandi </form> 860f3f0262cSandi </div> 8614da078a3Smatthiasgrimm<?php 862f3f0262cSandi} 863f3f0262cSandi 864f3f0262cSandi/** 8658b06d178Schris * Print the update profile form 8668b06d178Schris * 8678b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 8688b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 8698b06d178Schris */ 8708b06d178Schrisfunction html_updateprofile(){ 8718b06d178Schris global $lang; 8728b06d178Schris global $conf; 8738b06d178Schris global $ID; 8748b06d178Schris global $INFO; 8758b06d178Schris 8768b06d178Schris print p_locale_xhtml('updateprofile'); 8778b06d178Schris 8788b06d178Schris if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 8798b06d178Schris if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 8808b06d178Schris?> 88196331712SAnika Henke <div class="centeralign"> 8821dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 88396331712SAnika Henke <fieldset style="width: 80%;"> 8848b06d178Schris <input type="hidden" name="do" value="profile" /> 8858b06d178Schris <input type="hidden" name="save" value="1" /> 88696331712SAnika Henke 8878b06d178Schris <legend><?php echo $lang['profile']?></legend> 8888b06d178Schris <label class="block"> 8898b06d178Schris <?php echo $lang['user']?> 8908b06d178Schris <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" /> 8918b06d178Schris </label><br /> 8928b06d178Schris <label class="block"> 8938b06d178Schris <?php echo $lang['fullname']?> 8948b06d178Schris <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 8958b06d178Schris </label><br /> 8968b06d178Schris <label class="block"> 8978b06d178Schris <?php echo $lang['email']?> 8988b06d178Schris <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 8998b06d178Schris </label><br /><br /> 9008b06d178Schris <label class="block"> 9018b06d178Schris <?php echo $lang['newpass']?> 9028b06d178Schris <input type="password" name="newpass" class="edit" size="50" /> 9038b06d178Schris </label><br /> 9048b06d178Schris <label class="block"> 9058b06d178Schris <?php echo $lang['passchk']?> 9068b06d178Schris <input type="password" name="passchk" class="edit" size="50" /> 9078b06d178Schris </label><br /> 9088b06d178Schris 9098b06d178Schris <?php if ($conf['profileconfirm']) { ?> 9108b06d178Schris <br /> 9118b06d178Schris <label class="block"> 9128b06d178Schris <?php echo $lang['oldpass']?> 9138b06d178Schris <input type="password" name="oldpass" class="edit" size="50" /> 9148b06d178Schris </label><br /> 9158b06d178Schris <?php } ?> 9168b06d178Schris 9174cb79657SMatthias Grimm <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" /> 9188b06d178Schris <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" /> 9198b06d178Schris </fieldset> 9208b06d178Schris </form> 9218b06d178Schris </div> 9228b06d178Schris<?php 9238b06d178Schris} 9248b06d178Schris 9258b06d178Schris/** 926f3f0262cSandi * This displays the edit form (lots of logic included) 92715fae107Sandi * 9287146cee2SAndreas Gohr * @fixme this is a huge lump of code and should be modularized 92915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 930f3f0262cSandi */ 931f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed? 932f3f0262cSandi global $ID; 933f3f0262cSandi global $REV; 934f3f0262cSandi global $DATE; 935f3f0262cSandi global $RANGE; 936f3f0262cSandi global $PRE; 937f3f0262cSandi global $SUF; 938f3f0262cSandi global $INFO; 939f3f0262cSandi global $SUM; 940f3f0262cSandi global $lang; 941f3f0262cSandi global $conf; 942f3f0262cSandi 943f3f0262cSandi //set summary default 944f3f0262cSandi if(!$SUM){ 945f3f0262cSandi if($REV){ 946f3f0262cSandi $SUM = $lang['restored']; 947f3f0262cSandi }elseif(!$INFO['exists']){ 948f3f0262cSandi $SUM = $lang['created']; 949f3f0262cSandi } 950f3f0262cSandi } 951f3f0262cSandi 952f3f0262cSandi //no text? Load it! 953f3f0262cSandi if(!isset($text)){ 954f3f0262cSandi $pr = false; //no preview mode 9557146cee2SAndreas Gohr if($INFO['exists']){ 956f3f0262cSandi if($RANGE){ 957f3f0262cSandi list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 958f3f0262cSandi }else{ 959f3f0262cSandi $text = rawWiki($ID,$REV); 960f3f0262cSandi } 961f3f0262cSandi }else{ 9627146cee2SAndreas Gohr //try to load a pagetemplate 9637146cee2SAndreas Gohr $text = pageTemplate($ID); 9647146cee2SAndreas Gohr } 9657146cee2SAndreas Gohr }else{ 966f3f0262cSandi $pr = true; //preview mode 967f3f0262cSandi } 968f3f0262cSandi 969f3f0262cSandi $wr = $INFO['writable']; 970f3f0262cSandi if($wr){ 971c112d578Sandi if ($REV) print p_locale_xhtml('editrev'); 972c112d578Sandi print p_locale_xhtml($include); 973f3f0262cSandi }else{ 974c112d578Sandi print p_locale_xhtml('read'); 975f3f0262cSandi $ro='readonly="readonly"'; 976f3f0262cSandi } 977f3f0262cSandi if(!$DATE) $DATE = $INFO['lastmod']; 978dc57ef04Sandi 979dc57ef04Sandi 980f3f0262cSandi?> 9811dd0c202SAnika Henke <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 98296331712SAnika Henke <table style="width:99%"> 98396331712SAnika Henke <tr> 98496331712SAnika Henke <td class="toolbar" colspan="2"> 98596331712SAnika Henke <div id="toolbar"></div> 9864da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 9874da078a3Smatthiasgrimm <input type="hidden" name="rev" value="<?php echo $REV?>" /> 9884da078a3Smatthiasgrimm <input type="hidden" name="date" value="<?php echo $DATE?>" /> 9894da078a3Smatthiasgrimm <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" /> 9904da078a3Smatthiasgrimm <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" /> 99120d062caSAndreas Gohr 9924da078a3Smatthiasgrimm <?php if($wr){?> 9934beabca9SAnika Henke <script type="text/javascript" charset="utf-8"> 9944da078a3Smatthiasgrimm <?php /* sets changed to true when previewed */?> 9954da078a3Smatthiasgrimm textChanged = <?php ($pr) ? print 'true' : print 'false' ?>; 996f3f0262cSandi </script> 99758bef989Smatthiasgrimm <span id="spell_action"></span> 9984da078a3Smatthiasgrimm <?php } ?> 999f3f0262cSandi </td> 1000dc57ef04Sandi <td> 1001dc57ef04Sandi <div id="spell_suggest"></div> 1002f3f0262cSandi </td> 1003f3f0262cSandi </tr> 1004f3f0262cSandi <tr> 1005dc57ef04Sandi <td colspan="3"> 1006dc57ef04Sandi <div id="spell_result"></div> 10075e163278SAndreas Gohr <textarea name="wikitext" id="wikitext" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea> 1008dc57ef04Sandi </td> 1009dc57ef04Sandi </tr> 1010dc57ef04Sandi <tr id="wikieditbar"> 1011f3f0262cSandi <td> 10124da078a3Smatthiasgrimm <?php if($wr){?> 10135e163278SAndreas Gohr <input class="button" id="edbtn_save" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" tabindex="4" /> 10145e163278SAndreas Gohr <input class="button" id="edbtn_preview" type="submit" name="do" value="<?php echo $lang['btn_preview']?>" accesskey="p" title="[ALT+P]" tabindex="5" /> 10154da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" tabindex="5" /> 10164da078a3Smatthiasgrimm <?php } ?> 1017f3f0262cSandi </td> 1018f3f0262cSandi <td> 10194da078a3Smatthiasgrimm <?php if($wr){ ?> 10204da078a3Smatthiasgrimm <?php echo $lang['summary']?>: 10215e163278SAndreas Gohr <input type="text" class="edit" name="summary" id="summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" /> 1022b6912aeaSAndreas Gohr <?php html_minoredit()?> 10234da078a3Smatthiasgrimm <?php }?> 1024f3f0262cSandi </td> 102596331712SAnika Henke <td class="rightalign"> 102620d062caSAndreas Gohr <div id="sizectl"></div> 1027f3f0262cSandi </td> 1028f3f0262cSandi </tr> 1029f3f0262cSandi </table> 1030f3f0262cSandi </form> 10314da078a3Smatthiasgrimm<?php 1032f3f0262cSandi} 1033f3f0262cSandi 1034f3f0262cSandi/** 1035b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1036b6912aeaSAndreas Gohr * 1037b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org> 1038b6912aeaSAndreas Gohr */ 1039b6912aeaSAndreas Gohrfunction html_minoredit(){ 1040b6912aeaSAndreas Gohr global $conf; 1041b6912aeaSAndreas Gohr global $lang; 1042b6912aeaSAndreas Gohr // minor edits are for logged in users only 1043b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1044b6912aeaSAndreas Gohr return; 1045b6912aeaSAndreas Gohr } 1046b6912aeaSAndreas Gohr 1047b6912aeaSAndreas Gohr $p = array(); 1048b6912aeaSAndreas Gohr $p['name'] = 'minor'; 1049b6912aeaSAndreas Gohr $p['type'] = 'checkbox'; 1050b6912aeaSAndreas Gohr $p['id'] = 'minoredit'; 1051b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1052b6912aeaSAndreas Gohr $p['value'] = '1'; 1053b6912aeaSAndreas Gohr if($_REQUEST['minor']) $p['checked']='checked'; 1054b6912aeaSAndreas Gohr $att = buildAttributes($p); 1055b6912aeaSAndreas Gohr 1056b6912aeaSAndreas Gohr print "<input $att />"; 1057b6912aeaSAndreas Gohr print '<label for="minoredit">'; 1058b6912aeaSAndreas Gohr print $lang['minoredit']; 1059b6912aeaSAndreas Gohr print '</label>'; 1060b6912aeaSAndreas Gohr} 1061b6912aeaSAndreas Gohr 1062b6912aeaSAndreas Gohr/** 1063f3f0262cSandi * prints some debug info 106415fae107Sandi * 106515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1066f3f0262cSandi */ 1067f3f0262cSandifunction html_debug(){ 1068f3f0262cSandi global $conf; 1069d16a4edaSandi global $lang; 107028fb55ffSandi //remove sensitive data 107128fb55ffSandi $cnf = $conf; 107228fb55ffSandi $cnf['auth']='***'; 107328fb55ffSandi $cnf['notify']='***'; 10743dc3a5f1Sandi $cnf['ftp']='***'; 1075f3f0262cSandi 1076f3f0262cSandi print '<html><body>'; 1077f3f0262cSandi 1078f3f0262cSandi print '<p>When reporting bugs please send all the following '; 1079f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 1080f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 1081f3f0262cSandi 1082f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 1083f3f0262cSandi print_r($_SERVER); 1084f3f0262cSandi print '</pre>'; 1085f3f0262cSandi 1086f3f0262cSandi print '<b>$conf:</b><pre>'; 108728fb55ffSandi print_r($cnf); 1088f3f0262cSandi print '</pre>'; 1089f3f0262cSandi 1090ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 1091ed7b5f09Sandi print DOKU_BASE; 1092f3f0262cSandi print '</pre>'; 1093f3f0262cSandi 1094ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 1095ed7b5f09Sandi print DOKU_URL; 1096ed7b5f09Sandi print '</pre>'; 1097ed7b5f09Sandi 1098ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 1099f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 1100f3f0262cSandi print '</pre>'; 1101f3f0262cSandi 1102f3f0262cSandi print '<b>PHP Version:</b><pre>'; 1103f3f0262cSandi print phpversion(); 1104f3f0262cSandi print '</pre>'; 1105f3f0262cSandi 1106f3f0262cSandi print '<b>locale:</b><pre>'; 1107f3f0262cSandi print setlocale(LC_ALL,0); 1108f3f0262cSandi print '</pre>'; 1109f3f0262cSandi 1110d16a4edaSandi print '<b>encoding:</b><pre>'; 1111d16a4edaSandi print $lang['encoding']; 1112d16a4edaSandi print '</pre>'; 1113d16a4edaSandi 11143aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 11153aa54d7cSAndreas Gohr print_r($_SESSION); 11163aa54d7cSAndreas Gohr print '</pre>'; 11173aa54d7cSAndreas Gohr 1118f3f0262cSandi print '<b>Environment:</b><pre>'; 1119f3f0262cSandi print_r($_ENV); 1120f3f0262cSandi print '</pre>'; 1121f3f0262cSandi 1122f3f0262cSandi print '<b>PHP settings:</b><pre>'; 1123f3f0262cSandi $inis = ini_get_all(); 1124f3f0262cSandi print_r($inis); 1125f3f0262cSandi print '</pre>'; 1126f3f0262cSandi 1127f3f0262cSandi print '</body></html>'; 1128f3f0262cSandi} 1129f3f0262cSandi 1130c19fe9c0Sandifunction html_admin(){ 1131c19fe9c0Sandi global $ID; 1132c19fe9c0Sandi global $lang; 1133ca3a6df1SMatthias Grimm global $conf; 1134c19fe9c0Sandi 1135c112d578Sandi print p_locale_xhtml('admin'); 1136c19fe9c0Sandi 113711e2ce22Schris // build menu of admin functions from the plugins that handle them 113811e2ce22Schris $pluginlist = plugin_list('admin'); 113911e2ce22Schris $menu = array(); 114011e2ce22Schris foreach ($pluginlist as $p) { 114111e2ce22Schris if($obj =& plugin_load('admin',$p) === NULL) continue; 114211e2ce22Schris $menu[] = array('plugin' => $p, 114311e2ce22Schris 'prompt' => $obj->getMenuText($conf['lang']), 114411e2ce22Schris 'sort' => $obj->getMenuSort() 114511e2ce22Schris ); 114611e2ce22Schris } 114711e2ce22Schris 114811e2ce22Schris usort($menu, p_sort_modes); 114911e2ce22Schris 115011e2ce22Schris // output the menu 115111e2ce22Schris ptln('<ul>'); 115211e2ce22Schris 115311e2ce22Schris foreach ($menu as $item) { 115411e2ce22Schris if (!$item['prompt']) continue; 11550c6b58a8SAndreas Gohr ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 115611e2ce22Schris } 115711e2ce22Schris 115811e2ce22Schris // add in non-plugin functions 115911e2ce22Schris if (!$conf['openregister']){ 11600c6b58a8SAndreas Gohr ptln('<li><div class="li"><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></div></li>'); 116111e2ce22Schris } 116211e2ce22Schris 116311e2ce22Schris ptln('</ul>'); 1164ca3a6df1SMatthias Grimm} 1165c19fe9c0Sandi 11668b06d178Schris/** 11678b06d178Schris * Form to request a new password for an existing account 11688b06d178Schris * 11698b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 117011e2ce22Schris */ 11718b06d178Schrisfunction html_resendpwd() { 11728b06d178Schris global $lang; 11738b06d178Schris global $conf; 11748b06d178Schris global $ID; 1175c19fe9c0Sandi 11768b06d178Schris print p_locale_xhtml('resendpwd'); 11778b06d178Schris?> 117896331712SAnika Henke <div class="centeralign"> 11791dd0c202SAnika Henke <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 11808b06d178Schris <fieldset> 11818b06d178Schris <br /> 1182753d5abfSMatthias Grimm <legend><?php echo $lang['resendpwd']?></legend> 11838b06d178Schris <input type="hidden" name="do" value="resendpwd" /> 11848b06d178Schris <input type="hidden" name="save" value="1" /> 11858b06d178Schris <label class="block"> 11868b06d178Schris <span><?php echo $lang['user']?></span> 11878b06d178Schris <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br /> 11888b06d178Schris </label><br /> 11898b06d178Schris <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" /> 11908b06d178Schris </fieldset> 11918b06d178Schris </form> 11928b06d178Schris </div> 11938b06d178Schris<?php 11948b06d178Schris} 1195340756e4Sandi 1196340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 : 1197