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 90c3a5702SAndreas Gohruse dokuwiki\ChangeLog\MediaChangeLog; 100c3a5702SAndreas Gohruse dokuwiki\ChangeLog\PageChangeLog; 11e1d9dcc8SAndreas Gohruse dokuwiki\Extension\AuthPlugin; 12cbb44eabSAndreas Gohruse dokuwiki\Extension\Event; 130c3a5702SAndreas Gohr 142d3b082eSMichael Großeif (!defined('SEC_EDIT_PATTERN')) { 1537c80e0eSLarsDW223 define('SEC_EDIT_PATTERN', '#<!-- EDIT({.*?}) -->#'); 162d3b082eSMichael Große} 172d3b082eSMichael Große 186bbae538Sandi 19f3f0262cSandi/** 20f3f0262cSandi * Convenience function to quickly build a wikilink 2115fae107Sandi * 2215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 238d5e837eSMichael Hamann * @param string $id id of the target page 248d5e837eSMichael Hamann * @param string $name the name of the link, i.e. the text that is displayed 258d5e837eSMichael Hamann * @param string|array $search search string(s) that shall be highlighted in the target page 268d5e837eSMichael Hamann * @return string the HTML code of the link 27f3f0262cSandi */ 28db959ae3SAndreas Gohrfunction html_wikilink($id,$name=null,$search=''){ 29a8397511SGerrit Uitslag /** @var Doku_Renderer_xhtml $xhtml_renderer */ 30db959ae3SAndreas Gohr static $xhtml_renderer = null; 31723d78dbSandi if(is_null($xhtml_renderer)){ 327aea91afSChris Smith $xhtml_renderer = p_get_renderer('xhtml'); 33f3f0262cSandi } 34f3f0262cSandi 35fe9ec250SChris Smith return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); 36f3f0262cSandi} 37f3f0262cSandi 38f3f0262cSandi/** 39f3f0262cSandi * The loginform 4015fae107Sandi * 4115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 42d1d904bbSMichael Große * 43d1d904bbSMichael Große * @param bool $svg Whether to show svg icons in the register and resendpwd links or not 44f3f0262cSandi */ 45d1d904bbSMichael Großefunction html_login($svg = false){ 46f3f0262cSandi global $lang; 47f3f0262cSandi global $conf; 48f3f0262cSandi global $ID; 49f0859d4bSTom N Harris global $INPUT; 50f3f0262cSandi 51c112d578Sandi print p_locale_xhtml('login'); 52fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 533f552e56SAndreas Gohr $form = new Doku_Form(array('id' => 'dw__login', 'action'=>wl($ID))); 54fdb8d77bSTom N Harris $form->startFieldset($lang['btn_login']); 55fdb8d77bSTom N Harris $form->addHidden('id', $ID); 56fdb8d77bSTom N Harris $form->addHidden('do', 'login'); 5764159a61SAndreas Gohr $form->addElement(form_makeTextField( 5864159a61SAndreas Gohr 'u', 5964159a61SAndreas Gohr ((!$INPUT->bool('http_credentials')) ? $INPUT->str('u') : ''), 6064159a61SAndreas Gohr $lang['user'], 6164159a61SAndreas Gohr 'focus__this', 6264159a61SAndreas Gohr 'block') 6364159a61SAndreas Gohr ); 64fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('p', $lang['pass'], '', 'block')); 6517f89d7eSMichael Klier if($conf['rememberme']) { 66fdb8d77bSTom N Harris $form->addElement(form_makeCheckboxField('r', '1', $lang['remember'], 'remember__me', 'simple')); 6717f89d7eSMichael Klier } 68fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_login'])); 69fdb8d77bSTom N Harris $form->endFieldset(); 705b62573aSAndreas Gohr 71de4d479aSAdrian Lang if(actionOK('register')){ 72d1d904bbSMichael Große $registerLink = (new \dokuwiki\Menu\Item\Register())->asHtmlLink('', $svg); 73d1d904bbSMichael Große $form->addElement('<p>'.$lang['reghere'].': '. $registerLink .'</p>'); 74f3f0262cSandi } 758b06d178Schris 76de4d479aSAdrian Lang if (actionOK('resendpwd')) { 77d1d904bbSMichael Große $resendPwLink = (new \dokuwiki\Menu\Item\Resendpwd())->asHtmlLink('', $svg); 78d1d904bbSMichael Große $form->addElement('<p>'.$lang['pwdforget'].': '. $resendPwLink .'</p>'); 798b06d178Schris } 8076ec5467SMichael Klier 8176ec5467SMichael Klier html_form('login', $form); 82fdb8d77bSTom N Harris print '</div>'.NL; 83f3f0262cSandi} 84f3f0262cSandi 85d59dea9fSGerrit Uitslag 86d59dea9fSGerrit Uitslag/** 87d59dea9fSGerrit Uitslag * Denied page content 88d59dea9fSGerrit Uitslag * 89d59dea9fSGerrit Uitslag * @return string html 90d59dea9fSGerrit Uitslag */ 91d59dea9fSGerrit Uitslagfunction html_denied() { 92d1e9181eSGerrit Uitslag print p_locale_xhtml('denied'); 93f019ab46SGerrit Uitslag 940db7a50dSThammi if(empty($_SERVER['REMOTE_USER']) && actionOK('login')){ 95f019ab46SGerrit Uitslag html_login(); 96f019ab46SGerrit Uitslag } 97d59dea9fSGerrit Uitslag} 98d59dea9fSGerrit Uitslag 99f3f0262cSandi/** 10015fae107Sandi * inserts section edit buttons if wanted or removes the markers 10115fae107Sandi * 10215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 10342ea7f44SGerrit Uitslag * 10442ea7f44SGerrit Uitslag * @param string $text 10542ea7f44SGerrit Uitslag * @param bool $show show section edit buttons? 10642ea7f44SGerrit Uitslag * @return string 10715fae107Sandi */ 108f3f0262cSandifunction html_secedit($text,$show=true){ 109f3f0262cSandi global $INFO; 11035dae8b0SBen Coburn 111aac83cd4SPhy if((isset($INFO) && !$INFO['writable']) || !$show || (isset($INFO) && $INFO['rev'])){ 1122d3b082eSMichael Große return preg_replace(SEC_EDIT_PATTERN,'',$text); 113f3f0262cSandi } 11435dae8b0SBen Coburn 1152d3b082eSMichael Große return preg_replace_callback(SEC_EDIT_PATTERN, 11640868f2fSAdrian Lang 'html_secedit_button', $text); 11740868f2fSAdrian Lang} 11840868f2fSAdrian Lang 11940868f2fSAdrian Lang/** 12040868f2fSAdrian Lang * prepares section edit button data for event triggering 12140868f2fSAdrian Lang * used as a callback in html_secedit 12240868f2fSAdrian Lang * 12340868f2fSAdrian Lang * @author Andreas Gohr <andi@splitbrain.org> 12442ea7f44SGerrit Uitslag * 12542ea7f44SGerrit Uitslag * @param array $matches matches with regexp 12642ea7f44SGerrit Uitslag * @return string 12742ea7f44SGerrit Uitslag * @triggers HTML_SECEDIT_BUTTON 12840868f2fSAdrian Lang */ 12940868f2fSAdrian Langfunction html_secedit_button($matches){ 130ada0d779SMichael Hamann $json = htmlspecialchars_decode($matches[1], ENT_QUOTES); 131ada0d779SMichael Hamann $data = json_decode($json, true); 132ec57f119SLarsDW223 if ($data == NULL) { 133ec57f119SLarsDW223 return; 13406917fceSMichael Große } 135ec57f119SLarsDW223 $data ['target'] = strtolower($data['target']); 136ec57f119SLarsDW223 $data ['hid'] = strtolower($data['hid']); 13740868f2fSAdrian Lang 138cbb44eabSAndreas Gohr return Event::createAndTrigger('HTML_SECEDIT_BUTTON', $data, 13940868f2fSAdrian Lang 'html_secedit_get_button'); 14040868f2fSAdrian Lang} 14140868f2fSAdrian Lang 14240868f2fSAdrian Lang/** 14340868f2fSAdrian Lang * prints a section editing button 14440868f2fSAdrian Lang * used as default action form HTML_SECEDIT_BUTTON 14540868f2fSAdrian Lang * 14640868f2fSAdrian Lang * @author Adrian Lang <lang@cosmocode.de> 14742ea7f44SGerrit Uitslag * 14842ea7f44SGerrit Uitslag * @param array $data name, section id and target 14942ea7f44SGerrit Uitslag * @return string html 15040868f2fSAdrian Lang */ 15140868f2fSAdrian Langfunction html_secedit_get_button($data) { 15240868f2fSAdrian Lang global $ID; 15340868f2fSAdrian Lang global $INFO; 15440868f2fSAdrian Lang 1556d9eab4dSMichael Hamann if (!isset($data['name']) || $data['name'] === '') return ''; 15640868f2fSAdrian Lang 15740868f2fSAdrian Lang $name = $data['name']; 15840868f2fSAdrian Lang unset($data['name']); 15940868f2fSAdrian Lang 160905fa971SAdrian Lang $secid = $data['secid']; 161905fa971SAdrian Lang unset($data['secid']); 162905fa971SAdrian Lang 16340868f2fSAdrian Lang return "<div class='secedit editbutton_" . $data['target'] . 164defa93a1SAdrian Lang " editbutton_" . $secid . "'>" . 16540868f2fSAdrian Lang html_btn('secedit', $ID, '', 16640868f2fSAdrian Lang array_merge(array('do' => 'edit', 167b150cd2cSGina Haeussge 'rev' => $INFO['lastmod'], 168b150cd2cSGina Haeussge 'summary' => '['.$name.'] '), $data), 16940868f2fSAdrian Lang 'post', $name) . '</div>'; 170f3f0262cSandi} 171f3f0262cSandi 172f3f0262cSandi/** 173d6c9c552Smatthiasgrimm * Just the back to top button (in its own form) 1746b13307fSandi * 1756b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 17642ea7f44SGerrit Uitslag * 17742ea7f44SGerrit Uitslag * @return string html 1786b13307fSandi */ 1796b13307fSandifunction html_topbtn(){ 1806b13307fSandi global $lang; 1816b13307fSandi 18264159a61SAndreas Gohr $ret = '<a class="nolink" href="#dokuwiki__top">' . 18364159a61SAndreas Gohr '<button class="button" onclick="window.scrollTo(0, 0)" title="' . $lang['btn_top'] . '">' . 18464159a61SAndreas Gohr $lang['btn_top'] . 18564159a61SAndreas Gohr '</button></a>'; 186df7b6005Sandi 1876b13307fSandi return $ret; 1886b13307fSandi} 1896b13307fSandi 1906b13307fSandi/** 191d67ca2c0Smatthiasgrimm * Displays a button (using its own form) 19235dae8b0SBen Coburn * If tooltip exists, the access key tooltip is replaced. 19315fae107Sandi * 19415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 19542ea7f44SGerrit Uitslag * 19642ea7f44SGerrit Uitslag * @param string $name 19742ea7f44SGerrit Uitslag * @param string $id 19842ea7f44SGerrit Uitslag * @param string $akey access key 199e3710957SGerrit Uitslag * @param string[] $params key-value pairs added as hidden inputs 20042ea7f44SGerrit Uitslag * @param string $method 20142ea7f44SGerrit Uitslag * @param string $tooltip 20242ea7f44SGerrit Uitslag * @param bool|string $label label text, false: lookup btn_$name in localization 203e824d633SMichael Große * @param string $svg (optional) svg code, inserted into the button 20442ea7f44SGerrit Uitslag * @return string 205f3f0262cSandi */ 206e824d633SMichael Großefunction html_btn($name, $id, $akey, $params, $method='get', $tooltip='', $label=false, $svg=null){ 207f3f0262cSandi global $conf; 208f3f0262cSandi global $lang; 209f3f0262cSandi 210f5baf821SAnika Henke if (!$label) 211f3f0262cSandi $label = $lang['btn_'.$name]; 212f3f0262cSandi 213f3f0262cSandi $ret = ''; 214f3f0262cSandi 21549c713a3Sandi //filter id (without urlencoding) 21649c713a3Sandi $id = idfilter($id,false); 217f3f0262cSandi 218f3f0262cSandi //make nice URLs even for buttons 2196c7843b5Sandi if($conf['userewrite'] == 2){ 2206c7843b5Sandi $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 2216c7843b5Sandi }elseif($conf['userewrite']){ 2226c7843b5Sandi $script = DOKU_BASE.$id; 2236c7843b5Sandi }else{ 2248b00ebcfSandi $script = DOKU_BASE.DOKU_SCRIPT; 225f3f0262cSandi $params['id'] = $id; 226f3f0262cSandi } 227f3f0262cSandi 228b278f2deSAndreas Gohr $ret .= '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">'; 229f3f0262cSandi 23006a4bf8fSAndreas Gohr if(is_array($params)){ 2319e491c01SAndreas Gohr foreach($params as $key => $val) { 232f3f0262cSandi $ret .= '<input type="hidden" name="'.$key.'" '; 23365cc1598SPhy $ret .= 'value="'.hsc($val).'" />'; 234f3f0262cSandi } 23506a4bf8fSAndreas Gohr } 236f3f0262cSandi 23735dae8b0SBen Coburn if ($tooltip!='') { 23865cc1598SPhy $tip = hsc($tooltip); 23911ea018fSAndreas Gohr }else{ 24065cc1598SPhy $tip = hsc($label); 24111ea018fSAndreas Gohr } 24211ea018fSAndreas Gohr 243ae614416SAnika Henke $ret .= '<button type="submit" '; 24411ea018fSAndreas Gohr if($akey){ 24507493d05SAnika Henke $tip .= ' ['.strtoupper($akey).']'; 24687cb01b7SAnika Henke $ret .= 'accesskey="'.$akey.'" '; 24735dae8b0SBen Coburn } 2489c65e2a9SAndreas Gohr $ret .= 'title="'.$tip.'">'; 249e824d633SMichael Große if ($svg) { 250679dba01SMichael Große $ret .= '<span>' . hsc($label) . '</span>'; 251e824d633SMichael Große $ret .= inlineSVG($svg); 252679dba01SMichael Große } else { 253ae614416SAnika Henke $ret .= hsc($label); 254679dba01SMichael Große } 255ae614416SAnika Henke $ret .= '</button>'; 2564beabca9SAnika Henke $ret .= '</div></form>'; 257f3f0262cSandi 258f3f0262cSandi return $ret; 259f3f0262cSandi} 2600747f5d7Sghi/** 2610747f5d7Sghi * show a revision warning 2620747f5d7Sghi * 2630747f5d7Sghi * @author Szymon Olewniczak <dokuwiki@imz.re> 2640747f5d7Sghi */ 265c8556525Sghifunction html_showrev() { 266c8556525Sghi print p_locale_xhtml('showrev'); 2670747f5d7Sghi} 268f3f0262cSandi 269f3f0262cSandi/** 27042ea7f44SGerrit Uitslag * Show a wiki page 27115fae107Sandi * 27215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 27342ea7f44SGerrit Uitslag * 27442ea7f44SGerrit Uitslag * @param null|string $txt wiki text or null for showing $ID 27515fae107Sandi */ 27611c78c94SAndreas Gohrfunction html_show($txt=null){ 277f3f0262cSandi global $ID; 278f3f0262cSandi global $REV; 279f3f0262cSandi global $HIGH; 280b8595a66SAndreas Gohr global $INFO; 2815c2eed9aSlisps global $DATE_AT; 282f3f0262cSandi //disable section editing for old revisions or in preview 2835400331dSandi if($txt || $REV){ 2846bbae538Sandi $secedit = false; 2856bbae538Sandi }else{ 2866bbae538Sandi $secedit = true; 287f3f0262cSandi } 288f3f0262cSandi 28911c78c94SAndreas Gohr if (!is_null($txt)){ 290f3f0262cSandi //PreviewHeader 291e0959e88SDeathCamel57 echo '<br id="scroll__here" />'; 292b8595a66SAndreas Gohr echo p_locale_xhtml('preview'); 293fc8dc822SAnika Henke echo '<div class="preview"><div class="pad">'; 294b8595a66SAndreas Gohr $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit); 295b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 296b8595a66SAndreas Gohr echo $html; 297b8595a66SAndreas Gohr echo '<div class="clearer"></div>'; 298fc8dc822SAnika Henke echo '</div></div>'; 2996bbae538Sandi 300f3f0262cSandi }else{ 3010747f5d7Sghi if ($REV||$DATE_AT){ 302c8556525Sghi $data = array('rev' => &$REV, 'date_at' => &$DATE_AT); 303cbb44eabSAndreas Gohr Event::createAndTrigger('HTML_SHOWREV_OUTPUT', $data, 'html_showrev'); 3040747f5d7Sghi } 3055c2eed9aSlisps $html = p_wiki_xhtml($ID,$REV,true,$DATE_AT); 3066bbae538Sandi $html = html_secedit($html,$secedit); 307b8595a66SAndreas Gohr if($INFO['prependTOC']) $html = tpl_toc(true).$html; 308b8595a66SAndreas Gohr $html = html_hilight($html,$HIGH); 309b8595a66SAndreas Gohr echo $html; 310f3f0262cSandi } 311f3f0262cSandi} 312f3f0262cSandi 313f3f0262cSandi/** 314ee4c4a1bSAndreas Gohr * ask the user about how to handle an exisiting draft 315ee4c4a1bSAndreas Gohr * 316ee4c4a1bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 317ee4c4a1bSAndreas Gohr */ 318ee4c4a1bSAndreas Gohrfunction html_draft(){ 319ee4c4a1bSAndreas Gohr global $INFO; 320ee4c4a1bSAndreas Gohr global $ID; 321ee4c4a1bSAndreas Gohr global $lang; 3220aabe6f8SMichael Große $draft = new \dokuwiki\Draft($ID, $INFO['client']); 3230aabe6f8SMichael Große $text = $draft->getDraftText(); 324ee4c4a1bSAndreas Gohr 325fdb8d77bSTom N Harris print p_locale_xhtml('draft'); 32637816f76SLukas Rademacher html_diff($text, false); 327e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 328fdb8d77bSTom N Harris $form->addHidden('id', $ID); 329520438b3SMichael Große $form->addHidden('date', $draft->getDraftDate()); 3301362c8afSAndreas Gohr $form->addHidden('wikitext', $text); 331fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'draft__status'))); 332520438b3SMichael Große $form->addElement($draft->getDraftMessage()); 333fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 334fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'recover', $lang['btn_recover'], array('tabindex'=>'1'))); 335fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'draftdel', $lang['btn_draftdel'], array('tabindex'=>'2'))); 336fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'show', $lang['btn_cancel'], array('tabindex'=>'3'))); 337fdb8d77bSTom N Harris html_form('draft', $form); 338ee4c4a1bSAndreas Gohr} 339ee4c4a1bSAndreas Gohr 340ee4c4a1bSAndreas Gohr/** 341f3f0262cSandi * Highlights searchqueries in HTML code 34215fae107Sandi * 34315fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 3447209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 34542ea7f44SGerrit Uitslag * 34642ea7f44SGerrit Uitslag * @param string $html 34742ea7f44SGerrit Uitslag * @param array|string $phrases 34842ea7f44SGerrit Uitslag * @return string html 349f3f0262cSandi */ 350546d3a99SAndreas Gohrfunction html_hilight($html,$phrases){ 3518a803caeSAndreas Gohr $phrases = (array) $phrases; 3528a803caeSAndreas Gohr $phrases = array_map('preg_quote_cb', $phrases); 3538a803caeSAndreas Gohr $phrases = array_map('ft_snippet_re_preprocess', $phrases); 3548a803caeSAndreas Gohr $phrases = array_filter($phrases); 3558a803caeSAndreas Gohr $regex = join('|',$phrases); 35660c15d7dSAndreas Gohr 35760c15d7dSAndreas Gohr if ($regex === '') return $html; 3588cbc5ee8SAndreas Gohr if (!\dokuwiki\Utf8\Clean::isUtf8($regex)) return $html; 35924a6c235SAndreas Gohr $html = @preg_replace_callback("/((<[^>]*)|$regex)/ui",'html_hilight_callback',$html); 360f3f0262cSandi return $html; 361f3f0262cSandi} 362f3f0262cSandi 363f3f0262cSandi/** 3647209be23SAndreas Gohr * Callback used by html_hilight() 3657209be23SAndreas Gohr * 3667209be23SAndreas Gohr * @author Harry Fuecks <hfuecks@gmail.com> 36742ea7f44SGerrit Uitslag * 36842ea7f44SGerrit Uitslag * @param array $m matches 36942ea7f44SGerrit Uitslag * @return string html 3707209be23SAndreas Gohr */ 3717209be23SAndreas Gohrfunction html_hilight_callback($m) { 3727209be23SAndreas Gohr $hlight = unslash($m[0]); 3737209be23SAndreas Gohr if ( !isset($m[2])) { 374688774a0SAnika Henke $hlight = '<span class="search_hit">'.$hlight.'</span>'; 3757209be23SAndreas Gohr } 3767209be23SAndreas Gohr return $hlight; 3777209be23SAndreas Gohr} 3787209be23SAndreas Gohr 3797209be23SAndreas Gohr/** 38015fae107Sandi * Display error on locked pages 38115fae107Sandi * 38215fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 38315fae107Sandi */ 384ee20e7d1Sandifunction html_locked(){ 385f3f0262cSandi global $ID; 386f3f0262cSandi global $conf; 387f3f0262cSandi global $lang; 38888f522e9Sandi global $INFO; 389f3f0262cSandi 390c9b4bd1eSBen Coburn $locktime = filemtime(wikiLockFN($ID)); 391f2263577SAndreas Gohr $expire = dformat($locktime + $conf['locktime']); 392f3f0262cSandi $min = round(($conf['locktime'] - (time() - $locktime) )/60); 393f3f0262cSandi 394c112d578Sandi print p_locale_xhtml('locked'); 395f3f0262cSandi print '<ul>'; 396fde860beSGerrit Uitslag print '<li><div class="li"><strong>'.$lang['lockedby'].'</strong> '.editorinfo($INFO['locked']).'</div></li>'; 397fde860beSGerrit Uitslag print '<li><div class="li"><strong>'.$lang['lockexpire'].'</strong> '.$expire.' ('.$min.' min)</div></li>'; 398f3f0262cSandi print '</ul>'; 399f3f0262cSandi} 400f3f0262cSandi 40115fae107Sandi/** 40215fae107Sandi * list old revisions 40315fae107Sandi * 40415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 40571726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 4068e69fd30SKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 407e0c26282SGerrit Uitslag * 408e0c26282SGerrit Uitslag * @param int $first skip the first n changelog lines 409e0c26282SGerrit Uitslag * @param bool|string $media_id id of media, or false for current page 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; 417047bad06SGerrit Uitslag if ($media_id) { 418047bad06SGerrit Uitslag $id = $media_id; 419047bad06SGerrit Uitslag $changelog = new MediaChangeLog($id); 420047bad06SGerrit Uitslag } else { 421047bad06SGerrit Uitslag $changelog = new PageChangeLog($id); 422047bad06SGerrit Uitslag } 423f523c971SGerrit Uitslag 42461e0b2f8SChristopher Smith /* we need to get one additional log entry to be able to 42571726d78SBen Coburn * decide if this is the last page or is there another one. 42671726d78SBen Coburn * see html_recent() 42771726d78SBen Coburn */ 428047bad06SGerrit Uitslag 429047bad06SGerrit Uitslag $revisions = $changelog->getRevisions($first, $conf['recent']+1); 4308e69fd30SKate Arzamastseva 43171726d78SBen Coburn if(count($revisions)==0 && $first!=0){ 43271726d78SBen Coburn $first=0; 433047bad06SGerrit Uitslag $revisions = $changelog->getRevisions($first, $conf['recent']+1); 43471726d78SBen Coburn } 43571726d78SBen Coburn $hasNext = false; 43671726d78SBen Coburn if (count($revisions)>$conf['recent']) { 43771726d78SBen Coburn $hasNext = true; 43871726d78SBen Coburn array_pop($revisions); // remove extra log entry 43971726d78SBen Coburn } 44071726d78SBen Coburn 4418e69fd30SKate Arzamastseva if (!$media_id) print p_locale_xhtml('revisions'); 44237a1dc12Smichael 4430607bfeeSAnika Henke $params = array('id' => 'page__revisions', 'class' => 'changes'); 444551be3f9SGerrit Uitslag if($media_id) { 445551be3f9SGerrit Uitslag $params['action'] = media_managerURL(array('image' => $media_id), '&'); 446551be3f9SGerrit Uitslag } 447551be3f9SGerrit Uitslag 448551be3f9SGerrit Uitslag if(!$media_id) { 449551be3f9SGerrit Uitslag $exists = $INFO['exists']; 450551be3f9SGerrit Uitslag $display_name = useHeading('navigation') ? hsc(p_get_first_heading($id)) : $id; 451551be3f9SGerrit Uitslag if(!$display_name) { 452551be3f9SGerrit Uitslag $display_name = $id; 453551be3f9SGerrit Uitslag } 454551be3f9SGerrit Uitslag } else { 455551be3f9SGerrit Uitslag $exists = file_exists(mediaFN($id)); 456551be3f9SGerrit Uitslag $display_name = $id; 457551be3f9SGerrit Uitslag } 4587d7ab775SKate Arzamastseva 4597d7ab775SKate Arzamastseva $form = new Doku_Form($params); 46037a1dc12Smichael $form->addElement(form_makeOpenTag('ul')); 4618e69fd30SKate Arzamastseva 4628e69fd30SKate Arzamastseva if($exists && $first == 0) { 463551be3f9SGerrit Uitslag $minor = false; 464551be3f9SGerrit Uitslag if($media_id) { 465551be3f9SGerrit Uitslag $date = dformat(@filemtime(mediaFN($id))); 466551be3f9SGerrit Uitslag $href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&'); 467551be3f9SGerrit Uitslag 468551be3f9SGerrit Uitslag $changelog->setChunkSize(1024); 469551be3f9SGerrit Uitslag $revinfo = $changelog->getRevisionInfo(@filemtime(fullpath(mediaFN($id)))); 470551be3f9SGerrit Uitslag 471551be3f9SGerrit Uitslag $summary = $revinfo['sum']; 472551be3f9SGerrit Uitslag if($revinfo['user']) { 473551be3f9SGerrit Uitslag $editor = $revinfo['user']; 474551be3f9SGerrit Uitslag } else { 475551be3f9SGerrit Uitslag $editor = $revinfo['ip']; 476551be3f9SGerrit Uitslag } 477551be3f9SGerrit Uitslag $sizechange = $revinfo['sizechange']; 478551be3f9SGerrit Uitslag } else { 479551be3f9SGerrit Uitslag $date = dformat($INFO['lastmod']); 480551be3f9SGerrit Uitslag if(isset($INFO['meta']) && isset($INFO['meta']['last_change'])) { 481551be3f9SGerrit Uitslag if($INFO['meta']['last_change']['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { 482551be3f9SGerrit Uitslag $minor = true; 483551be3f9SGerrit Uitslag } 484551be3f9SGerrit Uitslag if(isset($INFO['meta']['last_change']['sizechange'])) { 485551be3f9SGerrit Uitslag $sizechange = $INFO['meta']['last_change']['sizechange']; 486551be3f9SGerrit Uitslag } else { 487551be3f9SGerrit Uitslag $sizechange = null; 488551be3f9SGerrit Uitslag } 489551be3f9SGerrit Uitslag } 490fe101f30SMetin Güler $pagelog = new PageChangeLog($ID); 49170635395SAndreas Gohr $latestrev = $pagelog->getRevisions(-1, 1); 49270635395SAndreas Gohr $latestrev = array_pop($latestrev); 493fe101f30SMetin Güler $href = wl($id,"rev=$latestrev",false,'&'); 494551be3f9SGerrit Uitslag $summary = $INFO['sum']; 495551be3f9SGerrit Uitslag $editor = $INFO['editor']; 496551be3f9SGerrit Uitslag } 497551be3f9SGerrit Uitslag 498551be3f9SGerrit Uitslag $form->addElement(form_makeOpenTag('li', array('class' => ($minor ? 'minor' : '')))); 49937a1dc12Smichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 50037a1dc12Smichael $form->addElement(form_makeTag('input', array( 50137a1dc12Smichael 'type' => 'checkbox', 50237a1dc12Smichael 'name' => 'rev2[]', 50337a1dc12Smichael 'value' => 'current'))); 504f9b2fe70Sandi 50537a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 50637a1dc12Smichael $form->addElement($date); 50737a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 508f9b2fe70Sandi 509c2e73886SAnika Henke $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); 510cffcc403Sandi 51137a1dc12Smichael $form->addElement(form_makeOpenTag('a', array( 51237a1dc12Smichael 'class' => 'wikilink1', 513dad6764eSKate Arzamastseva 'href' => $href))); 51490658f38SMichael Hamann $form->addElement($display_name); 51537a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 516652610a2Sandi 51767c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeOpenTag('div')); 51867c8cda1SKate Arzamastseva 519551be3f9SGerrit Uitslag if($summary) { 52037a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 521551be3f9SGerrit Uitslag if(!$media_id) $form->addElement(' – '); 52265cc1598SPhy $form->addElement('<bdi>' . hsc($summary) . '</bdi>'); 52337a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 524035e07f1SKate Arzamastseva } 525652610a2Sandi 52637a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 527551be3f9SGerrit Uitslag $form->addElement((empty($editor))?('('.$lang['external_edit'].')'):'<bdi>'.editorinfo($editor).'</bdi>'); 52837a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 52937a1dc12Smichael 530cd2a4cfdSAnika Henke html_sizechange($sizechange, $form); 531551be3f9SGerrit Uitslag 53237a1dc12Smichael $form->addElement('('.$lang['current'].')'); 53367c8cda1SKate Arzamastseva 53467c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeCloseTag('div')); 53567c8cda1SKate Arzamastseva 53637a1dc12Smichael $form->addElement(form_makeCloseTag('div')); 53737a1dc12Smichael $form->addElement(form_makeCloseTag('li')); 538f3f0262cSandi } 539f3f0262cSandi 540f3f0262cSandi foreach($revisions as $rev) { 541f2263577SAndreas Gohr $date = dformat($rev); 542047bad06SGerrit Uitslag $info = $changelog->getRevisionInfo($rev); 543047bad06SGerrit Uitslag if($media_id) { 54479e79377SAndreas Gohr $exists = file_exists(mediaFN($id, $rev)); 545047bad06SGerrit Uitslag } else { 546047bad06SGerrit Uitslag $exists = page_exists($id, $rev); 547dad6764eSKate Arzamastseva } 548652610a2Sandi 549551be3f9SGerrit Uitslag $class = ''; 550551be3f9SGerrit Uitslag if($info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { 551551be3f9SGerrit Uitslag $class = 'minor'; 552551be3f9SGerrit Uitslag } 553551be3f9SGerrit Uitslag $form->addElement(form_makeOpenTag('li', array('class' => $class))); 55437a1dc12Smichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 55577707b04SAndreas Gohr if($exists){ 55637a1dc12Smichael $form->addElement(form_makeTag('input', array( 55737a1dc12Smichael 'type' => 'checkbox', 55837a1dc12Smichael 'name' => 'rev2[]', 55937a1dc12Smichael 'value' => $rev))); 56077707b04SAndreas Gohr }else{ 561c2e73886SAnika Henke $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); 56241396b71SAndreas Gohr } 563f9b2fe70Sandi 56437a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 56537a1dc12Smichael $form->addElement($date); 56637a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 56737a1dc12Smichael 56837a1dc12Smichael if($exists){ 569551be3f9SGerrit Uitslag if (!$media_id) { 570551be3f9SGerrit Uitslag $href = wl($id,"rev=$rev,do=diff", false, '&'); 571551be3f9SGerrit Uitslag } else { 572551be3f9SGerrit Uitslag $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff'), '&'); 573551be3f9SGerrit Uitslag } 574551be3f9SGerrit Uitslag $form->addElement(form_makeOpenTag('a', array( 575551be3f9SGerrit Uitslag 'class' => 'diff_link', 576551be3f9SGerrit Uitslag 'href' => $href))); 57737a1dc12Smichael $form->addElement(form_makeTag('img', array( 57837a1dc12Smichael 'src' => DOKU_BASE.'lib/images/diff.png', 57937a1dc12Smichael 'width' => 15, 58037a1dc12Smichael 'height' => 11, 58137a1dc12Smichael 'title' => $lang['diff'], 58237a1dc12Smichael 'alt' => $lang['diff']))); 58337a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 584551be3f9SGerrit Uitslag 585551be3f9SGerrit Uitslag if (!$media_id) { 586551be3f9SGerrit Uitslag $href = wl($id,"rev=$rev",false,'&'); 587551be3f9SGerrit Uitslag } else { 588551be3f9SGerrit Uitslag $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&'); 589551be3f9SGerrit Uitslag } 590551be3f9SGerrit Uitslag $form->addElement(form_makeOpenTag('a', array( 591551be3f9SGerrit Uitslag 'class' => 'wikilink1', 592551be3f9SGerrit Uitslag 'href' => $href))); 59390658f38SMichael Hamann $form->addElement($display_name); 59437a1dc12Smichael $form->addElement(form_makeCloseTag('a')); 59537a1dc12Smichael }else{ 596c2e73886SAnika Henke $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); 59790658f38SMichael Hamann $form->addElement($display_name); 59837a1dc12Smichael } 59937a1dc12Smichael 60067c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeOpenTag('div')); 60167c8cda1SKate Arzamastseva 602035e07f1SKate Arzamastseva if ($info['sum']) { 60337a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 604e260f93bSAnika Henke if(!$media_id) $form->addElement(' – '); 60565cc1598SPhy $form->addElement('<bdi>'.hsc($info['sum']).'</bdi>'); 60637a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 607035e07f1SKate Arzamastseva } 60837a1dc12Smichael 60937a1dc12Smichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 61088f522e9Sandi if($info['user']){ 611d317fb5dSAnika Henke $form->addElement('<bdi>'.editorinfo($info['user']).'</bdi>'); 612433efb25SAndreas Gohr if(auth_ismanager()){ 613d317fb5dSAnika Henke $form->addElement(' <bdo dir="ltr">('.$info['ip'].')</bdo>'); 614433efb25SAndreas Gohr } 61588f522e9Sandi }else{ 616d317fb5dSAnika Henke $form->addElement('<bdo dir="ltr">'.$info['ip'].'</bdo>'); 61788f522e9Sandi } 61837a1dc12Smichael $form->addElement(form_makeCloseTag('span')); 619652610a2Sandi 620cd2a4cfdSAnika Henke html_sizechange($info['sizechange'], $form); 621551be3f9SGerrit Uitslag 62267c8cda1SKate Arzamastseva if ($media_id) $form->addElement(form_makeCloseTag('div')); 62367c8cda1SKate Arzamastseva 62437a1dc12Smichael $form->addElement(form_makeCloseTag('div')); 62537a1dc12Smichael $form->addElement(form_makeCloseTag('li')); 626f3f0262cSandi } 62737a1dc12Smichael $form->addElement(form_makeCloseTag('ul')); 6282e55802cSKate Arzamastseva if (!$media_id) { 6292e55802cSKate Arzamastseva $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); 6302e55802cSKate Arzamastseva } else { 6312e55802cSKate Arzamastseva $form->addHidden('mediado', 'diff'); 6322e55802cSKate Arzamastseva $form->addElement(form_makeButton('submit', '', $lang['diff2'])); 6332e55802cSKate Arzamastseva } 63437a1dc12Smichael html_form('revisions', $form); 63571726d78SBen Coburn 63671726d78SBen Coburn print '<div class="pagenav">'; 63771726d78SBen Coburn $last = $first + $conf['recent']; 63871726d78SBen Coburn if ($first > 0) { 63971726d78SBen Coburn $first -= $conf['recent']; 64071726d78SBen Coburn if ($first < 0) $first = 0; 64171726d78SBen Coburn print '<div class="pagenav-prev">'; 6427e6b49bbSKate Arzamastseva if ($media_id) { 643035e07f1SKate Arzamastseva print html_btn('newer',$media_id,"p",media_managerURL(array('first' => $first), '&', false, true)); 6447e6b49bbSKate Arzamastseva } else { 6458e69fd30SKate Arzamastseva print html_btn('newer',$id,"p",array('do' => 'revisions', 'first' => $first)); 6467e6b49bbSKate Arzamastseva } 64771726d78SBen Coburn print '</div>'; 64871726d78SBen Coburn } 64971726d78SBen Coburn if ($hasNext) { 65071726d78SBen Coburn print '<div class="pagenav-next">'; 6517e6b49bbSKate Arzamastseva if ($media_id) { 652035e07f1SKate Arzamastseva print html_btn('older',$media_id,"n",media_managerURL(array('first' => $last), '&', false, true)); 6537e6b49bbSKate Arzamastseva } else { 6548e69fd30SKate Arzamastseva print html_btn('older',$id,"n",array('do' => 'revisions', 'first' => $last)); 6557e6b49bbSKate Arzamastseva } 65671726d78SBen Coburn print '</div>'; 65771726d78SBen Coburn } 65871726d78SBen Coburn print '</div>'; 65971726d78SBen Coburn 660f3f0262cSandi} 661f3f0262cSandi 66215fae107Sandi/** 66315fae107Sandi * display recent changes 66415fae107Sandi * 66515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 6665749f1ceSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 66771726d78SBen Coburn * @author Ben Coburn <btcoburn@silicodon.net> 6688d40b4b6SKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 66942ea7f44SGerrit Uitslag * 67042ea7f44SGerrit Uitslag * @param int $first 67142ea7f44SGerrit Uitslag * @param string $show_changes 67215fae107Sandi */ 6730739a638SKate Arzamastsevafunction html_recent($first = 0, $show_changes = 'both') { 674f3f0262cSandi global $conf; 675cffcc403Sandi global $lang; 676dbb00abcSEsther Brunner global $ID; 6775749f1ceSmatthiasgrimm /* we need to get one additionally log entry to be able to 6785749f1ceSmatthiasgrimm * decide if this is the last page or is there another one. 6795749f1ceSmatthiasgrimm * This is the cheapest solution to get this information. 6805749f1ceSmatthiasgrimm */ 681e5d185e1SKate Arzamastseva $flags = 0; 682e5d185e1SKate Arzamastseva if($show_changes == 'mediafiles' && $conf['mediarevisions']) { 683b5941dfaSKate Arzamastseva $flags = RECENTS_MEDIA_CHANGES; 684b5941dfaSKate Arzamastseva } elseif($show_changes == 'pages') { 685b5941dfaSKate Arzamastseva $flags = 0; 686e5d185e1SKate Arzamastseva } elseif($conf['mediarevisions']) { 687b5941dfaSKate Arzamastseva $show_changes = 'both'; 688b5941dfaSKate Arzamastseva $flags = RECENTS_MEDIA_PAGES_MIXED; 689b5941dfaSKate Arzamastseva } 6908d40b4b6SKate Arzamastseva 6918d40b4b6SKate Arzamastseva $recents = getRecents($first, $conf['recent'] + 1, getNS($ID), $flags); 6925749f1ceSmatthiasgrimm if(count($recents) == 0 && $first != 0) { 6935749f1ceSmatthiasgrimm $first = 0; 6948d40b4b6SKate Arzamastseva $recents = getRecents($first, $conf['recent'] + 1, getNS($ID), $flags); 6955749f1ceSmatthiasgrimm } 69671726d78SBen Coburn $hasNext = false; 69771726d78SBen Coburn if(count($recents) > $conf['recent']) { 69871726d78SBen Coburn $hasNext = true; 69971726d78SBen Coburn array_pop($recents); // remove extra log entry 70071726d78SBen Coburn } 701f3f0262cSandi 702c112d578Sandi print p_locale_xhtml('recent'); 703e83cef14SGina Haeussge 704a023425bSGerrit Uitslag if(getNS($ID) != '') { 70564159a61SAndreas Gohr print '<div class="level1"><p>' . 70664159a61SAndreas Gohr sprintf($lang['recent_global'], getNS($ID), wl('', 'do=recent')) . 70764159a61SAndreas Gohr '</p></div>'; 708a023425bSGerrit Uitslag } 709e83cef14SGina Haeussge 710d1264ecfSAndreas Gohr $form = new Doku_Form(array('id' => 'dw__recent', 'method' => 'GET', 'class' => 'changes', 'action'=>wl($ID))); 711abdcc39fSmichael $form->addHidden('sectok', null); 712abdcc39fSmichael $form->addHidden('do', 'recent'); 713abdcc39fSmichael $form->addHidden('id', $ID); 7148d40b4b6SKate Arzamastseva 715e5d185e1SKate Arzamastseva if($conf['mediarevisions']) { 7160607bfeeSAnika Henke $form->addElement('<div class="changeType">'); 717b5941dfaSKate Arzamastseva $form->addElement(form_makeListboxField( 718b5941dfaSKate Arzamastseva 'show_changes', 719b5941dfaSKate Arzamastseva array( 720b5941dfaSKate Arzamastseva 'pages' => $lang['pages_changes'], 721b5941dfaSKate Arzamastseva 'mediafiles' => $lang['media_changes'], 72253cba3d0SGerrit Uitslag 'both' => $lang['both_changes'] 72353cba3d0SGerrit Uitslag ), 724b5941dfaSKate Arzamastseva $show_changes, 725b5941dfaSKate Arzamastseva $lang['changes_type'], 726b5941dfaSKate Arzamastseva '', '', 727b5941dfaSKate Arzamastseva array('class' => 'quickselect'))); 728b5941dfaSKate Arzamastseva 729b5941dfaSKate Arzamastseva $form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply'])); 7300607bfeeSAnika Henke $form->addElement('</div>'); 731e5d185e1SKate Arzamastseva } 7328d40b4b6SKate Arzamastseva 733abdcc39fSmichael $form->addElement(form_makeOpenTag('ul')); 734a39955b0Smatthiasgrimm 735d437bcc4SAndreas Gohr foreach($recents as $recent) { 736f2263577SAndreas Gohr $date = dformat($recent['date']); 737cffcc403Sandi 738a023425bSGerrit Uitslag $class = ''; 739a023425bSGerrit Uitslag if($recent['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) { 740a023425bSGerrit Uitslag $class = 'minor'; 741a023425bSGerrit Uitslag } 742a023425bSGerrit Uitslag $form->addElement(form_makeOpenTag('li', array('class' => $class))); 743abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'li'))); 744f9b2fe70Sandi 7450e80bb5eSChristopher Smith if(!empty($recent['media'])) { 746421ec38eSKate Arzamastseva $form->addElement(media_printicon($recent['id'])); 747421ec38eSKate Arzamastseva } else { 748421ec38eSKate Arzamastseva $icon = DOKU_BASE . 'lib/images/fileicons/file.png'; 7490686da46SMichael Hamann $form->addElement('<img src="' . $icon . '" alt="' . $recent['id'] . '" class="icon" />'); 750421ec38eSKate Arzamastseva } 751421ec38eSKate Arzamastseva 752abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'date'))); 753abdcc39fSmichael $form->addElement($date); 754abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 755cffcc403Sandi 7566d9eab4dSMichael Hamann $diff = false; 7576d9eab4dSMichael Hamann $href = ''; 7586d9eab4dSMichael Hamann 7590e80bb5eSChristopher Smith if(!empty($recent['media'])) { 76068921571SGerrit Uitslag $changelog = new MediaChangeLog($recent['id']); 76168921571SGerrit Uitslag $revs = $changelog->getRevisions(0, 1); 76268921571SGerrit Uitslag $diff = (count($revs) && file_exists(mediaFN($recent['id']))); 76392cac9a9SKate Arzamastseva if($diff) { 76468921571SGerrit Uitslag $href = media_managerURL(array( 76568921571SGerrit Uitslag 'tab_details' => 'history', 76668921571SGerrit Uitslag 'mediado' => 'diff', 76768921571SGerrit Uitslag 'image' => $recent['id'], 76868921571SGerrit Uitslag 'ns' => getNS($recent['id']) 76968921571SGerrit Uitslag ), '&'); 77092cac9a9SKate Arzamastseva } 771b5941dfaSKate Arzamastseva } else { 772b5941dfaSKate Arzamastseva $href = wl($recent['id'], "do=diff", false, '&'); 773b5941dfaSKate Arzamastseva } 77492cac9a9SKate Arzamastseva 7750e80bb5eSChristopher Smith if(!empty($recent['media']) && !$diff) { 77692cac9a9SKate Arzamastseva $form->addElement('<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />'); 77792cac9a9SKate Arzamastseva } else { 778b5941dfaSKate Arzamastseva $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href))); 779abdcc39fSmichael $form->addElement(form_makeTag('img', array( 780abdcc39fSmichael 'src' => DOKU_BASE . 'lib/images/diff.png', 781abdcc39fSmichael 'width' => 15, 782abdcc39fSmichael 'height' => 11, 783abdcc39fSmichael 'title' => $lang['diff'], 784abdcc39fSmichael 'alt' => $lang['diff'] 785abdcc39fSmichael ))); 786abdcc39fSmichael $form->addElement(form_makeCloseTag('a')); 78792cac9a9SKate Arzamastseva } 788cffcc403Sandi 7890e80bb5eSChristopher Smith if(!empty($recent['media'])) { 79064159a61SAndreas Gohr $href = media_managerURL( 79164159a61SAndreas Gohr array( 79264159a61SAndreas Gohr 'tab_details' => 'history', 79364159a61SAndreas Gohr 'image' => $recent['id'], 79464159a61SAndreas Gohr 'ns' => getNS($recent['id']) 79564159a61SAndreas Gohr ), 79664159a61SAndreas Gohr '&' 79764159a61SAndreas Gohr ); 798b5941dfaSKate Arzamastseva } else { 799b5941dfaSKate Arzamastseva $href = wl($recent['id'], "do=revisions", false, '&'); 800b5941dfaSKate Arzamastseva } 801a023425bSGerrit Uitslag $form->addElement(form_makeOpenTag('a', array( 802a023425bSGerrit Uitslag 'class' => 'revisions_link', 803a023425bSGerrit Uitslag 'href' => $href))); 804abdcc39fSmichael $form->addElement(form_makeTag('img', array( 805abdcc39fSmichael 'src' => DOKU_BASE . 'lib/images/history.png', 806abdcc39fSmichael 'width' => 12, 807abdcc39fSmichael 'height' => 14, 808abdcc39fSmichael 'title' => $lang['btn_revs'], 809abdcc39fSmichael 'alt' => $lang['btn_revs'] 810abdcc39fSmichael ))); 811abdcc39fSmichael $form->addElement(form_makeCloseTag('a')); 812b6912aeaSAndreas Gohr 8130e80bb5eSChristopher Smith if(!empty($recent['media'])) { 81464159a61SAndreas Gohr $href = media_managerURL( 81564159a61SAndreas Gohr array( 81664159a61SAndreas Gohr 'tab_details' => 'view', 81764159a61SAndreas Gohr 'image' => $recent['id'], 81864159a61SAndreas Gohr 'ns' => getNS($recent['id']) 81964159a61SAndreas Gohr ), 82064159a61SAndreas Gohr '&' 82164159a61SAndreas Gohr ); 822a023425bSGerrit Uitslag $class = file_exists(mediaFN($recent['id'])) ? 'wikilink1' : 'wikilink2'; 823a023425bSGerrit Uitslag $form->addElement(form_makeOpenTag('a', array( 824a023425bSGerrit Uitslag 'class' => $class, 825a023425bSGerrit Uitslag 'href' => $href))); 826b5941dfaSKate Arzamastseva $form->addElement($recent['id']); 827b5941dfaSKate Arzamastseva $form->addElement(form_makeCloseTag('a')); 828b5941dfaSKate Arzamastseva } else { 829b5941dfaSKate Arzamastseva $form->addElement(html_wikilink(':' . $recent['id'], useHeading('navigation') ? null : $recent['id'])); 830b5941dfaSKate Arzamastseva } 831abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); 83265cc1598SPhy $form->addElement(' – ' . hsc($recent['sum'])); 833abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 834abdcc39fSmichael 835abdcc39fSmichael $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); 836d437bcc4SAndreas Gohr if($recent['user']) { 837d317fb5dSAnika Henke $form->addElement('<bdi>' . editorinfo($recent['user']) . '</bdi>'); 838433efb25SAndreas Gohr if(auth_ismanager()) { 839d317fb5dSAnika Henke $form->addElement(' <bdo dir="ltr">(' . $recent['ip'] . ')</bdo>'); 840433efb25SAndreas Gohr } 84188f522e9Sandi } else { 842d317fb5dSAnika Henke $form->addElement('<bdo dir="ltr">' . $recent['ip'] . '</bdo>'); 84388f522e9Sandi } 844abdcc39fSmichael $form->addElement(form_makeCloseTag('span')); 845cffcc403Sandi 846cd2a4cfdSAnika Henke html_sizechange($recent['sizechange'], $form); 847976b572aSGerrit Uitslag 848abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 849abdcc39fSmichael $form->addElement(form_makeCloseTag('li')); 850f3f0262cSandi } 851abdcc39fSmichael $form->addElement(form_makeCloseTag('ul')); 852a39955b0Smatthiasgrimm 853abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav'))); 8545749f1ceSmatthiasgrimm $last = $first + $conf['recent']; 855a39955b0Smatthiasgrimm if($first > 0) { 856a39955b0Smatthiasgrimm $first -= $conf['recent']; 857a39955b0Smatthiasgrimm if($first < 0) $first = 0; 858abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-prev'))); 859ae614416SAnika Henke $form->addElement(form_makeOpenTag('button', array( 860abdcc39fSmichael 'type' => 'submit', 861abdcc39fSmichael 'name' => 'first[' . $first . ']', 862cddd152cSmichael 'accesskey' => 'n', 863f948eeabSMichael Klier 'title' => $lang['btn_newer'] . ' [N]', 864d5daba10SKate Arzamastseva 'class' => 'button show' 865abdcc39fSmichael ))); 866ae614416SAnika Henke $form->addElement($lang['btn_newer']); 867ae614416SAnika Henke $form->addElement(form_makeCloseTag('button')); 868abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 869a39955b0Smatthiasgrimm } 87071726d78SBen Coburn if($hasNext) { 871abdcc39fSmichael $form->addElement(form_makeOpenTag('div', array('class' => 'pagenav-next'))); 872ae614416SAnika Henke $form->addElement(form_makeOpenTag('button', array( 873abdcc39fSmichael 'type' => 'submit', 874abdcc39fSmichael 'name' => 'first[' . $last . ']', 875cddd152cSmichael 'accesskey' => 'p', 876f948eeabSMichael Klier 'title' => $lang['btn_older'] . ' [P]', 877d5daba10SKate Arzamastseva 'class' => 'button show' 878abdcc39fSmichael ))); 879ae614416SAnika Henke $form->addElement($lang['btn_older']); 880ae614416SAnika Henke $form->addElement(form_makeCloseTag('button')); 881abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 882a39955b0Smatthiasgrimm } 883abdcc39fSmichael $form->addElement(form_makeCloseTag('div')); 884abdcc39fSmichael html_form('recent', $form); 885f3f0262cSandi} 886f3f0262cSandi 88715fae107Sandi/** 88815fae107Sandi * Display page index 88915fae107Sandi * 89015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 89142ea7f44SGerrit Uitslag * 89242ea7f44SGerrit Uitslag * @param string $ns 89315fae107Sandi */ 894f3f0262cSandifunction html_index($ns){ 895f3f0262cSandi global $conf; 896f3f0262cSandi global $ID; 897f3f0262cSandi $ns = cleanID($ns); 898f3f0262cSandi if(empty($ns)){ 89982f5f399SSatoshi Sahara $ns = getNS($ID); 900dab290efSSatoshi Sahara if($ns === false) $ns =''; 901f3f0262cSandi } 90288d3a917Sandi $ns = utf8_encodeFN(str_replace(':','/',$ns)); 903f3f0262cSandi 904a06884abSAndreas Gohr echo p_locale_xhtml('index'); 905158a5bffSDeathCamel57 echo '<div id="index__tree" class="index__tree">'; 906f3f0262cSandi 907f3f0262cSandi $data = array(); 908f3f0262cSandi search($data,$conf['datadir'],'search_index',array('ns' => $ns)); 909a06884abSAndreas Gohr echo html_buildlist($data,'idx','html_list_index','html_li_index'); 910a06884abSAndreas Gohr 911a06884abSAndreas Gohr echo '</div>'; 912f3f0262cSandi} 913f3f0262cSandi 914f3f0262cSandi/** 91515fae107Sandi * Index item formatter 91615fae107Sandi * 917f3f0262cSandi * User function for html_buildlist() 91815fae107Sandi * 91915fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 92042ea7f44SGerrit Uitslag * 92142ea7f44SGerrit Uitslag * @param array $item 92242ea7f44SGerrit Uitslag * @return string 923f3f0262cSandi */ 924f3f0262cSandifunction html_list_index($item){ 92574ef1778SChristopher Smith global $ID, $conf; 92674ef1778SChristopher Smith 927b8bc53ceSChristopher Smith // prevent searchbots needlessly following links 92874ef1778SChristopher Smith $nofollow = ($ID != $conf['start'] || $conf['sitemap']) ? 'rel="nofollow"' : ''; 92974ef1778SChristopher Smith 930f3f0262cSandi $ret = ''; 931f3f0262cSandi $base = ':'.$item['id']; 932f3f0262cSandi $base = substr($base,strrpos($base,':')+1); 933f3f0262cSandi if($item['type']=='d'){ 934b1af9014SChristopher Smith // FS#2766, no need for search bots to follow namespace links in the index 93564159a61SAndreas Gohr $link = wl($ID, 'idx=' . rawurlencode($item['id'])); 93664159a61SAndreas Gohr $ret .= '<a href="' . $link . '" title="' . $item['id'] . '" class="idx_dir" ' . $nofollow . '><strong>'; 937f3f0262cSandi $ret .= $base; 938ed7ecb79SAnika Henke $ret .= '</strong></a>'; 939f3f0262cSandi }else{ 9409aa38483SMichael Hamann // default is noNSorNS($id), but we want noNS($id) when useheading is off FS#2605 9419aa38483SMichael Hamann $ret .= html_wikilink(':'.$item['id'], useHeading('navigation') ? null : noNS($item['id'])); 942f3f0262cSandi } 943f3f0262cSandi return $ret; 944f3f0262cSandi} 945f3f0262cSandi 946f3f0262cSandi/** 947cb70c441Sandi * Index List item 948cb70c441Sandi * 949a1dee2b9SAdrian Lang * This user function is used in html_buildlist to build the 950cb70c441Sandi * <li> tags for namespaces when displaying the page index 951cb70c441Sandi * it gives different classes to opened or closed "folders" 952cb70c441Sandi * 953cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 95442ea7f44SGerrit Uitslag * 95542ea7f44SGerrit Uitslag * @param array $item 95642ea7f44SGerrit Uitslag * @return string html 957cb70c441Sandi */ 958cb70c441Sandifunction html_li_index($item){ 959f7dbf175SAndreas Gohr global $INFO; 96021b07cb4SAndreas Gohr global $ACT; 961f7dbf175SAndreas Gohr 9626fa4721aSAndreas Gohr $class = ''; 9636fa4721aSAndreas Gohr $id = ''; 9646fa4721aSAndreas Gohr 965cb70c441Sandi if($item['type'] == "f"){ 966f7dbf175SAndreas Gohr // scroll to the current item 967aac83cd4SPhy if(isset($INFO) && $item['id'] == $INFO['id'] && $ACT == 'index') { 968f7dbf175SAndreas Gohr $id = ' id="scroll__here"'; 969772f3c51SDeathCamel57 $class = ' bounce'; 970f7dbf175SAndreas Gohr } 9716fa4721aSAndreas Gohr return '<li class="level'.$item['level'].$class.'" '.$id.'>'; 972cb70c441Sandi }elseif($item['open']){ 973cb70c441Sandi return '<li class="open">'; 974cb70c441Sandi }else{ 975cb70c441Sandi return '<li class="closed">'; 976cb70c441Sandi } 977cb70c441Sandi} 978cb70c441Sandi 979cb70c441Sandi/** 980cb70c441Sandi * Default List item 981cb70c441Sandi * 982cb70c441Sandi * @author Andreas Gohr <andi@splitbrain.org> 98342ea7f44SGerrit Uitslag * 98442ea7f44SGerrit Uitslag * @param array $item 98542ea7f44SGerrit Uitslag * @return string html 986cb70c441Sandi */ 987cb70c441Sandifunction html_li_default($item){ 988cb70c441Sandi return '<li class="level'.$item['level'].'">'; 989cb70c441Sandi} 990cb70c441Sandi 991cb70c441Sandi/** 99215fae107Sandi * Build an unordered list 99315fae107Sandi * 994f3f0262cSandi * Build an unordered list from the given $data array 995f3f0262cSandi * Each item in the array has to have a 'level' property 996f3f0262cSandi * the item itself gets printed by the given $func user 997cb70c441Sandi * function. The second and optional function is used to 998cb70c441Sandi * print the <li> tag. Both user function need to accept 999cb70c441Sandi * a single item. 100015fae107Sandi * 1001c5a8fd96SAndreas Gohr * Both user functions can be given as array to point to 1002c5a8fd96SAndreas Gohr * a member of an object. 1003c5a8fd96SAndreas Gohr * 100415fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 100580679bafSGerrit Uitslag * 100680679bafSGerrit Uitslag * @param array $data array with item arrays 100780679bafSGerrit Uitslag * @param string $class class of ul wrapper 100880679bafSGerrit Uitslag * @param callable $func callback to print an list item 10095a9597bbSTakamura * @param callable $lifunc callback to the opening li tag 101080679bafSGerrit Uitslag * @param bool $forcewrapper Trigger building a wrapper ul if the first level is 1011ae614416SAnika Henke * 0 (we have a root object) or 1 (just the root content) 101280679bafSGerrit Uitslag * @return string html of an unordered list 1013f3f0262cSandi */ 101487671313SHakan Sandellfunction html_buildlist($data,$class,$func,$lifunc='html_li_default',$forcewrapper=false){ 1015a1dee2b9SAdrian Lang if (count($data) === 0) { 1016a1dee2b9SAdrian Lang return ''; 1017a1dee2b9SAdrian Lang } 1018a1dee2b9SAdrian Lang 10192689c55fSMichael Große $firstElement = reset($data); 10202689c55fSMichael Große $start_level = $firstElement['level']; 10219e4f7880SAdrian Lang $level = $start_level; 1022434f5921SHakan Sandell $ret = ''; 1023434f5921SHakan Sandell $open = 0; 10249e4f7880SAdrian Lang 1025f3f0262cSandi foreach ($data as $item){ 1026f3f0262cSandi 1027f3f0262cSandi if( $item['level'] > $level ){ 1028f3f0262cSandi //open new list 1029df52d0feSandi for($i=0; $i<($item['level'] - $level); $i++){ 1030434f5921SHakan Sandell if ($i) $ret .= "<li class=\"clear\">"; 1031f3f0262cSandi $ret .= "\n<ul class=\"$class\">\n"; 1032434f5921SHakan Sandell $open++; 1033df52d0feSandi } 1034434f5921SHakan Sandell $level = $item['level']; 1035434f5921SHakan Sandell 1036f3f0262cSandi }elseif( $item['level'] < $level ){ 1037f3f0262cSandi //close last item 1038f3f0262cSandi $ret .= "</li>\n"; 1039434f5921SHakan Sandell while( $level > $item['level'] && $open > 0 ){ 1040f3f0262cSandi //close higher lists 1041f3f0262cSandi $ret .= "</ul>\n</li>\n"; 1042434f5921SHakan Sandell $level--; 1043434f5921SHakan Sandell $open--; 1044f3f0262cSandi } 1045a1dee2b9SAdrian Lang } elseif ($ret !== '') { 104687671313SHakan Sandell //close previous item 1047f3f0262cSandi $ret .= "</li>\n"; 1048f3f0262cSandi } 1049f3f0262cSandi 1050f3f0262cSandi //print item 105134dbe711Schris $ret .= call_user_func($lifunc,$item); 10520c6b58a8SAndreas Gohr $ret .= '<div class="li">'; 105334dbe711Schris 105434dbe711Schris $ret .= call_user_func($func,$item); 10550c6b58a8SAndreas Gohr $ret .= '</div>'; 1056f3f0262cSandi } 1057f3f0262cSandi 1058f3f0262cSandi //close remaining items and lists 1059434f5921SHakan Sandell $ret .= "</li>\n"; 1060434f5921SHakan Sandell while($open-- > 0) { 1061434f5921SHakan Sandell $ret .= "</ul></li>\n"; 1062434f5921SHakan Sandell } 1063434f5921SHakan Sandell 1064434f5921SHakan Sandell if ($forcewrapper || $start_level < 2) { 1065434f5921SHakan Sandell // Trigger building a wrapper ul if the first level is 1066434f5921SHakan Sandell // 0 (we have a root object) or 1 (just the root content) 1067434f5921SHakan Sandell $ret = "\n<ul class=\"$class\">\n".$ret."</ul>\n"; 1068f3f0262cSandi } 1069f3f0262cSandi 1070f3f0262cSandi return $ret; 1071f3f0262cSandi} 1072f3f0262cSandi 107315fae107Sandi/** 107415fae107Sandi * display backlinks 107515fae107Sandi * 107615fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 107711df47ecSMichael Klier * @author Michael Klier <chi@chimeric.de> 107815fae107Sandi */ 1079f3f0262cSandifunction html_backlinks(){ 1080f3f0262cSandi global $ID; 108111df47ecSMichael Klier global $lang; 1082f3f0262cSandi 1083c112d578Sandi print p_locale_xhtml('backlinks'); 1084f3f0262cSandi 108554f4c056SAndreas Gohr $data = ft_backlinks($ID); 1086f3f0262cSandi 108711df47ecSMichael Klier if(!empty($data)) { 1088f3f0262cSandi print '<ul class="idx">'; 108954f4c056SAndreas Gohr foreach($data as $blink){ 10900c6b58a8SAndreas Gohr print '<li><div class="li">'; 1091db959ae3SAndreas Gohr print html_wikilink(':'.$blink,useHeading('navigation')?null:$blink); 10920c6b58a8SAndreas Gohr print '</div></li>'; 1093f3f0262cSandi } 1094f3f0262cSandi print '</ul>'; 109511df47ecSMichael Klier } else { 109611df47ecSMichael Klier print '<div class="level1"><p>' . $lang['nothingfound'] . '</p></div>'; 109711df47ecSMichael Klier } 1098f3f0262cSandi} 1099f3f0262cSandi 11008d5e837eSMichael Hamann/** 11018d5e837eSMichael Hamann * Get header of diff HTML 110242ea7f44SGerrit Uitslag * 11038d5e837eSMichael Hamann * @param string $l_rev Left revisions 11048d5e837eSMichael Hamann * @param string $r_rev Right revision 11058d5e837eSMichael Hamann * @param string $id Page id, if null $ID is used 11068d5e837eSMichael Hamann * @param bool $media If it is for media files 1107f76724a4STom N Harris * @param bool $inline Return the header on a single line 110842ea7f44SGerrit Uitslag * @return string[] HTML snippets for diff header 11098d5e837eSMichael Hamann */ 1110f76724a4STom N Harrisfunction html_diff_head($l_rev, $r_rev, $id = null, $media = false, $inline = false) { 111195b451bcSAdrian Lang global $lang; 111295b451bcSAdrian Lang if ($id === null) { 111395b451bcSAdrian Lang global $ID; 111495b451bcSAdrian Lang $id = $ID; 111595b451bcSAdrian Lang } 1116f76724a4STom N Harris $head_separator = $inline ? ' ' : '<br />'; 111795b451bcSAdrian Lang $media_or_wikiFN = $media ? 'mediaFN' : 'wikiFN'; 111895b451bcSAdrian Lang $ml_or_wl = $media ? 'ml' : 'wl'; 111995b451bcSAdrian Lang $l_minor = $r_minor = ''; 112095b451bcSAdrian Lang 1121047bad06SGerrit Uitslag if($media) { 11224f6e20c7SGerrit Uitslag $changelog = new MediaChangeLog($id); 1123047bad06SGerrit Uitslag } else { 11244f6e20c7SGerrit Uitslag $changelog = new PageChangeLog($id); 1125047bad06SGerrit Uitslag } 112695b451bcSAdrian Lang if(!$l_rev){ 112795b451bcSAdrian Lang $l_head = '—'; 112895b451bcSAdrian Lang }else{ 11294f6e20c7SGerrit Uitslag $l_info = $changelog->getRevisionInfo($l_rev); 113095b451bcSAdrian Lang if($l_info['user']){ 1131d317fb5dSAnika Henke $l_user = '<bdi>'.editorinfo($l_info['user']).'</bdi>'; 1132d317fb5dSAnika Henke if(auth_ismanager()) $l_user .= ' <bdo dir="ltr">('.$l_info['ip'].')</bdo>'; 113395b451bcSAdrian Lang } else { 1134d317fb5dSAnika Henke $l_user = '<bdo dir="ltr">'.$l_info['ip'].'</bdo>'; 113595b451bcSAdrian Lang } 113695b451bcSAdrian Lang $l_user = '<span class="user">'.$l_user.'</span>'; 1137d317fb5dSAnika Henke $l_sum = ($l_info['sum']) ? '<span class="sum"><bdi>'.hsc($l_info['sum']).'</bdi></span>' : ''; 113895b451bcSAdrian Lang if ($l_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $l_minor = 'class="minor"'; 113995b451bcSAdrian Lang 1140699c5072SAnika Henke $l_head_title = ($media) ? dformat($l_rev) : $id.' ['.dformat($l_rev).']'; 1141d317fb5dSAnika Henke $l_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id,"rev=$l_rev").'">'. 1142d317fb5dSAnika Henke $l_head_title.'</a></bdi>'. 1143f76724a4STom N Harris $head_separator.$l_user.' '.$l_sum; 114495b451bcSAdrian Lang } 114595b451bcSAdrian Lang 114695b451bcSAdrian Lang if($r_rev){ 11474f6e20c7SGerrit Uitslag $r_info = $changelog->getRevisionInfo($r_rev); 114895b451bcSAdrian Lang if($r_info['user']){ 1149d317fb5dSAnika Henke $r_user = '<bdi>'.editorinfo($r_info['user']).'</bdi>'; 1150d317fb5dSAnika Henke if(auth_ismanager()) $r_user .= ' <bdo dir="ltr">('.$r_info['ip'].')</bdo>'; 115195b451bcSAdrian Lang } else { 1152d317fb5dSAnika Henke $r_user = '<bdo dir="ltr">'.$r_info['ip'].'</bdo>'; 115395b451bcSAdrian Lang } 115495b451bcSAdrian Lang $r_user = '<span class="user">'.$r_user.'</span>'; 1155d317fb5dSAnika Henke $r_sum = ($r_info['sum']) ? '<span class="sum"><bdi>'.hsc($r_info['sum']).'</bdi></span>' : ''; 115695b451bcSAdrian Lang if ($r_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; 115795b451bcSAdrian Lang 1158699c5072SAnika Henke $r_head_title = ($media) ? dformat($r_rev) : $id.' ['.dformat($r_rev).']'; 1159d317fb5dSAnika Henke $r_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id,"rev=$r_rev").'">'. 1160d317fb5dSAnika Henke $r_head_title.'</a></bdi>'. 1161f76724a4STom N Harris $head_separator.$r_user.' '.$r_sum; 116295b451bcSAdrian Lang }elseif($_rev = @filemtime($media_or_wikiFN($id))){ 11634f6e20c7SGerrit Uitslag $_info = $changelog->getRevisionInfo($_rev); 116495b451bcSAdrian Lang if($_info['user']){ 1165d317fb5dSAnika Henke $_user = '<bdi>'.editorinfo($_info['user']).'</bdi>'; 1166d317fb5dSAnika Henke if(auth_ismanager()) $_user .= ' <bdo dir="ltr">('.$_info['ip'].')</bdo>'; 116795b451bcSAdrian Lang } else { 1168d317fb5dSAnika Henke $_user = '<bdo dir="ltr">'.$_info['ip'].'</bdo>'; 116995b451bcSAdrian Lang } 117095b451bcSAdrian Lang $_user = '<span class="user">'.$_user.'</span>'; 1171d317fb5dSAnika Henke $_sum = ($_info['sum']) ? '<span class="sum"><bdi>'.hsc($_info['sum']).'</span></bdi>' : ''; 117295b451bcSAdrian Lang if ($_info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $r_minor = 'class="minor"'; 117395b451bcSAdrian Lang 1174699c5072SAnika Henke $r_head_title = ($media) ? dformat($_rev) : $id.' ['.dformat($_rev).']'; 1175d317fb5dSAnika Henke $r_head = '<bdi><a class="wikilink1" href="'.$ml_or_wl($id).'">'. 1176d317fb5dSAnika Henke $r_head_title.'</a></bdi> '. 117795b451bcSAdrian Lang '('.$lang['current'].')'. 1178f76724a4STom N Harris $head_separator.$_user.' '.$_sum; 117995b451bcSAdrian Lang }else{ 118095b451bcSAdrian Lang $r_head = '— ('.$lang['current'].')'; 118195b451bcSAdrian Lang } 118295b451bcSAdrian Lang 118395b451bcSAdrian Lang return array($l_head, $r_head, $l_minor, $r_minor); 118495b451bcSAdrian Lang} 118595b451bcSAdrian Lang 118615fae107Sandi/** 118704e99fe1SGerrit Uitslag * Show diff 1188baf0c3e5SGerrit Uitslag * between current page version and provided $text 1189baf0c3e5SGerrit Uitslag * or between the revisions provided via GET or POST 119015fae107Sandi * 119115fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1192baf0c3e5SGerrit Uitslag * @param string $text when non-empty: compare with this text with most current version 119304e99fe1SGerrit Uitslag * @param bool $intro display the intro text 11948d5e837eSMichael Hamann * @param string $type type of the diff (inline or sidebyside) 119515fae107Sandi */ 119672165381SAndreas Gohrfunction html_diff($text = '', $intro = true, $type = null) { 1197f3f0262cSandi global $ID; 1198f3f0262cSandi global $REV; 1199f3f0262cSandi global $lang; 1200f0859d4bSTom N Harris global $INPUT; 12013c94d07bSAnika Henke global $INFO; 1202047bad06SGerrit Uitslag $pagelog = new PageChangeLog($ID); 1203e1bd90ffSAndreas Gohr 1204c7686ac1SGerrit Uitslag /* 1205c7686ac1SGerrit Uitslag * Determine diff type 1206c7686ac1SGerrit Uitslag */ 12073c94d07bSAnika Henke if (!$type) { 12083c94d07bSAnika Henke $type = $INPUT->str('difftype'); 12093c94d07bSAnika Henke if (empty($type)) { 12103c94d07bSAnika Henke $type = get_doku_pref('difftype', $type); 12113c94d07bSAnika Henke if (empty($type) && $INFO['ismobile']) { 12123c94d07bSAnika Henke $type = 'inline'; 12133c94d07bSAnika Henke } 12143c94d07bSAnika Henke } 12153c94d07bSAnika Henke } 121672165381SAndreas Gohr if ($type != 'inline') $type = 'sidebyside'; 121772165381SAndreas Gohr 1218c7686ac1SGerrit Uitslag /* 1219c7686ac1SGerrit Uitslag * Determine requested revision(s) 1220c7686ac1SGerrit Uitslag */ 122177707b04SAndreas Gohr // we're trying to be clever here, revisions to compare can be either 122277707b04SAndreas Gohr // given as rev and rev2 parameters, with rev2 being optional. Or in an 122377707b04SAndreas Gohr // array in rev2. 122477707b04SAndreas Gohr $rev1 = $REV; 12257b3f8b16SAndreas Gohr 1226f1d7655bSAndreas Gohr $rev2 = $INPUT->ref('rev2'); 1227f1d7655bSAndreas Gohr if (is_array($rev2)) { 1228f1d7655bSAndreas Gohr $rev1 = (int) $rev2[0]; 1229f1d7655bSAndreas Gohr $rev2 = (int) $rev2[1]; 123054041c77SAndreas Gohr 123154041c77SAndreas Gohr if (!$rev1) { 123254041c77SAndreas Gohr $rev1 = $rev2; 123354041c77SAndreas Gohr unset($rev2); 123454041c77SAndreas Gohr } 1235f3f0262cSandi } else { 1236f0859d4bSTom N Harris $rev2 = $INPUT->int('rev2'); 12374d58bd99Sandi } 12384d58bd99Sandi 1239c7686ac1SGerrit Uitslag /* 1240c7686ac1SGerrit Uitslag * Determine left and right revision, its texts and the header 1241c7686ac1SGerrit Uitslag */ 12423733161eSAdrian Lang $r_minor = ''; 12433733161eSAdrian Lang $l_minor = ''; 12443733161eSAdrian Lang 124577707b04SAndreas Gohr if ($text) { // compare text to the most current revision 124677707b04SAndreas Gohr $l_rev = ''; 124777707b04SAndreas Gohr $l_text = rawWiki($ID, ''); 1248*5a25e725SSatoshi Sahara $l_head = '<a class="wikilink1" href="'. wl($ID) .'">' 1249*5a25e725SSatoshi Sahara . $ID .' '. dformat((int) @filemtime(wikiFN($ID))) .'</a> ' 1250*5a25e725SSatoshi Sahara . $lang['current']; 125177707b04SAndreas Gohr 125277707b04SAndreas Gohr $r_rev = ''; 125377707b04SAndreas Gohr $r_text = cleanText($text); 125477707b04SAndreas Gohr $r_head = $lang['yours']; 1255e1bd90ffSAndreas Gohr } else { 12566d9eab4dSMichael Hamann if ($rev1 && isset($rev2) && $rev2) { // two specific revisions wanted 125754041c77SAndreas Gohr // make sure order is correct (older on the left) 125877707b04SAndreas Gohr if ($rev1 < $rev2) { 125977707b04SAndreas Gohr $l_rev = $rev1; 126077707b04SAndreas Gohr $r_rev = $rev2; 126177707b04SAndreas Gohr } else { 126277707b04SAndreas Gohr $l_rev = $rev2; 126377707b04SAndreas Gohr $r_rev = $rev1; 1264e1bd90ffSAndreas Gohr } 126577707b04SAndreas Gohr } elseif ($rev1) { // single revision given, compare to current 126677707b04SAndreas Gohr $r_rev = ''; 126777707b04SAndreas Gohr $l_rev = $rev1; 126877707b04SAndreas Gohr } else { // no revision was given, compare previous to current 126977707b04SAndreas Gohr $r_rev = ''; 1270f523c971SGerrit Uitslag $revs = $pagelog->getRevisions(0, 1); 127177707b04SAndreas Gohr $l_rev = $revs[0]; 12726f8e9f59SAndreas Gohr $REV = $l_rev; // store revision back in $REV 127377707b04SAndreas Gohr } 127477707b04SAndreas Gohr 12757b3f8b16SAndreas Gohr // when both revisions are empty then the page was created just now 12767b3f8b16SAndreas Gohr if (!$l_rev && !$r_rev) { 12777b3f8b16SAndreas Gohr $l_text = ''; 12787b3f8b16SAndreas Gohr } else { 127977707b04SAndreas Gohr $l_text = rawWiki($ID, $l_rev); 12807b3f8b16SAndreas Gohr } 128177707b04SAndreas Gohr $r_text = rawWiki($ID, $r_rev); 128277707b04SAndreas Gohr 1283f76724a4STom N Harris list($l_head, $r_head, $l_minor, $r_minor) = html_diff_head($l_rev, $r_rev, null, false, $type == 'inline'); 128477707b04SAndreas Gohr } 128577707b04SAndreas Gohr 1286c7686ac1SGerrit Uitslag /* 1287c7686ac1SGerrit Uitslag * Build navigation 1288c7686ac1SGerrit Uitslag */ 1289c7686ac1SGerrit Uitslag $l_nav = ''; 1290c7686ac1SGerrit Uitslag $r_nav = ''; 1291c7686ac1SGerrit Uitslag if (!$text) { 1292baf0c3e5SGerrit Uitslag list($l_nav, $r_nav) = html_diff_navigation($pagelog, $type, $l_rev, $r_rev); 1293c7686ac1SGerrit Uitslag } 1294c7686ac1SGerrit Uitslag /* 1295c7686ac1SGerrit Uitslag * Create diff object and the formatter 1296c7686ac1SGerrit Uitslag */ 129704e99fe1SGerrit Uitslag $diff = new Diff(explode("\n", $l_text), explode("\n", $r_text)); 129877707b04SAndreas Gohr 129972165381SAndreas Gohr if ($type == 'inline') { 130004e99fe1SGerrit Uitslag $diffformatter = new InlineDiffFormatter(); 130172165381SAndreas Gohr } else { 130204e99fe1SGerrit Uitslag $diffformatter = new TableDiffFormatter(); 130372165381SAndreas Gohr } 1304c7686ac1SGerrit Uitslag /* 1305c7686ac1SGerrit Uitslag * Display intro 1306c7686ac1SGerrit Uitslag */ 1307c112d578Sandi if ($intro) print p_locale_xhtml('diff'); 1308226bf2dcSGina Haeussge 1309c7686ac1SGerrit Uitslag /* 1310c7686ac1SGerrit Uitslag * Display type and exact reference 1311c7686ac1SGerrit Uitslag */ 1312226bf2dcSGina Haeussge if (!$text) { 1313*5a25e725SSatoshi Sahara print '<div class="diffoptions group">'; 131472165381SAndreas Gohr 1315c7686ac1SGerrit Uitslag 131672165381SAndreas Gohr $form = new Doku_Form(array('action' => wl())); 13171b885c58SAndreas Gohr $form->addHidden('id', $ID); 131872165381SAndreas Gohr $form->addHidden('rev2[0]', $l_rev); 131972165381SAndreas Gohr $form->addHidden('rev2[1]', $r_rev); 132072165381SAndreas Gohr $form->addHidden('do', 'diff'); 132104e99fe1SGerrit Uitslag $form->addElement( 132204e99fe1SGerrit Uitslag form_makeListboxField( 132372165381SAndreas Gohr 'difftype', 132472165381SAndreas Gohr array( 132572165381SAndreas Gohr 'sidebyside' => $lang['diff_side'], 132604e99fe1SGerrit Uitslag 'inline' => $lang['diff_inline'] 132704e99fe1SGerrit Uitslag ), 132872165381SAndreas Gohr $type, 132972165381SAndreas Gohr $lang['diff_type'], 133072165381SAndreas Gohr '', '', 133104e99fe1SGerrit Uitslag array('class' => 'quickselect') 133204e99fe1SGerrit Uitslag ) 133304e99fe1SGerrit Uitslag ); 133472165381SAndreas Gohr $form->addElement(form_makeButton('submit', 'diff', 'Go')); 133572165381SAndreas Gohr $form->printForm(); 133672165381SAndreas Gohr 1337*5a25e725SSatoshi Sahara print '<p>'; 13384fc1354aSGerrit Uitslag // link to exactly this view FS#2835 1339*5a25e725SSatoshi Sahara print html_diff_navigationlink($type, 'difflink', $l_rev, $r_rev ? $r_rev : $INFO['currentrev']); 1340*5a25e725SSatoshi Sahara print '</p>'; 1341cfe2f202SGerrit Uitslag 1342*5a25e725SSatoshi Sahara print '</div>'; // .diffoptions 134304e99fe1SGerrit Uitslag } 1344f1f2f711SGerrit Uitslag 134551684808SGerrit Uitslag /* 1346c7686ac1SGerrit Uitslag * Display diff view table 134751684808SGerrit Uitslag */ 1348*5a25e725SSatoshi Sahara print '<div class="table">'; 1349*5a25e725SSatoshi Sahara print '<table class="diff diff_'. $type .'">'; 1350c7686ac1SGerrit Uitslag 1351c7686ac1SGerrit Uitslag //navigation and header 1352cfe2f202SGerrit Uitslag if ($type == 'inline') { 1353*5a25e725SSatoshi Sahara if (!$text) { 1354*5a25e725SSatoshi Sahara print '<tr>' 1355*5a25e725SSatoshi Sahara . '<td class="diff-lineheader">-</td>' 1356*5a25e725SSatoshi Sahara . '<td class="diffnav">'. $l_nav .'</td>' 1357*5a25e725SSatoshi Sahara . '</tr>'; 1358*5a25e725SSatoshi Sahara print '<tr>' 1359*5a25e725SSatoshi Sahara . '<th class="diff-lineheader">-</th>' 1360*5a25e725SSatoshi Sahara . '<th '. $l_minor .'>'. $l_head .'</th>' 1361*5a25e725SSatoshi Sahara .'</tr>'; 1362*5a25e725SSatoshi Sahara } 1363*5a25e725SSatoshi Sahara print '<tr>' 1364*5a25e725SSatoshi Sahara . '<td class="diff-lineheader">+</td>' 1365*5a25e725SSatoshi Sahara . '<td class="diffnav">'. $r_nav .'</td>' 1366*5a25e725SSatoshi Sahara .'</tr>'; 1367*5a25e725SSatoshi Sahara print '<tr>' 1368*5a25e725SSatoshi Sahara . '<th class="diff-lineheader">+</th>' 1369*5a25e725SSatoshi Sahara . '<th '. $r_minor .'>'. $r_head .'</th>' 1370*5a25e725SSatoshi Sahara . '</tr>'; 1371*5a25e725SSatoshi Sahara } else { 1372*5a25e725SSatoshi Sahara if (!$text) { 1373*5a25e725SSatoshi Sahara print '<tr>' 1374*5a25e725SSatoshi Sahara . '<td colspan="2" class="diffnav">'. $l_nav .'</td>' 1375*5a25e725SSatoshi Sahara . '<td colspan="2" class="diffnav">'. $r_nav .'</td>' 1376*5a25e725SSatoshi Sahara . '</tr>'; 1377*5a25e725SSatoshi Sahara } 1378*5a25e725SSatoshi Sahara print '<tr>' 1379*5a25e725SSatoshi Sahara . '<th colspan="2" '. $l_minor ,'>'. $l_head .'</th>' 1380*5a25e725SSatoshi Sahara . '<th colspan="2" '. $r_minor .'>'. $r_head .'</th>' 1381*5a25e725SSatoshi Sahara . '</tr>'; 1382*5a25e725SSatoshi Sahara } 1383c7686ac1SGerrit Uitslag 1384c7686ac1SGerrit Uitslag //diff view 1385*5a25e725SSatoshi Sahara print html_insert_softbreaks($diffformatter->format($diff)); 1386c7686ac1SGerrit Uitslag 1387*5a25e725SSatoshi Sahara print '</table>'; 1388*5a25e725SSatoshi Sahara print '</div>'. DOKU_LF; 1389f3f0262cSandi} 1390f3f0262cSandi 13914fc1354aSGerrit Uitslag/** 1392baf0c3e5SGerrit Uitslag * Create html for revision navigation 1393baf0c3e5SGerrit Uitslag * 1394baf0c3e5SGerrit Uitslag * @param PageChangeLog $pagelog changelog object of current page 1395baf0c3e5SGerrit Uitslag * @param string $type inline vs sidebyside 1396baf0c3e5SGerrit Uitslag * @param int $l_rev left revision timestamp 1397baf0c3e5SGerrit Uitslag * @param int $r_rev right revision timestamp 1398baf0c3e5SGerrit Uitslag * @return string[] html of left and right navigation elements 1399baf0c3e5SGerrit Uitslag */ 1400baf0c3e5SGerrit Uitslagfunction html_diff_navigation($pagelog, $type, $l_rev, $r_rev) { 1401baf0c3e5SGerrit Uitslag global $INFO, $ID; 1402baf0c3e5SGerrit Uitslag 14034d5954c8SGerrit Uitslag // last timestamp is not in changelog, retrieve timestamp from metadata 14044d5954c8SGerrit Uitslag // note: when page is removed, the metadata timestamp is zero 1405bdca103aSAndreas Gohr if (!$r_rev) { 1406bdca103aSAndreas Gohr if (isset($INFO['meta']['last_change']['date'])) { 1407bdca103aSAndreas Gohr $r_rev = $INFO['meta']['last_change']['date']; 1408bdca103aSAndreas Gohr } else { 1409bdca103aSAndreas Gohr $r_rev = 0; 1410bdca103aSAndreas Gohr } 1411bdca103aSAndreas Gohr } 1412baf0c3e5SGerrit Uitslag 1413baf0c3e5SGerrit Uitslag //retrieve revisions with additional info 1414baf0c3e5SGerrit Uitslag list($l_revs, $r_revs) = $pagelog->getRevisionsAround($l_rev, $r_rev); 1415baf0c3e5SGerrit Uitslag $l_revisions = array(); 1416621bbd2aSGerrit Uitslag if (!$l_rev) { 1417621bbd2aSGerrit Uitslag $l_revisions[0] = array(0, "", false); //no left revision given, add dummy 1418621bbd2aSGerrit Uitslag } 1419baf0c3e5SGerrit Uitslag foreach ($l_revs as $rev) { 1420baf0c3e5SGerrit Uitslag $info = $pagelog->getRevisionInfo($rev); 1421baf0c3e5SGerrit Uitslag $l_revisions[$rev] = array( 1422baf0c3e5SGerrit Uitslag $rev, 1423c006b6aaSGerrit Uitslag dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'], 1424621bbd2aSGerrit Uitslag $r_rev ? $rev >= $r_rev : false //disable? 1425baf0c3e5SGerrit Uitslag ); 1426baf0c3e5SGerrit Uitslag } 1427baf0c3e5SGerrit Uitslag $r_revisions = array(); 1428621bbd2aSGerrit Uitslag if (!$r_rev) { 1429621bbd2aSGerrit Uitslag $r_revisions[0] = array(0, "", false); //no right revision given, add dummy 1430621bbd2aSGerrit Uitslag } 1431baf0c3e5SGerrit Uitslag foreach ($r_revs as $rev) { 1432baf0c3e5SGerrit Uitslag $info = $pagelog->getRevisionInfo($rev); 1433baf0c3e5SGerrit Uitslag $r_revisions[$rev] = array( 1434baf0c3e5SGerrit Uitslag $rev, 1435c006b6aaSGerrit Uitslag dformat($info['date']) . ' ' . editorinfo($info['user'], true) . ' ' . $info['sum'], 1436baf0c3e5SGerrit Uitslag $rev <= $l_rev //disable? 1437baf0c3e5SGerrit Uitslag ); 1438baf0c3e5SGerrit Uitslag } 1439621bbd2aSGerrit Uitslag 1440baf0c3e5SGerrit Uitslag //determine previous/next revisions 1441baf0c3e5SGerrit Uitslag $l_index = array_search($l_rev, $l_revs); 1442baf0c3e5SGerrit Uitslag $l_prev = $l_revs[$l_index + 1]; 1443baf0c3e5SGerrit Uitslag $l_next = $l_revs[$l_index - 1]; 1444621bbd2aSGerrit Uitslag if ($r_rev) { 1445baf0c3e5SGerrit Uitslag $r_index = array_search($r_rev, $r_revs); 1446baf0c3e5SGerrit Uitslag $r_prev = $r_revs[$r_index + 1]; 1447baf0c3e5SGerrit Uitslag $r_next = $r_revs[$r_index - 1]; 1448621bbd2aSGerrit Uitslag } else { 1449621bbd2aSGerrit Uitslag //removed page 1450621bbd2aSGerrit Uitslag if ($l_next) { 1451621bbd2aSGerrit Uitslag $r_prev = $r_revs[0]; 1452621bbd2aSGerrit Uitslag } else { 1453621bbd2aSGerrit Uitslag $r_prev = null; 1454621bbd2aSGerrit Uitslag } 1455621bbd2aSGerrit Uitslag $r_next = null; 1456621bbd2aSGerrit Uitslag } 1457baf0c3e5SGerrit Uitslag 1458baf0c3e5SGerrit Uitslag /* 1459baf0c3e5SGerrit Uitslag * Left side: 1460baf0c3e5SGerrit Uitslag */ 1461baf0c3e5SGerrit Uitslag $l_nav = ''; 1462baf0c3e5SGerrit Uitslag //move back 1463baf0c3e5SGerrit Uitslag if ($l_prev) { 1464baf0c3e5SGerrit Uitslag $l_nav .= html_diff_navigationlink($type, 'diffbothprevrev', $l_prev, $r_prev); 1465baf0c3e5SGerrit Uitslag $l_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_prev, $r_rev); 1466baf0c3e5SGerrit Uitslag } 1467baf0c3e5SGerrit Uitslag //dropdown 1468baf0c3e5SGerrit Uitslag $form = new Doku_Form(array('action' => wl())); 1469baf0c3e5SGerrit Uitslag $form->addHidden('id', $ID); 1470baf0c3e5SGerrit Uitslag $form->addHidden('difftype', $type); 1471baf0c3e5SGerrit Uitslag $form->addHidden('rev2[1]', $r_rev); 1472baf0c3e5SGerrit Uitslag $form->addHidden('do', 'diff'); 1473baf0c3e5SGerrit Uitslag $form->addElement( 1474baf0c3e5SGerrit Uitslag form_makeListboxField( 1475baf0c3e5SGerrit Uitslag 'rev2[0]', 1476baf0c3e5SGerrit Uitslag $l_revisions, 1477baf0c3e5SGerrit Uitslag $l_rev, 1478baf0c3e5SGerrit Uitslag '', '', '', 1479baf0c3e5SGerrit Uitslag array('class' => 'quickselect') 1480baf0c3e5SGerrit Uitslag ) 1481baf0c3e5SGerrit Uitslag ); 1482baf0c3e5SGerrit Uitslag $form->addElement(form_makeButton('submit', 'diff', 'Go')); 1483baf0c3e5SGerrit Uitslag $l_nav .= $form->getForm(); 1484baf0c3e5SGerrit Uitslag //move forward 1485621bbd2aSGerrit Uitslag if ($l_next && ($l_next < $r_rev || !$r_rev)) { 1486baf0c3e5SGerrit Uitslag $l_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_next, $r_rev); 1487baf0c3e5SGerrit Uitslag } 1488baf0c3e5SGerrit Uitslag 1489baf0c3e5SGerrit Uitslag /* 1490baf0c3e5SGerrit Uitslag * Right side: 1491baf0c3e5SGerrit Uitslag */ 1492baf0c3e5SGerrit Uitslag $r_nav = ''; 1493baf0c3e5SGerrit Uitslag //move back 1494baf0c3e5SGerrit Uitslag if ($l_rev < $r_prev) { 1495baf0c3e5SGerrit Uitslag $r_nav .= html_diff_navigationlink($type, 'diffprevrev', $l_rev, $r_prev); 1496baf0c3e5SGerrit Uitslag } 1497baf0c3e5SGerrit Uitslag //dropdown 1498baf0c3e5SGerrit Uitslag $form = new Doku_Form(array('action' => wl())); 1499baf0c3e5SGerrit Uitslag $form->addHidden('id', $ID); 1500baf0c3e5SGerrit Uitslag $form->addHidden('rev2[0]', $l_rev); 1501baf0c3e5SGerrit Uitslag $form->addHidden('difftype', $type); 1502baf0c3e5SGerrit Uitslag $form->addHidden('do', 'diff'); 1503baf0c3e5SGerrit Uitslag $form->addElement( 1504baf0c3e5SGerrit Uitslag form_makeListboxField( 1505baf0c3e5SGerrit Uitslag 'rev2[1]', 1506baf0c3e5SGerrit Uitslag $r_revisions, 1507baf0c3e5SGerrit Uitslag $r_rev, 1508baf0c3e5SGerrit Uitslag '', '', '', 1509baf0c3e5SGerrit Uitslag array('class' => 'quickselect') 1510baf0c3e5SGerrit Uitslag ) 1511baf0c3e5SGerrit Uitslag ); 1512baf0c3e5SGerrit Uitslag $form->addElement(form_makeButton('submit', 'diff', 'Go')); 1513baf0c3e5SGerrit Uitslag $r_nav .= $form->getForm(); 1514baf0c3e5SGerrit Uitslag //move forward 1515baf0c3e5SGerrit Uitslag if ($r_next) { 1516baf0c3e5SGerrit Uitslag if ($pagelog->isCurrentRevision($r_next)) { 1517baf0c3e5SGerrit Uitslag $r_nav .= html_diff_navigationlink($type, 'difflastrev', $l_rev); //last revision is diff with current page 1518baf0c3e5SGerrit Uitslag } else { 1519baf0c3e5SGerrit Uitslag $r_nav .= html_diff_navigationlink($type, 'diffnextrev', $l_rev, $r_next); 1520baf0c3e5SGerrit Uitslag } 1521baf0c3e5SGerrit Uitslag $r_nav .= html_diff_navigationlink($type, 'diffbothnextrev', $l_next, $r_next); 1522baf0c3e5SGerrit Uitslag } 1523baf0c3e5SGerrit Uitslag return array($l_nav, $r_nav); 1524baf0c3e5SGerrit Uitslag} 1525baf0c3e5SGerrit Uitslag 1526baf0c3e5SGerrit Uitslag/** 15274fc1354aSGerrit Uitslag * Create html link to a diff defined by two revisions 15284fc1354aSGerrit Uitslag * 152998a6b214SAnika Henke * @param string $difftype display type 153098a6b214SAnika Henke * @param string $linktype 15314fc1354aSGerrit Uitslag * @param int $lrev oldest revision 15324fc1354aSGerrit Uitslag * @param int $rrev newest revision or null for diff with current revision 15334fc1354aSGerrit Uitslag * @return string html of link to a diff 15344fc1354aSGerrit Uitslag */ 153598a6b214SAnika Henkefunction html_diff_navigationlink($difftype, $linktype, $lrev, $rrev = null) { 153698a6b214SAnika Henke global $ID, $lang; 1537621bbd2aSGerrit Uitslag if (!$rrev) { 15384fc1354aSGerrit Uitslag $urlparam = array( 15394fc1354aSGerrit Uitslag 'do' => 'diff', 15404fc1354aSGerrit Uitslag 'rev' => $lrev, 154198a6b214SAnika Henke 'difftype' => $difftype, 15424fc1354aSGerrit Uitslag ); 15434fc1354aSGerrit Uitslag } else { 15444fc1354aSGerrit Uitslag $urlparam = array( 15454fc1354aSGerrit Uitslag 'do' => 'diff', 15464fc1354aSGerrit Uitslag 'rev2[0]' => $lrev, 15474fc1354aSGerrit Uitslag 'rev2[1]' => $rrev, 154898a6b214SAnika Henke 'difftype' => $difftype, 15494fc1354aSGerrit Uitslag ); 15504fc1354aSGerrit Uitslag } 1551*5a25e725SSatoshi Sahara return '<a class="'. $linktype .'" href="'. wl($ID, $urlparam) .'" title="'. $lang[$linktype] .'">' 1552*5a25e725SSatoshi Sahara . '<span>'. $lang[$linktype] .'</span>' 1553*5a25e725SSatoshi Sahara . '</a>'. DOKU_LF; 15544fc1354aSGerrit Uitslag} 15554fc1354aSGerrit Uitslag 1556a8397511SGerrit Uitslag/** 1557a8397511SGerrit Uitslag * Insert soft breaks in diff html 1558a8397511SGerrit Uitslag * 155942ea7f44SGerrit Uitslag * @param string $diffhtml 1560a8397511SGerrit Uitslag * @return string 1561a8397511SGerrit Uitslag */ 1562fcfecb69SChristopher Smithfunction html_insert_softbreaks($diffhtml) { 1563fcfecb69SChristopher Smith // search the diff html string for both: 1564fcfecb69SChristopher Smith // - html tags, so these can be ignored 1565fcfecb69SChristopher Smith // - long strings of characters without breaking characters 1566fcfecb69SChristopher Smith return preg_replace_callback('/<[^>]*>|[^<> ]{12,}/','html_softbreak_callback',$diffhtml); 1567fcfecb69SChristopher Smith} 1568fcfecb69SChristopher Smith 1569a8397511SGerrit Uitslag/** 1570a8397511SGerrit Uitslag * callback which adds softbreaks 1571a8397511SGerrit Uitslag * 1572a8397511SGerrit Uitslag * @param array $match array with first the complete match 1573a8397511SGerrit Uitslag * @return string the replacement 1574a8397511SGerrit Uitslag */ 1575fcfecb69SChristopher Smithfunction html_softbreak_callback($match){ 1576fcfecb69SChristopher Smith // if match is an html tag, return it intact 15772401f18dSSyntaxseed if ($match[0][0] == '<') return $match[0]; 1578fcfecb69SChristopher Smith 1579fcfecb69SChristopher Smith // its a long string without a breaking character, 1580fcfecb69SChristopher Smith // make certain characters into breaking characters by inserting a 158154436b19Sbleistivt // word break opportunity (<wbr> tag) in front of them. 1582fcfecb69SChristopher Smith $regex = <<< REGEX 1583fcfecb69SChristopher Smith(?(?= # start a conditional expression with a positive look ahead ... 1584298a7e08SChristopher Smith&\#?\\w{1,6};) # ... for html entities - we don't want to split them (ok to catch some invalid combinations) 1585298a7e08SChristopher Smith&\#?\\w{1,6}; # yes pattern - a quicker match for the html entity, since we know we have one 1586fcfecb69SChristopher Smith| 158707a7d21aSChristopher Smith[?/,&\#;:] # no pattern - any other group of 'special' characters to insert a breaking character after 158807a7d21aSChristopher Smith)+ # end conditional expression 1589fcfecb69SChristopher SmithREGEX; 1590fcfecb69SChristopher Smith 159154436b19Sbleistivt return preg_replace('<'.$regex.'>xu','\0<wbr>',$match[0]); 1592fcfecb69SChristopher Smith} 1593fcfecb69SChristopher Smith 159415fae107Sandi/** 159515fae107Sandi * show warning on conflict detection 159615fae107Sandi * 159715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 159842ea7f44SGerrit Uitslag * 159942ea7f44SGerrit Uitslag * @param string $text 160042ea7f44SGerrit Uitslag * @param string $summary 160115fae107Sandi */ 1602f3f0262cSandifunction html_conflict($text,$summary){ 1603f3f0262cSandi global $ID; 1604f3f0262cSandi global $lang; 1605f3f0262cSandi 1606c112d578Sandi print p_locale_xhtml('conflict'); 1607e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 1608fdb8d77bSTom N Harris $form->addHidden('id', $ID); 1609fdb8d77bSTom N Harris $form->addHidden('wikitext', $text); 1610fdb8d77bSTom N Harris $form->addHidden('summary', $summary); 1611fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'save', $lang['btn_save'], array('accesskey'=>'s'))); 1612fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'])); 1613fdb8d77bSTom N Harris html_form('conflict', $form); 1614fdb8d77bSTom N Harris print '<br /><br /><br /><br />'.NL; 1615f3f0262cSandi} 1616f3f0262cSandi 1617f3f0262cSandi/** 161815fae107Sandi * Prints the global message array 161915fae107Sandi * 162015fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1621f3f0262cSandi */ 1622f3f0262cSandifunction html_msgarea(){ 1623cc58224cSMichael Hamann global $MSG, $MSG_shown; 16248d5e837eSMichael Hamann /** @var array $MSG */ 1625cc58224cSMichael Hamann // store if the global $MSG has already been shown and thus HTML output has been started 1626cc58224cSMichael Hamann $MSG_shown = true; 1627cc58224cSMichael Hamann 1628f3f0262cSandi if(!isset($MSG)) return; 1629f3f0262cSandi 16304af9f0d4SAndreas Gohr $shown = array(); 1631f3f0262cSandi foreach($MSG as $msg){ 16324af9f0d4SAndreas Gohr $hash = md5($msg['msg']); 16334af9f0d4SAndreas Gohr if(isset($shown[$hash])) continue; // skip double messages 1634f755f9abSChristopher Smith if(info_msg_allowed($msg)){ 1635f3f0262cSandi print '<div class="'.$msg['lvl'].'">'; 1636f3f0262cSandi print $msg['msg']; 1637f3f0262cSandi print '</div>'; 1638d3bae478SChristopher Smith } 16394af9f0d4SAndreas Gohr $shown[$hash] = 1; 1640f3f0262cSandi } 1641cc58224cSMichael Hamann 1642cc58224cSMichael Hamann unset($GLOBALS['MSG']); 1643f3f0262cSandi} 1644f3f0262cSandi 1645f3f0262cSandi/** 1646f3f0262cSandi * Prints the registration form 164715fae107Sandi * 164815fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 1649f3f0262cSandi */ 1650f3f0262cSandifunction html_register(){ 1651f3f0262cSandi global $lang; 1652cab2716aSmatthias.grimm global $conf; 1653f0859d4bSTom N Harris global $INPUT; 1654f3f0262cSandi 1655a669bfe0SChristopher Smith $base_attrs = array('size'=>50,'required'=>'required'); 1656a669bfe0SChristopher Smith $email_attrs = $base_attrs + array('type'=>'email','class'=>'edit'); 1657a669bfe0SChristopher Smith 1658c112d578Sandi print p_locale_xhtml('register'); 1659fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 1660e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__register')); 1661bf413a4eSAnika Henke $form->startFieldset($lang['btn_register']); 1662fdb8d77bSTom N Harris $form->addHidden('do', 'register'); 1663fdb8d77bSTom N Harris $form->addHidden('save', '1'); 166464159a61SAndreas Gohr $form->addElement( 166564159a61SAndreas Gohr form_makeTextField( 166664159a61SAndreas Gohr 'login', 166764159a61SAndreas Gohr $INPUT->post->str('login'), 166864159a61SAndreas Gohr $lang['user'], 166964159a61SAndreas Gohr '', 167064159a61SAndreas Gohr 'block', 167164159a61SAndreas Gohr $base_attrs 167264159a61SAndreas Gohr ) 167364159a61SAndreas Gohr ); 1674cab2716aSmatthias.grimm if (!$conf['autopasswd']) { 1675a669bfe0SChristopher Smith $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', $base_attrs)); 1676a669bfe0SChristopher Smith $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', $base_attrs)); 1677cab2716aSmatthias.grimm } 167864159a61SAndreas Gohr $form->addElement( 167964159a61SAndreas Gohr form_makeTextField( 168064159a61SAndreas Gohr 'fullname', 168164159a61SAndreas Gohr $INPUT->post->str('fullname'), 168264159a61SAndreas Gohr $lang['fullname'], 168364159a61SAndreas Gohr '', 168464159a61SAndreas Gohr 'block', 168564159a61SAndreas Gohr $base_attrs 168664159a61SAndreas Gohr ) 168764159a61SAndreas Gohr ); 168864159a61SAndreas Gohr $form->addElement( 168964159a61SAndreas Gohr form_makeField( 169064159a61SAndreas Gohr 'email', 169164159a61SAndreas Gohr 'email', 169264159a61SAndreas Gohr $INPUT->post->str('email'), 169364159a61SAndreas Gohr $lang['email'], 169464159a61SAndreas Gohr '', 169564159a61SAndreas Gohr 'block', 169664159a61SAndreas Gohr $email_attrs 169764159a61SAndreas Gohr ) 169864159a61SAndreas Gohr ); 1699bf413a4eSAnika Henke $form->addElement(form_makeButton('submit', '', $lang['btn_register'])); 1700fdb8d77bSTom N Harris $form->endFieldset(); 1701fdb8d77bSTom N Harris html_form('register', $form); 1702cab2716aSmatthias.grimm 1703fdb8d77bSTom N Harris print '</div>'.NL; 1704f3f0262cSandi} 1705f3f0262cSandi 1706f3f0262cSandi/** 17078b06d178Schris * Print the update profile form 17088b06d178Schris * 17098b06d178Schris * @author Christopher Smith <chris@jalakai.co.uk> 17108b06d178Schris * @author Andreas Gohr <andi@splitbrain.org> 17118b06d178Schris */ 17128b06d178Schrisfunction html_updateprofile(){ 17138b06d178Schris global $lang; 17148b06d178Schris global $conf; 1715f0859d4bSTom N Harris global $INPUT; 17168b06d178Schris global $INFO; 1717e1d9dcc8SAndreas Gohr /** @var AuthPlugin $auth */ 171882fd59b6SAndreas Gohr global $auth; 17198b06d178Schris 17208b06d178Schris print p_locale_xhtml('updateprofile'); 17213b1338ffSChristopher Smith print '<div class="centeralign">'.NL; 17228b06d178Schris 1723f0859d4bSTom N Harris $fullname = $INPUT->post->str('fullname', $INFO['userinfo']['name'], true); 1724f0859d4bSTom N Harris $email = $INPUT->post->str('email', $INFO['userinfo']['mail'], true); 1725e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__register')); 1726fdb8d77bSTom N Harris $form->startFieldset($lang['profile']); 1727fdb8d77bSTom N Harris $form->addHidden('do', 'profile'); 1728fdb8d77bSTom N Harris $form->addHidden('save', '1'); 172964159a61SAndreas Gohr $form->addElement( 173064159a61SAndreas Gohr form_makeTextField( 173164159a61SAndreas Gohr 'login', 173264159a61SAndreas Gohr $_SERVER['REMOTE_USER'], 173364159a61SAndreas Gohr $lang['user'], 173464159a61SAndreas Gohr '', 173564159a61SAndreas Gohr 'block', 173664159a61SAndreas Gohr array('size' => '50', 'disabled' => 'disabled') 173764159a61SAndreas Gohr ) 173864159a61SAndreas Gohr ); 1739fdb8d77bSTom N Harris $attr = array('size'=>'50'); 1740fdb8d77bSTom N Harris if (!$auth->canDo('modName')) $attr['disabled'] = 'disabled'; 1741f0859d4bSTom N Harris $form->addElement(form_makeTextField('fullname', $fullname, $lang['fullname'], '', 'block', $attr)); 17423b1338ffSChristopher Smith $attr = array('size'=>'50', 'class'=>'edit'); 174339ba8890SAndreas Gohr if (!$auth->canDo('modMail')) $attr['disabled'] = 'disabled'; 17443b1338ffSChristopher Smith $form->addElement(form_makeField('email','email', $email, $lang['email'], '', 'block', $attr)); 1745fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 1746fdb8d77bSTom N Harris if ($auth->canDo('modPass')) { 1747fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('newpass', $lang['newpass'], '', 'block', array('size'=>'50'))); 1748fdb8d77bSTom N Harris $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 1749fdb8d77bSTom N Harris } 1750fdb8d77bSTom N Harris if ($conf['profileconfirm']) { 1751fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 175264159a61SAndreas Gohr $form->addElement( 175364159a61SAndreas Gohr form_makePasswordField( 175464159a61SAndreas Gohr 'oldpass', 175564159a61SAndreas Gohr $lang['oldpass'], 175664159a61SAndreas Gohr '', 175764159a61SAndreas Gohr 'block', 175864159a61SAndreas Gohr array('size' => '50', 'required' => 'required') 175964159a61SAndreas Gohr ) 176064159a61SAndreas Gohr ); 1761fdb8d77bSTom N Harris } 1762fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_save'])); 1763fdb8d77bSTom N Harris $form->addElement(form_makeButton('reset', '', $lang['btn_reset'])); 17643b1338ffSChristopher Smith 1765fdb8d77bSTom N Harris $form->endFieldset(); 1766fdb8d77bSTom N Harris html_form('updateprofile', $form); 17672a7abf2dSChristopher Smith 17682a7abf2dSChristopher Smith if ($auth->canDo('delUser') && actionOK('profile_delete')) { 17692a7abf2dSChristopher Smith $form_profiledelete = new Doku_Form(array('id' => 'dw__profiledelete')); 17702a7abf2dSChristopher Smith $form_profiledelete->startFieldset($lang['profdeleteuser']); 17712a7abf2dSChristopher Smith $form_profiledelete->addHidden('do', 'profile_delete'); 17722a7abf2dSChristopher Smith $form_profiledelete->addHidden('delete', '1'); 177364159a61SAndreas Gohr $form_profiledelete->addElement( 177464159a61SAndreas Gohr form_makeCheckboxField( 177564159a61SAndreas Gohr 'confirm_delete', 177664159a61SAndreas Gohr '1', 177764159a61SAndreas Gohr $lang['profconfdelete'], 177864159a61SAndreas Gohr 'dw__confirmdelete', 177964159a61SAndreas Gohr '', 178064159a61SAndreas Gohr array('required' => 'required') 178164159a61SAndreas Gohr ) 178264159a61SAndreas Gohr ); 17832a7abf2dSChristopher Smith if ($conf['profileconfirm']) { 17842a7abf2dSChristopher Smith $form_profiledelete->addElement(form_makeTag('br')); 178564159a61SAndreas Gohr $form_profiledelete->addElement( 178664159a61SAndreas Gohr form_makePasswordField( 178764159a61SAndreas Gohr 'oldpass', 178864159a61SAndreas Gohr $lang['oldpass'], 178964159a61SAndreas Gohr '', 179064159a61SAndreas Gohr 'block', 179164159a61SAndreas Gohr array('size' => '50', 'required' => 'required') 179264159a61SAndreas Gohr ) 179364159a61SAndreas Gohr ); 17942a7abf2dSChristopher Smith } 17952a7abf2dSChristopher Smith $form_profiledelete->addElement(form_makeButton('submit', '', $lang['btn_deleteuser'])); 17962a7abf2dSChristopher Smith $form_profiledelete->endFieldset(); 17972a7abf2dSChristopher Smith 17982a7abf2dSChristopher Smith html_form('profiledelete', $form_profiledelete); 17992a7abf2dSChristopher Smith } 18002a7abf2dSChristopher Smith 1801fdb8d77bSTom N Harris print '</div>'.NL; 18028b06d178Schris} 18038b06d178Schris 18048b06d178Schris/** 18057c4635c4SAdrian Lang * Preprocess edit form data 180615fae107Sandi * 180715fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 18082ffea8f2SAdrian Lang * 18092ffea8f2SAdrian Lang * @triggers HTML_EDITFORM_OUTPUT 1810f3f0262cSandi */ 18115a932e77SAdrian Langfunction html_edit(){ 1812f0859d4bSTom N Harris global $INPUT; 1813f3f0262cSandi global $ID; 1814f3f0262cSandi global $REV; 1815f3f0262cSandi global $DATE; 1816f3f0262cSandi global $PRE; 1817f3f0262cSandi global $SUF; 1818f3f0262cSandi global $INFO; 1819f3f0262cSandi global $SUM; 1820f3f0262cSandi global $lang; 1821f3f0262cSandi global $conf; 182245a99335SAdrian Lang global $TEXT; 1823f3f0262cSandi 1824f0859d4bSTom N Harris if ($INPUT->has('changecheck')) { 1825f0859d4bSTom N Harris $check = $INPUT->str('changecheck'); 182645a99335SAdrian Lang } elseif(!$INFO['exists']){ 182745a99335SAdrian Lang // $TEXT has been loaded from page template 182845a99335SAdrian Lang $check = md5(''); 18298fe3bb00STom N Harris } else { 183045a99335SAdrian Lang $check = md5($TEXT); 18318fe3bb00STom N Harris } 183245a99335SAdrian Lang $mod = md5($TEXT) !== $check; 1833f3f0262cSandi 183427eb9321SAnika Henke $wr = $INFO['writable'] && !$INFO['locked']; 183545a99335SAdrian Lang $include = 'edit'; 1836f3f0262cSandi if($wr){ 1837ffde0ac9SAdrian Lang if ($REV) $include = 'editrev'; 1838f3f0262cSandi }else{ 1839409d7af7SAndreas Gohr // check pseudo action 'source' 1840409d7af7SAndreas Gohr if(!actionOK('source')){ 1841409d7af7SAndreas Gohr msg('Command disabled: source',-1); 1842409d7af7SAndreas Gohr return; 1843409d7af7SAndreas Gohr } 1844ffde0ac9SAdrian Lang $include = 'read'; 1845f3f0262cSandi } 18467c4635c4SAdrian Lang 18477c4635c4SAdrian Lang global $license; 184842c7abd6SAndreas Gohr 1849e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__editform')); 1850fdb8d77bSTom N Harris $form->addHidden('id', $ID); 1851fdb8d77bSTom N Harris $form->addHidden('rev', $REV); 1852fdb8d77bSTom N Harris $form->addHidden('date', $DATE); 185342de51b1SAdrian Lang $form->addHidden('prefix', $PRE . '.'); 1854fdb8d77bSTom N Harris $form->addHidden('suffix', $SUF); 1855fdb8d77bSTom N Harris $form->addHidden('changecheck', $check); 18568e4da260SAdrian Lang 18572ffea8f2SAdrian Lang $data = array('form' => $form, 18582ffea8f2SAdrian Lang 'wr' => $wr, 18592ffea8f2SAdrian Lang 'media_manager' => true, 1860182ac905SAndreas Gohr 'target' => ($INPUT->has('target') && $wr) ? $INPUT->str('target') : 'section', 18612ffea8f2SAdrian Lang 'intro_locale' => $include); 186212c96aceSAdrian Lang 186312c96aceSAdrian Lang if ($data['target'] !== 'section') { 186412c96aceSAdrian Lang // Only emit event if page is writable, section edit data is valid and 186512c96aceSAdrian Lang // edit target is not section. 1866cbb44eabSAndreas Gohr Event::createAndTrigger('HTML_EDIT_FORMSELECTION', $data, 'html_edit_form', true); 18672ffea8f2SAdrian Lang } else { 18682ffea8f2SAdrian Lang html_edit_form($data); 18692ffea8f2SAdrian Lang } 1870ffde0ac9SAdrian Lang if (isset($data['intro_locale'])) { 1871ffde0ac9SAdrian Lang echo p_locale_xhtml($data['intro_locale']); 1872ffde0ac9SAdrian Lang } 18738e4da260SAdrian Lang 1874b7eccc60SAdrian Lang $form->addHidden('target', $data['target']); 18752571786cSLarsDW223 if ($INPUT->has('hid')) { 18762571786cSLarsDW223 $form->addHidden('hid', $INPUT->str('hid')); 18772571786cSLarsDW223 } 1878ec57f119SLarsDW223 if ($INPUT->has('codeblockOffset')) { 1879ec57f119SLarsDW223 $form->addHidden('codeblockOffset', $INPUT->str('codeblockOffset')); 1880ec57f119SLarsDW223 } 18810607bfeeSAnika Henke $form->addElement(form_makeOpenTag('div', array('id'=>'wiki__editbar', 'class'=>'editBar'))); 1882fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('id'=>'size__ctl'))); 1883fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1884fdb8d77bSTom N Harris if ($wr) { 1885fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'editButtons'))); 188664159a61SAndreas Gohr $form->addElement( 188764159a61SAndreas Gohr form_makeButton( 188864159a61SAndreas Gohr 'submit', 188964159a61SAndreas Gohr 'save', 189064159a61SAndreas Gohr $lang['btn_save'], 189164159a61SAndreas Gohr array('id' => 'edbtn__save', 'accesskey' => 's', 'tabindex' => '4') 189264159a61SAndreas Gohr ) 189364159a61SAndreas Gohr ); 189464159a61SAndreas Gohr $form->addElement( 189564159a61SAndreas Gohr form_makeButton( 189664159a61SAndreas Gohr 'submit', 189764159a61SAndreas Gohr 'preview', 189864159a61SAndreas Gohr $lang['btn_preview'], 189964159a61SAndreas Gohr array('id' => 'edbtn__preview', 'accesskey' => 'p', 'tabindex' => '5') 190064159a61SAndreas Gohr ) 190164159a61SAndreas Gohr ); 19023f5c3c1eSAndreas Gohr $form->addElement(form_makeButton('submit', 'cancel', $lang['btn_cancel'], array('tabindex'=>'6'))); 1903fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1904fdb8d77bSTom N Harris $form->addElement(form_makeOpenTag('div', array('class'=>'summary'))); 190564159a61SAndreas Gohr $form->addElement( 190664159a61SAndreas Gohr form_makeTextField( 190764159a61SAndreas Gohr 'summary', 190864159a61SAndreas Gohr $SUM, 190964159a61SAndreas Gohr $lang['summary'], 191064159a61SAndreas Gohr 'edit__summary', 191164159a61SAndreas Gohr 'nowrap', 191264159a61SAndreas Gohr array('size' => '50', 'tabindex' => '2') 191364159a61SAndreas Gohr ) 191464159a61SAndreas Gohr ); 1915fdb8d77bSTom N Harris $elem = html_minoredit(); 1916fdb8d77bSTom N Harris if ($elem) $form->addElement($elem); 1917fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 1918fdb8d77bSTom N Harris } 1919fdb8d77bSTom N Harris $form->addElement(form_makeCloseTag('div')); 19205808bc54SAndreas Gohr if($wr && $conf['license']){ 1921066fee30SAndreas Gohr $form->addElement(form_makeOpenTag('div', array('class'=>'license'))); 1922066fee30SAndreas Gohr $out = $lang['licenseok']; 1923066fee30SAndreas Gohr $out .= ' <a href="'.$license[$conf['license']]['url'].'" rel="license" class="urlextern"'; 1924507a2aebSAnika Henke if($conf['target']['extern']) $out .= ' target="'.$conf['target']['extern'].'"'; 1925066fee30SAndreas Gohr $out .= '>'.$license[$conf['license']]['name'].'</a>'; 1926066fee30SAndreas Gohr $form->addElement($out); 1927066fee30SAndreas Gohr $form->addElement(form_makeCloseTag('div')); 1928066fee30SAndreas Gohr } 19298e4da260SAdrian Lang 19308e4da260SAdrian Lang if ($wr) { 19318e4da260SAdrian Lang // sets changed to true when previewed 193259305168SPhy echo '<script>/*<![CDATA[*/'. NL; 19338e4da260SAdrian Lang echo 'textChanged = ' . ($mod ? 'true' : 'false'); 1934677d2785SDominik Eckelmann echo '/*!]]>*/</script>' . NL; 19358e4da260SAdrian Lang } ?> 19365a99d25bSAnika Henke <div class="editBox" role="application"> 19378e4da260SAdrian Lang 19388a65ef2eSAnika Henke <div class="toolbar group"> 193964159a61SAndreas Gohr <div id="tool__bar" class="tool__bar"><?php 194064159a61SAndreas Gohr if ($wr && $data['media_manager']){ 194164159a61SAndreas Gohr ?><a href="<?php echo DOKU_BASE?>lib/exe/mediamanager.php?ns=<?php echo $INFO['namespace']?>" 194264159a61SAndreas Gohr target="_blank"><?php echo $lang['mediaselect'] ?></a><?php 19439ddafcedSAndreas Gohr }?> 19449ddafcedSAndreas Gohr </div> 1945c49e647bSMichael Große </div> 19460aabe6f8SMichael Große <div id="draft__status" class="draft__status"> 19470aabe6f8SMichael Große <?php 19480aabe6f8SMichael Große $draft = new \dokuwiki\Draft($ID, $INFO['client']); 19490aabe6f8SMichael Große if ($draft->isDraftAvailable()) { 19500aabe6f8SMichael Große echo $draft->getDraftMessage(); 19510aabe6f8SMichael Große } 19520aabe6f8SMichael Große ?> 19538e4da260SAdrian Lang </div> 19548e4da260SAdrian Lang <?php 19558e4da260SAdrian Lang 1956fdb8d77bSTom N Harris html_form('edit', $form); 1957fdb8d77bSTom N Harris print '</div>'.NL; 1958f3f0262cSandi} 1959f3f0262cSandi 1960f3f0262cSandi/** 19618e4da260SAdrian Lang * Display the default edit form 19628e4da260SAdrian Lang * 19638e4da260SAdrian Lang * Is the default action for HTML_EDIT_FORMSELECTION. 196442ea7f44SGerrit Uitslag * 1965baf0c3e5SGerrit Uitslag * @param mixed[] $param 19668e4da260SAdrian Lang */ 19678e4da260SAdrian Langfunction html_edit_form($param) { 196845a99335SAdrian Lang global $TEXT; 196912c96aceSAdrian Lang 197012c96aceSAdrian Lang if ($param['target'] !== 'section') { 1971ff711734SAndreas Gohr msg('No editor for edit target ' . hsc($param['target']) . ' found.', -1); 197212c96aceSAdrian Lang } 197312c96aceSAdrian Lang 19748e4da260SAdrian Lang $attr = array('tabindex'=>'1'); 197512c96aceSAdrian Lang if (!$param['wr']) $attr['readonly'] = 'readonly'; 197612c96aceSAdrian Lang 197712c96aceSAdrian Lang $param['form']->addElement(form_makeWikiText($TEXT, $attr)); 19788e4da260SAdrian Lang} 19798e4da260SAdrian Lang 19808e4da260SAdrian Lang/** 1981b6912aeaSAndreas Gohr * Adds a checkbox for minor edits for logged in users 1982b6912aeaSAndreas Gohr * 1983b1f92db2SAdrian Lang * @author Andreas Gohr <andi@splitbrain.org> 198442ea7f44SGerrit Uitslag * 198542ea7f44SGerrit Uitslag * @return array|bool 1986b6912aeaSAndreas Gohr */ 1987b6912aeaSAndreas Gohrfunction html_minoredit(){ 1988b6912aeaSAndreas Gohr global $conf; 1989b6912aeaSAndreas Gohr global $lang; 1990f0859d4bSTom N Harris global $INPUT; 1991b6912aeaSAndreas Gohr // minor edits are for logged in users only 1992b6912aeaSAndreas Gohr if(!$conf['useacl'] || !$_SERVER['REMOTE_USER']){ 1993fdb8d77bSTom N Harris return false; 1994b6912aeaSAndreas Gohr } 1995b6912aeaSAndreas Gohr 1996b6912aeaSAndreas Gohr $p = array(); 1997b6912aeaSAndreas Gohr $p['tabindex'] = 3; 1998f0859d4bSTom N Harris if($INPUT->bool('minor')) $p['checked']='checked'; 1999fdb8d77bSTom N Harris return form_makeCheckboxField('minor', '1', $lang['minoredit'], 'minoredit', 'nowrap', $p); 2000b6912aeaSAndreas Gohr} 2001b6912aeaSAndreas Gohr 2002b6912aeaSAndreas Gohr/** 2003f3f0262cSandi * prints some debug info 200415fae107Sandi * 200515fae107Sandi * @author Andreas Gohr <andi@splitbrain.org> 2006f3f0262cSandi */ 2007f3f0262cSandifunction html_debug(){ 2008f3f0262cSandi global $conf; 2009d16a4edaSandi global $lang; 2010e1d9dcc8SAndreas Gohr /** @var AuthPlugin $auth */ 20115298a619SAndreas Gohr global $auth; 2012100a97e3SAndreas Gohr global $INFO; 2013100a97e3SAndreas Gohr 201428fb55ffSandi //remove sensitive data 201528fb55ffSandi $cnf = $conf; 201624297a69SAndreas Gohr debug_guard($cnf); 2017100a97e3SAndreas Gohr $nfo = $INFO; 201824297a69SAndreas Gohr debug_guard($nfo); 2019100a97e3SAndreas Gohr $ses = $_SESSION; 202024297a69SAndreas Gohr debug_guard($ses); 2021f3f0262cSandi 2022f3f0262cSandi print '<html><body>'; 2023f3f0262cSandi 2024f3f0262cSandi print '<p>When reporting bugs please send all the following '; 2025f3f0262cSandi print 'output as a mail to andi@splitbrain.org '; 2026f3f0262cSandi print 'The best way to do this is to save this page in your browser</p>'; 2027f3f0262cSandi 2028100a97e3SAndreas Gohr print '<b>$INFO:</b><pre>'; 2029100a97e3SAndreas Gohr print_r($nfo); 2030100a97e3SAndreas Gohr print '</pre>'; 2031100a97e3SAndreas Gohr 2032f3f0262cSandi print '<b>$_SERVER:</b><pre>'; 2033f3f0262cSandi print_r($_SERVER); 2034f3f0262cSandi print '</pre>'; 2035f3f0262cSandi 2036f3f0262cSandi print '<b>$conf:</b><pre>'; 203728fb55ffSandi print_r($cnf); 2038f3f0262cSandi print '</pre>'; 2039f3f0262cSandi 2040ed7b5f09Sandi print '<b>DOKU_BASE:</b><pre>'; 2041ed7b5f09Sandi print DOKU_BASE; 2042f3f0262cSandi print '</pre>'; 2043f3f0262cSandi 2044ed7b5f09Sandi print '<b>abs DOKU_BASE:</b><pre>'; 2045ed7b5f09Sandi print DOKU_URL; 2046ed7b5f09Sandi print '</pre>'; 2047ed7b5f09Sandi 2048ed7b5f09Sandi print '<b>rel DOKU_BASE:</b><pre>'; 2049f3f0262cSandi print dirname($_SERVER['PHP_SELF']).'/'; 2050f3f0262cSandi print '</pre>'; 2051f3f0262cSandi 2052f3f0262cSandi print '<b>PHP Version:</b><pre>'; 2053f3f0262cSandi print phpversion(); 2054f3f0262cSandi print '</pre>'; 2055f3f0262cSandi 2056f3f0262cSandi print '<b>locale:</b><pre>'; 2057f3f0262cSandi print setlocale(LC_ALL,0); 2058f3f0262cSandi print '</pre>'; 2059f3f0262cSandi 2060d16a4edaSandi print '<b>encoding:</b><pre>'; 2061d16a4edaSandi print $lang['encoding']; 2062d16a4edaSandi print '</pre>'; 2063d16a4edaSandi 20645298a619SAndreas Gohr if($auth){ 20655298a619SAndreas Gohr print '<b>Auth backend capabilities:</b><pre>'; 20662f46ade0SChristopher Smith foreach ($auth->getCapabilities() as $cando){ 20672f46ade0SChristopher Smith print ' '.str_pad($cando,16) . ' => ' . (int)$auth->canDo($cando) . NL; 20682f46ade0SChristopher Smith } 20695298a619SAndreas Gohr print '</pre>'; 20705298a619SAndreas Gohr } 20715298a619SAndreas Gohr 20723aa54d7cSAndreas Gohr print '<b>$_SESSION:</b><pre>'; 2073100a97e3SAndreas Gohr print_r($ses); 20743aa54d7cSAndreas Gohr print '</pre>'; 20753aa54d7cSAndreas Gohr 2076f3f0262cSandi print '<b>Environment:</b><pre>'; 2077f3f0262cSandi print_r($_ENV); 2078f3f0262cSandi print '</pre>'; 2079f3f0262cSandi 2080f3f0262cSandi print '<b>PHP settings:</b><pre>'; 2081f3f0262cSandi $inis = ini_get_all(); 2082f3f0262cSandi print_r($inis); 2083f3f0262cSandi print '</pre>'; 2084f3f0262cSandi 2085e89b7c1eSChristopher Smith if (function_exists('apache_get_version')) { 208659bc3b48SGerrit Uitslag $apache = array(); 2087e89b7c1eSChristopher Smith $apache['version'] = apache_get_version(); 2088e89b7c1eSChristopher Smith 2089e89b7c1eSChristopher Smith if (function_exists('apache_get_modules')) { 2090e89b7c1eSChristopher Smith $apache['modules'] = apache_get_modules(); 2091e89b7c1eSChristopher Smith } 2092e89b7c1eSChristopher Smith print '<b>Apache</b><pre>'; 2093e89b7c1eSChristopher Smith print_r($apache); 2094e89b7c1eSChristopher Smith print '</pre>'; 2095e89b7c1eSChristopher Smith } 2096e89b7c1eSChristopher Smith 2097f3f0262cSandi print '</body></html>'; 2098f3f0262cSandi} 2099f3f0262cSandi 210010271ce4SAndreas Gohr/** 21018b06d178Schris * Form to request a new password for an existing account 21028b06d178Schris * 21038b06d178Schris * @author Benoit Chesneau <benoit@bchesneau.info> 2104cc204bbdSAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de> 210511e2ce22Schris */ 21068b06d178Schrisfunction html_resendpwd() { 21078b06d178Schris global $lang; 21088b06d178Schris global $conf; 2109f0859d4bSTom N Harris global $INPUT; 2110c19fe9c0Sandi 2111f0859d4bSTom N Harris $token = preg_replace('/[^a-f0-9]+/','',$INPUT->str('pwauth')); 2112cc204bbdSAndreas Gohr 2113cc204bbdSAndreas Gohr if(!$conf['autopasswd'] && $token){ 2114cc204bbdSAndreas Gohr print p_locale_xhtml('resetpwd'); 2115cc204bbdSAndreas Gohr print '<div class="centeralign">'.NL; 2116cc204bbdSAndreas Gohr $form = new Doku_Form(array('id' => 'dw__resendpwd')); 2117cc204bbdSAndreas Gohr $form->startFieldset($lang['btn_resendpwd']); 2118cc204bbdSAndreas Gohr $form->addHidden('token', $token); 2119cc204bbdSAndreas Gohr $form->addHidden('do', 'resendpwd'); 2120cc204bbdSAndreas Gohr 2121cc204bbdSAndreas Gohr $form->addElement(form_makePasswordField('pass', $lang['pass'], '', 'block', array('size'=>'50'))); 2122cc204bbdSAndreas Gohr $form->addElement(form_makePasswordField('passchk', $lang['passchk'], '', 'block', array('size'=>'50'))); 2123cc204bbdSAndreas Gohr 2124cc204bbdSAndreas Gohr $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 2125cc204bbdSAndreas Gohr $form->endFieldset(); 2126cc204bbdSAndreas Gohr html_form('resendpwd', $form); 2127cc204bbdSAndreas Gohr print '</div>'.NL; 2128cc204bbdSAndreas Gohr }else{ 21298b06d178Schris print p_locale_xhtml('resendpwd'); 2130fdb8d77bSTom N Harris print '<div class="centeralign">'.NL; 2131e351c80dSAdrian Lang $form = new Doku_Form(array('id' => 'dw__resendpwd')); 2132fdb8d77bSTom N Harris $form->startFieldset($lang['resendpwd']); 2133fdb8d77bSTom N Harris $form->addHidden('do', 'resendpwd'); 2134fdb8d77bSTom N Harris $form->addHidden('save', '1'); 2135fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 2136f0859d4bSTom N Harris $form->addElement(form_makeTextField('login', $INPUT->post->str('login'), $lang['user'], '', 'block')); 2137fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 2138fdb8d77bSTom N Harris $form->addElement(form_makeTag('br')); 2139fdb8d77bSTom N Harris $form->addElement(form_makeButton('submit', '', $lang['btn_resendpwd'])); 2140fdb8d77bSTom N Harris $form->endFieldset(); 2141fdb8d77bSTom N Harris html_form('resendpwd', $form); 2142fdb8d77bSTom N Harris print '</div>'.NL; 2143fdb8d77bSTom N Harris } 2144cc204bbdSAndreas Gohr} 2145cc204bbdSAndreas Gohr 2146fdb8d77bSTom N Harris/** 2147b8595a66SAndreas Gohr * Return the TOC rendered to XHTML 2148b8595a66SAndreas Gohr * 2149b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 215042ea7f44SGerrit Uitslag * 215142ea7f44SGerrit Uitslag * @param array $toc 215242ea7f44SGerrit Uitslag * @return string html 2153b8595a66SAndreas Gohr */ 2154b8595a66SAndreas Gohrfunction html_TOC($toc){ 2155b8595a66SAndreas Gohr if(!count($toc)) return ''; 2156b8595a66SAndreas Gohr global $lang; 2157b8595a66SAndreas Gohr $out = '<!-- TOC START -->'.DOKU_LF; 2158158a5bffSDeathCamel57 $out .= '<div id="dw__toc" class="dw__toc">'.DOKU_LF; 215948722ac8SAnika Henke $out .= '<h3 class="toggle">'; 2160b8595a66SAndreas Gohr $out .= $lang['toc']; 2161d5acc30dSAnika Henke $out .= '</h3>'.DOKU_LF; 2162d5acc30dSAnika Henke $out .= '<div>'.DOKU_LF; 216387671313SHakan Sandell $out .= html_buildlist($toc,'toc','html_list_toc','html_li_default',true); 2164b8595a66SAndreas Gohr $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 2165b8595a66SAndreas Gohr $out .= '<!-- TOC END -->'.DOKU_LF; 2166db959ae3SAndreas Gohr return $out; 2167db959ae3SAndreas Gohr} 2168b8595a66SAndreas Gohr 2169b8595a66SAndreas Gohr/** 2170b8595a66SAndreas Gohr * Callback for html_buildlist 217142ea7f44SGerrit Uitslag * 217242ea7f44SGerrit Uitslag * @param array $item 217342ea7f44SGerrit Uitslag * @return string html 2174b8595a66SAndreas Gohr */ 2175b8595a66SAndreas Gohrfunction html_list_toc($item){ 2176c66972f2SAdrian Lang if(isset($item['hid'])){ 21777d91652aSAndreas Gohr $link = '#'.$item['hid']; 21787d91652aSAndreas Gohr }else{ 21797d91652aSAndreas Gohr $link = $item['link']; 21807d91652aSAndreas Gohr } 21817d91652aSAndreas Gohr 2182d5acc30dSAnika Henke return '<a href="'.$link.'">'.hsc($item['title']).'</a>'; 2183b8595a66SAndreas Gohr} 2184b8595a66SAndreas Gohr 2185b8595a66SAndreas Gohr/** 2186b8595a66SAndreas Gohr * Helper function to build TOC items 2187b8595a66SAndreas Gohr * 2188b8595a66SAndreas Gohr * Returns an array ready to be added to a TOC array 2189b8595a66SAndreas Gohr * 2190b8595a66SAndreas Gohr * @param string $link - where to link (if $hash set to '#' it's a local anchor) 2191b8595a66SAndreas Gohr * @param string $text - what to display in the TOC 2192b8595a66SAndreas Gohr * @param int $level - nesting level 2193b8595a66SAndreas Gohr * @param string $hash - is prepended to the given $link, set blank if you want full links 21948d5e837eSMichael Hamann * @return array the toc item 2195b8595a66SAndreas Gohr */ 2196b8595a66SAndreas Gohrfunction html_mktocitem($link, $text, $level, $hash='#'){ 2197b8595a66SAndreas Gohr return array( 'link' => $hash.$link, 2198b8595a66SAndreas Gohr 'title' => $text, 2199b8595a66SAndreas Gohr 'type' => 'ul', 22002bb0d541Schris 'level' => $level); 2201b8595a66SAndreas Gohr} 2202b8595a66SAndreas Gohr 2203b8595a66SAndreas Gohr/** 2204fdb8d77bSTom N Harris * Output a Doku_Form object. 2205fdb8d77bSTom N Harris * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 2206fdb8d77bSTom N Harris * 2207fdb8d77bSTom N Harris * @author Tom N Harris <tnharris@whoopdedo.org> 220842ea7f44SGerrit Uitslag * 22098d5e837eSMichael Hamann * @param string $name The name of the form 22108d5e837eSMichael Hamann * @param Doku_Form $form The form 2211fdb8d77bSTom N Harris */ 2212fdb8d77bSTom N Harrisfunction html_form($name, &$form) { 2213fdb8d77bSTom N Harris // Safety check in case the caller forgets. 2214fdb8d77bSTom N Harris $form->endFieldset(); 2215cbb44eabSAndreas Gohr Event::createAndTrigger('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 2216fdb8d77bSTom N Harris} 2217fdb8d77bSTom N Harris 2218fdb8d77bSTom N Harris/** 2219fdb8d77bSTom N Harris * Form print function. 222042ea7f44SGerrit Uitslag * 222125dd2a2fSSatoshi Sahara * @param Form|Doku_Form $form The form 2222fdb8d77bSTom N Harris */ 222325dd2a2fSSatoshi Saharafunction html_form_output($form) { 222425dd2a2fSSatoshi Sahara if ($form instanceof dokuwiki\Form\Form) { 222525dd2a2fSSatoshi Sahara print $form->toHTML(); 222625dd2a2fSSatoshi Sahara } else { // $form is instanceof Doku_Form 222725dd2a2fSSatoshi Sahara // Just calls printForm() on the form object. 222825dd2a2fSSatoshi Sahara $form->printForm(); 222925dd2a2fSSatoshi Sahara } 22308b06d178Schris} 2231340756e4Sandi 223207bf32b2SAndreas Gohr/** 223307bf32b2SAndreas Gohr * Embed a flash object in HTML 223407bf32b2SAndreas Gohr * 223507bf32b2SAndreas Gohr * This will create the needed HTML to embed a flash movie in a cross browser 223607bf32b2SAndreas Gohr * compatble way using valid XHTML 223707bf32b2SAndreas Gohr * 223807bf32b2SAndreas Gohr * The parameters $params, $flashvars and $atts need to be associative arrays. 223907bf32b2SAndreas Gohr * No escaping needs to be done for them. The alternative content *has* to be 224007bf32b2SAndreas Gohr * escaped because it is used as is. If no alternative content is given 224107bf32b2SAndreas Gohr * $lang['noflash'] is used. 224207bf32b2SAndreas Gohr * 224307bf32b2SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 224407bf32b2SAndreas Gohr * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml 224507bf32b2SAndreas Gohr * 224607bf32b2SAndreas Gohr * @param string $swf - the SWF movie to embed 224707bf32b2SAndreas Gohr * @param int $width - width of the flash movie in pixels 224807bf32b2SAndreas Gohr * @param int $height - height of the flash movie in pixels 224907bf32b2SAndreas Gohr * @param array $params - additional parameters (<param>) 225007bf32b2SAndreas Gohr * @param array $flashvars - parameters to be passed in the flashvar parameter 225107bf32b2SAndreas Gohr * @param array $atts - additional attributes for the <object> tag 225207bf32b2SAndreas Gohr * @param string $alt - alternative content (is NOT automatically escaped!) 2253b3d1090eSMichael Hamann * @return string - the XHTML markup 225407bf32b2SAndreas Gohr */ 225507bf32b2SAndreas Gohrfunction html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){ 225607bf32b2SAndreas Gohr global $lang; 225707bf32b2SAndreas Gohr 225807bf32b2SAndreas Gohr $out = ''; 225907bf32b2SAndreas Gohr 226007bf32b2SAndreas Gohr // prepare the object attributes 226107bf32b2SAndreas Gohr if(is_null($atts)) $atts = array(); 226207bf32b2SAndreas Gohr $atts['width'] = (int) $width; 2263d4c61e61SAndreas Gohr $atts['height'] = (int) $height; 226407bf32b2SAndreas Gohr if(!$atts['width']) $atts['width'] = 425; 226507bf32b2SAndreas Gohr if(!$atts['height']) $atts['height'] = 350; 226607bf32b2SAndreas Gohr 226707bf32b2SAndreas Gohr // add object attributes for standard compliant browsers 226807bf32b2SAndreas Gohr $std = $atts; 226907bf32b2SAndreas Gohr $std['type'] = 'application/x-shockwave-flash'; 227007bf32b2SAndreas Gohr $std['data'] = $swf; 227107bf32b2SAndreas Gohr 227207bf32b2SAndreas Gohr // add object attributes for IE 227307bf32b2SAndreas Gohr $ie = $atts; 227407bf32b2SAndreas Gohr $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 227507bf32b2SAndreas Gohr 227607bf32b2SAndreas Gohr // open object (with conditional comments) 227707bf32b2SAndreas Gohr $out .= '<!--[if !IE]> -->'.NL; 227807bf32b2SAndreas Gohr $out .= '<object '.buildAttributes($std).'>'.NL; 227907bf32b2SAndreas Gohr $out .= '<!-- <![endif]-->'.NL; 228007bf32b2SAndreas Gohr $out .= '<!--[if IE]>'.NL; 228107bf32b2SAndreas Gohr $out .= '<object '.buildAttributes($ie).'>'.NL; 228207bf32b2SAndreas Gohr $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL; 22839ae41cdcSAndreas Gohr $out .= '<!--><!-- -->'.NL; 228407bf32b2SAndreas Gohr 228507bf32b2SAndreas Gohr // print params 228607bf32b2SAndreas Gohr if(is_array($params)) foreach($params as $key => $val){ 228707bf32b2SAndreas Gohr $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL; 228807bf32b2SAndreas Gohr } 228907bf32b2SAndreas Gohr 229007bf32b2SAndreas Gohr // add flashvars 229107bf32b2SAndreas Gohr if(is_array($flashvars)){ 2292d4c61e61SAndreas Gohr $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL; 229307bf32b2SAndreas Gohr } 229407bf32b2SAndreas Gohr 229507bf32b2SAndreas Gohr // alternative content 229607bf32b2SAndreas Gohr if($alt){ 229707bf32b2SAndreas Gohr $out .= $alt.NL; 229807bf32b2SAndreas Gohr }else{ 229907bf32b2SAndreas Gohr $out .= $lang['noflash'].NL; 230007bf32b2SAndreas Gohr } 230107bf32b2SAndreas Gohr 230207bf32b2SAndreas Gohr // finish 230307bf32b2SAndreas Gohr $out .= '</object>'.NL; 230407bf32b2SAndreas Gohr $out .= '<!-- <![endif]-->'.NL; 230507bf32b2SAndreas Gohr 230607bf32b2SAndreas Gohr return $out; 230707bf32b2SAndreas Gohr} 230807bf32b2SAndreas Gohr 23098d5e837eSMichael Hamann/** 23108d5e837eSMichael Hamann * Prints HTML code for the given tab structure 23118d5e837eSMichael Hamann * 23128d5e837eSMichael Hamann * @param array $tabs tab structure 23138d5e837eSMichael Hamann * @param string $current_tab the current tab id 23148d5e837eSMichael Hamann */ 231595b451bcSAdrian Langfunction html_tabs($tabs, $current_tab = null) { 231694add303SAnika Henke echo '<ul class="tabs">'.NL; 231795b451bcSAdrian Lang 231895b451bcSAdrian Lang foreach($tabs as $id => $tab) { 231995b451bcSAdrian Lang html_tab($tab['href'], $tab['caption'], $id === $current_tab); 232095b451bcSAdrian Lang } 232195b451bcSAdrian Lang 232294add303SAnika Henke echo '</ul>'.NL; 232395b451bcSAdrian Lang} 2324cd2a4cfdSAnika Henke 232595b451bcSAdrian Lang/** 232695b451bcSAdrian Lang * Prints a single tab 232795b451bcSAdrian Lang * 232895b451bcSAdrian Lang * @author Kate Arzamastseva <pshns@ukr.net> 232995b451bcSAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 233095b451bcSAdrian Lang * 233195b451bcSAdrian Lang * @param string $href - tab href 233295b451bcSAdrian Lang * @param string $caption - tab caption 233395b451bcSAdrian Lang * @param boolean $selected - is tab selected 233495b451bcSAdrian Lang */ 233595b451bcSAdrian Lang 233695b451bcSAdrian Langfunction html_tab($href, $caption, $selected=false) { 233795b451bcSAdrian Lang $tab = '<li>'; 233895b451bcSAdrian Lang if ($selected) { 233995b451bcSAdrian Lang $tab .= '<strong>'; 234095b451bcSAdrian Lang } else { 234195b451bcSAdrian Lang $tab .= '<a href="' . hsc($href) . '">'; 234295b451bcSAdrian Lang } 234395b451bcSAdrian Lang $tab .= hsc($caption) 234495b451bcSAdrian Lang . '</' . ($selected ? 'strong' : 'a') . '>' 234594add303SAnika Henke . '</li>'.NL; 234695b451bcSAdrian Lang echo $tab; 234795b451bcSAdrian Lang} 234895b451bcSAdrian Lang 2349cd2a4cfdSAnika Henke/** 2350cd2a4cfdSAnika Henke * Display size change 2351cd2a4cfdSAnika Henke * 2352cd2a4cfdSAnika Henke * @param int $sizechange - size of change in Bytes 2353b0f23f4eSSatoshi Sahara * @param Form|Doku_Form $form - form to add elements to 2354cd2a4cfdSAnika Henke */ 2355cd2a4cfdSAnika Henke 2356172cb15aSSatoshi Saharafunction html_sizechange($sizechange, $form) { 2357cd2a4cfdSAnika Henke if(isset($sizechange)) { 2358cd2a4cfdSAnika Henke $class = 'sizechange'; 2359cd2a4cfdSAnika Henke $value = filesize_h(abs($sizechange)); 2360cd2a4cfdSAnika Henke if ($sizechange > 0) { 2361cd2a4cfdSAnika Henke $class .= ' positive'; 2362cd2a4cfdSAnika Henke $value = '+' . $value; 2363cd2a4cfdSAnika Henke } elseif ($sizechange < 0) { 2364cd2a4cfdSAnika Henke $class .= ' negative'; 2365cd2a4cfdSAnika Henke $value = '-' . $value; 23660b78a6edSAnika Henke } else { 23670b78a6edSAnika Henke $value = '±' . $value; 2368cd2a4cfdSAnika Henke } 2369b0f23f4eSSatoshi Sahara if ($form instanceof dokuwiki\Form\Form) { 2370b0f23f4eSSatoshi Sahara $form->addTagOpen('span')->addClass($class); 2371b0f23f4eSSatoshi Sahara $form->addHTML($value); 2372b0f23f4eSSatoshi Sahara $form->addTagClose('span'); 2373b0f23f4eSSatoshi Sahara } else { // Doku_Form 2374cd2a4cfdSAnika Henke $form->addElement(form_makeOpenTag('span', array('class' => $class))); 2375cd2a4cfdSAnika Henke $form->addElement($value); 2376cd2a4cfdSAnika Henke $form->addElement(form_makeCloseTag('span')); 2377cd2a4cfdSAnika Henke } 2378cd2a4cfdSAnika Henke } 2379b0f23f4eSSatoshi Sahara} 2380