* */ namespace ComboStrap\Tag; use ComboStrap\ExceptionCompile; use ComboStrap\Outline; use ComboStrap\PluginUtility; use ComboStrap\TagAttributes; /** * * Class TableUtility * @package ComboStrap * * @see DataTables (May be) * * See also: https://www.dokuwiki.org/tips:table_editing */ class TableTag { const TABLE_SNIPPET_ID = "table"; const BOOT_TABLE_CLASSES = 'table table-non-fluid table-hover table-striped'; const TAG = "table"; const TAG_CONTAINER = "table-container"; const TABLE_RESPONSIVE_CLASS = "table-responsive"; /** * @param \Doku_Renderer_xhtml $renderer * @param $class * @return void * The call is created during an outline scan at {@link Outline::buildOutline()} */ static function renderEnterXhtml(TagAttributes $tagAttributes, \Doku_Renderer_xhtml $renderer) { try { $position = $tagAttributes->getValueAsInteger(PluginUtility::POSITION); } catch (ExceptionCompile $e) { $position = null; } /** * We call table_open, to init the {@link \Doku_Renderer_xhtml::$_counter} number that is private otherwise, there * is a class name created with the name `row` that is a known bootstrap class */ $doc = $renderer->doc; $renderer->table_open(null, null, $position); $renderer->doc = $doc; // Add non-fluid to not have a table that takes 100% of the space // Otherwise we can't have floating element at the right and the visual space is too big PluginUtility::getSnippetManager()->attachCssInternalStyleSheet(self::TABLE_SNIPPET_ID); $renderer->doc .= TagAttributes::createEmpty(self::TAG_CONTAINER) ->addClassName(self::TABLE_RESPONSIVE_CLASS) ->toHtmlEnterTag("div"); $renderer->doc .= TagAttributes::createEmpty(self::TAG) ->addClassName("inline") // dokuwiki ->addClassName(self::BOOT_TABLE_CLASSES) ->toHtmlEnterTag("table"); } }