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 | var $date_at = ''; // link pages and media against this revision |
||
| 18 | |||
| 19 | /** @var int last section edit id, used by startSectionEdit */ |
||
| 20 | protected $lastsecid = 0; |
||
| 21 | |||
| 22 | /** @var array the list of headers used to create unique link ids */ |
||
| 23 | protected $headers = array(); |
||
| 24 | |||
| 25 | /** @var array a list of footnotes, list starts at 1! */ |
||
| 26 | protected $footnotes = array(); |
||
| 27 | |||
| 28 | /** @var int current section level */ |
||
| 29 | protected $lastlevel = 0; |
||
| 30 | /** @var array section node tracker */ |
||
| 31 | protected $node = array(0, 0, 0, 0, 0); |
||
| 32 | |||
| 33 | /** @var string temporary $doc store */ |
||
| 34 | protected $store = ''; |
||
| 35 | |||
| 36 | /** @var array global counter, for table classes etc. */ |
||
| 37 | protected $_counter = array(); // |
||
| 38 | |||
| 39 | /** @var int counts the code and file blocks, used to provide download links */ |
||
| 40 | protected $_codeblock = 0; |
||
| 41 | |||
| 42 | /** @var array list of allowed URL schemes */ |
||
| 43 | protected $schemes = null; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Register a new edit section range |
||
| 47 | * |
||
| 48 | * @param int $start The byte position for the edit start |
||
| 49 | * @param array $data Associative array with section data: |
||
| 50 | * Key 'name': the section name/title |
||
| 51 | * Key 'target': the target for the section edit, |
||
| 52 | * e.g. 'section' or 'table' |
||
| 53 | * Key 'hid': header id |
||
| 54 | * Key 'codeblockOffset': actual code block index |
||
| 55 | * Key 'start': set in startSectionEdit(), |
||
| 56 | * do not set yourself |
||
| 57 | * Key 'range': calculated from 'start' and |
||
| 58 | * $key in finishSectionEdit(), |
||
| 59 | * do not set yourself |
||
| 60 | * @return string A marker class for the starting HTML element |
||
| 61 | * |
||
| 62 | * @author Adrian Lang <[email protected]> |
||
| 63 | */ |
||
| 64 | public function startSectionEdit($start, $data) { |
||
| 65 | if (!is_array($data)) { |
||
| 66 | msg( |
||
| 67 | sprintf( |
||
| 68 | 'startSectionEdit: $data "%s" is NOT an array! One of your plugins needs an update.', |
||
| 69 | hsc((string) $data) |
||
| 70 | ), -1 |
||
| 71 | ); |
||
| 72 | |||
| 73 | // @deprecated 2018-04-14, backward compatibility |
||
| 74 | $args = func_get_args(); |
||
| 75 | $data = array(); |
||
| 76 | if(isset($args[1])) $data['target'] = $args[1]; |
||
| 77 | if(isset($args[2])) $data['name'] = $args[2]; |
||
| 78 | if(isset($args[3])) $data['hid'] = $args[3]; |
||
| 79 | } |
||
| 80 | $data['secid'] = ++$this->lastsecid; |
||
| 81 | $data['start'] = $start; |
||
| 82 | $this->sectionedits[] = $data; |
||
| 83 | return 'sectionedit'.$data['secid']; |
||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * Finish an edit section range |
||
| 88 | * |
||
| 89 | * @param int $end The byte position for the edit end; null for the rest of the page |
||
| 90 | * |
||
| 91 | * @author Adrian Lang <[email protected]> |
||
| 92 | */ |
||
| 93 | public function finishSectionEdit($end = null, $hid = null) { |
||
| 94 | $data = array_pop($this->sectionedits); |
||
| 95 | if(!is_null($end) && $end <= $data['start']) { |
||
| 96 | return; |
||
| 97 | } |
||
| 98 | if(!is_null($hid)) { |
||
| 99 | $data['hid'] .= $hid; |
||
| 100 | } |
||
| 101 | $data['range'] = $data['start'].'-'.(is_null($end) ? '' : $end); |
||
| 102 | unset($data['start']); |
||
| 103 | $this->doc .= '<!-- EDIT'.hsc(json_encode ($data)).' -->'; |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * Returns the format produced by this renderer. |
||
| 108 | * |
||
| 109 | * @return string always 'xhtml' |
||
| 110 | */ |
||
| 111 | function getFormat() { |
||
|
|
|||
| 112 | return 'xhtml'; |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Initialize the document |
||
| 117 | */ |
||
| 118 | function document_start() { |
||
| 119 | //reset some internals |
||
| 120 | $this->toc = array(); |
||
| 121 | $this->headers = array(); |
||
| 122 | } |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Finalize the document |
||
| 126 | */ |
||
| 127 | function document_end() { |
||
| 128 | // Finish open section edits. |
||
| 129 | while(count($this->sectionedits) > 0) { |
||
| 130 | if($this->sectionedits[count($this->sectionedits) - 1]['start'] <= 1) { |
||
| 131 | // If there is only one section, do not write a section edit |
||
| 132 | // marker. |
||
| 133 | array_pop($this->sectionedits); |
||
| 134 | } else { |
||
| 135 | $this->finishSectionEdit(); |
||
| 136 | } |
||
| 137 | } |
||
| 138 | |||
| 139 | if(count($this->footnotes) > 0) { |
||
| 140 | $this->doc .= '<div class="footnotes">'.DOKU_LF; |
||
| 141 | |||
| 142 | foreach($this->footnotes as $id => $footnote) { |
||
| 143 | // check its not a placeholder that indicates actual footnote text is elsewhere |
||
| 144 | if(substr($footnote, 0, 5) != "@@FNT") { |
||
| 145 | |||
| 146 | // open the footnote and set the anchor and backlink |
||
| 147 | $this->doc .= '<div class="fn">'; |
||
| 148 | $this->doc .= '<sup><a href="#fnt__'.$id.'" id="fn__'.$id.'" class="fn_bot">'; |
||
| 149 | $this->doc .= $id.')</a></sup> '.DOKU_LF; |
||
| 150 | |||
| 151 | // get any other footnotes that use the same markup |
||
| 152 | $alt = array_keys($this->footnotes, "@@FNT$id"); |
||
| 153 | |||
| 154 | if(count($alt)) { |
||
| 155 | foreach($alt as $ref) { |
||
| 156 | // set anchor and backlink for the other footnotes |
||
| 157 | $this->doc .= ', <sup><a href="#fnt__'.($ref).'" id="fn__'.($ref).'" class="fn_bot">'; |
||
| 158 | $this->doc .= ($ref).')</a></sup> '.DOKU_LF; |
||
| 159 | } |
||
| 160 | } |
||
| 161 | |||
| 162 | // add footnote markup and close this footnote |
||
| 163 | $this->doc .= '<div class="content">'.$footnote.'</div>'; |
||
| 164 | $this->doc .= '</div>'.DOKU_LF; |
||
| 165 | } |
||
| 166 | } |
||
| 167 | $this->doc .= '</div>'.DOKU_LF; |
||
| 168 | } |
||
| 169 | |||
| 170 | // Prepare the TOC |
||
| 171 | global $conf; |
||
| 172 | if( |
||
| 173 | $this->info['toc'] && |
||
| 174 | is_array($this->toc) && |
||
| 175 | $conf['tocminheads'] && count($this->toc) >= $conf['tocminheads'] |
||
| 176 | ) { |
||
| 177 | global $TOC; |
||
| 178 | $TOC = $this->toc; |
||
| 179 | } |
||
| 180 | |||
| 181 | // make sure there are no empty paragraphs |
||
| 182 | $this->doc = preg_replace('#<p>\s*</p>#', '', $this->doc); |
||
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Add an item to the TOC |
||
| 187 | * |
||
| 188 | * @param string $id the hash link |
||
| 189 | * @param string $text the text to display |
||
| 190 | * @param int $level the nesting level |
||
| 191 | */ |
||
| 192 | function toc_additem($id, $text, $level) { |
||
| 193 | global $conf; |
||
| 194 | |||
| 195 | //handle TOC |
||
| 196 | if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']) { |
||
| 197 | $this->toc[] = html_mktocitem($id, $text, $level - $conf['toptoclevel'] + 1); |
||
| 198 | } |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * Render a heading |
||
| 203 | * |
||
| 204 | * @param string $text the text to display |
||
| 205 | * @param int $level header level |
||
| 206 | * @param int $pos byte position in the original source |
||
| 207 | */ |
||
| 208 | function header($text, $level, $pos) { |
||
| 209 | global $conf; |
||
| 210 | |||
| 211 | if(blank($text)) return; //skip empty headlines |
||
| 212 | |||
| 213 | $hid = $this->_headerToLink($text, true); |
||
| 214 | |||
| 215 | //only add items within configured levels |
||
| 216 | $this->toc_additem($hid, $text, $level); |
||
| 217 | |||
| 218 | // adjust $node to reflect hierarchy of levels |
||
| 219 | $this->node[$level - 1]++; |
||
| 220 | if($level < $this->lastlevel) { |
||
| 221 | for($i = 0; $i < $this->lastlevel - $level; $i++) { |
||
| 222 | $this->node[$this->lastlevel - $i - 1] = 0; |
||
| 223 | } |
||
| 224 | } |
||
| 225 | $this->lastlevel = $level; |
||
| 226 | |||
| 227 | if($level <= $conf['maxseclevel'] && |
||
| 228 | count($this->sectionedits) > 0 && |
||
| 229 | $this->sectionedits[count($this->sectionedits) - 1]['target'] === 'section' |
||
| 230 | ) { |
||
| 231 | $this->finishSectionEdit($pos - 1); |
||
| 232 | } |
||
| 233 | |||
| 234 | // write the header |
||
| 235 | $this->doc .= DOKU_LF.'<h'.$level; |
||
| 236 | if($level <= $conf['maxseclevel']) { |
||
| 237 | $data = array(); |
||
| 238 | $data['target'] = 'section'; |
||
| 239 | $data['name'] = $text; |
||
| 240 | $data['hid'] = $hid; |
||
| 241 | $data['codeblockOffset'] = $this->_codeblock; |
||
| 242 | $this->doc .= ' class="'.$this->startSectionEdit($pos, $data).'"'; |
||
| 243 | } |
||
| 244 | $this->doc .= ' id="'.$hid.'">'; |
||
| 245 | $this->doc .= $this->_xmlEntities($text); |
||
| 246 | $this->doc .= "</h$level>".DOKU_LF; |
||
| 247 | } |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Open a new section |
||
| 251 | * |
||
| 252 | * @param int $level section level (as determined by the previous header) |
||
| 253 | */ |
||
| 254 | function section_open($level) { |
||
| 255 | $this->doc .= '<div class="level'.$level.'">'.DOKU_LF; |
||
| 256 | } |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Close the current section |
||
| 260 | */ |
||
| 261 | function section_close() { |
||
| 262 | $this->doc .= DOKU_LF.'</div>'.DOKU_LF; |
||
| 263 | } |
||
| 264 | |||
| 265 | /** |
||
| 266 | * Render plain text data |
||
| 267 | * |
||
| 268 | * @param $text |
||
| 269 | */ |
||
| 270 | function cdata($text) { |
||
| 271 | $this->doc .= $this->_xmlEntities($text); |
||
| 272 | } |
||
| 273 | |||
| 274 | /** |
||
| 275 | * Open a paragraph |
||
| 276 | */ |
||
| 277 | function p_open() { |
||
| 278 | $this->doc .= DOKU_LF.'<p>'.DOKU_LF; |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * Close a paragraph |
||
| 283 | */ |
||
| 284 | function p_close() { |
||
| 285 | $this->doc .= DOKU_LF.'</p>'.DOKU_LF; |
||
| 286 | } |
||
| 287 | |||
| 288 | /** |
||
| 289 | * Create a line break |
||
| 290 | */ |
||
| 291 | function linebreak() { |
||
| 292 | $this->doc .= '<br/>'.DOKU_LF; |
||
| 293 | } |
||
| 294 | |||
| 295 | /** |
||
| 296 | * Create a horizontal line |
||
| 297 | */ |
||
| 298 | function hr() { |
||
| 299 | $this->doc .= '<hr />'.DOKU_LF; |
||
| 300 | } |
||
| 301 | |||
| 302 | /** |
||
| 303 | * Start strong (bold) formatting |
||
| 304 | */ |
||
| 305 | function strong_open() { |
||
| 306 | $this->doc .= '<strong>'; |
||
| 307 | } |
||
| 308 | |||
| 309 | /** |
||
| 310 | * Stop strong (bold) formatting |
||
| 311 | */ |
||
| 312 | function strong_close() { |
||
| 313 | $this->doc .= '</strong>'; |
||
| 314 | } |
||
| 315 | |||
| 316 | /** |
||
| 317 | * Start emphasis (italics) formatting |
||
| 318 | */ |
||
| 319 | function emphasis_open() { |
||
| 320 | $this->doc .= '<em>'; |
||
| 321 | } |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Stop emphasis (italics) formatting |
||
| 325 | */ |
||
| 326 | function emphasis_close() { |
||
| 327 | $this->doc .= '</em>'; |
||
| 328 | } |
||
| 329 | |||
| 330 | /** |
||
| 331 | * Start underline formatting |
||
| 332 | */ |
||
| 333 | function underline_open() { |
||
| 334 | $this->doc .= '<em class="u">'; |
||
| 335 | } |
||
| 336 | |||
| 337 | /** |
||
| 338 | * Stop underline formatting |
||
| 339 | */ |
||
| 340 | function underline_close() { |
||
| 341 | $this->doc .= '</em>'; |
||
| 342 | } |
||
| 343 | |||
| 344 | /** |
||
| 345 | * Start monospace formatting |
||
| 346 | */ |
||
| 347 | function monospace_open() { |
||
| 348 | $this->doc .= '<code>'; |
||
| 349 | } |
||
| 350 | |||
| 351 | /** |
||
| 352 | * Stop monospace formatting |
||
| 353 | */ |
||
| 354 | function monospace_close() { |
||
| 355 | $this->doc .= '</code>'; |
||
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * Start a subscript |
||
| 360 | */ |
||
| 361 | function subscript_open() { |
||
| 362 | $this->doc .= '<sub>'; |
||
| 363 | } |
||
| 364 | |||
| 365 | /** |
||
| 366 | * Stop a subscript |
||
| 367 | */ |
||
| 368 | function subscript_close() { |
||
| 369 | $this->doc .= '</sub>'; |
||
| 370 | } |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Start a superscript |
||
| 374 | */ |
||
| 375 | function superscript_open() { |
||
| 376 | $this->doc .= '<sup>'; |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Stop a superscript |
||
| 381 | */ |
||
| 382 | function superscript_close() { |
||
| 383 | $this->doc .= '</sup>'; |
||
| 384 | } |
||
| 385 | |||
| 386 | /** |
||
| 387 | * Start deleted (strike-through) formatting |
||
| 388 | */ |
||
| 389 | function deleted_open() { |
||
| 390 | $this->doc .= '<del>'; |
||
| 391 | } |
||
| 392 | |||
| 393 | /** |
||
| 394 | * Stop deleted (strike-through) formatting |
||
| 395 | */ |
||
| 396 | function deleted_close() { |
||
| 397 | $this->doc .= '</del>'; |
||
| 398 | } |
||
| 399 | |||
| 400 | /** |
||
| 401 | * Callback for footnote start syntax |
||
| 402 | * |
||
| 403 | * All following content will go to the footnote instead of |
||
| 404 | * the document. To achieve this the previous rendered content |
||
| 405 | * is moved to $store and $doc is cleared |
||
| 406 | * |
||
| 407 | * @author Andreas Gohr <[email protected]> |
||
| 408 | */ |
||
| 409 | function footnote_open() { |
||
| 410 | |||
| 411 | // move current content to store and record footnote |
||
| 412 | $this->store = $this->doc; |
||
| 413 | $this->doc = ''; |
||
| 414 | } |
||
| 415 | |||
| 416 | /** |
||
| 417 | * Callback for footnote end syntax |
||
| 418 | * |
||
| 419 | * All rendered content is moved to the $footnotes array and the old |
||
| 420 | * content is restored from $store again |
||
| 421 | * |
||
| 422 | * @author Andreas Gohr |
||
| 423 | */ |
||
| 424 | function footnote_close() { |
||
| 425 | /** @var $fnid int takes track of seen footnotes, assures they are unique even across multiple docs FS#2841 */ |
||
| 426 | static $fnid = 0; |
||
| 427 | // assign new footnote id (we start at 1) |
||
| 428 | $fnid++; |
||
| 429 | |||
| 430 | // recover footnote into the stack and restore old content |
||
| 431 | $footnote = $this->doc; |
||
| 432 | $this->doc = $this->store; |
||
| 433 | $this->store = ''; |
||
| 434 | |||
| 435 | // check to see if this footnote has been seen before |
||
| 436 | $i = array_search($footnote, $this->footnotes); |
||
| 437 | |||
| 438 | if($i === false) { |
||
| 439 | // its a new footnote, add it to the $footnotes array |
||
| 440 | $this->footnotes[$fnid] = $footnote; |
||
| 441 | } else { |
||
| 442 | // seen this one before, save a placeholder |
||
| 443 | $this->footnotes[$fnid] = "@@FNT".($i); |
||
| 444 | } |
||
| 445 | |||
| 446 | // output the footnote reference and link |
||
| 447 | $this->doc .= '<sup><a href="#fn__'.$fnid.'" id="fnt__'.$fnid.'" class="fn_top">'.$fnid.')</a></sup>'; |
||
| 448 | } |
||
| 449 | |||
| 450 | /** |
||
| 451 | * Open an unordered list |
||
| 452 | * |
||
| 453 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 454 | */ |
||
| 455 | function listu_open($classes = null) { |
||
| 456 | $class = ''; |
||
| 457 | if($classes !== null) { |
||
| 458 | if(is_array($classes)) $classes = join(' ', $classes); |
||
| 459 | $class = " class=\"$classes\""; |
||
| 460 | } |
||
| 461 | $this->doc .= "<ul$class>".DOKU_LF; |
||
| 462 | } |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Close an unordered list |
||
| 466 | */ |
||
| 467 | function listu_close() { |
||
| 468 | $this->doc .= '</ul>'.DOKU_LF; |
||
| 469 | } |
||
| 470 | |||
| 471 | /** |
||
| 472 | * Open an ordered list |
||
| 473 | * |
||
| 474 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 475 | */ |
||
| 476 | function listo_open($classes = null) { |
||
| 477 | $class = ''; |
||
| 478 | if($classes !== null) { |
||
| 479 | if(is_array($classes)) $classes = join(' ', $classes); |
||
| 480 | $class = " class=\"$classes\""; |
||
| 481 | } |
||
| 482 | $this->doc .= "<ol$class>".DOKU_LF; |
||
| 483 | } |
||
| 484 | |||
| 485 | /** |
||
| 486 | * Close an ordered list |
||
| 487 | */ |
||
| 488 | function listo_close() { |
||
| 489 | $this->doc .= '</ol>'.DOKU_LF; |
||
| 490 | } |
||
| 491 | |||
| 492 | /** |
||
| 493 | * Open a list item |
||
| 494 | * |
||
| 495 | * @param int $level the nesting level |
||
| 496 | * @param bool $node true when a node; false when a leaf |
||
| 497 | */ |
||
| 498 | function listitem_open($level, $node=false) { |
||
| 499 | $branching = $node ? ' node' : ''; |
||
| 500 | $this->doc .= '<li class="level'.$level.$branching.'">'; |
||
| 501 | } |
||
| 502 | |||
| 503 | /** |
||
| 504 | * Close a list item |
||
| 505 | */ |
||
| 506 | function listitem_close() { |
||
| 507 | $this->doc .= '</li>'.DOKU_LF; |
||
| 508 | } |
||
| 509 | |||
| 510 | /** |
||
| 511 | * Start the content of a list item |
||
| 512 | */ |
||
| 513 | function listcontent_open() { |
||
| 514 | $this->doc .= '<div class="li">'; |
||
| 515 | } |
||
| 516 | |||
| 517 | /** |
||
| 518 | * Stop the content of a list item |
||
| 519 | */ |
||
| 520 | function listcontent_close() { |
||
| 521 | $this->doc .= '</div>'.DOKU_LF; |
||
| 522 | } |
||
| 523 | |||
| 524 | /** |
||
| 525 | * Output unformatted $text |
||
| 526 | * |
||
| 527 | * Defaults to $this->cdata() |
||
| 528 | * |
||
| 529 | * @param string $text |
||
| 530 | */ |
||
| 531 | function unformatted($text) { |
||
| 532 | $this->doc .= $this->_xmlEntities($text); |
||
| 533 | } |
||
| 534 | |||
| 535 | /** |
||
| 536 | * Execute PHP code if allowed |
||
| 537 | * |
||
| 538 | * @param string $text PHP code that is either executed or printed |
||
| 539 | * @param string $wrapper html element to wrap result if $conf['phpok'] is okff |
||
| 540 | * |
||
| 541 | * @author Andreas Gohr <[email protected]> |
||
| 542 | */ |
||
| 543 | function php($text, $wrapper = 'code') { |
||
| 544 | global $conf; |
||
| 545 | |||
| 546 | if($conf['phpok']) { |
||
| 547 | ob_start(); |
||
| 548 | eval($text); |
||
| 549 | $this->doc .= ob_get_contents(); |
||
| 550 | ob_end_clean(); |
||
| 551 | } else { |
||
| 552 | $this->doc .= p_xhtml_cached_geshi($text, 'php', $wrapper); |
||
| 553 | } |
||
| 554 | } |
||
| 555 | |||
| 556 | /** |
||
| 557 | * Output block level PHP code |
||
| 558 | * |
||
| 559 | * If $conf['phpok'] is true this should evaluate the given code and append the result |
||
| 560 | * to $doc |
||
| 561 | * |
||
| 562 | * @param string $text The PHP code |
||
| 563 | */ |
||
| 564 | function phpblock($text) { |
||
| 565 | $this->php($text, 'pre'); |
||
| 566 | } |
||
| 567 | |||
| 568 | /** |
||
| 569 | * Insert HTML if allowed |
||
| 570 | * |
||
| 571 | * @param string $text html text |
||
| 572 | * @param string $wrapper html element to wrap result if $conf['htmlok'] is okff |
||
| 573 | * |
||
| 574 | * @author Andreas Gohr <[email protected]> |
||
| 575 | */ |
||
| 576 | function html($text, $wrapper = 'code') { |
||
| 577 | global $conf; |
||
| 578 | |||
| 579 | if($conf['htmlok']) { |
||
| 580 | $this->doc .= $text; |
||
| 581 | } else { |
||
| 582 | $this->doc .= p_xhtml_cached_geshi($text, 'html4strict', $wrapper); |
||
| 583 | } |
||
| 584 | } |
||
| 585 | |||
| 586 | /** |
||
| 587 | * Output raw block-level HTML |
||
| 588 | * |
||
| 589 | * If $conf['htmlok'] is true this should add the code as is to $doc |
||
| 590 | * |
||
| 591 | * @param string $text The HTML |
||
| 592 | */ |
||
| 593 | function htmlblock($text) { |
||
| 594 | $this->html($text, 'pre'); |
||
| 595 | } |
||
| 596 | |||
| 597 | /** |
||
| 598 | * Start a block quote |
||
| 599 | */ |
||
| 600 | function quote_open() { |
||
| 601 | $this->doc .= '<blockquote><div class="no">'.DOKU_LF; |
||
| 602 | } |
||
| 603 | |||
| 604 | /** |
||
| 605 | * Stop a block quote |
||
| 606 | */ |
||
| 607 | function quote_close() { |
||
| 608 | $this->doc .= '</div></blockquote>'.DOKU_LF; |
||
| 609 | } |
||
| 610 | |||
| 611 | /** |
||
| 612 | * Output preformatted text |
||
| 613 | * |
||
| 614 | * @param string $text |
||
| 615 | */ |
||
| 616 | function preformatted($text) { |
||
| 617 | $this->doc .= '<pre class="code">'.trim($this->_xmlEntities($text), "\n\r").'</pre>'.DOKU_LF; |
||
| 618 | } |
||
| 619 | |||
| 620 | /** |
||
| 621 | * Display text as file content, optionally syntax highlighted |
||
| 622 | * |
||
| 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 | * @param array $options assoziative array with additional geshi options |
||
| 627 | */ |
||
| 628 | function file($text, $language = null, $filename = null, $options=null) { |
||
| 629 | $this->_highlight('file', $text, $language, $filename, $options); |
||
| 630 | } |
||
| 631 | |||
| 632 | /** |
||
| 633 | * Display text as code content, optionally syntax highlighted |
||
| 634 | * |
||
| 635 | * @param string $text text to show |
||
| 636 | * @param string $language programming language to use for syntax highlighting |
||
| 637 | * @param string $filename file path label |
||
| 638 | * @param array $options assoziative array with additional geshi options |
||
| 639 | */ |
||
| 640 | function code($text, $language = null, $filename = null, $options=null) { |
||
| 641 | $this->_highlight('code', $text, $language, $filename, $options); |
||
| 642 | } |
||
| 643 | |||
| 644 | /** |
||
| 645 | * Use GeSHi to highlight language syntax in code and file blocks |
||
| 646 | * |
||
| 647 | * @author Andreas Gohr <[email protected]> |
||
| 648 | * @param string $type code|file |
||
| 649 | * @param string $text text to show |
||
| 650 | * @param string $language programming language to use for syntax highlighting |
||
| 651 | * @param string $filename file path label |
||
| 652 | * @param array $options assoziative array with additional geshi options |
||
| 653 | */ |
||
| 654 | function _highlight($type, $text, $language = null, $filename = null, $options = null) { |
||
| 655 | global $ID; |
||
| 656 | global $lang; |
||
| 657 | global $INPUT; |
||
| 658 | |||
| 659 | $language = preg_replace(PREG_PATTERN_VALID_LANGUAGE, '', $language); |
||
| 660 | |||
| 661 | if($filename) { |
||
| 662 | // add icon |
||
| 663 | list($ext) = mimetype($filename, false); |
||
| 664 | $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext); |
||
| 665 | $class = 'mediafile mf_'.$class; |
||
| 666 | |||
| 667 | $offset = 0; |
||
| 668 | if ($INPUT->has('codeblockOffset')) { |
||
| 669 | $offset = $INPUT->str('codeblockOffset'); |
||
| 670 | } |
||
| 671 | $this->doc .= '<dl class="'.$type.'">'.DOKU_LF; |
||
| 672 | $this->doc .= '<dt><a href="' . |
||
| 673 | exportlink( |
||
| 674 | $ID, |
||
| 675 | 'code', |
||
| 676 | array('codeblock' => $offset + $this->_codeblock) |
||
| 677 | ) . '" title="' . $lang['download'] . '" class="' . $class . '">'; |
||
| 678 | $this->doc .= hsc($filename); |
||
| 679 | $this->doc .= '</a></dt>'.DOKU_LF.'<dd>'; |
||
| 680 | } |
||
| 681 | |||
| 682 | if($text{0} == "\n") { |
||
| 683 | $text = substr($text, 1); |
||
| 684 | } |
||
| 685 | if(substr($text, -1) == "\n") { |
||
| 686 | $text = substr($text, 0, -1); |
||
| 687 | } |
||
| 688 | |||
| 689 | if(empty($language)) { // empty is faster than is_null and can prevent '' string |
||
| 690 | $this->doc .= '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF; |
||
| 691 | } else { |
||
| 692 | $class = 'code'; //we always need the code class to make the syntax highlighting apply |
||
| 693 | if($type != 'code') $class .= ' '.$type; |
||
| 694 | |||
| 695 | $this->doc .= "<pre class=\"$class $language\">" . |
||
| 696 | p_xhtml_cached_geshi($text, $language, '', $options) . |
||
| 697 | '</pre>' . DOKU_LF; |
||
| 698 | } |
||
| 699 | |||
| 700 | if($filename) { |
||
| 701 | $this->doc .= '</dd></dl>'.DOKU_LF; |
||
| 702 | } |
||
| 703 | |||
| 704 | $this->_codeblock++; |
||
| 705 | } |
||
| 706 | |||
| 707 | /** |
||
| 708 | * Format an acronym |
||
| 709 | * |
||
| 710 | * Uses $this->acronyms |
||
| 711 | * |
||
| 712 | * @param string $acronym |
||
| 713 | */ |
||
| 714 | function acronym($acronym) { |
||
| 727 | |||
| 728 | /** |
||
| 729 | * Format a smiley |
||
| 730 | * |
||
| 731 | * Uses $this->smiley |
||
| 732 | * |
||
| 733 | * @param string $smiley |
||
| 734 | */ |
||
| 735 | function smiley($smiley) { |
||
| 744 | |||
| 745 | /** |
||
| 746 | * Format an entity |
||
| 747 | * |
||
| 748 | * Entities are basically small text replacements |
||
| 749 | * |
||
| 750 | * Uses $this->entities |
||
| 751 | * |
||
| 752 | * @param string $entity |
||
| 753 | */ |
||
| 754 | function entity($entity) { |
||
| 761 | |||
| 762 | /** |
||
| 763 | * Typographically format a multiply sign |
||
| 764 | * |
||
| 765 | * Example: ($x=640, $y=480) should result in "640×480" |
||
| 766 | * |
||
| 767 | * @param string|int $x first value |
||
| 768 | * @param string|int $y second value |
||
| 769 | */ |
||
| 770 | function multiplyentity($x, $y) { |
||
| 773 | |||
| 774 | /** |
||
| 775 | * Render an opening single quote char (language specific) |
||
| 776 | */ |
||
| 777 | function singlequoteopening() { |
||
| 781 | |||
| 782 | /** |
||
| 783 | * Render a closing single quote char (language specific) |
||
| 784 | */ |
||
| 785 | function singlequoteclosing() { |
||
| 789 | |||
| 790 | /** |
||
| 791 | * Render an apostrophe char (language specific) |
||
| 792 | */ |
||
| 793 | function apostrophe() { |
||
| 797 | |||
| 798 | /** |
||
| 799 | * Render an opening double quote char (language specific) |
||
| 800 | */ |
||
| 801 | function doublequoteopening() { |
||
| 805 | |||
| 806 | /** |
||
| 807 | * Render an closinging double quote char (language specific) |
||
| 808 | */ |
||
| 809 | function doublequoteclosing() { |
||
| 813 | |||
| 814 | /** |
||
| 815 | * Render a CamelCase link |
||
| 816 | * |
||
| 817 | * @param string $link The link name |
||
| 818 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 819 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 820 | * |
||
| 821 | * @see http://en.wikipedia.org/wiki/CamelCase |
||
| 822 | */ |
||
| 823 | function camelcaselink($link, $returnonly = false) { |
||
| 830 | |||
| 831 | /** |
||
| 832 | * Render a page local link |
||
| 833 | * |
||
| 834 | * @param string $hash hash link identifier |
||
| 835 | * @param string $name name for the link |
||
| 836 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 837 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 838 | */ |
||
| 839 | function locallink($hash, $name = null, $returnonly = false) { |
||
| 855 | |||
| 856 | /** |
||
| 857 | * Render an internal Wiki Link |
||
| 858 | * |
||
| 859 | * $search,$returnonly & $linktype are not for the renderer but are used |
||
| 860 | * elsewhere - no need to implement them in other renderers |
||
| 861 | * |
||
| 862 | * @author Andreas Gohr <[email protected]> |
||
| 863 | * @param string $id pageid |
||
| 864 | * @param string|null $name link name |
||
| 865 | * @param string|null $search adds search url param |
||
| 866 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 867 | * @param string $linktype type to set use of headings |
||
| 868 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 869 | */ |
||
| 870 | function internallink($id, $name = null, $search = null, $returnonly = false, $linktype = 'content') { |
||
| 952 | |||
| 953 | /** |
||
| 954 | * Render an external link |
||
| 955 | * |
||
| 956 | * @param string $url full URL with scheme |
||
| 957 | * @param string|array $name name for the link, array for media file |
||
| 958 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 959 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 960 | */ |
||
| 961 | function externallink($url, $name = null, $returnonly = false) { |
||
| 1012 | |||
| 1013 | /** |
||
| 1014 | * Render an interwiki link |
||
| 1015 | * |
||
| 1016 | * You may want to use $this->_resolveInterWiki() here |
||
| 1017 | * |
||
| 1018 | * @param string $match original link - probably not much use |
||
| 1019 | * @param string|array $name name for the link, array for media file |
||
| 1020 | * @param string $wikiName indentifier (shortcut) for the remote wiki |
||
| 1021 | * @param string $wikiUri the fragment parsed from the original link |
||
| 1022 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1023 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1024 | */ |
||
| 1025 | function interwikilink($match, $name = null, $wikiName, $wikiUri, $returnonly = false) { |
||
| 1071 | |||
| 1072 | /** |
||
| 1073 | * Link to windows share |
||
| 1074 | * |
||
| 1075 | * @param string $url the link |
||
| 1076 | * @param string|array $name name for the link, array for media file |
||
| 1077 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1078 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1079 | */ |
||
| 1080 | function windowssharelink($url, $name = null, $returnonly = false) { |
||
| 1109 | |||
| 1110 | /** |
||
| 1111 | * Render a linked E-Mail Address |
||
| 1112 | * |
||
| 1113 | * Honors $conf['mailguard'] setting |
||
| 1114 | * |
||
| 1115 | * @param string $address Email-Address |
||
| 1116 | * @param string|array $name name for the link, array for media file |
||
| 1117 | * @param bool $returnonly whether to return html or write to doc attribute |
||
| 1118 | * @return void|string writes to doc attribute or returns html depends on $returnonly |
||
| 1119 | */ |
||
| 1120 | function emaillink($address, $name = null, $returnonly = false) { |
||
| 1158 | |||
| 1159 | /** |
||
| 1160 | * Render an internal media file |
||
| 1161 | * |
||
| 1162 | * @param string $src media ID |
||
| 1163 | * @param string $title descriptive text |
||
| 1164 | * @param string $align left|center|right |
||
| 1165 | * @param int $width width of media in pixel |
||
| 1166 | * @param int $height height of media in pixel |
||
| 1167 | * @param string $cache cache|recache|nocache |
||
| 1168 | * @param string $linking linkonly|detail|nolink |
||
| 1169 | * @param bool $return return HTML instead of adding to $doc |
||
| 1170 | * @return void|string writes to doc attribute or returns html depends on $return |
||
| 1171 | */ |
||
| 1172 | function internalmedia($src, $title = null, $align = null, $width = null, |
||
| 1173 | $height = null, $cache = null, $linking = null, $return = false) { |
||
| 1174 | global $ID; |
||
| 1175 | if (strpos($src, '#') !== false) { |
||
| 1176 | list($src, $hash) = explode('#', $src, 2); |
||
| 1177 | } |
||
| 1178 | resolve_mediaid(getNS($ID), $src, $exists, $this->date_at, true); |
||
| 1179 | |||
| 1180 | $noLink = false; |
||
| 1181 | $render = ($linking == 'linkonly') ? false : true; |
||
| 1182 | $link = $this->_getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render); |
||
| 1183 | |||
| 1184 | list($ext, $mime) = mimetype($src, false); |
||
| 1185 | if(substr($mime, 0, 5) == 'image' && $render) { |
||
| 1186 | $link['url'] = ml( |
||
| 1187 | $src, |
||
| 1188 | array( |
||
| 1189 | 'id' => $ID, |
||
| 1190 | 'cache' => $cache, |
||
| 1191 | 'rev' => $this->_getLastMediaRevisionAt($src) |
||
| 1192 | ), |
||
| 1193 | ($linking == 'direct') |
||
| 1194 | ); |
||
| 1195 | } elseif(($mime == 'application/x-shockwave-flash' || media_supportedav($mime)) && $render) { |
||
| 1196 | // don't link movies |
||
| 1197 | $noLink = true; |
||
| 1198 | } else { |
||
| 1199 | // add file icons |
||
| 1200 | $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext); |
||
| 1201 | $link['class'] .= ' mediafile mf_'.$class; |
||
| 1202 | $link['url'] = ml( |
||
| 1203 | $src, |
||
| 1204 | array( |
||
| 1205 | 'id' => $ID, |
||
| 1206 | 'cache' => $cache, |
||
| 1207 | 'rev' => $this->_getLastMediaRevisionAt($src) |
||
| 1230 | |||
| 1231 | /** |
||
| 1232 | * Render an external media file |
||
| 1233 | * |
||
| 1234 | * @param string $src full media URL |
||
| 1235 | * @param string $title descriptive text |
||
| 1236 | * @param string $align left|center|right |
||
| 1237 | * @param int $width width of media in pixel |
||
| 1238 | * @param int $height height of media in pixel |
||
| 1239 | * @param string $cache cache|recache|nocache |
||
| 1240 | * @param string $linking linkonly|detail|nolink |
||
| 1241 | * @param bool $return return HTML instead of adding to $doc |
||
| 1242 | * @return void|string writes to doc attribute or returns html depends on $return |
||
| 1243 | */ |
||
| 1244 | function externalmedia($src, $title = null, $align = null, $width = null, |
||
| 1282 | |||
| 1283 | /** |
||
| 1284 | * Renders an RSS feed |
||
| 1285 | * |
||
| 1286 | * @param string $url URL of the feed |
||
| 1287 | * @param array $params Finetuning of the output |
||
| 1288 | * |
||
| 1289 | * @author Andreas Gohr <[email protected]> |
||
| 1290 | */ |
||
| 1291 | function rss($url, $params) { |
||
| 1374 | |||
| 1375 | /** |
||
| 1376 | * Start a table |
||
| 1377 | * |
||
| 1378 | * @param int $maxcols maximum number of columns |
||
| 1379 | * @param int $numrows NOT IMPLEMENTED |
||
| 1380 | * @param int $pos byte position in the original source |
||
| 1381 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1382 | */ |
||
| 1383 | function table_open($maxcols = null, $numrows = null, $pos = null, $classes = null) { |
||
| 1402 | |||
| 1403 | /** |
||
| 1404 | * Close a table |
||
| 1405 | * |
||
| 1406 | * @param int $pos byte position in the original source |
||
| 1407 | */ |
||
| 1408 | function table_close($pos = null) { |
||
| 1414 | |||
| 1415 | /** |
||
| 1416 | * Open a table header |
||
| 1417 | */ |
||
| 1418 | function tablethead_open() { |
||
| 1421 | |||
| 1422 | /** |
||
| 1423 | * Close a table header |
||
| 1424 | */ |
||
| 1425 | function tablethead_close() { |
||
| 1428 | |||
| 1429 | /** |
||
| 1430 | * Open a table body |
||
| 1431 | */ |
||
| 1432 | function tabletbody_open() { |
||
| 1435 | |||
| 1436 | /** |
||
| 1437 | * Close a table body |
||
| 1438 | */ |
||
| 1439 | function tabletbody_close() { |
||
| 1442 | |||
| 1443 | /** |
||
| 1444 | * Open a table footer |
||
| 1445 | */ |
||
| 1446 | function tabletfoot_open() { |
||
| 1449 | |||
| 1450 | /** |
||
| 1451 | * Close a table footer |
||
| 1452 | */ |
||
| 1453 | function tabletfoot_close() { |
||
| 1456 | |||
| 1457 | /** |
||
| 1458 | * Open a table row |
||
| 1459 | * |
||
| 1460 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1461 | */ |
||
| 1462 | function tablerow_open($classes = null) { |
||
| 1472 | |||
| 1473 | /** |
||
| 1474 | * Close a table row |
||
| 1475 | */ |
||
| 1476 | function tablerow_close() { |
||
| 1479 | |||
| 1480 | /** |
||
| 1481 | * Open a table header cell |
||
| 1482 | * |
||
| 1483 | * @param int $colspan |
||
| 1484 | * @param string $align left|center|right |
||
| 1485 | * @param int $rowspan |
||
| 1486 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1487 | */ |
||
| 1488 | function tableheader_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
| 1508 | |||
| 1509 | /** |
||
| 1510 | * Close a table header cell |
||
| 1511 | */ |
||
| 1512 | function tableheader_close() { |
||
| 1515 | |||
| 1516 | /** |
||
| 1517 | * Open a table cell |
||
| 1518 | * |
||
| 1519 | * @param int $colspan |
||
| 1520 | * @param string $align left|center|right |
||
| 1521 | * @param int $rowspan |
||
| 1522 | * @param string|string[] $classes css classes - have to be valid, do not pass unfiltered user input |
||
| 1523 | */ |
||
| 1524 | function tablecell_open($colspan = 1, $align = null, $rowspan = 1, $classes = null) { |
||
| 1544 | |||
| 1545 | /** |
||
| 1546 | * Close a table cell |
||
| 1547 | */ |
||
| 1548 | function tablecell_close() { |
||
| 1551 | |||
| 1552 | /** |
||
| 1553 | * Returns the current header level. |
||
| 1554 | * (required e.g. by the filelist plugin) |
||
| 1555 | * |
||
| 1556 | * @return int The current header level |
||
| 1557 | */ |
||
| 1558 | function getLastlevel() { |
||
| 1561 | |||
| 1562 | #region Utility functions |
||
| 1563 | |||
| 1564 | /** |
||
| 1565 | * Build a link |
||
| 1566 | * |
||
| 1567 | * Assembles all parts defined in $link returns HTML for the link |
||
| 1568 | * |
||
| 1569 | * @param array $link attributes of a link |
||
| 1570 | * @return string |
||
| 1571 | * |
||
| 1572 | * @author Andreas Gohr <[email protected]> |
||
| 1573 | */ |
||
| 1574 | function _formatLink($link) { |
||
| 1603 | |||
| 1604 | /** |
||
| 1605 | * Renders internal and external media |
||
| 1606 | * |
||
| 1607 | * @author Andreas Gohr <[email protected]> |
||
| 1608 | * @param string $src media ID |
||
| 1609 | * @param string $title descriptive text |
||
| 1610 | * @param string $align left|center|right |
||
| 1611 | * @param int $width width of media in pixel |
||
| 1612 | * @param int $height height of media in pixel |
||
| 1613 | * @param string $cache cache|recache|nocache |
||
| 1614 | * @param bool $render should the media be embedded inline or just linked |
||
| 1615 | * @return string |
||
| 1616 | */ |
||
| 1617 | function _media($src, $title = null, $align = null, $width = null, |
||
| 1727 | |||
| 1728 | /** |
||
| 1729 | * Escape string for output |
||
| 1730 | * |
||
| 1731 | * @param $string |
||
| 1732 | * @return string |
||
| 1733 | */ |
||
| 1734 | function _xmlEntities($string) { |
||
| 1737 | |||
| 1738 | /** |
||
| 1739 | * Creates a linkid from a headline |
||
| 1740 | * |
||
| 1741 | * @author Andreas Gohr <[email protected]> |
||
| 1742 | * @param string $title The headline title |
||
| 1743 | * @param boolean $create Create a new unique ID? |
||
| 1744 | * @return string |
||
| 1745 | */ |
||
| 1746 | function _headerToLink($title, $create = false) { |
||
| 1754 | |||
| 1755 | /** |
||
| 1756 | * Construct a title and handle images in titles |
||
| 1757 | * |
||
| 1758 | * @author Harry Fuecks <[email protected]> |
||
| 1759 | * @param string|array $title either string title or media array |
||
| 1760 | * @param string $default default title if nothing else is found |
||
| 1761 | * @param bool $isImage will be set to true if it's a media file |
||
| 1762 | * @param null|string $id linked page id (used to extract title from first heading) |
||
| 1763 | * @param string $linktype content|navigation |
||
| 1764 | * @return string HTML of the title, might be full image tag or just escaped text |
||
| 1765 | */ |
||
| 1766 | function _getLinkTitle($title, $default, &$isImage, $id = null, $linktype = 'content') { |
||
| 1783 | |||
| 1784 | /** |
||
| 1785 | * Returns HTML code for images used in link titles |
||
| 1786 | * |
||
| 1787 | * @author Andreas Gohr <[email protected]> |
||
| 1788 | * @param array $img |
||
| 1789 | * @return string HTML img tag or similar |
||
| 1790 | */ |
||
| 1791 | function _imageTitle($img) { |
||
| 1810 | |||
| 1811 | /** |
||
| 1812 | * helperfunction to return a basic link to a media |
||
| 1813 | * |
||
| 1814 | * used in internalmedia() and externalmedia() |
||
| 1815 | * |
||
| 1816 | * @author Pierre Spring <[email protected]> |
||
| 1817 | * @param string $src media ID |
||
| 1818 | * @param string $title descriptive text |
||
| 1819 | * @param string $align left|center|right |
||
| 1820 | * @param int $width width of media in pixel |
||
| 1821 | * @param int $height height of media in pixel |
||
| 1822 | * @param string $cache cache|recache|nocache |
||
| 1823 | * @param bool $render should the media be embedded inline or just linked |
||
| 1824 | * @return array associative array with link config |
||
| 1825 | */ |
||
| 1826 | function _getMediaLinkConf($src, $title, $align, $width, $height, $cache, $render) { |
||
| 1842 | |||
| 1843 | /** |
||
| 1844 | * Embed video(s) in HTML |
||
| 1845 | * |
||
| 1846 | * @author Anika Henke <[email protected]> |
||
| 1847 | * @author Schplurtz le Déboulonné <[email protected]> |
||
| 1848 | * |
||
| 1849 | * @param string $src - ID of video to embed |
||
| 1850 | * @param int $width - width of the video in pixels |
||
| 1851 | * @param int $height - height of the video in pixels |
||
| 1852 | * @param array $atts - additional attributes for the <video> tag |
||
| 1853 | * @return string |
||
| 1854 | */ |
||
| 1855 | function _video($src, $width, $height, $atts = null) { |
||
| 1928 | |||
| 1929 | /** |
||
| 1930 | * Embed audio in HTML |
||
| 1931 | * |
||
| 1932 | * @author Anika Henke <[email protected]> |
||
| 1933 | * |
||
| 1934 | * @param string $src - ID of audio to embed |
||
| 1935 | * @param array $atts - additional attributes for the <audio> tag |
||
| 1936 | * @return string |
||
| 1937 | */ |
||
| 1938 | function _audio($src, $atts = array()) { |
||
| 1987 | |||
| 1988 | /** |
||
| 1989 | * _getLastMediaRevisionAt is a helperfunction to internalmedia() and _media() |
||
| 1990 | * which returns an existing media revision less or equal to rev or date_at |
||
| 1991 | * |
||
| 1992 | * @author lisps |
||
| 1993 | * @param string $media_id |
||
| 1994 | * @access protected |
||
| 1995 | * @return string revision ('' for current) |
||
| 1996 | */ |
||
| 1997 | function _getLastMediaRevisionAt($media_id){ |
||
| 2002 | |||
| 2003 | #endregion |
||
| 2004 | } |
||
| 2005 | |||
| 2007 |
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.