1*04fd306cSNickeau<?php 2*04fd306cSNickeau/** 3*04fd306cSNickeau * Copyright (c) 2020. ComboStrap, Inc. and its affiliates. All Rights Reserved. 4*04fd306cSNickeau * 5*04fd306cSNickeau * This source code is licensed under the GPL license found in the 6*04fd306cSNickeau * COPYING file in the root directory of this source tree. 7*04fd306cSNickeau * 8*04fd306cSNickeau * @license GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html) 9*04fd306cSNickeau * @author ComboStrap <support@combostrap.com> 10*04fd306cSNickeau * 11*04fd306cSNickeau */ 12*04fd306cSNickeau 13*04fd306cSNickeaunamespace ComboStrap\Tag; 14*04fd306cSNickeau 15*04fd306cSNickeauuse ComboStrap\ExceptionCompile; 16*04fd306cSNickeauuse ComboStrap\Outline; 17*04fd306cSNickeauuse ComboStrap\PluginUtility; 18*04fd306cSNickeauuse ComboStrap\TagAttributes; 19*04fd306cSNickeau 20*04fd306cSNickeau/** 21*04fd306cSNickeau * 22*04fd306cSNickeau * Class TableUtility 23*04fd306cSNickeau * @package ComboStrap 24*04fd306cSNickeau * 25*04fd306cSNickeau * @see <a href="https://datatables.net/examples/styling/bootstrap4">DataTables (May be)</a> 26*04fd306cSNickeau * 27*04fd306cSNickeau * See also: https://www.dokuwiki.org/tips:table_editing 28*04fd306cSNickeau */ 29*04fd306cSNickeauclass TableTag 30*04fd306cSNickeau{ 31*04fd306cSNickeau 32*04fd306cSNickeau const TABLE_SNIPPET_ID = "table"; 33*04fd306cSNickeau const BOOT_TABLE_CLASSES = 'table table-non-fluid table-hover table-striped'; 34*04fd306cSNickeau const TAG = "table"; 35*04fd306cSNickeau const TAG_CONTAINER = "table-container"; 36*04fd306cSNickeau const TABLE_RESPONSIVE_CLASS = "table-responsive"; 37*04fd306cSNickeau 38*04fd306cSNickeau 39*04fd306cSNickeau /** 40*04fd306cSNickeau * @param \Doku_Renderer_xhtml $renderer 41*04fd306cSNickeau * @param $class 42*04fd306cSNickeau * @return void 43*04fd306cSNickeau * The call is created during an outline scan at {@link Outline::buildOutline()} 44*04fd306cSNickeau */ 45*04fd306cSNickeau static function renderEnterXhtml(TagAttributes $tagAttributes, \Doku_Renderer_xhtml $renderer) 46*04fd306cSNickeau { 47*04fd306cSNickeau 48*04fd306cSNickeau 49*04fd306cSNickeau try { 50*04fd306cSNickeau $position = $tagAttributes->getValueAsInteger(PluginUtility::POSITION); 51*04fd306cSNickeau } catch (ExceptionCompile $e) { 52*04fd306cSNickeau $position = null; 53*04fd306cSNickeau } 54*04fd306cSNickeau 55*04fd306cSNickeau /** 56*04fd306cSNickeau * We call table_open, to init the {@link \Doku_Renderer_xhtml::$_counter} number that is private otherwise, there 57*04fd306cSNickeau * is a class name created with the name `row` that is a known bootstrap class 58*04fd306cSNickeau */ 59*04fd306cSNickeau $doc = $renderer->doc; 60*04fd306cSNickeau $renderer->table_open(null, null, $position); 61*04fd306cSNickeau $renderer->doc = $doc; 62*04fd306cSNickeau 63*04fd306cSNickeau 64*04fd306cSNickeau // Add non-fluid to not have a table that takes 100% of the space 65*04fd306cSNickeau // Otherwise we can't have floating element at the right and the visual space is too big 66*04fd306cSNickeau PluginUtility::getSnippetManager()->attachCssInternalStyleSheet(self::TABLE_SNIPPET_ID); 67*04fd306cSNickeau 68*04fd306cSNickeau $renderer->doc .= TagAttributes::createEmpty(self::TAG_CONTAINER) 69*04fd306cSNickeau ->addClassName(self::TABLE_RESPONSIVE_CLASS) 70*04fd306cSNickeau ->toHtmlEnterTag("div"); 71*04fd306cSNickeau $renderer->doc .= TagAttributes::createEmpty(self::TAG) 72*04fd306cSNickeau ->addClassName("inline") // dokuwiki 73*04fd306cSNickeau ->addClassName(self::BOOT_TABLE_CLASSES) 74*04fd306cSNickeau ->toHtmlEnterTag("table"); 75*04fd306cSNickeau 76*04fd306cSNickeau } 77*04fd306cSNickeau 78*04fd306cSNickeau} 79