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) { |
||
82 | list($id, $start, $type, $title) = array_pop($this->sectionedits); |
||
83 | if(!is_null($end) && $end <= $start) { |
||
84 | return; |
||
85 | } |
||
86 | $this->doc .= "<!-- EDIT$id ".strtoupper($type).' '; |
||
87 | if(!is_null($title)) { |
||
88 | $this->doc .= '"'.str_replace('"', '', $title).'" '; |
||
89 | } |
||
90 | $this->doc .= "[$start-".(is_null($end) ? '' : $end).'] -->'; |
||
91 | } |
||
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() { |
||
106 | //reset some internals |
||
107 | $this->toc = array(); |
||
108 | $this->headers = array(); |
||
109 | } |
||
110 | |||
111 | /** |
||
112 | * Finalize the document |
||
113 | */ |
||
114 | function document_end() { |
||
115 | // Finish open section edits. |
||
116 | while(count($this->sectionedits) > 0) { |
||
117 | if($this->sectionedits[count($this->sectionedits) - 1][1] <= 1) { |
||
118 | // If there is only one section, do not write a section edit |
||
119 | // marker. |
||
120 | array_pop($this->sectionedits); |
||
121 | } else { |
||
122 | $this->finishSectionEdit(); |
||
123 | } |
||
124 | } |
||
125 | |||
126 | if(count($this->footnotes) > 0) { |
||
127 | $this->doc .= '<div class="footnotes">'.DOKU_LF; |
||
128 | |||
129 | foreach($this->footnotes as $id => $footnote) { |
||
130 | // check its not a placeholder that indicates actual footnote text is elsewhere |
||
131 | if(substr($footnote, 0, 5) != "@@FNT") { |
||
132 | |||
133 | // open the footnote and set the anchor and backlink |
||
134 | $this->doc .= '<div class="fn">'; |
||
135 | $this->doc .= '<sup><a href="#fnt__'.$id.'" id="fn__'.$id.'" class="fn_bot">'; |
||
136 | $this->doc .= $id.')</a></sup> '.DOKU_LF; |
||
137 | |||
138 | // get any other footnotes that use the same markup |
||
139 | $alt = array_keys($this->footnotes, "@@FNT$id"); |
||
140 | |||
141 | if(count($alt)) { |
||
142 | foreach($alt as $ref) { |
||
143 | // set anchor and backlink for the other footnotes |
||
144 | $this->doc .= ', <sup><a href="#fnt__'.($ref).'" id="fn__'.($ref).'" class="fn_bot">'; |
||
145 | $this->doc .= ($ref).')</a></sup> '.DOKU_LF; |
||
146 | } |
||
147 | } |
||
148 | |||
149 | // add footnote markup and close this footnote |
||
150 | $this->doc .= $footnote; |
||
151 | $this->doc .= '</div>'.DOKU_LF; |
||
152 | } |
||
153 | } |
||
154 | $this->doc .= '</div>'.DOKU_LF; |
||
155 | } |
||
156 | |||
157 | // Prepare the TOC |
||
158 | global $conf; |
||
159 | if($this->info['toc'] && is_array($this->toc) && $conf['tocminheads'] && count($this->toc) >= $conf['tocminheads']) { |
||
160 | global $TOC; |
||
161 | $TOC = $this->toc; |
||
162 | } |
||
163 | |||
164 | // make sure there are no empty paragraphs |
||
165 | $this->doc = preg_replace('#<p>\s*</p>#', '', $this->doc); |
||
166 | } |
||
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) { |
||
176 | global $conf; |
||
177 | |||
178 | //handle TOC |
||
179 | if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) { |
||
180 | $this->toc[] = html_mktocitem($id, $text, $level - $conf['toptoclevel'] + 1); |
||
181 | } |
||
182 | } |
||
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) { |
||
192 | global $conf; |
||
193 | |||
194 | if(!$text) return; //skip empty headlines |
||
195 | |||
196 | $hid = $this->_headerToLink($text, true); |
||
197 | |||
198 | //only add items within configured levels |
||
199 | $this->toc_additem($hid, $text, $level); |
||
200 | |||
201 | // adjust $node to reflect hierarchy of levels |
||
202 | $this->node[$level - 1]++; |
||
203 | if($level < $this->lastlevel) { |
||
204 | for($i = 0; $i < $this->lastlevel - $level; $i++) { |
||
205 | $this->node[$this->lastlevel - $i - 1] = 0; |
||
206 | } |
||
207 | } |
||
208 | $this->lastlevel = $level; |
||
209 | |||
210 | if($level <= $conf['maxseclevel'] && |
||
211 | count($this->sectionedits) > 0 && |
||
212 | $this->sectionedits[count($this->sectionedits) - 1][2] === 'section' |
||
213 | ) { |
||
214 | $this->finishSectionEdit($pos - 1); |
||
215 | } |
||
216 | |||
217 | // write the header |
||
218 | $this->doc .= DOKU_LF.'<h'.$level; |
||
219 | if($level <= $conf['maxseclevel']) { |
||
220 | $this->doc .= ' class="'.$this->startSectionEdit($pos, 'section', $text).'"'; |
||
221 | } |
||
222 | $this->doc .= ' id="'.$hid.'">'; |
||
223 | $this->doc .= $this->_xmlEntities($text); |
||
224 | $this->doc .= "</h$level>".DOKU_LF; |
||
225 | } |
||
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 $classes css class |
||
432 | */ |
||
433 | function listu_open($classes = null) { |
||
440 | |||
441 | /** |
||
442 | * Close an unordered list |
||
443 | */ |
||
444 | function listu_close() { |
||
447 | |||
448 | /** |
||
449 | * Open an ordered list |
||
450 | * |
||
451 | * @param string $classes css class |
||
452 | */ |
||
453 | function listo_open($classes = null) { |
||
460 | |||
461 | /** |
||
462 | * Close an ordered list |
||
463 | */ |
||
464 | function listo_close() { |
||
467 | |||
468 | /** |
||
469 | * Open a list item |
||
470 | * |
||
471 | * @param int $level the nesting level |
||
472 | * @param bool $node true when a node; false when a leaf |
||
473 | */ |
||
474 | function listitem_open($level, $node=false) { |
||
478 | |||
479 | /** |
||
480 | * Close a list item |
||
481 | */ |
||
482 | function listitem_close() { |
||
485 | |||
486 | /** |
||
487 | * Start the content of a list item |
||
488 | */ |
||
489 | function listcontent_open() { |
||
492 | |||
493 | /** |
||
494 | * Stop the content of a list item |
||
495 | */ |
||
496 | function listcontent_close() { |
||
499 | |||
500 | /** |
||
501 | * Output unformatted $text |
||
502 | * |
||
503 | * Defaults to $this->cdata() |
||
504 | * |
||
505 | * @param string $text |
||
506 | */ |
||
507 | function unformatted($text) { |
||
510 | |||
511 | /** |
||
512 | * Execute PHP code if allowed |
||
513 | * |
||
514 | * @param string $text PHP code that is either executed or printed |
||
515 | * @param string $wrapper html element to wrap result if $conf['phpok'] is okff |
||
516 | * |
||
517 | * @author Andreas Gohr <[email protected]> |
||
518 | */ |
||
519 | function php($text, $wrapper = 'code') { |
||
531 | |||
532 | /** |
||
533 | * Output block level PHP code |
||
534 | * |
||
535 | * If $conf['phpok'] is true this should evaluate the given code and append the result |
||
536 | * to $doc |
||
537 | * |
||
538 | * @param string $text The PHP code |
||
539 | */ |
||
540 | function phpblock($text) { |
||
543 | |||
544 | /** |
||
545 | * Insert HTML if allowed |
||
546 | * |
||
547 | * @param string $text html text |
||
548 | * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff |
||
549 | * |
||
550 | * @author Andreas Gohr <[email protected]> |
||
551 | */ |
||
552 | function html($text, $wrapper = 'code') { |
||
561 | |||
562 | /** |
||
563 | * Output raw block-level HTML |
||
564 | * |
||
565 | * If $conf['htmlok'] is true this should add the code as is to $doc |
||
566 | * |
||
567 | * @param string $text The HTML |
||
568 | */ |
||
569 | function htmlblock($text) { |
||
572 | |||
573 | /** |
||
574 | * Start a block quote |
||
575 | */ |
||
576 | function quote_open() { |
||
579 | |||
580 | /** |
||
581 | * Stop a block quote |
||
582 | */ |
||
583 | function quote_close() { |
||
586 | |||
587 | /** |
||
588 | * Output preformatted text |
||
589 | * |
||
590 | * @param string $text |
||
591 | */ |
||
592 | function preformatted($text) { |
||
595 | |||
596 | /** |
||
597 | * Display text as file content, optionally syntax highlighted |
||
598 | * |
||
599 | * @param string $text text to show |
||
600 | * @param string $language programming language to use for syntax highlighting |
||
601 | * @param string $filename file path label |
||
602 | */ |
||
603 | function file($text, $language = null, $filename = null) { |
||
606 | |||
607 | /** |
||
608 | * Display text as code content, optionally syntax highlighted |
||
609 | * |
||
610 | * @param string $text text to show |
||
611 | * @param string $language programming language to use for syntax highlighting |
||
612 | * @param string $filename file path label |
||
613 | */ |
||
614 | function code($text, $language = null, $filename = null) { |
||
617 | |||
618 | /** |
||
619 | * Use GeSHi to highlight language syntax in code and file blocks |
||
620 | * |
||
621 | * @author Andreas Gohr <[email protected]> |
||
622 | * @param string $type code|file |
||
623 | * @param string $text text to show |
||
624 | * @param string $language programming language to use for syntax highlighting |
||
625 | * @param string $filename file path label |
||
626 | */ |
||
627 | function _highlight($type, $text, $language = null, $filename = null) { |
||
665 | |||
666 | /** |
||
667 | * Format an acronym |
||
668 | * |
||
669 | * Uses $this->acronyms |
||
670 | * |
||
671 | * @param string $acronym |
||
672 | */ |
||
673 | function acronym($acronym) { |
||
686 | |||
687 | /** |
||
688 | * Format a smiley |
||
689 | * |
||
690 | * Uses $this->smiley |
||
691 | * |
||
692 | * @param string $smiley |
||
693 | */ |
||
694 | function smiley($smiley) { |
||
703 | |||
704 | /** |
||
705 | * Format an entity |
||
706 | * |
||
707 | * Entities are basically small text replacements |
||
708 | * |
||
709 | * Uses $this->entities |
||
710 | * |
||
711 | * @param string $entity |
||
712 | */ |
||
713 | function entity($entity) { |
||
720 | |||
721 | /** |
||
722 | * Typographically format a multiply sign |
||
723 | * |
||
724 | * Example: ($x=640, $y=480) should result in "640×480" |
||
725 | * |
||
726 | * @param string|int $x first value |
||
727 | * @param string|int $y second value |
||
728 | */ |
||
729 | function multiplyentity($x, $y) { |
||
732 | |||
733 | /** |
||
734 | * Render an opening single quote char (language specific) |
||
735 | */ |
||
736 | function singlequoteopening() { |
||
740 | |||
741 | /** |
||
742 | * Render a closing single quote char (language specific) |
||
743 | */ |
||
744 | function singlequoteclosing() { |
||
748 | |||
749 | /** |
||
750 | * Render an apostrophe char (language specific) |
||
751 | */ |
||
752 | function apostrophe() { |
||
756 | |||
757 | /** |
||
758 | * Render an opening double quote char (language specific) |
||
759 | */ |
||
760 | function doublequoteopening() { |
||
764 | |||
765 | /** |
||
766 | * Render an closinging double quote char (language specific) |
||
767 | */ |
||
768 | function doublequoteclosing() { |
||
772 | |||
773 | /** |
||
774 | * Render a CamelCase link |
||
775 | * |
||
776 | * @param string $link The link name |
||
777 | * @param bool $returnonly whether to return html or write to doc attribute |
||
778 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
779 | * |
||
780 | * @see http://en.wikipedia.org/wiki/CamelCase |
||
781 | */ |
||
782 | function camelcaselink($link, $returnonly = false) { |
||
789 | |||
790 | /** |
||
791 | * Render a page local link |
||
792 | * |
||
793 | * @param string $hash hash link identifier |
||
794 | * @param string $name name for the link |
||
795 | * @param bool $returnonly whether to return html or write to doc attribute |
||
796 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
797 | */ |
||
798 | function locallink($hash, $name = null, $returnonly = false) { |
||
814 | |||
815 | /** |
||
816 | * Render an internal Wiki Link |
||
817 | * |
||
818 | * $search,$returnonly & $linktype are not for the renderer but are used |
||
819 | * elsewhere - no need to implement them in other renderers |
||
820 | * |
||
821 | * @author Andreas Gohr <[email protected]> |
||
822 | * @param string $id pageid |
||
823 | * @param string|null $name link name |
||
824 | * @param string|null $search adds search url param |
||
825 | * @param bool $returnonly whether to return html or write to doc attribute |
||
826 | * @param string $linktype type to set use of headings |
||
827 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
828 | */ |
||
829 | function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { |
||
911 | |||
912 | /** |
||
913 | * Render an external link |
||
914 | * |
||
915 | * @param string $url full URL with scheme |
||
916 | * @param string|array $name name for the link, array for media file |
||
917 | * @param bool $returnonly whether to return html or write to doc attribute |
||
918 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
919 | */ |
||
920 | function externallink($url, $name = null, $returnonly = false) { |
||
971 | |||
972 | /** |
||
973 | * Render an interwiki link |
||
974 | * |
||
975 | * You may want to use $this->_resolveInterWiki() here |
||
976 | * |
||
977 | * @param string $match original link - probably not much use |
||
978 | * @param string|array $name name for the link, array for media file |
||
979 | * @param string $wikiName indentifier (shortcut) for the remote wiki |
||
980 | * @param string $wikiUri the fragment parsed from the original link |
||
981 | * @param bool $returnonly whether to return html or write to doc attribute |
||
982 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
983 | */ |
||
984 | function interwikilink($match, $name = null, $wikiName, $wikiUri, $returnonly = false) { |
||
1030 | |||
1031 | /** |
||
1032 | * Link to windows share |
||
1033 | * |
||
1034 | * @param string $url the link |
||
1035 | * @param string|array $name name for the link, array for media file |
||
1036 | * @param bool $returnonly whether to return html or write to doc attribute |
||
1037 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
1038 | */ |
||
1039 | function windowssharelink($url, $name = null, $returnonly = false) { |
||
1068 | |||
1069 | /** |
||
1070 | * Render a linked E-Mail Address |
||
1071 | * |
||
1072 | * Honors $conf['mailguard'] setting |
||
1073 | * |
||
1074 | * @param string $address Email-Address |
||
1075 | * @param string|array $name name for the link, array for media file |
||
1076 | * @param bool $returnonly whether to return html or write to doc attribute |
||
1077 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
1078 | */ |
||
1079 | function emaillink($address, $name = null, $returnonly = false) { |
||
1117 | |||
1118 | /** |
||
1119 | * Render an internal media file |
||
1120 | * |
||
1121 | * @param string $src media ID |
||
1122 | * @param string $title descriptive text |
||
1123 | * @param string $align left|center|right |
||
1124 | * @param int $width width of media in pixel |
||
1125 | * @param int $height height of media in pixel |
||
1126 | * @param string $cache cache|recache|nocache |
||
1127 | * @param string $linking linkonly|detail|nolink |
||
1128 | * @param bool $return return HTML instead of adding to $doc |
||
1129 | * @return void|string writes to doc attribute or returns html depends on $return |
||
1130 | */ |
||
1131 | function internalmedia($src, $title = null, $align = null, $width = null, |
||
1171 | |||
1172 | /** |
||
1173 | * Render an external media file |
||
1174 | * |
||
1175 | * @param string $src full media URL |
||
1176 | * @param string $title descriptive text |
||
1177 | * @param string $align left|center|right |
||
1178 | * @param int $width width of media in pixel |
||
1179 | * @param int $height height of media in pixel |
||
1180 | * @param string $cache cache|recache|nocache |
||
1181 | * @param string $linking linkonly|detail|nolink |
||
1182 | * @param bool $return return HTML instead of adding to $doc |
||
1183 | * @return void|string writes to doc attribute or returns html depends on $return |
||
1184 | */ |
||
1185 | function externalmedia($src, $title = null, $align = null, $width = null, |
||
1218 | |||
1219 | /** |
||
1220 | * Renders an RSS feed |
||
1221 | * |
||
1222 | * @param string $url URL of the feed |
||
1223 | * @param array $params Finetuning of the output |
||
1224 | * |
||
1225 | * @author Andreas Gohr <[email protected]> |
||
1226 | */ |
||
1227 | function rss($url, $params) { |
||
1310 | |||
1311 | /** |
||
1312 | * Start a table |
||
1313 | * |
||
1314 | * @param int $maxcols maximum number of columns |
||
1315 | * @param int $numrows NOT IMPLEMENTED |
||
1316 | * @param int $pos byte position in the original source |
||
1317 | * @param string $classes css class |
||
1318 | */ |
||
1319 | function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) { |
||
1332 | |||
1333 | /** |
||
1334 | * Close a table |
||
1335 | * |
||
1336 | * @param int $pos byte position in the original source |
||
1337 | */ |
||
1338 | function table_close($pos = null) { |
||
1344 | |||
1345 | /** |
||
1346 | * Open a table header |
||
1347 | */ |
||
1348 | function tablethead_open() { |
||
1351 | |||
1352 | /** |
||
1353 | * Close a table header |
||
1354 | */ |
||
1355 | function tablethead_close() { |
||
1358 | |||
1359 | /** |
||
1360 | * Open a table body |
||
1361 | */ |
||
1362 | function tabletbody_open() { |
||
1365 | |||
1366 | /** |
||
1367 | * Close a table body |
||
1368 | */ |
||
1369 | function tabletbody_close() { |
||
1372 | |||
1373 | /** |
||
1374 | * Open a table row |
||
1375 | * |
||
1376 | * @param string $classes css class |
||
1377 | */ |
||
1378 | function tablerow_open($classes = null) { |
||
1387 | |||
1388 | /** |
||
1389 | * Close a table row |
||
1390 | */ |
||
1391 | function tablerow_close() { |
||
1394 | |||
1395 | /** |
||
1396 | * Open a table header cell |
||
1397 | * |
||
1398 | * @param int $colspan |
||
1399 | * @param string $align left|center|right |
||
1400 | * @param int $rowspan |
||
1401 | * @param string $classes css class |
||
1402 | */ |
||
1403 | function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
1422 | |||
1423 | /** |
||
1424 | * Close a table header cell |
||
1425 | */ |
||
1426 | function tableheader_close() { |
||
1429 | |||
1430 | /** |
||
1431 | * Open a table cell |
||
1432 | * |
||
1433 | * @param int $colspan |
||
1434 | * @param string $align left|center|right |
||
1435 | * @param int $rowspan |
||
1436 | * @param string $classes css class |
||
1437 | */ |
||
1438 | function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
1457 | |||
1458 | /** |
||
1459 | * Close a table cell |
||
1460 | */ |
||
1461 | function tablecell_close() { |
||
1464 | |||
1465 | #region Utility functions |
||
1466 | |||
1467 | /** |
||
1468 | * Build a link |
||
1469 | * |
||
1470 | * Assembles all parts defined in $link returns HTML for the link |
||
1471 | * |
||
1472 | * @param array $link attributes of a link |
||
1473 | * @return string |
||
1474 | * |
||
1475 | * @author Andreas Gohr <[email protected]> |
||
1476 | */ |
||
1477 | function _formatLink($link) { |
||
1506 | |||
1507 | /** |
||
1508 | * Renders internal and external media |
||
1509 | * |
||
1510 | * @author Andreas Gohr <[email protected]> |
||
1511 | * @param string $src media ID |
||
1512 | * @param string $title descriptive text |
||
1513 | * @param string $align left|center|right |
||
1514 | * @param int $width width of media in pixel |
||
1515 | * @param int $height height of media in pixel |
||
1516 | * @param string $cache cache|recache|nocache |
||
1517 | * @param bool $render should the media be embedded inline or just linked |
||
1518 | * @return string |
||
1519 | */ |
||
1520 | function _media($src, $title = null, $align = null, $width = null, |
||
1623 | |||
1624 | /** |
||
1625 | * Escape string for output |
||
1626 | * |
||
1627 | * @param $string |
||
1628 | * @return string |
||
1629 | */ |
||
1630 | function _xmlEntities($string) { |
||
1633 | |||
1634 | /** |
||
1635 | * Creates a linkid from a headline |
||
1636 | * |
||
1637 | * @author Andreas Gohr <[email protected]> |
||
1638 | * @param string $title The headline title |
||
1639 | * @param boolean $create Create a new unique ID? |
||
1640 | * @return string |
||
1641 | */ |
||
1642 | function _headerToLink($title, $create = false) { |
||
1650 | |||
1651 | /** |
||
1652 | * Construct a title and handle images in titles |
||
1653 | * |
||
1654 | * @author Harry Fuecks <[email protected]> |
||
1655 | * @param string|array $title either string title or media array |
||
1656 | * @param string $default default title if nothing else is found |
||
1657 | * @param bool $isImage will be set to true if it's a media file |
||
1658 | * @param null|string $id linked page id (used to extract title from first heading) |
||
1659 | * @param string $linktype content|navigation |
||
1660 | * @return string HTML of the title, might be full image tag or just escaped text |
||
1661 | */ |
||
1662 | function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') { |
||
1679 | |||
1680 | /** |
||
1681 | * Returns HTML code for images used in link titles |
||
1682 | * |
||
1683 | * @author Andreas Gohr <[email protected]> |
||
1684 | * @param array $img |
||
1685 | * @return string HTML img tag or similar |
||
1686 | */ |
||
1687 | function _imageTitle($img) { |
||
1706 | |||
1707 | /** |
||
1708 | * helperfunction to return a basic link to a media |
||
1709 | * |
||
1710 | * used in internalmedia() and externalmedia() |
||
1711 | * |
||
1712 | * @author Pierre Spring <[email protected]> |
||
1713 | * @param string $src media ID |
||
1714 | * @param string $title descriptive text |
||
1715 | * @param string $align left|center|right |
||
1716 | * @param int $width width of media in pixel |
||
1717 | * @param int $height height of media in pixel |
||
1718 | * @param string $cache cache|recache|nocache |
||
1719 | * @param bool $render should the media be embedded inline or just linked |
||
1720 | * @return array associative array with link config |
||
1721 | */ |
||
1722 | function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) { |
||
1738 | |||
1739 | /** |
||
1740 | * Embed video(s) in HTML |
||
1741 | * |
||
1742 | * @author Anika Henke <[email protected]> |
||
1743 | * |
||
1744 | * @param string $src - ID of video to embed |
||
1745 | * @param int $width - width of the video in pixels |
||
1746 | * @param int $height - height of the video in pixels |
||
1747 | * @param array $atts - additional attributes for the <video> tag |
||
1748 | * @return string |
||
1749 | */ |
||
1750 | function _video($src, $width, $height, $atts = null) { |
||
1804 | |||
1805 | /** |
||
1806 | * Embed audio in HTML |
||
1807 | * |
||
1808 | * @author Anika Henke <[email protected]> |
||
1809 | * |
||
1810 | * @param string $src - ID of audio to embed |
||
1811 | * @param array $atts - additional attributes for the <audio> tag |
||
1812 | * @return string |
||
1813 | */ |
||
1814 | function _audio($src, $atts = array()) { |
||
1854 | |||
1855 | /** |
||
1856 | * _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media() |
||
1857 | * which returns an existing media revision less or equal to rev or date_at |
||
1858 | * |
||
1859 | * @author lisps |
||
1860 | * @param string $media_id |
||
1861 | * @access protected |
||
1862 | * @return string revision ('' for current) |
||
1863 | */ |
||
1864 | function _getLastMediaRevisionAt($media_id){ |
||
1869 | |||
1870 | #endregion |
||
1871 | } |
||
1872 | |||
1874 |
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.