webtrees
webtrees copied to clipboard
Report additions
The app/Report tool creates reports from the collected gedcom data. The current version has some limitation and shortcomings that this update addresses. A detailed description is included as a pdf file, and in short the changes are:
Report tries to place text on an exact position on a page. But many pitfalls on the way. Counting lines in a textbox is not enough, the lines may be set in different font sizes; converting lines to points in HTML uses a much too high number, which results in a lot of white space, especially for long reports (many pages). The PDF reports have problems to predict when the tool TcPdf will break a line or add a page. This applies to the files HtmlRenderer.php, ReportHtmlTextbox.php, ReportHtmlText.php, PdfRenderer.php, ReportPdfTextBox.php and ReportPdfText.php,
The file ReportParserGenerate.php is responsible for the interpretation of the xml code that defines the layout and contents of the report. A number of addition have been introduced. (1) GetPersonName has got a new attribute, select=..., that allows the report to present the last name used or a combination of latest and surname at birth. Another attribute, fam_relation="1", will add the relation the current person to the start person of a report, e.g. mmf which means mother's mother's father. (2) The value that is returned by GedcomValue can be a very long string. An attribute truncate=... already exists but has been two new possibilities for dates: "Y" will give only the year and "d" gives the date with the three character short for the month, "dd mmm yyyy". (3) The calculation of the family relation that can be give with the name requires a substantial amount of code. (4) The xml keyword Facts returns all facts and events of the current object (person, family) in the order they appear. But in a report one wants chronological order and that has been implemented. A special addition is that a temporary gedcom event is introduced in the process, _SP_DEAT, which when a spouse has died, if applicable. This is used only during calculations, not added to the Gedcom database or file. This (hidden) gedcom value must be added to the gedcom.php file. (A similar presentation is given on the main page for each person.) (5) The keyword SetVar has been expanded with new possibilities for the attribute value=.... The value can now specify "@$xxx" which means the the value of xxx is interpreted as the name of the varible to select. Other new values are "@format" that responds PDF or HTML depending on whichever form of report is selected. "@$dump" can give some help in debugging new or modified reports. (6) Sometimes ancestors have married a relative. In pedigree charts these persons were given as separate persons, although with tha same name, birthdate, et c. But now such persons are detected and the second occurrance is given as "same person as ...". (7) Some errors are corrected.
Unfortunately I used my own indentation rules and did not know how to fix it. So please make the corrections! And please tell me how I can use the tool StyleCI in the future.
Codecov Report
Attention: 130 lines
in your changes are missing coverage. Please review.
Comparison is base (
d5c9d9c
) 32.29% compared to head (42b74bb
) 32.53%. Report is 24 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #4945 +/- ##
============================================
+ Coverage 32.29% 32.53% +0.24%
- Complexity 11401 11535 +134
============================================
Files 1171 1172 +1
Lines 48056 48166 +110
============================================
+ Hits 15521 15673 +152
+ Misses 32535 32493 -42
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The static analysis checks that still fail relate to code that "always" has been there.
Therefore I want this pull request to be set to 'Ready for review' !
PR ready for review!
This PR solved the 'Missing data' Feature Request. It also handles translations for custom modules, especially reports, where the title and description strings were un-translated (because the translations were included too late).
Is this PR still a candidate to be merged with the dev branch? Headers & footers on reports are mentioned again in the forum: https://www.webtrees.net/index.php/forum/2-open-discussion/39136-reports-download
Yes it is!
Hello. I decided to try these changes. Generated a patch file and applied it to a clean 2.1.20 sources directory.
I got these errors:
can't find file to patch at input line 5939
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/phpstan-baseline.php b/phpstan-baseline.php
|index 8e433dded66..4596026fff8 100644
|--- a/phpstan-baseline.php
|+++ b/phpstan-baseline.php -
-------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 5952
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/phpstan-baseline.php b/phpstan-baseline.php
|index 4596026fff8..03a51d7ca51 100644
|--- a/phpstan-baseline.php
|+++ b/phpstan-baseline.php
--------------------------
File to patch:
Skip this patch? [y]
Skipping patch.
4 out of 4 hunks ignored
...
patching file app/Module/ModuleCustomTrait.php
Hunk #3 FAILED at 112.
1 out of 4 hunks FAILED -- saving rejects to file app/Module/ModuleCustomTrait.php.rej
...
patching file app/Report/ReportParserGenerate.php
Reversed (or previously applied) patch detected! Assume -R? [n]
Apply anyway? [n]
Skipping patch.
3 out of 3 hunks ignored -- saving rejects to file app/Report/ReportParserGenerate.php.rej
Is it ok that there is a missing file? Does the "Reversed" change should be applied?
[root@xxx public_html]# cat webtrees-2.1.20-test/app/Report/ReportParserGenerate.php.rej
--- app/Report/ReportParserGenerate.php
+++ app/Report/ReportParserGenerate.php
@@ -22,7 +22,6 @@
use DomainException;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Date;
-use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\Elements\UnknownElement;
use Fisharebest\Webtrees\Factories\MarkdownFactory;
use Fisharebest\Webtrees\Family;
@@ -36,6 +35,7 @@
use Fisharebest\Webtrees\Place;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Tree;
+use Illuminate\Database\Capsule\Manager as DB; // webtrees 2.1.x
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Query\JoinClause;
@@ -2058,7 +2058,7 @@ protected function imageStartHandler(array $attrs): void
if ($file === '@FILE') {
$match = [];
- if (preg_match("/\d OBJE @(.+)@/", $this->gedrec, $match)) {
+ if (preg_match("/1 OBJE @(.+)@/", $this->gedrec, $match)) {
$mediaobject = Registry::mediaFactory()->make($match[1], $this->tree);
$media_file = $mediaobject->firstImageFile();
Just in case it helps.
I doubt this is right:
diff --git a/app/Gedcom.php b/app/Gedcom.php
index 1af380bbb33..b9881765ba0 100644
--- a/app/Gedcom.php
+++ b/app/Gedcom.php
@@ -595,8 +594,8 @@ private function gedcom551Tags(): array
'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')),
'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')),
Is it?
Does the line with a fixed "55.5" is right?
diff --git a/app/Report/PdfRenderer.php b/app/Report/PdfRenderer.php
index bbe261242b4..ba12d1416ea 100644
--- a/app/Report/PdfRenderer.php
+++ b/app/Report/PdfRenderer.php
@@ -363,8 +364,8 @@ public function setup(): void
'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);
EDIT What I mean is I think it should be in a configuration file... I'm not questioning if the value is correct or not.