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