1<?php 2/** 3 * HTML output functions 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9use dokuwiki\ChangeLog\MediaChangeLog; 10use dokuwiki\ChangeLog\PageChangeLog; 11use dokuwiki\Extension\AuthPlugin; 12use dokuwiki\Extension\Event; 13 14if (!defined('SEC_EDIT_PATTERN')) { 15 define('SEC_EDIT_PATTERN', '#<!-- EDIT({.*?}) -->#'); 16} 17 18 19/** 20 * Convenience function to quickly build a wikilink 21 * 22 * @author Andreas Gohr <andi@splitbrain.org> 23 * @param string $id id of the target page 24 * @param string $name the name of the link, i.e. the text that is displayed 25 * @param string|array $search search string(s) that shall be highlighted in the target page 26 * @return string the HTML code of the link 27 */ 28function html_wikilink($id, $name = null, $search = '') { 29 /** @var Doku_Renderer_xhtml $xhtml_renderer */ 30 static $xhtml_renderer = null; 31 if (is_null($xhtml_renderer)) { 32 $xhtml_renderer = p_get_renderer('xhtml'); 33 } 34 35 return $xhtml_renderer->internallink($id,$name,$search,true,'navigation'); 36} 37 38/** 39 * The loginform 40 * 41 * @author Andreas Gohr <andi@splitbrain.org> 42 * 43 * @param bool $svg Whether to show svg icons in the register and resendpwd links or not 44 * @deprecated 2020-07-18 45 */ 46function html_login($svg = false) { 47 (new dokuwiki\Ui\Login($svg))->show(); 48} 49 50 51/** 52 * Denied page content 53 * 54 * @return string html 55 * @deprecated 2020-07-18 not called anymore, see inc/Action/Denied::tplContent() 56 */ 57function html_denied() { 58} 59 60/** 61 * inserts section edit buttons if wanted or removes the markers 62 * 63 * @author Andreas Gohr <andi@splitbrain.org> 64 * 65 * @param string $text 66 * @param bool $show show section edit buttons? 67 * @return string 68 */ 69function html_secedit($text, $show = true) { 70 global $INFO; 71 72 if ((isset($INFO) && !$INFO['writable']) || !$show || (isset($INFO) && $INFO['rev'])) { 73 return preg_replace(SEC_EDIT_PATTERN,'',$text); 74 } 75 76 return preg_replace_callback(SEC_EDIT_PATTERN, 77 'html_secedit_button', $text); 78} 79 80/** 81 * prepares section edit button data for event triggering 82 * used as a callback in html_secedit 83 * 84 * @author Andreas Gohr <andi@splitbrain.org> 85 * 86 * @param array $matches matches with regexp 87 * @return string 88 * @triggers HTML_SECEDIT_BUTTON 89 */ 90function html_secedit_button($matches){ 91 $json = htmlspecialchars_decode($matches[1], ENT_QUOTES); 92 $data = json_decode($json, true); 93 if ($data == NULL) { 94 return; 95 } 96 $data ['target'] = strtolower($data['target']); 97 $data ['hid'] = strtolower($data['hid']); 98 99 return Event::createAndTrigger('HTML_SECEDIT_BUTTON', $data, 100 'html_secedit_get_button'); 101} 102 103/** 104 * prints a section editing button 105 * used as default action form HTML_SECEDIT_BUTTON 106 * 107 * @author Adrian Lang <lang@cosmocode.de> 108 * 109 * @param array $data name, section id and target 110 * @return string html 111 */ 112function html_secedit_get_button($data) { 113 global $ID; 114 global $INFO; 115 116 if (!isset($data['name']) || $data['name'] === '') return ''; 117 118 $name = $data['name']; 119 unset($data['name']); 120 121 $secid = $data['secid']; 122 unset($data['secid']); 123 124 $params = array_merge( 125 array('do' => 'edit', 'rev' => $INFO['lastmod'], 'summary' => '['.$name.'] '), 126 $data 127 ); 128 129 $html = '<div class="secedit editbutton_'.$data['target'] .' editbutton_'.$secid .'">'; 130 $html.= html_btn('secedit', $ID, '', $params, 'post', $name); 131 $html.= '</div>'; 132 return $html; 133} 134 135/** 136 * Just the back to top button (in its own form) 137 * 138 * @author Andreas Gohr <andi@splitbrain.org> 139 * 140 * @return string html 141 */ 142function html_topbtn() { 143 global $lang; 144 145 $html = '<a class="nolink" href="#dokuwiki__top">' 146 .'<button class="button" onclick="window.scrollTo(0, 0)" title="'. $lang['btn_top'] .'">' 147 . $lang['btn_top'] 148 .'</button></a>'; 149 return $html; 150} 151 152/** 153 * Displays a button (using its own form) 154 * If tooltip exists, the access key tooltip is replaced. 155 * 156 * @author Andreas Gohr <andi@splitbrain.org> 157 * 158 * @param string $name 159 * @param string $id 160 * @param string $akey access key 161 * @param string[] $params key-value pairs added as hidden inputs 162 * @param string $method 163 * @param string $tooltip 164 * @param bool|string $label label text, false: lookup btn_$name in localization 165 * @param string $svg (optional) svg code, inserted into the button 166 * @return string 167 */ 168function html_btn($name, $id, $akey, $params, $method = 'get', $tooltip = '', $label = false, $svg = null) { 169 global $conf; 170 global $lang; 171 172 if (!$label) 173 $label = $lang['btn_'.$name]; 174 175 //filter id (without urlencoding) 176 $id = idfilter($id,false); 177 178 //make nice URLs even for buttons 179 if ($conf['userewrite'] == 2) { 180 $script = DOKU_BASE.DOKU_SCRIPT.'/'.$id; 181 } elseif ($conf['userewrite']) { 182 $script = DOKU_BASE.$id; 183 } else { 184 $script = DOKU_BASE.DOKU_SCRIPT; 185 $params['id'] = $id; 186 } 187 188 $html = '<form class="button btn_'.$name.'" method="'.$method.'" action="'.$script.'"><div class="no">'; 189 190 if (is_array($params)) { 191 foreach ($params as $key => $val) { 192 $html .= '<input type="hidden" name="'.$key.'" value="'.hsc($val).'" />'; 193 } 194 } 195 196 $tip = empty($tooltip) ? hsc($label) : hsc($tooltip); 197 198 $html .= '<button type="submit" '; 199 if ($akey) { 200 $tip .= ' ['.strtoupper($akey).']'; 201 $html .= 'accesskey="'.$akey.'" '; 202 } 203 $html .= 'title="'.$tip.'">'; 204 if ($svg) { 205 $html .= '<span>'. hsc($label) .'</span>'. inlineSVG($svg); 206 } else { 207 $html .= hsc($label); 208 } 209 $html .= '</button>'; 210 $html .= '</div></form>'; 211 212 return $html; 213} 214/** 215 * show a revision warning 216 * 217 * @author Szymon Olewniczak <dokuwiki@imz.re> 218 */ 219function html_showrev() { 220 print p_locale_xhtml('showrev'); 221} 222 223/** 224 * Show a wiki page 225 * 226 * @author Andreas Gohr <andi@splitbrain.org> 227 * 228 * @param null|string $txt wiki text or null for showing $ID 229 * @deprecated 2020-07-18 230 */ 231function html_show($txt=null) { 232 (new dokuwiki\Ui\PageView($txt))->show(); 233} 234 235/** 236 * ask the user about how to handle an exisiting draft 237 * 238 * @author Andreas Gohr <andi@splitbrain.org> 239 * @deprecated 2020-07-18 240 */ 241function html_draft() { 242 (new dokuwiki\Ui\Draft)->show(); 243} 244 245/** 246 * Highlights searchqueries in HTML code 247 * 248 * @author Andreas Gohr <andi@splitbrain.org> 249 * @author Harry Fuecks <hfuecks@gmail.com> 250 * 251 * @param string $html 252 * @param array|string $phrases 253 * @return string html 254 */ 255function html_hilight($html, $phrases) { 256 $phrases = (array) $phrases; 257 $phrases = array_map('preg_quote_cb', $phrases); 258 $phrases = array_map('ft_snippet_re_preprocess', $phrases); 259 $phrases = array_filter($phrases); 260 $regex = join('|',$phrases); 261 262 if ($regex === '') return $html; 263 if (!\dokuwiki\Utf8\Clean::isUtf8($regex)) return $html; 264 265 $html = @preg_replace_callback("/((<[^>]*)|$regex)/ui", function ($match) { 266 $hlight = unslash($match[0]); 267 if (!isset($match[2])) { 268 $hlight = '<span class="search_hit">'.$hlight.'</span>'; 269 } 270 return $hlight; 271 }, $html); 272 return $html; 273} 274 275/** 276 * Display error on locked pages 277 * 278 * @author Andreas Gohr <andi@splitbrain.org> 279 * @deprecated 2020-07-18 not called anymore, see inc/Action/Locked::tplContent() 280 */ 281function html_locked() { 282} 283 284/** 285 * list old revisions 286 * 287 * @author Andreas Gohr <andi@splitbrain.org> 288 * @author Ben Coburn <btcoburn@silicodon.net> 289 * @author Kate Arzamastseva <pshns@ukr.net> 290 * 291 * @param int $first skip the first n changelog lines 292 * @param bool|string $media_id id of media, or false for current page 293 * @deprecated 2020-07-18 294 */ 295function html_revisions($first=0, $media_id = false) { 296 (new dokuwiki\Ui\Revisions($first, $media_id))->show(); 297} 298 299/** 300 * display recent changes 301 * 302 * @author Andreas Gohr <andi@splitbrain.org> 303 * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 304 * @author Ben Coburn <btcoburn@silicodon.net> 305 * @author Kate Arzamastseva <pshns@ukr.net> 306 * 307 * @param int $first 308 * @param string $show_changes 309 * @deprecated 2020-07-18 310 */ 311function html_recent($first = 0, $show_changes = 'both') { 312 (new dokuwiki\Ui\Recent($first, $show_changes))->show(); 313} 314 315/** 316 * Display page index 317 * 318 * @author Andreas Gohr <andi@splitbrain.org> 319 * 320 * @param string $ns 321 * @deprecated 2020-07-18 322 */ 323function html_index($ns) { 324 (new dokuwiki\Ui\Index($ns))->show(); 325} 326 327/** 328 * Index item formatter 329 * 330 * User function for html_buildlist() 331 * 332 * @author Andreas Gohr <andi@splitbrain.org> 333 * 334 * @param array $item 335 * @return string 336 * @deprecated 2020-07-18 337 */ 338function html_list_index($item) { 339 return (new dokuwiki\Ui\Index)->formatListItem($item); 340} 341 342/** 343 * Index List item 344 * 345 * This user function is used in html_buildlist to build the 346 * <li> tags for namespaces when displaying the page index 347 * it gives different classes to opened or closed "folders" 348 * 349 * @author Andreas Gohr <andi@splitbrain.org> 350 * 351 * @param array $item 352 * @return string html 353 * @deprecated 2020-07-18 354 */ 355function html_li_index($item) { 356 return (new dokuwiki\Ui\Index)->tagListItem($item); 357} 358 359/** 360 * Build an unordered list 361 * 362 * Build an unordered list from the given $data array 363 * Each item in the array has to have a 'level' property 364 * the item itself gets printed by the given $func user 365 * function. The second and optional function is used to 366 * print the <li> tag. Both user function need to accept 367 * a single item. 368 * 369 * Both user functions can be given as array to point to 370 * a member of an object. 371 * 372 * @author Andreas Gohr <andi@splitbrain.org> 373 * 374 * @param array $data array with item arrays 375 * @param string $class class of ul wrapper 376 * @param callable $func callback to print an list item 377 * @param callable $lifunc (optional) callback to the opening li tag 378 * @param bool $forcewrapper (optional) Trigger building a wrapper ul if the first level is 379 * 0 (we have a root object) or 1 (just the root content) 380 * @return string html of an unordered list 381 */ 382function html_buildlist($data, $class, $func, $lifunc = null, $forcewrapper = false) { 383 if (count($data) === 0) { 384 return ''; 385 } 386 387 $firstElement = reset($data); 388 $start_level = $firstElement['level']; 389 $level = $start_level; 390 $html = ''; 391 $open = 0; 392 393 // set callback function to build the <li> tag, formerly defined as html_li_default() 394 if (!is_callable($lifunc)) { 395 $lifunc = function ($item) { 396 return '<li class="level'.$item['level'].'">'; 397 }; 398 } 399 400 foreach ($data as $item) { 401 if ($item['level'] > $level) { 402 //open new list 403 for ($i = 0; $i < ($item['level'] - $level); $i++) { 404 if ($i) $html .= '<li class="clear">'; 405 $html .= "\n".'<ul class="'.$class.'">'."\n"; 406 $open++; 407 } 408 $level = $item['level']; 409 410 } elseif ($item['level'] < $level) { 411 //close last item 412 $html .= '</li>'."\n"; 413 while ($level > $item['level'] && $open > 0 ) { 414 //close higher lists 415 $html .= '</ul>'."\n".'</li>'."\n"; 416 $level--; 417 $open--; 418 } 419 } elseif ($html !== '') { 420 //close previous item 421 $html .= '</li>'."\n"; 422 } 423 424 //print item 425 $html .= call_user_func($lifunc, $item); 426 $html .= '<div class="li">'; 427 428 $html .= call_user_func($func, $item); 429 $html .= '</div>'; 430 } 431 432 //close remaining items and lists 433 $html .= '</li>'."\n"; 434 while ($open-- > 0) { 435 $html .= '</ul></li>'."\n"; 436 } 437 438 if ($forcewrapper || $start_level < 2) { 439 // Trigger building a wrapper ul if the first level is 440 // 0 (we have a root object) or 1 (just the root content) 441 $html = "\n".'<ul class="'.$class.'">'."\n".$html.'</ul>'."\n"; 442 } 443 444 return $html; 445} 446 447/** 448 * display backlinks 449 * 450 * @author Andreas Gohr <andi@splitbrain.org> 451 * @author Michael Klier <chi@chimeric.de> 452 * @deprecated 2020-07-18 453 */ 454function html_backlinks() { 455 (new dokuwiki\Ui\Backlinks)->show(); 456} 457 458/** 459 * Show diff 460 * between current page version and provided $text 461 * or between the revisions provided via GET or POST 462 * 463 * @author Andreas Gohr <andi@splitbrain.org> 464 * @param string $text when non-empty: compare with this text with most current version 465 * @param bool $intro display the intro text 466 * @param string $type type of the diff (inline or sidebyside) 467 * @deprecated 2020-07-18 468 */ 469function html_diff($text = '', $intro = true, $type = null) { 470 (new dokuwiki\Ui\Diff($text, $intro, $type))->show(); 471} 472 473/** 474 * show warning on conflict detection 475 * 476 * @author Andreas Gohr <andi@splitbrain.org> 477 * 478 * @param string $text 479 * @param string $summary 480 * @deprecated 2020-07-18 481 */ 482function html_conflict($text, $summary) { 483 (new dokuwiki\Ui\Conflict($text, $summary))->show(); 484} 485 486/** 487 * Prints the global message array 488 * 489 * @author Andreas Gohr <andi@splitbrain.org> 490 */ 491function html_msgarea() { 492 global $MSG, $MSG_shown; 493 /** @var array $MSG */ 494 // store if the global $MSG has already been shown and thus HTML output has been started 495 $MSG_shown = true; 496 497 if (!isset($MSG)) return; 498 499 $shown = array(); 500 foreach ($MSG as $msg) { 501 $hash = md5($msg['msg']); 502 if (isset($shown[$hash])) continue; // skip double messages 503 if (info_msg_allowed($msg)) { 504 print '<div class="'.$msg['lvl'].'">'; 505 print $msg['msg']; 506 print '</div>'; 507 } 508 $shown[$hash] = 1; 509 } 510 511 unset($GLOBALS['MSG']); 512} 513 514/** 515 * Prints the registration form 516 * 517 * @author Andreas Gohr <andi@splitbrain.org> 518 * @deprecated 2020-07-18 519 */ 520function html_register() { 521 (new dokuwiki\Ui\UserRegister)->show(); 522} 523 524/** 525 * Print the update profile form 526 * 527 * @author Christopher Smith <chris@jalakai.co.uk> 528 * @author Andreas Gohr <andi@splitbrain.org> 529 * @deprecated 2020-07-18 530 */ 531function html_updateprofile() { 532 (new dokuwiki\Ui\UserProfile)->show(); 533} 534 535/** 536 * Preprocess edit form data 537 * 538 * @author Andreas Gohr <andi@splitbrain.org> 539 * 540 * @triggers HTML_EDITFORM_OUTPUT 541 * @deprecated 2020-07-18 542 */ 543function html_edit() { 544 (new dokuwiki\Ui\Editor)->show(); 545} 546 547/** 548 * prints some debug info 549 * 550 * @author Andreas Gohr <andi@splitbrain.org> 551 */ 552function html_debug() { 553 global $conf; 554 global $lang; 555 /** @var AuthPlugin $auth */ 556 global $auth; 557 global $INFO; 558 559 //remove sensitive data 560 $cnf = $conf; 561 debug_guard($cnf); 562 $nfo = $INFO; 563 debug_guard($nfo); 564 $ses = $_SESSION; 565 debug_guard($ses); 566 567 print '<html><body>'; 568 569 print '<p>When reporting bugs please send all the following '; 570 print 'output as a mail to andi@splitbrain.org '; 571 print 'The best way to do this is to save this page in your browser</p>'; 572 573 print '<b>$INFO:</b><pre>'; 574 print_r($nfo); 575 print '</pre>'; 576 577 print '<b>$_SERVER:</b><pre>'; 578 print_r($_SERVER); 579 print '</pre>'; 580 581 print '<b>$conf:</b><pre>'; 582 print_r($cnf); 583 print '</pre>'; 584 585 print '<b>DOKU_BASE:</b><pre>'; 586 print DOKU_BASE; 587 print '</pre>'; 588 589 print '<b>abs DOKU_BASE:</b><pre>'; 590 print DOKU_URL; 591 print '</pre>'; 592 593 print '<b>rel DOKU_BASE:</b><pre>'; 594 print dirname($_SERVER['PHP_SELF']).'/'; 595 print '</pre>'; 596 597 print '<b>PHP Version:</b><pre>'; 598 print phpversion(); 599 print '</pre>'; 600 601 print '<b>locale:</b><pre>'; 602 print setlocale(LC_ALL,0); 603 print '</pre>'; 604 605 print '<b>encoding:</b><pre>'; 606 print $lang['encoding']; 607 print '</pre>'; 608 609 if ($auth) { 610 print '<b>Auth backend capabilities:</b><pre>'; 611 foreach ($auth->getCapabilities() as $cando) { 612 print ' '.str_pad($cando,16) .' => '. (int)$auth->canDo($cando) . DOKU_LF; 613 } 614 print '</pre>'; 615 } 616 617 print '<b>$_SESSION:</b><pre>'; 618 print_r($ses); 619 print '</pre>'; 620 621 print '<b>Environment:</b><pre>'; 622 print_r($_ENV); 623 print '</pre>'; 624 625 print '<b>PHP settings:</b><pre>'; 626 $inis = ini_get_all(); 627 print_r($inis); 628 print '</pre>'; 629 630 if (function_exists('apache_get_version')) { 631 $apache = array(); 632 $apache['version'] = apache_get_version(); 633 634 if (function_exists('apache_get_modules')) { 635 $apache['modules'] = apache_get_modules(); 636 } 637 print '<b>Apache</b><pre>'; 638 print_r($apache); 639 print '</pre>'; 640 } 641 642 print '</body></html>'; 643} 644 645/** 646 * Form to request a new password for an existing account 647 * 648 * @author Benoit Chesneau <benoit@bchesneau.info> 649 * @author Andreas Gohr <gohr@cosmocode.de> 650 * @deprecated 2020-07-18 651 */ 652function html_resendpwd() { 653 (new dokuwiki\Ui\UserResendPwd)->show(); 654} 655 656/** 657 * Return the TOC rendered to XHTML 658 * 659 * @author Andreas Gohr <andi@splitbrain.org> 660 * 661 * @param array $toc 662 * @return string html 663 */ 664function html_TOC($toc) { 665 if (!count($toc)) return ''; 666 global $lang; 667 $out = '<!-- TOC START -->'.DOKU_LF; 668 $out .= '<div id="dw__toc" class="dw__toc">'.DOKU_LF; 669 $out .= '<h3 class="toggle">'; 670 $out .= $lang['toc']; 671 $out .= '</h3>'.DOKU_LF; 672 $out .= '<div>'.DOKU_LF; 673 $out .= html_buildlist($toc, 'toc', 'html_list_toc', null, true); 674 $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; 675 $out .= '<!-- TOC END -->'.DOKU_LF; 676 return $out; 677} 678 679/** 680 * Callback for html_buildlist 681 * 682 * @param array $item 683 * @return string html 684 */ 685function html_list_toc($item) { 686 if (isset($item['hid'])){ 687 $link = '#'.$item['hid']; 688 } else { 689 $link = $item['link']; 690 } 691 692 return '<a href="'.$link.'">'.hsc($item['title']).'</a>'; 693} 694 695/** 696 * Helper function to build TOC items 697 * 698 * Returns an array ready to be added to a TOC array 699 * 700 * @param string $link - where to link (if $hash set to '#' it's a local anchor) 701 * @param string $text - what to display in the TOC 702 * @param int $level - nesting level 703 * @param string $hash - is prepended to the given $link, set blank if you want full links 704 * @return array the toc item 705 */ 706function html_mktocitem($link, $text, $level, $hash='#') { 707 return array( 708 'link' => $hash.$link, 709 'title' => $text, 710 'type' => 'ul', 711 'level' => $level 712 ); 713} 714 715/** 716 * Output a Doku_Form object. 717 * Triggers an event with the form name: HTML_{$name}FORM_OUTPUT 718 * 719 * @author Tom N Harris <tnharris@whoopdedo.org> 720 * 721 * @param string $name The name of the form 722 * @param Doku_Form $form The form 723 */ 724function html_form($name, $form) { 725 // Safety check in case the caller forgets. 726 $form->endFieldset(); 727 Event::createAndTrigger('HTML_'.strtoupper($name).'FORM_OUTPUT', $form, 'html_form_output', false); 728} 729 730/** 731 * Form print function. 732 * Just calls printForm() on the form object. 733 * 734 * @param Doku_Form $form The form 735 */ 736function html_form_output($form) { 737 $form->printForm(); 738} 739 740/** 741 * Embed a flash object in HTML 742 * 743 * This will create the needed HTML to embed a flash movie in a cross browser 744 * compatble way using valid XHTML 745 * 746 * The parameters $params, $flashvars and $atts need to be associative arrays. 747 * No escaping needs to be done for them. The alternative content *has* to be 748 * escaped because it is used as is. If no alternative content is given 749 * $lang['noflash'] is used. 750 * 751 * @author Andreas Gohr <andi@splitbrain.org> 752 * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml 753 * 754 * @param string $swf - the SWF movie to embed 755 * @param int $width - width of the flash movie in pixels 756 * @param int $height - height of the flash movie in pixels 757 * @param array $params - additional parameters (<param>) 758 * @param array $flashvars - parameters to be passed in the flashvar parameter 759 * @param array $atts - additional attributes for the <object> tag 760 * @param string $alt - alternative content (is NOT automatically escaped!) 761 * @return string - the XHTML markup 762 */ 763function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){ 764 global $lang; 765 766 $out = ''; 767 768 // prepare the object attributes 769 if(is_null($atts)) $atts = array(); 770 $atts['width'] = (int) $width; 771 $atts['height'] = (int) $height; 772 if(!$atts['width']) $atts['width'] = 425; 773 if(!$atts['height']) $atts['height'] = 350; 774 775 // add object attributes for standard compliant browsers 776 $std = $atts; 777 $std['type'] = 'application/x-shockwave-flash'; 778 $std['data'] = $swf; 779 780 // add object attributes for IE 781 $ie = $atts; 782 $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; 783 784 // open object (with conditional comments) 785 $out .= '<!--[if !IE]> -->'.NL; 786 $out .= '<object '.buildAttributes($std).'>'.NL; 787 $out .= '<!-- <![endif]-->'.NL; 788 $out .= '<!--[if IE]>'.NL; 789 $out .= '<object '.buildAttributes($ie).'>'.NL; 790 $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL; 791 $out .= '<!--><!-- -->'.NL; 792 793 // print params 794 if(is_array($params)) foreach($params as $key => $val){ 795 $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL; 796 } 797 798 // add flashvars 799 if(is_array($flashvars)){ 800 $out .= ' <param name="FlashVars" value="'.buildURLparams($flashvars).'" />'.NL; 801 } 802 803 // alternative content 804 if($alt){ 805 $out .= $alt.NL; 806 }else{ 807 $out .= $lang['noflash'].NL; 808 } 809 810 // finish 811 $out .= '</object>'.NL; 812 $out .= '<!-- <![endif]-->'.NL; 813 814 return $out; 815} 816 817/** 818 * Prints HTML code for the given tab structure 819 * 820 * @param array $tabs tab structure 821 * @param string $current_tab the current tab id 822 */ 823function html_tabs($tabs, $current_tab = null) { 824 echo '<ul class="tabs">'.NL; 825 826 foreach ($tabs as $id => $tab) { 827 html_tab($tab['href'], $tab['caption'], $id === $current_tab); 828 } 829 830 echo '</ul>'.NL; 831} 832 833/** 834 * Prints a single tab 835 * 836 * @author Kate Arzamastseva <pshns@ukr.net> 837 * @author Adrian Lang <mail@adrianlang.de> 838 * 839 * @param string $href - tab href 840 * @param string $caption - tab caption 841 * @param boolean $selected - is tab selected 842 */ 843 844function html_tab($href, $caption, $selected = false) { 845 $tab = '<li>'; 846 if ($selected) { 847 $tab .= '<strong>'; 848 } else { 849 $tab .= '<a href="' . hsc($href) . '">'; 850 } 851 $tab .= hsc($caption) 852 . '</' . ($selected ? 'strong' : 'a') . '>' 853 . '</li>'.NL; 854 echo $tab; 855} 856 857/** 858 * Display size change 859 * 860 * @param int $sizechange - size of change in Bytes 861 * @param Doku_Form $form - (optional) form to add elements to 862 * @return void|string 863 */ 864function html_sizechange($sizechange, $form = null) { 865 if (isset($sizechange)) { 866 $class = 'sizechange'; 867 $value = filesize_h(abs($sizechange)); 868 if ($sizechange > 0) { 869 $class .= ' positive'; 870 $value = '+' . $value; 871 } elseif ($sizechange < 0) { 872 $class .= ' negative'; 873 $value = '-' . $value; 874 } else { 875 $value = '±' . $value; 876 } 877 if (!isset($form)) { 878 return '<span class="'.$class.'">'.$value.'</span>'; 879 } else { // Doku_Form 880 $form->addElement(form_makeOpenTag('span', array('class' => $class))); 881 $form->addElement($value); 882 $form->addElement(form_makeCloseTag('span')); 883 } 884 } 885} 886