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 ReportHtmlImage 21 */ 22class ReportHtmlImage extends ReportBaseImage { 23 /** 24 * Image renderer 25 * 26 * @param ReportHtml $renderer 27 */ 28 public function render($renderer) { 29 global $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright; 30 31 // Get the current positions 32 if ($this->x == ".") { 33 $this->x = $renderer->getX(); 34 } 35 if ($this->y == ".") { 36 //-- first check for a collision with the last picture 37 if (isset($lastpicbottom)) { 38 if (($renderer->pageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->getY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright)) { 39 $renderer->setY($lastpicbottom + ($renderer->cPadding * 2)); 40 } 41 } 42 $this->y = $renderer->getY(); 43 } 44 45 // Image alignment 46 switch ($this->align) { 47 case "L": 48 echo "<div style=\"position:absolute;top:", $this->y, "pt;left:0pt;width:", $renderer->getRemainingWidth(), "pt;text-align:left;\">\n"; 49 echo "<img src=\"", $this->file, "\" style=\"width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n</div>\n"; 50 break; 51 case "C": 52 echo "<div style=\"position:absolute;top:", $this->y, "pt;left:0pt;width:", $renderer->getRemainingWidth(), "pt;text-align:center;\">\n"; 53 echo "<img src=\"", $this->file, "\" style=\"width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n</div>\n"; 54 break; 55 case "R": 56 echo "<div style=\"position:absolute;top:", $this->y, "pt;left:0pt;width:", $renderer->getRemainingWidth(), "pt;text-align:right;\">\n"; 57 echo "<img src=\"", $this->file, "\" style=\"width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n</div>\n"; 58 break; 59 default: 60 echo "<img src=\"", $this->file, "\" style=\"position:absolute;", $renderer->alignRTL, ":", $this->x, "pt;top:", $this->y, "pt;width:", $this->width, "pt;height:", $this->height, "pt;\" alt=\"\">\n"; 61 } 62 63 $lastpicpage = $renderer->pageNo(); 64 $lastpicleft = $this->x; 65 $lastpicright = $this->x + $this->width; 66 $lastpicbottom = $this->y + $this->height; 67 // Setup for the next line 68 if ($this->line == "N") { 69 $renderer->setY($lastpicbottom); 70 } 71 // Keep max Y updated 72 $renderer->addMaxY($lastpicbottom); 73 } 74 75 /** 76 * Get the image height 77 * This would be called from the TextBox only for multiple images 78 * so we add a bit bottom space between the images 79 * 80 * @param ReportHtml $html 81 * 82 * @return float 83 */ 84 public function getHeight($html) { 85 return $this->height + ($html->cPadding * 2); 86 } 87 88} 89