xref: /webtrees/app/Report/ReportBaseElement.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 ReportBaseElement
20a25f0a04SGreg Roach */
21a25f0a04SGreg Roachclass ReportBaseElement {
2276692c8bSGreg Roach	/** @var string Text*/
2376692c8bSGreg Roach	public $text = '';
24a25f0a04SGreg Roach
25a25f0a04SGreg Roach	/**
26a25f0a04SGreg Roach	 * Element renderer
27a25f0a04SGreg Roach	 *
28729ce104SGreg Roach	 * @param ReportHtml|ReportTcpdf $renderer
29a25f0a04SGreg Roach	 */
30ffd703eaSGreg Roach	public function render($renderer) {
31a25f0a04SGreg Roach		//-- to be implemented in inherited classes
32a25f0a04SGreg Roach	}
33a25f0a04SGreg Roach
34a25f0a04SGreg Roach	/**
3576692c8bSGreg Roach	 * Get the height.
3676692c8bSGreg Roach	 *
37729ce104SGreg Roach	 * @param ReportHtml|ReportTcpdf $renderer
38a25f0a04SGreg Roach	 *
39a25f0a04SGreg Roach	 * @return float
40a25f0a04SGreg Roach	 */
41ffd703eaSGreg Roach	public function getHeight($renderer) {
42a25f0a04SGreg Roach		return 0.0;
43a25f0a04SGreg Roach	}
44a25f0a04SGreg Roach
45a25f0a04SGreg Roach	/**
4676692c8bSGreg Roach	 * Get the width.
4776692c8bSGreg Roach	 *
48729ce104SGreg Roach	 * @param ReportHtml|ReportTcpdf $renderer
49a25f0a04SGreg Roach	 *
50a25f0a04SGreg Roach	 * @return float
51a25f0a04SGreg Roach	 */
52ffd703eaSGreg Roach	public function getWidth($renderer) {
53a25f0a04SGreg Roach		return 0.0;
54a25f0a04SGreg Roach	}
55a25f0a04SGreg Roach
56a25f0a04SGreg Roach	/**
5776692c8bSGreg Roach	 * Add text.
5876692c8bSGreg Roach	 *
59a25f0a04SGreg Roach	 * @param string $t
60a25f0a04SGreg Roach	 *
61cbc1590aSGreg Roach	 * @return int
62a25f0a04SGreg Roach	 */
63ffd703eaSGreg Roach	public function addText($t) {
64a25f0a04SGreg Roach		$t = trim($t, "\r\n\t");
657a6ee1acSGreg Roach		$t = str_replace(['<br>', '&nbsp;'], ["\n", ' '], $t);
66a25f0a04SGreg Roach		$t = strip_tags($t);
67a25f0a04SGreg Roach		$t = htmlspecialchars_decode($t);
68a25f0a04SGreg Roach		$this->text .= $t;
69a25f0a04SGreg Roach
70a25f0a04SGreg Roach		return 0;
71a25f0a04SGreg Roach	}
72a25f0a04SGreg Roach
73a25f0a04SGreg Roach	/**
7476692c8bSGreg Roach	 * Add an end-of-line.
7576692c8bSGreg Roach	 *
76cbc1590aSGreg Roach	 * @return int
77a25f0a04SGreg Roach	 */
78ffd703eaSGreg Roach	public function addNewline() {
79a25f0a04SGreg Roach		$this->text .= "\n";
80a25f0a04SGreg Roach
81a25f0a04SGreg Roach		return 0;
82a25f0a04SGreg Roach	}
83a25f0a04SGreg Roach
84a25f0a04SGreg Roach	/**
8576692c8bSGreg Roach	 * Get the current text.
8676692c8bSGreg Roach	 *
87a25f0a04SGreg Roach	 * @return string
88a25f0a04SGreg Roach	 */
89ffd703eaSGreg Roach	public function getValue() {
90a25f0a04SGreg Roach		return $this->text;
91a25f0a04SGreg Roach	}
92a25f0a04SGreg Roach
93a25f0a04SGreg Roach	/**
9476692c8bSGreg Roach	 * Set the width to wrap text.
9576692c8bSGreg Roach	 *
96a25f0a04SGreg Roach	 * @param $wrapwidth
97a25f0a04SGreg Roach	 * @param $cellwidth
98a25f0a04SGreg Roach	 *
99cbc1590aSGreg Roach	 * @return int
100a25f0a04SGreg Roach	 */
101ffd703eaSGreg Roach	public function setWrapWidth($wrapwidth, $cellwidth) {
102a25f0a04SGreg Roach		return 0;
103a25f0a04SGreg Roach	}
104a25f0a04SGreg Roach
105a25f0a04SGreg Roach	/**
10676692c8bSGreg Roach	 * Render the footnotes.
10776692c8bSGreg Roach	 *
108a25f0a04SGreg Roach	 * @param $renderer
109a25f0a04SGreg Roach	 */
110ffd703eaSGreg Roach	public function renderFootnote($renderer) {
111a25f0a04SGreg Roach	}
112a25f0a04SGreg Roach
113a25f0a04SGreg Roach	/**
11476692c8bSGreg Roach	 * Set the text.
11576692c8bSGreg Roach	 *
116a25f0a04SGreg Roach	 * @param $text
117a25f0a04SGreg Roach	 */
118ffd703eaSGreg Roach	public function setText($text) {
119a25f0a04SGreg Roach		$this->text = $text;
120a25f0a04SGreg Roach	}
121a25f0a04SGreg Roach}
122