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