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  | 
            ||
| 14 | class Doku_Renderer_xhtml extends Doku_Renderer { | 
            ||
| 15 | /** @var array store the table of contents */  | 
            ||
| 16 | public $toc = array();  | 
            ||
| 17 | |||
| 18 | /** @var array A stack of section edit data */  | 
            ||
| 19 | protected $sectionedits = array();  | 
            ||
| 20 | |||
| 21 | /** @var string|int link pages and media against this revision */  | 
            ||
| 22 | public $date_at = '';  | 
            ||
| 23 | |||
| 24 | /** @var int last section edit id, used by startSectionEdit */  | 
            ||
| 25 | protected $lastsecid = 0;  | 
            ||
| 26 | |||
| 27 | /** @var array a list of footnotes, list starts at 1! */  | 
            ||
| 28 | protected $footnotes = array();  | 
            ||
| 29 | |||
| 30 | /** @var int current section level */  | 
            ||
| 31 | protected $lastlevel = 0;  | 
            ||
| 32 | /** @var array section node tracker */  | 
            ||
| 33 | protected $node = array(0, 0, 0, 0, 0);  | 
            ||
| 34 | |||
| 35 | /** @var string temporary $doc store */  | 
            ||
| 36 | protected $store = '';  | 
            ||
| 37 | |||
| 38 | /** @var array global counter, for table classes etc. */  | 
            ||
| 39 | protected $_counter = array(); //  | 
            ||
| 40 | |||
| 41 | /** @var int counts the code and file blocks, used to provide download links */  | 
            ||
| 42 | protected $_codeblock = 0;  | 
            ||
| 43 | |||
| 44 | /** @var array list of allowed URL schemes */  | 
            ||
| 45 | protected $schemes = null;  | 
            ||
| 46 | |||
| 47 | /**  | 
            ||
| 48 | * Register a new edit section range  | 
            ||
| 49 | *  | 
            ||
| 50 | * @param int $start The byte position for the edit start  | 
            ||
| 51 | * @param array $data Associative array with section data:  | 
            ||
| 52 | * Key 'name': the section name/title  | 
            ||
| 53 | * Key 'target': the target for the section edit,  | 
            ||
| 54 | * e.g. 'section' or 'table'  | 
            ||
| 55 | * Key 'hid': header id  | 
            ||
| 56 | * Key 'codeblockOffset': actual code block index  | 
            ||
| 57 | * Key 'start': set in startSectionEdit(),  | 
            ||
| 58 | * do not set yourself  | 
            ||
| 59 | * Key 'range': calculated from 'start' and  | 
            ||
| 60 | * $key in finishSectionEdit(),  | 
            ||
| 61 | * do not set yourself  | 
            ||
| 62 | * @return string A marker class for the starting HTML element  | 
            ||
| 63 | *  | 
            ||
| 64 | * @author Adrian Lang <[email protected]>  | 
            ||
| 65 | */  | 
            ||
| 66 |     public function startSectionEdit($start, $data) { | 
            ||
| 87 | |||
| 88 | /**  | 
            ||
| 89 | * Finish an edit section range  | 
            ||
| 90 | *  | 
            ||
| 91 | * @param int $end The byte position for the edit end; null for the rest of the page  | 
            ||
| 92 | *  | 
            ||
| 93 | * @author Adrian Lang <[email protected]>  | 
            ||
| 94 | */  | 
            ||
| 95 |     public function finishSectionEdit($end = null, $hid = null) { | 
            ||
| 107 | |||
| 108 | /**  | 
            ||
| 109 | * Returns the format produced by this renderer.  | 
            ||
| 110 | *  | 
            ||
| 111 | * @return string always 'xhtml'  | 
            ||
| 112 | */  | 
            ||
| 113 |     public function getFormat() { | 
            ||
| 116 | |||
| 117 | /**  | 
            ||
| 118 | * Initialize the document  | 
            ||
| 119 | */  | 
            ||
| 120 |     public function document_start() { | 
            ||
| 124 | |||
| 125 | /**  | 
            ||
| 126 | * Finalize the document  | 
            ||
| 127 | */  | 
            ||
| 128 |     public function document_end() { | 
            ||
| 185 | |||
| 186 | /**  | 
            ||
| 187 | * Add an item to the TOC  | 
            ||
| 188 | *  | 
            ||
| 189 | * @param string $id the hash link  | 
            ||
| 190 | * @param string $text the text to display  | 
            ||
| 191 | * @param int $level the nesting level  | 
            ||
| 192 | */  | 
            ||
| 193 |     public function toc_additem($id, $text, $level) { | 
            ||
| 201 | |||
| 202 | /**  | 
            ||
| 203 | * Render a heading  | 
            ||
| 204 | *  | 
            ||
| 205 | * @param string $text the text to display  | 
            ||
| 206 | * @param int $level header level  | 
            ||
| 207 | * @param int $pos byte position in the original source  | 
            ||
| 208 | */  | 
            ||
| 209 |     public function header($text, $level, $pos) { | 
            ||
| 249 | |||
| 250 | /**  | 
            ||
| 251 | * Open a new section  | 
            ||
| 252 | *  | 
            ||
| 253 | * @param int $level section level (as determined by the previous header)  | 
            ||
| 254 | */  | 
            ||
| 255 |     public function section_open($level) { | 
            ||
| 258 | |||
| 259 | /**  | 
            ||
| 260 | * Close the current section  | 
            ||
| 261 | */  | 
            ||
| 262 |     public function section_close() { | 
            ||
| 265 | |||
| 266 | /**  | 
            ||
| 267 | * Render plain text data  | 
            ||
| 268 | *  | 
            ||
| 269 | * @param $text  | 
            ||
| 270 | */  | 
            ||
| 271 |     public function cdata($text) { | 
            ||
| 274 | |||
| 275 | /**  | 
            ||
| 276 | * Open a paragraph  | 
            ||
| 277 | */  | 
            ||
| 278 |     public function p_open() { | 
            ||
| 281 | |||
| 282 | /**  | 
            ||
| 283 | * Close a paragraph  | 
            ||
| 284 | */  | 
            ||
| 285 |     public function p_close() { | 
            ||
| 288 | |||
| 289 | /**  | 
            ||
| 290 | * Create a line break  | 
            ||
| 291 | */  | 
            ||
| 292 |     public function linebreak() { | 
            ||
| 295 | |||
| 296 | /**  | 
            ||
| 297 | * Create a horizontal line  | 
            ||
| 298 | */  | 
            ||
| 299 |     public function hr() { | 
            ||
| 302 | |||
| 303 | /**  | 
            ||
| 304 | * Start strong (bold) formatting  | 
            ||
| 305 | */  | 
            ||
| 306 |     public function strong_open() { | 
            ||
| 309 | |||
| 310 | /**  | 
            ||
| 311 | * Stop strong (bold) formatting  | 
            ||
| 312 | */  | 
            ||
| 313 |     public function strong_close() { | 
            ||
| 316 | |||
| 317 | /**  | 
            ||
| 318 | * Start emphasis (italics) formatting  | 
            ||
| 319 | */  | 
            ||
| 320 |     public function emphasis_open() { | 
            ||
| 323 | |||
| 324 | /**  | 
            ||
| 325 | * Stop emphasis (italics) formatting  | 
            ||
| 326 | */  | 
            ||
| 327 |     public function emphasis_close() { | 
            ||
| 330 | |||
| 331 | /**  | 
            ||
| 332 | * Start underline formatting  | 
            ||
| 333 | */  | 
            ||
| 334 |     public function underline_open() { | 
            ||
| 337 | |||
| 338 | /**  | 
            ||
| 339 | * Stop underline formatting  | 
            ||
| 340 | */  | 
            ||
| 341 |     public function underline_close() { | 
            ||
| 344 | |||
| 345 | /**  | 
            ||
| 346 | * Start monospace formatting  | 
            ||
| 347 | */  | 
            ||
| 348 |     public function monospace_open() { | 
            ||
| 351 | |||
| 352 | /**  | 
            ||
| 353 | * Stop monospace formatting  | 
            ||
| 354 | */  | 
            ||
| 355 |     public function monospace_close() { | 
            ||
| 358 | |||
| 359 | /**  | 
            ||
| 360 | * Start a subscript  | 
            ||
| 361 | */  | 
            ||
| 362 |     public function subscript_open() { | 
            ||
| 365 | |||
| 366 | /**  | 
            ||
| 367 | * Stop a subscript  | 
            ||
| 368 | */  | 
            ||
| 369 |     public function subscript_close() { | 
            ||
| 372 | |||
| 373 | /**  | 
            ||
| 374 | * Start a superscript  | 
            ||
| 375 | */  | 
            ||
| 376 |     public function superscript_open() { | 
            ||
| 379 | |||
| 380 | /**  | 
            ||
| 381 | * Stop a superscript  | 
            ||
| 382 | */  | 
            ||
| 383 |     public function superscript_close() { | 
            ||
| 386 | |||
| 387 | /**  | 
            ||
| 388 | * Start deleted (strike-through) formatting  | 
            ||
| 389 | */  | 
            ||
| 390 |     public function deleted_open() { | 
            ||
| 393 | |||
| 394 | /**  | 
            ||
| 395 | * Stop deleted (strike-through) formatting  | 
            ||
| 396 | */  | 
            ||
| 397 |     public function deleted_close() { | 
            ||
| 400 | |||
| 401 | /**  | 
            ||
| 402 | * Callback for footnote start syntax  | 
            ||
| 403 | *  | 
            ||
| 404 | * All following content will go to the footnote instead of  | 
            ||
| 405 | * the document. To achieve this the previous rendered content  | 
            ||
| 406 | * is moved to $store and $doc is cleared  | 
            ||
| 407 | *  | 
            ||
| 408 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 409 | */  | 
            ||
| 410 |     public function footnote_open() { | 
            ||
| 416 | |||
| 417 | /**  | 
            ||
| 418 | * Callback for footnote end syntax  | 
            ||
| 419 | *  | 
            ||
| 420 | * All rendered content is moved to the $footnotes array and the old  | 
            ||
| 421 | * content is restored from $store again  | 
            ||
| 422 | *  | 
            ||
| 423 | * @author Andreas Gohr  | 
            ||
| 424 | */  | 
            ||
| 425 |     public function footnote_close() { | 
            ||
| 450 | |||
| 451 | /**  | 
            ||
| 452 | * Open an unordered list  | 
            ||
| 453 | *  | 
            ||
| 454 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input  | 
            ||
| 455 | */  | 
            ||
| 456 |     public function listu_open($classes = null) { | 
            ||
| 464 | |||
| 465 | /**  | 
            ||
| 466 | * Close an unordered list  | 
            ||
| 467 | */  | 
            ||
| 468 |     public function listu_close() { | 
            ||
| 471 | |||
| 472 | /**  | 
            ||
| 473 | * Open an ordered list  | 
            ||
| 474 | *  | 
            ||
| 475 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input  | 
            ||
| 476 | */  | 
            ||
| 477 |     public function listo_open($classes = null) { | 
            ||
| 485 | |||
| 486 | /**  | 
            ||
| 487 | * Close an ordered list  | 
            ||
| 488 | */  | 
            ||
| 489 |     public function listo_close() { | 
            ||
| 492 | |||
| 493 | /**  | 
            ||
| 494 | * Open a list item  | 
            ||
| 495 | *  | 
            ||
| 496 | * @param int $level the nesting level  | 
            ||
| 497 | * @param bool $node true when a node; false when a leaf  | 
            ||
| 498 | */  | 
            ||
| 499 |     public function listitem_open($level, $node=false) { | 
            ||
| 503 | |||
| 504 | /**  | 
            ||
| 505 | * Close a list item  | 
            ||
| 506 | */  | 
            ||
| 507 |     public function listitem_close() { | 
            ||
| 510 | |||
| 511 | /**  | 
            ||
| 512 | * Start the content of a list item  | 
            ||
| 513 | */  | 
            ||
| 514 |     public function listcontent_open() { | 
            ||
| 517 | |||
| 518 | /**  | 
            ||
| 519 | * Stop the content of a list item  | 
            ||
| 520 | */  | 
            ||
| 521 |     public function listcontent_close() { | 
            ||
| 524 | |||
| 525 | /**  | 
            ||
| 526 | * Output unformatted $text  | 
            ||
| 527 | *  | 
            ||
| 528 | * Defaults to $this->cdata()  | 
            ||
| 529 | *  | 
            ||
| 530 | * @param string $text  | 
            ||
| 531 | */  | 
            ||
| 532 |     public function unformatted($text) { | 
            ||
| 535 | |||
| 536 | /**  | 
            ||
| 537 | * Execute PHP code if allowed  | 
            ||
| 538 | *  | 
            ||
| 539 | * @param string $text PHP code that is either executed or printed  | 
            ||
| 540 | * @param string $wrapper html element to wrap result if $conf['phpok'] is okff  | 
            ||
| 541 | *  | 
            ||
| 542 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 543 | */  | 
            ||
| 544 |     public function php($text, $wrapper = 'code') { | 
            ||
| 556 | |||
| 557 | /**  | 
            ||
| 558 | * Output block level PHP code  | 
            ||
| 559 | *  | 
            ||
| 560 | * If $conf['phpok'] is true this should evaluate the given code and append the result  | 
            ||
| 561 | * to $doc  | 
            ||
| 562 | *  | 
            ||
| 563 | * @param string $text The PHP code  | 
            ||
| 564 | */  | 
            ||
| 565 |     public function phpblock($text) { | 
            ||
| 568 | |||
| 569 | /**  | 
            ||
| 570 | * Insert HTML if allowed  | 
            ||
| 571 | *  | 
            ||
| 572 | * @param string $text html text  | 
            ||
| 573 | * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff  | 
            ||
| 574 | *  | 
            ||
| 575 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 576 | */  | 
            ||
| 577 |     public function html($text, $wrapper = 'code') { | 
            ||
| 586 | |||
| 587 | /**  | 
            ||
| 588 | * Output raw block-level HTML  | 
            ||
| 589 | *  | 
            ||
| 590 | * If $conf['htmlok'] is true this should add the code as is to $doc  | 
            ||
| 591 | *  | 
            ||
| 592 | * @param string $text The HTML  | 
            ||
| 593 | */  | 
            ||
| 594 |     public function htmlblock($text) { | 
            ||
| 597 | |||
| 598 | /**  | 
            ||
| 599 | * Start a block quote  | 
            ||
| 600 | */  | 
            ||
| 601 |     public function quote_open() { | 
            ||
| 604 | |||
| 605 | /**  | 
            ||
| 606 | * Stop a block quote  | 
            ||
| 607 | */  | 
            ||
| 608 |     public function quote_close() { | 
            ||
| 611 | |||
| 612 | /**  | 
            ||
| 613 | * Output preformatted text  | 
            ||
| 614 | *  | 
            ||
| 615 | * @param string $text  | 
            ||
| 616 | */  | 
            ||
| 617 |     public function preformatted($text) { | 
            ||
| 620 | |||
| 621 | /**  | 
            ||
| 622 | * Display text as file content, optionally syntax highlighted  | 
            ||
| 623 | *  | 
            ||
| 624 | * @param string $text text to show  | 
            ||
| 625 | * @param string $language programming language to use for syntax highlighting  | 
            ||
| 626 | * @param string $filename file path label  | 
            ||
| 627 | * @param array $options assoziative array with additional geshi options  | 
            ||
| 628 | */  | 
            ||
| 629 |     public function file($text, $language = null, $filename = null, $options=null) { | 
            ||
| 632 | |||
| 633 | /**  | 
            ||
| 634 | * Display text as code content, optionally syntax highlighted  | 
            ||
| 635 | *  | 
            ||
| 636 | * @param string $text text to show  | 
            ||
| 637 | * @param string $language programming language to use for syntax highlighting  | 
            ||
| 638 | * @param string $filename file path label  | 
            ||
| 639 | * @param array $options assoziative array with additional geshi options  | 
            ||
| 640 | */  | 
            ||
| 641 |     public function code($text, $language = null, $filename = null, $options=null) { | 
            ||
| 644 | |||
| 645 | /**  | 
            ||
| 646 | * Use GeSHi to highlight language syntax in code and file blocks  | 
            ||
| 647 | *  | 
            ||
| 648 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 649 | * @param string $type code|file  | 
            ||
| 650 | * @param string $text text to show  | 
            ||
| 651 | * @param string $language programming language to use for syntax highlighting  | 
            ||
| 652 | * @param string $filename file path label  | 
            ||
| 653 | * @param array $options assoziative array with additional geshi options  | 
            ||
| 654 | */  | 
            ||
| 655 |     public function _highlight($type, $text, $language = null, $filename = null, $options = null) { | 
            ||
| 707 | |||
| 708 | /**  | 
            ||
| 709 | * Format an acronym  | 
            ||
| 710 | *  | 
            ||
| 711 | * Uses $this->acronyms  | 
            ||
| 712 | *  | 
            ||
| 713 | * @param string $acronym  | 
            ||
| 714 | */  | 
            ||
| 715 |     public function acronym($acronym) { | 
            ||
| 728 | |||
| 729 | /**  | 
            ||
| 730 | * Format a smiley  | 
            ||
| 731 | *  | 
            ||
| 732 | * Uses $this->smiley  | 
            ||
| 733 | *  | 
            ||
| 734 | * @param string $smiley  | 
            ||
| 735 | */  | 
            ||
| 736 |     public function smiley($smiley) { | 
            ||
| 745 | |||
| 746 | /**  | 
            ||
| 747 | * Format an entity  | 
            ||
| 748 | *  | 
            ||
| 749 | * Entities are basically small text replacements  | 
            ||
| 750 | *  | 
            ||
| 751 | * Uses $this->entities  | 
            ||
| 752 | *  | 
            ||
| 753 | * @param string $entity  | 
            ||
| 754 | */  | 
            ||
| 755 |     public function entity($entity) { | 
            ||
| 762 | |||
| 763 | /**  | 
            ||
| 764 | * Typographically format a multiply sign  | 
            ||
| 765 | *  | 
            ||
| 766 | * Example: ($x=640, $y=480) should result in "640×480"  | 
            ||
| 767 | *  | 
            ||
| 768 | * @param string|int $x first value  | 
            ||
| 769 | * @param string|int $y second value  | 
            ||
| 770 | */  | 
            ||
| 771 |     public function multiplyentity($x, $y) { | 
            ||
| 774 | |||
| 775 | /**  | 
            ||
| 776 | * Render an opening single quote char (language specific)  | 
            ||
| 777 | */  | 
            ||
| 778 |     public function singlequoteopening() { | 
            ||
| 782 | |||
| 783 | /**  | 
            ||
| 784 | * Render a closing single quote char (language specific)  | 
            ||
| 785 | */  | 
            ||
| 786 |     public function singlequoteclosing() { | 
            ||
| 790 | |||
| 791 | /**  | 
            ||
| 792 | * Render an apostrophe char (language specific)  | 
            ||
| 793 | */  | 
            ||
| 794 |     public function apostrophe() { | 
            ||
| 798 | |||
| 799 | /**  | 
            ||
| 800 | * Render an opening double quote char (language specific)  | 
            ||
| 801 | */  | 
            ||
| 802 |     public function doublequoteopening() { | 
            ||
| 806 | |||
| 807 | /**  | 
            ||
| 808 | * Render an closinging double quote char (language specific)  | 
            ||
| 809 | */  | 
            ||
| 810 |     public function doublequoteclosing() { | 
            ||
| 814 | |||
| 815 | /**  | 
            ||
| 816 | * Render a CamelCase link  | 
            ||
| 817 | *  | 
            ||
| 818 | * @param string $link The link name  | 
            ||
| 819 | * @param bool $returnonly whether to return html or write to doc attribute  | 
            ||
| 820 | * @return void|string writes to doc attribute or returns html depends on $returnonly  | 
            ||
| 821 | *  | 
            ||
| 822 | * @see http://en.wikipedia.org/wiki/CamelCase  | 
            ||
| 823 | */  | 
            ||
| 824 |     public function camelcaselink($link, $returnonly = false) { | 
            ||
| 831 | |||
| 832 | /**  | 
            ||
| 833 | * Render a page local link  | 
            ||
| 834 | *  | 
            ||
| 835 | * @param string $hash hash link identifier  | 
            ||
| 836 | * @param string $name name for the link  | 
            ||
| 837 | * @param bool $returnonly whether to return html or write to doc attribute  | 
            ||
| 838 | * @return void|string writes to doc attribute or returns html depends on $returnonly  | 
            ||
| 839 | */  | 
            ||
| 840 |     public function locallink($hash, $name = null, $returnonly = false) { | 
            ||
| 856 | |||
| 857 | /**  | 
            ||
| 858 | * Render an internal Wiki Link  | 
            ||
| 859 | *  | 
            ||
| 860 | * $search,$returnonly & $linktype are not for the renderer but are used  | 
            ||
| 861 | * elsewhere - no need to implement them in other renderers  | 
            ||
| 862 | *  | 
            ||
| 863 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 864 | * @param string $id pageid  | 
            ||
| 865 | * @param string|null $name link name  | 
            ||
| 866 | * @param string|null $search adds search url param  | 
            ||
| 867 | * @param bool $returnonly whether to return html or write to doc attribute  | 
            ||
| 868 | * @param string $linktype type to set use of headings  | 
            ||
| 869 | * @return void|string writes to doc attribute or returns html depends on $returnonly  | 
            ||
| 870 | */  | 
            ||
| 871 |     public function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { | 
            ||
| 953 | |||
| 954 | /**  | 
            ||
| 955 | * Render an external link  | 
            ||
| 956 | *  | 
            ||
| 957 | * @param string $url full URL with scheme  | 
            ||
| 958 | * @param string|array $name name for the link, array for media file  | 
            ||
| 959 | * @param bool $returnonly whether to return html or write to doc attribute  | 
            ||
| 960 | * @return void|string writes to doc attribute or returns html depends on $returnonly  | 
            ||
| 961 | */  | 
            ||
| 962 |     public function externallink($url, $name = null, $returnonly = false) { | 
            ||
| 1013 | |||
| 1014 | /**  | 
            ||
| 1015 | * Render an interwiki link  | 
            ||
| 1016 | *  | 
            ||
| 1017 | * You may want to use $this->_resolveInterWiki() here  | 
            ||
| 1018 | *  | 
            ||
| 1019 | * @param string $match original link - probably not much use  | 
            ||
| 1020 | * @param string|array $name name for the link, array for media file  | 
            ||
| 1021 | * @param string $wikiName indentifier (shortcut) for the remote wiki  | 
            ||
| 1022 | * @param string $wikiUri the fragment parsed from the original link  | 
            ||
| 1023 | * @param bool $returnonly whether to return html or write to doc attribute  | 
            ||
| 1024 | * @return void|string writes to doc attribute or returns html depends on $returnonly  | 
            ||
| 1025 | */  | 
            ||
| 1026 |     public function interwikilink($match, $name, $wikiName, $wikiUri, $returnonly = false) { | 
            ||
| 1072 | |||
| 1073 | /**  | 
            ||
| 1074 | * Link to windows share  | 
            ||
| 1075 | *  | 
            ||
| 1076 | * @param string $url the link  | 
            ||
| 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 |     public function windowssharelink($url, $name = null, $returnonly = false) { | 
            ||
| 1110 | |||
| 1111 | /**  | 
            ||
| 1112 | * Render a linked E-Mail Address  | 
            ||
| 1113 | *  | 
            ||
| 1114 | * Honors $conf['mailguard'] setting  | 
            ||
| 1115 | *  | 
            ||
| 1116 | * @param string $address Email-Address  | 
            ||
| 1117 | * @param string|array $name name for the link, array for media file  | 
            ||
| 1118 | * @param bool $returnonly whether to return html or write to doc attribute  | 
            ||
| 1119 | * @return void|string writes to doc attribute or returns html depends on $returnonly  | 
            ||
| 1120 | */  | 
            ||
| 1121 |     public function emaillink($address, $name = null, $returnonly = false) { | 
            ||
| 1159 | |||
| 1160 | /**  | 
            ||
| 1161 | * Render an internal media file  | 
            ||
| 1162 | *  | 
            ||
| 1163 | * @param string $src media ID  | 
            ||
| 1164 | * @param string $title descriptive text  | 
            ||
| 1165 | * @param string $align left|center|right  | 
            ||
| 1166 | * @param int $width width of media in pixel  | 
            ||
| 1167 | * @param int $height height of media in pixel  | 
            ||
| 1168 | * @param string $cache cache|recache|nocache  | 
            ||
| 1169 | * @param string $linking linkonly|detail|nolink  | 
            ||
| 1170 | * @param bool $return return HTML instead of adding to $doc  | 
            ||
| 1171 | * @return void|string writes to doc attribute or returns html depends on $return  | 
            ||
| 1172 | */  | 
            ||
| 1173 | public function internalmedia($src, $title = null, $align = null, $width = null,  | 
            ||
| 1231 | |||
| 1232 | /**  | 
            ||
| 1233 | * Render an external media file  | 
            ||
| 1234 | *  | 
            ||
| 1235 | * @param string $src full media URL  | 
            ||
| 1236 | * @param string $title descriptive text  | 
            ||
| 1237 | * @param string $align left|center|right  | 
            ||
| 1238 | * @param int $width width of media in pixel  | 
            ||
| 1239 | * @param int $height height of media in pixel  | 
            ||
| 1240 | * @param string $cache cache|recache|nocache  | 
            ||
| 1241 | * @param string $linking linkonly|detail|nolink  | 
            ||
| 1242 | * @param bool $return return HTML instead of adding to $doc  | 
            ||
| 1243 | * @return void|string writes to doc attribute or returns html depends on $return  | 
            ||
| 1244 | */  | 
            ||
| 1245 | public function externalmedia($src, $title = null, $align = null, $width = null,  | 
            ||
| 1283 | |||
| 1284 | /**  | 
            ||
| 1285 | * Renders an RSS feed  | 
            ||
| 1286 | *  | 
            ||
| 1287 | * @param string $url URL of the feed  | 
            ||
| 1288 | * @param array $params Finetuning of the output  | 
            ||
| 1289 | *  | 
            ||
| 1290 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 1291 | */  | 
            ||
| 1292 |     public function rss($url, $params) { | 
            ||
| 1375 | |||
| 1376 | /**  | 
            ||
| 1377 | * Start a table  | 
            ||
| 1378 | *  | 
            ||
| 1379 | * @param int $maxcols maximum number of columns  | 
            ||
| 1380 | * @param int $numrows NOT IMPLEMENTED  | 
            ||
| 1381 | * @param int $pos byte position in the original source  | 
            ||
| 1382 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input  | 
            ||
| 1383 | */  | 
            ||
| 1384 |     public function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) { | 
            ||
| 1403 | |||
| 1404 | /**  | 
            ||
| 1405 | * Close a table  | 
            ||
| 1406 | *  | 
            ||
| 1407 | * @param int $pos byte position in the original source  | 
            ||
| 1408 | */  | 
            ||
| 1409 |     public function table_close($pos = null) { | 
            ||
| 1415 | |||
| 1416 | /**  | 
            ||
| 1417 | * Open a table header  | 
            ||
| 1418 | */  | 
            ||
| 1419 |     public function tablethead_open() { | 
            ||
| 1422 | |||
| 1423 | /**  | 
            ||
| 1424 | * Close a table header  | 
            ||
| 1425 | */  | 
            ||
| 1426 |     public function tablethead_close() { | 
            ||
| 1429 | |||
| 1430 | /**  | 
            ||
| 1431 | * Open a table body  | 
            ||
| 1432 | */  | 
            ||
| 1433 |     public function tabletbody_open() { | 
            ||
| 1436 | |||
| 1437 | /**  | 
            ||
| 1438 | * Close a table body  | 
            ||
| 1439 | */  | 
            ||
| 1440 |     public function tabletbody_close() { | 
            ||
| 1443 | |||
| 1444 | /**  | 
            ||
| 1445 | * Open a table footer  | 
            ||
| 1446 | */  | 
            ||
| 1447 |     public function tabletfoot_open() { | 
            ||
| 1450 | |||
| 1451 | /**  | 
            ||
| 1452 | * Close a table footer  | 
            ||
| 1453 | */  | 
            ||
| 1454 |     public function tabletfoot_close() { | 
            ||
| 1457 | |||
| 1458 | /**  | 
            ||
| 1459 | * Open a table row  | 
            ||
| 1460 | *  | 
            ||
| 1461 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input  | 
            ||
| 1462 | */  | 
            ||
| 1463 |     public function tablerow_open($classes = null) { | 
            ||
| 1473 | |||
| 1474 | /**  | 
            ||
| 1475 | * Close a table row  | 
            ||
| 1476 | */  | 
            ||
| 1477 |     public function tablerow_close() { | 
            ||
| 1480 | |||
| 1481 | /**  | 
            ||
| 1482 | * Open a table header cell  | 
            ||
| 1483 | *  | 
            ||
| 1484 | * @param int $colspan  | 
            ||
| 1485 | * @param string $align left|center|right  | 
            ||
| 1486 | * @param int $rowspan  | 
            ||
| 1487 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input  | 
            ||
| 1488 | */  | 
            ||
| 1489 |     public function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { | 
            ||
| 1509 | |||
| 1510 | /**  | 
            ||
| 1511 | * Close a table header cell  | 
            ||
| 1512 | */  | 
            ||
| 1513 |     public function tableheader_close() { | 
            ||
| 1516 | |||
| 1517 | /**  | 
            ||
| 1518 | * Open a table cell  | 
            ||
| 1519 | *  | 
            ||
| 1520 | * @param int $colspan  | 
            ||
| 1521 | * @param string $align left|center|right  | 
            ||
| 1522 | * @param int $rowspan  | 
            ||
| 1523 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input  | 
            ||
| 1524 | */  | 
            ||
| 1525 |     public function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { | 
            ||
| 1545 | |||
| 1546 | /**  | 
            ||
| 1547 | * Close a table cell  | 
            ||
| 1548 | */  | 
            ||
| 1549 |     public function tablecell_close() { | 
            ||
| 1552 | |||
| 1553 | /**  | 
            ||
| 1554 | * Returns the current header level.  | 
            ||
| 1555 | * (required e.g. by the filelist plugin)  | 
            ||
| 1556 | *  | 
            ||
| 1557 | * @return int The current header level  | 
            ||
| 1558 | */  | 
            ||
| 1559 |     public function getLastlevel() { | 
            ||
| 1562 | |||
| 1563 | #region Utility functions  | 
            ||
| 1564 | |||
| 1565 | /**  | 
            ||
| 1566 | * Build a link  | 
            ||
| 1567 | *  | 
            ||
| 1568 | * Assembles all parts defined in $link returns HTML for the link  | 
            ||
| 1569 | *  | 
            ||
| 1570 | * @param array $link attributes of a link  | 
            ||
| 1571 | * @return string  | 
            ||
| 1572 | *  | 
            ||
| 1573 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 1574 | */  | 
            ||
| 1575 |     public function _formatLink($link) { | 
            ||
| 1604 | |||
| 1605 | /**  | 
            ||
| 1606 | * Renders internal and external media  | 
            ||
| 1607 | *  | 
            ||
| 1608 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 1609 | * @param string $src media ID  | 
            ||
| 1610 | * @param string $title descriptive text  | 
            ||
| 1611 | * @param string $align left|center|right  | 
            ||
| 1612 | * @param int $width width of media in pixel  | 
            ||
| 1613 | * @param int $height height of media in pixel  | 
            ||
| 1614 | * @param string $cache cache|recache|nocache  | 
            ||
| 1615 | * @param bool $render should the media be embedded inline or just linked  | 
            ||
| 1616 | * @return string  | 
            ||
| 1617 | */  | 
            ||
| 1618 | public function _media($src, $title = null, $align = null, $width = null,  | 
            ||
| 1728 | |||
| 1729 | /**  | 
            ||
| 1730 | * Escape string for output  | 
            ||
| 1731 | *  | 
            ||
| 1732 | * @param $string  | 
            ||
| 1733 | * @return string  | 
            ||
| 1734 | */  | 
            ||
| 1735 |     public function _xmlEntities($string) { | 
            ||
| 1738 | |||
| 1739 | |||
| 1740 | |||
| 1741 | /**  | 
            ||
| 1742 | * Construct a title and handle images in titles  | 
            ||
| 1743 | *  | 
            ||
| 1744 | * @author Harry Fuecks <[email protected]>  | 
            ||
| 1745 | * @param string|array $title either string title or media array  | 
            ||
| 1746 | * @param string $default default title if nothing else is found  | 
            ||
| 1747 | * @param bool $isImage will be set to true if it's a media file  | 
            ||
| 1748 | * @param null|string $id linked page id (used to extract title from first heading)  | 
            ||
| 1749 | * @param string $linktype content|navigation  | 
            ||
| 1750 | * @return string HTML of the title, might be full image tag or just escaped text  | 
            ||
| 1751 | */  | 
            ||
| 1752 |     public function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') { | 
            ||
| 1769 | |||
| 1770 | /**  | 
            ||
| 1771 | * Returns HTML code for images used in link titles  | 
            ||
| 1772 | *  | 
            ||
| 1773 | * @author Andreas Gohr <[email protected]>  | 
            ||
| 1774 | * @param array $img  | 
            ||
| 1775 | * @return string HTML img tag or similar  | 
            ||
| 1776 | */  | 
            ||
| 1777 |     public function _imageTitle($img) { | 
            ||
| 1796 | |||
| 1797 | /**  | 
            ||
| 1798 | * helperfunction to return a basic link to a media  | 
            ||
| 1799 | *  | 
            ||
| 1800 | * used in internalmedia() and externalmedia()  | 
            ||
| 1801 | *  | 
            ||
| 1802 | * @author Pierre Spring <[email protected]>  | 
            ||
| 1803 | * @param string $src media ID  | 
            ||
| 1804 | * @param string $title descriptive text  | 
            ||
| 1805 | * @param string $align left|center|right  | 
            ||
| 1806 | * @param int $width width of media in pixel  | 
            ||
| 1807 | * @param int $height height of media in pixel  | 
            ||
| 1808 | * @param string $cache cache|recache|nocache  | 
            ||
| 1809 | * @param bool $render should the media be embedded inline or just linked  | 
            ||
| 1810 | * @return array associative array with link config  | 
            ||
| 1811 | */  | 
            ||
| 1812 |     public function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) { | 
            ||
| 1828 | |||
| 1829 | /**  | 
            ||
| 1830 | * Embed video(s) in HTML  | 
            ||
| 1831 | *  | 
            ||
| 1832 | * @author Anika Henke <[email protected]>  | 
            ||
| 1833 | * @author Schplurtz le Déboulonné <[email protected]>  | 
            ||
| 1834 | *  | 
            ||
| 1835 | * @param string $src - ID of video to embed  | 
            ||
| 1836 | * @param int $width - width of the video in pixels  | 
            ||
| 1837 | * @param int $height - height of the video in pixels  | 
            ||
| 1838 | * @param array $atts - additional attributes for the <video> tag  | 
            ||
| 1839 | * @return string  | 
            ||
| 1840 | */  | 
            ||
| 1841 |     public function _video($src, $width, $height, $atts = null) { | 
            ||
| 1914 | |||
| 1915 | /**  | 
            ||
| 1916 | * Embed audio in HTML  | 
            ||
| 1917 | *  | 
            ||
| 1918 | * @author Anika Henke <[email protected]>  | 
            ||
| 1919 | *  | 
            ||
| 1920 | * @param string $src - ID of audio to embed  | 
            ||
| 1921 | * @param array $atts - additional attributes for the <audio> tag  | 
            ||
| 1922 | * @return string  | 
            ||
| 1923 | */  | 
            ||
| 1924 |     public function _audio($src, $atts = array()) { | 
            ||
| 1973 | |||
| 1974 | /**  | 
            ||
| 1975 | * _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media()  | 
            ||
| 1976 | * which returns an existing media revision less or equal to rev or date_at  | 
            ||
| 1977 | *  | 
            ||
| 1978 | * @author lisps  | 
            ||
| 1979 | * @param string $media_id  | 
            ||
| 1980 | * @access protected  | 
            ||
| 1981 |      * @return string revision ('' for current) | 
            ||
| 1982 | */  | 
            ||
| 1983 |     protected function _getLastMediaRevisionAt($media_id){ | 
            ||
| 1988 | |||
| 1989 | #endregion  | 
            ||
| 1990 | }  | 
            ||
| 1991 | |||
| 1993 | 
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: