1<?php 2/** 3 * DokuWiki Syntax Plugin Combostrap. 4 * 5 */ 6 7use ComboStrap\PluginUtility; 8 9if (!defined('DOKU_INC')) { 10 die(); 11} 12 13require_once(__DIR__ . '/../class/PluginUtility.php'); 14 15/** 16 * 17 * The name of the class must follow a pattern (don't change it) 18 * ie: 19 * syntax_plugin_PluginName_ComponentName 20 * @deprecated for {@link syntax_plugin_combo_tabs} in version 1.12 21 */ 22class syntax_plugin_combo_tabpanels extends DokuWiki_Syntax_Plugin 23{ 24 25 const TAG = 'tabpanels'; 26 27 28 /** 29 * Syntax Type. 30 * 31 * Needs to return one of the mode types defined in $PARSER_MODES in parser.php 32 * @see DokuWiki_Syntax_Plugin::getType() 33 */ 34 function getType() 35 { 36 return 'container'; 37 } 38 39 /** 40 * @return array 41 * Allow which kind of plugin inside 42 * All 43 */ 44 public function getAllowedTypes() 45 { 46 return array('container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs'); 47 } 48 49 public function accepts($mode) 50 { 51 return syntax_plugin_combo_preformatted::disablePreformatted($mode); 52 } 53 54 55 /** 56 * How Dokuwiki will add P element 57 * 58 * * 'normal' - The plugin can be used inside paragraphs 59 * * 'block' - Open paragraphs need to be closed before plugin output - block should not be inside paragraphs 60 * * 'stack' - Special case. Plugin wraps other paragraphs. - Stacks can contain paragraphs 61 * 62 * @see DokuWiki_Syntax_Plugin::getPType() 63 */ 64 function getPType() 65 { 66 return 'stack'; 67 } 68 69 /** 70 * @see Doku_Parser_Mode::getSort() 71 * 72 * the mode with the lowest sort number will win out 73 * the container (parent) must then have a lower number than the child 74 */ 75 function getSort() 76 { 77 return 100; 78 } 79 80 /** 81 * Create a pattern that will called this plugin 82 * 83 * @param string $mode 84 * @see Doku_Parser_Mode::connectTo() 85 */ 86 function connectTo($mode) 87 { 88 89 $pattern = PluginUtility::getContainerTagPattern(self::TAG); 90 $this->Lexer->addEntryPattern($pattern, $mode, PluginUtility::getModeFromTag($this->getPluginComponent())); 91 92 } 93 94 public function postConnect() 95 { 96 97 $this->Lexer->addExitPattern('</' . self::TAG . '>', PluginUtility::getModeFromTag($this->getPluginComponent())); 98 99 } 100 101 /** 102 * 103 * The handle function goal is to parse the matched syntax through the pattern function 104 * and to return the result for use in the renderer 105 * This result is always cached until the page is modified. 106 * @param string $match 107 * @param int $state 108 * @param int $pos 109 * @param Doku_Handler $handler 110 * @return array|bool 111 * @see DokuWiki_Syntax_Plugin::handle() 112 * 113 */ 114 function handle($match, $state, $pos, Doku_Handler $handler) 115 { 116 117 switch ($state) { 118 119 case DOKU_LEXER_ENTER: 120 121 $tagAttributes = PluginUtility::getTagAttributes($match); 122 123 return array( 124 PluginUtility::STATE => $state, 125 PluginUtility::ATTRIBUTES => $tagAttributes 126 ); 127 128 case DOKU_LEXER_UNMATCHED: 129 130 // We should never get there but yeah ... 131 return PluginUtility::handleAndReturnUnmatchedData(self::TAG,$match,$handler); 132 133 134 case DOKU_LEXER_EXIT : 135 136 return array( 137 PluginUtility::STATE => $state 138 ); 139 140 141 } 142 143 return array(); 144 145 } 146 147 /** 148 * Render the output 149 * @param string $format 150 * @param Doku_Renderer $renderer 151 * @param array $data - what the function handle() return'ed 152 * @return boolean - rendered correctly? (however, returned value is not used at the moment) 153 * @see DokuWiki_Syntax_Plugin::render() 154 * 155 * 156 */ 157 function render($format, Doku_Renderer $renderer, $data) 158 { 159 160 if ($format == 'xhtml') { 161 162 /** @var Doku_Renderer_xhtml $renderer */ 163 $state = $data[PluginUtility::STATE]; 164 $attributes = array(); 165 switch ($state) { 166 167 case DOKU_LEXER_ENTER : 168 $renderer->doc .= syntax_plugin_combo_tabs::openTabPanelsElement($attributes); 169 break; 170 case DOKU_LEXER_EXIT : 171 $renderer->doc .= syntax_plugin_combo_tabs::closeTabPanelsElement($attributes); 172 break; 173 case DOKU_LEXER_UNMATCHED: 174 $renderer->doc .= PluginUtility::renderUnmatched($data); 175 break; 176 } 177 return true; 178 } 179 return false; 180 } 181 182 183} 184