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