1ed7b5f09Sandi<?php 215fae107Sandi/** 315fae107Sandi * HTML output functions 415fae107Sandi * 515fae107Sandi * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 715fae107Sandi */ 815fae107Sandi 9ed7b5f09Sandi if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/'); 10f3f0262cSandi 116bbae538Sandi require_once(DOKU_INC.'inc/parserutils.php'); 126bbae538Sandi 13f3f0262cSandi/** 14f3f0262cSandi * Convenience function to quickly build a wikilink 1515fae107Sandi * 1615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 17f3f0262cSandi */ 1830f1737dSandifunction html_wikilink($id,$name=NULL,$search=''){ 19723d78dbSandi static $xhtml_renderer = NULL; 20723d78dbSandi if(is_null($xhtml_renderer)){ 21fdf3dcb9SMatthias Urlichs require_once(DOKU_INC.'inc/parser/xhtml.php'); 22723d78dbSandi $xhtml_renderer = new Doku_Renderer_xhtml(); 23f3f0262cSandi } 24f3f0262cSandi 25cffcc403Sandi return $xhtml_renderer->internallink($id,$name,$search,true); 26f3f0262cSandi} 27f3f0262cSandi 28f3f0262cSandi/** 29c19fe9c0Sandi * Helps building long attribute lists 30c19fe9c0Sandi * 31c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 32c19fe9c0Sandi */ 33c19fe9c0Sandifunction html_attbuild($attributes){ 34c19fe9c0Sandi $ret = ''; 35c19fe9c0Sandi foreach ( $attributes as $key => $value ) { 36c19fe9c0Sandi $ret .= $key.'="'.formtext($value).'" '; 37c19fe9c0Sandi } 38c19fe9c0Sandi return trim($ret); 39c19fe9c0Sandi} 40c19fe9c0Sandi 41c19fe9c0Sandi/** 42f3f0262cSandi * The loginform 4315fae107Sandi * 4415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 45f3f0262cSandi */ 46f3f0262cSandifunction html_login(){ 47f3f0262cSandi global $lang; 48f3f0262cSandi global $conf; 49f3f0262cSandi global $ID; 50cd52f92dSchris global $auth; 51f3f0262cSandi 52c112d578Sandi print p_locale_xhtml('login'); 53f3f0262cSandi ?> 5496331712SAnika Henke <div class="centeralign"> 554da078a3Smatthiasgrimm <form action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 56f3f0262cSandi <fieldset> 574da078a3Smatthiasgrimm <legend><?php echo $lang['btn_login']?></legend> 584da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 59f3f0262cSandi <input type="hidden" name="do" value="login" /> 60b6912aeaSAndreas Gohr <label class="block"> 614da078a3Smatthiasgrimm <span><?php echo $lang['user']?></span> 624da078a3Smatthiasgrimm <input type="text" name="u" value="<?php echo formText($_REQUEST['u'])?>" class="edit" /> 63f3f0262cSandi </label><br /> 64b6912aeaSAndreas Gohr <label class="block"> 654da078a3Smatthiasgrimm <span><?php echo $lang['pass']?></span> 66f3f0262cSandi <input type="password" name="p" class="edit" /> 67f3f0262cSandi </label><br /> 684da078a3Smatthiasgrimm <input type="submit" value="<?php echo $lang['btn_login']?>" class="button" /> 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 7682fd59b6SAndreas Gohr if($auth->canDo('addUser') && $conf['openregister']){ 77f3f0262cSandi print '<p>'; 78f3f0262cSandi print $lang['reghere']; 79f3f0262cSandi print ': <a href="'.wl($ID,'do=register').'" class="wikilink1">'.$lang['register'].'</a>'; 80f3f0262cSandi print '</p>'; 81f3f0262cSandi } 828b06d178Schris 8382fd59b6SAndreas Gohr if ($auth->canDo('modPass') && $conf['resendpasswd']) { 848b06d178Schris print '<p>'; 858b06d178Schris print $lang['pwdforget']; 86753d5abfSMatthias Grimm print ': <a href="'.wl($ID,'do=resendpwd').'" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'; 878b06d178Schris print '</p>'; 888b06d178Schris } 89f3f0262cSandi ?> 90f3f0262cSandi </div> 914da078a3Smatthiasgrimm <?php 926bbae538Sandi/* 936bbae538Sandi FIXME provide new hook 94f3f0262cSandi if(@file_exists('includes/login.txt')){ 95f3f0262cSandi print io_cacheParse('includes/login.txt'); 96f3f0262cSandi } 976bbae538Sandi*/ 98f3f0262cSandi} 99f3f0262cSandi 100f3f0262cSandi/** 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 27250835be7SAndreas 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">'; 3454f732f0eSAnika Henke print '<h3>'.$lang[quickhits].':</h3>'; 3464f732f0eSAnika Henke print '<ul class="search_quickhits">'; 347140c93f3SAnika Henke foreach($data as $id){ 3484f732f0eSAnika Henke print '<li> '; 349506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id); 3504f732f0eSAnika Henke print '</li> '; 351f3f0262cSandi } 352140c93f3SAnika Henke print '</ul> '; 353f3f0262cSandi //clear float (see http://www.complexspiral.com/publications/containing-floats/) 354f3f0262cSandi print '<div class="clearer"> </div>'; 355f3f0262cSandi print '</div>'; 356f3f0262cSandi } 357f3f0262cSandi flush(); 358f3f0262cSandi 359f3f0262cSandi //do fulltext search 360506fa893SAndreas Gohr $data = ft_pageSearch($QUERY,$poswords); 361f3f0262cSandi if(count($data)){ 362506fa893SAndreas Gohr $num = 1; 363506fa893SAndreas Gohr foreach($data as $id => $cnt){ 364f3f0262cSandi print '<div class="search_result">'; 365506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); 366506fa893SAndreas Gohr print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 367506fa893SAndreas Gohr if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 368506fa893SAndreas Gohr print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; 369506fa893SAndreas Gohr } 370f3f0262cSandi print '</div>'; 371506fa893SAndreas Gohr flush(); 372506fa893SAndreas Gohr $num++; 373f3f0262cSandi } 374f3f0262cSandi }else{ 375820fa24bSandi print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 376f3f0262cSandi } 3774d9ff3d5Sandi 3784d9ff3d5Sandi //hide progressbar 3794beabca9SAnika Henke print '<script type="text/javascript" charset="utf-8">'; 3804d9ff3d5Sandi print 'hideLoadBar();'; 3814d9ff3d5Sandi print '</script>'; 382f3f0262cSandi} 383f3f0262cSandi 38415fae107Sandi/** 38515fae107Sandi * Display error on locked pages 38615fae107Sandi * 38715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 38815fae107Sandi */ 389ee20e7d1Sandifunction html_locked(){ 390f3f0262cSandi global $ID; 391f3f0262cSandi global $conf; 392f3f0262cSandi global $lang; 39388f522e9Sandi global $INFO; 394f3f0262cSandi 395f3f0262cSandi $locktime = filemtime(wikiFN($ID).'.lock'); 396f3f0262cSandi $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); 397f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 398f3f0262cSandi 399c112d578Sandi print p_locale_xhtml('locked'); 400f3f0262cSandi print '<ul>'; 4010c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>'; 4020c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 403f3f0262cSandi print '</ul>'; 404f3f0262cSandi} 405f3f0262cSandi 40615fae107Sandi/** 40715fae107Sandi * list old revisions 40815fae107Sandi * 40915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 41015fae107Sandi */ 411f3f0262cSandifunction html_revisions(){ 412f3f0262cSandi global $ID; 413f3f0262cSandi global $INFO; 414f3f0262cSandi global $conf; 415f3f0262cSandi global $lang; 416f3f0262cSandi $revisions = getRevisions($ID); 417f3f0262cSandi $date = @date($conf['dformat'],$INFO['lastmod']); 418f3f0262cSandi 419c112d578Sandi print p_locale_xhtml('revisions'); 420f3f0262cSandi print '<ul>'; 421f3f0262cSandi if($INFO['exists']){ 422b6912aeaSAndreas Gohr print ($INFO['minor']) ? '<li class="minor">' : '<li>'; 4230c6b58a8SAndreas Gohr print '<div class="li">'; 424f9b2fe70Sandi 425f9b2fe70Sandi print $date; 426f9b2fe70Sandi 42702e51121SAnika Henke print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 428cffcc403Sandi 429f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> '; 430652610a2Sandi 431652610a2Sandi print $INFO['sum']; 43288f522e9Sandi print ' <span class="user">'; 43388f522e9Sandi print $INFO['editor']; 43488f522e9Sandi print '</span> '; 435652610a2Sandi 436652610a2Sandi print '('.$lang['current'].')'; 4370c6b58a8SAndreas Gohr print '</div>'; 438652610a2Sandi print '</li>'; 439f3f0262cSandi } 440f3f0262cSandi 441f3f0262cSandi foreach($revisions as $rev){ 442f3f0262cSandi $date = date($conf['dformat'],$rev); 443652610a2Sandi $info = getRevisionInfo($ID,$rev); 444652610a2Sandi 445b6912aeaSAndreas Gohr print ($info['minor']) ? '<li class="minor">' : '<li>'; 4460c6b58a8SAndreas Gohr print '<div class="li">'; 447f9b2fe70Sandi print $date; 448f9b2fe70Sandi 449cffcc403Sandi print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">'; 450d94f4568SAndreas Gohr $p = array(); 451d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 452d94f4568SAndreas Gohr $p['border'] = 0; 453d94f4568SAndreas Gohr $p['width'] = 15; 454d94f4568SAndreas Gohr $p['height'] = 11; 455d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 456d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 457d94f4568SAndreas Gohr $att = buildAttributes($p); 458d94f4568SAndreas Gohr print "<img $att />"; 459cffcc403Sandi print '</a> '; 460cffcc403Sandi 461f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a> '; 462f9b2fe70Sandi 463f243a77fSandi print htmlspecialchars($info['sum']); 46488f522e9Sandi print ' <span class="user">'; 46588f522e9Sandi if($info['user']){ 46688f522e9Sandi print $info['user']; 46788f522e9Sandi }else{ 468652610a2Sandi print $info['ip']; 46988f522e9Sandi } 47088f522e9Sandi print '</span>'; 471652610a2Sandi 4720c6b58a8SAndreas Gohr print '</div>'; 473f3f0262cSandi print '</li>'; 474f3f0262cSandi } 475f3f0262cSandi print '</ul>'; 476f3f0262cSandi} 477f3f0262cSandi 47815fae107Sandi/** 47915fae107Sandi * display recent changes 48015fae107Sandi * 48115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 4825749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 48315fae107Sandi */ 484a39955b0Smatthiasgrimmfunction html_recent($first=0){ 485f3f0262cSandi global $conf; 486cffcc403Sandi global $lang; 487dbb00abcSEsther Brunner global $ID; 4885749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 4895749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 4905749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 4915749f1ceSmatthiasgrimm */ 492b6912aeaSAndreas Gohr $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 4935749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0){ 4945749f1ceSmatthiasgrimm $first=0; 495b6912aeaSAndreas Gohr $recents = getRecents(0,$conf['recent'] + 1,getNS($ID)); 4965749f1ceSmatthiasgrimm } 4975749f1ceSmatthiasgrimm $cnt = count($recents) <= $conf['recent'] ? count($recents) : $conf['recent']; 498f3f0262cSandi 499c112d578Sandi print p_locale_xhtml('recent'); 500f3f0262cSandi print '<ul>'; 501a39955b0Smatthiasgrimm 502d437bcc4SAndreas Gohr foreach($recents as $recent){ 503d437bcc4SAndreas Gohr $date = date($conf['dformat'],$recent['date']); 504b6912aeaSAndreas Gohr print ($recent['minor']) ? '<li class="minor">' : '<li>'; 5050c6b58a8SAndreas Gohr print '<div class="li">'; 506cffcc403Sandi 507f9b2fe70Sandi print $date.' '; 508f9b2fe70Sandi 509d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=diff").'">'; 510d94f4568SAndreas Gohr $p = array(); 511d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 512d94f4568SAndreas Gohr $p['border'] = 0; 513d94f4568SAndreas Gohr $p['width'] = 15; 514d94f4568SAndreas Gohr $p['height'] = 11; 515d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 516d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 517d94f4568SAndreas Gohr $att = buildAttributes($p); 518d94f4568SAndreas Gohr print "<img $att />"; 519cffcc403Sandi print '</a> '; 520cffcc403Sandi 521d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=revisions").'">'; 522d94f4568SAndreas Gohr $p = array(); 523d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/history.png'; 524d94f4568SAndreas Gohr $p['border'] = 0; 525d94f4568SAndreas Gohr $p['width'] = 12; 526d94f4568SAndreas Gohr $p['height'] = 14; 527d94f4568SAndreas Gohr $p['title'] = $lang['btn_revs']; 528d94f4568SAndreas Gohr $p['alt'] = $lang['btn_revs']; 529d94f4568SAndreas Gohr $att = buildAttributes($p); 530d94f4568SAndreas Gohr print "<img $att />"; 531cffcc403Sandi print '</a> '; 532cffcc403Sandi 533d437bcc4SAndreas Gohr print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 534d437bcc4SAndreas Gohr print ' '.htmlspecialchars($recent['sum']); 535b6912aeaSAndreas Gohr 53688f522e9Sandi print ' <span class="user">'; 537d437bcc4SAndreas Gohr if($recent['user']){ 538d437bcc4SAndreas Gohr print $recent['user']; 53988f522e9Sandi }else{ 540d437bcc4SAndreas Gohr print $recent['ip']; 54188f522e9Sandi } 54288f522e9Sandi print '</span>'; 543cffcc403Sandi 5440c6b58a8SAndreas Gohr print '</div>'; 545f3f0262cSandi print '</li>'; 546f3f0262cSandi } 547f3f0262cSandi print '</ul>'; 548a39955b0Smatthiasgrimm 549a39955b0Smatthiasgrimm print '<div class="pagenav">'; 5505749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 551a39955b0Smatthiasgrimm if ($first > 0) { 552a39955b0Smatthiasgrimm $first -= $conf['recent']; 553a39955b0Smatthiasgrimm if ($first < 0) $first = 0; 554a39955b0Smatthiasgrimm print '<div class="pagenav-prev">'; 5555749f1ceSmatthiasgrimm print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); 556a39955b0Smatthiasgrimm print '</div>'; 557a39955b0Smatthiasgrimm } 5585749f1ceSmatthiasgrimm if ($conf['recent'] < count($recents)) { 559a39955b0Smatthiasgrimm print '<div class="pagenav-next">'; 5605749f1ceSmatthiasgrimm print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); 561a39955b0Smatthiasgrimm print '</div>'; 562a39955b0Smatthiasgrimm } 563a39955b0Smatthiasgrimm print '</div>'; 564f3f0262cSandi} 565f3f0262cSandi 56615fae107Sandi/** 56715fae107Sandi * Display page index 56815fae107Sandi * 56915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 57015fae107Sandi */ 571f3f0262cSandifunction html_index($ns){ 572ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 573f3f0262cSandi global $conf; 574f3f0262cSandi global $ID; 575f3f0262cSandi $dir = $conf['datadir']; 576f3f0262cSandi $ns = cleanID($ns); 57730f1737dSandi #fixme use appropriate function 578f3f0262cSandi if(empty($ns)){ 579f3f0262cSandi $ns = dirname(str_replace(':','/',$ID)); 580f3f0262cSandi if($ns == '.') $ns =''; 581f3f0262cSandi } 58288d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 583f3f0262cSandi 584c112d578Sandi print p_locale_xhtml('index'); 585f3f0262cSandi 586f3f0262cSandi $data = array(); 587f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 588cb70c441Sandi print html_buildlist($data,'idx','html_list_index','html_li_index'); 589f3f0262cSandi} 590f3f0262cSandi 591f3f0262cSandi/** 59215fae107Sandi * Index item formatter 59315fae107Sandi * 594f3f0262cSandi * User function for html_buildlist() 59515fae107Sandi * 59615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 597f3f0262cSandi */ 598f3f0262cSandifunction html_list_index($item){ 599f3f0262cSandi $ret = ''; 600f3f0262cSandi $base = ':'.$item['id']; 601f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 602f3f0262cSandi if($item['type']=='d'){ 603f3f0262cSandi $ret .= '<a href="'.wl($ID,'idx='.$item['id']).'" class="idx_dir">'; 604f3f0262cSandi $ret .= $base; 605f3f0262cSandi $ret .= '</a>'; 606f3f0262cSandi }else{ 607f3f0262cSandi $ret .= html_wikilink(':'.$item['id']); 608f3f0262cSandi } 609f3f0262cSandi return $ret; 610f3f0262cSandi} 611f3f0262cSandi 612f3f0262cSandi/** 613cb70c441Sandi * Index List item 614cb70c441Sandi * 615cb70c441Sandi * This user function is used in html_build_lidt to build the 616cb70c441Sandi * <li> tags for namespaces when displaying the page index 617cb70c441Sandi * it gives different classes to opened or closed "folders" 618cb70c441Sandi * 619cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 620cb70c441Sandi */ 621cb70c441Sandifunction html_li_index($item){ 622cb70c441Sandi if($item['type'] == "f"){ 623cb70c441Sandi return '<li class="level'.$item['level'].'">'; 624cb70c441Sandi }elseif($item['open']){ 625cb70c441Sandi return '<li class="open">'; 626cb70c441Sandi }else{ 627cb70c441Sandi return '<li class="closed">'; 628cb70c441Sandi } 629cb70c441Sandi} 630cb70c441Sandi 631cb70c441Sandi/** 632cb70c441Sandi * Default List item 633cb70c441Sandi * 634cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 635cb70c441Sandi */ 636cb70c441Sandifunction html_li_default($item){ 637cb70c441Sandi return '<li class="level'.$item['level'].'">'; 638cb70c441Sandi} 639cb70c441Sandi 640cb70c441Sandi/** 64115fae107Sandi * Build an unordered list 64215fae107Sandi * 643f3f0262cSandi * Build an unordered list from the given $data array 644f3f0262cSandi * Each item in the array has to have a 'level' property 645f3f0262cSandi * the item itself gets printed by the given $func user 646cb70c441Sandi * function. The second and optional function is used to 647cb70c441Sandi * print the <li> tag. Both user function need to accept 648cb70c441Sandi * a single item. 64915fae107Sandi * 65015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 651f3f0262cSandi */ 652cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 653f3f0262cSandi $level = 0; 654f3f0262cSandi $opens = 0; 655f3f0262cSandi $ret = ''; 656f3f0262cSandi 657f3f0262cSandi foreach ($data as $item){ 658f3f0262cSandi 659f3f0262cSandi if( $item['level'] > $level ){ 660f3f0262cSandi //open new list 661df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 662df52d0feSandi if ($i) $ret .= "<li class=\"clear\">\n"; 663f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 664df52d0feSandi } 665f3f0262cSandi }elseif( $item['level'] < $level ){ 666f3f0262cSandi //close last item 667f3f0262cSandi $ret .= "</li>\n"; 668f3f0262cSandi for ($i=0; $i<($level - $item['level']); $i++){ 669f3f0262cSandi //close higher lists 670f3f0262cSandi $ret .= "</ul>\n</li>\n"; 671f3f0262cSandi } 672f3f0262cSandi }else{ 673f3f0262cSandi //close last item 674f3f0262cSandi $ret .= "</li>\n"; 675f3f0262cSandi } 676f3f0262cSandi 677f3f0262cSandi //remember current level 678f3f0262cSandi $level = $item['level']; 679f3f0262cSandi 680f3f0262cSandi //print item 681cb70c441Sandi $ret .= $lifunc($item); //user function 6820c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 683f3f0262cSandi $ret .= $func($item); //user function 6840c6b58a8SAndreas Gohr $ret .= '</div>'; 685f3f0262cSandi } 686f3f0262cSandi 687f3f0262cSandi //close remaining items and lists 688f3f0262cSandi for ($i=0; $i < $level; $i++){ 689f3f0262cSandi $ret .= "</li></ul>\n"; 690f3f0262cSandi } 691f3f0262cSandi 692f3f0262cSandi return $ret; 693f3f0262cSandi} 694f3f0262cSandi 69515fae107Sandi/** 69615fae107Sandi * display backlinks 69715fae107Sandi * 69815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 69915fae107Sandi */ 700f3f0262cSandifunction html_backlinks(){ 70154f4c056SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 702f3f0262cSandi global $ID; 703f3f0262cSandi global $conf; 704f3f0262cSandi 705c112d578Sandi print p_locale_xhtml('backlinks'); 706f3f0262cSandi 70754f4c056SAndreas Gohr $data = ft_backlinks($ID); 708f3f0262cSandi 709f3f0262cSandi print '<ul class="idx">'; 71054f4c056SAndreas Gohr foreach($data as $blink){ 7110c6b58a8SAndreas Gohr print '<li><div class="li">'; 71254f4c056SAndreas Gohr print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 7130c6b58a8SAndreas Gohr print '</div></li>'; 714f3f0262cSandi } 715f3f0262cSandi print '</ul>'; 716f3f0262cSandi} 717f3f0262cSandi 71815fae107Sandi/** 71915fae107Sandi * show diff 72015fae107Sandi * 72115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 72215fae107Sandi */ 723f3f0262cSandifunction html_diff($text='',$intro=true){ 724ed7b5f09Sandi require_once(DOKU_INC.'inc/DifferenceEngine.php'); 725f3f0262cSandi global $ID; 726f3f0262cSandi global $REV; 727f3f0262cSandi global $lang; 728f3f0262cSandi global $conf; 729f3f0262cSandi if($text){ 730f3f0262cSandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,''))), 731f3f0262cSandi split("\n",htmlspecialchars(cleanText($text)))); 732f3f0262cSandi $left = '<a class="wikilink1" href="'.wl($ID).'">'. 733f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a>'. 734f3f0262cSandi $lang['current']; 735f3f0262cSandi $right = $lang['yours']; 736f3f0262cSandi }else{ 7374d58bd99Sandi if($REV){ 7384d58bd99Sandi $r = $REV; 7394d58bd99Sandi }else{ 7404d58bd99Sandi //use last revision if none given 7414d58bd99Sandi $revs = getRevisions($ID); 7424d58bd99Sandi $r = $revs[0]; 7434d58bd99Sandi } 7444d58bd99Sandi 7454d58bd99Sandi $df = new Diff(split("\n",htmlspecialchars(rawWiki($ID,$r))), 746f3f0262cSandi split("\n",htmlspecialchars(rawWiki($ID,'')))); 7474d58bd99Sandi $left = '<a class="wikilink1" href="'.wl($ID,"rev=$r").'">'. 7484d58bd99Sandi $ID.' '.date($conf['dformat'],$r).'</a>'; 749f3f0262cSandi $right = '<a class="wikilink1" href="'.wl($ID).'">'. 750f3f0262cSandi $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 751f3f0262cSandi $lang['current']; 752f3f0262cSandi } 753f3f0262cSandi $tdf = new TableDiffFormatter(); 754c112d578Sandi if($intro) print p_locale_xhtml('diff'); 755f3f0262cSandi ?> 756f3f0262cSandi <table class="diff" width="100%"> 757f3f0262cSandi <tr> 758f3f0262cSandi <td colspan="2" width="50%" class="diff-header"> 7594da078a3Smatthiasgrimm <?php echo $left?> 760f3f0262cSandi </td> 761f3f0262cSandi <td colspan="2" width="50%" class="diff-header"> 7624da078a3Smatthiasgrimm <?php echo $right?> 763f3f0262cSandi </td> 764f3f0262cSandi </tr> 7654da078a3Smatthiasgrimm <?php echo $tdf->format($df)?> 766f3f0262cSandi </table> 7674da078a3Smatthiasgrimm <?php 768f3f0262cSandi} 769f3f0262cSandi 77015fae107Sandi/** 77115fae107Sandi * show warning on conflict detection 77215fae107Sandi * 77315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 77415fae107Sandi */ 775f3f0262cSandifunction html_conflict($text,$summary){ 776f3f0262cSandi global $ID; 777f3f0262cSandi global $lang; 778f3f0262cSandi 779c112d578Sandi print p_locale_xhtml('conflict'); 780f3f0262cSandi ?> 7811dd0c202SAnika Henke <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"> 78296331712SAnika Henke <div class="centeralign"> 7834da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 7844da078a3Smatthiasgrimm <input type="hidden" name="wikitext" value="<?php echo formText($text)?>" /> 7854da078a3Smatthiasgrimm <input type="hidden" name="summary" value="<?php echo formText($summary)?>" /> 786f3f0262cSandi 7874da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_save']?>" accesskey="s" title="[ALT+S]" /> 7884da078a3Smatthiasgrimm <input class="button" type="submit" name="do" value="<?php echo $lang['btn_cancel']?>" /> 789f3f0262cSandi </div> 790f3f0262cSandi </form> 791f3f0262cSandi <br /><br /><br /><br /> 7924da078a3Smatthiasgrimm <?php 793f3f0262cSandi} 794f3f0262cSandi 795f3f0262cSandi/** 79615fae107Sandi * Prints the global message array 79715fae107Sandi * 79815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 799f3f0262cSandi */ 800f3f0262cSandifunction html_msgarea(){ 801f3f0262cSandi global $MSG; 802f3f0262cSandi 803f3f0262cSandi if(!isset($MSG)) return; 804f3f0262cSandi 805f3f0262cSandi foreach($MSG as $msg){ 806f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 807f3f0262cSandi print $msg['msg']; 808f3f0262cSandi print '</div>'; 809f3f0262cSandi } 810f3f0262cSandi} 811f3f0262cSandi 812f3f0262cSandi/** 813f3f0262cSandi * Prints the registration form 81415fae107Sandi * 81515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 816f3f0262cSandi */ 817f3f0262cSandifunction html_register(){ 818f3f0262cSandi global $lang; 819cab2716aSmatthias.grimm global $conf; 820f3f0262cSandi global $ID; 821f3f0262cSandi 822c112d578Sandi print p_locale_xhtml('register'); 823f3f0262cSandi?> 82496331712SAnika Henke <div class="centeralign"> 8251dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 82696331712SAnika Henke <fieldset> 827f3f0262cSandi <input type="hidden" name="do" value="register" /> 828f3f0262cSandi <input type="hidden" name="save" value="1" /> 82996331712SAnika Henke 8304da078a3Smatthiasgrimm <legend><?php echo $lang['register']?></legend> 831b6912aeaSAndreas Gohr <label class="block"> 8324da078a3Smatthiasgrimm <?php echo $lang['user']?> 8334da078a3Smatthiasgrimm <input type="text" name="login" class="edit" size="50" value="<?php echo formText($_POST['login'])?>" /> 834f3f0262cSandi </label><br /> 835cab2716aSmatthias.grimm 836cab2716aSmatthias.grimm <?php 837cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 838cab2716aSmatthias.grimm ?> 839b6912aeaSAndreas Gohr <label class="block"> 8404da078a3Smatthiasgrimm <?php echo $lang['pass']?> 841cab2716aSmatthias.grimm <input type="password" name="pass" class="edit" size="50" /> 842cab2716aSmatthias.grimm </label><br /> 843b6912aeaSAndreas Gohr <label class="block"> 8444da078a3Smatthiasgrimm <?php echo $lang['passchk']?> 845cab2716aSmatthias.grimm <input type="password" name="passchk" class="edit" size="50" /> 846cab2716aSmatthias.grimm </label><br /> 847cab2716aSmatthias.grimm <?php 848cab2716aSmatthias.grimm } 849cab2716aSmatthias.grimm ?> 850cab2716aSmatthias.grimm 851b6912aeaSAndreas Gohr <label class="block"> 8524da078a3Smatthiasgrimm <?php echo $lang['fullname']?> 8534da078a3Smatthiasgrimm <input type="text" name="fullname" class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 854f3f0262cSandi </label><br /> 855b6912aeaSAndreas Gohr <label class="block"> 8564da078a3Smatthiasgrimm <?php echo $lang['email']?> 8574da078a3Smatthiasgrimm <input type="text" name="email" class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 858f3f0262cSandi </label><br /> 8594da078a3Smatthiasgrimm <input type="submit" class="button" value="<?php echo $lang['register']?>" /> 860f3f0262cSandi </fieldset> 861f3f0262cSandi </form> 862f3f0262cSandi </div> 8634da078a3Smatthiasgrimm<?php 864f3f0262cSandi} 865f3f0262cSandi 866f3f0262cSandi/** 8678b06d178Schris * Print the update profile form 8688b06d178Schris * 8698b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 8708b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 8718b06d178Schris */ 8728b06d178Schrisfunction html_updateprofile(){ 8738b06d178Schris global $lang; 8748b06d178Schris global $conf; 8758b06d178Schris global $ID; 8768b06d178Schris global $INFO; 87782fd59b6SAndreas Gohr global $auth; 8788b06d178Schris 8798b06d178Schris print p_locale_xhtml('updateprofile'); 8808b06d178Schris 8818b06d178Schris if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 8828b06d178Schris if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 8838b06d178Schris?> 88496331712SAnika Henke <div class="centeralign"> 8851dd0c202SAnika Henke <form id="dw__register" method="post" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>"> 88696331712SAnika Henke <fieldset style="width: 80%;"> 8878b06d178Schris <input type="hidden" name="do" value="profile" /> 8888b06d178Schris <input type="hidden" name="save" value="1" /> 88996331712SAnika Henke 8908b06d178Schris <legend><?php echo $lang['profile']?></legend> 8918b06d178Schris <label class="block"> 8928b06d178Schris <?php echo $lang['user']?> 8938b06d178Schris <input type="text" name="fullname" disabled="disabled" class="edit" size="50" value="<?php echo formText($_SERVER['REMOTE_USER'])?>" /> 8948b06d178Schris </label><br /> 8958b06d178Schris <label class="block"> 8968b06d178Schris <?php echo $lang['fullname']?> 89782fd59b6SAndreas Gohr <input type="text" name="fullname" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['fullname'])?>" /> 8988b06d178Schris </label><br /> 8998b06d178Schris <label class="block"> 9008b06d178Schris <?php echo $lang['email']?> 90182fd59b6SAndreas Gohr <input type="text" name="email" <?php if(!$auth->canDo('modName')) echo 'disabled="disabled"'?> class="edit" size="50" value="<?php echo formText($_POST['email'])?>" /> 9028b06d178Schris </label><br /><br /> 90382fd59b6SAndreas Gohr 90482fd59b6SAndreas Gohr <?php if($auth->canDo('modPass')) { ?> 9058b06d178Schris <label class="block"> 9068b06d178Schris <?php echo $lang['newpass']?> 9078b06d178Schris <input type="password" name="newpass" class="edit" size="50" /> 9088b06d178Schris </label><br /> 9098b06d178Schris <label class="block"> 9108b06d178Schris <?php echo $lang['passchk']?> 9118b06d178Schris <input type="password" name="passchk" class="edit" size="50" /> 9128b06d178Schris </label><br /> 91382fd59b6SAndreas Gohr <?php } ?> 9148b06d178Schris 9158b06d178Schris <?php if ($conf['profileconfirm']) { ?> 9168b06d178Schris <br /> 9178b06d178Schris <label class="block"> 9188b06d178Schris <?php echo $lang['oldpass']?> 9198b06d178Schris <input type="password" name="oldpass" class="edit" size="50" /> 9208b06d178Schris </label><br /> 9218b06d178Schris <?php } ?> 9228b06d178Schris 9234cb79657SMatthias Grimm <input type="submit" class="button" value="<?php echo $lang['btn_save']?>" /> 9248b06d178Schris <input type="reset" class="button" value="<?php echo $lang['btn_reset']?>" /> 9258b06d178Schris </fieldset> 9268b06d178Schris </form> 9278b06d178Schris </div> 9288b06d178Schris<?php 9298b06d178Schris} 9308b06d178Schris 9318b06d178Schris/** 932f3f0262cSandi * This displays the edit form (lots of logic included) 93315fae107Sandi * 9347146cee2SAndreas Gohr * @fixme this is a huge lump of code and should be modularized 93515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 936f3f0262cSandi */ 937f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed? 938f3f0262cSandi global $ID; 939f3f0262cSandi global $REV; 940f3f0262cSandi global $DATE; 941f3f0262cSandi global $RANGE; 942f3f0262cSandi global $PRE; 943f3f0262cSandi global $SUF; 944f3f0262cSandi global $INFO; 945f3f0262cSandi global $SUM; 946f3f0262cSandi global $lang; 947f3f0262cSandi global $conf; 948f3f0262cSandi 949f3f0262cSandi //set summary default 950f3f0262cSandi if(!$SUM){ 951f3f0262cSandi if($REV){ 952f3f0262cSandi $SUM = $lang['restored']; 953f3f0262cSandi }elseif(!$INFO['exists']){ 954f3f0262cSandi $SUM = $lang['created']; 955f3f0262cSandi } 956f3f0262cSandi } 957f3f0262cSandi 958f3f0262cSandi //no text? Load it! 959f3f0262cSandi if(!isset($text)){ 960f3f0262cSandi $pr = false; //no preview mode 9617146cee2SAndreas Gohr if($INFO['exists']){ 962f3f0262cSandi if($RANGE){ 963f3f0262cSandi list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 964f3f0262cSandi }else{ 965f3f0262cSandi $text = rawWiki($ID,$REV); 966f3f0262cSandi } 967f3f0262cSandi }else{ 9687146cee2SAndreas Gohr //try to load a pagetemplate 9697146cee2SAndreas Gohr $text = pageTemplate($ID); 9707146cee2SAndreas Gohr } 9717146cee2SAndreas Gohr }else{ 972f3f0262cSandi $pr = true; //preview mode 973f3f0262cSandi } 974f3f0262cSandi 975f3f0262cSandi $wr = $INFO['writable']; 976f3f0262cSandi if($wr){ 977c112d578Sandi if ($REV) print p_locale_xhtml('editrev'); 978c112d578Sandi print p_locale_xhtml($include); 979f3f0262cSandi }else{ 980c112d578Sandi print p_locale_xhtml('read'); 981f3f0262cSandi $ro='readonly="readonly"'; 982f3f0262cSandi } 983f3f0262cSandi if(!$DATE) $DATE = $INFO['lastmod']; 984dc57ef04Sandi 985dc57ef04Sandi 986f3f0262cSandi?> 98763afe2a6SAnika Henke <div style="width:99%;"> 98863afe2a6SAnika Henke <form id="dw__editform" method="post" action="<?php echo script()?>" accept-charset="<?php echo $lang['encoding']?>"><div class="no"> 98963afe2a6SAnika Henke <div class="toolbar"> 99096331712SAnika Henke <div id="toolbar"></div> 9914da078a3Smatthiasgrimm <input type="hidden" name="id" value="<?php echo $ID?>" /> 9924da078a3Smatthiasgrimm <input type="hidden" name="rev" value="<?php echo $REV?>" /> 9934da078a3Smatthiasgrimm <input type="hidden" name="date" value="<?php echo $DATE?>" /> 9944da078a3Smatthiasgrimm <input type="hidden" name="prefix" value="<?php echo formText($PRE)?>" /> 9954da078a3Smatthiasgrimm <input type="hidden" name="suffix" value="<?php echo formText($SUF)?>" /> 99620d062caSAndreas Gohr 9974da078a3Smatthiasgrimm <?php if($wr){?> 9984beabca9SAnika Henke <script type="text/javascript" charset="utf-8"> 9994da078a3Smatthiasgrimm <?php /* sets changed to true when previewed */?> 10004da078a3Smatthiasgrimm textChanged = <?php ($pr) ? print 'true' : print 'false' ?>; 1001f3f0262cSandi </script> 100258bef989Smatthiasgrimm <span id="spell_action"></span> 10034da078a3Smatthiasgrimm <?php } ?> 1004dc57ef04Sandi <div id="spell_suggest"></div> 100563afe2a6SAnika Henke </div> 1006dc57ef04Sandi <div id="spell_result"></div> 100763afe2a6SAnika Henke 10085e163278SAndreas Gohr <textarea name="wikitext" id="wikitext" <?php echo $ro?> cols="80" rows="10" class="edit" tabindex="1"><?php echo "\n".formText($text)?></textarea> 100963afe2a6SAnika Henke 101063afe2a6SAnika Henke <div id="wikieditbar"> 101163afe2a6SAnika Henke <div id="sizectl"></div> 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 } ?> 10174da078a3Smatthiasgrimm <?php if($wr){ ?> 101863afe2a6SAnika Henke <span class="summary"> 101963afe2a6SAnika Henke <label for="summary"><?php echo $lang['summary']?>:</label> 10205e163278SAndreas Gohr <input type="text" class="edit" name="summary" id="summary" size="50" value="<?php echo formText($SUM)?>" tabindex="2" /> 1021b6912aeaSAndreas Gohr <?php html_minoredit()?> 102263afe2a6SAnika Henke </span> 10234da078a3Smatthiasgrimm <?php }?> 102463afe2a6SAnika Henke </div> 102563afe2a6SAnika Henke </div></form> 102663afe2a6SAnika Henke </div> 10274da078a3Smatthiasgrimm<?php 1028f3f0262cSandi} 1029f3f0262cSandi 1030f3f0262cSandi/** 1031b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1032b6912aeaSAndreas Gohr * 1033b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org> 1034b6912aeaSAndreas Gohr */ 1035b6912aeaSAndreas Gohrfunction html_minoredit(){ 1036b6912aeaSAndreas Gohr global $conf; 1037b6912aeaSAndreas Gohr global $lang; 1038b6912aeaSAndreas Gohr // minor edits are for logged in users only 1039b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1040b6912aeaSAndreas Gohr return; 1041b6912aeaSAndreas Gohr } 1042b6912aeaSAndreas Gohr 1043b6912aeaSAndreas Gohr $p = array(); 1044b6912aeaSAndreas Gohr $p['name'] = 'minor'; 1045b6912aeaSAndreas Gohr $p['type'] = 'checkbox'; 1046b6912aeaSAndreas Gohr $p['id'] = 'minoredit'; 1047b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1048b6912aeaSAndreas Gohr $p['value'] = '1'; 1049b6912aeaSAndreas Gohr if($_REQUEST['minor']) $p['checked']='checked'; 1050b6912aeaSAndreas Gohr $att = buildAttributes($p); 1051b6912aeaSAndreas Gohr 1052b6912aeaSAndreas Gohr print "<input $att />"; 1053b6912aeaSAndreas Gohr print '<label for="minoredit">'; 1054b6912aeaSAndreas Gohr print $lang['minoredit']; 1055b6912aeaSAndreas Gohr print '</label>'; 1056b6912aeaSAndreas Gohr} 1057b6912aeaSAndreas Gohr 1058b6912aeaSAndreas Gohr/** 1059f3f0262cSandi * prints some debug info 106015fae107Sandi * 106115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1062f3f0262cSandi */ 1063f3f0262cSandifunction html_debug(){ 1064f3f0262cSandi global $conf; 1065d16a4edaSandi global $lang; 1066*5298a619SAndreas Gohr global $auth; 106728fb55ffSandi //remove sensitive data 106828fb55ffSandi $cnf = $conf; 106928fb55ffSandi $cnf['auth']='***'; 107028fb55ffSandi $cnf['notify']='***'; 10713dc3a5f1Sandi $cnf['ftp']='***'; 1072f3f0262cSandi 1073f3f0262cSandi print '<html><body>'; 1074f3f0262cSandi 1075f3f0262cSandi print '<p>When reporting bugs please send all the following '; 1076f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 1077f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 1078f3f0262cSandi 1079f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 1080f3f0262cSandi print_r($_SERVER); 1081f3f0262cSandi print '</pre>'; 1082f3f0262cSandi 1083f3f0262cSandi print '<b>$conf:</b><pre>'; 108428fb55ffSandi print_r($cnf); 1085f3f0262cSandi print '</pre>'; 1086f3f0262cSandi 1087ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 1088ed7b5f09Sandi print DOKU_BASE; 1089f3f0262cSandi print '</pre>'; 1090f3f0262cSandi 1091ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 1092ed7b5f09Sandi print DOKU_URL; 1093ed7b5f09Sandi print '</pre>'; 1094ed7b5f09Sandi 1095ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 1096f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 1097f3f0262cSandi print '</pre>'; 1098f3f0262cSandi 1099f3f0262cSandi print '<b>PHP Version:</b><pre>'; 1100f3f0262cSandi print phpversion(); 1101f3f0262cSandi print '</pre>'; 1102f3f0262cSandi 1103f3f0262cSandi print '<b>locale:</b><pre>'; 1104f3f0262cSandi print setlocale(LC_ALL,0); 1105f3f0262cSandi print '</pre>'; 1106f3f0262cSandi 1107d16a4edaSandi print '<b>encoding:</b><pre>'; 1108d16a4edaSandi print $lang['encoding']; 1109d16a4edaSandi print '</pre>'; 1110d16a4edaSandi 1111*5298a619SAndreas Gohr if($auth){ 1112*5298a619SAndreas Gohr print '<b>Auth backend capabilities:</b><pre>'; 1113*5298a619SAndreas Gohr print_r($auth->cando); 1114*5298a619SAndreas Gohr print '</pre>'; 1115*5298a619SAndreas Gohr } 1116*5298a619SAndreas Gohr 11173aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 11183aa54d7cSAndreas Gohr print_r($_SESSION); 11193aa54d7cSAndreas Gohr print '</pre>'; 11203aa54d7cSAndreas Gohr 1121f3f0262cSandi print '<b>Environment:</b><pre>'; 1122f3f0262cSandi print_r($_ENV); 1123f3f0262cSandi print '</pre>'; 1124f3f0262cSandi 1125f3f0262cSandi print '<b>PHP settings:</b><pre>'; 1126f3f0262cSandi $inis = ini_get_all(); 1127f3f0262cSandi print_r($inis); 1128f3f0262cSandi print '</pre>'; 1129f3f0262cSandi 1130f3f0262cSandi print '</body></html>'; 1131f3f0262cSandi} 1132f3f0262cSandi 1133c19fe9c0Sandifunction html_admin(){ 1134c19fe9c0Sandi global $ID; 1135c19fe9c0Sandi global $lang; 1136ca3a6df1SMatthias Grimm global $conf; 1137c19fe9c0Sandi 1138c112d578Sandi print p_locale_xhtml('admin'); 1139c19fe9c0Sandi 114011e2ce22Schris // build menu of admin functions from the plugins that handle them 114111e2ce22Schris $pluginlist = plugin_list('admin'); 114211e2ce22Schris $menu = array(); 114311e2ce22Schris foreach ($pluginlist as $p) { 114411e2ce22Schris if($obj =& plugin_load('admin',$p) === NULL) continue; 114511e2ce22Schris $menu[] = array('plugin' => $p, 114611e2ce22Schris 'prompt' => $obj->getMenuText($conf['lang']), 114711e2ce22Schris 'sort' => $obj->getMenuSort() 114811e2ce22Schris ); 114911e2ce22Schris } 115011e2ce22Schris 115111e2ce22Schris usort($menu, p_sort_modes); 115211e2ce22Schris 115311e2ce22Schris // output the menu 115411e2ce22Schris ptln('<ul>'); 115511e2ce22Schris 115611e2ce22Schris foreach ($menu as $item) { 115711e2ce22Schris if (!$item['prompt']) continue; 11580c6b58a8SAndreas Gohr ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 115911e2ce22Schris } 116011e2ce22Schris 116111e2ce22Schris // add in non-plugin functions 116211e2ce22Schris if (!$conf['openregister']){ 11630c6b58a8SAndreas Gohr ptln('<li><div class="li"><a href="'.wl($ID,'do=register').'">'.$lang['admin_register'].'</a></div></li>'); 116411e2ce22Schris } 116511e2ce22Schris 116611e2ce22Schris ptln('</ul>'); 1167ca3a6df1SMatthias Grimm} 1168c19fe9c0Sandi 11698b06d178Schris/** 11708b06d178Schris * Form to request a new password for an existing account 11718b06d178Schris * 11728b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 117311e2ce22Schris */ 11748b06d178Schrisfunction html_resendpwd() { 11758b06d178Schris global $lang; 11768b06d178Schris global $conf; 11778b06d178Schris global $ID; 1178c19fe9c0Sandi 11798b06d178Schris print p_locale_xhtml('resendpwd'); 11808b06d178Schris?> 118196331712SAnika Henke <div class="centeralign"> 11821dd0c202SAnika Henke <form id="dw__resendpwd" action="<?php echo wl($ID)?>" accept-charset="<?php echo $lang['encoding']?>" method="post"> 11838b06d178Schris <fieldset> 11848b06d178Schris <br /> 1185753d5abfSMatthias Grimm <legend><?php echo $lang['resendpwd']?></legend> 11868b06d178Schris <input type="hidden" name="do" value="resendpwd" /> 11878b06d178Schris <input type="hidden" name="save" value="1" /> 11888b06d178Schris <label class="block"> 11898b06d178Schris <span><?php echo $lang['user']?></span> 11908b06d178Schris <input type="text" name="login" value="<?php echo formText($_POST['login'])?>" class="edit" /><br /><br /> 11918b06d178Schris </label><br /> 11928b06d178Schris <input type="submit" value="<?php echo $lang['btn_resendpwd']?>" class="button" /> 11938b06d178Schris </fieldset> 11948b06d178Schris </form> 11958b06d178Schris </div> 11968b06d178Schris<?php 11978b06d178Schris} 1198340756e4Sandi 1199340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 : 1200