1a25f0a04SGreg Roach<?php 2a25f0a04SGreg Roach/** 3a25f0a04SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 webtrees development team 5a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify 6a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by 7a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8a25f0a04SGreg Roach * (at your option) any later version. 9a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful, 10a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a25f0a04SGreg Roach * GNU General Public License for more details. 13a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License 14a25f0a04SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15a25f0a04SGreg Roach */ 16*e7f56f2aSGreg Roachdeclare(strict_types=1); 17*e7f56f2aSGreg Roach 1876692c8bSGreg Roachnamespace Fisharebest\Webtrees\Report; 19a25f0a04SGreg Roach 20a25f0a04SGreg Roach/** 21a25f0a04SGreg Roach * Class ReportBaseElement 22a25f0a04SGreg Roach */ 23c1010edaSGreg Roachclass ReportBaseElement 24c1010edaSGreg Roach{ 2576692c8bSGreg Roach /** @var string Text */ 2676692c8bSGreg Roach public $text = ''; 27a25f0a04SGreg Roach 28a25f0a04SGreg Roach /** 29a25f0a04SGreg Roach * Element renderer 30a25f0a04SGreg Roach * 31729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 32c7ff4153SGreg Roach * 33c7ff4153SGreg Roach * @return void 34a25f0a04SGreg Roach */ 35c1010edaSGreg Roach public function render($renderer) 36c1010edaSGreg Roach { 37a25f0a04SGreg Roach //-- to be implemented in inherited classes 38a25f0a04SGreg Roach } 39a25f0a04SGreg Roach 40a25f0a04SGreg Roach /** 4176692c8bSGreg Roach * Get the height. 4276692c8bSGreg Roach * 43729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 44a25f0a04SGreg Roach * 45a25f0a04SGreg Roach * @return float 46a25f0a04SGreg Roach */ 478f53f488SRico Sonntag public function getHeight($renderer): float 48c1010edaSGreg Roach { 49a25f0a04SGreg Roach return 0.0; 50a25f0a04SGreg Roach } 51a25f0a04SGreg Roach 52a25f0a04SGreg Roach /** 5376692c8bSGreg Roach * Get the width. 5476692c8bSGreg Roach * 55729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 56a25f0a04SGreg Roach * 578ba2e626SGreg Roach * @return float|array 58a25f0a04SGreg Roach */ 598ba2e626SGreg Roach public function getWidth($renderer) 60c1010edaSGreg Roach { 61a25f0a04SGreg Roach return 0.0; 62a25f0a04SGreg Roach } 63a25f0a04SGreg Roach 64a25f0a04SGreg Roach /** 6576692c8bSGreg Roach * Add text. 6676692c8bSGreg Roach * 67a25f0a04SGreg Roach * @param string $t 68a25f0a04SGreg Roach * 696c1eebecSGreg Roach * @return void 70a25f0a04SGreg Roach */ 716c1eebecSGreg Roach public function addText(string $t) 72c1010edaSGreg Roach { 73a25f0a04SGreg Roach $t = trim($t, "\r\n\t"); 74c1010edaSGreg Roach $t = str_replace([ 75c1010edaSGreg Roach '<br>', 76c1010edaSGreg Roach ' ', 77c1010edaSGreg Roach ], [ 78c1010edaSGreg Roach "\n", 79c1010edaSGreg Roach ' ', 80c1010edaSGreg Roach ], $t); 81a25f0a04SGreg Roach $t = strip_tags($t); 82a25f0a04SGreg Roach $t = htmlspecialchars_decode($t); 83a25f0a04SGreg Roach $this->text .= $t; 84a25f0a04SGreg Roach } 85a25f0a04SGreg Roach 86a25f0a04SGreg Roach /** 8776692c8bSGreg Roach * Add an end-of-line. 8876692c8bSGreg Roach * 89cbc1590aSGreg Roach * @return int 90a25f0a04SGreg Roach */ 918f53f488SRico Sonntag public function addNewline(): int 92c1010edaSGreg Roach { 93a25f0a04SGreg Roach $this->text .= "\n"; 94a25f0a04SGreg Roach 95a25f0a04SGreg Roach return 0; 96a25f0a04SGreg Roach } 97a25f0a04SGreg Roach 98a25f0a04SGreg Roach /** 9976692c8bSGreg Roach * Get the current text. 10076692c8bSGreg Roach * 101a25f0a04SGreg Roach * @return string 102a25f0a04SGreg Roach */ 1038f53f488SRico Sonntag public function getValue(): string 104c1010edaSGreg Roach { 105a25f0a04SGreg Roach return $this->text; 106a25f0a04SGreg Roach } 107a25f0a04SGreg Roach 108a25f0a04SGreg Roach /** 10976692c8bSGreg Roach * Set the width to wrap text. 11076692c8bSGreg Roach * 111a25f0a04SGreg Roach * @param $wrapwidth 112a25f0a04SGreg Roach * @param $cellwidth 113a25f0a04SGreg Roach * 114cbc1590aSGreg Roach * @return int 115a25f0a04SGreg Roach */ 1168f53f488SRico Sonntag public function setWrapWidth($wrapwidth, $cellwidth): int 117c1010edaSGreg Roach { 118a25f0a04SGreg Roach return 0; 119a25f0a04SGreg Roach } 120a25f0a04SGreg Roach 121a25f0a04SGreg Roach /** 12276692c8bSGreg Roach * Render the footnotes. 12376692c8bSGreg Roach * 124a25f0a04SGreg Roach * @param $renderer 12518d7a90dSGreg Roach * 12618d7a90dSGreg Roach * @return void 127a25f0a04SGreg Roach */ 128c1010edaSGreg Roach public function renderFootnote($renderer) 129c1010edaSGreg Roach { 130a25f0a04SGreg Roach } 131a25f0a04SGreg Roach 132a25f0a04SGreg Roach /** 13376692c8bSGreg Roach * Set the text. 13476692c8bSGreg Roach * 135a25f0a04SGreg Roach * @param $text 13618d7a90dSGreg Roach * 13718d7a90dSGreg Roach * @return void 138a25f0a04SGreg Roach */ 139c1010edaSGreg Roach public function setText($text) 140c1010edaSGreg Roach { 141a25f0a04SGreg Roach $this->text = $text; 142a25f0a04SGreg Roach } 143a25f0a04SGreg Roach} 144