1<?php 2/** 3 * Copyright (c) 2020. ComboStrap, Inc. and its affiliates. All Rights Reserved. 4 * 5 * This source code is licensed under the GPL license found in the 6 * COPYING file in the root directory of this source tree. 7 * 8 * @license GPL 3 (https://www.gnu.org/licenses/gpl-3.0.en.html) 9 * @author ComboStrap <support@combostrap.com> 10 * 11 */ 12 13namespace ComboStrap; 14 15/** 16 * 17 * Class TableUtility 18 * @package ComboStrap 19 * 20 * @see <a href="https://datatables.net/examples/styling/bootstrap4">DataTables (May be)</a> 21 * 22 */ 23class TableUtility 24{ 25 26 const TABLE_SNIPPET_ID = "table"; 27 28 static function tableOpen($renderer, $pos) 29 { 30 31 $class = 'table'; 32 if ($pos !== null) { 33 $sectionEditStartData = ['target' => 'table']; 34 if (!defined('SEC_EDIT_PATTERN')) { 35 // backwards-compatibility for Frusterick Manners (2017-02-19) 36 $sectionEditStartData = 'table'; 37 } 38 $class .= ' ' . $renderer->startSectionEdit($pos, $sectionEditStartData); 39 } 40 // table-responsive and 41 $bootResponsiveClass = 'table-responsive'; 42 43 // Add non-fluid to not have a table that takes 100% of the space 44 // Otherwise we can't have floating element at the right and the visual space is to big 45 PluginUtility::getSnippetManager()->attachCssSnippetForRequest(self::TABLE_SNIPPET_ID); 46 47 $bootTableClass = 'table table-non-fluid table-hover table-striped'; 48 49 $renderer->doc .= '<div class="' . $class . ' ' . $bootResponsiveClass . '"><table class="inline ' . $bootTableClass . '">' . DOKU_LF; 50 } 51 52} 53