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