59a8097c38aeb1c6c4fc73625f9bb972bc9c0120
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / html / output / node / HtmlOutputNodeTable.class.php
1 <?php
2 namespace wcf\system\html\output\node;
3 use wcf\system\html\node\AbstractHtmlNodeProcessor;
4
5 /**
6 * Adds wrapper div for tables to allow content overflow with scrollbars.
7 *
8 * @author Alexander Ebert
9 * @copyright 2001-2018 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package WoltLabSuite\Core\System\Html\Output\Node
12 * @since 3.0
13 */
14 class HtmlOutputNodeTable extends AbstractHtmlOutputNode {
15 /**
16 * @inheritDoc
17 */
18 protected $tagName = 'table';
19
20 /**
21 * @inheritDoc
22 */
23 public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor) {
24 if ($this->outputType === 'text/html' || $this->outputType === 'text/simplified-html') {
25 /** @var \DOMElement $element */
26 foreach ($elements as $element) {
27 // check if table is not contained within another table
28 $parent = $element;
29 while ($parent = $parent->parentNode) {
30 if ($parent->nodeName === 'table') {
31 continue;
32 }
33 }
34
35 $div = $element->ownerDocument->createElement('div');
36 $div->setAttribute('class', 'messageTableOverflow');
37
38 $element->parentNode->insertBefore($div, $element);
39 $div->appendChild($element);
40 }
41 }
42 }
43 }