1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees: online genealogy |
5
|
|
|
* Copyright (C) 2025 webtrees development team |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU General Public License as published by |
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* You should have received a copy of the GNU General Public License |
15
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
declare(strict_types=1); |
19
|
|
|
|
20
|
|
|
namespace Fisharebest\Webtrees\Report; |
21
|
|
|
|
22
|
|
|
use function str_contains; |
23
|
|
|
use function str_replace; |
24
|
|
|
|
25
|
|
|
class ReportHtmlCell extends ReportBaseCell |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* HTML Cell renderer |
29
|
|
|
* |
30
|
|
|
* @param HtmlRenderer $renderer |
31
|
|
|
* |
32
|
|
|
* @return void |
33
|
|
|
*/ |
34
|
|
|
public function render($renderer): void |
35
|
|
|
{ |
36
|
|
|
if (str_contains($this->text, '{{:ptp:}}')) { |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
$temptext = str_replace('#PAGENUM#', (string) $renderer->pageNo(), $this->text); |
40
|
|
|
// underline «title» part of Source item |
41
|
|
|
$temptext = str_replace([ |
42
|
|
|
'«', |
43
|
|
|
'»', |
44
|
|
|
], [ |
45
|
|
|
'<u>', |
46
|
|
|
'</u>', |
47
|
|
|
], $temptext); |
48
|
|
|
|
49
|
|
|
// Set up the text style |
50
|
|
|
if ($renderer->getCurrentStyle() !== $this->styleName) { |
51
|
|
|
$renderer->setCurrentStyle($this->styleName); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// If (Future-feature-enable/disable cell padding) |
55
|
|
|
$cP = $renderer->cPadding; |
56
|
|
|
|
57
|
|
|
// Adjust the positions |
58
|
|
|
if ($this->left === ReportBaseElement::CURRENT_POSITION) { |
|
|
|
|
59
|
|
|
$this->left = $renderer->getX(); |
60
|
|
|
} else { |
61
|
|
|
$renderer->setX($this->left); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
if ($this->top === ReportBaseElement::CURRENT_POSITION) { |
65
|
|
|
$this->top = $renderer->getY(); |
66
|
|
|
} else { |
67
|
|
|
$renderer->setY($this->top); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
// Start collecting the HTML code |
71
|
|
|
echo '<div class="', $this->styleName, '" style="position:absolute;top:', $this->top, 'pt;'; |
72
|
|
|
// Use Cell around padding to support RTL also |
73
|
|
|
echo 'padding:', $cP, 'pt;'; |
74
|
|
|
// LTR (left) or RTL (right) |
75
|
|
|
echo $renderer->alignRTL, ':', $this->left, 'pt;'; |
76
|
|
|
|
77
|
|
|
// Background color |
78
|
|
|
if (!empty($this->bgcolor)) { |
79
|
|
|
echo 'background-color:', $this->bgcolor, ';'; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
// Borders |
83
|
|
|
$bpixX = 0; |
84
|
|
|
$bpixY = 0; |
85
|
|
|
if (!empty($this->border)) { |
86
|
|
|
// Border all around |
87
|
|
|
if ($this->border === '1') { |
88
|
|
|
echo ' border:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
89
|
|
|
$bpixX = 1; |
90
|
|
|
$bpixY = 1; |
91
|
|
|
} else { |
92
|
|
|
if (str_contains($this->border, 'T')) { |
93
|
|
|
echo ' border-top:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
94
|
|
|
$bpixY = 1; |
95
|
|
|
} |
96
|
|
|
if (str_contains($this->border, 'B')) { |
97
|
|
|
echo ' border-bottom:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
98
|
|
|
$bpixY = 1; |
99
|
|
|
} |
100
|
|
|
if (str_contains($this->border, 'R')) { |
101
|
|
|
echo ' border-right:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
102
|
|
|
$bpixX = 1; |
103
|
|
|
} |
104
|
|
|
if (str_contains($this->border, 'L')) { |
105
|
|
|
echo ' border-left:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
106
|
|
|
$bpixX = 1; |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
// Check the width if set to page wide OR set by xml to larger then page wide |
111
|
|
|
if ($this->width === 0.0 || $this->width > $renderer->getRemainingWidth()) { |
112
|
|
|
$this->width = $renderer->getRemainingWidth(); |
113
|
|
|
} |
114
|
|
|
// We have to calculate a different width for the padding, counting on both side |
115
|
|
|
$cW = $this->width - $cP * 2.0; |
116
|
|
|
|
117
|
|
|
// If there is any text |
118
|
|
|
if (!empty($temptext)) { |
119
|
|
|
// Wrap the text |
120
|
|
|
$temptext = $renderer->textWrap($temptext, $cW); |
121
|
|
|
$tmph = $renderer->getTextCellHeight($temptext); |
122
|
|
|
// Add some cell padding |
123
|
|
|
$this->height += $cP; |
124
|
|
|
if ($tmph > $this->height) { |
125
|
|
|
$this->height = $tmph; |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
// Check the last cell height and adjust the current cell height if needed |
129
|
|
|
if ($renderer->lastCellHeight > $this->height) { |
130
|
|
|
$this->height = $renderer->lastCellHeight; |
131
|
|
|
} |
132
|
|
|
echo ' width:', $cW - $bpixX, 'pt;height:', $this->height - $bpixY, 'pt;'; |
133
|
|
|
|
134
|
|
|
// Text alignment |
135
|
|
|
switch ($this->align) { |
136
|
|
|
case 'C': |
137
|
|
|
echo ' text-align:center;'; |
138
|
|
|
break; |
139
|
|
|
case 'L': |
140
|
|
|
echo ' text-align:left;'; |
141
|
|
|
break; |
142
|
|
|
case 'R': |
143
|
|
|
echo ' text-align:right;'; |
144
|
|
|
break; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
// Print the collected HTML code |
148
|
|
|
echo '">'; |
149
|
|
|
|
150
|
|
|
// Print URL |
151
|
|
|
if (!empty($this->url)) { |
152
|
|
|
echo '<a href="', $this->url, '">'; |
153
|
|
|
} |
154
|
|
|
// Print any text if exists |
155
|
|
|
if (!empty($temptext)) { |
156
|
|
|
$renderer->write($temptext, $this->tcolor, false); |
157
|
|
|
} |
158
|
|
|
if (!empty($this->url)) { |
159
|
|
|
echo '</a>'; |
160
|
|
|
} |
161
|
|
|
// Finish the cell printing and start to clean up |
162
|
|
|
echo "</div>\n"; |
163
|
|
|
|
164
|
|
|
// Where to place the next position |
165
|
|
|
if ($this->newline === 0) { |
166
|
|
|
// -> Next to this cell in the same line |
167
|
|
|
$renderer->setXy($this->left + $this->width, $this->top); |
168
|
|
|
$renderer->lastCellHeight = $this->height; |
169
|
|
|
} elseif ($this->newline === 1) { |
170
|
|
|
// -> On a new line at the margin - Default |
171
|
|
|
$renderer->setXy(0, $renderer->getY() + $this->height + $cP * 2); |
172
|
|
|
// Reset the last cell height for the next line |
173
|
|
|
$renderer->lastCellHeight = 0; |
174
|
|
|
} elseif ($this->newline === 2) { |
175
|
|
|
// -> On a new line at the end of this cell |
176
|
|
|
$renderer->setXy($renderer->getX() + $this->width, $renderer->getY() + $this->height + $cP * 2); |
177
|
|
|
// Reset the last cell height for the next line |
178
|
|
|
$renderer->lastCellHeight = 0; |
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths