1<?php 2/** 3 * Plugin imagereference 4 * 5 * Syntax: <tabref linkname> - creates a table link to a table 6 * <tabcaption linkname <orientation> | Table caption> Table</tabcaption> 7 * 8 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 9 * @author Gerrit Uitslag <klapinklapin@gmail.com> 10 */ 11 12if(!defined('DOKU_INC')) die(); 13 14/** 15 * All DokuWiki plugins to extend the parser/rendering mechanism 16 * need to inherit from this class 17 */ 18class syntax_plugin_imagereference_tabcaption extends syntax_plugin_imagereference_imgcaption { 19 20 /** 21 * @return string Syntax type 22 */ 23 public function getType() { 24 return 'formatting'; 25 } 26 /** 27 * @return string Paragraph type 28 */ 29 public function getPType() { 30 return 'block'; 31 } 32 /** 33 * @return int Sort order 34 */ 35 public function getSort() { 36 return 196; 37 } 38 39 /** 40 * Specify modes allowed in the imgcaption/tabcaption 41 * Using getAllowedTypes() includes too much modes. 42 * 43 * @param string $mode Parser mode 44 * @return bool true if $mode is accepted 45 */ 46 public function accepts($mode) { 47 $allowedsinglemodes = array( 48 'table', //allowed content 49 'plugin_diagram_main' //plugins 50 ); 51 if(in_array($mode, $allowedsinglemodes)) return true; 52 53 return parent::accepts($mode); 54 } 55 56 /** 57 * Connect lookup pattern to lexer. 58 * 59 * @param string $mode Parser mode 60 */ 61 public function connectTo($mode) { 62 $this->Lexer->addEntryPattern('<tabcaption.*?>(?=.*?</tabcaption>)', $mode, 'plugin_imagereference_tabcaption'); 63 } 64 65 public function postConnect() { 66 $this->Lexer->addExitPattern('</tabcaption>', 'plugin_imagereference_tabcaption'); 67 } 68 69 /** 70 * @var string $captionStart opening tag of caption, image/table dependent 71 * @var string $captionEnd closing tag of caption, image/table dependent 72 */ 73 protected $captionStart = '<div id="%1$s" class="tabcaptionbox%3$s"><div class="tabcaption%2$s">'; 74 protected $captionEnd = '</div></div>'; 75} 76 77