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 string $type The section type identifier |
||
| 63 | * @param string $title The section title |
||
| 64 | * @param int $start The byte position for the edit start |
||
| 65 | * @return string A marker class for the starting HTML element |
||
| 66 | * |
||
| 67 | * @author Adrian Lang <[email protected]> |
||
| 68 | */ |
||
| 69 | public function startSectionEdit($start, $type, $title = null) { |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Finish an edit section range |
||
| 76 | * |
||
| 77 | * @param int $end The byte position for the edit end; null for the rest of the page |
||
| 78 | * |
||
| 79 | * @author Adrian Lang <[email protected]> |
||
| 80 | */ |
||
| 81 | public function finishSectionEdit($end = null) { |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Returns the format produced by this renderer. |
||
| 95 | * |
||
| 96 | * @return string always 'xhtml' |
||
| 97 | */ |
||
| 98 | function getFormat() { |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Initialize the document |
||
| 104 | */ |
||
| 105 | function document_start() { |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Finalize the document |
||
| 113 | */ |
||
| 114 | function document_end() { |
||
| 167 | |||
| 168 | /** |
||
| 169 | * Add an item to the TOC |
||
| 170 | * |
||
| 171 | * @param string $id the hash link |
||
| 172 | * @param string $text the text to display |
||
| 173 | * @param int $level the nesting level |
||
| 174 | */ |
||
| 175 | function toc_additem($id, $text, $level) { |
||
| 183 | |||
| 184 | /** |
||
| 185 | * Render a heading |
||
| 186 | * |
||
| 187 | * @param string $text the text to display |
||
| 188 | * @param int $level header level |
||
| 189 | * @param int $pos byte position in the original source |
||
| 190 | */ |
||
| 191 | function header($text, $level, $pos) { |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Open a new section |
||
| 229 | * |
||
| 230 | * @param int $level section level (as determined by the previous header) |
||
| 231 | */ |
||
| 232 | function section_open($level) { |
||
| 235 | |||
| 236 | /** |
||
| 237 | * Close the current section |
||
| 238 | */ |
||
| 239 | function section_close() { |
||
| 242 | |||
| 243 | /** |
||
| 244 | * Render plain text data |
||
| 245 | * |
||
| 246 | * @param $text |
||
| 247 | */ |
||
| 248 | function cdata($text) { |
||
| 251 | |||
| 252 | /** |
||
| 253 | * Open a paragraph |
||
| 254 | */ |
||
| 255 | function p_open() { |
||
| 258 | |||
| 259 | /** |
||
| 260 | * Close a paragraph |
||
| 261 | */ |
||
| 262 | function p_close() { |
||
| 265 | |||
| 266 | /** |
||
| 267 | * Create a line break |
||
| 268 | */ |
||
| 269 | function linebreak() { |
||
| 272 | |||
| 273 | /** |
||
| 274 | * Create a horizontal line |
||
| 275 | */ |
||
| 276 | function hr() { |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Start strong (bold) formatting |
||
| 282 | */ |
||
| 283 | function strong_open() { |
||
| 286 | |||
| 287 | /** |
||
| 288 | * Stop strong (bold) formatting |
||
| 289 | */ |
||
| 290 | function strong_close() { |
||
| 293 | |||
| 294 | /** |
||
| 295 | * Start emphasis (italics) formatting |
||
| 296 | */ |
||
| 297 | function emphasis_open() { |
||
| 300 | |||
| 301 | /** |
||
| 302 | * Stop emphasis (italics) formatting |
||
| 303 | */ |
||
| 304 | function emphasis_close() { |
||
| 307 | |||
| 308 | /** |
||
| 309 | * Start underline formatting |
||
| 310 | */ |
||
| 311 | function underline_open() { |
||
| 314 | |||
| 315 | /** |
||
| 316 | * Stop underline formatting |
||
| 317 | */ |
||
| 318 | function underline_close() { |
||
| 321 | |||
| 322 | /** |
||
| 323 | * Start monospace formatting |
||
| 324 | */ |
||
| 325 | function monospace_open() { |
||
| 328 | |||
| 329 | /** |
||
| 330 | * Stop monospace formatting |
||
| 331 | */ |
||
| 332 | function monospace_close() { |
||
| 335 | |||
| 336 | /** |
||
| 337 | * Start a subscript |
||
| 338 | */ |
||
| 339 | function subscript_open() { |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Stop a subscript |
||
| 345 | */ |
||
| 346 | function subscript_close() { |
||
| 349 | |||
| 350 | /** |
||
| 351 | * Start a superscript |
||
| 352 | */ |
||
| 353 | function superscript_open() { |
||
| 356 | |||
| 357 | /** |
||
| 358 | * Stop a superscript |
||
| 359 | */ |
||
| 360 | function superscript_close() { |
||
| 363 | |||
| 364 | /** |
||
| 365 | * Start deleted (strike-through) formatting |
||
| 366 | */ |
||
| 367 | function deleted_open() { |
||
| 370 | |||
| 371 | /** |
||
| 372 | * Stop deleted (strike-through) formatting |
||
| 373 | */ |
||
| 374 | function deleted_close() { |
||
| 377 | |||
| 378 | /** |
||
| 379 | * Callback for footnote start syntax |
||
| 380 | * |
||
| 381 | * All following content will go to the footnote instead of |
||
| 382 | * the document. To achieve this the previous rendered content |
||
| 383 | * is moved to $store and $doc is cleared |
||
| 384 | * |
||
| 385 | * @author Andreas Gohr <[email protected]> |
||
| 386 | */ |
||
| 387 | function footnote_open() { |
||
| 393 | |||
| 394 | /** |
||
| 395 | * Callback for footnote end syntax |
||
| 396 | * |
||
| 397 | * All rendered content is moved to the $footnotes array and the old |
||
| 398 | * content is restored from $store again |
||
| 399 | * |
||
| 400 | * @author Andreas Gohr |
||
| 401 | */ |
||
| 402 | function footnote_close() { |
||
| 427 | |||
| 428 | /** |
||
| 429 | * Open an unordered list |
||
| 430 | * |
||
| 431 | * @param string|string[] $classes css class |
||
| 432 | */ |
||
| 433 | function listu_open($classes = null) { |
||
| 441 | |||
| 442 | /** |
||
| 443 | * Close an unordered list |
||
| 444 | */ |
||
| 445 | function listu_close() { |
||
| 448 | |||
| 449 | /** |
||
| 450 | * Open an ordered list |
||
| 451 | * |
||
| 452 | * @param string|string[] $classes css class |
||
| 453 | */ |
||
| 454 | function listo_open($classes = null) { |
||
| 462 | |||
| 463 | /** |
||
| 464 | * Close an ordered list |
||
| 465 | */ |
||
| 466 | function listo_close() { |
||
| 469 | |||
| 470 | /** |
||
| 471 | * Open a list item |
||
| 472 | * |
||
| 473 | * @param int $level the nesting level |
||
| 474 | * @param bool $node true when a node; false when a leaf |
||
| 475 | */ |
||
| 476 | function listitem_open($level, $node=false) { |
||
| 480 | |||
| 481 | /** |
||
| 482 | * Close a list item |
||
| 483 | */ |
||
| 484 | function listitem_close() { |
||
| 487 | |||
| 488 | /** |
||
| 489 | * Start the content of a list item |
||
| 490 | */ |
||
| 491 | function listcontent_open() { |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Stop the content of a list item |
||
| 497 | */ |
||
| 498 | function listcontent_close() { |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Output unformatted $text |
||
| 504 | * |
||
| 505 | * Defaults to $this->cdata() |
||
| 506 | * |
||
| 507 | * @param string $text |
||
| 508 | */ |
||
| 509 | function unformatted($text) { |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Execute PHP code if allowed |
||
| 515 | * |
||
| 516 | * @param string $text PHP code that is either executed or printed |
||
| 517 | * @param string $wrapper html element to wrap result if $conf['phpok'] is okff |
||
| 518 | * |
||
| 519 | * @author Andreas Gohr <[email protected]> |
||
| 520 | */ |
||
| 521 | function php($text, $wrapper = 'code') { |
||
| 533 | |||
| 534 | /** |
||
| 535 | * Output block level PHP code |
||
| 536 | * |
||
| 537 | * If $conf['phpok'] is true this should evaluate the given code and append the result |
||
| 538 | * to $doc |
||
| 539 | * |
||
| 540 | * @param string $text The PHP code |
||
| 541 | */ |
||
| 542 | function phpblock($text) { |
||
| 545 | |||
| 546 | /** |
||
| 547 | * Insert HTML if allowed |
||
| 548 | * |
||
| 549 | * @param string $text html text |
||
| 550 | * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff |
||
| 551 | * |
||
| 552 | * @author Andreas Gohr <[email protected]> |
||
| 553 | */ |
||
| 554 | function html($text, $wrapper = 'code') { |
||
| 563 | |||
| 564 | /** |
||
| 565 | * Output raw block-level HTML |
||
| 566 | * |
||
| 567 | * If $conf['htmlok'] is true this should add the code as is to $doc |
||
| 568 | * |
||
| 569 | * @param string $text The HTML |
||
| 570 | */ |
||
| 571 | function htmlblock($text) { |
||
| 574 | |||
| 575 | /** |
||
| 576 | * Start a block quote |
||
| 577 | */ |
||
| 578 | function quote_open() { |
||
| 581 | |||
| 582 | /** |
||
| 583 | * Stop a block quote |
||
| 584 | */ |
||
| 585 | function quote_close() { |
||
| 588 | |||
| 589 | /** |
||
| 590 | * Output preformatted text |
||
| 591 | * |
||
| 592 | * @param string $text |
||
| 593 | */ |
||
| 594 | function preformatted($text) { |
||
| 597 | |||
| 598 | /** |
||
| 599 | * Display text as file content, optionally syntax highlighted |
||
| 600 | * |
||
| 601 | * @param string $text text to show |
||
| 602 | * @param string $language programming language to use for syntax highlighting |
||
| 603 | * @param string $filename file path label |
||
| 604 | */ |
||
| 605 | function file($text, $language = null, $filename = null) { |
||
| 608 | |||
| 609 | /** |
||
| 610 | * Display text as code content, optionally syntax highlighted |
||
| 611 | * |
||
| 612 | * @param string $text text to show |
||
| 613 | * @param string $language programming language to use for syntax highlighting |
||
| 614 | * @param string $filename file path label |
||
| 615 | */ |
||
| 616 | function code($text, $language = null, $filename = null) { |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Use GeSHi to highlight language syntax in code and file blocks |
||
| 622 | * |
||
| 623 | * @author Andreas Gohr <[email protected]> |
||
| 624 | * @param string $type code|file |
||
| 625 | * @param string $text text to show |
||
| 626 | * @param string $language programming language to use for syntax highlighting |
||
| 627 | * @param string $filename file path label |
||
| 628 | */ |
||
| 629 | function _highlight($type, $text, $language = null, $filename = null) { |
||
| 667 | |||
| 668 | /** |
||
| 669 | * Format an acronym |
||
| 670 | * |
||
| 671 | * Uses $this->acronyms |
||
| 672 | * |
||
| 673 | * @param string $acronym |
||
| 674 | */ |
||
| 675 | function acronym($acronym) { |
||
| 688 | |||
| 689 | /** |
||
| 690 | * Format a smiley |
||
| 691 | * |
||
| 692 | * Uses $this->smiley |
||
| 693 | * |
||
| 694 | * @param string $smiley |
||
| 695 | */ |
||
| 696 | function smiley($smiley) { |
||
| 705 | |||
| 706 | /** |
||
| 707 | * Format an entity |
||
| 708 | * |
||
| 709 | * Entities are basically small text replacements |
||
| 710 | * |
||
| 711 | * Uses $this->entities |
||
| 712 | * |
||
| 713 | * @param string $entity |
||
| 714 | */ |
||
| 715 | function entity($entity) { |
||
| 722 | |||
| 723 | /** |
||
| 724 | * Typographically format a multiply sign |
||
| 725 | * |
||
| 726 | * Example: ($x=640, $y=480) should result in "640×480" |
||
| 727 | * |
||
| 728 | * @param string|int $x first value |
||
| 729 | * @param string|int $y second value |
||
| 730 | */ |
||
| 731 | function multiplyentity($x, $y) { |
||
| 734 | |||
| 735 | /** |
||
| 736 | * Render an opening single quote char (language specific) |
||
| 737 | */ |
||
| 738 | function singlequoteopening() { |
||
| 742 | |||
| 743 | /** |
||
| 744 | * Render a closing single quote char (language specific) |
||
| 745 | */ |
||
| 746 | function singlequoteclosing() { |
||
| 750 | |||
| 751 | /** |
||
| 752 | * Render an apostrophe char (language specific) |
||
| 753 | */ |
||
| 754 | function apostrophe() { |
||
| 758 | |||
| 759 | /** |
||
| 760 | * Render an opening double quote char (language specific) |
||
| 761 | */ |
||
| 762 | function doublequoteopening() { |
||
| 766 | |||
| 767 | /** |
||
| 768 | * Render an closinging double quote char (language specific) |
||
| 769 | */ |
||
| 770 | function doublequoteclosing() { |
||
| 774 | |||
| 775 | /** |
||
| 776 | * Render a CamelCase link |
||
| 777 | * |
||
| 778 | * @param string $link The link name |
||
| 779 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 780 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 781 | * |
||
| 782 | * @see http://en.wikipedia.org/wiki/CamelCase |
||
| 783 | */ |
||
| 784 | function camelcaselink($link, $returnonly = false) { |
||
| 791 | |||
| 792 | /** |
||
| 793 | * Render a page local link |
||
| 794 | * |
||
| 795 | * @param string $hash hash link identifier |
||
| 796 | * @param string $name name for the link |
||
| 797 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 798 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 799 | */ |
||
| 800 | function locallink($hash, $name = null, $returnonly = false) { |
||
| 816 | |||
| 817 | /** |
||
| 818 | * Render an internal Wiki Link |
||
| 819 | * |
||
| 820 | * $search,$returnonly & $linktype are not for the renderer but are used |
||
| 821 | * elsewhere - no need to implement them in other renderers |
||
| 822 | * |
||
| 823 | * @author Andreas Gohr <[email protected]> |
||
| 824 | * @param string $id pageid |
||
| 825 | * @param string|null $name link name |
||
| 826 | * @param string|null $search adds search url param |
||
| 827 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 828 | * @param string $linktype type to set use of headings |
||
| 829 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 830 | */ |
||
| 831 | function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { |
||
| 913 | |||
| 914 | /** |
||
| 915 | * Render an external link |
||
| 916 | * |
||
| 917 | * @param string $url full URL with scheme |
||
| 918 | * @param string|array $name name for the link, array for media file |
||
| 919 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 920 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 921 | */ |
||
| 922 | function externallink($url, $name = null, $returnonly = false) { |
||
| 973 | |||
| 974 | /** |
||
| 975 | * Render an interwiki link |
||
| 976 | * |
||
| 977 | * You may want to use $this->_resolveInterWiki() here |
||
| 978 | * |
||
| 979 | * @param string $match original link - probably not much use |
||
| 980 | * @param string|array $name name for the link, array for media file |
||
| 981 | * @param string $wikiName indentifier (shortcut) for the remote wiki |
||
| 982 | * @param string $wikiUri the fragment parsed from the original link |
||
| 983 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 984 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 985 | */ |
||
| 986 | function interwikilink($match, $name = null, $wikiName, $wikiUri, $returnonly = false) { |
||
| 1032 | |||
| 1033 | /** |
||
| 1034 | * Link to windows share |
||
| 1035 | * |
||
| 1036 | * @param string $url the link |
||
| 1037 | * @param string|array $name name for the link, array for media file |
||
| 1038 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1039 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1040 | */ |
||
| 1041 | function windowssharelink($url, $name = null, $returnonly = false) { |
||
| 1070 | |||
| 1071 | /** |
||
| 1072 | * Render a linked E-Mail Address |
||
| 1073 | * |
||
| 1074 | * Honors $conf['mailguard'] setting |
||
| 1075 | * |
||
| 1076 | * @param string $address Email-Address |
||
| 1077 | * @param string|array $name name for the link, array for media file |
||
| 1078 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1079 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1080 | */ |
||
| 1081 | function emaillink($address, $name = null, $returnonly = false) { |
||
| 1119 | |||
| 1120 | /** |
||
| 1121 | * Render an internal media file |
||
| 1122 | * |
||
| 1123 | * @param string $src media ID |
||
| 1124 | * @param string $title descriptive text |
||
| 1125 | * @param string $align left|center|right |
||
| 1126 | * @param int $width width of media in pixel |
||
| 1127 | * @param int $height height of media in pixel |
||
| 1128 | * @param string $cache cache|recache|nocache |
||
| 1129 | * @param string $linking linkonly|detail|nolink |
||
| 1130 | * @param bool $return return HTML instead of adding to $doc |
||
| 1131 | * @return void|string writes to doc attribute or returns html depends on $return |
||
| 1132 | */ |
||
| 1133 | function internalmedia($src, $title = null, $align = null, $width = null, |
||
| 1173 | |||
| 1174 | /** |
||
| 1175 | * Render an external media file |
||
| 1176 | * |
||
| 1177 | * @param string $src full media URL |
||
| 1178 | * @param string $title descriptive text |
||
| 1179 | * @param string $align left|center|right |
||
| 1180 | * @param int $width width of media in pixel |
||
| 1181 | * @param int $height height of media in pixel |
||
| 1182 | * @param string $cache cache|recache|nocache |
||
| 1183 | * @param string $linking linkonly|detail|nolink |
||
| 1184 | * @param bool $return return HTML instead of adding to $doc |
||
| 1185 | * @return void|string writes to doc attribute or returns html depends on $return |
||
| 1186 | */ |
||
| 1187 | function externalmedia($src, $title = null, $align = null, $width = null, |
||
| 1220 | |||
| 1221 | /** |
||
| 1222 | * Renders an RSS feed |
||
| 1223 | * |
||
| 1224 | * @param string $url URL of the feed |
||
| 1225 | * @param array $params Finetuning of the output |
||
| 1226 | * |
||
| 1227 | * @author Andreas Gohr <[email protected]> |
||
| 1228 | */ |
||
| 1229 | function rss($url, $params) { |
||
| 1312 | |||
| 1313 | /** |
||
| 1314 | * Start a table |
||
| 1315 | * |
||
| 1316 | * @param int $maxcols maximum number of columns |
||
| 1317 | * @param int $numrows NOT IMPLEMENTED |
||
| 1318 | * @param int $pos byte position in the original source |
||
| 1319 | * @param string|string[] $classes css class |
||
| 1320 | */ |
||
| 1321 | function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) { |
||
| 1335 | |||
| 1336 | /** |
||
| 1337 | * Close a table |
||
| 1338 | * |
||
| 1339 | * @param int $pos byte position in the original source |
||
| 1340 | */ |
||
| 1341 | function table_close($pos = null) { |
||
| 1347 | |||
| 1348 | /** |
||
| 1349 | * Open a table header |
||
| 1350 | */ |
||
| 1351 | function tablethead_open() { |
||
| 1354 | |||
| 1355 | /** |
||
| 1356 | * Close a table header |
||
| 1357 | */ |
||
| 1358 | function tablethead_close() { |
||
| 1361 | |||
| 1362 | /** |
||
| 1363 | * Open a table body |
||
| 1364 | */ |
||
| 1365 | function tabletbody_open() { |
||
| 1368 | |||
| 1369 | /** |
||
| 1370 | * Close a table body |
||
| 1371 | */ |
||
| 1372 | function tabletbody_close() { |
||
| 1375 | |||
| 1376 | /** |
||
| 1377 | * Open a table row |
||
| 1378 | * |
||
| 1379 | * @param string|string[] $classes css class |
||
| 1380 | */ |
||
| 1381 | function tablerow_open($classes = null) { |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Close a table row |
||
| 1394 | */ |
||
| 1395 | function tablerow_close() { |
||
| 1398 | |||
| 1399 | /** |
||
| 1400 | * Open a table header cell |
||
| 1401 | * |
||
| 1402 | * @param int $colspan |
||
| 1403 | * @param string $align left|center|right |
||
| 1404 | * @param int $rowspan |
||
| 1405 | * @param string|string[] $classes css class |
||
| 1406 | */ |
||
| 1407 | function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
| 1427 | |||
| 1428 | /** |
||
| 1429 | * Close a table header cell |
||
| 1430 | */ |
||
| 1431 | function tableheader_close() { |
||
| 1434 | |||
| 1435 | /** |
||
| 1436 | * Open a table cell |
||
| 1437 | * |
||
| 1438 | * @param int $colspan |
||
| 1439 | * @param string $align left|center|right |
||
| 1440 | * @param int $rowspan |
||
| 1441 | * @param string|string[] $classes css class |
||
| 1442 | */ |
||
| 1443 | function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
| 1463 | |||
| 1464 | /** |
||
| 1465 | * Close a table cell |
||
| 1466 | */ |
||
| 1467 | function tablecell_close() { |
||
| 1470 | |||
| 1471 | #region Utility functions |
||
| 1472 | |||
| 1473 | /** |
||
| 1474 | * Build a link |
||
| 1475 | * |
||
| 1476 | * Assembles all parts defined in $link returns HTML for the link |
||
| 1477 | * |
||
| 1478 | * @param array $link attributes of a link |
||
| 1479 | * @return string |
||
| 1480 | * |
||
| 1481 | * @author Andreas Gohr <[email protected]> |
||
| 1482 | */ |
||
| 1483 | function _formatLink($link) { |
||
| 1512 | |||
| 1513 | /** |
||
| 1514 | * Renders internal and external media |
||
| 1515 | * |
||
| 1516 | * @author Andreas Gohr <[email protected]> |
||
| 1517 | * @param string $src media ID |
||
| 1518 | * @param string $title descriptive text |
||
| 1519 | * @param string $align left|center|right |
||
| 1520 | * @param int $width width of media in pixel |
||
| 1521 | * @param int $height height of media in pixel |
||
| 1522 | * @param string $cache cache|recache|nocache |
||
| 1523 | * @param bool $render should the media be embedded inline or just linked |
||
| 1524 | * @return string |
||
| 1525 | */ |
||
| 1526 | function _media($src, $title = null, $align = null, $width = null, |
||
| 1629 | |||
| 1630 | /** |
||
| 1631 | * Escape string for output |
||
| 1632 | * |
||
| 1633 | * @param $string |
||
| 1634 | * @return string |
||
| 1635 | */ |
||
| 1636 | function _xmlEntities($string) { |
||
| 1639 | |||
| 1640 | /** |
||
| 1641 | * Creates a linkid from a headline |
||
| 1642 | * |
||
| 1643 | * @author Andreas Gohr <[email protected]> |
||
| 1644 | * @param string $title The headline title |
||
| 1645 | * @param boolean $create Create a new unique ID? |
||
| 1646 | * @return string |
||
| 1647 | */ |
||
| 1648 | function _headerToLink($title, $create = false) { |
||
| 1656 | |||
| 1657 | /** |
||
| 1658 | * Construct a title and handle images in titles |
||
| 1659 | * |
||
| 1660 | * @author Harry Fuecks <[email protected]> |
||
| 1661 | * @param string|array $title either string title or media array |
||
| 1662 | * @param string $default default title if nothing else is found |
||
| 1663 | * @param bool $isImage will be set to true if it's a media file |
||
| 1664 | * @param null|string $id linked page id (used to extract title from first heading) |
||
| 1665 | * @param string $linktype content|navigation |
||
| 1666 | * @return string HTML of the title, might be full image tag or just escaped text |
||
| 1667 | */ |
||
| 1668 | function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') { |
||
| 1685 | |||
| 1686 | /** |
||
| 1687 | * Returns HTML code for images used in link titles |
||
| 1688 | * |
||
| 1689 | * @author Andreas Gohr <[email protected]> |
||
| 1690 | * @param array $img |
||
| 1691 | * @return string HTML img tag or similar |
||
| 1692 | */ |
||
| 1693 | function _imageTitle($img) { |
||
| 1712 | |||
| 1713 | /** |
||
| 1714 | * helperfunction to return a basic link to a media |
||
| 1715 | * |
||
| 1716 | * used in internalmedia() and externalmedia() |
||
| 1717 | * |
||
| 1718 | * @author Pierre Spring <[email protected]> |
||
| 1719 | * @param string $src media ID |
||
| 1720 | * @param string $title descriptive text |
||
| 1721 | * @param string $align left|center|right |
||
| 1722 | * @param int $width width of media in pixel |
||
| 1723 | * @param int $height height of media in pixel |
||
| 1724 | * @param string $cache cache|recache|nocache |
||
| 1725 | * @param bool $render should the media be embedded inline or just linked |
||
| 1726 | * @return array associative array with link config |
||
| 1727 | */ |
||
| 1728 | function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) { |
||
| 1744 | |||
| 1745 | /** |
||
| 1746 | * Embed video(s) in HTML |
||
| 1747 | * |
||
| 1748 | * @author Anika Henke <[email protected]> |
||
| 1749 | * |
||
| 1750 | * @param string $src - ID of video to embed |
||
| 1751 | * @param int $width - width of the video in pixels |
||
| 1752 | * @param int $height - height of the video in pixels |
||
| 1753 | * @param array $atts - additional attributes for the <video> tag |
||
| 1754 | * @return string |
||
| 1755 | */ |
||
| 1756 | function _video($src, $width, $height, $atts = null) { |
||
| 1810 | |||
| 1811 | /** |
||
| 1812 | * Embed audio in HTML |
||
| 1813 | * |
||
| 1814 | * @author Anika Henke <[email protected]> |
||
| 1815 | * |
||
| 1816 | * @param string $src - ID of audio to embed |
||
| 1817 | * @param array $atts - additional attributes for the <audio> tag |
||
| 1818 | * @return string |
||
| 1819 | */ |
||
| 1820 | function _audio($src, $atts = array()) { |
||
| 1860 | |||
| 1861 | /** |
||
| 1862 | * _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media() |
||
| 1863 | * which returns an existing media revision less or equal to rev or date_at |
||
| 1864 | * |
||
| 1865 | * @author lisps |
||
| 1866 | * @param string $media_id |
||
| 1867 | * @access protected |
||
| 1868 | * @return string revision ('' for current) |
||
| 1869 | */ |
||
| 1870 | function _getLastMediaRevisionAt($media_id){ |
||
| 1875 | |||
| 1876 | #endregion |
||
| 1877 | } |
||
| 1878 | |||
| 1880 |
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.