Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report additions #4945

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c4d12a0
Report facilities expanded
Jan 22, 2024
db2a1a8
Motivation and description of changes, not to be included in a release
Jan 22, 2024
6fb35fa
Updated standard Reports
Jan 22, 2024
b082d4a
Guide to the xml language used to create reports
Jan 22, 2024
afd414d
Changed to standard indentation.
Jan 26, 2024
38af847
Test line removed, should not have been there
Jan 26, 2024
6f198e5
Changed to use more common server info
Jan 27, 2024
4ff2d64
Fixed non-standard indentation
Jan 27, 2024
764697b
Tried more corrections
Jan 27, 2024
0420fc2
More adjustments
Jan 27, 2024
9bbf3bc
Now all tests are OK!
Jan 27, 2024
8e98b94
Once more
Jan 27, 2024
2ead5e2
Gorrected indent again
Jan 27, 2024
922fa45
The original expressions have worked "forever" but the static analysi…
Jan 28, 2024
c2bc34c
Trying to declare $rep as array of int
Jan 28, 2024
933c825
Reverted declaration attempt
Jan 28, 2024
90be709
Merge branch 'fisharebest:main' into sevtor
sevtor Jan 28, 2024
76a911b
Merge branch 'fisharebest:main' into sevtor
sevtor Jan 28, 2024
e4786c9
Trying to satisffy phpstan
Jan 29, 2024
fe7a64a
Merge branch 'sevtor' of https://github.com/sevtor/webtrees into sevtor
Jan 29, 2024
ba5e23b
Previous mistake
Jan 29, 2024
f3224c0
More phpstan effects
Jan 29, 2024
66f9339
Once again
Jan 29, 2024
184e27f
And again ...
Jan 29, 2024
71f9433
and again
Jan 29, 2024
b8ce38b
and again
Jan 29, 2024
54c4aab
...
Jan 29, 2024
cb26595
typo
Jan 29, 2024
ecb6473
impossible error
Jan 29, 2024
6692673
Changes to place bottomdiv better and preventing footerdiv and bottom…
Jan 30, 2024
4560d41
Removed ugly test
Jan 30, 2024
bd0b7fe
Revert "Removed ugly test"
Jan 31, 2024
0de7896
Restored th ugly test with a better comment
Jan 31, 2024
ac9b2ee
Update phpstan-baseline.php
sevtor Jan 31, 2024
ca63714
Updeted ignore pattern to current version of ReportParserGenerate.php
Jan 31, 2024
c085b62
Changed layout inside style=.. string; removed old comment
Feb 1, 2024
a691c16
The report 'missing facts' will now contain links to the persons and…
Feb 1, 2024
5fa0229
New nice report on missing facts
Feb 3, 2024
ab3891f
Further updates to handle pretty urls
Feb 6, 2024
6c48d1d
Generate translation files ...php for custom modules from ...mo or ..…
Feb 8, 2024
1aed39f
Changed one string to be translated in the reports
Feb 8, 2024
ce7e609
Translations must be added very early.
Feb 11, 2024
9ada638
Revert change of ModuleCustomTrait.php
Feb 13, 2024
d61435c
Moved the _SP_DEAT tag to Reports, only used there
Feb 15, 2024
6feb9bd
Changed to not use lcfirst() for German language ('de').
Feb 15, 2024
42b74bb
Minor changes for pdf reports: header on first page, table-like outpu…
Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Gedcom.php
Expand Up @@ -594,8 +594,8 @@
'INDI:BARM:DATE' => new DateValue(I18N::translate('Date of bar mitzvah')),
'INDI:BARM:PLAC' => new PlaceName(I18N::translate('Place of bar mitzvah')),
'INDI:BASM' => new BasMitzvah(I18N::translate('Bat mitzvah')),
'INDI:BASM:DATE' => new DateValue(I18N::translate('Date of bat mitzvah')),
'INDI:BASM:PLAC' => new PlaceName(I18N::translate('Place of bat mitzvah')),
'INDI:BASM:DATE' => new BasMitzvah(I18N::translate('Date of bat mitzvah')),
'INDI:BASM:PLAC' => new DateValue(I18N::translate('Place of bat mitzvah')),

Check warning on line 598 in app/Gedcom.php

View check run for this annotation

Codecov / codecov/patch

app/Gedcom.php#L597-L598

