1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2018 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16namespace Fisharebest\Webtrees\Report; 17 18/** 19 * Class ReportBaseFootnote 20 */ 21class ReportBaseFootnote extends ReportBaseElement { 22 /** 23 * The name of the style for this element 24 * 25 * @var string 26 */ 27 public $styleName = ''; 28 29 /** 30 * Numbers for the links 31 * 32 * @var int 33 */ 34 public $num; 35 36 /** 37 * The text that will be printed with the number 38 * 39 * @var string 40 */ 41 public $numText = ''; 42 43 /** 44 * Remaining width of a cell 45 * 46 * @var float User unit (points) 47 */ 48 public $wrapWidthRemaining; 49 50 /** 51 * Original width of a cell 52 * 53 * @var float User unit (points) 54 */ 55 public $wrapWidthCell; 56 57 /** @var string A link */ 58 public $addlink; 59 60 /** 61 * Createa an element. 62 * 63 * @param string $style 64 */ 65 public function __construct($style = '') { 66 $this->text = ''; 67 if (!empty($style)) { 68 $this->styleName = $style; 69 } else { 70 $this->styleName = 'footnote'; 71 } 72 } 73 74 /** 75 * Add text. 76 * 77 * @param $t 78 * 79 * @return int 80 */ 81 public function addText($t) { 82 $t = trim($t, "\r\n\t"); 83 $t = str_replace(['<br>', ' '], ["\n", ' '], $t); 84 $t = strip_tags($t); 85 $t = htmlspecialchars_decode($t); 86 $this->text .= $t; 87 88 return 0; 89 } 90 91 /** 92 * Set the width to wrap text. 93 * 94 * @param $wrapwidth 95 * @param $cellwidth 96 * 97 * @return mixed 98 */ 99 public function setWrapWidth($wrapwidth, $cellwidth) { 100 $this->wrapWidthCell = $cellwidth; 101 if (strpos($this->numText, "\n") !== false) { 102 $this->wrapWidthRemaining = $cellwidth; 103 } else { 104 $this->wrapWidthRemaining = $wrapwidth; 105 } 106 107 return $this->wrapWidthRemaining; 108 } 109 110 /** 111 * Set the number. 112 * 113 * @param $n 114 * 115 * @return int 116 */ 117 public function setNum($n) { 118 $this->num = $n; 119 $this->numText = "$n "; 120 121 return 0; 122 } 123 124 /** 125 * Add a link. 126 * 127 * @param $a 128 * 129 * @return int 130 */ 131 public function setAddlink($a) { 132 $this->addlink = $a; 133 134 return 0; 135 } 136} 137