* @copyright (C) 2015-2020, Giuseppe Di Terlizzi */ class syntax_plugin_bootstyle_container extends syntax_plugin_bootswrapper_bootstrap { public $p_type = 'block'; public $pattern_start = '(?=[\w\W]*?)'; public $pattern_end = ''; public $tag_name = 'container'; public $tag_attributes = array( 'fluid' => array( 'type' => 'string', 'values' => array("0", "1", "2"), 'required' => false, 'default' => false ), ); public function connectTo($mode) { $this->Lexer->addEntryPattern($this->pattern_start, $mode, 'plugin_bootstyle_' . $this->getPluginComponent()); } public function postConnect() { $this->Lexer->addExitPattern($this->pattern_end, 'plugin_bootstyle_' . $this->getPluginComponent()); $this->Lexer->addPattern($this->header_pattern, 'plugin_bootstyle_' . $this->getPluginComponent()); } public function removeClass($class, $classes) { $containerIndex = array_search($class, $classes); if($containerIndex !== false) { unset($classes[$containerIndex]); } return $classes; } public function render($mode, Doku_Renderer $renderer, $data) { if (empty($data)) { return false; } if ($mode !== 'xhtml') { return false; } /** @var Doku_Renderer_xhtml $renderer */ $data["target"] = "container"; list($state, $match, $pos, $attributes) = $data; //print_r($data); if ($state == DOKU_LEXER_ENTER) { extract($attributes); $this->wrapInner = (isset($attributes['fluid']) ? $attributes['fluid'] == 2 : false); $html_attributes = $this->mergeCoreAttributes($attributes); if(isset($attributes["fluid"]) && $attributes["fluid"] > 0) { $html_attributes["class"][] = "container-fluid"; } else { $html_attributes["class"][] = "container"; } if(isset($html_attributes["fluid"])) { unset($html_attributes["fluid"]); } $html_attributes["class"][] = $renderer->startSectionEdit($pos, $data); $renderer->doc .= '
buildAttributes($html_attributes) . '>'; if($this->wrapInner) { $renderer->doc .= '
'; } return true; } if ($state == DOKU_LEXER_EXIT) { // TODO: only the first container gets the button at the correct spot. $renderer->finishSectionEdit($pos+strlen("")); if($this->wrapInner) { $renderer->doc .= '
'; } $renderer->doc .= '
'; return true; } return true; } }