Added lines #L597 - L598 were not covered by tests
'INDI:BIRT' => new Birth(I18N::translate('Birth')),
'INDI:BIRT:DATE' => new DateValue(I18N::translate('Date of birth')),
'INDI:BIRT:FAMC' => new XrefFamily(I18N::translate('Birth parents')),
Expand Down
21 changes: 14 additions & 7 deletions app/Report/HtmlRenderer.php
Expand Up @@ -169,7 +169,7 @@ public function run(): void
//-- header divider
echo '</style>', PHP_EOL;
echo '<div id="headermargin" style="position: relative; top: auto; height: ', $this->header_margin, 'pt; width: ', $this->noMarginWidth, 'pt;"></div>';
echo '<div id="headerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;">';
echo '<div id="headerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;margin-bottom:10pt;text-align:center;">';
foreach ($this->headerElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
Expand All @@ -196,9 +196,8 @@ public function run(): void
}
//-- footer
echo '</div>';
echo '<script>document.getElementById("bodydiv").style.height="', $this->maxY, 'pt";</script>';
echo '<div id="bottommargin" style="position: relative; top: auto; height: ', $this->bottom_margin - $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
echo '<div id="footerdiv" style="position: relative; top: auto; width: ', $this->noMarginWidth, 'pt;height:auto;">';
echo '<div id="bottommargin" style="position: relative; z-index: -1; top: ' . $this->Y . 'pt; height: ', $this->bottom_margin - $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
echo '<div id="footerdiv" style="position: relative; top: ' . $this->Y . 'pt; width: ', $this->noMarginWidth, 'pt;height:auto;">';
$this->Y = 0;
$this->X = 0;
$this->maxY = 0;
Expand All @@ -212,8 +211,12 @@ public function run(): void
}
}
echo '</div>';
echo '<script>document.getElementById("footerdiv").style.height="', $this->maxY, 'pt";</script>';
echo '<div id="footermargin" style="position: relative; top: auto; height: ', $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
if ($this->show_generated_by) {
echo '<script>document.getElementsByClassName("genby")[0].style.height="15pt";';
echo 'document.getElementsByClassName("date")[0].style.top="15pt";';
echo '</script>';
}
echo '<div id="footermargin" style="position: relative; z-index: -1; top: auto; height: ', $this->footer_margin, 'pt;width:', $this->noMarginWidth, 'pt;"></div>';
}

