Complex classes like Doku_Renderer_xhtml often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Doku_Renderer_xhtml, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 25 | class Doku_Renderer_xhtml extends Doku_Renderer { |
||
| 26 | /** @var array store the table of contents */ |
||
| 27 | public $toc = array(); |
||
| 28 | |||
| 29 | /** @var array A stack of section edit data */ |
||
| 30 | protected $sectionedits = array(); |
||
| 31 | var $date_at = ''; // link pages and media against this revision |
||
| 32 | |||
| 33 | /** @var int last section edit id, used by startSectionEdit */ |
||
| 34 | protected $lastsecid = 0; |
||
| 35 | |||
| 36 | /** @var array the list of headers used to create unique link ids */ |
||
| 37 | protected $headers = array(); |
||
| 38 | |||
| 39 | /** @var array a list of footnotes, list starts at 1! */ |
||
| 40 | protected $footnotes = array(); |
||
| 41 | |||
| 42 | /** @var int current section level */ |
||
| 43 | protected $lastlevel = 0; |
||
| 44 | /** @var array section node tracker */ |
||
| 45 | protected $node = array(0, 0, 0, 0, 0); |
||
| 46 | |||
| 47 | /** @var string temporary $doc store */ |
||
| 48 | protected $store = ''; |
||
| 49 | |||
| 50 | /** @var array global counter, for table classes etc. */ |
||
| 51 | protected $_counter = array(); // |
||
| 52 | |||
| 53 | /** @var int counts the code and file blocks, used to provide download links */ |
||
| 54 | protected $_codeblock = 0; |
||
| 55 | |||
| 56 | /** @var array list of allowed URL schemes */ |
||
| 57 | protected $schemes = null; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Register a new edit section range |
||
| 61 | * |
||
| 62 | * @param int $start The byte position for the edit start |
||
| 63 | * @param array $data Associative array with section data: |
||
| 64 | * Key 'name': the section name/title |
||
| 65 | * Key 'target': the target for the section edit, |
||
| 66 | * e.g. 'section' or 'table' |
||
| 67 | * Key 'hid': header id |
||
| 68 | * Key 'codeblockOffset': actual code block index |
||
| 69 | * Key 'start': set in startSectionEdit(), |
||
| 70 | * do not set yourself |
||
| 71 | * Key 'range': calculated from 'start' and |
||
| 72 | * $key in finishSectionEdit(), |
||
| 73 | * do not set yourself |
||
| 74 | * @return string A marker class for the starting HTML element |
||
| 75 | * |
||
| 76 | * @author Adrian Lang <[email protected]> |
||
| 77 | */ |
||
| 78 | public function startSectionEdit($start, $data) { |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Finish an edit section range |
||
| 102 | * |
||
| 103 | * @param int $end The byte position for the edit end; null for the rest of the page |
||
| 104 | * |
||
| 105 | * @author Adrian Lang <[email protected]> |
||
| 106 | */ |
||
| 107 | public function finishSectionEdit($end = null, $hid = null) { |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Returns the format produced by this renderer. |
||
| 122 | * |
||
| 123 | * @return string always 'xhtml' |
||
| 124 | */ |
||
| 125 | function getFormat() { |
||
| 128 | |||
| 129 | /** |
||
| 130 | * Initialize the document |
||
| 131 | */ |
||
| 132 | function document_start() { |
||
| 137 | |||
| 138 | /** |
||
| 139 | * Finalize the document |
||
| 140 | */ |
||
| 141 | function document_end() { |
||
| 194 | |||
| 195 | /** |
||
| 196 | * Add an item to the TOC |
||
| 197 | * |
||
| 198 | * @param string $id the hash link |
||
| 199 | * @param string $text the text to display |
||
| 200 | * @param int $level the nesting level |
||
| 201 | */ |
||
| 202 | function toc_additem($id, $text, $level) { |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Render a heading |
||
| 213 | * |
||
| 214 | * @param string $text the text to display |
||
| 215 | * @param int $level header level |
||
| 216 | * @param int $pos byte position in the original source |
||
| 217 | */ |
||
| 218 | function header($text, $level, $pos) { |
||
| 258 | |||
| 259 | /** |
||
| 260 | * Open a new section |
||
| 261 | * |
||
| 262 | * @param int $level section level (as determined by the previous header) |
||
| 263 | */ |
||
| 264 | function section_open($level) { |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Close the current section |
||
| 270 | */ |
||
| 271 | function section_close() { |
||
| 274 | |||
| 275 | /** |
||
| 276 | * Render plain text data |
||
| 277 | * |
||
| 278 | * @param $text |
||
| 279 | */ |
||
| 280 | function cdata($text) { |
||
| 283 | |||
| 284 | /** |
||
| 285 | * Open a paragraph |
||
| 286 | */ |
||
| 287 | function p_open() { |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Close a paragraph |
||
| 293 | */ |
||
| 294 | function p_close() { |
||
| 297 | |||
| 298 | /** |
||
| 299 | * Create a line break |
||
| 300 | */ |
||
| 301 | function linebreak() { |
||
| 304 | |||
| 305 | /** |
||
| 306 | * Create a horizontal line |
||
| 307 | */ |
||
| 308 | function hr() { |
||
| 311 | |||
| 312 | /** |
||
| 313 | * Start strong (bold) formatting |
||
| 314 | */ |
||
| 315 | function strong_open() { |
||
| 318 | |||
| 319 | /** |
||
| 320 | * Stop strong (bold) formatting |
||
| 321 | */ |
||
| 322 | function strong_close() { |
||
| 325 | |||
| 326 | /** |
||
| 327 | * Start emphasis (italics) formatting |
||
| 328 | */ |
||
| 329 | function emphasis_open() { |
||
| 332 | |||
| 333 | /** |
||
| 334 | * Stop emphasis (italics) formatting |
||
| 335 | */ |
||
| 336 | function emphasis_close() { |
||
| 339 | |||
| 340 | /** |
||
| 341 | * Start underline formatting |
||
| 342 | */ |
||
| 343 | function underline_open() { |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Stop underline formatting |
||
| 349 | */ |
||
| 350 | function underline_close() { |
||
| 353 | |||
| 354 | /** |
||
| 355 | * Start monospace formatting |
||
| 356 | */ |
||
| 357 | function monospace_open() { |
||
| 360 | |||
| 361 | /** |
||
| 362 | * Stop monospace formatting |
||
| 363 | */ |
||
| 364 | function monospace_close() { |
||
| 367 | |||
| 368 | /** |
||
| 369 | * Start a subscript |
||
| 370 | */ |
||
| 371 | function subscript_open() { |
||
| 374 | |||
| 375 | /** |
||
| 376 | * Stop a subscript |
||
| 377 | */ |
||
| 378 | function subscript_close() { |
||
| 381 | |||
| 382 | /** |
||
| 383 | * Start a superscript |
||
| 384 | */ |
||
| 385 | function superscript_open() { |
||
| 388 | |||
| 389 | /** |
||
| 390 | * Stop a superscript |
||
| 391 | */ |
||
| 392 | function superscript_close() { |
||
| 395 | |||
| 396 | /** |
||
| 397 | * Start deleted (strike-through) formatting |
||
| 398 | */ |
||
| 399 | function deleted_open() { |
||
| 402 | |||
| 403 | /** |
||
| 404 | * Stop deleted (strike-through) formatting |
||
| 405 | */ |
||
| 406 | function deleted_close() { |
||
| 409 | |||
| 410 | /** |
||
| 411 | * Callback for footnote start syntax |
||
| 412 | * |
||
| 413 | * All following content will go to the footnote instead of |
||
| 414 | * the document. To achieve this the previous rendered content |
||
| 415 | * is moved to $store and $doc is cleared |
||
| 416 | * |
||
| 417 | * @author Andreas Gohr <[email protected]> |
||
| 418 | */ |
||
| 419 | function footnote_open() { |
||
| 425 | |||
| 426 | /** |
||
| 427 | * Callback for footnote end syntax |
||
| 428 | * |
||
| 429 | * All rendered content is moved to the $footnotes array and the old |
||
| 430 | * content is restored from $store again |
||
| 431 | * |
||
| 432 | * @author Andreas Gohr |
||
| 433 | */ |
||
| 434 | function footnote_close() { |
||
| 459 | |||
| 460 | /** |
||
| 461 | * Open an unordered list |
||
| 462 | * |
||
| 463 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 464 | */ |
||
| 465 | function listu_open($classes = null) { |
||
| 473 | |||
| 474 | /** |
||
| 475 | * Close an unordered list |
||
| 476 | */ |
||
| 477 | function listu_close() { |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Open an ordered list |
||
| 483 | * |
||
| 484 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 485 | */ |
||
| 486 | function listo_open($classes = null) { |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Close an ordered list |
||
| 497 | */ |
||
| 498 | function listo_close() { |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Open a list item |
||
| 504 | * |
||
| 505 | * @param int $level the nesting level |
||
| 506 | * @param bool $node true when a node; false when a leaf |
||
| 507 | */ |
||
| 508 | function listitem_open($level, $node=false) { |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Close a list item |
||
| 515 | */ |
||
| 516 | function listitem_close() { |
||
| 519 | |||
| 520 | /** |
||
| 521 | * Start the content of a list item |
||
| 522 | */ |
||
| 523 | function listcontent_open() { |
||
| 526 | |||
| 527 | /** |
||
| 528 | * Stop the content of a list item |
||
| 529 | */ |
||
| 530 | function listcontent_close() { |
||
| 533 | |||
| 534 | /** |
||
| 535 | * Output unformatted $text |
||
| 536 | * |
||
| 537 | * Defaults to $this->cdata() |
||
| 538 | * |
||
| 539 | * @param string $text |
||
| 540 | */ |
||
| 541 | function unformatted($text) { |
||
| 544 | |||
| 545 | /** |
||
| 546 | * Execute PHP code if allowed |
||
| 547 | * |
||
| 548 | * @param string $text PHP code that is either executed or printed |
||
| 549 | * @param string $wrapper html element to wrap result if $conf['phpok'] is okff |
||
| 550 | * |
||
| 551 | * @author Andreas Gohr <[email protected]> |
||
| 552 | */ |
||
| 553 | function php($text, $wrapper = 'code') { |
||
| 565 | |||
| 566 | /** |
||
| 567 | * Output block level PHP code |
||
| 568 | * |
||
| 569 | * If $conf['phpok'] is true this should evaluate the given code and append the result |
||
| 570 | * to $doc |
||
| 571 | * |
||
| 572 | * @param string $text The PHP code |
||
| 573 | */ |
||
| 574 | function phpblock($text) { |
||
| 577 | |||
| 578 | /** |
||
| 579 | * Insert HTML if allowed |
||
| 580 | * |
||
| 581 | * @param string $text html text |
||
| 582 | * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff |
||
| 583 | * |
||
| 584 | * @author Andreas Gohr <[email protected]> |
||
| 585 | */ |
||
| 586 | function html($text, $wrapper = 'code') { |
||
| 595 | |||
| 596 | /** |
||
| 597 | * Output raw block-level HTML |
||
| 598 | * |
||
| 599 | * If $conf['htmlok'] is true this should add the code as is to $doc |
||
| 600 | * |
||
| 601 | * @param string $text The HTML |
||
| 602 | */ |
||
| 603 | function htmlblock($text) { |
||
| 606 | |||
| 607 | /** |
||
| 608 | * Start a block quote |
||
| 609 | */ |
||
| 610 | function quote_open() { |
||
| 613 | |||
| 614 | /** |
||
| 615 | * Stop a block quote |
||
| 616 | */ |
||
| 617 | function quote_close() { |
||
| 620 | |||
| 621 | /** |
||
| 622 | * Output preformatted text |
||
| 623 | * |
||
| 624 | * @param string $text |
||
| 625 | */ |
||
| 626 | function preformatted($text) { |
||
| 629 | |||
| 630 | /** |
||
| 631 | * Display text as file content, optionally syntax highlighted |
||
| 632 | * |
||
| 633 | * @param string $text text to show |
||
| 634 | * @param string $language programming language to use for syntax highlighting |
||
| 635 | * @param string $filename file path label |
||
| 636 | */ |
||
| 637 | function file($text, $language = null, $filename = null) { |
||
| 640 | |||
| 641 | /** |
||
| 642 | * Display text as code content, optionally syntax highlighted |
||
| 643 | * |
||
| 644 | * @param string $text text to show |
||
| 645 | * @param string $language programming language to use for syntax highlighting |
||
| 646 | * @param string $filename file path label |
||
| 647 | */ |
||
| 648 | function code($text, $language = null, $filename = null) { |
||
| 651 | |||
| 652 | /** |
||
| 653 | * Use GeSHi to highlight language syntax in code and file blocks |
||
| 654 | * |
||
| 655 | * @author Andreas Gohr <[email protected]> |
||
| 656 | * @param string $type code|file |
||
| 657 | * @param string $text text to show |
||
| 658 | * @param string $language programming language to use for syntax highlighting |
||
| 659 | * @param string $filename file path label |
||
| 660 | */ |
||
| 661 | function _highlight($type, $text, $language = null, $filename = null) { |
||
| 706 | |||
| 707 | /** |
||
| 708 | * Format an acronym |
||
| 709 | * |
||
| 710 | * Uses $this->acronyms |
||
| 711 | * |
||
| 712 | * @param string $acronym |
||
| 713 | */ |
||
| 714 | function acronym($acronym) { |
||
| 727 | |||
| 728 | /** |
||
| 729 | * Format a smiley |
||
| 730 | * |
||
| 731 | * Uses $this->smiley |
||
| 732 | * |
||
| 733 | * @param string $smiley |
||
| 734 | */ |
||
| 735 | function smiley($smiley) { |
||
| 744 | |||
| 745 | /** |
||
| 746 | * Format an entity |
||
| 747 | * |
||
| 748 | * Entities are basically small text replacements |
||
| 749 | * |
||
| 750 | * Uses $this->entities |
||
| 751 | * |
||
| 752 | * @param string $entity |
||
| 753 | */ |
||
| 754 | function entity($entity) { |
||
| 761 | |||
| 762 | /** |
||
| 763 | * Typographically format a multiply sign |
||
| 764 | * |
||
| 765 | * Example: ($x=640, $y=480) should result in "640×480" |
||
| 766 | * |
||
| 767 | * @param string|int $x first value |
||
| 768 | * @param string|int $y second value |
||
| 769 | */ |
||
| 770 | function multiplyentity($x, $y) { |
||
| 773 | |||
| 774 | /** |
||
| 775 | * Render an opening single quote char (language specific) |
||
| 776 | */ |
||
| 777 | function singlequoteopening() { |
||
| 781 | |||
| 782 | /** |
||
| 783 | * Render a closing single quote char (language specific) |
||
| 784 | */ |
||
| 785 | function singlequoteclosing() { |
||
| 789 | |||
| 790 | /** |
||
| 791 | * Render an apostrophe char (language specific) |
||
| 792 | */ |
||
| 793 | function apostrophe() { |
||
| 797 | |||
| 798 | /** |
||
| 799 | * Render an opening double quote char (language specific) |
||
| 800 | */ |
||
| 801 | function doublequoteopening() { |
||
| 805 | |||
| 806 | /** |
||
| 807 | * Render an closinging double quote char (language specific) |
||
| 808 | */ |
||
| 809 | function doublequoteclosing() { |
||
| 813 | |||
| 814 | /** |
||
| 815 | * Render a CamelCase link |
||
| 816 | * |
||
| 817 | * @param string $link The link name |
||
| 818 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 819 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 820 | * |
||
| 821 | * @see http://en.wikipedia.org/wiki/CamelCase |
||
| 822 | */ |
||
| 823 | function camelcaselink($link, $returnonly = false) { |
||
| 830 | |||
| 831 | /** |
||
| 832 | * Render a page local link |
||
| 833 | * |
||
| 834 | * @param string $hash hash link identifier |
||
| 835 | * @param string $name name for the link |
||
| 836 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 837 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 838 | */ |
||
| 839 | function locallink($hash, $name = null, $returnonly = false) { |
||
| 855 | |||
| 856 | /** |
||
| 857 | * Render an internal Wiki Link |
||
| 858 | * |
||
| 859 | * $search,$returnonly & $linktype are not for the renderer but are used |
||
| 860 | * elsewhere - no need to implement them in other renderers |
||
| 861 | * |
||
| 862 | * @author Andreas Gohr <[email protected]> |
||
| 863 | * @param string $id pageid |
||
| 864 | * @param string|null $name link name |
||
| 865 | * @param string|null $search adds search url param |
||
| 866 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 867 | * @param string $linktype type to set use of headings |
||
| 868 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 869 | */ |
||
| 870 | function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { |
||
| 952 | |||
| 953 | /** |
||
| 954 | * Render an external link |
||
| 955 | * |
||
| 956 | * @param string $url full URL with scheme |
||
| 957 | * @param string|array $name name for the link, array for media file |
||
| 958 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 959 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 960 | */ |
||
| 961 | function externallink($url, $name = null, $returnonly = false) { |
||
| 1012 | |||
| 1013 | /** |
||
| 1014 | * Render an interwiki link |
||
| 1015 | * |
||
| 1016 | * You may want to use $this->_resolveInterWiki() here |
||
| 1017 | * |
||
| 1018 | * @param string $match original link - probably not much use |
||
| 1019 | * @param string|array $name name for the link, array for media file |
||
| 1020 | * @param string $wikiName indentifier (shortcut) for the remote wiki |
||
| 1021 | * @param string $wikiUri the fragment parsed from the original link |
||
| 1022 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1023 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1024 | */ |
||
| 1025 | function interwikilink($match, $name = null, $wikiName, $wikiUri, $returnonly = false) { |
||
| 1071 | |||
| 1072 | /** |
||
| 1073 | * Link to windows share |
||
| 1074 | * |
||
| 1075 | * @param string $url the link |
||
| 1076 | * @param string|array $name name for the link, array for media file |
||
| 1077 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1078 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1079 | */ |
||
| 1080 | function windowssharelink($url, $name = null, $returnonly = false) { |
||
| 1109 | |||
| 1110 | /** |
||
| 1111 | * Render a linked E-Mail Address |
||
| 1112 | * |
||
| 1113 | * Honors $conf['mailguard'] setting |
||
| 1114 | * |
||
| 1115 | * @param string $address Email-Address |
||
| 1116 | * @param string|array $name name for the link, array for media file |
||
| 1117 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1118 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1119 | */ |
||
| 1120 | function emaillink($address, $name = null, $returnonly = false) { |
||
| 1158 | |||
| 1159 | /** |
||
| 1160 | * Render an internal media file |
||
| 1161 | * |
||
| 1162 | * @param string $src media ID |
||
| 1163 | * @param string $title descriptive text |
||
| 1164 | * @param string $align left|center|right |
||
| 1165 | * @param int $width width of media in pixel |
||
| 1166 | * @param int $height height of media in pixel |
||
| 1167 | * @param string $cache cache|recache|nocache |
||
| 1168 | * @param string $linking linkonly|detail|nolink |
||
| 1169 | * @param bool $return return HTML instead of adding to $doc |
||
| 1170 | * @return void|string writes to doc attribute or returns html depends on $return |
||
| 1171 | */ |
||
| 1172 | function internalmedia($src, $title = null, $align = null, $width = null, |
||
| 1214 | |||
| 1215 | /** |
||
| 1216 | * Render an external media file |
||
| 1217 | * |
||
| 1218 | * @param string $src full media URL |
||
| 1219 | * @param string $title descriptive text |
||
| 1220 | * @param string $align left|center|right |
||
| 1221 | * @param int $width width of media in pixel |
||
| 1222 | * @param int $height height of media in pixel |
||
| 1223 | * @param string $cache cache|recache|nocache |
||
| 1224 | * @param string $linking linkonly|detail|nolink |
||
| 1225 | * @param bool $return return HTML instead of adding to $doc |
||
| 1226 | * @return void|string writes to doc attribute or returns html depends on $return |
||
| 1227 | */ |
||
| 1228 | function externalmedia($src, $title = null, $align = null, $width = null, |
||
| 1266 | |||
| 1267 | /** |
||
| 1268 | * Renders an RSS feed |
||
| 1269 | * |
||
| 1270 | * @param string $url URL of the feed |
||
| 1271 | * @param array $params Finetuning of the output |
||
| 1272 | * |
||
| 1273 | * @author Andreas Gohr <[email protected]> |
||
| 1274 | */ |
||
| 1275 | function rss($url, $params) { |
||
| 1358 | |||
| 1359 | /** |
||
| 1360 | * Start a table |
||
| 1361 | * |
||
| 1362 | * @param int $maxcols maximum number of columns |
||
| 1363 | * @param int $numrows NOT IMPLEMENTED |
||
| 1364 | * @param int $pos byte position in the original source |
||
| 1365 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1366 | */ |
||
| 1367 | function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) { |
||
| 1386 | |||
| 1387 | /** |
||
| 1388 | * Close a table |
||
| 1389 | * |
||
| 1390 | * @param int $pos byte position in the original source |
||
| 1391 | */ |
||
| 1392 | function table_close($pos = null) { |
||
| 1398 | |||
| 1399 | /** |
||
| 1400 | * Open a table header |
||
| 1401 | */ |
||
| 1402 | function tablethead_open() { |
||
| 1405 | |||
| 1406 | /** |
||
| 1407 | * Close a table header |
||
| 1408 | */ |
||
| 1409 | function tablethead_close() { |
||
| 1412 | |||
| 1413 | /** |
||
| 1414 | * Open a table body |
||
| 1415 | */ |
||
| 1416 | function tabletbody_open() { |
||
| 1419 | |||
| 1420 | /** |
||
| 1421 | * Close a table body |
||
| 1422 | */ |
||
| 1423 | function tabletbody_close() { |
||
| 1426 | |||
| 1427 | /** |
||
| 1428 | * Open a table footer |
||
| 1429 | */ |
||
| 1430 | function tabletfoot_open() { |
||
| 1433 | |||
| 1434 | /** |
||
| 1435 | * Close a table footer |
||
| 1436 | */ |
||
| 1437 | function tabletfoot_close() { |
||
| 1440 | |||
| 1441 | /** |
||
| 1442 | * Open a table row |
||
| 1443 | * |
||
| 1444 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1445 | */ |
||
| 1446 | function tablerow_open($classes = null) { |
||
| 1456 | |||
| 1457 | /** |
||
| 1458 | * Close a table row |
||
| 1459 | */ |
||
| 1460 | function tablerow_close() { |
||
| 1463 | |||
| 1464 | /** |
||
| 1465 | * Open a table header cell |
||
| 1466 | * |
||
| 1467 | * @param int $colspan |
||
| 1468 | * @param string $align left|center|right |
||
| 1469 | * @param int $rowspan |
||
| 1470 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1471 | */ |
||
| 1472 | function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
| 1492 | |||
| 1493 | /** |
||
| 1494 | * Close a table header cell |
||
| 1495 | */ |
||
| 1496 | function tableheader_close() { |
||
| 1499 | |||
| 1500 | /** |
||
| 1501 | * Open a table cell |
||
| 1502 | * |
||
| 1503 | * @param int $colspan |
||
| 1504 | * @param string $align left|center|right |
||
| 1505 | * @param int $rowspan |
||
| 1506 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1507 | */ |
||
| 1508 | function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
| 1528 | |||
| 1529 | /** |
||
| 1530 | * Close a table cell |
||
| 1531 | */ |
||
| 1532 | function tablecell_close() { |
||
| 1535 | |||
| 1536 | /** |
||
| 1537 | * Returns the current header level. |
||
| 1538 | * (required e.g. by the filelist plugin) |
||
| 1539 | * |
||
| 1540 | * @return int The current header level |
||
| 1541 | */ |
||
| 1542 | function getLastlevel() { |
||
| 1545 | |||
| 1546 | #region Utility functions |
||
| 1547 | |||
| 1548 | /** |
||
| 1549 | * Build a link |
||
| 1550 | * |
||
| 1551 | * Assembles all parts defined in $link returns HTML for the link |
||
| 1552 | * |
||
| 1553 | * @param array $link attributes of a link |
||
| 1554 | * @return string |
||
| 1555 | * |
||
| 1556 | * @author Andreas Gohr <[email protected]> |
||
| 1557 | */ |
||
| 1558 | function _formatLink($link) { |
||
| 1587 | |||
| 1588 | /** |
||
| 1589 | * Renders internal and external media |
||
| 1590 | * |
||
| 1591 | * @author Andreas Gohr <[email protected]> |
||
| 1592 | * @param string $src media ID |
||
| 1593 | * @param string $title descriptive text |
||
| 1594 | * @param string $align left|center|right |
||
| 1595 | * @param int $width width of media in pixel |
||
| 1596 | * @param int $height height of media in pixel |
||
| 1597 | * @param string $cache cache|recache|nocache |
||
| 1598 | * @param bool $render should the media be embedded inline or just linked |
||
| 1599 | * @return string |
||
| 1600 | */ |
||
| 1601 | function _media($src, $title = null, $align = null, $width = null, |
||
| 1704 | |||
| 1705 | /** |
||
| 1706 | * Escape string for output |
||
| 1707 | * |
||
| 1708 | * @param $string |
||
| 1709 | * @return string |
||
| 1710 | */ |
||
| 1711 | function _xmlEntities($string) { |
||
| 1714 | |||
| 1715 | /** |
||
| 1716 | * Creates a linkid from a headline |
||
| 1717 | * |
||
| 1718 | * @author Andreas Gohr <[email protected]> |
||
| 1719 | * @param string $title The headline title |
||
| 1720 | * @param boolean $create Create a new unique ID? |
||
| 1721 | * @return string |
||
| 1722 | */ |
||
| 1723 | function _headerToLink($title, $create = false) { |
||
| 1731 | |||
| 1732 | /** |
||
| 1733 | * Construct a title and handle images in titles |
||
| 1734 | * |
||
| 1735 | * @author Harry Fuecks <[email protected]> |
||
| 1736 | * @param string|array $title either string title or media array |
||
| 1737 | * @param string $default default title if nothing else is found |
||
| 1738 | * @param bool $isImage will be set to true if it's a media file |
||
| 1739 | * @param null|string $id linked page id (used to extract title from first heading) |
||
| 1740 | * @param string $linktype content|navigation |
||
| 1741 | * @return string HTML of the title, might be full image tag or just escaped text |
||
| 1742 | */ |
||
| 1743 | function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') { |
||
| 1760 | |||
| 1761 | /** |
||
| 1762 | * Returns HTML code for images used in link titles |
||
| 1763 | * |
||
| 1764 | * @author Andreas Gohr <[email protected]> |
||
| 1765 | * @param array $img |
||
| 1766 | * @return string HTML img tag or similar |
||
| 1767 | */ |
||
| 1768 | function _imageTitle($img) { |
||
| 1787 | |||
| 1788 | /** |
||
| 1789 | * helperfunction to return a basic link to a media |
||
| 1790 | * |
||
| 1791 | * used in internalmedia() and externalmedia() |
||
| 1792 | * |
||
| 1793 | * @author Pierre Spring <[email protected]> |
||
| 1794 | * @param string $src media ID |
||
| 1795 | * @param string $title descriptive text |
||
| 1796 | * @param string $align left|center|right |
||
| 1797 | * @param int $width width of media in pixel |
||
| 1798 | * @param int $height height of media in pixel |
||
| 1799 | * @param string $cache cache|recache|nocache |
||
| 1800 | * @param bool $render should the media be embedded inline or just linked |
||
| 1801 | * @return array associative array with link config |
||
| 1802 | */ |
||
| 1803 | function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) { |
||
| 1819 | |||
| 1820 | /** |
||
| 1821 | * Embed video(s) in HTML |
||
| 1822 | * |
||
| 1823 | * @author Anika Henke <[email protected]> |
||
| 1824 | * @author Schplurtz le Déboulonné <[email protected]> |
||
| 1825 | * |
||
| 1826 | * @param string $src - ID of video to embed |
||
| 1827 | * @param int $width - width of the video in pixels |
||
| 1828 | * @param int $height - height of the video in pixels |
||
| 1829 | * @param array $atts - additional attributes for the <video> tag |
||
| 1830 | * @return string |
||
| 1831 | */ |
||
| 1832 | function _video($src, $width, $height, $atts = null) { |
||
| 1896 | |||
| 1897 | /** |
||
| 1898 | * Embed audio in HTML |
||
| 1899 | * |
||
| 1900 | * @author Anika Henke <[email protected]> |
||
| 1901 | * |
||
| 1902 | * @param string $src - ID of audio to embed |
||
| 1903 | * @param array $atts - additional attributes for the <audio> tag |
||
| 1904 | * @return string |
||
| 1905 | */ |
||
| 1906 | function _audio($src, $atts = array()) { |
||
| 1946 | |||
| 1947 | /** |
||
| 1948 | * _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media() |
||
| 1949 | * which returns an existing media revision less or equal to rev or date_at |
||
| 1950 | * |
||
| 1951 | * @author lisps |
||
| 1952 | * @param string $media_id |
||
| 1953 | * @access protected |
||
| 1954 | * @return string revision ('' for current) |
||
| 1955 | */ |
||
| 1956 | function _getLastMediaRevisionAt($media_id){ |
||
| 1961 | |||
| 1962 | #endregion |
||
| 1963 | } |
||
| 1964 | |||
| 1966 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.