xref: /webtrees/app/Report/ReportBaseElement.php (revision a25f0a04682c4c39c1947220c90af4118c713952)
1<?php
2namespace Webtrees;
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
32
33*
34*@param ReportHtml|PDF $renderer
35
36
37
38*
39*@return void
40	 */
41	function render($renderer) {
42		//-- to be implemented in inherited classes
43	}
44
45	/**
46	 * @param ReportHtml|PDF $renderer
47
48
49
50*
51*@return float
52	 */
53	function getHeight($renderer) {
54		return 0.0;
55	}
56
57	/**
58	 * @param ReportHtml|PDF $renderer
59
60
61
62*
63*@return float
64	 */
65	function getWidth($renderer) {
66		return 0.0;
67	}
68
69	/**
70	 * @param string $t
71	 *
72	 * @return integer
73	 */
74	function addText($t) {
75		global $wt_report, $reportTitle, $reportDescription;
76
77		$t = trim($t, "\r\n\t");
78		$t = str_replace(array("<br>", "&nbsp;"), array("\n", " "), $t);
79		$t = strip_tags($t);
80		$t = htmlspecialchars_decode($t);
81		$this->text .= $t;
82
83		// Adding the title and description to the Document Properties
84		if ($reportTitle) {
85			$wt_report->addTitle($t);
86		} elseif ($reportDescription) {
87			$wt_report->addDescription($t);
88		}
89
90		return 0;
91	}
92
93	/**
94	 * @return integer
95	 */
96	function addNewline() {
97		$this->text .= "\n";
98
99		return 0;
100	}
101
102	/**
103	 * @return string
104	 */
105	function getValue() {
106		return $this->text;
107	}
108
109	/**
110	 * @param $wrapwidth
111	 * @param $cellwidth
112	 *
113	 * @return integer
114	 */
115	function setWrapWidth($wrapwidth, $cellwidth) {
116		return 0;
117	}
118
119	/**
120	 * @param $renderer
121	 *
122	 * @return void
123	 */
124	function renderFootnote($renderer) {
125		// To be implemented in inherited classes
126	}
127
128	/**
129	 * @param $text
130	 *
131	 * @return void
132	 */
133	function setText($text) {
134		$this->text = $text;
135	}
136}
137