/**
Expand Down Expand Up @@ -524,7 +527,9 @@ public function getStringWidth(string $text): float
{
$style = $this->getStyle($this->currentStyle);

return mb_strlen($text) * $style['size'] / 2;
// &#x..; is counted as 6 chars, not one. Many such chars will force too early line breaks
$txt2 = str_replace(['&#xA0;', '&#x2570;', '&nbsp;', '&mdash;'], ["#", "#", "#", "#"], $text);
return mb_strlen($txt2) * ($style['size'] / 2);
}

/**
Expand Down Expand Up @@ -715,10 +720,12 @@ public function write(string $text, string $color = '', bool $useclass = true):
"\n",
'> ',
' <',
"\xA0",
], [
'<br>',
'>&nbsp;',
'&nbsp;<',
'&nbsp;',
], $htmlcode);
echo $htmlcode;
}
Expand Down
5 changes: 3 additions & 2 deletions app/Report/PdfRenderer.php
Expand Up @@ -74,6 +74,7 @@
*/
public function header(): void
{
$this->tcpdf->AddPage();

Check warning on line 77 in app/Report/PdfRenderer.php

View check run for this annotation

Codecov / codecov/patch

app/Report/PdfRenderer.php#L77

Added line #L77 was not covered by tests
foreach ($this->headerElements as $element) {
if ($element instanceof ReportBaseElement) {
$element->render($this);
Expand Down Expand Up @@ -363,8 +364,8 @@
'UTF-8',
self::DISK_CACHE
);

$this->tcpdf->setMargins($this->left_margin, $this->top_margin, $this->right_margin);
$this->tcpdf->setPrintFooter(true);
$this->tcpdf->setMargins($this->left_margin, 55.5 /*$this->top_margin*/, $this->right_margin); // header-height?
$this->tcpdf->setHeaderMargin($this->header_margin);
$this->tcpdf->setFooterMargin($this->footer_margin);
$this->tcpdf->setAutoPageBreak(true, $this->bottom_margin);
Expand Down
Binary file added app/Report/Report-update.pdf
Binary file not shown.
6 changes: 5 additions & 1 deletion app/Report/ReportHtmlText.php
Expand Up @@ -97,7 +97,11 @@ public function render($renderer, bool $attrib = true): void
*/
public function getHeight($renderer): float
{
$ct = substr_count($this->text, "\n");
$txt2 = $this->text;
if (substr($txt2, -1) == "\n") {
$txt2 = substr($txt2, 0, -1);
}
$ct = substr_count($txt2, "\n");
if ($ct > 0) {
$ct += 1;
}
Expand Down
62 changes: 47 additions & 15 deletions app/Report/ReportHtmlTextbox.php
Expand Up @@ -40,9 +40,10 @@
*/
public function render($renderer): void
{
static $lastBoxYfinal;
// checkFootnote
$newelements = [];
$lastelement = [];
$lastelement = null;
$footnote_element = [];
// Element counter
$cE = count($this->elements);
Expand All @@ -58,22 +59,23 @@
}
$footnote_element = [];
}
if (empty($lastelement)) {
if (!isset($lastelement)) {
$lastelement = $element;
} elseif ($element->getStyleName() === $lastelement->getStyleName()) {
// Checking if the Text has the same style
} elseif (($element instanceof ReportBaseText && $lastelement instanceof ReportBaseText) && ($element->getStyleName() === $lastelement->getStyleName())) {
$lastelement->addText(str_replace("\n", '<br>', $element->getValue()));
} else {
$newelements[] = $lastelement;
$lastelement = $element;
}
} elseif ($element instanceof ReportHtmlImage) {
$lastelement = $element;

Check warning on line 71 in app/Report/ReportHtmlTextbox.php

View check run for this annotation

Codecov / codecov/patch

app/Report/ReportHtmlTextbox.php#L71

Added line #L71 was not covered by tests
} elseif ($element instanceof ReportHtmlFootnote) {
// Check if the Footnote has been set with it’s link number
$renderer->checkFootnote($element);
// Save first the last element if any
if (!empty($lastelement)) {
if (isset($lastelement)) {
$newelements[] = $lastelement;
$lastelement = [];
$lastelement = null;
}
// Save the Footnote with it’s link number as key for sorting later
$footnote_element[$element->num] = $element;
Expand All @@ -86,16 +88,16 @@
}
$footnote_element = [];
}
if (!empty($lastelement)) {
if (isset($lastelement)) {

Check warning on line 91 in app/Report/ReportHtmlTextbox.php

View check run for this annotation

Codecov / codecov/patch

app/Report/ReportHtmlTextbox.php#L91

Added line #L91 was not covered by tests
$newelements[] = $lastelement;
$lastelement = [];
$lastelement = null;

Check warning on line 93 in app/Report/ReportHtmlTextbox.php

View check run for this annotation

Codecov / codecov/patch

app/Report/ReportHtmlTextbox.php#L93

Added line #L93 was not covered by tests
}
$newelements[] = $element;
}
} else {
if (!empty($lastelement)) {
if (isset($lastelement)) {
$newelements[] = $lastelement;
$lastelement = [];
$lastelement = null;
}
if (!empty($footnote_element)) {
ksort($footnote_element);
Expand All @@ -107,7 +109,7 @@
$newelements[] = $element;
}
}
if (!empty($lastelement)) {
if (isset($lastelement)) {
$newelements[] = $lastelement;
}
if (!empty($footnote_element)) {
Expand All @@ -132,6 +134,19 @@
$renderer->setX($cX);
}
// If current position (top)
$align_Y = false;
$topstr = "";
if ($this->top < -110000) { // pos='abs'
$this->top += 222000;

Check warning on line 140 in app/Report/ReportHtmlTextbox.php

View check run for this annotation

Codecov / codecov/patch

app/Report/ReportHtmlTextbox.php#L140

Added line #L140 was not covered by tests
}
if ($this->top < -10000) { // <= -100000: both pdf and html; -100000 -- -90000: only html
$this->top += 90000; //= ReportBaseElement::CURRENT_POSITION;
if ($this->top < -9000) {
$this->top += 10000;
}
$topstr = "top:" . $this->top . "pt;";
$align_Y = true;
}
if ($this->top === ReportBaseElement::CURRENT_POSITION) {
$this->top = $renderer->getY();
} else {
Expand Down Expand Up @@ -192,7 +207,8 @@
}

// Add up what’s the final height
$cH = $this->height;
//$cH = $this->height;
$cH = 0;
// If any element exist
if ($cE > 0) {
// Check if this is text or some other element, like images
Expand Down Expand Up @@ -225,7 +241,12 @@
$renderer->addMaxY($this->top + $cH);

// Start to print HTML
echo '<div style="position:absolute;top:', $this->top, 'pt;';
if (!$align_Y) {
echo '<div style="position:absolute;top:', $this->top, 'pt;';
} else {
echo '<div style="position:relative;top:', $this->top, 'pt;';
}
//echo '<div style="position:relative;';
// LTR (left) or RTL (right)
echo $renderer->alignRTL, ':', $cX, 'pt;';
// Background color
Expand All @@ -240,9 +261,17 @@
// Border setup
if ($this->border) {
echo ' border:solid black 1pt;';
echo 'width:', $this->width - 1 - $cP * 2, 'pt;height:', $cH - 1, 'pt;';
if (!$align_Y) {
echo 'width:', $this->width - 1 - $cP * 2, 'pt;height:', $cH - 1, 'pt;';
} else {
echo 'width:', $this->width - 1 - $cP * 2, 'pt;height:auto;';
} // height:',$this->height,'pt;'; //,$topstr;
} else {
echo 'width:', $this->width - $cP * 2, 'pt;height:', $cH, 'pt;';
if (!$align_Y) {
echo 'width:', $this->width - $cP * 2, 'pt;height:', $cH, 'pt;';
} else {
echo 'width:', $this->width - $cP * 2, 'pt;height:auto;';
} //height:',$this->height,'pt;'; //,$topstr;
}
echo '">';

Expand Down Expand Up @@ -280,5 +309,8 @@
$renderer->setXy(0, $this->top + $cH + $cP * 2);
$renderer->lastCellHeight = 0;
}
// This will make images in textboxes to ignore images in previous textboxes
// Without this trick the $lastpicbottom in the previos textbox will be used in ReportHtmlImage
$renderer->pageN++;
}
}