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 */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 1876692c8bSGreg Roachnamespace Fisharebest\Webtrees\Report; 19a25f0a04SGreg Roach 20a25f0a04SGreg Roach/** 21a25f0a04SGreg Roach * Class ReportBaseElement 22a25f0a04SGreg Roach */ 23c1010edaSGreg Roachclass ReportBaseElement 24c1010edaSGreg Roach{ 25c21bdddcSGreg Roach // Special value for X or Y position, to indicate the current position. 262f3269d8SGreg Roach const CURRENT_POSITION = -1.0; 27c21bdddcSGreg Roach 2876692c8bSGreg Roach /** @var string Text */ 2976692c8bSGreg Roach public $text = ''; 30a25f0a04SGreg Roach 31a25f0a04SGreg Roach /** 32a25f0a04SGreg Roach * Element renderer 33a25f0a04SGreg Roach * 34729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 35c7ff4153SGreg Roach * 36c7ff4153SGreg Roach * @return void 37a25f0a04SGreg Roach */ 38c1010edaSGreg Roach public function render($renderer) 39c1010edaSGreg Roach { 40a25f0a04SGreg Roach //-- to be implemented in inherited classes 41a25f0a04SGreg Roach } 42a25f0a04SGreg Roach 43a25f0a04SGreg Roach /** 4476692c8bSGreg Roach * Get the height. 4576692c8bSGreg Roach * 46729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 47a25f0a04SGreg Roach * 48a25f0a04SGreg Roach * @return float 49a25f0a04SGreg Roach */ 508f53f488SRico Sonntag public function getHeight($renderer): float 51c1010edaSGreg Roach { 52a25f0a04SGreg Roach return 0.0; 53a25f0a04SGreg Roach } 54a25f0a04SGreg Roach 55a25f0a04SGreg Roach /** 5676692c8bSGreg Roach * Get the width. 5776692c8bSGreg Roach * 58729ce104SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 59a25f0a04SGreg Roach * 608ba2e626SGreg Roach * @return float|array 61a25f0a04SGreg Roach */ 628ba2e626SGreg Roach public function getWidth($renderer) 63c1010edaSGreg Roach { 64a25f0a04SGreg Roach return 0.0; 65a25f0a04SGreg Roach } 66a25f0a04SGreg Roach 67a25f0a04SGreg Roach /** 6876692c8bSGreg Roach * Add text. 6976692c8bSGreg Roach * 70a25f0a04SGreg Roach * @param string $t 71a25f0a04SGreg Roach * 726c1eebecSGreg Roach * @return void 73a25f0a04SGreg Roach */ 746c1eebecSGreg Roach public function addText(string $t) 75c1010edaSGreg Roach { 76a25f0a04SGreg Roach $t = trim($t, "\r\n\t"); 77c1010edaSGreg Roach $t = str_replace([ 78c1010edaSGreg Roach '<br>', 79c1010edaSGreg Roach ' ', 80c1010edaSGreg Roach ], [ 81c1010edaSGreg Roach "\n", 82c1010edaSGreg Roach ' ', 83c1010edaSGreg Roach ], $t); 84a25f0a04SGreg Roach $t = strip_tags($t); 85a25f0a04SGreg Roach $t = htmlspecialchars_decode($t); 86a25f0a04SGreg Roach $this->text .= $t; 87a25f0a04SGreg Roach } 88a25f0a04SGreg Roach 89a25f0a04SGreg Roach /** 9076692c8bSGreg Roach * Add an end-of-line. 9176692c8bSGreg Roach * 92589feda3SGreg Roach * @return void 93a25f0a04SGreg Roach */ 94589feda3SGreg Roach public function addNewline() 95c1010edaSGreg Roach { 96a25f0a04SGreg Roach $this->text .= "\n"; 97a25f0a04SGreg Roach } 98a25f0a04SGreg Roach 99a25f0a04SGreg Roach /** 10076692c8bSGreg Roach * Get the current text. 10176692c8bSGreg Roach * 102a25f0a04SGreg Roach * @return string 103a25f0a04SGreg Roach */ 1048f53f488SRico Sonntag public function getValue(): string 105c1010edaSGreg Roach { 106a25f0a04SGreg Roach return $this->text; 107a25f0a04SGreg Roach } 108a25f0a04SGreg Roach 109a25f0a04SGreg Roach /** 11076692c8bSGreg Roach * Set the width to wrap text. 11176692c8bSGreg Roach * 112c21bdddcSGreg Roach * @param float $wrapwidth 113c21bdddcSGreg Roach * @param float $cellwidth 114a25f0a04SGreg Roach * 115589feda3SGreg Roach * @return float 116a25f0a04SGreg Roach */ 117c21bdddcSGreg Roach public function setWrapWidth(float $wrapwidth, float $cellwidth): float 118c1010edaSGreg Roach { 119a25f0a04SGreg Roach return 0; 120a25f0a04SGreg Roach } 121a25f0a04SGreg Roach 122a25f0a04SGreg Roach /** 12376692c8bSGreg Roach * Render the footnotes. 12476692c8bSGreg Roach * 125*9ae7af99SGreg Roach * @param ReportHtml|ReportTcpdf $renderer 12618d7a90dSGreg Roach * 12718d7a90dSGreg Roach * @return void 128a25f0a04SGreg Roach */ 129c1010edaSGreg Roach public function renderFootnote($renderer) 130c1010edaSGreg Roach { 131a25f0a04SGreg Roach } 132a25f0a04SGreg Roach 133a25f0a04SGreg Roach /** 13476692c8bSGreg Roach * Set the text. 13576692c8bSGreg Roach * 136c21bdddcSGreg Roach * @param string $text 13718d7a90dSGreg Roach * 13818d7a90dSGreg Roach * @return void 139a25f0a04SGreg Roach */ 140c21bdddcSGreg Roach public function setText(string $text) 141c1010edaSGreg Roach { 142a25f0a04SGreg Roach $this->text = $text; 143a25f0a04SGreg Roach } 144a25f0a04SGreg Roach} 145