xref: /webtrees/app/Report/ReportBaseFootnote.php (revision 1062a1429914c995339f502856821457aa975a5a)
1a25f0a04SGreg Roach<?php
2a25f0a04SGreg Roach/**
3a25f0a04SGreg Roach * webtrees: online genealogy
4*1062a142SGreg 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 */
21a25f0a04SGreg Roachclass ReportBaseFootnote extends ReportBaseElement {
22a25f0a04SGreg Roach	/**
23a25f0a04SGreg Roach	 * The name of the style for this element
24a25f0a04SGreg Roach	 *
25a25f0a04SGreg Roach	 * @var string
26a25f0a04SGreg Roach	 */
277a6ee1acSGreg Roach	public $styleName = '';
28a25f0a04SGreg Roach
29a25f0a04SGreg Roach	/**
30a25f0a04SGreg Roach	 * Numbers for the links
31a25f0a04SGreg Roach	 *
32a25f0a04SGreg Roach	 * @var int
33a25f0a04SGreg Roach	 */
34a25f0a04SGreg Roach	public $num;
35a25f0a04SGreg Roach
36a25f0a04SGreg Roach	/**
37a25f0a04SGreg Roach	 * The text that will be printed with the number
38a25f0a04SGreg Roach	 *
39a25f0a04SGreg Roach	 * @var string
40a25f0a04SGreg Roach	 */
417a6ee1acSGreg Roach	public $numText = '';
42a25f0a04SGreg Roach
43a25f0a04SGreg Roach	/**
44a25f0a04SGreg Roach	 * Remaining width of a cell
45a25f0a04SGreg Roach	 *
46a25f0a04SGreg Roach	 * @var float User unit (points)
47a25f0a04SGreg Roach	 */
48a25f0a04SGreg Roach	public $wrapWidthRemaining;
49a25f0a04SGreg Roach
50a25f0a04SGreg Roach	/**
51a25f0a04SGreg Roach	 * Original width of a cell
52a25f0a04SGreg Roach	 *
53a25f0a04SGreg Roach	 * @var float User unit (points)
54a25f0a04SGreg Roach	 */
55a25f0a04SGreg Roach	public $wrapWidthCell;
56a25f0a04SGreg Roach
5776692c8bSGreg Roach	/** @var string A link */
58a25f0a04SGreg Roach	public $addlink;
59a25f0a04SGreg Roach
60a25f0a04SGreg Roach	/**
6176692c8bSGreg Roach	 * Createa an element.
6276692c8bSGreg Roach	 *
63a25f0a04SGreg Roach	 * @param string $style
64a25f0a04SGreg Roach	 */
657a6ee1acSGreg Roach	public function __construct($style = '') {
667a6ee1acSGreg Roach		$this->text = '';
67a25f0a04SGreg Roach		if (!empty($style)) {
68a25f0a04SGreg Roach			$this->styleName = $style;
69a25f0a04SGreg Roach		} else {
707a6ee1acSGreg Roach			$this->styleName = 'footnote';
71a25f0a04SGreg Roach		}
72a25f0a04SGreg Roach	}
73a25f0a04SGreg Roach
74a25f0a04SGreg Roach	/**
7576692c8bSGreg Roach	 * Add text.
7676692c8bSGreg Roach	 *
77a25f0a04SGreg Roach	 * @param $t
78a25f0a04SGreg Roach	 *
79cbc1590aSGreg Roach	 * @return int
80a25f0a04SGreg Roach	 */
81ffd703eaSGreg Roach	public function addText($t) {
82a25f0a04SGreg Roach		$t = trim($t, "\r\n\t");
837a6ee1acSGreg Roach		$t = str_replace(['<br>', '&nbsp;'], ["\n", ' '], $t);
84a25f0a04SGreg Roach		$t = strip_tags($t);
85a25f0a04SGreg Roach		$t = htmlspecialchars_decode($t);
86a25f0a04SGreg Roach		$this->text .= $t;
87a25f0a04SGreg Roach
88a25f0a04SGreg Roach		return 0;
89a25f0a04SGreg Roach	}
90a25f0a04SGreg Roach
91a25f0a04SGreg Roach	/**
9276692c8bSGreg Roach	 * Set the width to wrap text.
9376692c8bSGreg Roach	 *
94a25f0a04SGreg Roach	 * @param $wrapwidth
95a25f0a04SGreg Roach	 * @param $cellwidth
96a25f0a04SGreg Roach	 *
97a25f0a04SGreg Roach	 * @return mixed
98a25f0a04SGreg Roach	 */
99ffd703eaSGreg Roach	public function setWrapWidth($wrapwidth, $cellwidth) {
100a25f0a04SGreg Roach		$this->wrapWidthCell = $cellwidth;
101a25f0a04SGreg Roach		if (strpos($this->numText, "\n") !== false) {
102a25f0a04SGreg Roach			$this->wrapWidthRemaining = $cellwidth;
103a25f0a04SGreg Roach		} else {
104a25f0a04SGreg Roach			$this->wrapWidthRemaining = $wrapwidth;
105a25f0a04SGreg Roach		}
106a25f0a04SGreg Roach
107a25f0a04SGreg Roach		return $this->wrapWidthRemaining;
108a25f0a04SGreg Roach	}
109a25f0a04SGreg Roach
110a25f0a04SGreg Roach	/**
11176692c8bSGreg Roach	 * Set the number.
11276692c8bSGreg Roach	 *
113a25f0a04SGreg Roach	 * @param $n
114a25f0a04SGreg Roach	 *
115cbc1590aSGreg Roach	 * @return int
116a25f0a04SGreg Roach	 */
117ffd703eaSGreg Roach	public function setNum($n) {
118a25f0a04SGreg Roach		$this->num     = $n;
119a25f0a04SGreg Roach		$this->numText = "$n ";
120a25f0a04SGreg Roach
121a25f0a04SGreg Roach		return 0;
122a25f0a04SGreg Roach	}
123a25f0a04SGreg Roach
124a25f0a04SGreg Roach	/**
12576692c8bSGreg Roach	 * Add a link.
12676692c8bSGreg Roach	 *
127a25f0a04SGreg Roach	 * @param $a
128a25f0a04SGreg Roach	 *
129cbc1590aSGreg Roach	 * @return int
130a25f0a04SGreg Roach	 */
131ffd703eaSGreg Roach	public function setAddlink($a) {
132a25f0a04SGreg Roach		$this->addlink = $a;
133a25f0a04SGreg Roach
134a25f0a04SGreg Roach		return 0;
135a25f0a04SGreg Roach	}
136a25f0a04SGreg Roach}
137