xref: /webtrees/app/Report/ReportBaseElement.php (revision 3d7a8a4ca809135634f38216b734b15acff479f7)
1<?php
2namespace Fisharebest\Webtrees\Report;
3
4/**
5 * webtrees: online genealogy
6 * Copyright (C) 2015 webtrees development team
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/**
20 * Class ReportBaseElement
21 */
22class ReportBaseElement {
23	/**
24	 * @var string
25	 */
26	public $text = "";
27
28	/**
29	 * Element renderer
30	 *
31	 * @param ReportHtml|ReportTcpdf $renderer
32	 */
33	public function render($renderer) {
34		//-- to be implemented in inherited classes
35	}
36
37	/**
38	 * @param ReportHtml|ReportTcpdf $renderer
39	 *
40	 * @return float
41	 */
42	public function getHeight($renderer) {
43		return 0.0;
44	}
45
46	/**
47	 * @param ReportHtml|ReportTcpdf $renderer
48	 *
49	 * @return float
50	 */
51	public function getWidth($renderer) {
52		return 0.0;
53	}
54
55	/**
56	 * @param string $t
57	 *
58	 * @return int
59	 */
60	public function addText($t) {
61		$t = trim($t, "\r\n\t");
62		$t = str_replace(array("<br>", "&nbsp;"), array("\n", " "), $t);
63		$t = strip_tags($t);
64		$t = htmlspecialchars_decode($t);
65		$this->text .= $t;
66
67		return 0;
68	}
69
70	/**
71	 * @return int
72	 */
73	public function addNewline() {
74		$this->text .= "\n";
75
76		return 0;
77	}
78
79	/**
80	 * @return string
81	 */
82	public function getValue() {
83		return $this->text;
84	}
85
86	/**
87	 * @param $wrapwidth
88	 * @param $cellwidth
89	 *
90	 * @return int
91	 */
92	public function setWrapWidth($wrapwidth, $cellwidth) {
93		return 0;
94	}
95
96	/**
97	 * @param $renderer
98	 */
99	public function renderFootnote($renderer) {
100		// To be implemented in inherited classes
101	}
102
103	/**
104	 * @param $text
105	 */
106	public function setText($text) {
107		$this->text = $text;
108	}
109}
110