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 ReportBaseFootnote 20a25f0a04SGreg Roach */ 21c1010edaSGreg Roachclass ReportBaseFootnote extends ReportBaseElement 22c1010edaSGreg Roach{ 23a25f0a04SGreg Roach /** 24a25f0a04SGreg Roach * The name of the style for this element 25a25f0a04SGreg Roach * 26a25f0a04SGreg Roach * @var string 27a25f0a04SGreg Roach */ 287a6ee1acSGreg Roach public $styleName = ''; 29a25f0a04SGreg Roach 30a25f0a04SGreg Roach /** 31a25f0a04SGreg Roach * Numbers for the links 32a25f0a04SGreg Roach * 33a25f0a04SGreg Roach * @var int 34a25f0a04SGreg Roach */ 35a25f0a04SGreg Roach public $num; 36a25f0a04SGreg Roach 37a25f0a04SGreg Roach /** 38a25f0a04SGreg Roach * The text that will be printed with the number 39a25f0a04SGreg Roach * 40a25f0a04SGreg Roach * @var string 41a25f0a04SGreg Roach */ 427a6ee1acSGreg Roach public $numText = ''; 43a25f0a04SGreg Roach 44a25f0a04SGreg Roach /** 45a25f0a04SGreg Roach * Remaining width of a cell 46a25f0a04SGreg Roach * 47a25f0a04SGreg Roach * @var float User unit (points) 48a25f0a04SGreg Roach */ 49a25f0a04SGreg Roach public $wrapWidthRemaining; 50a25f0a04SGreg Roach 51a25f0a04SGreg Roach /** 52a25f0a04SGreg Roach * Original width of a cell 53a25f0a04SGreg Roach * 54a25f0a04SGreg Roach * @var float User unit (points) 55a25f0a04SGreg Roach */ 56a25f0a04SGreg Roach public $wrapWidthCell; 57a25f0a04SGreg Roach 5876692c8bSGreg Roach /** @var string A link */ 59a25f0a04SGreg Roach public $addlink; 60a25f0a04SGreg Roach 61a25f0a04SGreg Roach /** 6276692c8bSGreg Roach * Createa an element. 6376692c8bSGreg Roach * 64a25f0a04SGreg Roach * @param string $style 65a25f0a04SGreg Roach */ 66c1010edaSGreg Roach public function __construct($style = '') 67c1010edaSGreg Roach { 687a6ee1acSGreg Roach $this->text = ''; 69a25f0a04SGreg Roach if (!empty($style)) { 70a25f0a04SGreg Roach $this->styleName = $style; 71a25f0a04SGreg Roach } else { 727a6ee1acSGreg Roach $this->styleName = 'footnote'; 73a25f0a04SGreg Roach } 74a25f0a04SGreg Roach } 75a25f0a04SGreg Roach 76a25f0a04SGreg Roach /** 7776692c8bSGreg Roach * Add text. 7876692c8bSGreg Roach * 79a25f0a04SGreg Roach * @param $t 80a25f0a04SGreg Roach * 81*6c1eebecSGreg Roach * @return void 82a25f0a04SGreg Roach */ 83*6c1eebecSGreg Roach public function addText(string $t) 84c1010edaSGreg Roach { 85a25f0a04SGreg Roach $t = trim($t, "\r\n\t"); 86c1010edaSGreg Roach $t = str_replace([ 87c1010edaSGreg Roach '<br>', 88c1010edaSGreg Roach ' ', 89c1010edaSGreg Roach ], [ 90c1010edaSGreg Roach "\n", 91c1010edaSGreg Roach ' ', 92c1010edaSGreg Roach ], $t); 93a25f0a04SGreg Roach $t = strip_tags($t); 94a25f0a04SGreg Roach $t = htmlspecialchars_decode($t); 95a25f0a04SGreg Roach $this->text .= $t; 96a25f0a04SGreg Roach } 97a25f0a04SGreg Roach 98a25f0a04SGreg Roach /** 9976692c8bSGreg Roach * Set the width to wrap text. 10076692c8bSGreg Roach * 101a25f0a04SGreg Roach * @param $wrapwidth 102a25f0a04SGreg Roach * @param $cellwidth 103a25f0a04SGreg Roach * 1048ba2e626SGreg Roach * @return int 105a25f0a04SGreg Roach */ 1068ba2e626SGreg Roach public function setWrapWidth($wrapwidth, $cellwidth): int 107c1010edaSGreg Roach { 108a25f0a04SGreg Roach $this->wrapWidthCell = $cellwidth; 109a25f0a04SGreg Roach if (strpos($this->numText, "\n") !== false) { 110a25f0a04SGreg Roach $this->wrapWidthRemaining = $cellwidth; 111a25f0a04SGreg Roach } else { 112a25f0a04SGreg Roach $this->wrapWidthRemaining = $wrapwidth; 113a25f0a04SGreg Roach } 114a25f0a04SGreg Roach 115a25f0a04SGreg Roach return $this->wrapWidthRemaining; 116a25f0a04SGreg Roach } 117a25f0a04SGreg Roach 118a25f0a04SGreg Roach /** 11976692c8bSGreg Roach * Set the number. 12076692c8bSGreg Roach * 121a25f0a04SGreg Roach * @param $n 122a25f0a04SGreg Roach * 123cbc1590aSGreg Roach * @return int 124a25f0a04SGreg Roach */ 1258f53f488SRico Sonntag public function setNum($n): int 126c1010edaSGreg Roach { 127a25f0a04SGreg Roach $this->num = $n; 128a25f0a04SGreg Roach $this->numText = "$n "; 129a25f0a04SGreg Roach 130a25f0a04SGreg Roach return 0; 131a25f0a04SGreg Roach } 132a25f0a04SGreg Roach 133a25f0a04SGreg Roach /** 13476692c8bSGreg Roach * Add a link. 13576692c8bSGreg Roach * 136a25f0a04SGreg Roach * @param $a 137a25f0a04SGreg Roach * 138cbc1590aSGreg Roach * @return int 139a25f0a04SGreg Roach */ 1408f53f488SRico Sonntag public function setAddlink($a): int 141c1010edaSGreg Roach { 142a25f0a04SGreg Roach $this->addlink = $a; 143a25f0a04SGreg Roach 144a25f0a04SGreg Roach return 0; 145a25f0a04SGreg Roach } 146a25f0a04SGreg Roach} 147