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 * 81cbc1590aSGreg Roach * @return int 82a25f0a04SGreg Roach */ 83*8f53f488SRico Sonntag public function addText($t): int 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 return 0; 98a25f0a04SGreg Roach } 99a25f0a04SGreg Roach 100a25f0a04SGreg Roach /** 10176692c8bSGreg Roach * Set the width to wrap text. 10276692c8bSGreg Roach * 103a25f0a04SGreg Roach * @param $wrapwidth 104a25f0a04SGreg Roach * @param $cellwidth 105a25f0a04SGreg Roach * 106a25f0a04SGreg Roach * @return mixed 107a25f0a04SGreg Roach */ 108c1010edaSGreg Roach public function setWrapWidth($wrapwidth, $cellwidth) 109c1010edaSGreg Roach { 110a25f0a04SGreg Roach $this->wrapWidthCell = $cellwidth; 111a25f0a04SGreg Roach if (strpos($this->numText, "\n") !== false) { 112a25f0a04SGreg Roach $this->wrapWidthRemaining = $cellwidth; 113a25f0a04SGreg Roach } else { 114a25f0a04SGreg Roach $this->wrapWidthRemaining = $wrapwidth; 115a25f0a04SGreg Roach } 116a25f0a04SGreg Roach 117a25f0a04SGreg Roach return $this->wrapWidthRemaining; 118a25f0a04SGreg Roach } 119a25f0a04SGreg Roach 120a25f0a04SGreg Roach /** 12176692c8bSGreg Roach * Set the number. 12276692c8bSGreg Roach * 123a25f0a04SGreg Roach * @param $n 124a25f0a04SGreg Roach * 125cbc1590aSGreg Roach * @return int 126a25f0a04SGreg Roach */ 127*8f53f488SRico Sonntag public function setNum($n): int 128c1010edaSGreg Roach { 129a25f0a04SGreg Roach $this->num = $n; 130a25f0a04SGreg Roach $this->numText = "$n "; 131a25f0a04SGreg Roach 132a25f0a04SGreg Roach return 0; 133a25f0a04SGreg Roach } 134a25f0a04SGreg Roach 135a25f0a04SGreg Roach /** 13676692c8bSGreg Roach * Add a link. 13776692c8bSGreg Roach * 138a25f0a04SGreg Roach * @param $a 139a25f0a04SGreg Roach * 140cbc1590aSGreg Roach * @return int 141a25f0a04SGreg Roach */ 142*8f53f488SRico Sonntag public function setAddlink($a): int 143c1010edaSGreg Roach { 144a25f0a04SGreg Roach $this->addlink = $a; 145a25f0a04SGreg Roach 146a25f0a04SGreg Roach return 0; 147a25f0a04SGreg Roach } 148a25f0a04SGreg Roach} 149