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