summaryrefslogtreecommitdiff
path: root/app/Report
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-08-30 09:17:02 +0100
committerGreg Roach <fisharebest@webtrees.net>2018-08-30 09:17:12 +0100
commit83cdc021ef3cbd30c7b73b429e75d0d3c95ff416 (patch)
tree1353c1d9c8b2848c12cfc88bc807308d5bd68c97 /app/Report
parentc7ff415313b94d2d6d06ec673249f39fae9865e9 (diff)
downloadwebtrees-83cdc021ef3cbd30c7b73b429e75d0d3c95ff416.tar.gz
webtrees-83cdc021ef3cbd30c7b73b429e75d0d3c95ff416.tar.bz2
webtrees-83cdc021ef3cbd30c7b73b429e75d0d3c95ff416.zip
Report images - types and phpdoc
Diffstat (limited to 'app/Report')
-rw-r--r--app/Report/ReportBase.php2
-rw-r--r--app/Report/ReportBaseImage.php62
-rw-r--r--app/Report/ReportHtml.php34
-rw-r--r--app/Report/ReportHtmlImage.php6
-rw-r--r--app/Report/ReportParserGenerate.php103
-rw-r--r--app/Report/ReportParserSetup.php14
-rw-r--r--app/Report/ReportPdf.php22
-rw-r--r--app/Report/ReportPdfImage.php7
8 files changed, 97 insertions, 153 deletions
diff --git a/app/Report/ReportBase.php b/app/Report/ReportBase.php
index 9d56768c20..4288d12aff 100644
--- a/app/Report/ReportBase.php
+++ b/app/Report/ReportBase.php
@@ -96,6 +96,8 @@ class ReportBase
*
* Setting up document wide defaults that will be inherited of the report modules
* As DEFAULT A4 and Portrait will be used if not set
+ *
+ * @return void
*/
public function setup()
{
diff --git a/app/Report/ReportBaseImage.php b/app/Report/ReportBaseImage.php
index 04d6563a8c..52c05cea83 100644
--- a/app/Report/ReportBaseImage.php
+++ b/app/Report/ReportBaseImage.php
@@ -20,61 +20,39 @@ namespace Fisharebest\Webtrees\Report;
*/
class ReportBaseImage extends ReportBaseElement
{
- /**
- * Filename of the image
- *
- * @var string
- */
+ /** @var string Filename of the image */
public $file;
- /**
- * Height of the image
- *
- * @var float
- */
+
+ /** @var int Height of the image */
public $height;
- /**
- * Width of the image
- *
- * @var float
- */
+
+ /** @var int Width of the image */
public $width;
- /**
- * X-position (left) of the image
- *
- * @var float
- */
+
+ /** @var int X-position (left) of the image */
public $x;
- /**
- * Y-position (top) of the image
- *
- * @var float
- */
+
+ /** @var int Y-position (top) of the image */
public $y;
- /**
- * Placement fo the image. L: left, C:center, R:right
- *
- * @var string
- */
- public $align = '';
- /**
- * T:same line, N:next line
- *
- * @var string
- */
- public $line = '';
+
+ /** @var string Placement fo the image. L: left, C:center, R:right (or empty for x/y) */
+ public $align;
+
+ /** @var string T:same line, N:next line */
+ public $line;
/**
* Image class function - Base
*
* @param string $file Filename of the image
- * @param float $x X-position (left) of the image
- * @param float $y Y-position (top) of the image
- * @param float $w Width of the image
- * @param float $h Height of the image
+ * @param int $x X-position (left) of the image
+ * @param int $y Y-position (top) of the image
+ * @param int $w Width of the image
+ * @param int $h Height of the image
* @param string $align Placement of the image. L: left, C:center, R:right
* @param string $ln T:same line, N:next line
*/
- public function __construct($file, $x, $y, $w, $h, $align, $ln)
+ public function __construct(string $file, int $x, int $y, int $w, int $h, string $align, string $ln)
{
$this->file = $file;
$this->width = $w;
diff --git a/app/Report/ReportHtml.php b/app/Report/ReportHtml.php
index c4fe879268..8f46d314e2 100644
--- a/app/Report/ReportHtml.php
+++ b/app/Report/ReportHtml.php
@@ -133,6 +133,8 @@ class ReportHtml extends ReportBase
/**
* HTML Setup - ReportHtml
+ *
+ * @return void
*/
public function setup()
{
@@ -212,6 +214,8 @@ class ReportHtml extends ReportBase
/**
* Run the report.
+ *
+ * @return void
*/
public function run()
{
@@ -378,17 +382,17 @@ class ReportHtml extends ReportBase
/**
* Create an image.
*
- * @param $file
- * @param $x
- * @param $y
- * @param $w
- * @param $h
- * @param $align
- * @param $ln
+ * @param string $file
+ * @param float $x
+ * @param float $y
+ * @param float $w
+ * @param float $h
+ * @param string $align
+ * @param string $ln
*
* @return ReportHtmlImage
*/
- public function createImage($file, $x, $y, $w, $h, $align, $ln): ReportHtmlImage
+ public function createImage(string $file, float $x, float $y, float $w, float $h, string $align, string $ln): ReportHtmlImage
{
return new ReportHtmlImage($file, $x, $y, $w, $h, $align, $ln);
}
@@ -397,16 +401,16 @@ class ReportHtml extends ReportBase
* Create an image.
*
* @param MediaFile $media_file
- * @param $x
- * @param $y
- * @param $w
- * @param $h
- * @param $align
- * @param $ln
+ * @param int $x
+ * @param int $y
+ * @param int $w
+ * @param int $h
+ * @param string $align
+ * @param string $ln
*
* @return ReportHtmlImage
*/
- public function createImageFromObject(MediaFile $media_file, $x, $y, $w, $h, $align, $ln): ReportHtmlImage
+ public function createImageFromObject(MediaFile $media_file, int $x, int $y, int $w, int $h, string $align, string $ln): ReportHtmlImage
{
return new ReportHtmlImage($media_file->imageUrl($w, $h, ''), $x, $y, $w, $h, $align, $ln);
}
diff --git a/app/Report/ReportHtmlImage.php b/app/Report/ReportHtmlImage.php
index f633423e19..749a9b387c 100644
--- a/app/Report/ReportHtmlImage.php
+++ b/app/Report/ReportHtmlImage.php
@@ -32,10 +32,10 @@ class ReportHtmlImage extends ReportBaseImage
global $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright;
// Get the current positions
- if ($this->x == '.') {
+ if ($this->x === -1) {
$this->x = $renderer->getX();
}
- if ($this->y == '.') {
+ if ($this->y === -1) {
//-- first check for a collision with the last picture
if (isset($lastpicbottom)) {
if (($renderer->pageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->getY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright)) {
@@ -68,7 +68,7 @@ class ReportHtmlImage extends ReportBaseImage
$lastpicright = $this->x + $this->width;
$lastpicbottom = $this->y + $this->height;
// Setup for the next line
- if ($this->line == 'N') {
+ if ($this->line === 'N') {
$renderer->setY($lastpicbottom);
}
// Keep max Y updated
diff --git a/app/Report/ReportParserGenerate.php b/app/Report/ReportParserGenerate.php
index ea713c3e44..232c57a19b 100644
--- a/app/Report/ReportParserGenerate.php
+++ b/app/Report/ReportParserGenerate.php
@@ -1636,56 +1636,26 @@ class ReportParserGenerate extends ReportParserBase
*/
private function highlightedImageStartHandler($attrs)
{
- $id = '';
- $match = [];
+ $id = '';
if (preg_match('/0 @(.+)@/', $this->gedrec, $match)) {
$id = $match[1];
}
- // mixed Position the top corner of this box on the page. the default is the current position
- $top = '.';
- if (isset($attrs['top'])) {
- if ($attrs['top'] === '0') {
- $top = 0;
- } elseif ($attrs['top'] === '.') {
- $top = '.';
- } elseif (!empty($attrs['top'])) {
- $top = (int) $attrs['top'];
- }
- }
+ // Position the top corner of this box on the page. the default is the current position
+ $top = (int) ($attrs['top'] ?? -1);
// mixed Position the left corner of this box on the page. the default is the current position
- $left = '.';
- if (isset($attrs['left'])) {
- if ($attrs['left'] === '0') {
- $left = 0;
- } elseif ($attrs['left'] === '.') {
- $left = '.';
- } elseif (!empty($attrs['left'])) {
- $left = (int) $attrs['left'];
- }
- }
+ $left = (int) ($attrs['left'] ?? -1);
- // string Align the image in left, center, right
- $align = '';
- if (!empty($attrs['align'])) {
- $align = $attrs['align'];
- }
+ // string Align the image in left, center, right (or empty to use x/y position).
+ $align = $attrs['align'] ?? '';
// string Next Line should be T:next to the image, N:next line
- $ln = '';
- if (!empty($attrs['ln'])) {
- $ln = $attrs['ln'];
- }
+ $ln = $attrs['ln'] ?? 'T';
- $width = 0;
- $height = 0;
- if (!empty($attrs['width'])) {
- $width = (int) $attrs['width'];
- }
- if (!empty($attrs['height'])) {
- $height = (int) $attrs['height'];
- }
+ // Width, height (or both).
+ $width = (int) ($attrs['width'] ?? 0);
+ $height = (int) ($attrs['height'] ?? 0);
$person = Individual::getInstance($id, $this->tree);
$media_file = $person->findHighlightedMediaFile();
@@ -1719,55 +1689,24 @@ class ReportParserGenerate extends ReportParserBase
*/
private function imageStartHandler($attrs)
{
- // mixed Position the top corner of this box on the page. the default is the current position
- $top = '.';
- if (isset($attrs['top'])) {
- if ($attrs['top'] === '0') {
- $top = 0;
- } elseif ($attrs['top'] === '.') {
- $top = '.';
- } elseif (!empty($attrs['top'])) {
- $top = (int) $attrs['top'];
- }
- }
+ // Position the top corner of this box on the page. the default is the current position
+ $top = (int) ($attrs['top'] ?? -1);
// mixed Position the left corner of this box on the page. the default is the current position
- $left = '.';
- if (isset($attrs['left'])) {
- if ($attrs['left'] === '0') {
- $left = 0;
- } elseif ($attrs['left'] === '.') {
- $left = '.';
- } elseif (!empty($attrs['left'])) {
- $left = (int) $attrs['left'];
- }
- }
+ $left = (int) ($attrs['left'] ?? -1);
- // string Align the image in left, center, right
- $align = '';
- if (!empty($attrs['align'])) {
- $align = $attrs['align'];
- }
+ // string Align the image in left, center, right (or empty to use x/y position).
+ $align = $attrs['align'] ?? '';
// string Next Line should be T:next to the image, N:next line
- $ln = 'T';
- if (!empty($attrs['ln'])) {
- $ln = $attrs['ln'];
- }
+ $ln = $attrs['ln'] ?? 'T';
- $width = 0;
- $height = 0;
- if (!empty($attrs['width'])) {
- $width = (int) $attrs['width'];
- }
- if (!empty($attrs['height'])) {
- $height = (int) $attrs['height'];
- }
+ // Width, height (or both).
+ $width = (int) ($attrs['width'] ?? 0);
+ $height = (int) ($attrs['height'] ?? 0);
+
+ $file = $attrs['file'] ?? '';
- $file = '';
- if (!empty($attrs['file'])) {
- $file = $attrs['file'];
- }
if ($file == '@FILE') {
$match = [];
if (preg_match("/\d OBJE @(.+)@/", $this->gedrec, $match)) {
diff --git a/app/Report/ReportParserSetup.php b/app/Report/ReportParserSetup.php
index 415886af48..e0785d8475 100644
--- a/app/Report/ReportParserSetup.php
+++ b/app/Report/ReportParserSetup.php
@@ -43,6 +43,8 @@ class ReportParserSetup extends ReportParserBase
* Process <Report>
*
* @param string[] $attrs
+ *
+ * @return void
*/
protected function reportStartHandler($attrs)
{
@@ -65,6 +67,8 @@ class ReportParserSetup extends ReportParserBase
* Process <var var="">
*
* @param string[] $attrs
+ *
+ * @return void
*/
protected function varStartHandler($attrs)
{
@@ -81,6 +85,8 @@ class ReportParserSetup extends ReportParserBase
/**
* Process <Title>
+ *
+ * @return void
*/
protected function titleStartHandler()
{
@@ -89,6 +95,8 @@ class ReportParserSetup extends ReportParserBase
/**
* Process </Title>
+ *
+ * @return void
*/
protected function titleEndHandler()
{
@@ -98,6 +106,8 @@ class ReportParserSetup extends ReportParserBase
/**
* Process </Description>
+ *
+ * @return void
*/
protected function descriptionEndHandler()
{
@@ -109,6 +119,8 @@ class ReportParserSetup extends ReportParserBase
* Process <Input>
*
* @param string[] $attrs
+ *
+ * @return void
*/
protected function inputStartHandler($attrs)
{
@@ -142,6 +154,8 @@ class ReportParserSetup extends ReportParserBase
/**
* Process </Input>
+ *
+ * @return void
*/
protected function inputEndHandler()
{
diff --git a/app/Report/ReportPdf.php b/app/Report/ReportPdf.php
index 887c0fe294..25b145b82c 100644
--- a/app/Report/ReportPdf.php
+++ b/app/Report/ReportPdf.php
@@ -57,6 +57,8 @@ class ReportPdf extends ReportBase
/**
* PDF Setup - ReportPdf
+ *
+ * @return void
*/
public function setup()
{
@@ -126,6 +128,8 @@ class ReportPdf extends ReportBase
/**
* Run the report.
+ *
+ * @return void
*/
public function run()
{
@@ -143,6 +147,8 @@ class ReportPdf extends ReportBase
/**
* Clear the Page Header - ReportPdf
+ *
+ * @return void
*/
public function clearPageHeader()
{
@@ -236,16 +242,16 @@ class ReportPdf extends ReportBase
* Create a new image object - ReportPdf
*
* @param string $file Filename
- * @param mixed $x
- * @param mixed $y
- * @param int $w Image width
- * @param int $h Image height
+ * @param string $x
+ * @param string $y
+ * @param float $w Image width
+ * @param float $h Image height
* @param string $align L:left, C:center, R:right or empty to use x/y
* @param string $ln T:same line, N:next line
*
* @return ReportPdfImage
*/
- public function createImage($file, $x, $y, $w, $h, $align, $ln): ReportPdfImage
+ public function createImage(string $file, float $x, float $y, float $w, float $h, string $align, string $ln): ReportPdfImage
{
return new ReportPdfImage($file, $x, $y, $w, $h, $align, $ln);
}
@@ -254,8 +260,8 @@ class ReportPdf extends ReportBase
* Create a new image object from Media Object - ReportPdf
*
* @param MediaFile $media_file
- * @param mixed $x
- * @param mixed $y
+ * @param int $x
+ * @param int $y
* @param int $w Image width
* @param int $h Image height
* @param string $align L:left, C:center, R:right or empty to use x/y
@@ -263,7 +269,7 @@ class ReportPdf extends ReportBase
*
* @return ReportPdfImage
*/
- public function createImageFromObject(MediaFile $media_file, $x, $y, $w, $h, $align, $ln): ReportPdfImage
+ public function createImageFromObject(MediaFile $media_file, int $x, int $y, int $w, int $h, string $align, string $ln): ReportPdfImage
{
return new ReportPdfImage($media_file->getServerFilename(), $x, $y, $w, $h, $align, $ln);
}
diff --git a/app/Report/ReportPdfImage.php b/app/Report/ReportPdfImage.php
index 40db43a1b7..7aa078f354 100644
--- a/app/Report/ReportPdfImage.php
+++ b/app/Report/ReportPdfImage.php
@@ -37,15 +37,16 @@ class ReportPdfImage extends ReportBaseImage
}
$curx = $renderer->GetX();
- // If current position (left)set "."
- if ($this->x == '.') {
+
+ // Get the current positions
+ if ($this->x === -1) {
$this->x = $renderer->GetX();
} else {
// For static position add margin
$this->x = $renderer->addMarginX($this->x);
$renderer->SetX($curx);
}
- if ($this->y == '.') {
+ if ($this->y === -1) {
//-- first check for a collision with the last picture
if (isset($lastpicbottom)) {
if (($renderer->PageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->GetY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright)