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 |
||
11 | class Doku_Renderer_xhtml extends Doku_Renderer { |
||
12 | /** @var array store the table of contents */ |
||
13 | public $toc = array(); |
||
14 | |||
15 | /** @var array A stack of section edit data */ |
||
16 | protected $sectionedits = array(); |
||
17 | |||
18 | /** @var string|int link pages and media against this revision */ |
||
19 | public $date_at = ''; |
||
20 | |||
21 | /** @var int last section edit id, used by startSectionEdit */ |
||
22 | protected $lastsecid = 0; |
||
23 | |||
24 | /** @var array a list of footnotes, list starts at 1! */ |
||
25 | protected $footnotes = array(); |
||
26 | |||
27 | /** @var int current section level */ |
||
28 | protected $lastlevel = 0; |
||
29 | /** @var array section node tracker */ |
||
30 | protected $node = array(0, 0, 0, 0, 0); |
||
31 | |||
32 | /** @var string temporary $doc store */ |
||
33 | protected $store = ''; |
||
34 | |||
35 | /** @var array global counter, for table classes etc. */ |
||
36 | protected $_counter = array(); // |
||
37 | |||
38 | /** @var int counts the code and file blocks, used to provide download links */ |
||
39 | protected $_codeblock = 0; |
||
40 | |||
41 | /** @var array list of allowed URL schemes */ |
||
42 | protected $schemes = null; |
||
43 | |||
44 | /** |
||
45 | * Register a new edit section range |
||
46 | * |
||
47 | * @param int $start The byte position for the edit start |
||
48 | * @param array $data Associative array with section data: |
||
49 | * Key 'name': the section name/title |
||
50 | * Key 'target': the target for the section edit, |
||
51 | * e.g. 'section' or 'table' |
||
52 | * Key 'hid': header id |
||
53 | * Key 'codeblockOffset': actual code block index |
||
54 | * Key 'start': set in startSectionEdit(), |
||
55 | * do not set yourself |
||
56 | * Key 'range': calculated from 'start' and |
||
57 | * $key in finishSectionEdit(), |
||
58 | * do not set yourself |
||
59 | * @return string A marker class for the starting HTML element |
||
60 | * |
||
61 | * @author Adrian Lang <[email protected]> |
||
62 | */ |
||
63 | public function startSectionEdit($start, $data) { |
||
84 | |||
85 | /** |
||
86 | * Finish an edit section range |
||
87 | * |
||
88 | * @param int $end The byte position for the edit end; null for the rest of the page |
||
89 | * |
||
90 | * @author Adrian Lang <[email protected]> |
||
91 | */ |
||
92 | public function finishSectionEdit($end = null, $hid = null) { |
||
104 | |||
105 | /** |
||
106 | * Returns the format produced by this renderer. |
||
107 | * |
||
108 | * @return string always 'xhtml' |
||
109 | */ |
||
110 | public function getFormat() { |
||
113 | |||
114 | /** |
||
115 | * Initialize the document |
||
116 | */ |
||
117 | public function document_start() { |
||
121 | |||
122 | /** |
||
123 | * Finalize the document |
||
124 | */ |
||
125 | public function document_end() { |
||
182 | |||
183 | /** |
||
184 | * Add an item to the TOC |
||
185 | * |
||
186 | * @param string $id the hash link |
||
187 | * @param string $text the text to display |
||
188 | * @param int $level the nesting level |
||
189 | */ |
||
190 | public function toc_additem($id, $text, $level) { |
||
198 | |||
199 | /** |
||
200 | * Render a heading |
||
201 | * |
||
202 | * @param string $text the text to display |
||
203 | * @param int $level header level |
||
204 | * @param int $pos byte position in the original source |
||
205 | */ |
||
206 | public function header($text, $level, $pos) { |
||
246 | |||
247 | /** |
||
248 | * Open a new section |
||
249 | * |
||
250 | * @param int $level section level (as determined by the previous header) |
||
251 | */ |
||
252 | public function section_open($level) { |
||
255 | |||
256 | /** |
||
257 | * Close the current section |
||
258 | */ |
||
259 | public function section_close() { |
||
262 | |||
263 | /** |
||
264 | * Render plain text data |
||
265 | * |
||
266 | * @param $text |
||
267 | */ |
||
268 | public function cdata($text) { |
||
271 | |||
272 | /** |
||
273 | * Open a paragraph |
||
274 | */ |
||
275 | public function p_open() { |
||
278 | |||
279 | /** |
||
280 | * Close a paragraph |
||
281 | */ |
||
282 | public function p_close() { |
||
285 | |||
286 | /** |
||
287 | * Create a line break |
||
288 | */ |
||
289 | public function linebreak() { |
||
292 | |||
293 | /** |
||
294 | * Create a horizontal line |
||
295 | */ |
||
296 | public function hr() { |
||
299 | |||
300 | /** |
||
301 | * Start strong (bold) formatting |
||
302 | */ |
||
303 | public function strong_open() { |
||
306 | |||
307 | /** |
||
308 | * Stop strong (bold) formatting |
||
309 | */ |
||
310 | public function strong_close() { |
||
313 | |||
314 | /** |
||
315 | * Start emphasis (italics) formatting |
||
316 | */ |
||
317 | public function emphasis_open() { |
||
320 | |||
321 | /** |
||
322 | * Stop emphasis (italics) formatting |
||
323 | */ |
||
324 | public function emphasis_close() { |
||
327 | |||
328 | /** |
||
329 | * Start underline formatting |
||
330 | */ |
||
331 | public function underline_open() { |
||
334 | |||
335 | /** |
||
336 | * Stop underline formatting |
||
337 | */ |
||
338 | public function underline_close() { |
||
341 | |||
342 | /** |
||
343 | * Start monospace formatting |
||
344 | */ |
||
345 | public function monospace_open() { |
||
348 | |||
349 | /** |
||
350 | * Stop monospace formatting |
||
351 | */ |
||
352 | public function monospace_close() { |
||
355 | |||
356 | /** |
||
357 | * Start a subscript |
||
358 | */ |
||
359 | public function subscript_open() { |
||
362 | |||
363 | /** |
||
364 | * Stop a subscript |
||
365 | */ |
||
366 | public function subscript_close() { |
||
369 | |||
370 | /** |
||
371 | * Start a superscript |
||
372 | */ |
||
373 | public function superscript_open() { |
||
376 | |||
377 | /** |
||
378 | * Stop a superscript |
||
379 | */ |
||
380 | public function superscript_close() { |
||
383 | |||
384 | /** |
||
385 | * Start deleted (strike-through) formatting |
||
386 | */ |
||
387 | public function deleted_open() { |
||
390 | |||
391 | /** |
||
392 | * Stop deleted (strike-through) formatting |
||
393 | */ |
||
394 | public function deleted_close() { |
||
397 | |||
398 | /** |
||
399 | * Callback for footnote start syntax |
||
400 | * |
||
401 | * All following content will go to the footnote instead of |
||
402 | * the document. To achieve this the previous rendered content |
||
403 | * is moved to $store and $doc is cleared |
||
404 | * |
||
405 | * @author Andreas Gohr <[email protected]> |
||
406 | */ |
||
407 | public function footnote_open() { |
||
413 | |||
414 | /** |
||
415 | * Callback for footnote end syntax |
||
416 | * |
||
417 | * All rendered content is moved to the $footnotes array and the old |
||
418 | * content is restored from $store again |
||
419 | * |
||
420 | * @author Andreas Gohr |
||
421 | */ |
||
422 | public function footnote_close() { |
||
447 | |||
448 | /** |
||
449 | * Open an unordered list |
||
450 | * |
||
451 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
452 | */ |
||
453 | public function listu_open($classes = null) { |
||
461 | |||
462 | /** |
||
463 | * Close an unordered list |
||
464 | */ |
||
465 | public function listu_close() { |
||
468 | |||
469 | /** |
||
470 | * Open an ordered list |
||
471 | * |
||
472 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
473 | */ |
||
474 | public function listo_open($classes = null) { |
||
482 | |||
483 | /** |
||
484 | * Close an ordered list |
||
485 | */ |
||
486 | public function listo_close() { |
||
489 | |||
490 | /** |
||
491 | * Open a list item |
||
492 | * |
||
493 | * @param int $level the nesting level |
||
494 | * @param bool $node true when a node; false when a leaf |
||
495 | */ |
||
496 | public function listitem_open($level, $node=false) { |
||
500 | |||
501 | /** |
||
502 | * Close a list item |
||
503 | */ |
||
504 | public function listitem_close() { |
||
507 | |||
508 | /** |
||
509 | * Start the content of a list item |
||
510 | */ |
||
511 | public function listcontent_open() { |
||
514 | |||
515 | /** |
||
516 | * Stop the content of a list item |
||
517 | */ |
||
518 | public function listcontent_close() { |
||
521 | |||
522 | /** |
||
523 | * Output unformatted $text |
||
524 | * |
||
525 | * Defaults to $this->cdata() |
||
526 | * |
||
527 | * @param string $text |
||
528 | */ |
||
529 | public function unformatted($text) { |
||
532 | |||
533 | /** |
||
534 | * Execute PHP code if allowed |
||
535 | * |
||
536 | * @param string $text PHP code that is either executed or printed |
||
537 | * @param string $wrapper html element to wrap result if $conf['phpok'] is okff |
||
538 | * |
||
539 | * @author Andreas Gohr <[email protected]> |
||
540 | */ |
||
541 | public function php($text, $wrapper = 'code') { |
||
553 | |||
554 | /** |
||
555 | * Output block level PHP code |
||
556 | * |
||
557 | * If $conf['phpok'] is true this should evaluate the given code and append the result |
||
558 | * to $doc |
||
559 | * |
||
560 | * @param string $text The PHP code |
||
561 | */ |
||
562 | public function phpblock($text) { |
||
565 | |||
566 | /** |
||
567 | * Insert HTML if allowed |
||
568 | * |
||
569 | * @param string $text html text |
||
570 | * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff |
||
571 | * |
||
572 | * @author Andreas Gohr <[email protected]> |
||
573 | */ |
||
574 | public function html($text, $wrapper = 'code') { |
||
583 | |||
584 | /** |
||
585 | * Output raw block-level HTML |
||
586 | * |
||
587 | * If $conf['htmlok'] is true this should add the code as is to $doc |
||
588 | * |
||
589 | * @param string $text The HTML |
||
590 | */ |
||
591 | public function htmlblock($text) { |
||
594 | |||
595 | /** |
||
596 | * Start a block quote |
||
597 | */ |
||
598 | public function quote_open() { |
||
601 | |||
602 | /** |
||
603 | * Stop a block quote |
||
604 | */ |
||
605 | public function quote_close() { |
||
608 | |||
609 | /** |
||
610 | * Output preformatted text |
||
611 | * |
||
612 | * @param string $text |
||
613 | */ |
||
614 | public function preformatted($text) { |
||
617 | |||
618 | /** |
||
619 | * Display text as file content, optionally syntax highlighted |
||
620 | * |
||
621 | * @param string $text text to show |
||
622 | * @param string $language programming language to use for syntax highlighting |
||
623 | * @param string $filename file path label |
||
624 | * @param array $options assoziative array with additional geshi options |
||
625 | */ |
||
626 | public function file($text, $language = null, $filename = null, $options=null) { |
||
629 | |||
630 | /** |
||
631 | * Display text as code 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 | * @param array $options assoziative array with additional geshi options |
||
637 | */ |
||
638 | public function code($text, $language = null, $filename = null, $options=null) { |
||
641 | |||
642 | /** |
||
643 | * Use GeSHi to highlight language syntax in code and file blocks |
||
644 | * |
||
645 | * @author Andreas Gohr <[email protected]> |
||
646 | * @param string $type code|file |
||
647 | * @param string $text text to show |
||
648 | * @param string $language programming language to use for syntax highlighting |
||
649 | * @param string $filename file path label |
||
650 | * @param array $options assoziative array with additional geshi options |
||
651 | */ |
||
652 | public function _highlight($type, $text, $language = null, $filename = null, $options = null) { |
||
704 | |||
705 | /** |
||
706 | * Format an acronym |
||
707 | * |
||
708 | * Uses $this->acronyms |
||
709 | * |
||
710 | * @param string $acronym |
||
711 | */ |
||
712 | public function acronym($acronym) { |
||
725 | |||
726 | /** |
||
727 | * Format a smiley |
||
728 | * |
||
729 | * Uses $this->smiley |
||
730 | * |
||
731 | * @param string $smiley |
||
732 | */ |
||
733 | public function smiley($smiley) { |
||
742 | |||
743 | /** |
||
744 | * Format an entity |
||
745 | * |
||
746 | * Entities are basically small text replacements |
||
747 | * |
||
748 | * Uses $this->entities |
||
749 | * |
||
750 | * @param string $entity |
||
751 | */ |
||
752 | public function entity($entity) { |
||
759 | |||
760 | /** |
||
761 | * Typographically format a multiply sign |
||
762 | * |
||
763 | * Example: ($x=640, $y=480) should result in "640×480" |
||
764 | * |
||
765 | * @param string|int $x first value |
||
766 | * @param string|int $y second value |
||
767 | */ |
||
768 | public function multiplyentity($x, $y) { |
||
771 | |||
772 | /** |
||
773 | * Render an opening single quote char (language specific) |
||
774 | */ |
||
775 | public function singlequoteopening() { |
||
779 | |||
780 | /** |
||
781 | * Render a closing single quote char (language specific) |
||
782 | */ |
||
783 | public function singlequoteclosing() { |
||
787 | |||
788 | /** |
||
789 | * Render an apostrophe char (language specific) |
||
790 | */ |
||
791 | public function apostrophe() { |
||
795 | |||
796 | /** |
||
797 | * Render an opening double quote char (language specific) |
||
798 | */ |
||
799 | public function doublequoteopening() { |
||
803 | |||
804 | /** |
||
805 | * Render an closinging double quote char (language specific) |
||
806 | */ |
||
807 | public function doublequoteclosing() { |
||
811 | |||
812 | /** |
||
813 | * Render a CamelCase link |
||
814 | * |
||
815 | * @param string $link The link name |
||
816 | * @param bool $returnonly whether to return html or write to doc attribute |
||
817 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
818 | * |
||
819 | * @see http://en.wikipedia.org/wiki/CamelCase |
||
820 | */ |
||
821 | public function camelcaselink($link, $returnonly = false) { |
||
828 | |||
829 | /** |
||
830 | * Render a page local link |
||
831 | * |
||
832 | * @param string $hash hash link identifier |
||
833 | * @param string $name name for the link |
||
834 | * @param bool $returnonly whether to return html or write to doc attribute |
||
835 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
836 | */ |
||
837 | public function locallink($hash, $name = null, $returnonly = false) { |
||
853 | |||
854 | /** |
||
855 | * Render an internal Wiki Link |
||
856 | * |
||
857 | * $search,$returnonly & $linktype are not for the renderer but are used |
||
858 | * elsewhere - no need to implement them in other renderers |
||
859 | * |
||
860 | * @author Andreas Gohr <[email protected]> |
||
861 | * @param string $id pageid |
||
862 | * @param string|null $name link name |
||
863 | * @param string|null $search adds search url param |
||
864 | * @param bool $returnonly whether to return html or write to doc attribute |
||
865 | * @param string $linktype type to set use of headings |
||
866 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
867 | */ |
||
868 | public function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { |
||
950 | |||
951 | /** |
||
952 | * Render an external link |
||
953 | * |
||
954 | * @param string $url full URL with scheme |
||
955 | * @param string|array $name name for the link, array for media file |
||
956 | * @param bool $returnonly whether to return html or write to doc attribute |
||
957 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
958 | */ |
||
959 | public function externallink($url, $name = null, $returnonly = false) { |
||
1010 | |||
1011 | /** |
||
1012 | * Render an interwiki link |
||
1013 | * |
||
1014 | * You may want to use $this->_resolveInterWiki() here |
||
1015 | * |
||
1016 | * @param string $match original link - probably not much use |
||
1017 | * @param string|array $name name for the link, array for media file |
||
1018 | * @param string $wikiName indentifier (shortcut) for the remote wiki |
||
1019 | * @param string $wikiUri the fragment parsed from the original link |
||
1020 | * @param bool $returnonly whether to return html or write to doc attribute |
||
1021 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
1022 | */ |
||
1023 | public function interwikilink($match, $name, $wikiName, $wikiUri, $returnonly = false) { |
||
1069 | |||
1070 | /** |
||
1071 | * Link to windows share |
||
1072 | * |
||
1073 | * @param string $url the link |
||
1074 | * @param string|array $name name for the link, array for media file |
||
1075 | * @param bool $returnonly whether to return html or write to doc attribute |
||
1076 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
1077 | */ |
||
1078 | public function windowssharelink($url, $name = null, $returnonly = false) { |
||
1107 | |||
1108 | /** |
||
1109 | * Render a linked E-Mail Address |
||
1110 | * |
||
1111 | * Honors $conf['mailguard'] setting |
||
1112 | * |
||
1113 | * @param string $address Email-Address |
||
1114 | * @param string|array $name name for the link, array for media file |
||
1115 | * @param bool $returnonly whether to return html or write to doc attribute |
||
1116 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
1117 | */ |
||
1118 | public function emaillink($address, $name = null, $returnonly = false) { |
||
1156 | |||
1157 | /** |
||
1158 | * Render an internal media file |
||
1159 | * |
||
1160 | * @param string $src media ID |
||
1161 | * @param string $title descriptive text |
||
1162 | * @param string $align left|center|right |
||
1163 | * @param int $width width of media in pixel |
||
1164 | * @param int $height height of media in pixel |
||
1165 | * @param string $cache cache|recache|nocache |
||
1166 | * @param string $linking linkonly|detail|nolink |
||
1167 | * @param bool $return return HTML instead of adding to $doc |
||
1168 | * @return void|string writes to doc attribute or returns html depends on $return |
||
1169 | */ |
||
1170 | public function internalmedia($src, $title = null, $align = null, $width = null, |
||
1228 | |||
1229 | /** |
||
1230 | * Render an external media file |
||
1231 | * |
||
1232 | * @param string $src full media URL |
||
1233 | * @param string $title descriptive text |
||
1234 | * @param string $align left|center|right |
||
1235 | * @param int $width width of media in pixel |
||
1236 | * @param int $height height of media in pixel |
||
1237 | * @param string $cache cache|recache|nocache |
||
1238 | * @param string $linking linkonly|detail|nolink |
||
1239 | * @param bool $return return HTML instead of adding to $doc |
||
1240 | * @return void|string writes to doc attribute or returns html depends on $return |
||
1241 | */ |
||
1242 | public function externalmedia($src, $title = null, $align = null, $width = null, |
||
1280 | |||
1281 | /** |
||
1282 | * Renders an RSS feed |
||
1283 | * |
||
1284 | * @param string $url URL of the feed |
||
1285 | * @param array $params Finetuning of the output |
||
1286 | * |
||
1287 | * @author Andreas Gohr <[email protected]> |
||
1288 | */ |
||
1289 | public function rss($url, $params) { |
||
1372 | |||
1373 | /** |
||
1374 | * Start a table |
||
1375 | * |
||
1376 | * @param int $maxcols maximum number of columns |
||
1377 | * @param int $numrows NOT IMPLEMENTED |
||
1378 | * @param int $pos byte position in the original source |
||
1379 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
1380 | */ |
||
1381 | public function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) { |
||
1400 | |||
1401 | /** |
||
1402 | * Close a table |
||
1403 | * |
||
1404 | * @param int $pos byte position in the original source |
||
1405 | */ |
||
1406 | public function table_close($pos = null) { |
||
1412 | |||
1413 | /** |
||
1414 | * Open a table header |
||
1415 | */ |
||
1416 | public function tablethead_open() { |
||
1419 | |||
1420 | /** |
||
1421 | * Close a table header |
||
1422 | */ |
||
1423 | public function tablethead_close() { |
||
1426 | |||
1427 | /** |
||
1428 | * Open a table body |
||
1429 | */ |
||
1430 | public function tabletbody_open() { |
||
1433 | |||
1434 | /** |
||
1435 | * Close a table body |
||
1436 | */ |
||
1437 | public function tabletbody_close() { |
||
1440 | |||
1441 | /** |
||
1442 | * Open a table footer |
||
1443 | */ |
||
1444 | public function tabletfoot_open() { |
||
1447 | |||
1448 | /** |
||
1449 | * Close a table footer |
||
1450 | */ |
||
1451 | public function tabletfoot_close() { |
||
1454 | |||
1455 | /** |
||
1456 | * Open a table row |
||
1457 | * |
||
1458 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
1459 | */ |
||
1460 | public function tablerow_open($classes = null) { |
||
1470 | |||
1471 | /** |
||
1472 | * Close a table row |
||
1473 | */ |
||
1474 | public function tablerow_close() { |
||
1477 | |||
1478 | /** |
||
1479 | * Open a table header cell |
||
1480 | * |
||
1481 | * @param int $colspan |
||
1482 | * @param string $align left|center|right |
||
1483 | * @param int $rowspan |
||
1484 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
1485 | */ |
||
1486 | public function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
1506 | |||
1507 | /** |
||
1508 | * Close a table header cell |
||
1509 | */ |
||
1510 | public function tableheader_close() { |
||
1513 | |||
1514 | /** |
||
1515 | * Open a table cell |
||
1516 | * |
||
1517 | * @param int $colspan |
||
1518 | * @param string $align left|center|right |
||
1519 | * @param int $rowspan |
||
1520 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
1521 | */ |
||
1522 | public function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
1542 | |||
1543 | /** |
||
1544 | * Close a table cell |
||
1545 | */ |
||
1546 | public function tablecell_close() { |
||
1549 | |||
1550 | /** |
||
1551 | * Returns the current header level. |
||
1552 | * (required e.g. by the filelist plugin) |
||
1553 | * |
||
1554 | * @return int The current header level |
||
1555 | */ |
||
1556 | public function getLastlevel() { |
||
1559 | |||
1560 | #region Utility functions |
||
1561 | |||
1562 | /** |
||
1563 | * Build a link |
||
1564 | * |
||
1565 | * Assembles all parts defined in $link returns HTML for the link |
||
1566 | * |
||
1567 | * @param array $link attributes of a link |
||
1568 | * @return string |
||
1569 | * |
||
1570 | * @author Andreas Gohr <[email protected]> |
||
1571 | */ |
||
1572 | public function _formatLink($link) { |
||
1601 | |||
1602 | /** |
||
1603 | * Renders internal and external media |
||
1604 | * |
||
1605 | * @author Andreas Gohr <[email protected]> |
||
1606 | * @param string $src media ID |
||
1607 | * @param string $title descriptive text |
||
1608 | * @param string $align left|center|right |
||
1609 | * @param int $width width of media in pixel |
||
1610 | * @param int $height height of media in pixel |
||
1611 | * @param string $cache cache|recache|nocache |
||
1612 | * @param bool $render should the media be embedded inline or just linked |
||
1613 | * @return string |
||
1614 | */ |
||
1615 | public function _media($src, $title = null, $align = null, $width = null, |
||
1725 | |||
1726 | /** |
||
1727 | * Escape string for output |
||
1728 | * |
||
1729 | * @param $string |
||
1730 | * @return string |
||
1731 | */ |
||
1732 | public function _xmlEntities($string) { |
||
1735 | |||
1736 | |||
1737 | |||
1738 | /** |
||
1739 | * Construct a title and handle images in titles |
||
1740 | * |
||
1741 | * @author Harry Fuecks <[email protected]> |
||
1742 | * @param string|array $title either string title or media array |
||
1743 | * @param string $default default title if nothing else is found |
||
1744 | * @param bool $isImage will be set to true if it's a media file |
||
1745 | * @param null|string $id linked page id (used to extract title from first heading) |
||
1746 | * @param string $linktype content|navigation |
||
1747 | * @return string HTML of the title, might be full image tag or just escaped text |
||
1748 | */ |
||
1749 | public function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') { |
||
1766 | |||
1767 | /** |
||
1768 | * Returns HTML code for images used in link titles |
||
1769 | * |
||
1770 | * @author Andreas Gohr <[email protected]> |
||
1771 | * @param array $img |
||
1772 | * @return string HTML img tag or similar |
||
1773 | */ |
||
1774 | public function _imageTitle($img) { |
||
1793 | |||
1794 | /** |
||
1795 | * helperfunction to return a basic link to a media |
||
1796 | * |
||
1797 | * used in internalmedia() and externalmedia() |
||
1798 | * |
||
1799 | * @author Pierre Spring <[email protected]> |
||
1800 | * @param string $src media ID |
||
1801 | * @param string $title descriptive text |
||
1802 | * @param string $align left|center|right |
||
1803 | * @param int $width width of media in pixel |
||
1804 | * @param int $height height of media in pixel |
||
1805 | * @param string $cache cache|recache|nocache |
||
1806 | * @param bool $render should the media be embedded inline or just linked |
||
1807 | * @return array associative array with link config |
||
1808 | */ |
||
1809 | public function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) { |
||
1825 | |||
1826 | /** |
||
1827 | * Embed video(s) in HTML |
||
1828 | * |
||
1829 | * @author Anika Henke <[email protected]> |
||
1830 | * @author Schplurtz le Déboulonné <[email protected]> |
||
1831 | * |
||
1832 | * @param string $src - ID of video to embed |
||
1833 | * @param int $width - width of the video in pixels |
||
1834 | * @param int $height - height of the video in pixels |
||
1835 | * @param array $atts - additional attributes for the <video> tag |
||
1836 | * @return string |
||
1837 | */ |
||
1838 | public function _video($src, $width, $height, $atts = null) { |
||
1911 | |||
1912 | /** |
||
1913 | * Embed audio in HTML |
||
1914 | * |
||
1915 | * @author Anika Henke <[email protected]> |
||
1916 | * |
||
1917 | * @param string $src - ID of audio to embed |
||
1918 | * @param array $atts - additional attributes for the <audio> tag |
||
1919 | * @return string |
||
1920 | */ |
||
1921 | public function _audio($src, $atts = array()) { |
||
1970 | |||
1971 | /** |
||
1972 | * _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media() |
||
1973 | * which returns an existing media revision less or equal to rev or date_at |
||
1974 | * |
||
1975 | * @author lisps |
||
1976 | * @param string $media_id |
||
1977 | * @access protected |
||
1978 | * @return string revision ('' for current) |
||
1979 | */ |
||
1980 | protected function _getLastMediaRevisionAt($media_id){ |
||
1985 | |||
1986 | #endregion |
||
1987 | } |
||
1988 | |||
1990 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: