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 9fa8adffeSAndreas Gohrif(!defined('DOKU_INC')) die('meh.'); 10e226efe1SAndreas Gohrif(!defined('NL')) define('NL',"\n"); 116bbae538Sandi 12f3f0262cSandi/** 13f3f0262cSandi * Convenience function to quickly build a wikilink 1415fae107Sandi * 1515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 16f3f0262cSandi */ 17db959ae3SAndreas Gohrfunction html_wikilink($id,$name=null,$search=''){ 18db959ae3SAndreas Gohr static $xhtml_renderer = null; 19723d78dbSandi if(is_null($xhtml_renderer)){ 207aea91afSChris Smith $xhtml_renderer = p_get_renderer('xhtml'); 21f3f0262cSandi } 22f3f0262cSandi 23fe9ec250SChris Smith return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); 24f3f0262cSandi} 25f3f0262cSandi 26f3f0262cSandi/** 27c19fe9c0Sandi * Helps building long attribute lists 28c19fe9c0Sandi * 29c277a6bdSTom N Harris * @deprecated Use buildAttributes instead 30c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 31c19fe9c0Sandi */ 32c19fe9c0Sandifunction html_attbuild($attributes){ 33c19fe9c0Sandi $ret = ''; 34c19fe9c0Sandi foreach ( $attributes as $key => $value ) { 35e351c80dSAdrian Lang $ret .= $key.'="'.formText($value).'" '; 36c19fe9c0Sandi } 37c19fe9c0Sandi return trim($ret); 38c19fe9c0Sandi} 39c19fe9c0Sandi 40c19fe9c0Sandi/** 41f3f0262cSandi * The loginform 4215fae107Sandi * 4315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 44f3f0262cSandi */ 45f3f0262cSandifunction html_login(){ 46f3f0262cSandi global $lang; 47f3f0262cSandi global $conf; 48f3f0262cSandi global $ID; 49f3f0262cSandi 50c112d578Sandi print p_locale_xhtml('login'); 51fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 52e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__login')); 53fdb8d77bSTom N Harris $form->startFieldset($lang['btn_login']); 54fdb8d77bSTom N Harris $form->addHidden('id', $ID); 55fdb8d77bSTom N Harris $form->addHidden('do', 'login'); 56aab557e9SGina Haeussge $form->addElement(form_makeTextField('u', ((!$_REQUEST['http_credentials']) ? $_REQUEST['u'] : ''), $lang['user'], 'focus__this', 'block')); 57fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); 5817f89d7eSMichael Klier if($conf['rememberme']) { 59fdb8d77bSTom N Harris $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); 6017f89d7eSMichael Klier } 61fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); 62fdb8d77bSTom N Harris $form->endFieldset(); 635b62573aSAndreas Gohr 64de4d479aSAdrian Lang if(actionOK('register')){ 65*bf413a4eSAnika Henke $form->addElement('<p>'.$lang['reghere'].': '.tpl_actionlink('register','','','',true).'</p>'); 66f3f0262cSandi } 678b06d178Schris 68de4d479aSAdrian Lang if (actionOK('resendpwd')) { 69*bf413a4eSAnika Henke $form->addElement('<p>'.$lang['pwdforget'].': '.tpl_actionlink('resendpwd','','','',true).'</p>'); 708b06d178Schris } 7176ec5467SMichael Klier 7276ec5467SMichael Klier html_form('login', $form); 73fdb8d77bSTom N Harris print '</div>'.NL; 74f3f0262cSandi} 75f3f0262cSandi 76f3f0262cSandi/** 7715fae107Sandi * inserts section edit buttons if wanted or removes the markers 7815fae107Sandi * 7915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 8015fae107Sandi */ 81f3f0262cSandifunction html_secedit($text,$show=true){ 82f3f0262cSandi global $INFO; 8335dae8b0SBen Coburn 843f9e3215SAdrian Lang $regexp = '#<!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->#'; 85b081e262SAdrian Lang 8640868f2fSAdrian Lang if(!$INFO['writable'] || !$show || $INFO['rev']){ 8740868f2fSAdrian Lang return preg_replace($regexp,'',$text); 88f3f0262cSandi } 8935dae8b0SBen Coburn 9040868f2fSAdrian Lang return preg_replace_callback($regexp, 9140868f2fSAdrian Lang 'html_secedit_button', $text); 9240868f2fSAdrian Lang} 9340868f2fSAdrian Lang 9440868f2fSAdrian Lang/** 9540868f2fSAdrian Lang * prepares section edit button data for event triggering 9640868f2fSAdrian Lang * used as a callback in html_secedit 9740868f2fSAdrian Lang * 9840868f2fSAdrian Lang * @triggers HTML_SECEDIT_BUTTON 9940868f2fSAdrian Lang * @author Andreas Gohr <andi@splitbrain.org> 10040868f2fSAdrian Lang */ 10140868f2fSAdrian Langfunction html_secedit_button($matches){ 102905fa971SAdrian Lang $data = array('secid' => $matches[1], 10340868f2fSAdrian Lang 'target' => strtolower($matches[2]), 10440868f2fSAdrian Lang 'range' => $matches[count($matches) - 1]); 10540868f2fSAdrian Lang if (count($matches) === 5) { 10640868f2fSAdrian Lang $data['name'] = $matches[3]; 10740868f2fSAdrian Lang } 10840868f2fSAdrian Lang 10940868f2fSAdrian Lang return trigger_event('HTML_SECEDIT_BUTTON', $data, 11040868f2fSAdrian Lang 'html_secedit_get_button'); 11140868f2fSAdrian Lang} 11240868f2fSAdrian Lang 11340868f2fSAdrian Lang/** 11440868f2fSAdrian Lang * prints a section editing button 11540868f2fSAdrian Lang * used as default action form HTML_SECEDIT_BUTTON 11640868f2fSAdrian Lang * 11740868f2fSAdrian Lang * @author Adrian Lang <lang@cosmocode.de> 11840868f2fSAdrian Lang */ 11940868f2fSAdrian Langfunction html_secedit_get_button($data) { 12040868f2fSAdrian Lang global $ID; 12140868f2fSAdrian Lang global $INFO; 12240868f2fSAdrian Lang 12340868f2fSAdrian Lang if (!isset($data['name']) || $data['name'] === '') return; 12440868f2fSAdrian Lang 12540868f2fSAdrian Lang $name = $data['name']; 12640868f2fSAdrian Lang unset($data['name']); 12740868f2fSAdrian Lang 128905fa971SAdrian Lang $secid = $data['secid']; 129905fa971SAdrian Lang unset($data['secid']); 130905fa971SAdrian Lang 13140868f2fSAdrian Lang return "<div class='secedit editbutton_" . $data['target'] . 132defa93a1SAdrian Lang " editbutton_" . $secid . "'>" . 13340868f2fSAdrian Lang html_btn('secedit', $ID, '', 13440868f2fSAdrian Lang array_merge(array('do' => 'edit', 135b150cd2cSGina Haeussge 'rev' => $INFO['lastmod'], 136b150cd2cSGina Haeussge 'summary' => '['.$name.'] '), $data), 13740868f2fSAdrian Lang 'post', $name) . '</div>'; 138f3f0262cSandi} 139f3f0262cSandi 140f3f0262cSandi/** 141d6c9c552Smatthiasgrimm * Just the back to top button (in its own form) 1426b13307fSandi * 1436b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 1446b13307fSandi */ 1456b13307fSandifunction html_topbtn(){ 1466b13307fSandi global $lang; 1476b13307fSandi 1486b13307fSandi $ret = ''; 14911ea018fSAndreas 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>'; 150df7b6005Sandi 1516b13307fSandi return $ret; 1526b13307fSandi} 1536b13307fSandi 1546b13307fSandi/** 155d67ca2c0Smatthiasgrimm * Displays a button (using its own form) 15635dae8b0SBen Coburn * If tooltip exists, the access key tooltip is replaced. 15715fae107Sandi * 15815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 159f3f0262cSandi */ 160f5baf821SAnika Henkefunction html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false){ 161f3f0262cSandi global $conf; 162f3f0262cSandi global $lang; 163f3f0262cSandi 164f5baf821SAnika Henke if (!$label) 165f3f0262cSandi $label = $lang['btn_'.$name]; 166f3f0262cSandi 167f3f0262cSandi $ret = ''; 16835dae8b0SBen Coburn $tip = ''; 169f3f0262cSandi 17049c713a3Sandi //filter id (without urlencoding) 17149c713a3Sandi $id = idfilter($id,false); 172f3f0262cSandi 173f3f0262cSandi //make nice URLs even for buttons 1746c7843b5Sandi if($conf['userewrite'] == 2){ 1756c7843b5Sandi $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 1766c7843b5Sandi }elseif($conf['userewrite']){ 1776c7843b5Sandi $script = DOKU_BASE.$id; 1786c7843b5Sandi }else{ 1798b00ebcfSandi $script = DOKU_BASE.DOKU_SCRIPT; 180f3f0262cSandi $params['id'] = $id; 181f3f0262cSandi } 182f3f0262cSandi 183b278f2deSAndreas Gohr $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">'; 184f3f0262cSandi 18506a4bf8fSAndreas Gohr if(is_array($params)){ 186f3f0262cSandi reset($params); 187f3f0262cSandi while (list($key, $val) = each($params)) { 188f3f0262cSandi $ret .= '<input type="hidden" name="'.$key.'" '; 189f3f0262cSandi $ret .= 'value="'.htmlspecialchars($val).'" />'; 190f3f0262cSandi } 19106a4bf8fSAndreas Gohr } 192f3f0262cSandi 19335dae8b0SBen Coburn if ($tooltip!='') { 19435dae8b0SBen Coburn $tip = htmlspecialchars($tooltip); 19511ea018fSAndreas Gohr }else{ 19611ea018fSAndreas Gohr $tip = htmlspecialchars($label); 19711ea018fSAndreas Gohr } 19811ea018fSAndreas Gohr 199d822118cSAdrian Lang $ret .= '<input type="submit" value="'.hsc($label).'" class="button" '; 20011ea018fSAndreas Gohr if($akey){ 20107493d05SAnika Henke $tip .= ' ['.strtoupper($akey).']'; 20287cb01b7SAnika Henke $ret .= 'accesskey="'.$akey.'" '; 20335dae8b0SBen Coburn } 20435dae8b0SBen Coburn $ret .= 'title="'.$tip.'" '; 205f3f0262cSandi $ret .= '/>'; 2064beabca9SAnika Henke $ret .= '</div></form>'; 207f3f0262cSandi 208f3f0262cSandi return $ret; 209f3f0262cSandi} 210f3f0262cSandi 211f3f0262cSandi/** 21215fae107Sandi * show a wiki page 21315fae107Sandi * 21415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 21515fae107Sandi */ 21611c78c94SAndreas Gohrfunction html_show($txt=null){ 217f3f0262cSandi global $ID; 218f3f0262cSandi global $REV; 219f3f0262cSandi global $HIGH; 220b8595a66SAndreas Gohr global $INFO; 221f3f0262cSandi //disable section editing for old revisions or in preview 2225400331dSandi if($txt || $REV){ 2236bbae538Sandi $secedit = false; 2246bbae538Sandi }else{ 2256bbae538Sandi $secedit = true; 226f3f0262cSandi } 227f3f0262cSandi 22811c78c94SAndreas Gohr if (!is_null($txt)){ 229f3f0262cSandi //PreviewHeader 230b8595a66SAndreas Gohr echo '<br id="scroll__here" />'; 231b8595a66SAndreas Gohr echo p_locale_xhtml('preview'); 232b8595a66SAndreas Gohr echo '<div class="preview">'; 233b8595a66SAndreas Gohr $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 234b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 235b8595a66SAndreas Gohr echo $html; 236b8595a66SAndreas Gohr echo '<div class="clearer"></div>'; 237b8595a66SAndreas Gohr echo '</div>'; 2386bbae538Sandi 239f3f0262cSandi }else{ 240c112d578Sandi if ($REV) print p_locale_xhtml('showrev'); 241c112d578Sandi $html = p_wiki_xhtml($ID,$REV,true); 2426bbae538Sandi $html = html_secedit($html,$secedit); 243b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 244b8595a66SAndreas Gohr $html = html_hilight($html,$HIGH); 245b8595a66SAndreas Gohr echo $html; 246f3f0262cSandi } 247f3f0262cSandi} 248f3f0262cSandi 249f3f0262cSandi/** 250ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft 251ee4c4a1bSAndreas Gohr * 252ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 253ee4c4a1bSAndreas Gohr */ 254ee4c4a1bSAndreas Gohrfunction html_draft(){ 255ee4c4a1bSAndreas Gohr global $INFO; 256ee4c4a1bSAndreas Gohr global $ID; 257ee4c4a1bSAndreas Gohr global $lang; 258ee4c4a1bSAndreas Gohr global $conf; 259ee4c4a1bSAndreas Gohr $draft = unserialize(io_readFile($INFO['draft'],false)); 260ee4c4a1bSAndreas Gohr $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); 261ee4c4a1bSAndreas Gohr 262fdb8d77bSTom N Harris print p_locale_xhtml('draft'); 263e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 264fdb8d77bSTom N Harris $form->addHidden('id', $ID); 265fdb8d77bSTom N Harris $form->addHidden('date', $draft['date']); 266fdb8d77bSTom N Harris $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); 267fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); 268f2263577SAndreas Gohr $form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft']))); 269fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 270fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); 271fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); 272fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); 273fdb8d77bSTom N Harris html_form('draft', $form); 274ee4c4a1bSAndreas Gohr} 275ee4c4a1bSAndreas Gohr 276ee4c4a1bSAndreas Gohr/** 277f3f0262cSandi * Highlights searchqueries in HTML code 27815fae107Sandi * 27915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 2807209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 281f3f0262cSandi */ 282546d3a99SAndreas Gohrfunction html_hilight($html,$phrases){ 283808551e3SAndreas Gohr $phrases = array_filter((array) $phrases); 2842237b4faSAndreas Gohr $regex = join('|',array_map('ft_snippet_re_preprocess', array_map('preg_quote_cb',$phrases))); 28560c15d7dSAndreas Gohr 28660c15d7dSAndreas Gohr if ($regex === '') return $html; 2871db218e9SAndreas Gohr $html = preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); 288f3f0262cSandi return $html; 289f3f0262cSandi} 290f3f0262cSandi 291f3f0262cSandi/** 2927209be23SAndreas Gohr * Callback used by html_hilight() 2937209be23SAndreas Gohr * 2947209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 2957209be23SAndreas Gohr */ 2967209be23SAndreas Gohrfunction html_hilight_callback($m) { 2977209be23SAndreas Gohr $hlight = unslash($m[0]); 2987209be23SAndreas Gohr if ( !isset($m[2])) { 299688774a0SAnika Henke $hlight = '<span class="search_hit">'.$hlight.'</span>'; 3007209be23SAndreas Gohr } 3017209be23SAndreas Gohr return $hlight; 3027209be23SAndreas Gohr} 3037209be23SAndreas Gohr 3047209be23SAndreas Gohr/** 30515fae107Sandi * Run a search and display the result 30615fae107Sandi * 30715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 308f3f0262cSandi */ 309f3f0262cSandifunction html_search(){ 310f3f0262cSandi global $conf; 311f3f0262cSandi global $QUERY; 312f3f0262cSandi global $ID; 313f3f0262cSandi global $lang; 314f3f0262cSandi 31506756ad2SAndreas Gohr $intro = p_locale_xhtml('searchpage'); 31606756ad2SAndreas Gohr // allow use of placeholder in search intro 31706756ad2SAndreas Gohr $intro = str_replace( 31806756ad2SAndreas Gohr array('@QUERY@','@SEARCH@'), 31906756ad2SAndreas Gohr array(hsc(rawurlencode($QUERY)),hsc($QUERY)), 32006756ad2SAndreas Gohr $intro); 32106756ad2SAndreas Gohr echo $intro; 322f3f0262cSandi flush(); 323f3f0262cSandi 3244d9ff3d5Sandi //show progressbar 325e226efe1SAndreas Gohr print '<div class="centeralign" id="dw__loading">'.NL; 326e226efe1SAndreas Gohr print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 327e226efe1SAndreas Gohr print 'showLoadBar();'.NL; 328e226efe1SAndreas Gohr print '//--><!]]></script>'.NL; 329e226efe1SAndreas Gohr print '<br /></div>'.NL; 3309edac8a8SAndreas Gohr flush(); 3314d9ff3d5Sandi 332f3f0262cSandi //do quick pagesearch 333f3f0262cSandi $data = array(); 334d0ab54f6SMichael Klier chi@chimeric.de 3356ef71970SAdrian Lang $data = ft_pageLookup($QUERY,true,useHeading('navigation')); 336f3f0262cSandi if(count($data)){ 337f3f0262cSandi print '<div class="search_quickresult">'; 338746855cfSBen Coburn print '<h3>'.$lang['quickhits'].':</h3>'; 3394f732f0eSAnika Henke print '<ul class="search_quickhits">'; 3408d22f1e9SAndreas Gohr foreach($data as $id => $title){ 3414f732f0eSAnika Henke print '<li> '; 3428d22f1e9SAndreas Gohr if (useHeading('navigation')) { 3438d22f1e9SAndreas Gohr $name = $title; 3448d22f1e9SAndreas Gohr }else{ 345bd2f6c2fSAndreas Gohr $ns = getNS($id); 346bd2f6c2fSAndreas Gohr if($ns){ 347bd2f6c2fSAndreas Gohr $name = shorten(noNS($id), ' ('.$ns.')',30); 348bd2f6c2fSAndreas Gohr }else{ 349bd2f6c2fSAndreas Gohr $name = $id; 350bd2f6c2fSAndreas Gohr } 3518d22f1e9SAndreas Gohr } 352bd2f6c2fSAndreas Gohr print html_wikilink(':'.$id,$name); 3534f732f0eSAnika Henke print '</li> '; 354f3f0262cSandi } 355140c93f3SAnika Henke print '</ul> '; 356f3f0262cSandi //clear float (see http://www.complexspiral.com/publications/containing-floats/) 357f3f0262cSandi print '<div class="clearer"> </div>'; 358f3f0262cSandi print '</div>'; 359f3f0262cSandi } 360f3f0262cSandi flush(); 361f3f0262cSandi 362f3f0262cSandi //do fulltext search 36360c15d7dSAndreas Gohr $data = ft_pageSearch($QUERY,$regex); 364f3f0262cSandi if(count($data)){ 365506fa893SAndreas Gohr $num = 1; 366506fa893SAndreas Gohr foreach($data as $id => $cnt){ 367f3f0262cSandi print '<div class="search_result">'; 368db959ae3SAndreas Gohr print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex); 369865c2687SKazutaka Miyasaka if($cnt !== 0){ 370506fa893SAndreas Gohr print ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />'; 371bd0293e7SAndreas Gohr if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only 37260c15d7dSAndreas Gohr print '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>'; 373506fa893SAndreas Gohr } 374865c2687SKazutaka Miyasaka $num++; 375865c2687SKazutaka Miyasaka } 376f3f0262cSandi print '</div>'; 377506fa893SAndreas Gohr flush(); 378f3f0262cSandi } 379f3f0262cSandi }else{ 380820fa24bSandi print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 381f3f0262cSandi } 3824d9ff3d5Sandi 3834d9ff3d5Sandi //hide progressbar 384e226efe1SAndreas Gohr print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'.NL; 385e226efe1SAndreas Gohr print 'hideLoadBar("dw__loading");'.NL; 386e226efe1SAndreas Gohr print '//--><!]]></script>'.NL; 3879edac8a8SAndreas Gohr flush(); 388f3f0262cSandi} 389f3f0262cSandi 39015fae107Sandi/** 39115fae107Sandi * Display error on locked pages 39215fae107Sandi * 39315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 39415fae107Sandi */ 395ee20e7d1Sandifunction html_locked(){ 396f3f0262cSandi global $ID; 397f3f0262cSandi global $conf; 398f3f0262cSandi global $lang; 39988f522e9Sandi global $INFO; 400f3f0262cSandi 401c9b4bd1eSBen Coburn $locktime = filemtime(wikiLockFN($ID)); 402f2263577SAndreas Gohr $expire = dformat($locktime + $conf['locktime']); 403f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 404f3f0262cSandi 405c112d578Sandi print p_locale_xhtml('locked'); 406f3f0262cSandi print '<ul>'; 4076d233a0cSAndy Webber print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.editorinfo($INFO['locked']).'</div></li>'; 4080c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 409f3f0262cSandi print '</ul>'; 410f3f0262cSandi} 411f3f0262cSandi 41215fae107Sandi/** 41315fae107Sandi * list old revisions 41415fae107Sandi * 41515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 41671726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 41715fae107Sandi */ 41871726d78SBen Coburnfunction html_revisions($first=0){ 419f3f0262cSandi global $ID; 420f3f0262cSandi global $INFO; 421f3f0262cSandi global $conf; 422f3f0262cSandi global $lang; 42371726d78SBen Coburn /* we need to get one additionally log entry to be able to 42471726d78SBen Coburn * decide if this is the last page or is there another one. 42571726d78SBen Coburn * see html_recent() 42671726d78SBen Coburn */ 42771726d78SBen Coburn $revisions = getRevisions($ID, $first, $conf['recent']+1); 42871726d78SBen Coburn if(count($revisions)==0 && $first!=0){ 42971726d78SBen Coburn $first=0; 43071726d78SBen Coburn $revisions = getRevisions($ID, $first, $conf['recent']+1);; 43171726d78SBen Coburn } 43271726d78SBen Coburn $hasNext = false; 43371726d78SBen Coburn if (count($revisions)>$conf['recent']) { 43471726d78SBen Coburn $hasNext = true; 43571726d78SBen Coburn array_pop($revisions); // remove extra log entry 43671726d78SBen Coburn } 43771726d78SBen Coburn 438f2263577SAndreas Gohr $date = dformat($INFO['lastmod']); 439f3f0262cSandi 440c112d578Sandi print p_locale_xhtml('revisions'); 44137a1dc12Smichael 442e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'page__revisions')); 44337a1dc12Smichael $form->addElement(form_makeOpenTag('ul')); 44471726d78SBen Coburn if($INFO['exists'] && $first==0){ 44537a1dc12Smichael if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 44637a1dc12Smichael $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 44737a1dc12Smichael else 44837a1dc12Smichael $form->addElement(form_makeOpenTag('li')); 44937a1dc12Smichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 45037a1dc12Smichael $form->addElement(form_makeTag('input', array( 45137a1dc12Smichael 'type' => 'checkbox', 45237a1dc12Smichael 'name' => 'rev2[]', 45337a1dc12Smichael 'value' => 'current'))); 454f9b2fe70Sandi 45537a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 45637a1dc12Smichael $form->addElement($date); 45737a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 458f9b2fe70Sandi 45937a1dc12Smichael $form->addElement(form_makeTag('img', array( 46037a1dc12Smichael 'src' => DOKU_BASE.'lib/images/blank.gif', 46137a1dc12Smichael 'width' => '15', 46237a1dc12Smichael 'height' => '11', 46337a1dc12Smichael 'alt' => ''))); 464cffcc403Sandi 46537a1dc12Smichael $form->addElement(form_makeOpenTag('a', array( 46637a1dc12Smichael 'class' => 'wikilink1', 46737a1dc12Smichael 'href' => wl($ID)))); 46837a1dc12Smichael $form->addElement($ID); 46937a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 470652610a2Sandi 47137a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 47237a1dc12Smichael $form->addElement(' – '); 47337a1dc12Smichael $form->addElement(htmlspecialchars($INFO['sum'])); 47437a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 475652610a2Sandi 47637a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 47737a1dc12Smichael $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor'])); 47837a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 47937a1dc12Smichael 48037a1dc12Smichael $form->addElement('('.$lang['current'].')'); 48137a1dc12Smichael $form->addElement(form_makeCloseTag('div')); 48237a1dc12Smichael $form->addElement(form_makeCloseTag('li')); 483f3f0262cSandi } 484f3f0262cSandi 485f3f0262cSandi foreach($revisions as $rev){ 486f2263577SAndreas Gohr $date = dformat($rev); 487fb53bfe2SBen Coburn $info = getRevisionInfo($ID,$rev,true); 488103c256aSChris Smith $exists = page_exists($ID,$rev); 489652610a2Sandi 49037a1dc12Smichael if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 49137a1dc12Smichael $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 49237a1dc12Smichael else 49337a1dc12Smichael $form->addElement(form_makeOpenTag('li')); 49437a1dc12Smichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 49577707b04SAndreas Gohr if($exists){ 49637a1dc12Smichael $form->addElement(form_makeTag('input', array( 49737a1dc12Smichael 'type' => 'checkbox', 49837a1dc12Smichael 'name' => 'rev2[]', 49937a1dc12Smichael 'value' => $rev))); 50077707b04SAndreas Gohr }else{ 50137a1dc12Smichael $form->addElement(form_makeTag('img', array( 50237a1dc12Smichael 'src' => DOKU_BASE.'lib/images/blank.gif', 50337a1dc12Smichael 'width' => 14, 50437a1dc12Smichael 'height' => 11, 50537a1dc12Smichael 'alt' => ''))); 50641396b71SAndreas Gohr } 507f9b2fe70Sandi 50837a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 50937a1dc12Smichael $form->addElement($date); 51037a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 51137a1dc12Smichael 51237a1dc12Smichael if($exists){ 51337a1dc12Smichael $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link'))); 51437a1dc12Smichael $form->addElement(form_makeTag('img', array( 51537a1dc12Smichael 'src' => DOKU_BASE.'lib/images/diff.png', 51637a1dc12Smichael 'width' => 15, 51737a1dc12Smichael 'height' => 11, 51837a1dc12Smichael 'title' => $lang['diff'], 51937a1dc12Smichael 'alt' => $lang['diff']))); 52037a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 52137a1dc12Smichael 52237a1dc12Smichael $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1'))); 52337a1dc12Smichael $form->addElement($ID); 52437a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 52537a1dc12Smichael }else{ 52637a1dc12Smichael $form->addElement(form_makeTag('img', array( 52737a1dc12Smichael 'src' => DOKU_BASE.'lib/images/blank.gif', 52837a1dc12Smichael 'width' => '15', 52937a1dc12Smichael 'height' => '11', 53037a1dc12Smichael 'alt' => ''))); 53137a1dc12Smichael $form->addElement($ID); 53237a1dc12Smichael } 53337a1dc12Smichael 53437a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 53537a1dc12Smichael $form->addElement(' – '); 53637a1dc12Smichael $form->addElement(htmlspecialchars($info['sum'])); 53737a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 53837a1dc12Smichael 53937a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 54088f522e9Sandi if($info['user']){ 54137a1dc12Smichael $form->addElement(editorinfo($info['user'])); 542433efb25SAndreas Gohr if(auth_ismanager()){ 543433efb25SAndreas Gohr $form->addElement(' ('.$info['ip'].')'); 544433efb25SAndreas Gohr } 54588f522e9Sandi }else{ 54637a1dc12Smichael $form->addElement($info['ip']); 54788f522e9Sandi } 54837a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 549652610a2Sandi 55037a1dc12Smichael $form->addElement(form_makeCloseTag('div')); 55137a1dc12Smichael $form->addElement(form_makeCloseTag('li')); 552f3f0262cSandi } 55337a1dc12Smichael $form->addElement(form_makeCloseTag('ul')); 55437a1dc12Smichael $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); 55537a1dc12Smichael html_form('revisions', $form); 55671726d78SBen Coburn 55771726d78SBen Coburn print '<div class="pagenav">'; 55871726d78SBen Coburn $last = $first + $conf['recent']; 55971726d78SBen Coburn if ($first > 0) { 56071726d78SBen Coburn $first -= $conf['recent']; 56171726d78SBen Coburn if ($first < 0) $first = 0; 56271726d78SBen Coburn print '<div class="pagenav-prev">'; 563eeb83e57SBen Coburn print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first)); 56471726d78SBen Coburn print '</div>'; 56571726d78SBen Coburn } 56671726d78SBen Coburn if ($hasNext) { 56771726d78SBen Coburn print '<div class="pagenav-next">'; 568eeb83e57SBen Coburn print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last)); 56971726d78SBen Coburn print '</div>'; 57071726d78SBen Coburn } 57171726d78SBen Coburn print '</div>'; 57271726d78SBen Coburn 573f3f0262cSandi} 574f3f0262cSandi 57515fae107Sandi/** 57615fae107Sandi * display recent changes 57715fae107Sandi * 57815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 5795749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 58071726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 58115fae107Sandi */ 582a39955b0Smatthiasgrimmfunction html_recent($first=0){ 583f3f0262cSandi global $conf; 584cffcc403Sandi global $lang; 585dbb00abcSEsther Brunner global $ID; 5865749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 5875749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 5885749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 5895749f1ceSmatthiasgrimm */ 590b6912aeaSAndreas Gohr $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 5915749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0){ 5925749f1ceSmatthiasgrimm $first=0; 59371726d78SBen Coburn $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); 5945749f1ceSmatthiasgrimm } 59571726d78SBen Coburn $hasNext = false; 59671726d78SBen Coburn if (count($recents)>$conf['recent']) { 59771726d78SBen Coburn $hasNext = true; 59871726d78SBen Coburn array_pop($recents); // remove extra log entry 59971726d78SBen Coburn } 600f3f0262cSandi 601c112d578Sandi print p_locale_xhtml('recent'); 602e83cef14SGina Haeussge 603e83cef14SGina Haeussge if (getNS($ID) != '') 6049e561443SAndreas Gohr print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>'; 605e83cef14SGina Haeussge 606e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET')); 607abdcc39fSmichael $form->addHidden('sectok', null); 608abdcc39fSmichael $form->addHidden('do', 'recent'); 609abdcc39fSmichael $form->addHidden('id', $ID); 610abdcc39fSmichael $form->addElement(form_makeOpenTag('ul')); 611a39955b0Smatthiasgrimm 612d437bcc4SAndreas Gohr foreach($recents as $recent){ 613f2263577SAndreas Gohr $date = dformat($recent['date']); 614abdcc39fSmichael if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 615abdcc39fSmichael $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 616abdcc39fSmichael else 617abdcc39fSmichael $form->addElement(form_makeOpenTag('li')); 618cffcc403Sandi 619abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 620f9b2fe70Sandi 621abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 622abdcc39fSmichael $form->addElement($date); 623abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 624cffcc403Sandi 625cddd152cSmichael $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => wl($recent['id'],"do=diff", false, '&')))); 626abdcc39fSmichael $form->addElement(form_makeTag('img', array( 627abdcc39fSmichael 'src' => DOKU_BASE.'lib/images/diff.png', 628abdcc39fSmichael 'width' => 15, 629abdcc39fSmichael 'height'=> 11, 630abdcc39fSmichael 'title' => $lang['diff'], 631abdcc39fSmichael 'alt' => $lang['diff'] 632abdcc39fSmichael ))); 633abdcc39fSmichael $form->addElement(form_makeCloseTag('a')); 634cffcc403Sandi 635cddd152cSmichael $form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => wl($recent['id'],"do=revisions",false,'&')))); 636abdcc39fSmichael $form->addElement(form_makeTag('img', array( 637abdcc39fSmichael 'src' => DOKU_BASE.'lib/images/history.png', 638abdcc39fSmichael 'width' => 12, 639abdcc39fSmichael 'height'=> 14, 640abdcc39fSmichael 'title' => $lang['btn_revs'], 641abdcc39fSmichael 'alt' => $lang['btn_revs'] 642abdcc39fSmichael ))); 643abdcc39fSmichael $form->addElement(form_makeCloseTag('a')); 644b6912aeaSAndreas Gohr 645db959ae3SAndreas Gohr $form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?null:$recent['id'])); 646abdcc39fSmichael 647abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 648abdcc39fSmichael $form->addElement(' – '.htmlspecialchars($recent['sum'])); 649abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 650abdcc39fSmichael 651abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 652d437bcc4SAndreas Gohr if($recent['user']){ 653abdcc39fSmichael $form->addElement(editorinfo($recent['user'])); 654433efb25SAndreas Gohr if(auth_ismanager()){ 655433efb25SAndreas Gohr $form->addElement(' ('.$recent['ip'].')'); 656433efb25SAndreas Gohr } 65788f522e9Sandi }else{ 658abdcc39fSmichael $form->addElement($recent['ip']); 65988f522e9Sandi } 660abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 661cffcc403Sandi 662abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 663abdcc39fSmichael $form->addElement(form_makeCloseTag('li')); 664f3f0262cSandi } 665abdcc39fSmichael $form->addElement(form_makeCloseTag('ul')); 666a39955b0Smatthiasgrimm 667abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav'))); 6685749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 669a39955b0Smatthiasgrimm if ($first > 0) { 670a39955b0Smatthiasgrimm $first -= $conf['recent']; 671a39955b0Smatthiasgrimm if ($first < 0) $first = 0; 672abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev'))); 673abdcc39fSmichael $form->addElement(form_makeTag('input', array( 674abdcc39fSmichael 'type' => 'submit', 675abdcc39fSmichael 'name' => 'first['.$first.']', 676cddd152cSmichael 'value' => $lang['btn_newer'], 677cddd152cSmichael 'accesskey' => 'n', 678f948eeabSMichael Klier 'title' => $lang['btn_newer'].' [N]', 67918d107cbSMichael Klier 'class' => 'button' 680abdcc39fSmichael ))); 681abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 682a39955b0Smatthiasgrimm } 68371726d78SBen Coburn if ($hasNext) { 684abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next'))); 685abdcc39fSmichael $form->addElement(form_makeTag('input', array( 686abdcc39fSmichael 'type' => 'submit', 687abdcc39fSmichael 'name' => 'first['.$last.']', 688cddd152cSmichael 'value' => $lang['btn_older'], 689cddd152cSmichael 'accesskey' => 'p', 690f948eeabSMichael Klier 'title' => $lang['btn_older'].' [P]', 69118d107cbSMichael Klier 'class' => 'button' 692abdcc39fSmichael ))); 693abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 694a39955b0Smatthiasgrimm } 695abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 696abdcc39fSmichael html_form('recent', $form); 697f3f0262cSandi} 698f3f0262cSandi 69915fae107Sandi/** 70015fae107Sandi * Display page index 70115fae107Sandi * 70215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 70315fae107Sandi */ 704f3f0262cSandifunction html_index($ns){ 705f3f0262cSandi global $conf; 706f3f0262cSandi global $ID; 707f3f0262cSandi $dir = $conf['datadir']; 708f3f0262cSandi $ns = cleanID($ns); 70930f1737dSandi #fixme use appropriate function 710f3f0262cSandi if(empty($ns)){ 711f3f0262cSandi $ns = dirname(str_replace(':','/',$ID)); 712f3f0262cSandi if($ns == '.') $ns =''; 713f3f0262cSandi } 71488d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 715f3f0262cSandi 716a06884abSAndreas Gohr echo p_locale_xhtml('index'); 717a06884abSAndreas Gohr echo '<div id="index__tree">'; 718f3f0262cSandi 719f3f0262cSandi $data = array(); 720f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 721a06884abSAndreas Gohr echo html_buildlist($data,'idx','html_list_index','html_li_index'); 722a06884abSAndreas Gohr 723a06884abSAndreas Gohr echo '</div>'; 724f3f0262cSandi} 725f3f0262cSandi 726f3f0262cSandi/** 72715fae107Sandi * Index item formatter 72815fae107Sandi * 729f3f0262cSandi * User function for html_buildlist() 73015fae107Sandi * 73115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 732f3f0262cSandi */ 733f3f0262cSandifunction html_list_index($item){ 734d98d4540SBen Coburn global $ID; 735f3f0262cSandi $ret = ''; 736f3f0262cSandi $base = ':'.$item['id']; 737f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 738f3f0262cSandi if($item['type']=='d'){ 7394a119027SAndreas Gohr $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" class="idx_dir"><strong>'; 740f3f0262cSandi $ret .= $base; 741ed7ecb79SAnika Henke $ret .= '</strong></a>'; 742f3f0262cSandi }else{ 743f3f0262cSandi $ret .= html_wikilink(':'.$item['id']); 744f3f0262cSandi } 745f3f0262cSandi return $ret; 746f3f0262cSandi} 747f3f0262cSandi 748f3f0262cSandi/** 749cb70c441Sandi * Index List item 750cb70c441Sandi * 751cb70c441Sandi * This user function is used in html_build_lidt to build the 752cb70c441Sandi * <li> tags for namespaces when displaying the page index 753cb70c441Sandi * it gives different classes to opened or closed "folders" 754cb70c441Sandi * 755cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 756cb70c441Sandi */ 757cb70c441Sandifunction html_li_index($item){ 758cb70c441Sandi if($item['type'] == "f"){ 759cb70c441Sandi return '<li class="level'.$item['level'].'">'; 760cb70c441Sandi }elseif($item['open']){ 761cb70c441Sandi return '<li class="open">'; 762cb70c441Sandi }else{ 763cb70c441Sandi return '<li class="closed">'; 764cb70c441Sandi } 765cb70c441Sandi} 766cb70c441Sandi 767cb70c441Sandi/** 768cb70c441Sandi * Default List item 769cb70c441Sandi * 770cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 771cb70c441Sandi */ 772cb70c441Sandifunction html_li_default($item){ 773cb70c441Sandi return '<li class="level'.$item['level'].'">'; 774cb70c441Sandi} 775cb70c441Sandi 776cb70c441Sandi/** 77715fae107Sandi * Build an unordered list 77815fae107Sandi * 779f3f0262cSandi * Build an unordered list from the given $data array 780f3f0262cSandi * Each item in the array has to have a 'level' property 781f3f0262cSandi * the item itself gets printed by the given $func user 782cb70c441Sandi * function. The second and optional function is used to 783cb70c441Sandi * print the <li> tag. Both user function need to accept 784cb70c441Sandi * a single item. 78515fae107Sandi * 786c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to 787c5a8fd96SAndreas Gohr * a member of an object. 788c5a8fd96SAndreas Gohr * 78915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 790f3f0262cSandi */ 791cb70c441Sandifunction html_buildlist($data,$class,$func,$lifunc='html_li_default'){ 792f3f0262cSandi $level = 0; 793f3f0262cSandi $opens = 0; 794f3f0262cSandi $ret = ''; 795f3f0262cSandi 796f3f0262cSandi foreach ($data as $item){ 797f3f0262cSandi 798f3f0262cSandi if( $item['level'] > $level ){ 799f3f0262cSandi //open new list 800df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 801df52d0feSandi if ($i) $ret .= "<li class=\"clear\">\n"; 802f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 803df52d0feSandi } 804f3f0262cSandi }elseif( $item['level'] < $level ){ 805f3f0262cSandi //close last item 806f3f0262cSandi $ret .= "</li>\n"; 807f3f0262cSandi for ($i=0; $i<($level - $item['level']); $i++){ 808f3f0262cSandi //close higher lists 809f3f0262cSandi $ret .= "</ul>\n</li>\n"; 810f3f0262cSandi } 811f3f0262cSandi }else{ 812f3f0262cSandi //close last item 813f3f0262cSandi $ret .= "</li>\n"; 814f3f0262cSandi } 815f3f0262cSandi 816f3f0262cSandi //remember current level 817f3f0262cSandi $level = $item['level']; 818f3f0262cSandi 819f3f0262cSandi //print item 82034dbe711Schris $ret .= call_user_func($lifunc,$item); 8210c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 82234dbe711Schris 82334dbe711Schris $ret .= call_user_func($func,$item); 8240c6b58a8SAndreas Gohr $ret .= '</div>'; 825f3f0262cSandi } 826f3f0262cSandi 827f3f0262cSandi //close remaining items and lists 828f3f0262cSandi for ($i=0; $i < $level; $i++){ 829f3f0262cSandi $ret .= "</li></ul>\n"; 830f3f0262cSandi } 831f3f0262cSandi 832f3f0262cSandi return $ret; 833f3f0262cSandi} 834f3f0262cSandi 83515fae107Sandi/** 83615fae107Sandi * display backlinks 83715fae107Sandi * 83815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 83911df47ecSMichael Klier * @author Michael Klier <chi@chimeric.de> 84015fae107Sandi */ 841f3f0262cSandifunction html_backlinks(){ 842f3f0262cSandi global $ID; 843f3f0262cSandi global $conf; 84411df47ecSMichael Klier global $lang; 845f3f0262cSandi 846c112d578Sandi print p_locale_xhtml('backlinks'); 847f3f0262cSandi 84854f4c056SAndreas Gohr $data = ft_backlinks($ID); 849f3f0262cSandi 85011df47ecSMichael Klier if(!empty($data)) { 851f3f0262cSandi print '<ul class="idx">'; 85254f4c056SAndreas Gohr foreach($data as $blink){ 8530c6b58a8SAndreas Gohr print '<li><div class="li">'; 854db959ae3SAndreas Gohr print html_wikilink(':'.$blink,useHeading('navigation')?null:$blink); 8550c6b58a8SAndreas Gohr print '</div></li>'; 856f3f0262cSandi } 857f3f0262cSandi print '</ul>'; 85811df47ecSMichael Klier } else { 85911df47ecSMichael Klier print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>'; 86011df47ecSMichael Klier } 861f3f0262cSandi} 862f3f0262cSandi 86315fae107Sandi/** 86415fae107Sandi * show diff 86515fae107Sandi * 86615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 86772165381SAndreas Gohr * @param string $text - compare with this text with most current version 86872165381SAndreas Gohr * @param bool $intr - display the intro text 86915fae107Sandi */ 87072165381SAndreas Gohrfunction html_diff($text='',$intro=true,$type=null){ 871f3f0262cSandi global $ID; 872f3f0262cSandi global $REV; 873f3f0262cSandi global $lang; 874f3f0262cSandi global $conf; 875e1bd90ffSAndreas Gohr 87672165381SAndreas Gohr if(!$type) $type = $_REQUEST['difftype']; 87772165381SAndreas Gohr if($type != 'inline') $type = 'sidebyside'; 87872165381SAndreas Gohr 87977707b04SAndreas Gohr // we're trying to be clever here, revisions to compare can be either 88077707b04SAndreas Gohr // given as rev and rev2 parameters, with rev2 being optional. Or in an 88177707b04SAndreas Gohr // array in rev2. 88277707b04SAndreas Gohr $rev1 = $REV; 8837b3f8b16SAndreas Gohr 88477707b04SAndreas Gohr if(is_array($_REQUEST['rev2'])){ 88577707b04SAndreas Gohr $rev1 = (int) $_REQUEST['rev2'][0]; 88677707b04SAndreas Gohr $rev2 = (int) $_REQUEST['rev2'][1]; 88754041c77SAndreas Gohr 88854041c77SAndreas Gohr if(!$rev1){ 88954041c77SAndreas Gohr $rev1 = $rev2; 89054041c77SAndreas Gohr unset($rev2); 89154041c77SAndreas Gohr } 892f3f0262cSandi }else{ 89377707b04SAndreas Gohr $rev2 = (int) $_REQUEST['rev2']; 8944d58bd99Sandi } 8954d58bd99Sandi 8963733161eSAdrian Lang $r_minor = ''; 8973733161eSAdrian Lang $l_minor = ''; 8983733161eSAdrian Lang 89977707b04SAndreas Gohr if($text){ // compare text to the most current revision 90077707b04SAndreas Gohr $l_rev = ''; 90177707b04SAndreas Gohr $l_text = rawWiki($ID,''); 90277707b04SAndreas Gohr $l_head = '<a class="wikilink1" href="'.wl($ID).'">'. 903f2263577SAndreas Gohr $ID.' '.dformat((int) @filemtime(wikiFN($ID))).'</a> '. 90477707b04SAndreas Gohr $lang['current']; 90577707b04SAndreas Gohr 90677707b04SAndreas Gohr $r_rev = ''; 90777707b04SAndreas Gohr $r_text = cleanText($text); 90877707b04SAndreas Gohr $r_head = $lang['yours']; 909e1bd90ffSAndreas Gohr }else{ 91077707b04SAndreas Gohr if($rev1 && $rev2){ // two specific revisions wanted 91154041c77SAndreas Gohr // make sure order is correct (older on the left) 91277707b04SAndreas Gohr if($rev1 < $rev2){ 91377707b04SAndreas Gohr $l_rev = $rev1; 91477707b04SAndreas Gohr $r_rev = $rev2; 91577707b04SAndreas Gohr }else{ 91677707b04SAndreas Gohr $l_rev = $rev2; 91777707b04SAndreas Gohr $r_rev = $rev1; 918e1bd90ffSAndreas Gohr } 91977707b04SAndreas Gohr }elseif($rev1){ // single revision given, compare to current 92077707b04SAndreas Gohr $r_rev = ''; 92177707b04SAndreas Gohr $l_rev = $rev1; 92277707b04SAndreas Gohr }else{ // no revision was given, compare previous to current 92377707b04SAndreas Gohr $r_rev = ''; 92477707b04SAndreas Gohr $revs = getRevisions($ID, 0, 1); 92577707b04SAndreas Gohr $l_rev = $revs[0]; 9266f8e9f59SAndreas Gohr $REV = $l_rev; // store revision back in $REV 92777707b04SAndreas Gohr } 92877707b04SAndreas Gohr 9297b3f8b16SAndreas Gohr // when both revisions are empty then the page was created just now 9307b3f8b16SAndreas Gohr if(!$l_rev && !$r_rev){ 9317b3f8b16SAndreas Gohr $l_text = ''; 9327b3f8b16SAndreas Gohr }else{ 93377707b04SAndreas Gohr $l_text = rawWiki($ID,$l_rev); 9347b3f8b16SAndreas Gohr } 93577707b04SAndreas Gohr $r_text = rawWiki($ID,$r_rev); 93677707b04SAndreas Gohr 9377b3f8b16SAndreas Gohr if(!$l_rev){ 9387b3f8b16SAndreas Gohr $l_head = '—'; 9397b3f8b16SAndreas Gohr }else{ 940e5e61eb0SAnika Henke $l_info = getRevisionInfo($ID,$l_rev,true); 941db959ae3SAndreas Gohr if($l_info['user']){ 942db959ae3SAndreas Gohr $l_user = editorinfo($l_info['user']); 943e5e61eb0SAnika Henke if(auth_ismanager()) $l_user .= ' ('.$l_info['ip'].')'; 944db959ae3SAndreas Gohr } else { 945db959ae3SAndreas Gohr $l_user = $l_info['ip']; 946db959ae3SAndreas Gohr } 947e5e61eb0SAnika Henke $l_user = '<span class="user">'.$l_user.'</span>'; 948e5e61eb0SAnika Henke $l_sum = ($l_info['sum']) ? '<span class="sum">'.hsc($l_info['sum']).'</span>' : ''; 949e5e61eb0SAnika Henke if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $l_minor = 'class="minor"'; 950e5e61eb0SAnika Henke 95177707b04SAndreas Gohr $l_head = '<a class="wikilink1" href="'.wl($ID,"rev=$l_rev").'">'. 952f2263577SAndreas Gohr $ID.' ['.dformat($l_rev).']</a>'. 953e5e61eb0SAnika Henke '<br />'.$l_user.' '.$l_sum; 9547b3f8b16SAndreas Gohr } 95577707b04SAndreas Gohr 956820923f1SMichael Hamann if($r_rev){ 957820923f1SMichael Hamann $r_info = getRevisionInfo($ID,$r_rev,true); 958db959ae3SAndreas Gohr if($r_info['user']){ 959db959ae3SAndreas Gohr $r_user = editorinfo($r_info['user']); 960e5e61eb0SAnika Henke if(auth_ismanager()) $r_user .= ' ('.$r_info['ip'].')'; 961db959ae3SAndreas Gohr } else { 962db959ae3SAndreas Gohr $r_user = $r_info['ip']; 963db959ae3SAndreas Gohr } 964e5e61eb0SAnika Henke $r_user = '<span class="user">'.$r_user.'</span>'; 965e5e61eb0SAnika Henke $r_sum = ($r_info['sum']) ? '<span class="sum">'.hsc($r_info['sum']).'</span>' : ''; 966e5e61eb0SAnika Henke if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; 967e5e61eb0SAnika Henke 96877707b04SAndreas Gohr $r_head = '<a class="wikilink1" href="'.wl($ID,"rev=$r_rev").'">'. 969f2263577SAndreas Gohr $ID.' ['.dformat($r_rev).']</a>'. 970e5e61eb0SAnika Henke '<br />'.$r_user.' '.$r_sum; 9717b3f8b16SAndreas Gohr }elseif($_rev = @filemtime(wikiFN($ID))){ 972e5e61eb0SAnika Henke $_info = getRevisionInfo($ID,$_rev,true); 973db959ae3SAndreas Gohr if($_info['user']){ 974db959ae3SAndreas Gohr $_user = editorinfo($_info['user']); 975e5e61eb0SAnika Henke if(auth_ismanager()) $_user .= ' ('.$_info['ip'].')'; 976db959ae3SAndreas Gohr } else { 977db959ae3SAndreas Gohr $_user = $_info['ip']; 978db959ae3SAndreas Gohr } 979e5e61eb0SAnika Henke $_user = '<span class="user">'.$_user.'</span>'; 980e5e61eb0SAnika Henke $_sum = ($_info['sum']) ? '<span class="sum">'.hsc($_info['sum']).'</span>' : ''; 981e5e61eb0SAnika Henke if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; 982e5e61eb0SAnika Henke 98377707b04SAndreas Gohr $r_head = '<a class="wikilink1" href="'.wl($ID).'">'. 984f2263577SAndreas Gohr $ID.' ['.dformat($_rev).']</a> '. 985658b1aa0SAnika Henke '('.$lang['current'].')'. 986e5e61eb0SAnika Henke '<br />'.$_user.' '.$_sum; 9877b3f8b16SAndreas Gohr }else{ 988658b1aa0SAnika Henke $r_head = '— ('.$lang['current'].')'; 989f3f0262cSandi } 99077707b04SAndreas Gohr } 99177707b04SAndreas Gohr 99277707b04SAndreas Gohr $df = new Diff(explode("\n",htmlspecialchars($l_text)), 99377707b04SAndreas Gohr explode("\n",htmlspecialchars($r_text))); 99477707b04SAndreas Gohr 99572165381SAndreas Gohr if($type == 'inline'){ 99672165381SAndreas Gohr $tdf = new InlineDiffFormatter(); 99772165381SAndreas Gohr } else { 998f3f0262cSandi $tdf = new TableDiffFormatter(); 99972165381SAndreas Gohr } 100072165381SAndreas Gohr 100172165381SAndreas Gohr 100272165381SAndreas Gohr 1003c112d578Sandi if($intro) print p_locale_xhtml('diff'); 1004226bf2dcSGina Haeussge 1005226bf2dcSGina Haeussge if (!$text) { 10068d9e6ae7SAnika Henke ptln('<p class="difflink">'); 100772165381SAndreas Gohr 100872165381SAndreas Gohr $form = new Doku_Form(array('action'=>wl())); 10091b885c58SAndreas Gohr $form->addHidden('id',$ID); 101072165381SAndreas Gohr $form->addHidden('rev2[0]',$l_rev); 101172165381SAndreas Gohr $form->addHidden('rev2[1]',$r_rev); 101272165381SAndreas Gohr $form->addHidden('do','diff'); 101372165381SAndreas Gohr $form->addElement(form_makeListboxField( 101472165381SAndreas Gohr 'difftype', 101572165381SAndreas Gohr array( 101672165381SAndreas Gohr 'sidebyside' => $lang['diff_side'], 101772165381SAndreas Gohr 'inline' => $lang['diff_inline']), 101872165381SAndreas Gohr $type, 101972165381SAndreas Gohr $lang['diff_type'], 102072165381SAndreas Gohr '','', 102172165381SAndreas Gohr array('class'=>'quickselect'))); 102272165381SAndreas Gohr $form->addElement(form_makeButton('submit', 'diff','Go')); 102372165381SAndreas Gohr $form->printForm(); 102472165381SAndreas Gohr 102572165381SAndreas Gohr 102672165381SAndreas Gohr $diffurl = wl($ID, array( 102772165381SAndreas Gohr 'do' => 'diff', 102872165381SAndreas Gohr 'rev2[0]' => $l_rev, 102972165381SAndreas Gohr 'rev2[1]' => $r_rev, 103072165381SAndreas Gohr 'difftype' => $type, 103172165381SAndreas Gohr )); 103272165381SAndreas Gohr ptln('<br /><a class="wikilink1" href="'.$diffurl.'">'.$lang['difflink'].'</a>'); 10338d9e6ae7SAnika Henke ptln('</p>'); 1034226bf2dcSGina Haeussge } 1035f3f0262cSandi ?> 103672165381SAndreas Gohr <table class="diff diff_<?php echo $type?>"> 1037f3f0262cSandi <tr> 1038e5e61eb0SAnika Henke <th colspan="2" <?php echo $l_minor?>> 103977707b04SAndreas Gohr <?php echo $l_head?> 1040daf4ca4eSAnika Henke </th> 1041e5e61eb0SAnika Henke <th colspan="2" <?php echo $r_minor?>> 104277707b04SAndreas Gohr <?php echo $r_head?> 1043daf4ca4eSAnika Henke </th> 1044f3f0262cSandi </tr> 10454da078a3Smatthiasgrimm <?php echo $tdf->format($df)?> 1046f3f0262cSandi </table> 10474da078a3Smatthiasgrimm <?php 1048f3f0262cSandi} 1049f3f0262cSandi 105015fae107Sandi/** 105115fae107Sandi * show warning on conflict detection 105215fae107Sandi * 105315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 105415fae107Sandi */ 1055f3f0262cSandifunction html_conflict($text,$summary){ 1056f3f0262cSandi global $ID; 1057f3f0262cSandi global $lang; 1058f3f0262cSandi 1059c112d578Sandi print p_locale_xhtml('conflict'); 1060e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 1061fdb8d77bSTom N Harris $form->addHidden('id', $ID); 1062fdb8d77bSTom N Harris $form->addHidden('wikitext', $text); 1063fdb8d77bSTom N Harris $form->addHidden('summary', $summary); 1064fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s'))); 1065fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'])); 1066fdb8d77bSTom N Harris html_form('conflict', $form); 1067fdb8d77bSTom N Harris print '<br /><br /><br /><br />'.NL; 1068f3f0262cSandi} 1069f3f0262cSandi 1070f3f0262cSandi/** 107115fae107Sandi * Prints the global message array 107215fae107Sandi * 107315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1074f3f0262cSandi */ 1075f3f0262cSandifunction html_msgarea(){ 1076cc58224cSMichael Hamann global $MSG, $MSG_shown; 1077cc58224cSMichael Hamann // store if the global $MSG has already been shown and thus HTML output has been started 1078cc58224cSMichael Hamann $MSG_shown = true; 1079cc58224cSMichael Hamann 1080f3f0262cSandi if(!isset($MSG)) return; 1081f3f0262cSandi 10824af9f0d4SAndreas Gohr $shown = array(); 1083f3f0262cSandi foreach($MSG as $msg){ 10844af9f0d4SAndreas Gohr $hash = md5($msg['msg']); 10854af9f0d4SAndreas Gohr if(isset($shown[$hash])) continue; // skip double messages 1086f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 1087f3f0262cSandi print $msg['msg']; 1088f3f0262cSandi print '</div>'; 10894af9f0d4SAndreas Gohr $shown[$hash] = 1; 1090f3f0262cSandi } 1091cc58224cSMichael Hamann 1092cc58224cSMichael Hamann unset($GLOBALS['MSG']); 1093f3f0262cSandi} 1094f3f0262cSandi 1095f3f0262cSandi/** 1096f3f0262cSandi * Prints the registration form 109715fae107Sandi * 109815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1099f3f0262cSandi */ 1100f3f0262cSandifunction html_register(){ 1101f3f0262cSandi global $lang; 1102cab2716aSmatthias.grimm global $conf; 1103f3f0262cSandi global $ID; 1104f3f0262cSandi 1105c112d578Sandi print p_locale_xhtml('register'); 1106fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 1107e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__register')); 1108*bf413a4eSAnika Henke $form->startFieldset($lang['btn_register']); 1109fdb8d77bSTom N Harris $form->addHidden('do', 'register'); 1110fdb8d77bSTom N Harris $form->addHidden('save', '1'); 1111fdb8d77bSTom N Harris $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], null, 'block', array('size'=>'50'))); 1112cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 1113fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50'))); 1114fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1115cab2716aSmatthias.grimm } 1116fdb8d77bSTom N Harris $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', array('size'=>'50'))); 1117fdb8d77bSTom N Harris $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', array('size'=>'50'))); 1118*bf413a4eSAnika Henke $form->addElement(form_makeButton('submit', '', $lang['btn_register'])); 1119fdb8d77bSTom N Harris $form->endFieldset(); 1120fdb8d77bSTom N Harris html_form('register', $form); 1121cab2716aSmatthias.grimm 1122fdb8d77bSTom N Harris print '</div>'.NL; 1123f3f0262cSandi} 1124f3f0262cSandi 1125f3f0262cSandi/** 11268b06d178Schris * Print the update profile form 11278b06d178Schris * 11288b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 11298b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 11308b06d178Schris */ 11318b06d178Schrisfunction html_updateprofile(){ 11328b06d178Schris global $lang; 11338b06d178Schris global $conf; 11348b06d178Schris global $ID; 11358b06d178Schris global $INFO; 113682fd59b6SAndreas Gohr global $auth; 11378b06d178Schris 11388b06d178Schris print p_locale_xhtml('updateprofile'); 11398b06d178Schris 11408b06d178Schris if (empty($_POST['fullname'])) $_POST['fullname'] = $INFO['userinfo']['name']; 11418b06d178Schris if (empty($_POST['email'])) $_POST['email'] = $INFO['userinfo']['mail']; 1142fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 1143e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__register')); 1144fdb8d77bSTom N Harris $form->startFieldset($lang['profile']); 1145fdb8d77bSTom N Harris $form->addHidden('do', 'profile'); 1146fdb8d77bSTom N Harris $form->addHidden('save', '1'); 1147fdb8d77bSTom N Harris $form->addElement(form_makeTextField('fullname', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled'))); 1148fdb8d77bSTom N Harris $attr = array('size'=>'50'); 1149fdb8d77bSTom N Harris if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; 1150fdb8d77bSTom N Harris $form->addElement(form_makeTextField('fullname', $_POST['fullname'], $lang['fullname'], '', 'block', $attr)); 115139ba8890SAndreas Gohr $attr = array('size'=>'50'); 115239ba8890SAndreas Gohr if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled'; 1153fdb8d77bSTom N Harris $form->addElement(form_makeTextField('email', $_POST['email'], $lang['email'], '', 'block', $attr)); 1154fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1155fdb8d77bSTom N Harris if ($auth->canDo('modPass')) { 1156fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50'))); 1157fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1158fdb8d77bSTom N Harris } 1159fdb8d77bSTom N Harris if ($conf['profileconfirm']) { 1160fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1161fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50'))); 1162fdb8d77bSTom N Harris } 1163fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_save'])); 1164fdb8d77bSTom N Harris $form->addElement(form_makeButton('reset', '', $lang['btn_reset'])); 1165fdb8d77bSTom N Harris $form->endFieldset(); 1166fdb8d77bSTom N Harris html_form('updateprofile', $form); 1167fdb8d77bSTom N Harris print '</div>'.NL; 11688b06d178Schris} 11698b06d178Schris 11708b06d178Schris/** 11717c4635c4SAdrian Lang * Preprocess edit form data 117215fae107Sandi * 117315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 11742ffea8f2SAdrian Lang * 11752ffea8f2SAdrian Lang * @triggers HTML_EDITFORM_OUTPUT 1176f3f0262cSandi */ 11775a932e77SAdrian Langfunction html_edit(){ 1178f3f0262cSandi global $ID; 1179f3f0262cSandi global $REV; 1180f3f0262cSandi global $DATE; 1181f3f0262cSandi global $PRE; 1182f3f0262cSandi global $SUF; 1183f3f0262cSandi global $INFO; 1184f3f0262cSandi global $SUM; 1185f3f0262cSandi global $lang; 1186f3f0262cSandi global $conf; 118745a99335SAdrian Lang global $TEXT; 1188d141c8dcSAdrian Lang global $RANGE; 1189f3f0262cSandi 11908fe3bb00STom N Harris if (isset($_REQUEST['changecheck'])) { 11918fe3bb00STom N Harris $check = $_REQUEST['changecheck']; 119245a99335SAdrian Lang } elseif(!$INFO['exists']){ 119345a99335SAdrian Lang // $TEXT has been loaded from page template 119445a99335SAdrian Lang $check = md5(''); 11958fe3bb00STom N Harris } else { 119645a99335SAdrian Lang $check = md5($TEXT); 11978fe3bb00STom N Harris } 119845a99335SAdrian Lang $mod = md5($TEXT) !== $check; 1199f3f0262cSandi 120027eb9321SAnika Henke $wr = $INFO['writable'] && !$INFO['locked']; 120145a99335SAdrian Lang $include = 'edit'; 1202f3f0262cSandi if($wr){ 1203ffde0ac9SAdrian Lang if ($REV) $include = 'editrev'; 1204f3f0262cSandi }else{ 1205409d7af7SAndreas Gohr // check pseudo action 'source' 1206409d7af7SAndreas Gohr if(!actionOK('source')){ 1207409d7af7SAndreas Gohr msg('Command disabled: source',-1); 1208409d7af7SAndreas Gohr return; 1209409d7af7SAndreas Gohr } 1210ffde0ac9SAdrian Lang $include = 'read'; 1211f3f0262cSandi } 12127c4635c4SAdrian Lang 12137c4635c4SAdrian Lang global $license; 121442c7abd6SAndreas Gohr 1215e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 1216fdb8d77bSTom N Harris $form->addHidden('id', $ID); 1217fdb8d77bSTom N Harris $form->addHidden('rev', $REV); 1218fdb8d77bSTom N Harris $form->addHidden('date', $DATE); 121942de51b1SAdrian Lang $form->addHidden('prefix', $PRE . '.'); 1220fdb8d77bSTom N Harris $form->addHidden('suffix', $SUF); 1221fdb8d77bSTom N Harris $form->addHidden('changecheck', $check); 12228e4da260SAdrian Lang 12232ffea8f2SAdrian Lang $data = array('form' => $form, 12242ffea8f2SAdrian Lang 'wr' => $wr, 12252ffea8f2SAdrian Lang 'media_manager' => true, 122612c96aceSAdrian Lang 'target' => (isset($_REQUEST['target']) && $wr && 122712c96aceSAdrian Lang $RANGE !== '') ? $_REQUEST['target'] : 'section', 12282ffea8f2SAdrian Lang 'intro_locale' => $include); 122912c96aceSAdrian Lang 123012c96aceSAdrian Lang if ($data['target'] !== 'section') { 123112c96aceSAdrian Lang // Only emit event if page is writable, section edit data is valid and 123212c96aceSAdrian Lang // edit target is not section. 12338e4da260SAdrian Lang trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); 12342ffea8f2SAdrian Lang } else { 12352ffea8f2SAdrian Lang html_edit_form($data); 12362ffea8f2SAdrian Lang } 1237ffde0ac9SAdrian Lang if (isset($data['intro_locale'])) { 1238ffde0ac9SAdrian Lang echo p_locale_xhtml($data['intro_locale']); 1239ffde0ac9SAdrian Lang } 12408e4da260SAdrian Lang 1241b7eccc60SAdrian Lang $form->addHidden('target', $data['target']); 1242fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar'))); 1243fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); 1244fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1245fdb8d77bSTom N Harris if ($wr) { 1246fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); 1247fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); 1248fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); 1249fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); 1250fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1251fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); 1252fdb8d77bSTom N Harris $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); 1253fdb8d77bSTom N Harris $elem = html_minoredit(); 1254fdb8d77bSTom N Harris if ($elem) $form->addElement($elem); 1255fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1256fdb8d77bSTom N Harris } 1257fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 12585808bc54SAndreas Gohr if($wr && $conf['license']){ 1259066fee30SAndreas Gohr $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); 1260066fee30SAndreas Gohr $out = $lang['licenseok']; 1261066fee30SAndreas Gohr $out .= ' <a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"'; 126284645d8cSAndreas Gohr if(isset($conf['target']['extern'])) $out .= ' target="'.$conf['target']['extern'].'"'; 1263066fee30SAndreas Gohr $out .= '>'.$license[$conf['license']]['name'].'</a>'; 1264066fee30SAndreas Gohr $form->addElement($out); 1265066fee30SAndreas Gohr $form->addElement(form_makeCloseTag('div')); 1266066fee30SAndreas Gohr } 12678e4da260SAdrian Lang 12688e4da260SAdrian Lang if ($wr) { 12698e4da260SAdrian Lang // sets changed to true when previewed 12702e61e4dfSAdrian Lang echo '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--'. NL; 12718e4da260SAdrian Lang echo 'textChanged = ' . ($mod ? 'true' : 'false'); 12722e61e4dfSAdrian Lang echo '//--><!]]></script>' . NL; 12738e4da260SAdrian Lang } ?> 12748e4da260SAdrian Lang <div style="width:99%;"> 12758e4da260SAdrian Lang 12768e4da260SAdrian Lang <div class="toolbar"> 12778e4da260SAdrian Lang <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.dformat();?></div> 12788e4da260SAdrian Lang <div id="tool__bar"><?php if ($wr && $data['media_manager']){?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 12798e4da260SAdrian Lang target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> 12808e4da260SAdrian Lang 12818e4da260SAdrian Lang </div> 12828e4da260SAdrian Lang <?php 12838e4da260SAdrian Lang 1284fdb8d77bSTom N Harris html_form('edit', $form); 1285fdb8d77bSTom N Harris print '</div>'.NL; 1286f3f0262cSandi} 1287f3f0262cSandi 1288f3f0262cSandi/** 12898e4da260SAdrian Lang * Display the default edit form 12908e4da260SAdrian Lang * 12918e4da260SAdrian Lang * Is the default action for HTML_EDIT_FORMSELECTION. 12928e4da260SAdrian Lang */ 12938e4da260SAdrian Langfunction html_edit_form($param) { 129445a99335SAdrian Lang global $TEXT; 129512c96aceSAdrian Lang 129612c96aceSAdrian Lang if ($param['target'] !== 'section') { 129712c96aceSAdrian Lang msg('No editor for edit target ' . $param['target'] . ' found.', -1); 129812c96aceSAdrian Lang } 129912c96aceSAdrian Lang 13008e4da260SAdrian Lang $attr = array('tabindex'=>'1'); 130112c96aceSAdrian Lang if (!$param['wr']) $attr['readonly'] = 'readonly'; 130212c96aceSAdrian Lang 130312c96aceSAdrian Lang $param['form']->addElement(form_makeWikiText($TEXT, $attr)); 13048e4da260SAdrian Lang} 13058e4da260SAdrian Lang 13068e4da260SAdrian Lang/** 1307b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1308b6912aeaSAndreas Gohr * 1309b1f92db2SAdrian Lang * @author Andreas Gohr <andi@splitbrain.org> 1310b6912aeaSAndreas Gohr */ 1311b6912aeaSAndreas Gohrfunction html_minoredit(){ 1312b6912aeaSAndreas Gohr global $conf; 1313b6912aeaSAndreas Gohr global $lang; 1314b6912aeaSAndreas Gohr // minor edits are for logged in users only 1315b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1316fdb8d77bSTom N Harris return false; 1317b6912aeaSAndreas Gohr } 1318b6912aeaSAndreas Gohr 1319b6912aeaSAndreas Gohr $p = array(); 1320b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1321bb4866bdSchris if(!empty($_REQUEST['minor'])) $p['checked']='checked'; 1322fdb8d77bSTom N Harris return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p); 1323b6912aeaSAndreas Gohr} 1324b6912aeaSAndreas Gohr 1325b6912aeaSAndreas Gohr/** 1326f3f0262cSandi * prints some debug info 132715fae107Sandi * 132815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1329f3f0262cSandi */ 1330f3f0262cSandifunction html_debug(){ 1331f3f0262cSandi global $conf; 1332d16a4edaSandi global $lang; 13335298a619SAndreas Gohr global $auth; 1334100a97e3SAndreas Gohr global $INFO; 1335100a97e3SAndreas Gohr 133628fb55ffSandi //remove sensitive data 133728fb55ffSandi $cnf = $conf; 133824297a69SAndreas Gohr debug_guard($cnf); 1339100a97e3SAndreas Gohr $nfo = $INFO; 134024297a69SAndreas Gohr debug_guard($nfo); 1341100a97e3SAndreas Gohr $ses = $_SESSION; 134224297a69SAndreas Gohr debug_guard($ses); 1343f3f0262cSandi 1344f3f0262cSandi print '<html><body>'; 1345f3f0262cSandi 1346f3f0262cSandi print '<p>When reporting bugs please send all the following '; 1347f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 1348f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 1349f3f0262cSandi 1350100a97e3SAndreas Gohr print '<b>$INFO:</b><pre>'; 1351100a97e3SAndreas Gohr print_r($nfo); 1352100a97e3SAndreas Gohr print '</pre>'; 1353100a97e3SAndreas Gohr 1354f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 1355f3f0262cSandi print_r($_SERVER); 1356f3f0262cSandi print '</pre>'; 1357f3f0262cSandi 1358f3f0262cSandi print '<b>$conf:</b><pre>'; 135928fb55ffSandi print_r($cnf); 1360f3f0262cSandi print '</pre>'; 1361f3f0262cSandi 1362ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 1363ed7b5f09Sandi print DOKU_BASE; 1364f3f0262cSandi print '</pre>'; 1365f3f0262cSandi 1366ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 1367ed7b5f09Sandi print DOKU_URL; 1368ed7b5f09Sandi print '</pre>'; 1369ed7b5f09Sandi 1370ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 1371f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 1372f3f0262cSandi print '</pre>'; 1373f3f0262cSandi 1374f3f0262cSandi print '<b>PHP Version:</b><pre>'; 1375f3f0262cSandi print phpversion(); 1376f3f0262cSandi print '</pre>'; 1377f3f0262cSandi 1378f3f0262cSandi print '<b>locale:</b><pre>'; 1379f3f0262cSandi print setlocale(LC_ALL,0); 1380f3f0262cSandi print '</pre>'; 1381f3f0262cSandi 1382d16a4edaSandi print '<b>encoding:</b><pre>'; 1383d16a4edaSandi print $lang['encoding']; 1384d16a4edaSandi print '</pre>'; 1385d16a4edaSandi 13865298a619SAndreas Gohr if($auth){ 13875298a619SAndreas Gohr print '<b>Auth backend capabilities:</b><pre>'; 13885298a619SAndreas Gohr print_r($auth->cando); 13895298a619SAndreas Gohr print '</pre>'; 13905298a619SAndreas Gohr } 13915298a619SAndreas Gohr 13923aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 1393100a97e3SAndreas Gohr print_r($ses); 13943aa54d7cSAndreas Gohr print '</pre>'; 13953aa54d7cSAndreas Gohr 1396f3f0262cSandi print '<b>Environment:</b><pre>'; 1397f3f0262cSandi print_r($_ENV); 1398f3f0262cSandi print '</pre>'; 1399f3f0262cSandi 1400f3f0262cSandi print '<b>PHP settings:</b><pre>'; 1401f3f0262cSandi $inis = ini_get_all(); 1402f3f0262cSandi print_r($inis); 1403f3f0262cSandi print '</pre>'; 1404f3f0262cSandi 1405f3f0262cSandi print '</body></html>'; 1406f3f0262cSandi} 1407f3f0262cSandi 140810271ce4SAndreas Gohr/** 140910271ce4SAndreas Gohr * List available Administration Tasks 141010271ce4SAndreas Gohr * 141110271ce4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 141210271ce4SAndreas Gohr * @author Håkan Sandell <hakan.sandell@home.se> 141310271ce4SAndreas Gohr */ 1414c19fe9c0Sandifunction html_admin(){ 1415c19fe9c0Sandi global $ID; 1416f8cc712eSAndreas Gohr global $INFO; 1417c19fe9c0Sandi global $lang; 1418ca3a6df1SMatthias Grimm global $conf; 141910271ce4SAndreas Gohr global $auth; 1420c19fe9c0Sandi 142111e2ce22Schris // build menu of admin functions from the plugins that handle them 142211e2ce22Schris $pluginlist = plugin_list('admin'); 142311e2ce22Schris $menu = array(); 142411e2ce22Schris foreach ($pluginlist as $p) { 1425db959ae3SAndreas Gohr if($obj =& plugin_load('admin',$p) === null) continue; 1426f8cc712eSAndreas Gohr 1427f8cc712eSAndreas Gohr // check permissions 1428f8cc712eSAndreas Gohr if($obj->forAdminOnly() && !$INFO['isadmin']) continue; 1429f8cc712eSAndreas Gohr 143010271ce4SAndreas Gohr $menu[$p] = array('plugin' => $p, 143111e2ce22Schris 'prompt' => $obj->getMenuText($conf['lang']), 143211e2ce22Schris 'sort' => $obj->getMenuSort() 143311e2ce22Schris ); 143411e2ce22Schris } 143511e2ce22Schris 1436c95a5b7dSAndreas Gohr // data security check 1437b2f0ffd0SAnika Henke // @todo: could be checked and only displayed if $conf['savedir'] is under the web root 1438b2f0ffd0SAnika Henke echo '<a style="border:none; float:right;" target="_blank" 1439b2f0ffd0SAnika Henke href="http://www.dokuwiki.org/security#web_access_security"> 1440e8188911SAndreas Gohr <img src="data/security.png" alt="Your data directory seems to be protected properly." 1441e8188911SAndreas Gohr onerror="this.parentNode.style.display=\'none\'" /></a>'; 1442c95a5b7dSAndreas Gohr 144310271ce4SAndreas Gohr print p_locale_xhtml('admin'); 144410271ce4SAndreas Gohr 144510271ce4SAndreas Gohr // Admin Tasks 144610271ce4SAndreas Gohr if($INFO['isadmin']){ 144710271ce4SAndreas Gohr ptln('<ul class="admin_tasks">'); 144810271ce4SAndreas Gohr 144976c65fd3SAndreas Gohr if($menu['usermanager'] && $auth && $auth->canDo('getUsers')){ 145010271ce4SAndreas Gohr ptln(' <li class="admin_usermanager"><div class="li">'. 145110271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'usermanager')).'">'. 145210271ce4SAndreas Gohr $menu['usermanager']['prompt'].'</a></div></li>'); 145310271ce4SAndreas Gohr } 145410271ce4SAndreas Gohr unset($menu['usermanager']); 145510271ce4SAndreas Gohr 145676c65fd3SAndreas Gohr if($menu['acl']){ 145710271ce4SAndreas Gohr ptln(' <li class="admin_acl"><div class="li">'. 145810271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'acl')).'">'. 145910271ce4SAndreas Gohr $menu['acl']['prompt'].'</a></div></li>'); 146076c65fd3SAndreas Gohr } 146110271ce4SAndreas Gohr unset($menu['acl']); 146210271ce4SAndreas Gohr 146376c65fd3SAndreas Gohr if($menu['plugin']){ 146410271ce4SAndreas Gohr ptln(' <li class="admin_plugin"><div class="li">'. 146510271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'plugin')).'">'. 146610271ce4SAndreas Gohr $menu['plugin']['prompt'].'</a></div></li>'); 146776c65fd3SAndreas Gohr } 146810271ce4SAndreas Gohr unset($menu['plugin']); 146910271ce4SAndreas Gohr 147076c65fd3SAndreas Gohr if($menu['config']){ 147110271ce4SAndreas Gohr ptln(' <li class="admin_config"><div class="li">'. 147210271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'config')).'">'. 147310271ce4SAndreas Gohr $menu['config']['prompt'].'</a></div></li>'); 147476c65fd3SAndreas Gohr } 147510271ce4SAndreas Gohr unset($menu['config']); 147610271ce4SAndreas Gohr } 147710271ce4SAndreas Gohr ptln('</ul>'); 147810271ce4SAndreas Gohr 147910271ce4SAndreas Gohr // Manager Tasks 148010271ce4SAndreas Gohr ptln('<ul class="admin_tasks">'); 148110271ce4SAndreas Gohr 148276c65fd3SAndreas Gohr if($menu['revert']){ 148310271ce4SAndreas Gohr ptln(' <li class="admin_revert"><div class="li">'. 148410271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'revert')).'">'. 148510271ce4SAndreas Gohr $menu['revert']['prompt'].'</a></div></li>'); 148676c65fd3SAndreas Gohr } 148710271ce4SAndreas Gohr unset($menu['revert']); 148810271ce4SAndreas Gohr 148976c65fd3SAndreas Gohr if($menu['popularity']){ 149010271ce4SAndreas Gohr ptln(' <li class="admin_popularity"><div class="li">'. 149110271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'popularity')).'">'. 149210271ce4SAndreas Gohr $menu['popularity']['prompt'].'</a></div></li>'); 149376c65fd3SAndreas Gohr } 149410271ce4SAndreas Gohr unset($menu['popularity']); 149510271ce4SAndreas Gohr 14969a2cec2eSAndreas Gohr // print DokuWiki version: 149710271ce4SAndreas Gohr ptln('</ul>'); 14989a2cec2eSAndreas Gohr echo '<div id="admin__version">'; 14999a2cec2eSAndreas Gohr echo getVersion(); 15009a2cec2eSAndreas Gohr echo '</div>'; 150110271ce4SAndreas Gohr 150210271ce4SAndreas Gohr // print the rest as sorted list 150310271ce4SAndreas Gohr if(count($menu)){ 1504746855cfSBen Coburn usort($menu, 'p_sort_modes'); 150511e2ce22Schris // output the menu 150610271ce4SAndreas Gohr ptln('<div class="clearer"></div>'); 150710271ce4SAndreas Gohr print p_locale_xhtml('adminplugins'); 150811e2ce22Schris ptln('<ul>'); 150911e2ce22Schris foreach ($menu as $item) { 151011e2ce22Schris if (!$item['prompt']) continue; 15110c6b58a8SAndreas Gohr ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 151211e2ce22Schris } 151311e2ce22Schris ptln('</ul>'); 1514ca3a6df1SMatthias Grimm } 151510271ce4SAndreas Gohr} 1516c19fe9c0Sandi 15178b06d178Schris/** 15188b06d178Schris * Form to request a new password for an existing account 15198b06d178Schris * 15208b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 152111e2ce22Schris */ 15228b06d178Schrisfunction html_resendpwd() { 15238b06d178Schris global $lang; 15248b06d178Schris global $conf; 15258b06d178Schris global $ID; 1526c19fe9c0Sandi 15278b06d178Schris print p_locale_xhtml('resendpwd'); 1528fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 1529e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__resendpwd')); 1530fdb8d77bSTom N Harris $form->startFieldset($lang['resendpwd']); 1531fdb8d77bSTom N Harris $form->addHidden('do', 'resendpwd'); 1532fdb8d77bSTom N Harris $form->addHidden('save', '1'); 1533fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1534fdb8d77bSTom N Harris $form->addElement(form_makeTextField('login', $_POST['login'], $lang['user'], '', 'block')); 1535fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1536fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1537fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 1538fdb8d77bSTom N Harris $form->endFieldset(); 1539fdb8d77bSTom N Harris html_form('resendpwd', $form); 1540fdb8d77bSTom N Harris print '</div>'.NL; 1541fdb8d77bSTom N Harris} 1542fdb8d77bSTom N Harris 1543fdb8d77bSTom N Harris/** 1544b8595a66SAndreas Gohr * Return the TOC rendered to XHTML 1545b8595a66SAndreas Gohr * 1546b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1547b8595a66SAndreas Gohr */ 1548b8595a66SAndreas Gohrfunction html_TOC($toc){ 1549b8595a66SAndreas Gohr if(!count($toc)) return ''; 1550b8595a66SAndreas Gohr global $lang; 1551b8595a66SAndreas Gohr $out = '<!-- TOC START -->'.DOKU_LF; 1552b8595a66SAndreas Gohr $out .= '<div class="toc">'.DOKU_LF; 1553b8595a66SAndreas Gohr $out .= '<div class="tocheader toctoggle" id="toc__header">'; 1554b8595a66SAndreas Gohr $out .= $lang['toc']; 1555b8595a66SAndreas Gohr $out .= '</div>'.DOKU_LF; 1556b8595a66SAndreas Gohr $out .= '<div id="toc__inside">'.DOKU_LF; 1557b8595a66SAndreas Gohr $out .= html_buildlist($toc,'toc','html_list_toc'); 1558b8595a66SAndreas Gohr $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 1559b8595a66SAndreas Gohr $out .= '<!-- TOC END -->'.DOKU_LF; 1560db959ae3SAndreas Gohr return $out; 1561db959ae3SAndreas Gohr} 1562b8595a66SAndreas Gohr 1563b8595a66SAndreas Gohr/** 1564b8595a66SAndreas Gohr * Callback for html_buildlist 1565b8595a66SAndreas Gohr */ 1566b8595a66SAndreas Gohrfunction html_list_toc($item){ 1567c66972f2SAdrian Lang if(isset($item['hid'])){ 15687d91652aSAndreas Gohr $link = '#'.$item['hid']; 15697d91652aSAndreas Gohr }else{ 15707d91652aSAndreas Gohr $link = $item['link']; 15717d91652aSAndreas Gohr } 15727d91652aSAndreas Gohr 15737d91652aSAndreas Gohr return '<span class="li"><a href="'.$link.'" class="toc">'. 1574b8595a66SAndreas Gohr hsc($item['title']).'</a></span>'; 1575b8595a66SAndreas Gohr} 1576b8595a66SAndreas Gohr 1577b8595a66SAndreas Gohr/** 1578b8595a66SAndreas Gohr * Helper function to build TOC items 1579b8595a66SAndreas Gohr * 1580b8595a66SAndreas Gohr * Returns an array ready to be added to a TOC array 1581b8595a66SAndreas Gohr * 1582b8595a66SAndreas Gohr * @param string $link - where to link (if $hash set to '#' it's a local anchor) 1583b8595a66SAndreas Gohr * @param string $text - what to display in the TOC 1584b8595a66SAndreas Gohr * @param int $level - nesting level 1585b8595a66SAndreas Gohr * @param string $hash - is prepended to the given $link, set blank if you want full links 1586b8595a66SAndreas Gohr */ 1587b8595a66SAndreas Gohrfunction html_mktocitem($link, $text, $level, $hash='#'){ 1588b8595a66SAndreas Gohr global $conf; 1589b8595a66SAndreas Gohr return array( 'link' => $hash.$link, 1590b8595a66SAndreas Gohr 'title' => $text, 1591b8595a66SAndreas Gohr 'type' => 'ul', 15922bb0d541Schris 'level' => $level); 1593b8595a66SAndreas Gohr} 1594b8595a66SAndreas Gohr 1595b8595a66SAndreas Gohr/** 1596fdb8d77bSTom N Harris * Output a Doku_Form object. 1597fdb8d77bSTom N Harris * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 1598fdb8d77bSTom N Harris * 1599fdb8d77bSTom N Harris * @author Tom N Harris <tnharris@whoopdedo.org> 1600fdb8d77bSTom N Harris */ 1601fdb8d77bSTom N Harrisfunction html_form($name, &$form) { 1602fdb8d77bSTom N Harris // Safety check in case the caller forgets. 1603fdb8d77bSTom N Harris $form->endFieldset(); 1604fdb8d77bSTom N Harris trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 1605fdb8d77bSTom N Harris} 1606fdb8d77bSTom N Harris 1607fdb8d77bSTom N Harris/** 1608fdb8d77bSTom N Harris * Form print function. 1609fdb8d77bSTom N Harris * Just calls printForm() on the data object. 1610fdb8d77bSTom N Harris */ 1611fdb8d77bSTom N Harrisfunction html_form_output($data) { 1612fdb8d77bSTom N Harris $data->printForm(); 16138b06d178Schris} 1614340756e4Sandi 161507bf32b2SAndreas Gohr/** 161607bf32b2SAndreas Gohr * Embed a flash object in HTML 161707bf32b2SAndreas Gohr * 161807bf32b2SAndreas Gohr * This will create the needed HTML to embed a flash movie in a cross browser 161907bf32b2SAndreas Gohr * compatble way using valid XHTML 162007bf32b2SAndreas Gohr * 162107bf32b2SAndreas Gohr * The parameters $params, $flashvars and $atts need to be associative arrays. 162207bf32b2SAndreas Gohr * No escaping needs to be done for them. The alternative content *has* to be 162307bf32b2SAndreas Gohr * escaped because it is used as is. If no alternative content is given 162407bf32b2SAndreas Gohr * $lang['noflash'] is used. 162507bf32b2SAndreas Gohr * 162607bf32b2SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 162707bf32b2SAndreas Gohr * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml 162807bf32b2SAndreas Gohr * 162907bf32b2SAndreas Gohr * @param string $swf - the SWF movie to embed 163007bf32b2SAndreas Gohr * @param int $width - width of the flash movie in pixels 163107bf32b2SAndreas Gohr * @param int $height - height of the flash movie in pixels 163207bf32b2SAndreas Gohr * @param array $params - additional parameters (<param>) 163307bf32b2SAndreas Gohr * @param array $flashvars - parameters to be passed in the flashvar parameter 163407bf32b2SAndreas Gohr * @param array $atts - additional attributes for the <object> tag 163507bf32b2SAndreas Gohr * @param string $alt - alternative content (is NOT automatically escaped!) 163607bf32b2SAndreas Gohr * @returns string - the XHTML markup 163707bf32b2SAndreas Gohr */ 163807bf32b2SAndreas Gohrfunction html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){ 163907bf32b2SAndreas Gohr global $lang; 164007bf32b2SAndreas Gohr 164107bf32b2SAndreas Gohr $out = ''; 164207bf32b2SAndreas Gohr 164307bf32b2SAndreas Gohr // prepare the object attributes 164407bf32b2SAndreas Gohr if(is_null($atts)) $atts = array(); 164507bf32b2SAndreas Gohr $atts['width'] = (int) $width; 1646d4c61e61SAndreas Gohr $atts['height'] = (int) $height; 164707bf32b2SAndreas Gohr if(!$atts['width']) $atts['width'] = 425; 164807bf32b2SAndreas Gohr if(!$atts['height']) $atts['height'] = 350; 164907bf32b2SAndreas Gohr 165007bf32b2SAndreas Gohr // add object attributes for standard compliant browsers 165107bf32b2SAndreas Gohr $std = $atts; 165207bf32b2SAndreas Gohr $std['type'] = 'application/x-shockwave-flash'; 165307bf32b2SAndreas Gohr $std['data'] = $swf; 165407bf32b2SAndreas Gohr 165507bf32b2SAndreas Gohr // add object attributes for IE 165607bf32b2SAndreas Gohr $ie = $atts; 165707bf32b2SAndreas Gohr $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 165807bf32b2SAndreas Gohr 165907bf32b2SAndreas Gohr // open object (with conditional comments) 166007bf32b2SAndreas Gohr $out .= '<!--[if !IE]> -->'.NL; 166107bf32b2SAndreas Gohr $out .= '<object '.buildAttributes($std).'>'.NL; 166207bf32b2SAndreas Gohr $out .= '<!-- <![endif]-->'.NL; 166307bf32b2SAndreas Gohr $out .= '<!--[if IE]>'.NL; 166407bf32b2SAndreas Gohr $out .= '<object '.buildAttributes($ie).'>'.NL; 166507bf32b2SAndreas Gohr $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL; 16669ae41cdcSAndreas Gohr $out .= '<!--><!-- -->'.NL; 166707bf32b2SAndreas Gohr 166807bf32b2SAndreas Gohr // print params 166907bf32b2SAndreas Gohr if(is_array($params)) foreach($params as $key => $val){ 167007bf32b2SAndreas Gohr $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL; 167107bf32b2SAndreas Gohr } 167207bf32b2SAndreas Gohr 167307bf32b2SAndreas Gohr // add flashvars 167407bf32b2SAndreas Gohr if(is_array($flashvars)){ 1675d4c61e61SAndreas Gohr $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL; 167607bf32b2SAndreas Gohr } 167707bf32b2SAndreas Gohr 167807bf32b2SAndreas Gohr // alternative content 167907bf32b2SAndreas Gohr if($alt){ 168007bf32b2SAndreas Gohr $out .= $alt.NL; 168107bf32b2SAndreas Gohr }else{ 168207bf32b2SAndreas Gohr $out .= $lang['noflash'].NL; 168307bf32b2SAndreas Gohr } 168407bf32b2SAndreas Gohr 168507bf32b2SAndreas Gohr // finish 168607bf32b2SAndreas Gohr $out .= '</object>'.NL; 168707bf32b2SAndreas Gohr $out .= '<!-- <![endif]-->'.NL; 168807bf32b2SAndreas Gohr 168907bf32b2SAndreas Gohr return $out; 169007bf32b2SAndreas Gohr} 169107bf32b2SAndreas Gohr 1692