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 900976812SAndreas Gohrif(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/'); 10e226efe1SAndreas Gohrif(!defined('NL')) define('NL',"\n"); 116bbae538Sandirequire_once(DOKU_INC.'inc/parserutils.php'); 12fdb8d77bSTom N Harrisrequire_once(DOKU_INC.'inc/form.php'); 136bbae538Sandi 14f3f0262cSandi/** 15f3f0262cSandi * Convenience function to quickly build a wikilink 1615fae107Sandi * 1715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 18f3f0262cSandi */ 1930f1737dSandifunction html_wikilink($id,$name=NULL,$search=''){ 20723d78dbSandi static $xhtml_renderer = NULL; 21723d78dbSandi if(is_null($xhtml_renderer)){ 22fdf3dcb9SMatthias Urlichs require_once(DOKU_INC.'inc/parser/xhtml.php'); 23723d78dbSandi $xhtml_renderer = new Doku_Renderer_xhtml(); 24f3f0262cSandi } 25f3f0262cSandi 26cffcc403Sandi return $xhtml_renderer->internallink($id,$name,$search,true); 27f3f0262cSandi} 28f3f0262cSandi 29f3f0262cSandi/** 30c19fe9c0Sandi * Helps building long attribute lists 31c19fe9c0Sandi * 32c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 33c19fe9c0Sandi */ 34c19fe9c0Sandifunction html_attbuild($attributes){ 35c19fe9c0Sandi $ret = ''; 36c19fe9c0Sandi foreach ( $attributes as $key => $value ) { 37c19fe9c0Sandi $ret .= $key.'="'.formtext($value).'" '; 38c19fe9c0Sandi } 39c19fe9c0Sandi return trim($ret); 40c19fe9c0Sandi} 41c19fe9c0Sandi 42c19fe9c0Sandi/** 43f3f0262cSandi * The loginform 4415fae107Sandi * 4515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 46f3f0262cSandi */ 47f3f0262cSandifunction html_login(){ 48f3f0262cSandi global $lang; 49f3f0262cSandi global $conf; 50f3f0262cSandi global $ID; 51cd52f92dSchris global $auth; 52f3f0262cSandi 53c112d578Sandi print p_locale_xhtml('login'); 54fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 55fdb8d77bSTom N Harris $form = new Doku_Form('dw__login'); 56fdb8d77bSTom N Harris $form->startFieldset($lang['btn_login']); 57fdb8d77bSTom N Harris $form->addHidden('id', $ID); 58fdb8d77bSTom N Harris $form->addHidden('do', 'login'); 59fdb8d77bSTom N Harris $form->addElement(form_makeTextField('u', $_REQUEST['u'], $lang['user'], 'focus__this', 'block')); 60fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); 61fdb8d77bSTom N Harris $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); 62fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); 63fdb8d77bSTom N Harris $form->endFieldset(); 64fdb8d77bSTom N Harris html_form('login', $form); 655b62573aSAndreas Gohr 666957b2eaSAndreas Gohr if($auth && $auth->canDo('addUser') && actionOK('register')){ 67f3f0262cSandi print '<p>'; 68f3f0262cSandi print $lang['reghere']; 691d5856cfSAndreas Gohr print ': <a href="'.wl($ID,'do=register').'" rel="nofollow" class="wikilink1">'.$lang['register'].'</a>'; 70f3f0262cSandi print '</p>'; 71f3f0262cSandi } 728b06d178Schris 736957b2eaSAndreas Gohr if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { 748b06d178Schris print '<p>'; 758b06d178Schris print $lang['pwdforget']; 761d5856cfSAndreas Gohr print ': <a href="'.wl($ID,'do=resendpwd').'" rel="nofollow" class="wikilink1">'.$lang['btn_resendpwd'].'</a>'; 778b06d178Schris print '</p>'; 788b06d178Schris } 79fdb8d77bSTom N Harris print '</div>'.NL; 80f3f0262cSandi} 81f3f0262cSandi 82f3f0262cSandi/** 8315fae107Sandi * prints a section editing button 8435dae8b0SBen Coburn * used as a callback in html_secedit 8515fae107Sandi * 8615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 8715fae107Sandi */ 8835dae8b0SBen Coburnfunction html_secedit_button($matches){ 89f3f0262cSandi global $ID; 90041d7a86SBen Coburn global $INFO; 91041d7a86SBen Coburn 92041d7a86SBen Coburn $section = $matches[2]; 93041d7a86SBen Coburn $name = $matches[1]; 94041d7a86SBen Coburn 95f3f0262cSandi $secedit = ''; 96f3f0262cSandi $secedit .= '<div class="secedit">'; 97f3f0262cSandi $secedit .= html_btn('secedit',$ID,'', 98f3f0262cSandi array('do' => 'edit', 99306b2c85SDenis Simakov 'lines' => "$section", 100306b2c85SDenis Simakov 'rev' => $INFO['lastmod']), 10135dae8b0SBen Coburn 'post', $name); 102f3f0262cSandi $secedit .= '</div>'; 103f3f0262cSandi return $secedit; 104f3f0262cSandi} 105f3f0262cSandi 10615fae107Sandi/** 10715fae107Sandi * inserts section edit buttons if wanted or removes the markers 10815fae107Sandi * 10915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 11015fae107Sandi */ 111f3f0262cSandifunction html_secedit($text,$show=true){ 112f3f0262cSandi global $INFO; 11335dae8b0SBen Coburn 114c112d578Sandi if($INFO['writable'] && $show && !$INFO['rev']){ 11535dae8b0SBen Coburn $text = preg_replace_callback('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#', 11635dae8b0SBen Coburn 'html_secedit_button', $text); 117f3f0262cSandi }else{ 11835dae8b0SBen Coburn $text = preg_replace('#<!-- SECTION "(.*?)" \[(\d+-\d*)\] -->#','',$text); 119f3f0262cSandi } 12035dae8b0SBen Coburn 121f3f0262cSandi return $text; 122f3f0262cSandi} 123f3f0262cSandi 124f3f0262cSandi/** 125d6c9c552Smatthiasgrimm * Just the back to top button (in its own form) 1266b13307fSandi * 1276b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 1286b13307fSandi */ 1296b13307fSandifunction html_topbtn(){ 1306b13307fSandi global $lang; 1316b13307fSandi 1326b13307fSandi $ret = ''; 13311ea018fSAndreas Gohr $ret = '<a class="nolink" href="#dokuwiki__top"><input type="button" class="button" value="'.$lang['btn_top'].'" onclick="window.scrollTo(0, 0)" title="'.$lang['btn_top'].'" /></a>'; 134df7b6005Sandi 1356b13307fSandi return $ret; 1366b13307fSandi} 1376b13307fSandi 1386b13307fSandi/** 139d67ca2c0Smatthiasgrimm * Displays a button (using its own form) 14035dae8b0SBen Coburn * If tooltip exists, the access key tooltip is replaced. 14115fae107Sandi * 14215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 143f3f0262cSandi */ 14435dae8b0SBen Coburnfunction html_btn($name,$id,$akey,$params,$method='get',$tooltip=''){ 145f3f0262cSandi global $conf; 146f3f0262cSandi global $lang; 147f3f0262cSandi 148f3f0262cSandi $label = $lang['btn_'.$name]; 149f3f0262cSandi 150f3f0262cSandi $ret = ''; 15135dae8b0SBen Coburn $tip = ''; 152f3f0262cSandi 15349c713a3Sandi //filter id (without urlencoding) 15449c713a3Sandi $id = idfilter($id,false); 155f3f0262cSandi 156f3f0262cSandi //make nice URLs even for buttons 1576c7843b5Sandi if($conf['userewrite'] == 2){ 1586c7843b5Sandi $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 1596c7843b5Sandi }elseif($conf['userewrite']){ 1606c7843b5Sandi $script = DOKU_BASE.$id; 1616c7843b5Sandi }else{ 1628b00ebcfSandi $script = DOKU_BASE.DOKU_SCRIPT; 163f3f0262cSandi $params['id'] = $id; 164f3f0262cSandi } 165f3f0262cSandi 166*b278f2deSAndreas Gohr $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">'; 167f3f0262cSandi 16806a4bf8fSAndreas Gohr if(is_array($params)){ 169f3f0262cSandi reset($params); 170f3f0262cSandi while (list($key, $val) = each($params)) { 171f3f0262cSandi $ret .= '<input type="hidden" name="'.$key.'" '; 172f3f0262cSandi $ret .= 'value="'.htmlspecialchars($val).'" />'; 173f3f0262cSandi } 17406a4bf8fSAndreas Gohr } 175f3f0262cSandi 17635dae8b0SBen Coburn if ($tooltip!='') { 17735dae8b0SBen Coburn $tip = htmlspecialchars($tooltip); 17811ea018fSAndreas Gohr }else{ 17911ea018fSAndreas Gohr $tip = htmlspecialchars($label); 18011ea018fSAndreas Gohr } 18111ea018fSAndreas Gohr 18211ea018fSAndreas Gohr $ret .= '<input type="submit" value="'.htmlspecialchars($label).'" class="button" '; 18311ea018fSAndreas Gohr if($akey){ 18411ea018fSAndreas Gohr $tip .= ' [ALT+'.strtoupper($akey).']'; 18511ea018fSAndreas Gohr $ret .= 'accesskey="'.$akey.'" '; 18635dae8b0SBen Coburn } 18735dae8b0SBen Coburn $ret .= 'title="'.$tip.'" '; 188f3f0262cSandi $ret .= '/>'; 1894beabca9SAnika Henke $ret .= '</div></form>'; 190f3f0262cSandi 191f3f0262cSandi return $ret; 192f3f0262cSandi} 193f3f0262cSandi 194f3f0262cSandi/** 19515fae107Sandi * show a wiki page 19615fae107Sandi * 19715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 19815fae107Sandi */ 1996bbae538Sandifunction html_show($txt=''){ 200f3f0262cSandi global $ID; 201f3f0262cSandi global $REV; 202f3f0262cSandi global $HIGH; 203b8595a66SAndreas Gohr global $INFO; 204f3f0262cSandi //disable section editing for old revisions or in preview 2055400331dSandi if($txt || $REV){ 2066bbae538Sandi $secedit = false; 2076bbae538Sandi }else{ 2086bbae538Sandi $secedit = true; 209f3f0262cSandi } 210f3f0262cSandi 2116bbae538Sandi if ($txt){ 212f3f0262cSandi //PreviewHeader 213b8595a66SAndreas Gohr echo '<br id="scroll__here" />'; 214b8595a66SAndreas Gohr echo p_locale_xhtml('preview'); 215b8595a66SAndreas Gohr echo '<div class="preview">'; 216b8595a66SAndreas Gohr $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 217b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 218b8595a66SAndreas Gohr echo $html; 219b8595a66SAndreas Gohr echo '<div class="clearer"></div>'; 220b8595a66SAndreas Gohr echo '</div>'; 2216bbae538Sandi 222f3f0262cSandi }else{ 223c112d578Sandi if ($REV) print p_locale_xhtml('showrev'); 224c112d578Sandi $html = p_wiki_xhtml($ID,$REV,true); 2256bbae538Sandi $html = html_secedit($html,$secedit); 226b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 227b8595a66SAndreas Gohr $html = html_hilight($html,$HIGH); 228b8595a66SAndreas Gohr echo $html; 229f3f0262cSandi } 230f3f0262cSandi} 231f3f0262cSandi 232f3f0262cSandi/** 233ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft 234ee4c4a1bSAndreas Gohr * 235ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 236ee4c4a1bSAndreas Gohr */ 237ee4c4a1bSAndreas Gohrfunction html_draft(){ 238ee4c4a1bSAndreas Gohr global $INFO; 239ee4c4a1bSAndreas Gohr global $ID; 240ee4c4a1bSAndreas Gohr global $lang; 241ee4c4a1bSAndreas Gohr global $conf; 242ee4c4a1bSAndreas Gohr $draft = unserialize(io_readFile($INFO['draft'],false)); 243ee4c4a1bSAndreas Gohr $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); 244ee4c4a1bSAndreas Gohr 245fdb8d77bSTom N Harris print p_locale_xhtml('draft'); 246fdb8d77bSTom N Harris $form = new Doku_Form('dw__editform'); 247fdb8d77bSTom N Harris $form->addHidden('id', $ID); 248fdb8d77bSTom N Harris $form->addHidden('date', $draft['date']); 249fdb8d77bSTom N Harris $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); 250fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); 251fdb8d77bSTom N Harris $form->addElement($lang['draftdate'].' '. date($conf['dformat'],filemtime($INFO['draft']))); 252fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 253fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); 254fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); 255fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); 256fdb8d77bSTom N Harris html_form('draft', $form); 257ee4c4a1bSAndreas Gohr} 258ee4c4a1bSAndreas Gohr 259ee4c4a1bSAndreas Gohr/** 260f3f0262cSandi * Highlights searchqueries in HTML code 26115fae107Sandi * 26215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 2637209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 264f3f0262cSandi */ 265f3f0262cSandifunction html_hilight($html,$query){ 2667209be23SAndreas Gohr //split at common delimiters 2679d9c165eSAndreas Gohr $queries = preg_split ('/[\s\'"\\\\`()\]\[?:!\.{};,#+*<>\\/]+/',$query,-1,PREG_SPLIT_NO_EMPTY); 268f3f0262cSandi foreach ($queries as $q){ 269f3f0262cSandi $q = preg_quote($q,'/'); 2707209be23SAndreas Gohr $html = preg_replace_callback("/((<[^>]*)|$q)/i",'html_hilight_callback',$html); 271f3f0262cSandi } 272f3f0262cSandi return $html; 273f3f0262cSandi} 274f3f0262cSandi 275f3f0262cSandi/** 2767209be23SAndreas Gohr * Callback used by html_hilight() 2777209be23SAndreas Gohr * 2787209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 2797209be23SAndreas Gohr */ 2807209be23SAndreas Gohrfunction html_hilight_callback($m) { 2817209be23SAndreas Gohr $hlight = unslash($m[0]); 2827209be23SAndreas Gohr if ( !isset($m[2])) { 283688774a0SAnika Henke $hlight = '<span class="search_hit">'.$hlight.'</span>'; 2847209be23SAndreas Gohr } 2857209be23SAndreas Gohr return $hlight; 2867209be23SAndreas Gohr} 2877209be23SAndreas Gohr 2887209be23SAndreas Gohr/** 28915fae107Sandi * Run a search and display the result 29015fae107Sandi * 29115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 292f3f0262cSandi */ 293f3f0262cSandifunction html_search(){ 294ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 295506fa893SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 296f3f0262cSandi global $conf; 297f3f0262cSandi global $QUERY; 298f3f0262cSandi global $ID; 299f3f0262cSandi global $lang; 300f3f0262cSandi 301c112d578Sandi print p_locale_xhtml('searchpage'); 302f3f0262cSandi flush(); 303f3f0262cSandi 304d0ab54f6SMichael Klier chi@chimeric.de //check if search is restricted to namespace 305d0ab54f6SMichael Klier chi@chimeric.de if(preg_match('/([^@]*)@([^@]*)/',$QUERY,$match)) { 306d0ab54f6SMichael Klier chi@chimeric.de $id = cleanID($match[1]); 307d0ab54f6SMichael Klier chi@chimeric.de if(empty($id)) { 308d0ab54f6SMichael Klier chi@chimeric.de print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 309d0ab54f6SMichael Klier chi@chimeric.de flush(); 310d0ab54f6SMichael Klier chi@chimeric.de return; 311d0ab54f6SMichael Klier chi@chimeric.de } 312d0ab54f6SMichael Klier chi@chimeric.de } else { 313d0ab54f6SMichael Klier chi@chimeric.de $id = cleanID($QUERY); 314d0ab54f6SMichael Klier chi@chimeric.de } 315d0ab54f6SMichael Klier chi@chimeric.de 3164d9ff3d5Sandi //show progressbar 317e226efe1SAndreas Gohr print '<div class="centeralign" id="dw__loading">'.NL; 318e226efe1SAndreas Gohr print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 319e226efe1SAndreas Gohr print 'showLoadBar();'.NL; 320e226efe1SAndreas Gohr print '//--><!]]></script>'.NL; 321e226efe1SAndreas Gohr print '<br /></div>'.NL; 3229edac8a8SAndreas Gohr flush(); 3234d9ff3d5Sandi 324f3f0262cSandi //do quick pagesearch 325f3f0262cSandi $data = array(); 326d0ab54f6SMichael Klier chi@chimeric.de 327d0ab54f6SMichael Klier chi@chimeric.de $data = ft_pageLookup($id); 328f3f0262cSandi if(count($data)){ 329f3f0262cSandi sort($data); 330f3f0262cSandi print '<div class="search_quickresult">'; 331746855cfSBen Coburn print '<h3>'.$lang['quickhits'].':</h3>'; 3324f732f0eSAnika Henke print '<ul class="search_quickhits">'; 333140c93f3SAnika Henke foreach($data as $id){ 3344f732f0eSAnika Henke print '<li> '; 335506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id); 3364f732f0eSAnika Henke print '</li> '; 337f3f0262cSandi } 338140c93f3SAnika Henke print '</ul> '; 339f3f0262cSandi //clear float (see http://www.complexspiral.com/publications/containing-floats/) 340f3f0262cSandi print '<div class="clearer"> </div>'; 341f3f0262cSandi print '</div>'; 342f3f0262cSandi } 343f3f0262cSandi flush(); 344f3f0262cSandi 345f3f0262cSandi //do fulltext search 346506fa893SAndreas Gohr $data = ft_pageSearch($QUERY,$poswords); 347f3f0262cSandi if(count($data)){ 348506fa893SAndreas Gohr $num = 1; 349506fa893SAndreas Gohr foreach($data as $id => $cnt){ 350f3f0262cSandi print '<div class="search_result">'; 351506fa893SAndreas Gohr print html_wikilink(':'.$id,$conf['useheading']?NULL:$id,$poswords); 352506fa893SAndreas Gohr print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 353506fa893SAndreas Gohr if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ? 354506fa893SAndreas Gohr print '<div class="search_snippet">'.ft_snippet($id,$poswords).'</div>'; 355506fa893SAndreas Gohr } 356f3f0262cSandi print '</div>'; 357506fa893SAndreas Gohr flush(); 358506fa893SAndreas Gohr $num++; 359f3f0262cSandi } 360f3f0262cSandi }else{ 361820fa24bSandi print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 362f3f0262cSandi } 3634d9ff3d5Sandi 3644d9ff3d5Sandi //hide progressbar 365e226efe1SAndreas Gohr print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 366e226efe1SAndreas Gohr print 'hideLoadBar("dw__loading");'.NL; 367e226efe1SAndreas Gohr print '//--><!]]></script>'.NL; 3689edac8a8SAndreas Gohr flush(); 369f3f0262cSandi} 370f3f0262cSandi 37115fae107Sandi/** 37215fae107Sandi * Display error on locked pages 37315fae107Sandi * 37415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 37515fae107Sandi */ 376ee20e7d1Sandifunction html_locked(){ 377f3f0262cSandi global $ID; 378f3f0262cSandi global $conf; 379f3f0262cSandi global $lang; 38088f522e9Sandi global $INFO; 381f3f0262cSandi 382c9b4bd1eSBen Coburn $locktime = filemtime(wikiLockFN($ID)); 383f3f0262cSandi $expire = @date($conf['dformat'], $locktime + $conf['locktime'] ); 384f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 385f3f0262cSandi 386c112d578Sandi print p_locale_xhtml('locked'); 387f3f0262cSandi print '<ul>'; 3880c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.$INFO['locked'].'</li>'; 3890c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 390f3f0262cSandi print '</ul>'; 391f3f0262cSandi} 392f3f0262cSandi 39315fae107Sandi/** 39415fae107Sandi * list old revisions 39515fae107Sandi * 39615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 39771726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 39815fae107Sandi */ 39971726d78SBen Coburnfunction html_revisions($first=0){ 400f3f0262cSandi global $ID; 401f3f0262cSandi global $INFO; 402f3f0262cSandi global $conf; 403f3f0262cSandi global $lang; 40471726d78SBen Coburn /* we need to get one additionally log entry to be able to 40571726d78SBen Coburn * decide if this is the last page or is there another one. 40671726d78SBen Coburn * see html_recent() 40771726d78SBen Coburn */ 40871726d78SBen Coburn $revisions = getRevisions($ID, $first, $conf['recent']+1); 40971726d78SBen Coburn if(count($revisions)==0 && $first!=0){ 41071726d78SBen Coburn $first=0; 41171726d78SBen Coburn $revisions = getRevisions($ID, $first, $conf['recent']+1);; 41271726d78SBen Coburn } 41371726d78SBen Coburn $hasNext = false; 41471726d78SBen Coburn if (count($revisions)>$conf['recent']) { 41571726d78SBen Coburn $hasNext = true; 41671726d78SBen Coburn array_pop($revisions); // remove extra log entry 41771726d78SBen Coburn } 41871726d78SBen Coburn 419f3f0262cSandi $date = @date($conf['dformat'],$INFO['lastmod']); 420f3f0262cSandi 421c112d578Sandi print p_locale_xhtml('revisions'); 42277707b04SAndreas Gohr print '<form action="'.wl($ID).'" method="post" id="page__revisions">'; 423f3f0262cSandi print '<ul>'; 42471726d78SBen Coburn if($INFO['exists'] && $first==0){ 425ebf1501fSBen Coburn print (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>'; 4260c6b58a8SAndreas Gohr print '<div class="li">'; 42777707b04SAndreas Gohr print '<input type="checkbox" name="rev2[]" value="current" /> '; 428f9b2fe70Sandi 429f9b2fe70Sandi print $date; 430f9b2fe70Sandi 43102e51121SAnika Henke print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 432cffcc403Sandi 433f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID).'">'.$ID.'</a> '; 434652610a2Sandi 43541396b71SAndreas Gohr print ' – '; 436652610a2Sandi print $INFO['sum']; 43788f522e9Sandi print ' <span class="user">'; 4385aa52fafSBen Coburn print (empty($INFO['editor']))?('('.$lang['external_edit'].')'):$INFO['editor']; 43988f522e9Sandi print '</span> '; 440652610a2Sandi 441652610a2Sandi print '('.$lang['current'].')'; 4420c6b58a8SAndreas Gohr print '</div>'; 443652610a2Sandi print '</li>'; 444f3f0262cSandi } 445f3f0262cSandi 446f3f0262cSandi foreach($revisions as $rev){ 447f3f0262cSandi $date = date($conf['dformat'],$rev); 448fb53bfe2SBen Coburn $info = getRevisionInfo($ID,$rev,true); 449103c256aSChris Smith $exists = page_exists($ID,$rev); 450652610a2Sandi 451ebf1501fSBen Coburn print ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>'; 4520c6b58a8SAndreas Gohr print '<div class="li">'; 45377707b04SAndreas Gohr if($exists){ 45477707b04SAndreas Gohr print '<input type="checkbox" name="rev2[]" value="'.$rev.'" /> '; 45577707b04SAndreas Gohr }else{ 45677707b04SAndreas Gohr print '<img src="'.DOKU_BASE.'lib/images/blank.gif" width="14" height="11" alt="" /> '; 45777707b04SAndreas Gohr } 458f9b2fe70Sandi print $date; 459f9b2fe70Sandi 46077707b04SAndreas Gohr if($exists){ 461cffcc403Sandi print ' <a href="'.wl($ID,"rev=$rev,do=diff").'">'; 462d94f4568SAndreas Gohr $p = array(); 463d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 464d94f4568SAndreas Gohr $p['width'] = 15; 465d94f4568SAndreas Gohr $p['height'] = 11; 466d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 467d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 468d94f4568SAndreas Gohr $att = buildAttributes($p); 469d94f4568SAndreas Gohr print "<img $att />"; 470cffcc403Sandi print '</a> '; 471cffcc403Sandi 472f9b2fe70Sandi print '<a class="wikilink1" href="'.wl($ID,"rev=$rev").'">'.$ID.'</a>'; 47341396b71SAndreas Gohr }else{ 47441396b71SAndreas Gohr print ' <img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" /> '; 47541396b71SAndreas Gohr print $ID; 47641396b71SAndreas Gohr } 477f9b2fe70Sandi 47841396b71SAndreas Gohr print ' – '; 479f243a77fSandi print htmlspecialchars($info['sum']); 48088f522e9Sandi print ' <span class="user">'; 48188f522e9Sandi if($info['user']){ 48288f522e9Sandi print $info['user']; 48388f522e9Sandi }else{ 484652610a2Sandi print $info['ip']; 48588f522e9Sandi } 48688f522e9Sandi print '</span>'; 487652610a2Sandi 4880c6b58a8SAndreas Gohr print '</div>'; 489f3f0262cSandi print '</li>'; 490f3f0262cSandi } 491f3f0262cSandi print '</ul>'; 49277707b04SAndreas Gohr print '<input name="do[diff]" type="submit" value="'.$lang['diff2'].'" class="button" />'; 49377707b04SAndreas Gohr print '</form>'; 49471726d78SBen Coburn 49571726d78SBen Coburn print '<div class="pagenav">'; 49671726d78SBen Coburn $last = $first + $conf['recent']; 49771726d78SBen Coburn if ($first > 0) { 49871726d78SBen Coburn $first -= $conf['recent']; 49971726d78SBen Coburn if ($first < 0) $first = 0; 50071726d78SBen Coburn print '<div class="pagenav-prev">'; 501eeb83e57SBen Coburn print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first)); 50271726d78SBen Coburn print '</div>'; 50371726d78SBen Coburn } 50471726d78SBen Coburn if ($hasNext) { 50571726d78SBen Coburn print '<div class="pagenav-next">'; 506eeb83e57SBen Coburn print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last)); 50771726d78SBen Coburn print '</div>'; 50871726d78SBen Coburn } 50971726d78SBen Coburn print '</div>'; 51071726d78SBen Coburn 511f3f0262cSandi} 512f3f0262cSandi 51315fae107Sandi/** 51415fae107Sandi * display recent changes 51515fae107Sandi * 51615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 5175749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 51871726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 51915fae107Sandi */ 520a39955b0Smatthiasgrimmfunction html_recent($first=0){ 521f3f0262cSandi global $conf; 522cffcc403Sandi global $lang; 523dbb00abcSEsther Brunner global $ID; 5245749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 5255749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 5265749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 5275749f1ceSmatthiasgrimm */ 528b6912aeaSAndreas Gohr $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 5295749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0){ 5305749f1ceSmatthiasgrimm $first=0; 53171726d78SBen Coburn $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 5325749f1ceSmatthiasgrimm } 53371726d78SBen Coburn $hasNext = false; 53471726d78SBen Coburn if (count($recents)>$conf['recent']) { 53571726d78SBen Coburn $hasNext = true; 53671726d78SBen Coburn array_pop($recents); // remove extra log entry 53771726d78SBen Coburn } 538f3f0262cSandi 539c112d578Sandi print p_locale_xhtml('recent'); 540f3f0262cSandi print '<ul>'; 541a39955b0Smatthiasgrimm 542d437bcc4SAndreas Gohr foreach($recents as $recent){ 543d437bcc4SAndreas Gohr $date = date($conf['dformat'],$recent['date']); 544ebf1501fSBen Coburn print ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) ? '<li class="minor">' : '<li>'; 5450c6b58a8SAndreas Gohr print '<div class="li">'; 546cffcc403Sandi 547f9b2fe70Sandi print $date.' '; 548f9b2fe70Sandi 549d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=diff").'">'; 550d94f4568SAndreas Gohr $p = array(); 551d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/diff.png'; 552d94f4568SAndreas Gohr $p['width'] = 15; 553d94f4568SAndreas Gohr $p['height'] = 11; 554d94f4568SAndreas Gohr $p['title'] = $lang['diff']; 555d94f4568SAndreas Gohr $p['alt'] = $lang['diff']; 556d94f4568SAndreas Gohr $att = buildAttributes($p); 557d94f4568SAndreas Gohr print "<img $att />"; 558cffcc403Sandi print '</a> '; 559cffcc403Sandi 560d437bcc4SAndreas Gohr print '<a href="'.wl($recent['id'],"do=revisions").'">'; 561d94f4568SAndreas Gohr $p = array(); 562d94f4568SAndreas Gohr $p['src'] = DOKU_BASE.'lib/images/history.png'; 563d94f4568SAndreas Gohr $p['width'] = 12; 564d94f4568SAndreas Gohr $p['height'] = 14; 565d94f4568SAndreas Gohr $p['title'] = $lang['btn_revs']; 566d94f4568SAndreas Gohr $p['alt'] = $lang['btn_revs']; 567d94f4568SAndreas Gohr $att = buildAttributes($p); 568d94f4568SAndreas Gohr print "<img $att />"; 569cffcc403Sandi print '</a> '; 570cffcc403Sandi 571d437bcc4SAndreas Gohr print html_wikilink(':'.$recent['id'],$conf['useheading']?NULL:$recent['id']); 57241396b71SAndreas Gohr print ' – '.htmlspecialchars($recent['sum']); 573b6912aeaSAndreas Gohr 57488f522e9Sandi print ' <span class="user">'; 575d437bcc4SAndreas Gohr if($recent['user']){ 576d437bcc4SAndreas Gohr print $recent['user']; 57788f522e9Sandi }else{ 578d437bcc4SAndreas Gohr print $recent['ip']; 57988f522e9Sandi } 58088f522e9Sandi print '</span>'; 581cffcc403Sandi 5820c6b58a8SAndreas Gohr print '</div>'; 583f3f0262cSandi print '</li>'; 584f3f0262cSandi } 585f3f0262cSandi print '</ul>'; 586a39955b0Smatthiasgrimm 587a39955b0Smatthiasgrimm print '<div class="pagenav">'; 5885749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 589a39955b0Smatthiasgrimm if ($first > 0) { 590a39955b0Smatthiasgrimm $first -= $conf['recent']; 591a39955b0Smatthiasgrimm if ($first < 0) $first = 0; 592a39955b0Smatthiasgrimm print '<div class="pagenav-prev">'; 5935749f1ceSmatthiasgrimm print html_btn('newer','',"p",array('do' => 'recent', 'first' => $first)); 594a39955b0Smatthiasgrimm print '</div>'; 595a39955b0Smatthiasgrimm } 59671726d78SBen Coburn if ($hasNext) { 597a39955b0Smatthiasgrimm print '<div class="pagenav-next">'; 5985749f1ceSmatthiasgrimm print html_btn('older','',"n",array('do' => 'recent', 'first' => $last)); 599a39955b0Smatthiasgrimm print '</div>'; 600a39955b0Smatthiasgrimm } 601a39955b0Smatthiasgrimm print '</div>'; 602f3f0262cSandi} 603f3f0262cSandi 60415fae107Sandi/** 60515fae107Sandi * Display page index 60615fae107Sandi * 60715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 60815fae107Sandi */ 609f3f0262cSandifunction html_index($ns){ 610ed7b5f09Sandi require_once(DOKU_INC.'inc/search.php'); 611f3f0262cSandi global $conf; 612f3f0262cSandi global $ID; 613f3f0262cSandi $dir = $conf['datadir']; 614f3f0262cSandi $ns = cleanID($ns); 61530f1737dSandi #fixme use appropriate function 616f3f0262cSandi if(empty($ns)){ 617f3f0262cSandi $ns = dirname(str_replace(':','/',$ID)); 618f3f0262cSandi if($ns == '.') $ns =''; 619f3f0262cSandi } 62088d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 621f3f0262cSandi 622a06884abSAndreas Gohr echo p_locale_xhtml('index'); 623a06884abSAndreas Gohr echo '<div id="index__tree">'; 624f3f0262cSandi 625f3f0262cSandi $data = array(); 626f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 627a06884abSAndreas Gohr echo html_buildlist($data,'idx','html_list_index','html_li_index'); 628a06884abSAndreas Gohr 629a06884abSAndreas Gohr echo '</div>'; 630f3f0262cSandi} 631f3f0262cSandi 632f3f0262cSandi/** 63315fae107Sandi * Index item formatter 63415fae107Sandi * 635f3f0262cSandi * User function for html_buildlist() 63615fae107Sandi * 63715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 638f3f0262cSandi */ 639f3f0262cSandifunction html_list_index($item){ 640d98d4540SBen Coburn global $ID; 641f3f0262cSandi $ret = ''; 642f3f0262cSandi $base = ':'.$item['id']; 643f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 644f3f0262cSandi if($item['type']=='d'){ 6454a119027SAndreas Gohr $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>'; 646f3f0262cSandi $ret .= $base; 647ed7ecb79SAnika Henke $ret .= '</strong></a>'; 648f3f0262cSandi }else{ 649f3f0262cSandi $ret .= html_wikilink(':'.$item['id']); 650f3f0262cSandi } 651f3f0262cSandi return $ret; 652f3f0262cSandi} 653f3f0262cSandi 654f3f0262cSandi/** 655cb70c441Sandi * Index List item 656cb70c441Sandi * 657cb70c441Sandi * This user function is used in html_build_lidt to build the 658cb70c441Sandi * <li> tags for namespaces when displaying the page index 659cb70c441Sandi * it gives different classes to opened or closed "folders" 660cb70c441Sandi * 661cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 662cb70c441Sandi */ 663cb70c441Sandifunction html_li_index($item){ 664cb70c441Sandi if($item['type'] == "f"){ 665cb70c441Sandi return '<li class="level'.$item['level'].'">'; 666cb70c441Sandi }elseif($item['open']){ 667cb70c441Sandi return '<li class="open">'; 668cb70c441Sandi }else{ 669cb70c441Sandi return '<li class="closed">'; 670cb70c441Sandi } 671cb70c441Sandi} 672cb70c441Sandi 673cb70c441Sandi/** 674cb70c441Sandi * Default List item 675cb70c441Sandi * 676cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 677cb70c441Sandi */ 678cb70c441Sandifunction html_li_default($item){ 679cb70c441Sandi return '<li class="level'.$item['level'].'">'; 680cb70c441Sandi} 681cb70c441Sandi 682cb70c441Sandi/** 68315fae107Sandi * Build an unordered list 68415fae107Sandi * 685f3f0262cSandi * Build an unordered list from the given $data array 686f3f0262cSandi * Each item in the array has to have a 'level' property 687f3f0262cSandi * the item itself gets printed by the given $func user 688cb70c441Sandi * function. The second and optional function is used to 689cb70c441Sandi * print the <li> tag. Both user function need to accept 690cb70c441Sandi * a single item. 69115fae107Sandi * 692c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to 693c5a8fd96SAndreas Gohr * a member of an object. 694c5a8fd96SAndreas Gohr * 69515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 696f3f0262cSandi */ 697cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 698f3f0262cSandi $level = 0; 699f3f0262cSandi $opens = 0; 700f3f0262cSandi $ret = ''; 701f3f0262cSandi 702f3f0262cSandi foreach ($data as $item){ 703f3f0262cSandi 704f3f0262cSandi if( $item['level'] > $level ){ 705f3f0262cSandi //open new list 706df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 707df52d0feSandi if ($i) $ret .= "<li class=\"clear\">\n"; 708f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 709df52d0feSandi } 710f3f0262cSandi }elseif( $item['level'] < $level ){ 711f3f0262cSandi //close last item 712f3f0262cSandi $ret .= "</li>\n"; 713f3f0262cSandi for ($i=0; $i<($level - $item['level']); $i++){ 714f3f0262cSandi //close higher lists 715f3f0262cSandi $ret .= "</ul>\n</li>\n"; 716f3f0262cSandi } 717f3f0262cSandi }else{ 718f3f0262cSandi //close last item 719f3f0262cSandi $ret .= "</li>\n"; 720f3f0262cSandi } 721f3f0262cSandi 722f3f0262cSandi //remember current level 723f3f0262cSandi $level = $item['level']; 724f3f0262cSandi 725f3f0262cSandi //print item 72634dbe711Schris $ret .= call_user_func($lifunc,$item); 7270c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 72834dbe711Schris 72934dbe711Schris $ret .= call_user_func($func,$item); 7300c6b58a8SAndreas Gohr $ret .= '</div>'; 731f3f0262cSandi } 732f3f0262cSandi 733f3f0262cSandi //close remaining items and lists 734f3f0262cSandi for ($i=0; $i < $level; $i++){ 735f3f0262cSandi $ret .= "</li></ul>\n"; 736f3f0262cSandi } 737f3f0262cSandi 738f3f0262cSandi return $ret; 739f3f0262cSandi} 740f3f0262cSandi 74115fae107Sandi/** 74215fae107Sandi * display backlinks 74315fae107Sandi * 74415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 74511df47ecSMichael Klier * @author Michael Klier <chi@chimeric.de> 74615fae107Sandi */ 747f3f0262cSandifunction html_backlinks(){ 74854f4c056SAndreas Gohr require_once(DOKU_INC.'inc/fulltext.php'); 749f3f0262cSandi global $ID; 750f3f0262cSandi global $conf; 75111df47ecSMichael Klier global $lang; 752f3f0262cSandi 753c112d578Sandi print p_locale_xhtml('backlinks'); 754f3f0262cSandi 75554f4c056SAndreas Gohr $data = ft_backlinks($ID); 756f3f0262cSandi 75711df47ecSMichael Klier if(!empty($data)) { 758f3f0262cSandi print '<ul class="idx">'; 75954f4c056SAndreas Gohr foreach($data as $blink){ 7600c6b58a8SAndreas Gohr print '<li><div class="li">'; 76154f4c056SAndreas Gohr print html_wikilink(':'.$blink,$conf['useheading']?NULL:$blink); 7620c6b58a8SAndreas Gohr print '</div></li>'; 763f3f0262cSandi } 764f3f0262cSandi print '</ul>'; 76511df47ecSMichael Klier } else { 76611df47ecSMichael Klier print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>'; 76711df47ecSMichael Klier } 768f3f0262cSandi} 769f3f0262cSandi 77015fae107Sandi/** 77115fae107Sandi * show diff 77215fae107Sandi * 77315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 77415fae107Sandi */ 775f3f0262cSandifunction html_diff($text='',$intro=true){ 776ed7b5f09Sandi require_once(DOKU_INC.'inc/DifferenceEngine.php'); 777f3f0262cSandi global $ID; 778f3f0262cSandi global $REV; 779f3f0262cSandi global $lang; 780f3f0262cSandi global $conf; 781e1bd90ffSAndreas Gohr 78277707b04SAndreas Gohr // we're trying to be clever here, revisions to compare can be either 78377707b04SAndreas Gohr // given as rev and rev2 parameters, with rev2 being optional. Or in an 78477707b04SAndreas Gohr // array in rev2. 78577707b04SAndreas Gohr $rev1 = $REV; 78677707b04SAndreas Gohr if(is_array($_REQUEST['rev2'])){ 78777707b04SAndreas Gohr $rev1 = (int) $_REQUEST['rev2'][0]; 78877707b04SAndreas Gohr $rev2 = (int) $_REQUEST['rev2'][1]; 789f3f0262cSandi }else{ 79077707b04SAndreas Gohr $rev2 = (int) $_REQUEST['rev2']; 7914d58bd99Sandi } 7924d58bd99Sandi 79377707b04SAndreas Gohr if($text){ // compare text to the most current revision 79477707b04SAndreas Gohr $l_rev = ''; 79577707b04SAndreas Gohr $l_text = rawWiki($ID,''); 79677707b04SAndreas Gohr $l_head = '<a class="wikilink1" href="'.wl($ID).'">'. 79777707b04SAndreas Gohr $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 79877707b04SAndreas Gohr $lang['current']; 79977707b04SAndreas Gohr 80077707b04SAndreas Gohr $r_rev = ''; 80177707b04SAndreas Gohr $r_text = cleanText($text); 80277707b04SAndreas Gohr $r_head = $lang['yours']; 803e1bd90ffSAndreas Gohr }else{ 80477707b04SAndreas Gohr if($rev1 && $rev2){ // two specific revisions wanted 80577707b04SAndreas Gohr // make sure order is correct (older on the right) 80677707b04SAndreas Gohr if($rev1 < $rev2){ 80777707b04SAndreas Gohr $l_rev = $rev1; 80877707b04SAndreas Gohr $r_rev = $rev2; 80977707b04SAndreas Gohr }else{ 81077707b04SAndreas Gohr $l_rev = $rev2; 81177707b04SAndreas Gohr $r_rev = $rev1; 812e1bd90ffSAndreas Gohr } 81377707b04SAndreas Gohr }elseif($rev1){ // single revision given, compare to current 81477707b04SAndreas Gohr $r_rev = ''; 81577707b04SAndreas Gohr $l_rev = $rev1; 81677707b04SAndreas Gohr }else{ // no revision was given, compare previous to current 81777707b04SAndreas Gohr $r_rev = ''; 81877707b04SAndreas Gohr $revs = getRevisions($ID, 0, 1); 81977707b04SAndreas Gohr $l_rev = $revs[0]; 82077707b04SAndreas Gohr } 82177707b04SAndreas Gohr 82277707b04SAndreas Gohr $l_text = rawWiki($ID,$l_rev); 82377707b04SAndreas Gohr $r_text = rawWiki($ID,$r_rev); 82477707b04SAndreas Gohr 82577707b04SAndreas Gohr $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'. 82677707b04SAndreas Gohr $ID.' '.date($conf['dformat'],$l_rev).'</a>'; 82777707b04SAndreas Gohr 82877707b04SAndreas Gohr if($r_rev){ 82977707b04SAndreas Gohr $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'. 83077707b04SAndreas Gohr $ID.' '.date($conf['dformat'],$r_rev).'</a>'; 83177707b04SAndreas Gohr }else{ 83277707b04SAndreas Gohr $r_head = '<a class="wikilink1" href="'.wl($ID).'">'. 83377707b04SAndreas Gohr $ID.' '.date($conf['dformat'],@filemtime(wikiFN($ID))).'</a> '. 834f3f0262cSandi $lang['current']; 835f3f0262cSandi } 83677707b04SAndreas Gohr } 83777707b04SAndreas Gohr 83877707b04SAndreas Gohr $df = new Diff(explode("\n",htmlspecialchars($l_text)), 83977707b04SAndreas Gohr explode("\n",htmlspecialchars($r_text))); 84077707b04SAndreas Gohr 841f3f0262cSandi $tdf = new TableDiffFormatter(); 842c112d578Sandi if($intro) print p_locale_xhtml('diff'); 843f3f0262cSandi ?> 844daf4ca4eSAnika Henke <table class="diff"> 845f3f0262cSandi <tr> 846daf4ca4eSAnika Henke <th colspan="2"> 84777707b04SAndreas Gohr <?php echo $l_head?> 848daf4ca4eSAnika Henke </th> 849daf4ca4eSAnika Henke <th colspan="2"> 85077707b04SAndreas Gohr <?php echo $r_head?> 851daf4ca4eSAnika Henke </th> 852f3f0262cSandi </tr> 8534da078a3Smatthiasgrimm <?php echo $tdf->format($df)?> 854f3f0262cSandi </table> 8554da078a3Smatthiasgrimm <?php 856f3f0262cSandi} 857f3f0262cSandi 85815fae107Sandi/** 85915fae107Sandi * show warning on conflict detection 86015fae107Sandi * 86115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 86215fae107Sandi */ 863f3f0262cSandifunction html_conflict($text,$summary){ 864f3f0262cSandi global $ID; 865f3f0262cSandi global $lang; 866f3f0262cSandi 867c112d578Sandi print p_locale_xhtml('conflict'); 868fdb8d77bSTom N Harris $form = new Doku_Form('dw__editform'); 869fdb8d77bSTom N Harris $form->addHidden('id', $ID); 870fdb8d77bSTom N Harris $form->addHidden('wikitext', $text); 871fdb8d77bSTom N Harris $form->addHidden('summary', $summary); 872fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s'))); 873fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'])); 874fdb8d77bSTom N Harris html_form('conflict', $form); 875fdb8d77bSTom N Harris print '<br /><br /><br /><br />'.NL; 876f3f0262cSandi} 877f3f0262cSandi 878f3f0262cSandi/** 87915fae107Sandi * Prints the global message array 88015fae107Sandi * 88115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 882f3f0262cSandi */ 883f3f0262cSandifunction html_msgarea(){ 884f3f0262cSandi global $MSG; 885f3f0262cSandi 886f3f0262cSandi if(!isset($MSG)) return; 887f3f0262cSandi 888f3f0262cSandi foreach($MSG as $msg){ 889f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 890f3f0262cSandi print $msg['msg']; 891f3f0262cSandi print '</div>'; 892f3f0262cSandi } 893f3f0262cSandi} 894f3f0262cSandi 895f3f0262cSandi/** 896f3f0262cSandi * Prints the registration form 89715fae107Sandi * 89815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 899f3f0262cSandi */ 900f3f0262cSandifunction html_register(){ 901f3f0262cSandi global $lang; 902cab2716aSmatthias.grimm global $conf; 903f3f0262cSandi global $ID; 904f3f0262cSandi 905c112d578Sandi print p_locale_xhtml('register'); 906fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 907fdb8d77bSTom N Harris $form = new Doku_Form('dw__register', wl($ID)); 908fdb8d77bSTom N Harris $form->startFieldset($lang['register']); 909fdb8d77bSTom N Harris $form->addHidden('do', 'register'); 910fdb8d77bSTom N Harris $form->addHidden('save', '1'); 911fdb8d77bSTom N Harris $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], null, 'block', array('size'=>'50'))); 912cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 913fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50'))); 914fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 915cab2716aSmatthias.grimm } 916fdb8d77bSTom N Harris $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', array('size'=>'50'))); 917fdb8d77bSTom N Harris $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', array('size'=>'50'))); 918fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['register'])); 919fdb8d77bSTom N Harris $form->endFieldset(); 920fdb8d77bSTom N Harris html_form('register', $form); 921cab2716aSmatthias.grimm 922fdb8d77bSTom N Harris print '</div>'.NL; 923f3f0262cSandi} 924f3f0262cSandi 925f3f0262cSandi/** 9268b06d178Schris * Print the update profile form 9278b06d178Schris * 9288b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 9298b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 9308b06d178Schris */ 9318b06d178Schrisfunction html_updateprofile(){ 9328b06d178Schris global $lang; 9338b06d178Schris global $conf; 9348b06d178Schris global $ID; 9358b06d178Schris global $INFO; 93682fd59b6SAndreas Gohr global $auth; 9378b06d178Schris 9388b06d178Schris print p_locale_xhtml('updateprofile'); 9398b06d178Schris 9408b06d178Schris if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 9418b06d178Schris if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 942fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 943fdb8d77bSTom N Harris $form = new Doku_Form('dw__register', wl($ID)); 944fdb8d77bSTom N Harris $form->startFieldset($lang['profile']); 945fdb8d77bSTom N Harris $form->addHidden('do', 'profile'); 946fdb8d77bSTom N Harris $form->addHidden('save', '1'); 947fdb8d77bSTom N Harris $form->addElement(form_makeTextField('fullname', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled'))); 948fdb8d77bSTom N Harris $attr = array('size'=>'50'); 949fdb8d77bSTom N Harris if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; 950fdb8d77bSTom N Harris $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', $attr)); 951fdb8d77bSTom N Harris $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', $attr)); 952fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 953fdb8d77bSTom N Harris if ($auth->canDo('modPass')) { 954fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50'))); 955fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 956fdb8d77bSTom N Harris } 957fdb8d77bSTom N Harris if ($conf['profileconfirm']) { 958fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 959fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50'))); 960fdb8d77bSTom N Harris } 961fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_save'])); 962fdb8d77bSTom N Harris $form->addElement(form_makeButton('reset', '', $lang['btn_reset'])); 963fdb8d77bSTom N Harris $form->endFieldset(); 964fdb8d77bSTom N Harris html_form('updateprofile', $form); 965fdb8d77bSTom N Harris print '</div>'.NL; 9668b06d178Schris} 9678b06d178Schris 9688b06d178Schris/** 969f3f0262cSandi * This displays the edit form (lots of logic included) 97015fae107Sandi * 9717146cee2SAndreas Gohr * @fixme this is a huge lump of code and should be modularized 972016b6153SAndreas Gohr * @triggers HTML_PAGE_FROMTEMPLATE 973c9570649SAndreas Gohr * @triggers HTML_EDITFORM_INJECTION 97415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 975f3f0262cSandi */ 976f3f0262cSandifunction html_edit($text=null,$include='edit'){ //FIXME: include needed? 977f3f0262cSandi global $ID; 978f3f0262cSandi global $REV; 979f3f0262cSandi global $DATE; 980f3f0262cSandi global $RANGE; 981f3f0262cSandi global $PRE; 982f3f0262cSandi global $SUF; 983f3f0262cSandi global $INFO; 984f3f0262cSandi global $SUM; 985f3f0262cSandi global $lang; 986f3f0262cSandi global $conf; 987f3f0262cSandi 988f3f0262cSandi //set summary default 989f3f0262cSandi if(!$SUM){ 990f3f0262cSandi if($REV){ 991f3f0262cSandi $SUM = $lang['restored']; 992f3f0262cSandi }elseif(!$INFO['exists']){ 993f3f0262cSandi $SUM = $lang['created']; 994f3f0262cSandi } 995f3f0262cSandi } 996f3f0262cSandi 997f3f0262cSandi //no text? Load it! 998f3f0262cSandi if(!isset($text)){ 999f3f0262cSandi $pr = false; //no preview mode 10007146cee2SAndreas Gohr if($INFO['exists']){ 1001f3f0262cSandi if($RANGE){ 1002f3f0262cSandi list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV); 1003f3f0262cSandi }else{ 1004f3f0262cSandi $text = rawWiki($ID,$REV); 1005f3f0262cSandi } 10068fe3bb00STom N Harris $check = md5($text); 10078fe3bb00STom N Harris $mod = false; 1008f3f0262cSandi }else{ 10097146cee2SAndreas Gohr //try to load a pagetemplate 1010b7d5a5f0SAndreas Gohr $data = array($ID); 1011016b6153SAndreas Gohr $text = trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); 10128fe3bb00STom N Harris $check = md5(''); 10138fe3bb00STom N Harris $mod = $text!==''; 10147146cee2SAndreas Gohr } 10157146cee2SAndreas Gohr }else{ 1016f3f0262cSandi $pr = true; //preview mode 10178fe3bb00STom N Harris if (isset($_REQUEST['changecheck'])) { 10188fe3bb00STom N Harris $check = $_REQUEST['changecheck']; 10198fe3bb00STom N Harris $mod = md5($text)!==$check; 10208fe3bb00STom N Harris } else { 10218fe3bb00STom N Harris // Why? Assume default text is unmodified. 10228fe3bb00STom N Harris $check = md5($text); 10238fe3bb00STom N Harris $mod = false; 10248fe3bb00STom N Harris } 1025f3f0262cSandi } 1026f3f0262cSandi 1027f3f0262cSandi $wr = $INFO['writable']; 1028f3f0262cSandi if($wr){ 1029c112d578Sandi if ($REV) print p_locale_xhtml('editrev'); 1030c112d578Sandi print p_locale_xhtml($include); 1031f3f0262cSandi }else{ 1032409d7af7SAndreas Gohr // check pseudo action 'source' 1033409d7af7SAndreas Gohr if(!actionOK('source')){ 1034409d7af7SAndreas Gohr msg('Command disabled: source',-1); 1035409d7af7SAndreas Gohr return; 1036409d7af7SAndreas Gohr } 1037c112d578Sandi print p_locale_xhtml('read'); 1038f3f0262cSandi } 1039f3f0262cSandi if(!$DATE) $DATE = $INFO['lastmod']; 1040dc57ef04Sandi 1041dc57ef04Sandi 1042f3f0262cSandi?> 104363afe2a6SAnika Henke <div style="width:99%;"> 104442c7abd6SAndreas Gohr 104563afe2a6SAnika Henke <div class="toolbar"> 1046bb4866bdSchris <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.date($conf['dformat']);?></div> 1047fdb8d77bSTom N Harris <div id="tool__bar"><?php if($wr){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 1048409d7af7SAndreas Gohr target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> 104920d062caSAndreas Gohr 10504da078a3Smatthiasgrimm <?php if($wr){?> 1051e226efe1SAndreas Gohr <script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!-- 10524da078a3Smatthiasgrimm <?php /* sets changed to true when previewed */?> 10538fe3bb00STom N Harris textChanged = <?php ($mod) ? print 'true' : print 'false' ?>; 1054e226efe1SAndreas Gohr //--><!]]></script> 105524a33b42SAndreas Gohr <span id="spell__action"></span> 105624a33b42SAndreas Gohr <div id="spell__suggest"></div> 1057ee4c4a1bSAndreas Gohr <?php } ?> 105863afe2a6SAnika Henke </div> 105924a33b42SAndreas Gohr <div id="spell__result"></div> 10604da078a3Smatthiasgrimm<?php 1061fdb8d77bSTom N Harris $form = new Doku_Form('dw__editform'); 1062fdb8d77bSTom N Harris $form->addHidden('id', $ID); 1063fdb8d77bSTom N Harris $form->addHidden('rev', $REV); 1064fdb8d77bSTom N Harris $form->addHidden('date', $DATE); 1065fdb8d77bSTom N Harris $form->addHidden('prefix', $PRE); 1066fdb8d77bSTom N Harris $form->addHidden('suffix', $SUF); 1067fdb8d77bSTom N Harris $form->addHidden('changecheck', $check); 1068fdb8d77bSTom N Harris $attr = array('tabindex'=>'1'); 1069fdb8d77bSTom N Harris if (!$wr) $attr['readonly'] = 'readonly'; 1070fdb8d77bSTom N Harris $form->addElement(form_makeWikiText($text, $attr)); 1071fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); 1072fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); 1073fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1074fdb8d77bSTom N Harris if ($wr) { 1075fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); 1076fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); 1077fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); 1078fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); 1079fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1080fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); 1081fdb8d77bSTom N Harris $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); 1082fdb8d77bSTom N Harris $elem = html_minoredit(); 1083fdb8d77bSTom N Harris if ($elem) $form->addElement($elem); 1084fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1085fdb8d77bSTom N Harris } 1086fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1087fdb8d77bSTom N Harris html_form('edit', $form); 1088fdb8d77bSTom N Harris print '</div>'.NL; 1089f3f0262cSandi} 1090f3f0262cSandi 1091f3f0262cSandi/** 1092b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1093b6912aeaSAndreas Gohr * 1094b6912aeaSAndreas Gohr * @author Andrea Gohr <andi@splitbrain.org> 1095b6912aeaSAndreas Gohr */ 1096b6912aeaSAndreas Gohrfunction html_minoredit(){ 1097b6912aeaSAndreas Gohr global $conf; 1098b6912aeaSAndreas Gohr global $lang; 1099b6912aeaSAndreas Gohr // minor edits are for logged in users only 1100b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1101fdb8d77bSTom N Harris return false; 1102b6912aeaSAndreas Gohr } 1103b6912aeaSAndreas Gohr 1104b6912aeaSAndreas Gohr $p = array(); 1105b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1106bb4866bdSchris if(!empty($_REQUEST['minor'])) $p['checked']='checked'; 1107fdb8d77bSTom N Harris return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p); 1108b6912aeaSAndreas Gohr} 1109b6912aeaSAndreas Gohr 1110b6912aeaSAndreas Gohr/** 1111f3f0262cSandi * prints some debug info 111215fae107Sandi * 111315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1114f3f0262cSandi */ 1115f3f0262cSandifunction html_debug(){ 1116f3f0262cSandi global $conf; 1117d16a4edaSandi global $lang; 11185298a619SAndreas Gohr global $auth; 1119100a97e3SAndreas Gohr global $INFO; 1120100a97e3SAndreas Gohr 112128fb55ffSandi //remove sensitive data 112228fb55ffSandi $cnf = $conf; 112328fb55ffSandi $cnf['auth']='***'; 112428fb55ffSandi $cnf['notify']='***'; 11253dc3a5f1Sandi $cnf['ftp']='***'; 1126100a97e3SAndreas Gohr $nfo = $INFO; 1127100a97e3SAndreas Gohr $nfo['userinfo'] = '***'; 1128100a97e3SAndreas Gohr $ses = $_SESSION; 1129100a97e3SAndreas Gohr $ses[$conf['title']]['auth'] = '***'; 1130f3f0262cSandi 1131f3f0262cSandi print '<html><body>'; 1132f3f0262cSandi 1133f3f0262cSandi print '<p>When reporting bugs please send all the following '; 1134f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 1135f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 1136f3f0262cSandi 1137100a97e3SAndreas Gohr print '<b>$INFO:</b><pre>'; 1138100a97e3SAndreas Gohr print_r($nfo); 1139100a97e3SAndreas Gohr print '</pre>'; 1140100a97e3SAndreas Gohr 1141f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 1142f3f0262cSandi print_r($_SERVER); 1143f3f0262cSandi print '</pre>'; 1144f3f0262cSandi 1145f3f0262cSandi print '<b>$conf:</b><pre>'; 114628fb55ffSandi print_r($cnf); 1147f3f0262cSandi print '</pre>'; 1148f3f0262cSandi 1149ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 1150ed7b5f09Sandi print DOKU_BASE; 1151f3f0262cSandi print '</pre>'; 1152f3f0262cSandi 1153ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 1154ed7b5f09Sandi print DOKU_URL; 1155ed7b5f09Sandi print '</pre>'; 1156ed7b5f09Sandi 1157ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 1158f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 1159f3f0262cSandi print '</pre>'; 1160f3f0262cSandi 1161f3f0262cSandi print '<b>PHP Version:</b><pre>'; 1162f3f0262cSandi print phpversion(); 1163f3f0262cSandi print '</pre>'; 1164f3f0262cSandi 1165f3f0262cSandi print '<b>locale:</b><pre>'; 1166f3f0262cSandi print setlocale(LC_ALL,0); 1167f3f0262cSandi print '</pre>'; 1168f3f0262cSandi 1169d16a4edaSandi print '<b>encoding:</b><pre>'; 1170d16a4edaSandi print $lang['encoding']; 1171d16a4edaSandi print '</pre>'; 1172d16a4edaSandi 11735298a619SAndreas Gohr if($auth){ 11745298a619SAndreas Gohr print '<b>Auth backend capabilities:</b><pre>'; 11755298a619SAndreas Gohr print_r($auth->cando); 11765298a619SAndreas Gohr print '</pre>'; 11775298a619SAndreas Gohr } 11785298a619SAndreas Gohr 11793aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 1180100a97e3SAndreas Gohr print_r($ses); 11813aa54d7cSAndreas Gohr print '</pre>'; 11823aa54d7cSAndreas Gohr 1183f3f0262cSandi print '<b>Environment:</b><pre>'; 1184f3f0262cSandi print_r($_ENV); 1185f3f0262cSandi print '</pre>'; 1186f3f0262cSandi 1187f3f0262cSandi print '<b>PHP settings:</b><pre>'; 1188f3f0262cSandi $inis = ini_get_all(); 1189f3f0262cSandi print_r($inis); 1190f3f0262cSandi print '</pre>'; 1191f3f0262cSandi 1192f3f0262cSandi print '</body></html>'; 1193f3f0262cSandi} 1194f3f0262cSandi 1195c19fe9c0Sandifunction html_admin(){ 1196c19fe9c0Sandi global $ID; 1197f8cc712eSAndreas Gohr global $INFO; 1198c19fe9c0Sandi global $lang; 1199ca3a6df1SMatthias Grimm global $conf; 1200c19fe9c0Sandi 1201c112d578Sandi print p_locale_xhtml('admin'); 1202c19fe9c0Sandi 120311e2ce22Schris // build menu of admin functions from the plugins that handle them 120411e2ce22Schris $pluginlist = plugin_list('admin'); 120511e2ce22Schris $menu = array(); 120611e2ce22Schris foreach ($pluginlist as $p) { 120711e2ce22Schris if($obj =& plugin_load('admin',$p) === NULL) continue; 1208f8cc712eSAndreas Gohr 1209f8cc712eSAndreas Gohr // check permissions 1210f8cc712eSAndreas Gohr if($obj->forAdminOnly() && !$INFO['isadmin']) continue; 1211f8cc712eSAndreas Gohr 121211e2ce22Schris $menu[] = array('plugin' => $p, 121311e2ce22Schris 'prompt' => $obj->getMenuText($conf['lang']), 121411e2ce22Schris 'sort' => $obj->getMenuSort() 121511e2ce22Schris ); 121611e2ce22Schris } 121711e2ce22Schris 1218746855cfSBen Coburn usort($menu, 'p_sort_modes'); 121911e2ce22Schris 122011e2ce22Schris // output the menu 122111e2ce22Schris ptln('<ul>'); 122211e2ce22Schris 122311e2ce22Schris foreach ($menu as $item) { 122411e2ce22Schris if (!$item['prompt']) continue; 12250c6b58a8SAndreas Gohr ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 122611e2ce22Schris } 122711e2ce22Schris 122811e2ce22Schris ptln('</ul>'); 1229ca3a6df1SMatthias Grimm} 1230c19fe9c0Sandi 12318b06d178Schris/** 12328b06d178Schris * Form to request a new password for an existing account 12338b06d178Schris * 12348b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 123511e2ce22Schris */ 12368b06d178Schrisfunction html_resendpwd() { 12378b06d178Schris global $lang; 12388b06d178Schris global $conf; 12398b06d178Schris global $ID; 1240c19fe9c0Sandi 12418b06d178Schris print p_locale_xhtml('resendpwd'); 1242fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 1243fdb8d77bSTom N Harris $form = new Doku_Form('dw__resendpwd', wl($ID)); 1244fdb8d77bSTom N Harris $form->startFieldset($lang['resendpwd']); 1245fdb8d77bSTom N Harris $form->addHidden('do', 'resendpwd'); 1246fdb8d77bSTom N Harris $form->addHidden('save', '1'); 1247fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1248fdb8d77bSTom N Harris $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block')); 1249fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1250fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1251fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 1252fdb8d77bSTom N Harris $form->endFieldset(); 1253fdb8d77bSTom N Harris html_form('resendpwd', $form); 1254fdb8d77bSTom N Harris print '</div>'.NL; 1255fdb8d77bSTom N Harris} 1256fdb8d77bSTom N Harris 1257fdb8d77bSTom N Harris/** 1258b8595a66SAndreas Gohr * Return the TOC rendered to XHTML 1259b8595a66SAndreas Gohr * 1260b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1261b8595a66SAndreas Gohr */ 1262b8595a66SAndreas Gohrfunction html_TOC($toc){ 1263b8595a66SAndreas Gohr if(!count($toc)) return ''; 1264b8595a66SAndreas Gohr global $lang; 1265b8595a66SAndreas Gohr $out = '<!-- TOC START -->'.DOKU_LF; 1266b8595a66SAndreas Gohr $out .= '<div class="toc">'.DOKU_LF; 1267b8595a66SAndreas Gohr $out .= '<div class="tocheader toctoggle" id="toc__header">'; 1268b8595a66SAndreas Gohr $out .= $lang['toc']; 1269b8595a66SAndreas Gohr $out .= '</div>'.DOKU_LF; 1270b8595a66SAndreas Gohr $out .= '<div id="toc__inside">'.DOKU_LF; 1271b8595a66SAndreas Gohr $out .= html_buildlist($toc,'toc','html_list_toc'); 1272b8595a66SAndreas Gohr $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 1273b8595a66SAndreas Gohr $out .= '<!-- TOC END -->'.DOKU_LF; 1274b8595a66SAndreas Gohr return $out; } 1275b8595a66SAndreas Gohr 1276b8595a66SAndreas Gohr/** 1277b8595a66SAndreas Gohr * Callback for html_buildlist 1278b8595a66SAndreas Gohr */ 1279b8595a66SAndreas Gohrfunction html_list_toc($item){ 12807d91652aSAndreas Gohr if($item['hid']){ 12817d91652aSAndreas Gohr $link = '#'.$item['hid']; 12827d91652aSAndreas Gohr }else{ 12837d91652aSAndreas Gohr $link = $item['link']; 12847d91652aSAndreas Gohr } 12857d91652aSAndreas Gohr 12867d91652aSAndreas Gohr return '<span class="li"><a href="'.$link.'" class="toc">'. 1287b8595a66SAndreas Gohr hsc($item['title']).'</a></span>'; 1288b8595a66SAndreas Gohr} 1289b8595a66SAndreas Gohr 1290b8595a66SAndreas Gohr/** 1291b8595a66SAndreas Gohr * Helper function to build TOC items 1292b8595a66SAndreas Gohr * 1293b8595a66SAndreas Gohr * Returns an array ready to be added to a TOC array 1294b8595a66SAndreas Gohr * 1295b8595a66SAndreas Gohr * @param string $link - where to link (if $hash set to '#' it's a local anchor) 1296b8595a66SAndreas Gohr * @param string $text - what to display in the TOC 1297b8595a66SAndreas Gohr * @param int $level - nesting level 1298b8595a66SAndreas Gohr * @param string $hash - is prepended to the given $link, set blank if you want full links 1299b8595a66SAndreas Gohr */ 1300b8595a66SAndreas Gohrfunction html_mktocitem($link, $text, $level, $hash='#'){ 1301b8595a66SAndreas Gohr global $conf; 1302b8595a66SAndreas Gohr return array( 'link' => $hash.$link, 1303b8595a66SAndreas Gohr 'title' => $text, 1304b8595a66SAndreas Gohr 'type' => 'ul', 13052bb0d541Schris 'level' => $level); 1306b8595a66SAndreas Gohr} 1307b8595a66SAndreas Gohr 1308b8595a66SAndreas Gohr/** 1309fdb8d77bSTom N Harris * Output a Doku_Form object. 1310fdb8d77bSTom N Harris * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 1311fdb8d77bSTom N Harris * 1312fdb8d77bSTom N Harris * @author Tom N Harris <tnharris@whoopdedo.org> 1313fdb8d77bSTom N Harris */ 1314fdb8d77bSTom N Harrisfunction html_form($name, &$form) { 1315fdb8d77bSTom N Harris // Safety check in case the caller forgets. 1316fdb8d77bSTom N Harris $form->endFieldset(); 1317fdb8d77bSTom N Harris trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 1318fdb8d77bSTom N Harris} 1319fdb8d77bSTom N Harris 1320fdb8d77bSTom N Harris/** 1321fdb8d77bSTom N Harris * Form print function. 1322fdb8d77bSTom N Harris * Just calls printForm() on the data object. 1323fdb8d77bSTom N Harris */ 1324fdb8d77bSTom N Harrisfunction html_form_output($data) { 1325fdb8d77bSTom N Harris $data->printForm(); 13268b06d178Schris} 1327340756e4Sandi 1328340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 : 1329