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> 168d5e837eSMichael Hamann * @param string $id id of the target page 178d5e837eSMichael Hamann * @param string $name the name of the link, i.e. the text that is displayed 188d5e837eSMichael Hamann * @param string|array $search search string(s) that shall be highlighted in the target page 198d5e837eSMichael Hamann * @return string the HTML code of the link 20f3f0262cSandi */ 21db959ae3SAndreas Gohrfunction html_wikilink($id,$name=null,$search=''){ 22db959ae3SAndreas Gohr static $xhtml_renderer = null; 23723d78dbSandi if(is_null($xhtml_renderer)){ 247aea91afSChris Smith $xhtml_renderer = p_get_renderer('xhtml'); 25f3f0262cSandi } 26f3f0262cSandi 27fe9ec250SChris Smith return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); 28f3f0262cSandi} 29f3f0262cSandi 30f3f0262cSandi/** 31f3f0262cSandi * The loginform 3215fae107Sandi * 3315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 34f3f0262cSandi */ 35f3f0262cSandifunction html_login(){ 36f3f0262cSandi global $lang; 37f3f0262cSandi global $conf; 38f3f0262cSandi global $ID; 39f0859d4bSTom N Harris global $INPUT; 40f3f0262cSandi 41c112d578Sandi print p_locale_xhtml('login'); 42fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 43e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__login')); 44fdb8d77bSTom N Harris $form->startFieldset($lang['btn_login']); 45fdb8d77bSTom N Harris $form->addHidden('id', $ID); 46fdb8d77bSTom N Harris $form->addHidden('do', 'login'); 47f0859d4bSTom N Harris $form->addElement(form_makeTextField('u', ((!$INPUT->bool('http_credentials')) ? $INPUT->str('u') : ''), $lang['user'], 'focus__this', 'block')); 48fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); 4917f89d7eSMichael Klier if($conf['rememberme']) { 50fdb8d77bSTom N Harris $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); 5117f89d7eSMichael Klier } 52fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); 53fdb8d77bSTom N Harris $form->endFieldset(); 545b62573aSAndreas Gohr 55de4d479aSAdrian Lang if(actionOK('register')){ 56bf413a4eSAnika Henke $form->addElement('<p>'.$lang['reghere'].': '.tpl_actionlink('register','','','',true).'</p>'); 57f3f0262cSandi } 588b06d178Schris 59de4d479aSAdrian Lang if (actionOK('resendpwd')) { 60bf413a4eSAnika Henke $form->addElement('<p>'.$lang['pwdforget'].': '.tpl_actionlink('resendpwd','','','',true).'</p>'); 618b06d178Schris } 6276ec5467SMichael Klier 6376ec5467SMichael Klier html_form('login', $form); 64fdb8d77bSTom N Harris print '</div>'.NL; 65f3f0262cSandi} 66f3f0262cSandi 67f3f0262cSandi/** 6815fae107Sandi * inserts section edit buttons if wanted or removes the markers 6915fae107Sandi * 7015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 7115fae107Sandi */ 72f3f0262cSandifunction html_secedit($text,$show=true){ 73f3f0262cSandi global $INFO; 7435dae8b0SBen Coburn 753f9e3215SAdrian Lang $regexp = '#<!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->#'; 76b081e262SAdrian Lang 7740868f2fSAdrian Lang if(!$INFO['writable'] || !$show || $INFO['rev']){ 7840868f2fSAdrian Lang return preg_replace($regexp,'',$text); 79f3f0262cSandi } 8035dae8b0SBen Coburn 8140868f2fSAdrian Lang return preg_replace_callback($regexp, 8240868f2fSAdrian Lang 'html_secedit_button', $text); 8340868f2fSAdrian Lang} 8440868f2fSAdrian Lang 8540868f2fSAdrian Lang/** 8640868f2fSAdrian Lang * prepares section edit button data for event triggering 8740868f2fSAdrian Lang * used as a callback in html_secedit 8840868f2fSAdrian Lang * 8940868f2fSAdrian Lang * @triggers HTML_SECEDIT_BUTTON 9040868f2fSAdrian Lang * @author Andreas Gohr <andi@splitbrain.org> 9140868f2fSAdrian Lang */ 9240868f2fSAdrian Langfunction html_secedit_button($matches){ 93905fa971SAdrian Lang $data = array('secid' => $matches[1], 9440868f2fSAdrian Lang 'target' => strtolower($matches[2]), 9540868f2fSAdrian Lang 'range' => $matches[count($matches) - 1]); 9640868f2fSAdrian Lang if (count($matches) === 5) { 9740868f2fSAdrian Lang $data['name'] = $matches[3]; 9840868f2fSAdrian Lang } 9940868f2fSAdrian Lang 10040868f2fSAdrian Lang return trigger_event('HTML_SECEDIT_BUTTON', $data, 10140868f2fSAdrian Lang 'html_secedit_get_button'); 10240868f2fSAdrian Lang} 10340868f2fSAdrian Lang 10440868f2fSAdrian Lang/** 10540868f2fSAdrian Lang * prints a section editing button 10640868f2fSAdrian Lang * used as default action form HTML_SECEDIT_BUTTON 10740868f2fSAdrian Lang * 10840868f2fSAdrian Lang * @author Adrian Lang <lang@cosmocode.de> 10940868f2fSAdrian Lang */ 11040868f2fSAdrian Langfunction html_secedit_get_button($data) { 11140868f2fSAdrian Lang global $ID; 11240868f2fSAdrian Lang global $INFO; 11340868f2fSAdrian Lang 1146d9eab4dSMichael Hamann if (!isset($data['name']) || $data['name'] === '') return ''; 11540868f2fSAdrian Lang 11640868f2fSAdrian Lang $name = $data['name']; 11740868f2fSAdrian Lang unset($data['name']); 11840868f2fSAdrian Lang 119905fa971SAdrian Lang $secid = $data['secid']; 120905fa971SAdrian Lang unset($data['secid']); 121905fa971SAdrian Lang 12240868f2fSAdrian Lang return "<div class='secedit editbutton_" . $data['target'] . 123defa93a1SAdrian Lang " editbutton_" . $secid . "'>" . 12440868f2fSAdrian Lang html_btn('secedit', $ID, '', 12540868f2fSAdrian Lang array_merge(array('do' => 'edit', 126b150cd2cSGina Haeussge 'rev' => $INFO['lastmod'], 127b150cd2cSGina Haeussge 'summary' => '['.$name.'] '), $data), 12840868f2fSAdrian Lang 'post', $name) . '</div>'; 129f3f0262cSandi} 130f3f0262cSandi 131f3f0262cSandi/** 132d6c9c552Smatthiasgrimm * Just the back to top button (in its own form) 1336b13307fSandi * 1346b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 1356b13307fSandi */ 1366b13307fSandifunction html_topbtn(){ 1376b13307fSandi global $lang; 1386b13307fSandi 13911ea018fSAndreas 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>'; 140df7b6005Sandi 1416b13307fSandi return $ret; 1426b13307fSandi} 1436b13307fSandi 1446b13307fSandi/** 145d67ca2c0Smatthiasgrimm * Displays a button (using its own form) 14635dae8b0SBen Coburn * If tooltip exists, the access key tooltip is replaced. 14715fae107Sandi * 14815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 149f3f0262cSandi */ 150f5baf821SAnika Henkefunction html_btn($name,$id,$akey,$params,$method='get',$tooltip='',$label=false){ 151f3f0262cSandi global $conf; 152f3f0262cSandi global $lang; 153f3f0262cSandi 154f5baf821SAnika Henke if (!$label) 155f3f0262cSandi $label = $lang['btn_'.$name]; 156f3f0262cSandi 157f3f0262cSandi $ret = ''; 158f3f0262cSandi 15949c713a3Sandi //filter id (without urlencoding) 16049c713a3Sandi $id = idfilter($id,false); 161f3f0262cSandi 162f3f0262cSandi //make nice URLs even for buttons 1636c7843b5Sandi if($conf['userewrite'] == 2){ 1646c7843b5Sandi $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 1656c7843b5Sandi }elseif($conf['userewrite']){ 1666c7843b5Sandi $script = DOKU_BASE.$id; 1676c7843b5Sandi }else{ 1688b00ebcfSandi $script = DOKU_BASE.DOKU_SCRIPT; 169f3f0262cSandi $params['id'] = $id; 170f3f0262cSandi } 171f3f0262cSandi 172b278f2deSAndreas Gohr $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">'; 173f3f0262cSandi 17406a4bf8fSAndreas Gohr if(is_array($params)){ 175f3f0262cSandi reset($params); 176f3f0262cSandi while (list($key, $val) = each($params)) { 177f3f0262cSandi $ret .= '<input type="hidden" name="'.$key.'" '; 178f3f0262cSandi $ret .= 'value="'.htmlspecialchars($val).'" />'; 179f3f0262cSandi } 18006a4bf8fSAndreas Gohr } 181f3f0262cSandi 18235dae8b0SBen Coburn if ($tooltip!='') { 18335dae8b0SBen Coburn $tip = htmlspecialchars($tooltip); 18411ea018fSAndreas Gohr }else{ 18511ea018fSAndreas Gohr $tip = htmlspecialchars($label); 18611ea018fSAndreas Gohr } 18711ea018fSAndreas Gohr 188d822118cSAdrian Lang $ret .= '<input type="submit" value="'.hsc($label).'" class="button" '; 18911ea018fSAndreas Gohr if($akey){ 19007493d05SAnika Henke $tip .= ' ['.strtoupper($akey).']'; 19187cb01b7SAnika Henke $ret .= 'accesskey="'.$akey.'" '; 19235dae8b0SBen Coburn } 19335dae8b0SBen Coburn $ret .= 'title="'.$tip.'" '; 194f3f0262cSandi $ret .= '/>'; 1954beabca9SAnika Henke $ret .= '</div></form>'; 196f3f0262cSandi 197f3f0262cSandi return $ret; 198f3f0262cSandi} 199f3f0262cSandi 200f3f0262cSandi/** 20115fae107Sandi * show a wiki page 20215fae107Sandi * 20315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 20415fae107Sandi */ 20511c78c94SAndreas Gohrfunction html_show($txt=null){ 206f3f0262cSandi global $ID; 207f3f0262cSandi global $REV; 208f3f0262cSandi global $HIGH; 209b8595a66SAndreas Gohr global $INFO; 210f3f0262cSandi //disable section editing for old revisions or in preview 2115400331dSandi if($txt || $REV){ 2126bbae538Sandi $secedit = false; 2136bbae538Sandi }else{ 2146bbae538Sandi $secedit = true; 215f3f0262cSandi } 216f3f0262cSandi 21711c78c94SAndreas Gohr if (!is_null($txt)){ 218f3f0262cSandi //PreviewHeader 219b8595a66SAndreas Gohr echo '<br id="scroll__here" />'; 220b8595a66SAndreas Gohr echo p_locale_xhtml('preview'); 221fc8dc822SAnika Henke echo '<div class="preview"><div class="pad">'; 222b8595a66SAndreas Gohr $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 223b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 224b8595a66SAndreas Gohr echo $html; 225b8595a66SAndreas Gohr echo '<div class="clearer"></div>'; 226fc8dc822SAnika Henke echo '</div></div>'; 2276bbae538Sandi 228f3f0262cSandi }else{ 229c112d578Sandi if ($REV) print p_locale_xhtml('showrev'); 230c112d578Sandi $html = p_wiki_xhtml($ID,$REV,true); 2316bbae538Sandi $html = html_secedit($html,$secedit); 232b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 233b8595a66SAndreas Gohr $html = html_hilight($html,$HIGH); 234b8595a66SAndreas Gohr echo $html; 235f3f0262cSandi } 236f3f0262cSandi} 237f3f0262cSandi 238f3f0262cSandi/** 239ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft 240ee4c4a1bSAndreas Gohr * 241ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 242ee4c4a1bSAndreas Gohr */ 243ee4c4a1bSAndreas Gohrfunction html_draft(){ 244ee4c4a1bSAndreas Gohr global $INFO; 245ee4c4a1bSAndreas Gohr global $ID; 246ee4c4a1bSAndreas Gohr global $lang; 247ee4c4a1bSAndreas Gohr $draft = unserialize(io_readFile($INFO['draft'],false)); 248ee4c4a1bSAndreas Gohr $text = cleanText(con($draft['prefix'],$draft['text'],$draft['suffix'],true)); 249ee4c4a1bSAndreas Gohr 250fdb8d77bSTom N Harris print p_locale_xhtml('draft'); 251e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 252fdb8d77bSTom N Harris $form->addHidden('id', $ID); 253fdb8d77bSTom N Harris $form->addHidden('date', $draft['date']); 254fdb8d77bSTom N Harris $form->addElement(form_makeWikiText($text, array('readonly'=>'readonly'))); 255fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); 256f2263577SAndreas Gohr $form->addElement($lang['draftdate'].' '. dformat(filemtime($INFO['draft']))); 257fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 258fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); 259fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); 260fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); 261fdb8d77bSTom N Harris html_form('draft', $form); 262ee4c4a1bSAndreas Gohr} 263ee4c4a1bSAndreas Gohr 264ee4c4a1bSAndreas Gohr/** 265f3f0262cSandi * Highlights searchqueries in HTML code 26615fae107Sandi * 26715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 2687209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 269f3f0262cSandi */ 270546d3a99SAndreas Gohrfunction html_hilight($html,$phrases){ 2718a803caeSAndreas Gohr $phrases = (array) $phrases; 2728a803caeSAndreas Gohr $phrases = array_map('preg_quote_cb', $phrases); 2738a803caeSAndreas Gohr $phrases = array_map('ft_snippet_re_preprocess', $phrases); 2748a803caeSAndreas Gohr $phrases = array_filter($phrases); 2758a803caeSAndreas Gohr $regex = join('|',$phrases); 27660c15d7dSAndreas Gohr 27760c15d7dSAndreas Gohr if ($regex === '') return $html; 27824a6c235SAndreas Gohr if (!utf8_check($regex)) return $html; 27924a6c235SAndreas Gohr $html = @preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); 280f3f0262cSandi return $html; 281f3f0262cSandi} 282f3f0262cSandi 283f3f0262cSandi/** 2847209be23SAndreas Gohr * Callback used by html_hilight() 2857209be23SAndreas Gohr * 2867209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 2877209be23SAndreas Gohr */ 2887209be23SAndreas Gohrfunction html_hilight_callback($m) { 2897209be23SAndreas Gohr $hlight = unslash($m[0]); 2907209be23SAndreas Gohr if ( !isset($m[2])) { 291688774a0SAnika Henke $hlight = '<span class="search_hit">'.$hlight.'</span>'; 2927209be23SAndreas Gohr } 2937209be23SAndreas Gohr return $hlight; 2947209be23SAndreas Gohr} 2957209be23SAndreas Gohr 2967209be23SAndreas Gohr/** 29715fae107Sandi * Run a search and display the result 29815fae107Sandi * 29915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 300f3f0262cSandi */ 301f3f0262cSandifunction html_search(){ 302f3f0262cSandi global $QUERY; 303f3f0262cSandi global $lang; 304f3f0262cSandi 30506756ad2SAndreas Gohr $intro = p_locale_xhtml('searchpage'); 30606756ad2SAndreas Gohr // allow use of placeholder in search intro 30706756ad2SAndreas Gohr $intro = str_replace( 30806756ad2SAndreas Gohr array('@QUERY@','@SEARCH@'), 30906756ad2SAndreas Gohr array(hsc(rawurlencode($QUERY)),hsc($QUERY)), 31006756ad2SAndreas Gohr $intro); 31106756ad2SAndreas Gohr echo $intro; 312f3f0262cSandi flush(); 313f3f0262cSandi 3144d9ff3d5Sandi //show progressbar 31591b05b6bSAnika Henke print '<div id="dw__loading">'.NL; 316677d2785SDominik Eckelmann print '<script type="text/javascript">/*<![CDATA[*/'.NL; 317e226efe1SAndreas Gohr print 'showLoadBar();'.NL; 318677d2785SDominik Eckelmann print '/*!]]>*/</script>'.NL; 31991b05b6bSAnika Henke print '</div>'.NL; 3209edac8a8SAndreas Gohr flush(); 3214d9ff3d5Sandi 322f3f0262cSandi //do quick pagesearch 3236ef71970SAdrian Lang $data = ft_pageLookup($QUERY,true,useHeading('navigation')); 324f3f0262cSandi if(count($data)){ 325f3f0262cSandi print '<div class="search_quickresult">'; 326746855cfSBen Coburn print '<h3>'.$lang['quickhits'].':</h3>'; 3274f732f0eSAnika Henke print '<ul class="search_quickhits">'; 3288d22f1e9SAndreas Gohr foreach($data as $id => $title){ 3294f732f0eSAnika Henke print '<li> '; 3308d22f1e9SAndreas Gohr if (useHeading('navigation')) { 3318d22f1e9SAndreas Gohr $name = $title; 3328d22f1e9SAndreas Gohr }else{ 333bd2f6c2fSAndreas Gohr $ns = getNS($id); 334bd2f6c2fSAndreas Gohr if($ns){ 335bd2f6c2fSAndreas Gohr $name = shorten(noNS($id), ' ('.$ns.')',30); 336bd2f6c2fSAndreas Gohr }else{ 337bd2f6c2fSAndreas Gohr $name = $id; 338bd2f6c2fSAndreas Gohr } 3398d22f1e9SAndreas Gohr } 340bd2f6c2fSAndreas Gohr print html_wikilink(':'.$id,$name); 3414f732f0eSAnika Henke print '</li> '; 342f3f0262cSandi } 343140c93f3SAnika Henke print '</ul> '; 344f3f0262cSandi //clear float (see http://www.complexspiral.com/publications/containing-floats/) 345be62ff97SAnika Henke print '<div class="clearer"></div>'; 346f3f0262cSandi print '</div>'; 347f3f0262cSandi } 348f3f0262cSandi flush(); 349f3f0262cSandi 350f3f0262cSandi //do fulltext search 35160c15d7dSAndreas Gohr $data = ft_pageSearch($QUERY,$regex); 352f3f0262cSandi if(count($data)){ 35391b05b6bSAnika Henke print '<dl class="search_results">'; 354506fa893SAndreas Gohr $num = 1; 355506fa893SAndreas Gohr foreach($data as $id => $cnt){ 35691b05b6bSAnika Henke print '<dt>'; 357db959ae3SAndreas Gohr print html_wikilink(':'.$id,useHeading('navigation')?null:$id,$regex); 358865c2687SKazutaka Miyasaka if($cnt !== 0){ 35991b05b6bSAnika Henke print ': '.$cnt.' '.$lang['hits'].''; 36091b05b6bSAnika Henke } 36191b05b6bSAnika Henke print '</dt>'; 36291b05b6bSAnika Henke if($cnt !== 0){ 363bd0293e7SAndreas Gohr if($num < FT_SNIPPET_NUMBER){ // create snippets for the first number of matches only 36491b05b6bSAnika Henke print '<dd>'.ft_snippet($id,$regex).'</dd>'; 365506fa893SAndreas Gohr } 366865c2687SKazutaka Miyasaka $num++; 367865c2687SKazutaka Miyasaka } 368506fa893SAndreas Gohr flush(); 369f3f0262cSandi } 37091b05b6bSAnika Henke print '</dl>'; 371f3f0262cSandi }else{ 372820fa24bSandi print '<div class="nothing">'.$lang['nothingfound'].'</div>'; 373f3f0262cSandi } 3744d9ff3d5Sandi 3754d9ff3d5Sandi //hide progressbar 376677d2785SDominik Eckelmann print '<script type="text/javascript">/*<![CDATA[*/'.NL; 377e226efe1SAndreas Gohr print 'hideLoadBar("dw__loading");'.NL; 378677d2785SDominik Eckelmann print '/*!]]>*/</script>'.NL; 3799edac8a8SAndreas Gohr flush(); 380f3f0262cSandi} 381f3f0262cSandi 38215fae107Sandi/** 38315fae107Sandi * Display error on locked pages 38415fae107Sandi * 38515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 38615fae107Sandi */ 387ee20e7d1Sandifunction html_locked(){ 388f3f0262cSandi global $ID; 389f3f0262cSandi global $conf; 390f3f0262cSandi global $lang; 39188f522e9Sandi global $INFO; 392f3f0262cSandi 393c9b4bd1eSBen Coburn $locktime = filemtime(wikiLockFN($ID)); 394f2263577SAndreas Gohr $expire = dformat($locktime + $conf['locktime']); 395f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 396f3f0262cSandi 397c112d578Sandi print p_locale_xhtml('locked'); 398f3f0262cSandi print '<ul>'; 3996d233a0cSAndy Webber print '<li><div class="li"><strong>'.$lang['lockedby'].':</strong> '.editorinfo($INFO['locked']).'</div></li>'; 4000c6b58a8SAndreas Gohr print '<li><div class="li"><strong>'.$lang['lockexpire'].':</strong> '.$expire.' ('.$min.' min)</div></li>'; 401f3f0262cSandi print '</ul>'; 402f3f0262cSandi} 403f3f0262cSandi 40415fae107Sandi/** 40515fae107Sandi * list old revisions 40615fae107Sandi * 40715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 40871726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 4098e69fd30SKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 41015fae107Sandi */ 4118e69fd30SKate Arzamastsevafunction html_revisions($first=0, $media_id = false){ 412f3f0262cSandi global $ID; 413f3f0262cSandi global $INFO; 414f3f0262cSandi global $conf; 415f3f0262cSandi global $lang; 4168e69fd30SKate Arzamastseva $id = $ID; 41761e0b2f8SChristopher Smith /* we need to get one additional log entry to be able to 41871726d78SBen Coburn * decide if this is the last page or is there another one. 41971726d78SBen Coburn * see html_recent() 42071726d78SBen Coburn */ 4218e69fd30SKate Arzamastseva if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1); 4228e69fd30SKate Arzamastseva else { 4238e69fd30SKate Arzamastseva $revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true); 4248e69fd30SKate Arzamastseva $id = $media_id; 4258e69fd30SKate Arzamastseva } 4268e69fd30SKate Arzamastseva 42771726d78SBen Coburn if(count($revisions)==0 && $first!=0){ 42871726d78SBen Coburn $first=0; 4298e69fd30SKate Arzamastseva if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1); 4308e69fd30SKate Arzamastseva else $revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true); 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 4388e69fd30SKate Arzamastseva if (!$media_id) $date = dformat($INFO['lastmod']); 4398e69fd30SKate Arzamastseva else $date = dformat(@filemtime(mediaFN($id))); 440f3f0262cSandi 4418e69fd30SKate Arzamastseva if (!$media_id) print p_locale_xhtml('revisions'); 44237a1dc12Smichael 4430607bfeeSAnika Henke $params = array('id' => 'page__revisions', 'class' => 'changes'); 4446183fb05SKate Arzamastseva if ($media_id) $params['action'] = media_managerURL(array('image' => $media_id), '&'); 4457d7ab775SKate Arzamastseva 4467d7ab775SKate Arzamastseva $form = new Doku_Form($params); 44737a1dc12Smichael $form->addElement(form_makeOpenTag('ul')); 4488e69fd30SKate Arzamastseva 4498e69fd30SKate Arzamastseva if (!$media_id) $exists = $INFO['exists']; 4508e69fd30SKate Arzamastseva else $exists = @file_exists(mediaFN($id)); 4518e69fd30SKate Arzamastseva 45290658f38SMichael Hamann $display_name = (!$media_id && useHeading('navigation')) ? hsc(p_get_first_heading($id)) : $id; 453ff5a286cSMichael Hamann if (!$display_name) $display_name = $id; 45490658f38SMichael Hamann 4558e69fd30SKate Arzamastseva if($exists && $first==0){ 4568e69fd30SKate Arzamastseva if (!$media_id && isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 45737a1dc12Smichael $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 45837a1dc12Smichael else 45937a1dc12Smichael $form->addElement(form_makeOpenTag('li')); 46037a1dc12Smichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 46137a1dc12Smichael $form->addElement(form_makeTag('input', array( 46237a1dc12Smichael 'type' => 'checkbox', 46337a1dc12Smichael 'name' => 'rev2[]', 46437a1dc12Smichael 'value' => 'current'))); 465f9b2fe70Sandi 46637a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 46737a1dc12Smichael $form->addElement($date); 46837a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 469f9b2fe70Sandi 470c2e73886SAnika Henke $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); 471cffcc403Sandi 472dad6764eSKate Arzamastseva if (!$media_id) $href = wl($id); 473de11c42fSKate Arzamastseva else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&'); 47437a1dc12Smichael $form->addElement(form_makeOpenTag('a', array( 47537a1dc12Smichael 'class' => 'wikilink1', 476dad6764eSKate Arzamastseva 'href' => $href))); 47790658f38SMichael Hamann $form->addElement($display_name); 47837a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 479652610a2Sandi 48067c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeOpenTag('div')); 48167c8cda1SKate Arzamastseva 482035e07f1SKate Arzamastseva if (!$media_id) { 48337a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 484e260f93bSAnika Henke $form->addElement(' – '); 485035e07f1SKate Arzamastseva $form->addElement(htmlspecialchars($INFO['sum'])); 48637a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 487035e07f1SKate Arzamastseva } 488652610a2Sandi 48937a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 490dad6764eSKate Arzamastseva if (!$media_id) $editor = $INFO['editor']; 491dad6764eSKate Arzamastseva else { 492dad6764eSKate Arzamastseva $revinfo = getRevisionInfo($id, @filemtime(fullpath(mediaFN($id))), 1024, true); 493dad6764eSKate Arzamastseva if($revinfo['user']){ 494dad6764eSKate Arzamastseva $editor = $revinfo['user']; 495dad6764eSKate Arzamastseva }else{ 496dad6764eSKate Arzamastseva $editor = $revinfo['ip']; 497dad6764eSKate Arzamastseva } 498dad6764eSKate Arzamastseva } 499dad6764eSKate Arzamastseva $form->addElement((empty($editor))?('('.$lang['external_edit'].')'):editorinfo($editor)); 50037a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 50137a1dc12Smichael 50237a1dc12Smichael $form->addElement('('.$lang['current'].')'); 50367c8cda1SKate Arzamastseva 50467c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeCloseTag('div')); 50567c8cda1SKate Arzamastseva 50637a1dc12Smichael $form->addElement(form_makeCloseTag('div')); 50737a1dc12Smichael $form->addElement(form_makeCloseTag('li')); 508f3f0262cSandi } 509f3f0262cSandi 510f3f0262cSandi foreach($revisions as $rev){ 511f2263577SAndreas Gohr $date = dformat($rev); 512dad6764eSKate Arzamastseva if (!$media_id) { 5138e69fd30SKate Arzamastseva $info = getRevisionInfo($id,$rev,true); 514dad6764eSKate Arzamastseva $exists = page_exists($id,$rev); 515dad6764eSKate Arzamastseva } else { 516dad6764eSKate Arzamastseva $info = getRevisionInfo($id,$rev,true,true); 517dad6764eSKate Arzamastseva $exists = @file_exists(mediaFN($id,$rev)); 518dad6764eSKate Arzamastseva } 519652610a2Sandi 52037a1dc12Smichael if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 52137a1dc12Smichael $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 52237a1dc12Smichael else 52337a1dc12Smichael $form->addElement(form_makeOpenTag('li')); 52437a1dc12Smichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 52577707b04SAndreas Gohr if($exists){ 52637a1dc12Smichael $form->addElement(form_makeTag('input', array( 52737a1dc12Smichael 'type' => 'checkbox', 52837a1dc12Smichael 'name' => 'rev2[]', 52937a1dc12Smichael 'value' => $rev))); 53077707b04SAndreas Gohr }else{ 531c2e73886SAnika Henke $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); 53241396b71SAndreas Gohr } 533f9b2fe70Sandi 53437a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 53537a1dc12Smichael $form->addElement($date); 53637a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 53737a1dc12Smichael 53837a1dc12Smichael if($exists){ 539dad6764eSKate Arzamastseva if (!$media_id) $href = wl($id,"rev=$rev,do=diff", false, '&'); 540de11c42fSKate Arzamastseva else $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff'), '&'); 541dad6764eSKate Arzamastseva $form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'diff_link'))); 54237a1dc12Smichael $form->addElement(form_makeTag('img', array( 54337a1dc12Smichael 'src' => DOKU_BASE.'lib/images/diff.png', 54437a1dc12Smichael 'width' => 15, 54537a1dc12Smichael 'height' => 11, 54637a1dc12Smichael 'title' => $lang['diff'], 54737a1dc12Smichael 'alt' => $lang['diff']))); 54837a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 549dad6764eSKate Arzamastseva if (!$media_id) $href = wl($id,"rev=$rev",false,'&'); 550de11c42fSKate Arzamastseva else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&'); 551dad6764eSKate Arzamastseva $form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'wikilink1'))); 55290658f38SMichael Hamann $form->addElement($display_name); 55337a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 55437a1dc12Smichael }else{ 555c2e73886SAnika Henke $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); 55690658f38SMichael Hamann $form->addElement($display_name); 55737a1dc12Smichael } 55837a1dc12Smichael 55967c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeOpenTag('div')); 56067c8cda1SKate Arzamastseva 561035e07f1SKate Arzamastseva if ($info['sum']) { 56237a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 563e260f93bSAnika Henke if (!$media_id) $form->addElement(' – '); 564d317fb5dSAnika Henke $form->addElement('<bdi>'.htmlspecialchars($info['sum']).'</bdi>'); 56537a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 566035e07f1SKate Arzamastseva } 56737a1dc12Smichael 56837a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 56988f522e9Sandi if($info['user']){ 570d317fb5dSAnika Henke $form->addElement('<bdi>'.editorinfo($info['user']).'</bdi>'); 571433efb25SAndreas Gohr if(auth_ismanager()){ 572d317fb5dSAnika Henke $form->addElement(' <bdo dir="ltr">('.$info['ip'].')</bdo>'); 573433efb25SAndreas Gohr } 57488f522e9Sandi }else{ 575d317fb5dSAnika Henke $form->addElement('<bdo dir="ltr">'.$info['ip'].'</bdo>'); 57688f522e9Sandi } 57737a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 578652610a2Sandi 57967c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeCloseTag('div')); 58067c8cda1SKate Arzamastseva 58137a1dc12Smichael $form->addElement(form_makeCloseTag('div')); 58237a1dc12Smichael $form->addElement(form_makeCloseTag('li')); 583f3f0262cSandi } 58437a1dc12Smichael $form->addElement(form_makeCloseTag('ul')); 5852e55802cSKate Arzamastseva if (!$media_id) { 5862e55802cSKate Arzamastseva $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); 5872e55802cSKate Arzamastseva } else { 5882e55802cSKate Arzamastseva $form->addHidden('mediado', 'diff'); 5892e55802cSKate Arzamastseva $form->addElement(form_makeButton('submit', '', $lang['diff2'])); 5902e55802cSKate Arzamastseva } 59137a1dc12Smichael html_form('revisions', $form); 59271726d78SBen Coburn 59371726d78SBen Coburn print '<div class="pagenav">'; 59471726d78SBen Coburn $last = $first + $conf['recent']; 59571726d78SBen Coburn if ($first > 0) { 59671726d78SBen Coburn $first -= $conf['recent']; 59771726d78SBen Coburn if ($first < 0) $first = 0; 59871726d78SBen Coburn print '<div class="pagenav-prev">'; 5997e6b49bbSKate Arzamastseva if ($media_id) { 600035e07f1SKate Arzamastseva print html_btn('newer',$media_id,"p",media_managerURL(array('first' => $first), '&', false, true)); 6017e6b49bbSKate Arzamastseva } else { 6028e69fd30SKate Arzamastseva print html_btn('newer',$id,"p",array('do' => 'revisions', 'first' => $first)); 6037e6b49bbSKate Arzamastseva } 60471726d78SBen Coburn print '</div>'; 60571726d78SBen Coburn } 60671726d78SBen Coburn if ($hasNext) { 60771726d78SBen Coburn print '<div class="pagenav-next">'; 6087e6b49bbSKate Arzamastseva if ($media_id) { 609035e07f1SKate Arzamastseva print html_btn('older',$media_id,"n",media_managerURL(array('first' => $last), '&', false, true)); 6107e6b49bbSKate Arzamastseva } else { 6118e69fd30SKate Arzamastseva print html_btn('older',$id,"n",array('do' => 'revisions', 'first' => $last)); 6127e6b49bbSKate Arzamastseva } 61371726d78SBen Coburn print '</div>'; 61471726d78SBen Coburn } 61571726d78SBen Coburn print '</div>'; 61671726d78SBen Coburn 617f3f0262cSandi} 618f3f0262cSandi 61915fae107Sandi/** 62015fae107Sandi * display recent changes 62115fae107Sandi * 62215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 6235749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 62471726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 6258d40b4b6SKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 62615fae107Sandi */ 6270739a638SKate Arzamastsevafunction html_recent($first=0, $show_changes='both'){ 628f3f0262cSandi global $conf; 629cffcc403Sandi global $lang; 630dbb00abcSEsther Brunner global $ID; 6315749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 6325749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 6335749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 6345749f1ceSmatthiasgrimm */ 635e5d185e1SKate Arzamastseva $flags = 0; 636e5d185e1SKate Arzamastseva if ($show_changes == 'mediafiles' && $conf['mediarevisions']) { 637b5941dfaSKate Arzamastseva $flags = RECENTS_MEDIA_CHANGES; 638b5941dfaSKate Arzamastseva } elseif ($show_changes == 'pages') { 639b5941dfaSKate Arzamastseva $flags = 0; 640e5d185e1SKate Arzamastseva } elseif ($conf['mediarevisions']) { 641b5941dfaSKate Arzamastseva $show_changes = 'both'; 642b5941dfaSKate Arzamastseva $flags = RECENTS_MEDIA_PAGES_MIXED; 643b5941dfaSKate Arzamastseva } 6448d40b4b6SKate Arzamastseva 6458d40b4b6SKate Arzamastseva $recents = getRecents($first,$conf['recent'] + 1,getNS($ID),$flags); 6465749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0){ 6475749f1ceSmatthiasgrimm $first=0; 6488d40b4b6SKate Arzamastseva $recents = getRecents($first,$conf['recent'] + 1,getNS($ID),$flags); 6495749f1ceSmatthiasgrimm } 65071726d78SBen Coburn $hasNext = false; 65171726d78SBen Coburn if (count($recents)>$conf['recent']) { 65271726d78SBen Coburn $hasNext = true; 65371726d78SBen Coburn array_pop($recents); // remove extra log entry 65471726d78SBen Coburn } 655f3f0262cSandi 656c112d578Sandi print p_locale_xhtml('recent'); 657e83cef14SGina Haeussge 658e83cef14SGina Haeussge if (getNS($ID) != '') 6599e561443SAndreas Gohr print '<div class="level1"><p>' . sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . '</p></div>'; 660e83cef14SGina Haeussge 6610607bfeeSAnika Henke $form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET', 'class' => 'changes')); 662abdcc39fSmichael $form->addHidden('sectok', null); 663abdcc39fSmichael $form->addHidden('do', 'recent'); 664abdcc39fSmichael $form->addHidden('id', $ID); 6658d40b4b6SKate Arzamastseva 666e5d185e1SKate Arzamastseva if ($conf['mediarevisions']) { 6670607bfeeSAnika Henke $form->addElement('<div class="changeType">'); 668b5941dfaSKate Arzamastseva $form->addElement(form_makeListboxField( 669b5941dfaSKate Arzamastseva 'show_changes', 670b5941dfaSKate Arzamastseva array( 671b5941dfaSKate Arzamastseva 'pages' => $lang['pages_changes'], 672b5941dfaSKate Arzamastseva 'mediafiles' => $lang['media_changes'], 673b5941dfaSKate Arzamastseva 'both' => $lang['both_changes']), 674b5941dfaSKate Arzamastseva $show_changes, 675b5941dfaSKate Arzamastseva $lang['changes_type'], 676b5941dfaSKate Arzamastseva '','', 677b5941dfaSKate Arzamastseva array('class'=>'quickselect'))); 678b5941dfaSKate Arzamastseva 679b5941dfaSKate Arzamastseva $form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply'])); 6800607bfeeSAnika Henke $form->addElement('</div>'); 681e5d185e1SKate Arzamastseva } 6828d40b4b6SKate Arzamastseva 683abdcc39fSmichael $form->addElement(form_makeOpenTag('ul')); 684a39955b0Smatthiasgrimm 685d437bcc4SAndreas Gohr foreach($recents as $recent){ 686f2263577SAndreas Gohr $date = dformat($recent['date']); 687abdcc39fSmichael if ($recent['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) 688abdcc39fSmichael $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); 689abdcc39fSmichael else 690abdcc39fSmichael $form->addElement(form_makeOpenTag('li')); 691cffcc403Sandi 692abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 693f9b2fe70Sandi 694421ec38eSKate Arzamastseva if ($recent['media']) { 695421ec38eSKate Arzamastseva $form->addElement(media_printicon($recent['id'])); 696421ec38eSKate Arzamastseva } else { 697421ec38eSKate Arzamastseva $icon = DOKU_BASE.'lib/images/fileicons/file.png'; 6980686da46SMichael Hamann $form->addElement('<img src="'.$icon.'" alt="'.$recent['id'].'" class="icon" />'); 699421ec38eSKate Arzamastseva } 700421ec38eSKate Arzamastseva 701abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 702abdcc39fSmichael $form->addElement($date); 703abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 704cffcc403Sandi 7056d9eab4dSMichael Hamann $diff = false; 7066d9eab4dSMichael Hamann $href = ''; 7076d9eab4dSMichael Hamann 708b5941dfaSKate Arzamastseva if ($recent['media']) { 70992cac9a9SKate Arzamastseva $diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id']))); 71092cac9a9SKate Arzamastseva if ($diff) { 711b5941dfaSKate Arzamastseva $href = media_managerURL(array('tab_details' => 'history', 712421ec38eSKate Arzamastseva 'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&'); 71392cac9a9SKate Arzamastseva } 714b5941dfaSKate Arzamastseva } else { 715b5941dfaSKate Arzamastseva $href = wl($recent['id'],"do=diff", false, '&'); 716b5941dfaSKate Arzamastseva } 71792cac9a9SKate Arzamastseva 71892cac9a9SKate Arzamastseva if ($recent['media'] && !$diff) { 71992cac9a9SKate Arzamastseva $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); 72092cac9a9SKate Arzamastseva } else { 721b5941dfaSKate Arzamastseva $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href))); 722abdcc39fSmichael $form->addElement(form_makeTag('img', array( 723abdcc39fSmichael 'src' => DOKU_BASE.'lib/images/diff.png', 724abdcc39fSmichael 'width' => 15, 725abdcc39fSmichael 'height'=> 11, 726abdcc39fSmichael 'title' => $lang['diff'], 727abdcc39fSmichael 'alt' => $lang['diff'] 728abdcc39fSmichael ))); 729abdcc39fSmichael $form->addElement(form_makeCloseTag('a')); 73092cac9a9SKate Arzamastseva } 731cffcc403Sandi 732b5941dfaSKate Arzamastseva if ($recent['media']) { 733421ec38eSKate Arzamastseva $href = media_managerURL(array('tab_details' => 'history', 734421ec38eSKate Arzamastseva 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&'); 735b5941dfaSKate Arzamastseva } else { 736b5941dfaSKate Arzamastseva $href = wl($recent['id'],"do=revisions",false,'&'); 737b5941dfaSKate Arzamastseva } 738b5941dfaSKate Arzamastseva $form->addElement(form_makeOpenTag('a', array('class' => 'revisions_link', 'href' => $href))); 739abdcc39fSmichael $form->addElement(form_makeTag('img', array( 740abdcc39fSmichael 'src' => DOKU_BASE.'lib/images/history.png', 741abdcc39fSmichael 'width' => 12, 742abdcc39fSmichael 'height'=> 14, 743abdcc39fSmichael 'title' => $lang['btn_revs'], 744abdcc39fSmichael 'alt' => $lang['btn_revs'] 745abdcc39fSmichael ))); 746abdcc39fSmichael $form->addElement(form_makeCloseTag('a')); 747b6912aeaSAndreas Gohr 748b5941dfaSKate Arzamastseva if ($recent['media']) { 749421ec38eSKate Arzamastseva $href = media_managerURL(array('tab_details' => 'view', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&'); 750035e07f1SKate Arzamastseva $class = (file_exists(mediaFN($recent['id']))) ? 'wikilink1' : $class = 'wikilink2'; 751035e07f1SKate Arzamastseva $form->addElement(form_makeOpenTag('a', array('class' => $class, 'href' => $href))); 752b5941dfaSKate Arzamastseva $form->addElement($recent['id']); 753b5941dfaSKate Arzamastseva $form->addElement(form_makeCloseTag('a')); 754b5941dfaSKate Arzamastseva } else { 755b5941dfaSKate Arzamastseva $form->addElement(html_wikilink(':'.$recent['id'],useHeading('navigation')?null:$recent['id'])); 756b5941dfaSKate Arzamastseva } 757abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 758e260f93bSAnika Henke $form->addElement(' – '.htmlspecialchars($recent['sum'])); 759abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 760abdcc39fSmichael 761abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 762d437bcc4SAndreas Gohr if($recent['user']){ 763d317fb5dSAnika Henke $form->addElement('<bdi>'.editorinfo($recent['user']).'</bdi>'); 764433efb25SAndreas Gohr if(auth_ismanager()){ 765d317fb5dSAnika Henke $form->addElement(' <bdo dir="ltr">('.$recent['ip'].')</bdo>'); 766433efb25SAndreas Gohr } 76788f522e9Sandi }else{ 768d317fb5dSAnika Henke $form->addElement('<bdo dir="ltr">'.$recent['ip'].'</bdo>'); 76988f522e9Sandi } 770abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 771cffcc403Sandi 772abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 773abdcc39fSmichael $form->addElement(form_makeCloseTag('li')); 774f3f0262cSandi } 775abdcc39fSmichael $form->addElement(form_makeCloseTag('ul')); 776a39955b0Smatthiasgrimm 777abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav'))); 7785749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 779a39955b0Smatthiasgrimm if ($first > 0) { 780a39955b0Smatthiasgrimm $first -= $conf['recent']; 781a39955b0Smatthiasgrimm if ($first < 0) $first = 0; 782abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev'))); 783abdcc39fSmichael $form->addElement(form_makeTag('input', array( 784abdcc39fSmichael 'type' => 'submit', 785abdcc39fSmichael 'name' => 'first['.$first.']', 786cddd152cSmichael 'value' => $lang['btn_newer'], 787cddd152cSmichael 'accesskey' => 'n', 788f948eeabSMichael Klier 'title' => $lang['btn_newer'].' [N]', 789d5daba10SKate Arzamastseva 'class' => 'button show' 790abdcc39fSmichael ))); 791abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 792a39955b0Smatthiasgrimm } 79371726d78SBen Coburn if ($hasNext) { 794abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next'))); 795abdcc39fSmichael $form->addElement(form_makeTag('input', array( 796abdcc39fSmichael 'type' => 'submit', 797abdcc39fSmichael 'name' => 'first['.$last.']', 798cddd152cSmichael 'value' => $lang['btn_older'], 799cddd152cSmichael 'accesskey' => 'p', 800f948eeabSMichael Klier 'title' => $lang['btn_older'].' [P]', 801d5daba10SKate Arzamastseva 'class' => 'button show' 802abdcc39fSmichael ))); 803abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 804a39955b0Smatthiasgrimm } 805abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 806abdcc39fSmichael html_form('recent', $form); 807f3f0262cSandi} 808f3f0262cSandi 80915fae107Sandi/** 81015fae107Sandi * Display page index 81115fae107Sandi * 81215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 81315fae107Sandi */ 814f3f0262cSandifunction html_index($ns){ 815f3f0262cSandi global $conf; 816f3f0262cSandi global $ID; 817f3f0262cSandi $ns = cleanID($ns); 81830f1737dSandi #fixme use appropriate function 819f3f0262cSandi if(empty($ns)){ 820f3f0262cSandi $ns = dirname(str_replace(':','/',$ID)); 821f3f0262cSandi if($ns == '.') $ns =''; 822f3f0262cSandi } 82388d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 824f3f0262cSandi 825a06884abSAndreas Gohr echo p_locale_xhtml('index'); 826a06884abSAndreas Gohr echo '<div id="index__tree">'; 827f3f0262cSandi 828f3f0262cSandi $data = array(); 829f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 830a06884abSAndreas Gohr echo html_buildlist($data,'idx','html_list_index','html_li_index'); 831a06884abSAndreas Gohr 832a06884abSAndreas Gohr echo '</div>'; 833f3f0262cSandi} 834f3f0262cSandi 835f3f0262cSandi/** 83615fae107Sandi * Index item formatter 83715fae107Sandi * 838f3f0262cSandi * User function for html_buildlist() 83915fae107Sandi * 84015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 841f3f0262cSandi */ 842f3f0262cSandifunction html_list_index($item){ 84374ef1778SChristopher Smith global $ID, $conf; 84474ef1778SChristopher Smith 845b8bc53ceSChristopher Smith // prevent searchbots needlessly following links 84674ef1778SChristopher Smith $nofollow = ($ID != $conf['start'] || $conf['sitemap']) ? ' rel="nofollow"' : ''; 84774ef1778SChristopher Smith 848f3f0262cSandi $ret = ''; 849f3f0262cSandi $base = ':'.$item['id']; 850f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 851f3f0262cSandi if($item['type']=='d'){ 852b1af9014SChristopher Smith // FS#2766, no need for search bots to follow namespace links in the index 85374ef1778SChristopher Smith $ret .= '<a href="'.wl($ID,'idx='.rawurlencode($item['id'])).'" title="' . $item['id'] . '" class="idx_dir"' . $nofollow . '><strong>'; 854f3f0262cSandi $ret .= $base; 855ed7ecb79SAnika Henke $ret .= '</strong></a>'; 856f3f0262cSandi }else{ 8579aa38483SMichael Hamann // default is noNSorNS($id), but we want noNS($id) when useheading is off FS#2605 8589aa38483SMichael Hamann $ret .= html_wikilink(':'.$item['id'], useHeading('navigation') ? null : noNS($item['id'])); 859f3f0262cSandi } 860f3f0262cSandi return $ret; 861f3f0262cSandi} 862f3f0262cSandi 863f3f0262cSandi/** 864cb70c441Sandi * Index List item 865cb70c441Sandi * 866a1dee2b9SAdrian Lang * This user function is used in html_buildlist to build the 867cb70c441Sandi * <li> tags for namespaces when displaying the page index 868cb70c441Sandi * it gives different classes to opened or closed "folders" 869cb70c441Sandi * 870cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 871cb70c441Sandi */ 872cb70c441Sandifunction html_li_index($item){ 873cb70c441Sandi if($item['type'] == "f"){ 874cb70c441Sandi return '<li class="level'.$item['level'].'">'; 875cb70c441Sandi }elseif($item['open']){ 876cb70c441Sandi return '<li class="open">'; 877cb70c441Sandi }else{ 878cb70c441Sandi return '<li class="closed">'; 879cb70c441Sandi } 880cb70c441Sandi} 881cb70c441Sandi 882cb70c441Sandi/** 883cb70c441Sandi * Default List item 884cb70c441Sandi * 885cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 886cb70c441Sandi */ 887cb70c441Sandifunction html_li_default($item){ 888cb70c441Sandi return '<li class="level'.$item['level'].'">'; 889cb70c441Sandi} 890cb70c441Sandi 891cb70c441Sandi/** 89215fae107Sandi * Build an unordered list 89315fae107Sandi * 894f3f0262cSandi * Build an unordered list from the given $data array 895f3f0262cSandi * Each item in the array has to have a 'level' property 896f3f0262cSandi * the item itself gets printed by the given $func user 897cb70c441Sandi * function. The second and optional function is used to 898cb70c441Sandi * print the <li> tag. Both user function need to accept 899cb70c441Sandi * a single item. 90015fae107Sandi * 901c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to 902c5a8fd96SAndreas Gohr * a member of an object. 903c5a8fd96SAndreas Gohr * 90415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 905f3f0262cSandi */ 90687671313SHakan Sandellfunction html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapper=false){ 907a1dee2b9SAdrian Lang if (count($data) === 0) { 908a1dee2b9SAdrian Lang return ''; 909a1dee2b9SAdrian Lang } 910a1dee2b9SAdrian Lang 9119e4f7880SAdrian Lang $start_level = $data[0]['level']; 9129e4f7880SAdrian Lang $level = $start_level; 913434f5921SHakan Sandell $ret = ''; 914434f5921SHakan Sandell $open = 0; 9159e4f7880SAdrian Lang 916f3f0262cSandi foreach ($data as $item){ 917f3f0262cSandi 918f3f0262cSandi if( $item['level'] > $level ){ 919f3f0262cSandi //open new list 920df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 921434f5921SHakan Sandell if ($i) $ret .= "<li class=\"clear\">"; 922f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 923434f5921SHakan Sandell $open++; 924df52d0feSandi } 925434f5921SHakan Sandell $level = $item['level']; 926434f5921SHakan Sandell 927f3f0262cSandi }elseif( $item['level'] < $level ){ 928f3f0262cSandi //close last item 929f3f0262cSandi $ret .= "</li>\n"; 930434f5921SHakan Sandell while( $level > $item['level'] && $open > 0 ){ 931f3f0262cSandi //close higher lists 932f3f0262cSandi $ret .= "</ul>\n</li>\n"; 933434f5921SHakan Sandell $level--; 934434f5921SHakan Sandell $open--; 935f3f0262cSandi } 936a1dee2b9SAdrian Lang } elseif ($ret !== '') { 93787671313SHakan Sandell //close previous item 938f3f0262cSandi $ret .= "</li>\n"; 939f3f0262cSandi } 940f3f0262cSandi 941f3f0262cSandi //print item 94234dbe711Schris $ret .= call_user_func($lifunc,$item); 9430c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 94434dbe711Schris 94534dbe711Schris $ret .= call_user_func($func,$item); 9460c6b58a8SAndreas Gohr $ret .= '</div>'; 947f3f0262cSandi } 948f3f0262cSandi 949f3f0262cSandi //close remaining items and lists 950434f5921SHakan Sandell $ret .= "</li>\n"; 951434f5921SHakan Sandell while($open-- > 0) { 952434f5921SHakan Sandell $ret .= "</ul></li>\n"; 953434f5921SHakan Sandell } 954434f5921SHakan Sandell 955434f5921SHakan Sandell if ($forcewrapper || $start_level < 2) { 956434f5921SHakan Sandell // Trigger building a wrapper ul if the first level is 957434f5921SHakan Sandell // 0 (we have a root object) or 1 (just the root content) 958434f5921SHakan Sandell $ret = "\n<ul class=\"$class\">\n".$ret."</ul>\n"; 959f3f0262cSandi } 960f3f0262cSandi 961f3f0262cSandi return $ret; 962f3f0262cSandi} 963f3f0262cSandi 96415fae107Sandi/** 96515fae107Sandi * display backlinks 96615fae107Sandi * 96715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 96811df47ecSMichael Klier * @author Michael Klier <chi@chimeric.de> 96915fae107Sandi */ 970f3f0262cSandifunction html_backlinks(){ 971f3f0262cSandi global $ID; 97211df47ecSMichael Klier global $lang; 973f3f0262cSandi 974c112d578Sandi print p_locale_xhtml('backlinks'); 975f3f0262cSandi 97654f4c056SAndreas Gohr $data = ft_backlinks($ID); 977f3f0262cSandi 97811df47ecSMichael Klier if(!empty($data)) { 979f3f0262cSandi print '<ul class="idx">'; 98054f4c056SAndreas Gohr foreach($data as $blink){ 9810c6b58a8SAndreas Gohr print '<li><div class="li">'; 982db959ae3SAndreas Gohr print html_wikilink(':'.$blink,useHeading('navigation')?null:$blink); 9830c6b58a8SAndreas Gohr print '</div></li>'; 984f3f0262cSandi } 985f3f0262cSandi print '</ul>'; 98611df47ecSMichael Klier } else { 98711df47ecSMichael Klier print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>'; 98811df47ecSMichael Klier } 989f3f0262cSandi} 990f3f0262cSandi 9918d5e837eSMichael Hamann/** 9928d5e837eSMichael Hamann * Get header of diff HTML 9938d5e837eSMichael Hamann * @param string $l_rev Left revisions 9948d5e837eSMichael Hamann * @param string $r_rev Right revision 9958d5e837eSMichael Hamann * @param string $id Page id, if null $ID is used 9968d5e837eSMichael Hamann * @param bool $media If it is for media files 997f76724a4STom N Harris * @param bool $inline Return the header on a single line 9988d5e837eSMichael Hamann * @return array HTML snippets for diff header 9998d5e837eSMichael Hamann */ 1000f76724a4STom N Harrisfunction html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false) { 100195b451bcSAdrian Lang global $lang; 100295b451bcSAdrian Lang if ($id === null) { 100395b451bcSAdrian Lang global $ID; 100495b451bcSAdrian Lang $id = $ID; 100595b451bcSAdrian Lang } 1006f76724a4STom N Harris $head_separator = $inline ? ' ' : '<br />'; 100795b451bcSAdrian Lang $media_or_wikiFN = $media ? 'mediaFN' : 'wikiFN'; 100895b451bcSAdrian Lang $ml_or_wl = $media ? 'ml' : 'wl'; 100995b451bcSAdrian Lang $l_minor = $r_minor = ''; 101095b451bcSAdrian Lang 101195b451bcSAdrian Lang if(!$l_rev){ 101295b451bcSAdrian Lang $l_head = '—'; 101395b451bcSAdrian Lang }else{ 101495b451bcSAdrian Lang $l_info = getRevisionInfo($id,$l_rev,true, $media); 101595b451bcSAdrian Lang if($l_info['user']){ 1016d317fb5dSAnika Henke $l_user = '<bdi>'.editorinfo($l_info['user']).'</bdi>'; 1017d317fb5dSAnika Henke if(auth_ismanager()) $l_user .= ' <bdo dir="ltr">('.$l_info['ip'].')</bdo>'; 101895b451bcSAdrian Lang } else { 1019d317fb5dSAnika Henke $l_user = '<bdo dir="ltr">'.$l_info['ip'].'</bdo>'; 102095b451bcSAdrian Lang } 102195b451bcSAdrian Lang $l_user = '<span class="user">'.$l_user.'</span>'; 1022d317fb5dSAnika Henke $l_sum = ($l_info['sum']) ? '<span class="sum"><bdi>'.hsc($l_info['sum']).'</bdi></span>' : ''; 102395b451bcSAdrian Lang if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $l_minor = 'class="minor"'; 102495b451bcSAdrian Lang 1025699c5072SAnika Henke $l_head_title = ($media) ? dformat($l_rev) : $id.' ['.dformat($l_rev).']'; 1026d317fb5dSAnika Henke $l_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id,"rev=$l_rev").'">'. 1027d317fb5dSAnika Henke $l_head_title.'</a></bdi>'. 1028f76724a4STom N Harris $head_separator.$l_user.' '.$l_sum; 102995b451bcSAdrian Lang } 103095b451bcSAdrian Lang 103195b451bcSAdrian Lang if($r_rev){ 103295b451bcSAdrian Lang $r_info = getRevisionInfo($id,$r_rev,true, $media); 103395b451bcSAdrian Lang if($r_info['user']){ 1034d317fb5dSAnika Henke $r_user = '<bdi>'.editorinfo($r_info['user']).'</bdi>'; 1035d317fb5dSAnika Henke if(auth_ismanager()) $r_user .= ' <bdo dir="ltr">('.$r_info['ip'].')</bdo>'; 103695b451bcSAdrian Lang } else { 1037d317fb5dSAnika Henke $r_user = '<bdo dir="ltr">'.$r_info['ip'].'</bdo>'; 103895b451bcSAdrian Lang } 103995b451bcSAdrian Lang $r_user = '<span class="user">'.$r_user.'</span>'; 1040d317fb5dSAnika Henke $r_sum = ($r_info['sum']) ? '<span class="sum"><bdi>'.hsc($r_info['sum']).'</bdi></span>' : ''; 104195b451bcSAdrian Lang if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; 104295b451bcSAdrian Lang 1043699c5072SAnika Henke $r_head_title = ($media) ? dformat($r_rev) : $id.' ['.dformat($r_rev).']'; 1044d317fb5dSAnika Henke $r_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id,"rev=$r_rev").'">'. 1045d317fb5dSAnika Henke $r_head_title.'</a></bdi>'. 1046f76724a4STom N Harris $head_separator.$r_user.' '.$r_sum; 104795b451bcSAdrian Lang }elseif($_rev = @filemtime($media_or_wikiFN($id))){ 104895b451bcSAdrian Lang $_info = getRevisionInfo($id,$_rev,true, $media); 104995b451bcSAdrian Lang if($_info['user']){ 1050d317fb5dSAnika Henke $_user = '<bdi>'.editorinfo($_info['user']).'</bdi>'; 1051d317fb5dSAnika Henke if(auth_ismanager()) $_user .= ' <bdo dir="ltr">('.$_info['ip'].')</bdo>'; 105295b451bcSAdrian Lang } else { 1053d317fb5dSAnika Henke $_user = '<bdo dir="ltr">'.$_info['ip'].'</bdo>'; 105495b451bcSAdrian Lang } 105595b451bcSAdrian Lang $_user = '<span class="user">'.$_user.'</span>'; 1056d317fb5dSAnika Henke $_sum = ($_info['sum']) ? '<span class="sum"><bdi>'.hsc($_info['sum']).'</span></bdi>' : ''; 105795b451bcSAdrian Lang if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; 105895b451bcSAdrian Lang 1059699c5072SAnika Henke $r_head_title = ($media) ? dformat($_rev) : $id.' ['.dformat($_rev).']'; 1060d317fb5dSAnika Henke $r_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id).'">'. 1061d317fb5dSAnika Henke $r_head_title.'</a></bdi> '. 106295b451bcSAdrian Lang '('.$lang['current'].')'. 1063f76724a4STom N Harris $head_separator.$_user.' '.$_sum; 106495b451bcSAdrian Lang }else{ 106595b451bcSAdrian Lang $r_head = '— ('.$lang['current'].')'; 106695b451bcSAdrian Lang } 106795b451bcSAdrian Lang 106895b451bcSAdrian Lang return array($l_head, $r_head, $l_minor, $r_minor); 106995b451bcSAdrian Lang} 107095b451bcSAdrian Lang 107115fae107Sandi/** 107215fae107Sandi * show diff 107315fae107Sandi * 107415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 107572165381SAndreas Gohr * @param string $text - compare with this text with most current version 10768d5e837eSMichael Hamann * @param bool $intro - display the intro text 10778d5e837eSMichael Hamann * @param string $type type of the diff (inline or sidebyside) 107815fae107Sandi */ 107972165381SAndreas Gohrfunction html_diff($text='',$intro=true,$type=null){ 1080f3f0262cSandi global $ID; 1081f3f0262cSandi global $REV; 1082f3f0262cSandi global $lang; 1083f0859d4bSTom N Harris global $INPUT; 10843c94d07bSAnika Henke global $INFO; 1085e1bd90ffSAndreas Gohr 10863c94d07bSAnika Henke if(!$type) { 10873c94d07bSAnika Henke $type = $INPUT->str('difftype'); 10883c94d07bSAnika Henke if (empty($type)) { 10893c94d07bSAnika Henke $type = get_doku_pref('difftype', $type); 10903c94d07bSAnika Henke if (empty($type) && $INFO['ismobile']) { 10913c94d07bSAnika Henke $type = 'inline'; 10923c94d07bSAnika Henke } 10933c94d07bSAnika Henke } 10943c94d07bSAnika Henke } 109572165381SAndreas Gohr if($type != 'inline') $type = 'sidebyside'; 109672165381SAndreas Gohr 109777707b04SAndreas Gohr // we're trying to be clever here, revisions to compare can be either 109877707b04SAndreas Gohr // given as rev and rev2 parameters, with rev2 being optional. Or in an 109977707b04SAndreas Gohr // array in rev2. 110077707b04SAndreas Gohr $rev1 = $REV; 11017b3f8b16SAndreas Gohr 1102f1d7655bSAndreas Gohr $rev2 = $INPUT->ref('rev2'); 1103f1d7655bSAndreas Gohr if(is_array($rev2)){ 1104f1d7655bSAndreas Gohr $rev1 = (int) $rev2[0]; 1105f1d7655bSAndreas Gohr $rev2 = (int) $rev2[1]; 110654041c77SAndreas Gohr 110754041c77SAndreas Gohr if(!$rev1){ 110854041c77SAndreas Gohr $rev1 = $rev2; 110954041c77SAndreas Gohr unset($rev2); 111054041c77SAndreas Gohr } 1111f3f0262cSandi }else{ 1112f0859d4bSTom N Harris $rev2 = $INPUT->int('rev2'); 11134d58bd99Sandi } 11144d58bd99Sandi 11153733161eSAdrian Lang $r_minor = ''; 11163733161eSAdrian Lang $l_minor = ''; 11173733161eSAdrian Lang 111877707b04SAndreas Gohr if($text){ // compare text to the most current revision 111977707b04SAndreas Gohr $l_rev = ''; 112077707b04SAndreas Gohr $l_text = rawWiki($ID,''); 112177707b04SAndreas Gohr $l_head = '<a class="wikilink1" href="'.wl($ID).'">'. 1122f2263577SAndreas Gohr $ID.' '.dformat((int) @filemtime(wikiFN($ID))).'</a> '. 112377707b04SAndreas Gohr $lang['current']; 112477707b04SAndreas Gohr 112577707b04SAndreas Gohr $r_rev = ''; 112677707b04SAndreas Gohr $r_text = cleanText($text); 112777707b04SAndreas Gohr $r_head = $lang['yours']; 1128e1bd90ffSAndreas Gohr }else{ 11296d9eab4dSMichael Hamann if($rev1 && isset($rev2) && $rev2){ // two specific revisions wanted 113054041c77SAndreas Gohr // make sure order is correct (older on the left) 113177707b04SAndreas Gohr if($rev1 < $rev2){ 113277707b04SAndreas Gohr $l_rev = $rev1; 113377707b04SAndreas Gohr $r_rev = $rev2; 113477707b04SAndreas Gohr }else{ 113577707b04SAndreas Gohr $l_rev = $rev2; 113677707b04SAndreas Gohr $r_rev = $rev1; 1137e1bd90ffSAndreas Gohr } 113877707b04SAndreas Gohr }elseif($rev1){ // single revision given, compare to current 113977707b04SAndreas Gohr $r_rev = ''; 114077707b04SAndreas Gohr $l_rev = $rev1; 114177707b04SAndreas Gohr }else{ // no revision was given, compare previous to current 114277707b04SAndreas Gohr $r_rev = ''; 114377707b04SAndreas Gohr $revs = getRevisions($ID, 0, 1); 114477707b04SAndreas Gohr $l_rev = $revs[0]; 11456f8e9f59SAndreas Gohr $REV = $l_rev; // store revision back in $REV 114677707b04SAndreas Gohr } 114777707b04SAndreas Gohr 11487b3f8b16SAndreas Gohr // when both revisions are empty then the page was created just now 11497b3f8b16SAndreas Gohr if(!$l_rev && !$r_rev){ 11507b3f8b16SAndreas Gohr $l_text = ''; 11517b3f8b16SAndreas Gohr }else{ 115277707b04SAndreas Gohr $l_text = rawWiki($ID,$l_rev); 11537b3f8b16SAndreas Gohr } 115477707b04SAndreas Gohr $r_text = rawWiki($ID,$r_rev); 115577707b04SAndreas Gohr 1156f76724a4STom N Harris list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline'); 115777707b04SAndreas Gohr } 115877707b04SAndreas Gohr 115907a7d21aSChristopher Smith $df = new Diff(explode("\n",$l_text),explode("\n",$r_text)); 116077707b04SAndreas Gohr 116172165381SAndreas Gohr if($type == 'inline'){ 116272165381SAndreas Gohr $tdf = new InlineDiffFormatter(); 116372165381SAndreas Gohr } else { 1164f3f0262cSandi $tdf = new TableDiffFormatter(); 116572165381SAndreas Gohr } 116672165381SAndreas Gohr 1167c112d578Sandi if($intro) print p_locale_xhtml('diff'); 1168226bf2dcSGina Haeussge 1169226bf2dcSGina Haeussge if (!$text) { 1170e8af313fSAnika Henke ptln('<div class="diffoptions">'); 117172165381SAndreas Gohr 117272165381SAndreas Gohr $form = new Doku_Form(array('action'=>wl())); 11731b885c58SAndreas Gohr $form->addHidden('id',$ID); 117472165381SAndreas Gohr $form->addHidden('rev2[0]',$l_rev); 117572165381SAndreas Gohr $form->addHidden('rev2[1]',$r_rev); 117672165381SAndreas Gohr $form->addHidden('do','diff'); 117772165381SAndreas Gohr $form->addElement(form_makeListboxField( 117872165381SAndreas Gohr 'difftype', 117972165381SAndreas Gohr array( 118072165381SAndreas Gohr 'sidebyside' => $lang['diff_side'], 118172165381SAndreas Gohr 'inline' => $lang['diff_inline']), 118272165381SAndreas Gohr $type, 118372165381SAndreas Gohr $lang['diff_type'], 118472165381SAndreas Gohr '','', 118572165381SAndreas Gohr array('class'=>'quickselect'))); 118672165381SAndreas Gohr $form->addElement(form_makeButton('submit', 'diff','Go')); 118772165381SAndreas Gohr $form->printForm(); 118872165381SAndreas Gohr 118972165381SAndreas Gohr $diffurl = wl($ID, array( 119072165381SAndreas Gohr 'do' => 'diff', 119172165381SAndreas Gohr 'rev2[0]' => $l_rev, 119272165381SAndreas Gohr 'rev2[1]' => $r_rev, 119372165381SAndreas Gohr 'difftype' => $type, 119472165381SAndreas Gohr )); 1195e8af313fSAnika Henke ptln('<p><a class="wikilink1" href="'.$diffurl.'">'.$lang['difflink'].'</a></p>'); 1196e8af313fSAnika Henke ptln('</div>'); 1197226bf2dcSGina Haeussge } 1198f3f0262cSandi ?> 1199c7b28ffdSAnika Henke <div class="table"> 120072165381SAndreas Gohr <table class="diff diff_<?php echo $type?>"> 1201f76724a4STom N Harris <?php if ($type == 'inline') { ?> 1202f76724a4STom N Harris <tr> 120356133a04STom N Harris <th class="diff-lineheader">-</th><th <?php echo $l_minor?>> 1204f76724a4STom N Harris <?php echo $l_head?> 1205f76724a4STom N Harris </th> 1206f76724a4STom N Harris </tr> 1207f76724a4STom N Harris <tr> 120856133a04STom N Harris <th class="diff-lineheader">+</th><th <?php echo $r_minor?>> 1209f76724a4STom N Harris <?php echo $r_head?> 1210f76724a4STom N Harris </th> 1211f76724a4STom N Harris </tr> 1212f76724a4STom N Harris <?php } else { ?> 1213f3f0262cSandi <tr> 1214e5e61eb0SAnika Henke <th colspan="2" <?php echo $l_minor?>> 121577707b04SAndreas Gohr <?php echo $l_head?> 1216daf4ca4eSAnika Henke </th> 1217e5e61eb0SAnika Henke <th colspan="2" <?php echo $r_minor?>> 121877707b04SAndreas Gohr <?php echo $r_head?> 1219daf4ca4eSAnika Henke </th> 1220f3f0262cSandi </tr> 1221f76724a4STom N Harris <?php } 1222f76724a4STom N Harris echo html_insert_softbreaks($tdf->format($df)); ?> 1223f3f0262cSandi </table> 1224c7b28ffdSAnika Henke </div> 12254da078a3Smatthiasgrimm <?php 1226f3f0262cSandi} 1227f3f0262cSandi 1228fcfecb69SChristopher Smithfunction html_insert_softbreaks($diffhtml) { 1229fcfecb69SChristopher Smith // search the diff html string for both: 1230fcfecb69SChristopher Smith // - html tags, so these can be ignored 1231fcfecb69SChristopher Smith // - long strings of characters without breaking characters 1232fcfecb69SChristopher Smith return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/','html_softbreak_callback',$diffhtml); 1233fcfecb69SChristopher Smith} 1234fcfecb69SChristopher Smith 1235fcfecb69SChristopher Smithfunction html_softbreak_callback($match){ 1236fcfecb69SChristopher Smith // if match is an html tag, return it intact 1237fcfecb69SChristopher Smith if ($match[0]{0} == '<') return $match[0]; 1238fcfecb69SChristopher Smith 1239fcfecb69SChristopher Smith // its a long string without a breaking character, 1240fcfecb69SChristopher Smith // make certain characters into breaking characters by inserting a 1241fcfecb69SChristopher Smith // breaking character (zero length space, U+200B / #8203) in front them. 1242fcfecb69SChristopher Smith $regex = <<< REGEX 1243fcfecb69SChristopher Smith(?(?= # start a conditional expression with a positive look ahead ... 1244298a7e08SChristopher Smith&\#?\\w{1,6};) # ... for html entities - we don't want to split them (ok to catch some invalid combinations) 1245298a7e08SChristopher Smith&\#?\\w{1,6}; # yes pattern - a quicker match for the html entity, since we know we have one 1246fcfecb69SChristopher Smith| 124707a7d21aSChristopher Smith[?/,&\#;:] # no pattern - any other group of 'special' characters to insert a breaking character after 124807a7d21aSChristopher Smith)+ # end conditional expression 1249fcfecb69SChristopher SmithREGEX; 1250fcfecb69SChristopher Smith 1251fcfecb69SChristopher Smith return preg_replace('<'.$regex.'>xu','\0​',$match[0]); 1252fcfecb69SChristopher Smith} 1253fcfecb69SChristopher Smith 125415fae107Sandi/** 125515fae107Sandi * show warning on conflict detection 125615fae107Sandi * 125715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 125815fae107Sandi */ 1259f3f0262cSandifunction html_conflict($text,$summary){ 1260f3f0262cSandi global $ID; 1261f3f0262cSandi global $lang; 1262f3f0262cSandi 1263c112d578Sandi print p_locale_xhtml('conflict'); 1264e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 1265fdb8d77bSTom N Harris $form->addHidden('id', $ID); 1266fdb8d77bSTom N Harris $form->addHidden('wikitext', $text); 1267fdb8d77bSTom N Harris $form->addHidden('summary', $summary); 1268fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s'))); 1269fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'])); 1270fdb8d77bSTom N Harris html_form('conflict', $form); 1271fdb8d77bSTom N Harris print '<br /><br /><br /><br />'.NL; 1272f3f0262cSandi} 1273f3f0262cSandi 1274f3f0262cSandi/** 127515fae107Sandi * Prints the global message array 127615fae107Sandi * 127715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1278f3f0262cSandi */ 1279f3f0262cSandifunction html_msgarea(){ 1280cc58224cSMichael Hamann global $MSG, $MSG_shown; 12818d5e837eSMichael Hamann /** @var array $MSG */ 1282cc58224cSMichael Hamann // store if the global $MSG has already been shown and thus HTML output has been started 1283cc58224cSMichael Hamann $MSG_shown = true; 1284cc58224cSMichael Hamann 1285f3f0262cSandi if(!isset($MSG)) return; 1286f3f0262cSandi 12874af9f0d4SAndreas Gohr $shown = array(); 1288f3f0262cSandi foreach($MSG as $msg){ 12894af9f0d4SAndreas Gohr $hash = md5($msg['msg']); 12904af9f0d4SAndreas Gohr if(isset($shown[$hash])) continue; // skip double messages 1291f755f9abSChristopher Smith if(info_msg_allowed($msg)){ 1292f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 1293f3f0262cSandi print $msg['msg']; 1294f3f0262cSandi print '</div>'; 1295d3bae478SChristopher Smith } 12964af9f0d4SAndreas Gohr $shown[$hash] = 1; 1297f3f0262cSandi } 1298cc58224cSMichael Hamann 1299cc58224cSMichael Hamann unset($GLOBALS['MSG']); 1300f3f0262cSandi} 1301f3f0262cSandi 1302f3f0262cSandi/** 1303f3f0262cSandi * Prints the registration form 130415fae107Sandi * 130515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1306f3f0262cSandi */ 1307f3f0262cSandifunction html_register(){ 1308f3f0262cSandi global $lang; 1309cab2716aSmatthias.grimm global $conf; 1310f0859d4bSTom N Harris global $INPUT; 1311f3f0262cSandi 1312a669bfe0SChristopher Smith $base_attrs = array('size'=>50,'required'=>'required'); 1313a669bfe0SChristopher Smith $email_attrs = $base_attrs + array('type'=>'email','class'=>'edit'); 1314a669bfe0SChristopher Smith 1315c112d578Sandi print p_locale_xhtml('register'); 1316fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 1317e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__register')); 1318bf413a4eSAnika Henke $form->startFieldset($lang['btn_register']); 1319fdb8d77bSTom N Harris $form->addHidden('do', 'register'); 1320fdb8d77bSTom N Harris $form->addHidden('save', '1'); 1321a669bfe0SChristopher Smith $form->addElement(form_makeTextField('login', $INPUT->post->str('login'), $lang['user'], '', 'block', $base_attrs)); 1322cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 1323a669bfe0SChristopher Smith $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', $base_attrs)); 1324a669bfe0SChristopher Smith $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', $base_attrs)); 1325cab2716aSmatthias.grimm } 1326a669bfe0SChristopher Smith $form->addElement(form_makeTextField('fullname', $INPUT->post->str('fullname'), $lang['fullname'], '', 'block', $base_attrs)); 1327a669bfe0SChristopher Smith $form->addElement(form_makeField('email','email', $INPUT->post->str('email'), $lang['email'], '', 'block', $email_attrs)); 1328bf413a4eSAnika Henke $form->addElement(form_makeButton('submit', '', $lang['btn_register'])); 1329fdb8d77bSTom N Harris $form->endFieldset(); 1330fdb8d77bSTom N Harris html_form('register', $form); 1331cab2716aSmatthias.grimm 1332fdb8d77bSTom N Harris print '</div>'.NL; 1333f3f0262cSandi} 1334f3f0262cSandi 1335f3f0262cSandi/** 13368b06d178Schris * Print the update profile form 13378b06d178Schris * 13388b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 13398b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 13408b06d178Schris */ 13418b06d178Schrisfunction html_updateprofile(){ 13428b06d178Schris global $lang; 13438b06d178Schris global $conf; 1344f0859d4bSTom N Harris global $INPUT; 13458b06d178Schris global $INFO; 13468d5e837eSMichael Hamann /** @var auth_basic $auth */ 134782fd59b6SAndreas Gohr global $auth; 13488b06d178Schris 13498b06d178Schris print p_locale_xhtml('updateprofile'); 13503b1338ffSChristopher Smith print '<div class="centeralign">'.NL; 13518b06d178Schris 1352f0859d4bSTom N Harris $fullname = $INPUT->post->str('fullname', $INFO['userinfo']['name'], true); 1353f0859d4bSTom N Harris $email = $INPUT->post->str('email', $INFO['userinfo']['mail'], true); 1354e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__register')); 1355fdb8d77bSTom N Harris $form->startFieldset($lang['profile']); 1356fdb8d77bSTom N Harris $form->addHidden('do', 'profile'); 1357fdb8d77bSTom N Harris $form->addHidden('save', '1'); 1358f0859d4bSTom N Harris $form->addElement(form_makeTextField('login', $_SERVER['REMOTE_USER'], $lang['user'], '', 'block', array('size'=>'50', 'disabled'=>'disabled'))); 1359fdb8d77bSTom N Harris $attr = array('size'=>'50'); 1360fdb8d77bSTom N Harris if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; 1361f0859d4bSTom N Harris $form->addElement(form_makeTextField('fullname', $fullname, $lang['fullname'], '', 'block', $attr)); 13623b1338ffSChristopher Smith $attr = array('size'=>'50', 'class'=>'edit'); 136339ba8890SAndreas Gohr if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled'; 13643b1338ffSChristopher Smith $form->addElement(form_makeField('email','email', $email, $lang['email'], '', 'block', $attr)); 1365fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1366fdb8d77bSTom N Harris if ($auth->canDo('modPass')) { 1367fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50'))); 1368fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1369fdb8d77bSTom N Harris } 1370fdb8d77bSTom N Harris if ($conf['profileconfirm']) { 1371fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 13723b1338ffSChristopher Smith $form->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50', 'required' => 'required'))); 1373fdb8d77bSTom N Harris } 1374fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_save'])); 1375fdb8d77bSTom N Harris $form->addElement(form_makeButton('reset', '', $lang['btn_reset'])); 13763b1338ffSChristopher Smith 1377fdb8d77bSTom N Harris $form->endFieldset(); 1378fdb8d77bSTom N Harris html_form('updateprofile', $form); 13792a7abf2dSChristopher Smith 13802a7abf2dSChristopher Smith if ($auth->canDo('delUser') && actionOK('profile_delete')) { 13812a7abf2dSChristopher Smith $form_profiledelete = new Doku_Form(array('id' => 'dw__profiledelete')); 13822a7abf2dSChristopher Smith $form_profiledelete->startFieldset($lang['profdeleteuser']); 13832a7abf2dSChristopher Smith $form_profiledelete->addHidden('do', 'profile_delete'); 13842a7abf2dSChristopher Smith $form_profiledelete->addHidden('delete', '1'); 13852a7abf2dSChristopher Smith $form_profiledelete->addElement(form_makeCheckboxField('confirm_delete', '1', $lang['profconfdelete'],'dw__confirmdelete','', array('required' => 'required'))); 13862a7abf2dSChristopher Smith if ($conf['profileconfirm']) { 13872a7abf2dSChristopher Smith $form_profiledelete->addElement(form_makeTag('br')); 13882a7abf2dSChristopher Smith $form_profiledelete->addElement(form_makePasswordField('oldpass', $lang['oldpass'], '', 'block', array('size'=>'50', 'required' => 'required'))); 13892a7abf2dSChristopher Smith } 13902a7abf2dSChristopher Smith $form_profiledelete->addElement(form_makeButton('submit', '', $lang['btn_deleteuser'])); 13912a7abf2dSChristopher Smith $form_profiledelete->endFieldset(); 13922a7abf2dSChristopher Smith 13932a7abf2dSChristopher Smith html_form('profiledelete', $form_profiledelete); 13942a7abf2dSChristopher Smith } 13952a7abf2dSChristopher Smith 1396fdb8d77bSTom N Harris print '</div>'.NL; 13978b06d178Schris} 13988b06d178Schris 13998b06d178Schris/** 14007c4635c4SAdrian Lang * Preprocess edit form data 140115fae107Sandi * 140215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 14032ffea8f2SAdrian Lang * 14042ffea8f2SAdrian Lang * @triggers HTML_EDITFORM_OUTPUT 1405f3f0262cSandi */ 14065a932e77SAdrian Langfunction html_edit(){ 1407f0859d4bSTom N Harris global $INPUT; 1408f3f0262cSandi global $ID; 1409f3f0262cSandi global $REV; 1410f3f0262cSandi global $DATE; 1411f3f0262cSandi global $PRE; 1412f3f0262cSandi global $SUF; 1413f3f0262cSandi global $INFO; 1414f3f0262cSandi global $SUM; 1415f3f0262cSandi global $lang; 1416f3f0262cSandi global $conf; 141745a99335SAdrian Lang global $TEXT; 1418d141c8dcSAdrian Lang global $RANGE; 1419f3f0262cSandi 1420f0859d4bSTom N Harris if ($INPUT->has('changecheck')) { 1421f0859d4bSTom N Harris $check = $INPUT->str('changecheck'); 142245a99335SAdrian Lang } elseif(!$INFO['exists']){ 142345a99335SAdrian Lang // $TEXT has been loaded from page template 142445a99335SAdrian Lang $check = md5(''); 14258fe3bb00STom N Harris } else { 142645a99335SAdrian Lang $check = md5($TEXT); 14278fe3bb00STom N Harris } 142845a99335SAdrian Lang $mod = md5($TEXT) !== $check; 1429f3f0262cSandi 143027eb9321SAnika Henke $wr = $INFO['writable'] && !$INFO['locked']; 143145a99335SAdrian Lang $include = 'edit'; 1432f3f0262cSandi if($wr){ 1433ffde0ac9SAdrian Lang if ($REV) $include = 'editrev'; 1434f3f0262cSandi }else{ 1435409d7af7SAndreas Gohr // check pseudo action 'source' 1436409d7af7SAndreas Gohr if(!actionOK('source')){ 1437409d7af7SAndreas Gohr msg('Command disabled: source',-1); 1438409d7af7SAndreas Gohr return; 1439409d7af7SAndreas Gohr } 1440ffde0ac9SAdrian Lang $include = 'read'; 1441f3f0262cSandi } 14427c4635c4SAdrian Lang 14437c4635c4SAdrian Lang global $license; 144442c7abd6SAndreas Gohr 1445e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 1446fdb8d77bSTom N Harris $form->addHidden('id', $ID); 1447fdb8d77bSTom N Harris $form->addHidden('rev', $REV); 1448fdb8d77bSTom N Harris $form->addHidden('date', $DATE); 144942de51b1SAdrian Lang $form->addHidden('prefix', $PRE . '.'); 1450fdb8d77bSTom N Harris $form->addHidden('suffix', $SUF); 1451fdb8d77bSTom N Harris $form->addHidden('changecheck', $check); 14528e4da260SAdrian Lang 14532ffea8f2SAdrian Lang $data = array('form' => $form, 14542ffea8f2SAdrian Lang 'wr' => $wr, 14552ffea8f2SAdrian Lang 'media_manager' => true, 1456182ac905SAndreas Gohr 'target' => ($INPUT->has('target') && $wr) ? $INPUT->str('target') : 'section', 14572ffea8f2SAdrian Lang 'intro_locale' => $include); 145812c96aceSAdrian Lang 145912c96aceSAdrian Lang if ($data['target'] !== 'section') { 146012c96aceSAdrian Lang // Only emit event if page is writable, section edit data is valid and 146112c96aceSAdrian Lang // edit target is not section. 14628e4da260SAdrian Lang trigger_event('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); 14632ffea8f2SAdrian Lang } else { 14642ffea8f2SAdrian Lang html_edit_form($data); 14652ffea8f2SAdrian Lang } 1466ffde0ac9SAdrian Lang if (isset($data['intro_locale'])) { 1467ffde0ac9SAdrian Lang echo p_locale_xhtml($data['intro_locale']); 1468ffde0ac9SAdrian Lang } 14698e4da260SAdrian Lang 1470b7eccc60SAdrian Lang $form->addHidden('target', $data['target']); 14710607bfeeSAnika Henke $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar', 'class'=>'editBar'))); 1472fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); 1473fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1474fdb8d77bSTom N Harris if ($wr) { 1475fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); 1476fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('id'=>'edbtn__save', 'accesskey'=>'s', 'tabindex'=>'4'))); 1477fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'preview', $lang['btn_preview'], array('id'=>'edbtn__preview', 'accesskey'=>'p', 'tabindex'=>'5'))); 1478fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_cancel'], array('tabindex'=>'6'))); 1479fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1480fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); 1481fdb8d77bSTom N Harris $form->addElement(form_makeTextField('summary', $SUM, $lang['summary'], 'edit__summary', 'nowrap', array('size'=>'50', 'tabindex'=>'2'))); 1482fdb8d77bSTom N Harris $elem = html_minoredit(); 1483fdb8d77bSTom N Harris if ($elem) $form->addElement($elem); 1484fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1485fdb8d77bSTom N Harris } 1486fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 14875808bc54SAndreas Gohr if($wr && $conf['license']){ 1488066fee30SAndreas Gohr $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); 1489066fee30SAndreas Gohr $out = $lang['licenseok']; 1490066fee30SAndreas Gohr $out .= ' <a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"'; 1491507a2aebSAnika Henke if($conf['target']['extern']) $out .= ' target="'.$conf['target']['extern'].'"'; 1492066fee30SAndreas Gohr $out .= '>'.$license[$conf['license']]['name'].'</a>'; 1493066fee30SAndreas Gohr $form->addElement($out); 1494066fee30SAndreas Gohr $form->addElement(form_makeCloseTag('div')); 1495066fee30SAndreas Gohr } 14968e4da260SAdrian Lang 14978e4da260SAdrian Lang if ($wr) { 14988e4da260SAdrian Lang // sets changed to true when previewed 1499677d2785SDominik Eckelmann echo '<script type="text/javascript">/*<![CDATA[*/'. NL; 15008e4da260SAdrian Lang echo 'textChanged = ' . ($mod ? 'true' : 'false'); 1501677d2785SDominik Eckelmann echo '/*!]]>*/</script>' . NL; 15028e4da260SAdrian Lang } ?> 15035a99d25bSAnika Henke <div class="editBox" role="application"> 15048e4da260SAdrian Lang 15058a65ef2eSAnika Henke <div class="toolbar group"> 15068e4da260SAdrian Lang <div id="draft__status"><?php if(!empty($INFO['draft'])) echo $lang['draftdate'].' '.dformat();?></div> 15078e4da260SAdrian 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']?>" 15088e4da260SAdrian Lang target="_blank"><?php echo $lang['mediaselect'] ?></a><?php }?></div> 15098e4da260SAdrian Lang </div> 15108e4da260SAdrian Lang <?php 15118e4da260SAdrian Lang 1512fdb8d77bSTom N Harris html_form('edit', $form); 1513fdb8d77bSTom N Harris print '</div>'.NL; 1514f3f0262cSandi} 1515f3f0262cSandi 1516f3f0262cSandi/** 15178e4da260SAdrian Lang * Display the default edit form 15188e4da260SAdrian Lang * 15198e4da260SAdrian Lang * Is the default action for HTML_EDIT_FORMSELECTION. 15208e4da260SAdrian Lang */ 15218e4da260SAdrian Langfunction html_edit_form($param) { 152245a99335SAdrian Lang global $TEXT; 152312c96aceSAdrian Lang 152412c96aceSAdrian Lang if ($param['target'] !== 'section') { 1525ff711734SAndreas Gohr msg('No editor for edit target ' . hsc($param['target']) . ' found.', -1); 152612c96aceSAdrian Lang } 152712c96aceSAdrian Lang 15288e4da260SAdrian Lang $attr = array('tabindex'=>'1'); 152912c96aceSAdrian Lang if (!$param['wr']) $attr['readonly'] = 'readonly'; 153012c96aceSAdrian Lang 153112c96aceSAdrian Lang $param['form']->addElement(form_makeWikiText($TEXT, $attr)); 15328e4da260SAdrian Lang} 15338e4da260SAdrian Lang 15348e4da260SAdrian Lang/** 1535b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1536b6912aeaSAndreas Gohr * 1537b1f92db2SAdrian Lang * @author Andreas Gohr <andi@splitbrain.org> 1538b6912aeaSAndreas Gohr */ 1539b6912aeaSAndreas Gohrfunction html_minoredit(){ 1540b6912aeaSAndreas Gohr global $conf; 1541b6912aeaSAndreas Gohr global $lang; 1542f0859d4bSTom N Harris global $INPUT; 1543b6912aeaSAndreas Gohr // minor edits are for logged in users only 1544b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1545fdb8d77bSTom N Harris return false; 1546b6912aeaSAndreas Gohr } 1547b6912aeaSAndreas Gohr 1548b6912aeaSAndreas Gohr $p = array(); 1549b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1550f0859d4bSTom N Harris if($INPUT->bool('minor')) $p['checked']='checked'; 1551fdb8d77bSTom N Harris return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p); 1552b6912aeaSAndreas Gohr} 1553b6912aeaSAndreas Gohr 1554b6912aeaSAndreas Gohr/** 1555f3f0262cSandi * prints some debug info 155615fae107Sandi * 155715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1558f3f0262cSandi */ 1559f3f0262cSandifunction html_debug(){ 1560f3f0262cSandi global $conf; 1561d16a4edaSandi global $lang; 15628d5e837eSMichael Hamann /** @var auth_basic $auth */ 15635298a619SAndreas Gohr global $auth; 1564100a97e3SAndreas Gohr global $INFO; 1565100a97e3SAndreas Gohr 156628fb55ffSandi //remove sensitive data 156728fb55ffSandi $cnf = $conf; 156824297a69SAndreas Gohr debug_guard($cnf); 1569100a97e3SAndreas Gohr $nfo = $INFO; 157024297a69SAndreas Gohr debug_guard($nfo); 1571100a97e3SAndreas Gohr $ses = $_SESSION; 157224297a69SAndreas Gohr debug_guard($ses); 1573f3f0262cSandi 1574f3f0262cSandi print '<html><body>'; 1575f3f0262cSandi 1576f3f0262cSandi print '<p>When reporting bugs please send all the following '; 1577f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 1578f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 1579f3f0262cSandi 1580100a97e3SAndreas Gohr print '<b>$INFO:</b><pre>'; 1581100a97e3SAndreas Gohr print_r($nfo); 1582100a97e3SAndreas Gohr print '</pre>'; 1583100a97e3SAndreas Gohr 1584f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 1585f3f0262cSandi print_r($_SERVER); 1586f3f0262cSandi print '</pre>'; 1587f3f0262cSandi 1588f3f0262cSandi print '<b>$conf:</b><pre>'; 158928fb55ffSandi print_r($cnf); 1590f3f0262cSandi print '</pre>'; 1591f3f0262cSandi 1592ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 1593ed7b5f09Sandi print DOKU_BASE; 1594f3f0262cSandi print '</pre>'; 1595f3f0262cSandi 1596ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 1597ed7b5f09Sandi print DOKU_URL; 1598ed7b5f09Sandi print '</pre>'; 1599ed7b5f09Sandi 1600ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 1601f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 1602f3f0262cSandi print '</pre>'; 1603f3f0262cSandi 1604f3f0262cSandi print '<b>PHP Version:</b><pre>'; 1605f3f0262cSandi print phpversion(); 1606f3f0262cSandi print '</pre>'; 1607f3f0262cSandi 1608f3f0262cSandi print '<b>locale:</b><pre>'; 1609f3f0262cSandi print setlocale(LC_ALL,0); 1610f3f0262cSandi print '</pre>'; 1611f3f0262cSandi 1612d16a4edaSandi print '<b>encoding:</b><pre>'; 1613d16a4edaSandi print $lang['encoding']; 1614d16a4edaSandi print '</pre>'; 1615d16a4edaSandi 16165298a619SAndreas Gohr if($auth){ 16175298a619SAndreas Gohr print '<b>Auth backend capabilities:</b><pre>'; 16182f46ade0SChristopher Smith foreach ($auth->getCapabilities() as $cando){ 16192f46ade0SChristopher Smith print ' '.str_pad($cando,16) . ' => ' . (int)$auth->canDo($cando) . NL; 16202f46ade0SChristopher Smith } 16215298a619SAndreas Gohr print '</pre>'; 16225298a619SAndreas Gohr } 16235298a619SAndreas Gohr 16243aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 1625100a97e3SAndreas Gohr print_r($ses); 16263aa54d7cSAndreas Gohr print '</pre>'; 16273aa54d7cSAndreas Gohr 1628f3f0262cSandi print '<b>Environment:</b><pre>'; 1629f3f0262cSandi print_r($_ENV); 1630f3f0262cSandi print '</pre>'; 1631f3f0262cSandi 1632f3f0262cSandi print '<b>PHP settings:</b><pre>'; 1633f3f0262cSandi $inis = ini_get_all(); 1634f3f0262cSandi print_r($inis); 1635f3f0262cSandi print '</pre>'; 1636f3f0262cSandi 1637*e89b7c1eSChristopher Smith if (function_exists('apache_get_version')) { 1638*e89b7c1eSChristopher Smith $apache['version'] = apache_get_version(); 1639*e89b7c1eSChristopher Smith 1640*e89b7c1eSChristopher Smith if (function_exists('apache_get_modules')) { 1641*e89b7c1eSChristopher Smith $apache['modules'] = apache_get_modules(); 1642*e89b7c1eSChristopher Smith } 1643*e89b7c1eSChristopher Smith print '<b>Apache</b><pre>'; 1644*e89b7c1eSChristopher Smith print_r($apache); 1645*e89b7c1eSChristopher Smith print '</pre>'; 1646*e89b7c1eSChristopher Smith } 1647*e89b7c1eSChristopher Smith 1648f3f0262cSandi print '</body></html>'; 1649f3f0262cSandi} 1650f3f0262cSandi 165110271ce4SAndreas Gohr/** 165210271ce4SAndreas Gohr * List available Administration Tasks 165310271ce4SAndreas Gohr * 165410271ce4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 165510271ce4SAndreas Gohr * @author Håkan Sandell <hakan.sandell@home.se> 165610271ce4SAndreas Gohr */ 1657c19fe9c0Sandifunction html_admin(){ 1658c19fe9c0Sandi global $ID; 1659f8cc712eSAndreas Gohr global $INFO; 1660ca3a6df1SMatthias Grimm global $conf; 16615da403f1SGerrit Uitslag /** @var DokuWiki_Auth_Plugin $auth */ 166210271ce4SAndreas Gohr global $auth; 1663c19fe9c0Sandi 166411e2ce22Schris // build menu of admin functions from the plugins that handle them 166511e2ce22Schris $pluginlist = plugin_list('admin'); 166611e2ce22Schris $menu = array(); 166711e2ce22Schris foreach ($pluginlist as $p) { 16688d5e837eSMichael Hamann /** @var DokuWiki_Admin_Plugin $obj */ 16695da403f1SGerrit Uitslag if(($obj = plugin_load('admin',$p)) === null) continue; 1670f8cc712eSAndreas Gohr 1671f8cc712eSAndreas Gohr // check permissions 1672f8cc712eSAndreas Gohr if($obj->forAdminOnly() && !$INFO['isadmin']) continue; 1673f8cc712eSAndreas Gohr 167410271ce4SAndreas Gohr $menu[$p] = array('plugin' => $p, 167511e2ce22Schris 'prompt' => $obj->getMenuText($conf['lang']), 167611e2ce22Schris 'sort' => $obj->getMenuSort() 167711e2ce22Schris ); 167811e2ce22Schris } 167911e2ce22Schris 1680c95a5b7dSAndreas Gohr // data security check 168125c4afb8SChristopher Smith // simple check if the 'savedir' is relative and accessible when appended to DOKU_URL 168225c4afb8SChristopher Smith // it verifies either: 168325c4afb8SChristopher Smith // 'savedir' has been moved elsewhere, or 168425c4afb8SChristopher Smith // has protection to prevent the webserver serving files from it 168525c4afb8SChristopher Smith if (substr($conf['savedir'],0,2) == './'){ 1686f24af591SAnika Henke echo '<a style="border:none; float:right;" 1687b2f0ffd0SAnika Henke href="http://www.dokuwiki.org/security#web_access_security"> 168825c4afb8SChristopher Smith <img src="'.DOKU_URL.$conf['savedir'].'/security.png" alt="Your data directory seems to be protected properly." 1689e8188911SAndreas Gohr onerror="this.parentNode.style.display=\'none\'" /></a>'; 169025c4afb8SChristopher Smith } 1691c95a5b7dSAndreas Gohr 169210271ce4SAndreas Gohr print p_locale_xhtml('admin'); 169310271ce4SAndreas Gohr 169410271ce4SAndreas Gohr // Admin Tasks 169510271ce4SAndreas Gohr if($INFO['isadmin']){ 169610271ce4SAndreas Gohr ptln('<ul class="admin_tasks">'); 169710271ce4SAndreas Gohr 169876c65fd3SAndreas Gohr if($menu['usermanager'] && $auth && $auth->canDo('getUsers')){ 169910271ce4SAndreas Gohr ptln(' <li class="admin_usermanager"><div class="li">'. 170010271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'usermanager')).'">'. 170110271ce4SAndreas Gohr $menu['usermanager']['prompt'].'</a></div></li>'); 170210271ce4SAndreas Gohr } 170310271ce4SAndreas Gohr unset($menu['usermanager']); 170410271ce4SAndreas Gohr 170576c65fd3SAndreas Gohr if($menu['acl']){ 170610271ce4SAndreas Gohr ptln(' <li class="admin_acl"><div class="li">'. 170710271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'acl')).'">'. 170810271ce4SAndreas Gohr $menu['acl']['prompt'].'</a></div></li>'); 170976c65fd3SAndreas Gohr } 171010271ce4SAndreas Gohr unset($menu['acl']); 171110271ce4SAndreas Gohr 171295905cbeSAndreas Gohr if($menu['extension']){ 171310271ce4SAndreas Gohr ptln(' <li class="admin_plugin"><div class="li">'. 171495905cbeSAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'extension')).'">'. 171595905cbeSAndreas Gohr $menu['extension']['prompt'].'</a></div></li>'); 171676c65fd3SAndreas Gohr } 171795905cbeSAndreas Gohr unset($menu['extension']); 171810271ce4SAndreas Gohr 171976c65fd3SAndreas Gohr if($menu['config']){ 172010271ce4SAndreas Gohr ptln(' <li class="admin_config"><div class="li">'. 172110271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'config')).'">'. 172210271ce4SAndreas Gohr $menu['config']['prompt'].'</a></div></li>'); 172376c65fd3SAndreas Gohr } 172410271ce4SAndreas Gohr unset($menu['config']); 172510271ce4SAndreas Gohr } 172610271ce4SAndreas Gohr ptln('</ul>'); 172710271ce4SAndreas Gohr 172810271ce4SAndreas Gohr // Manager Tasks 172910271ce4SAndreas Gohr ptln('<ul class="admin_tasks">'); 173010271ce4SAndreas Gohr 173176c65fd3SAndreas Gohr if($menu['revert']){ 173210271ce4SAndreas Gohr ptln(' <li class="admin_revert"><div class="li">'. 173310271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'revert')).'">'. 173410271ce4SAndreas Gohr $menu['revert']['prompt'].'</a></div></li>'); 173576c65fd3SAndreas Gohr } 173610271ce4SAndreas Gohr unset($menu['revert']); 173710271ce4SAndreas Gohr 173876c65fd3SAndreas Gohr if($menu['popularity']){ 173910271ce4SAndreas Gohr ptln(' <li class="admin_popularity"><div class="li">'. 174010271ce4SAndreas Gohr '<a href="'.wl($ID, array('do' => 'admin','page' => 'popularity')).'">'. 174110271ce4SAndreas Gohr $menu['popularity']['prompt'].'</a></div></li>'); 174276c65fd3SAndreas Gohr } 174310271ce4SAndreas Gohr unset($menu['popularity']); 174410271ce4SAndreas Gohr 17459a2cec2eSAndreas Gohr // print DokuWiki version: 174610271ce4SAndreas Gohr ptln('</ul>'); 17479a2cec2eSAndreas Gohr echo '<div id="admin__version">'; 17489a2cec2eSAndreas Gohr echo getVersion(); 17499a2cec2eSAndreas Gohr echo '</div>'; 175010271ce4SAndreas Gohr 175110271ce4SAndreas Gohr // print the rest as sorted list 175210271ce4SAndreas Gohr if(count($menu)){ 1753746855cfSBen Coburn usort($menu, 'p_sort_modes'); 175411e2ce22Schris // output the menu 175510271ce4SAndreas Gohr ptln('<div class="clearer"></div>'); 175610271ce4SAndreas Gohr print p_locale_xhtml('adminplugins'); 175711e2ce22Schris ptln('<ul>'); 175811e2ce22Schris foreach ($menu as $item) { 175911e2ce22Schris if (!$item['prompt']) continue; 17600c6b58a8SAndreas Gohr ptln(' <li><div class="li"><a href="'.wl($ID, 'do=admin&page='.$item['plugin']).'">'.$item['prompt'].'</a></div></li>'); 176111e2ce22Schris } 176211e2ce22Schris ptln('</ul>'); 1763ca3a6df1SMatthias Grimm } 176410271ce4SAndreas Gohr} 1765c19fe9c0Sandi 17668b06d178Schris/** 17678b06d178Schris * Form to request a new password for an existing account 17688b06d178Schris * 17698b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 1770cc204bbdSAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de> 177111e2ce22Schris */ 17728b06d178Schrisfunction html_resendpwd() { 17738b06d178Schris global $lang; 17748b06d178Schris global $conf; 1775f0859d4bSTom N Harris global $INPUT; 1776c19fe9c0Sandi 1777f0859d4bSTom N Harris $token = preg_replace('/[^a-f0-9]+/','',$INPUT->str('pwauth')); 1778cc204bbdSAndreas Gohr 1779cc204bbdSAndreas Gohr if(!$conf['autopasswd'] && $token){ 1780cc204bbdSAndreas Gohr print p_locale_xhtml('resetpwd'); 1781cc204bbdSAndreas Gohr print '<div class="centeralign">'.NL; 1782cc204bbdSAndreas Gohr $form = new Doku_Form(array('id' => 'dw__resendpwd')); 1783cc204bbdSAndreas Gohr $form->startFieldset($lang['btn_resendpwd']); 1784cc204bbdSAndreas Gohr $form->addHidden('token', $token); 1785cc204bbdSAndreas Gohr $form->addHidden('do', 'resendpwd'); 1786cc204bbdSAndreas Gohr 1787cc204bbdSAndreas Gohr $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50'))); 1788cc204bbdSAndreas Gohr $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1789cc204bbdSAndreas Gohr 1790cc204bbdSAndreas Gohr $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 1791cc204bbdSAndreas Gohr $form->endFieldset(); 1792cc204bbdSAndreas Gohr html_form('resendpwd', $form); 1793cc204bbdSAndreas Gohr print '</div>'.NL; 1794cc204bbdSAndreas Gohr }else{ 17958b06d178Schris print p_locale_xhtml('resendpwd'); 1796fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 1797e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__resendpwd')); 1798fdb8d77bSTom N Harris $form->startFieldset($lang['resendpwd']); 1799fdb8d77bSTom N Harris $form->addHidden('do', 'resendpwd'); 1800fdb8d77bSTom N Harris $form->addHidden('save', '1'); 1801fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1802f0859d4bSTom N Harris $form->addElement(form_makeTextField('login', $INPUT->post->str('login'), $lang['user'], '', 'block')); 1803fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1804fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1805fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 1806fdb8d77bSTom N Harris $form->endFieldset(); 1807fdb8d77bSTom N Harris html_form('resendpwd', $form); 1808fdb8d77bSTom N Harris print '</div>'.NL; 1809fdb8d77bSTom N Harris } 1810cc204bbdSAndreas Gohr} 1811cc204bbdSAndreas Gohr 1812fdb8d77bSTom N Harris/** 1813b8595a66SAndreas Gohr * Return the TOC rendered to XHTML 1814b8595a66SAndreas Gohr * 1815b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1816b8595a66SAndreas Gohr */ 1817b8595a66SAndreas Gohrfunction html_TOC($toc){ 1818b8595a66SAndreas Gohr if(!count($toc)) return ''; 1819b8595a66SAndreas Gohr global $lang; 1820b8595a66SAndreas Gohr $out = '<!-- TOC START -->'.DOKU_LF; 1821d5acc30dSAnika Henke $out .= '<div id="dw__toc">'.DOKU_LF; 182248722ac8SAnika Henke $out .= '<h3 class="toggle">'; 1823b8595a66SAndreas Gohr $out .= $lang['toc']; 1824d5acc30dSAnika Henke $out .= '</h3>'.DOKU_LF; 1825d5acc30dSAnika Henke $out .= '<div>'.DOKU_LF; 182687671313SHakan Sandell $out .= html_buildlist($toc,'toc','html_list_toc','html_li_default',true); 1827b8595a66SAndreas Gohr $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 1828b8595a66SAndreas Gohr $out .= '<!-- TOC END -->'.DOKU_LF; 1829db959ae3SAndreas Gohr return $out; 1830db959ae3SAndreas Gohr} 1831b8595a66SAndreas Gohr 1832b8595a66SAndreas Gohr/** 1833b8595a66SAndreas Gohr * Callback for html_buildlist 1834b8595a66SAndreas Gohr */ 1835b8595a66SAndreas Gohrfunction html_list_toc($item){ 1836c66972f2SAdrian Lang if(isset($item['hid'])){ 18377d91652aSAndreas Gohr $link = '#'.$item['hid']; 18387d91652aSAndreas Gohr }else{ 18397d91652aSAndreas Gohr $link = $item['link']; 18407d91652aSAndreas Gohr } 18417d91652aSAndreas Gohr 1842d5acc30dSAnika Henke return '<a href="'.$link.'">'.hsc($item['title']).'</a>'; 1843b8595a66SAndreas Gohr} 1844b8595a66SAndreas Gohr 1845b8595a66SAndreas Gohr/** 1846b8595a66SAndreas Gohr * Helper function to build TOC items 1847b8595a66SAndreas Gohr * 1848b8595a66SAndreas Gohr * Returns an array ready to be added to a TOC array 1849b8595a66SAndreas Gohr * 1850b8595a66SAndreas Gohr * @param string $link - where to link (if $hash set to '#' it's a local anchor) 1851b8595a66SAndreas Gohr * @param string $text - what to display in the TOC 1852b8595a66SAndreas Gohr * @param int $level - nesting level 1853b8595a66SAndreas Gohr * @param string $hash - is prepended to the given $link, set blank if you want full links 18548d5e837eSMichael Hamann * @return array the toc item 1855b8595a66SAndreas Gohr */ 1856b8595a66SAndreas Gohrfunction html_mktocitem($link, $text, $level, $hash='#'){ 1857b8595a66SAndreas Gohr return array( 'link' => $hash.$link, 1858b8595a66SAndreas Gohr 'title' => $text, 1859b8595a66SAndreas Gohr 'type' => 'ul', 18602bb0d541Schris 'level' => $level); 1861b8595a66SAndreas Gohr} 1862b8595a66SAndreas Gohr 1863b8595a66SAndreas Gohr/** 1864fdb8d77bSTom N Harris * Output a Doku_Form object. 1865fdb8d77bSTom N Harris * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 1866fdb8d77bSTom N Harris * 1867fdb8d77bSTom N Harris * @author Tom N Harris <tnharris@whoopdedo.org> 18688d5e837eSMichael Hamann * @param string $name The name of the form 18698d5e837eSMichael Hamann * @param Doku_Form $form The form 1870fdb8d77bSTom N Harris */ 1871fdb8d77bSTom N Harrisfunction html_form($name, &$form) { 1872fdb8d77bSTom N Harris // Safety check in case the caller forgets. 1873fdb8d77bSTom N Harris $form->endFieldset(); 1874fdb8d77bSTom N Harris trigger_event('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 1875fdb8d77bSTom N Harris} 1876fdb8d77bSTom N Harris 1877fdb8d77bSTom N Harris/** 1878fdb8d77bSTom N Harris * Form print function. 1879fdb8d77bSTom N Harris * Just calls printForm() on the data object. 18808d5e837eSMichael Hamann * @param Doku_Form $data The form 1881fdb8d77bSTom N Harris */ 1882fdb8d77bSTom N Harrisfunction html_form_output($data) { 1883fdb8d77bSTom N Harris $data->printForm(); 18848b06d178Schris} 1885340756e4Sandi 188607bf32b2SAndreas Gohr/** 188707bf32b2SAndreas Gohr * Embed a flash object in HTML 188807bf32b2SAndreas Gohr * 188907bf32b2SAndreas Gohr * This will create the needed HTML to embed a flash movie in a cross browser 189007bf32b2SAndreas Gohr * compatble way using valid XHTML 189107bf32b2SAndreas Gohr * 189207bf32b2SAndreas Gohr * The parameters $params, $flashvars and $atts need to be associative arrays. 189307bf32b2SAndreas Gohr * No escaping needs to be done for them. The alternative content *has* to be 189407bf32b2SAndreas Gohr * escaped because it is used as is. If no alternative content is given 189507bf32b2SAndreas Gohr * $lang['noflash'] is used. 189607bf32b2SAndreas Gohr * 189707bf32b2SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 189807bf32b2SAndreas Gohr * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml 189907bf32b2SAndreas Gohr * 190007bf32b2SAndreas Gohr * @param string $swf - the SWF movie to embed 190107bf32b2SAndreas Gohr * @param int $width - width of the flash movie in pixels 190207bf32b2SAndreas Gohr * @param int $height - height of the flash movie in pixels 190307bf32b2SAndreas Gohr * @param array $params - additional parameters (<param>) 190407bf32b2SAndreas Gohr * @param array $flashvars - parameters to be passed in the flashvar parameter 190507bf32b2SAndreas Gohr * @param array $atts - additional attributes for the <object> tag 190607bf32b2SAndreas Gohr * @param string $alt - alternative content (is NOT automatically escaped!) 1907b3d1090eSMichael Hamann * @return string - the XHTML markup 190807bf32b2SAndreas Gohr */ 190907bf32b2SAndreas Gohrfunction html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){ 191007bf32b2SAndreas Gohr global $lang; 191107bf32b2SAndreas Gohr 191207bf32b2SAndreas Gohr $out = ''; 191307bf32b2SAndreas Gohr 191407bf32b2SAndreas Gohr // prepare the object attributes 191507bf32b2SAndreas Gohr if(is_null($atts)) $atts = array(); 191607bf32b2SAndreas Gohr $atts['width'] = (int) $width; 1917d4c61e61SAndreas Gohr $atts['height'] = (int) $height; 191807bf32b2SAndreas Gohr if(!$atts['width']) $atts['width'] = 425; 191907bf32b2SAndreas Gohr if(!$atts['height']) $atts['height'] = 350; 192007bf32b2SAndreas Gohr 192107bf32b2SAndreas Gohr // add object attributes for standard compliant browsers 192207bf32b2SAndreas Gohr $std = $atts; 192307bf32b2SAndreas Gohr $std['type'] = 'application/x-shockwave-flash'; 192407bf32b2SAndreas Gohr $std['data'] = $swf; 192507bf32b2SAndreas Gohr 192607bf32b2SAndreas Gohr // add object attributes for IE 192707bf32b2SAndreas Gohr $ie = $atts; 192807bf32b2SAndreas Gohr $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 192907bf32b2SAndreas Gohr 193007bf32b2SAndreas Gohr // open object (with conditional comments) 193107bf32b2SAndreas Gohr $out .= '<!--[if !IE]> -->'.NL; 193207bf32b2SAndreas Gohr $out .= '<object '.buildAttributes($std).'>'.NL; 193307bf32b2SAndreas Gohr $out .= '<!-- <![endif]-->'.NL; 193407bf32b2SAndreas Gohr $out .= '<!--[if IE]>'.NL; 193507bf32b2SAndreas Gohr $out .= '<object '.buildAttributes($ie).'>'.NL; 193607bf32b2SAndreas Gohr $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL; 19379ae41cdcSAndreas Gohr $out .= '<!--><!-- -->'.NL; 193807bf32b2SAndreas Gohr 193907bf32b2SAndreas Gohr // print params 194007bf32b2SAndreas Gohr if(is_array($params)) foreach($params as $key => $val){ 194107bf32b2SAndreas Gohr $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL; 194207bf32b2SAndreas Gohr } 194307bf32b2SAndreas Gohr 194407bf32b2SAndreas Gohr // add flashvars 194507bf32b2SAndreas Gohr if(is_array($flashvars)){ 1946d4c61e61SAndreas Gohr $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL; 194707bf32b2SAndreas Gohr } 194807bf32b2SAndreas Gohr 194907bf32b2SAndreas Gohr // alternative content 195007bf32b2SAndreas Gohr if($alt){ 195107bf32b2SAndreas Gohr $out .= $alt.NL; 195207bf32b2SAndreas Gohr }else{ 195307bf32b2SAndreas Gohr $out .= $lang['noflash'].NL; 195407bf32b2SAndreas Gohr } 195507bf32b2SAndreas Gohr 195607bf32b2SAndreas Gohr // finish 195707bf32b2SAndreas Gohr $out .= '</object>'.NL; 195807bf32b2SAndreas Gohr $out .= '<!-- <![endif]-->'.NL; 195907bf32b2SAndreas Gohr 196007bf32b2SAndreas Gohr return $out; 196107bf32b2SAndreas Gohr} 196207bf32b2SAndreas Gohr 19638d5e837eSMichael Hamann/** 19648d5e837eSMichael Hamann * Prints HTML code for the given tab structure 19658d5e837eSMichael Hamann * 19668d5e837eSMichael Hamann * @param array $tabs tab structure 19678d5e837eSMichael Hamann * @param string $current_tab the current tab id 19688d5e837eSMichael Hamann */ 196995b451bcSAdrian Langfunction html_tabs($tabs, $current_tab = null) { 197094add303SAnika Henke echo '<ul class="tabs">'.NL; 197195b451bcSAdrian Lang 197295b451bcSAdrian Lang foreach($tabs as $id => $tab) { 197395b451bcSAdrian Lang html_tab($tab['href'], $tab['caption'], $id === $current_tab); 197495b451bcSAdrian Lang } 197595b451bcSAdrian Lang 197694add303SAnika Henke echo '</ul>'.NL; 197795b451bcSAdrian Lang} 197895b451bcSAdrian Lang/** 197995b451bcSAdrian Lang * Prints a single tab 198095b451bcSAdrian Lang * 198195b451bcSAdrian Lang * @author Kate Arzamastseva <pshns@ukr.net> 198295b451bcSAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 198395b451bcSAdrian Lang * 198495b451bcSAdrian Lang * @param string $href - tab href 198595b451bcSAdrian Lang * @param string $caption - tab caption 198695b451bcSAdrian Lang * @param boolean $selected - is tab selected 198795b451bcSAdrian Lang */ 198895b451bcSAdrian Lang 198995b451bcSAdrian Langfunction html_tab($href, $caption, $selected=false) { 199095b451bcSAdrian Lang $tab = '<li>'; 199195b451bcSAdrian Lang if ($selected) { 199295b451bcSAdrian Lang $tab .= '<strong>'; 199395b451bcSAdrian Lang } else { 199495b451bcSAdrian Lang $tab .= '<a href="' . hsc($href) . '">'; 199595b451bcSAdrian Lang } 199695b451bcSAdrian Lang $tab .= hsc($caption) 199795b451bcSAdrian Lang . '</' . ($selected ? 'strong' : 'a') . '>' 199894add303SAnika Henke . '</li>'.NL; 199995b451bcSAdrian Lang echo $tab; 200095b451bcSAdrian Lang} 200195b451bcSAdrian Lang 2002