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 */ 1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Report; 17a25f0a04SGreg Roach 18a25f0a04SGreg Roach/** 19a25f0a04SGreg Roach * Class ReportBaseElement 20a25f0a04SGreg Roach */ 21c1010edaSGreg Roachclass ReportBaseElement 22c1010edaSGreg Roach{ 2376692c8bSGreg Roach /** @var string Text */ 2476692c8bSGreg Roach public $text = ''; 25a25f0a04SGreg Roach 26a25f0a04SGreg Roach /** 27a25f0a04SGreg Roach * Element renderer 28a25f0a04SGreg Roach * 29729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 30a25f0a04SGreg Roach */ 31c1010edaSGreg Roach public function render($renderer) 32c1010edaSGreg Roach { 33a25f0a04SGreg Roach //-- to be implemented in inherited classes 34a25f0a04SGreg Roach } 35a25f0a04SGreg Roach 36a25f0a04SGreg Roach /** 3776692c8bSGreg Roach * Get the height. 3876692c8bSGreg Roach * 39729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 40a25f0a04SGreg Roach * 41a25f0a04SGreg Roach * @return float 42a25f0a04SGreg Roach */ 438f53f488SRico Sonntag public function getHeight($renderer): float 44c1010edaSGreg Roach { 45a25f0a04SGreg Roach return 0.0; 46a25f0a04SGreg Roach } 47a25f0a04SGreg Roach 48a25f0a04SGreg Roach /** 4976692c8bSGreg Roach * Get the width. 5076692c8bSGreg Roach * 51729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 52a25f0a04SGreg Roach * 53*8ba2e626SGreg Roach * @return float|array 54a25f0a04SGreg Roach */ 55*8ba2e626SGreg Roach public function getWidth($renderer) 56c1010edaSGreg Roach { 57a25f0a04SGreg Roach return 0.0; 58a25f0a04SGreg Roach } 59a25f0a04SGreg Roach 60a25f0a04SGreg Roach /** 6176692c8bSGreg Roach * Add text. 6276692c8bSGreg Roach * 63a25f0a04SGreg Roach * @param string $t 64a25f0a04SGreg Roach * 65cbc1590aSGreg Roach * @return int 66a25f0a04SGreg Roach */ 678f53f488SRico Sonntag public function addText($t): int 68c1010edaSGreg Roach { 69a25f0a04SGreg Roach $t = trim($t, "\r\n\t"); 70c1010edaSGreg Roach $t = str_replace([ 71c1010edaSGreg Roach '<br>', 72c1010edaSGreg Roach ' ', 73c1010edaSGreg Roach ], [ 74c1010edaSGreg Roach "\n", 75c1010edaSGreg Roach ' ', 76c1010edaSGreg Roach ], $t); 77a25f0a04SGreg Roach $t = strip_tags($t); 78a25f0a04SGreg Roach $t = htmlspecialchars_decode($t); 79a25f0a04SGreg Roach $this->text .= $t; 80a25f0a04SGreg Roach 81a25f0a04SGreg Roach return 0; 82a25f0a04SGreg Roach } 83a25f0a04SGreg Roach 84a25f0a04SGreg Roach /** 8576692c8bSGreg Roach * Add an end-of-line. 8676692c8bSGreg Roach * 87cbc1590aSGreg Roach * @return int 88a25f0a04SGreg Roach */ 898f53f488SRico Sonntag public function addNewline(): int 90c1010edaSGreg Roach { 91a25f0a04SGreg Roach $this->text .= "\n"; 92a25f0a04SGreg Roach 93a25f0a04SGreg Roach return 0; 94a25f0a04SGreg Roach } 95a25f0a04SGreg Roach 96a25f0a04SGreg Roach /** 9776692c8bSGreg Roach * Get the current text. 9876692c8bSGreg Roach * 99a25f0a04SGreg Roach * @return string 100a25f0a04SGreg Roach */ 1018f53f488SRico Sonntag public function getValue(): string 102c1010edaSGreg Roach { 103a25f0a04SGreg Roach return $this->text; 104a25f0a04SGreg Roach } 105a25f0a04SGreg Roach 106a25f0a04SGreg Roach /** 10776692c8bSGreg Roach * Set the width to wrap text. 10876692c8bSGreg Roach * 109a25f0a04SGreg Roach * @param $wrapwidth 110a25f0a04SGreg Roach * @param $cellwidth 111a25f0a04SGreg Roach * 112cbc1590aSGreg Roach * @return int 113a25f0a04SGreg Roach */ 1148f53f488SRico Sonntag public function setWrapWidth($wrapwidth, $cellwidth): int 115c1010edaSGreg Roach { 116a25f0a04SGreg Roach return 0; 117a25f0a04SGreg Roach } 118a25f0a04SGreg Roach 119a25f0a04SGreg Roach /** 12076692c8bSGreg Roach * Render the footnotes. 12176692c8bSGreg Roach * 122a25f0a04SGreg Roach * @param $renderer 123a25f0a04SGreg Roach */ 124c1010edaSGreg Roach public function renderFootnote($renderer) 125c1010edaSGreg Roach { 126a25f0a04SGreg Roach } 127a25f0a04SGreg Roach 128a25f0a04SGreg Roach /** 12976692c8bSGreg Roach * Set the text. 13076692c8bSGreg Roach * 131a25f0a04SGreg Roach * @param $text 132a25f0a04SGreg Roach */ 133c1010edaSGreg Roach public function setText($text) 134c1010edaSGreg Roach { 135a25f0a04SGreg Roach $this->text = $text; 136a25f0a04SGreg Roach } 137a25f0a04SGreg Roach} 138