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 30*c7ff4153SGreg Roach * 31*c7ff4153SGreg Roach * @return void 32a25f0a04SGreg Roach */ 33c1010edaSGreg Roach public function render($renderer) 34c1010edaSGreg Roach { 35a25f0a04SGreg Roach //-- to be implemented in inherited classes 36a25f0a04SGreg Roach } 37a25f0a04SGreg Roach 38a25f0a04SGreg Roach /** 3976692c8bSGreg Roach * Get the height. 4076692c8bSGreg Roach * 41729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 42a25f0a04SGreg Roach * 43a25f0a04SGreg Roach * @return float 44a25f0a04SGreg Roach */ 458f53f488SRico Sonntag public function getHeight($renderer): float 46c1010edaSGreg Roach { 47a25f0a04SGreg Roach return 0.0; 48a25f0a04SGreg Roach } 49a25f0a04SGreg Roach 50a25f0a04SGreg Roach /** 5176692c8bSGreg Roach * Get the width. 5276692c8bSGreg Roach * 53729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 54a25f0a04SGreg Roach * 558ba2e626SGreg Roach * @return float|array 56a25f0a04SGreg Roach */ 578ba2e626SGreg Roach public function getWidth($renderer) 58c1010edaSGreg Roach { 59a25f0a04SGreg Roach return 0.0; 60a25f0a04SGreg Roach } 61a25f0a04SGreg Roach 62a25f0a04SGreg Roach /** 6376692c8bSGreg Roach * Add text. 6476692c8bSGreg Roach * 65a25f0a04SGreg Roach * @param string $t 66a25f0a04SGreg Roach * 67cbc1590aSGreg Roach * @return int 68a25f0a04SGreg Roach */ 698f53f488SRico Sonntag public function addText($t): int 70c1010edaSGreg Roach { 71a25f0a04SGreg Roach $t = trim($t, "\r\n\t"); 72c1010edaSGreg Roach $t = str_replace([ 73c1010edaSGreg Roach '<br>', 74c1010edaSGreg Roach ' ', 75c1010edaSGreg Roach ], [ 76c1010edaSGreg Roach "\n", 77c1010edaSGreg Roach ' ', 78c1010edaSGreg Roach ], $t); 79a25f0a04SGreg Roach $t = strip_tags($t); 80a25f0a04SGreg Roach $t = htmlspecialchars_decode($t); 81a25f0a04SGreg Roach $this->text .= $t; 82a25f0a04SGreg Roach 83a25f0a04SGreg Roach return 0; 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 125a25f0a04SGreg Roach */ 126c1010edaSGreg Roach public function renderFootnote($renderer) 127c1010edaSGreg Roach { 128a25f0a04SGreg Roach } 129a25f0a04SGreg Roach 130a25f0a04SGreg Roach /** 13176692c8bSGreg Roach * Set the text. 13276692c8bSGreg Roach * 133a25f0a04SGreg Roach * @param $text 134a25f0a04SGreg Roach */ 135c1010edaSGreg Roach public function setText($text) 136c1010edaSGreg Roach { 137a25f0a04SGreg Roach $this->text = $text; 138a25f0a04SGreg Roach } 139a25f0a04SGreg Roach} 140