1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
4
|
|
|
* |
5
|
|
|
* @package MyArtJaub\Webtrees |
6
|
|
|
* @subpackage Sosa |
7
|
|
|
* @author Jonathan Jaubart <[email protected]> |
8
|
|
|
* @copyright Copyright (c) 2009-2016, Jonathan Jaubart |
9
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
10
|
|
|
*/ |
11
|
|
|
namespace MyArtJaub\Webtrees\Module\Sosa\Views; |
12
|
|
|
|
13
|
|
|
use Fisharebest\Webtrees\Date; |
14
|
|
|
use Fisharebest\Webtrees\Filter; |
15
|
|
|
use Fisharebest\Webtrees\GedcomTag; |
16
|
|
|
use Fisharebest\Webtrees\I18N; |
17
|
|
|
use Fisharebest\Webtrees\Individual; |
18
|
|
|
use Fisharebest\Webtrees\Place; |
19
|
|
|
use MyArtJaub\Webtrees\Constants; |
20
|
|
|
use MyArtJaub\Webtrees\Functions\FunctionsPrint; |
21
|
|
|
use MyArtJaub\Webtrees\Functions\FunctionsPrintLists; |
22
|
|
|
use MyArtJaub\Webtrees\Module\ModuleManager; |
23
|
|
|
use MyArtJaub\Webtrees\Mvc\View\AbstractView; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* View for SosaList@sosalist@indi |
27
|
|
|
*/ |
28
|
|
|
class SosaListIndiView extends AbstractView { |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* {@inhericDoc} |
32
|
|
|
* @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
33
|
|
|
*/ |
34
|
|
|
protected function renderContent() { |
35
|
|
|
|
36
|
|
|
if($this->data->get('has_sosa', false)) { |
37
|
|
|
$table_id = $this->data->get('table_id'); |
38
|
|
|
?> |
39
|
|
|
|
40
|
|
|
<div id="sosa-indi-list" class="sosa-list"> |
41
|
|
|
<table id="<?= $table_id ?>"> |
42
|
|
|
<thead> |
43
|
|
|
<tr> |
44
|
|
|
<th colspan="15"> |
45
|
|
|
<div class="btn-toolbar"> |
46
|
|
|
<div class="btn-group"> |
47
|
|
|
<button |
48
|
|
|
class="ui-state-default" |
49
|
|
|
data-filter-column="11" |
50
|
|
|
data-filter-value="M" |
51
|
|
|
title="<?= I18N::translate('Show only males.') ?>" |
52
|
|
|
type="button" |
53
|
|
|
><?= Individual::sexImage('M', 'large') ?> |
54
|
|
|
</button> |
55
|
|
|
<button |
56
|
|
|
class="ui-state-default" |
57
|
|
|
data-filter-column="11" |
58
|
|
|
data-filter-value="F" |
59
|
|
|
title="<?= I18N::translate('Show only females.') ?>" |
60
|
|
|
type="button" |
61
|
|
|
> |
62
|
|
|
<?= Individual::sexImage('F', 'large') ?> |
63
|
|
|
</button> |
64
|
|
|
<button |
65
|
|
|
class="ui-state-default" |
66
|
|
|
data-filter-column="11" |
67
|
|
|
data-filter-value="U" |
68
|
|
|
title="<?= I18N::translate('Show only individuals for whom the gender is not known.') ?>" |
69
|
|
|
type="button" |
70
|
|
|
> |
71
|
|
|
<?= Individual::sexImage('U', 'large') ?> |
72
|
|
|
</button> |
73
|
|
|
</div> |
74
|
|
|
<div class="btn-group"> |
75
|
|
|
<button |
76
|
|
|
class="ui-state-default" |
77
|
|
|
data-filter-column="13" |
78
|
|
|
data-filter-value="N" |
79
|
|
|
title="<?= I18N::translate('Show individuals who are alive or couples where both partners are alive.') ?>" |
80
|
|
|
type="button" |
81
|
|
|
> |
82
|
|
|
<?= I18N::translate('Alive') ?> |
83
|
|
|
</button> |
84
|
|
|
<button |
85
|
|
|
class="ui-state-default" |
86
|
|
|
data-filter-column="13" |
87
|
|
|
data-filter-value="Y" |
88
|
|
|
title="<?= I18N::translate('Show individuals who are dead or couples where both partners are dead.') ?>" |
89
|
|
|
type="button" |
90
|
|
|
> |
91
|
|
|
<?= I18N::translate('Dead') ?> |
92
|
|
|
</button> |
93
|
|
|
<button |
94
|
|
|
class="ui-state-default" |
95
|
|
|
data-filter-column="13" |
96
|
|
|
data-filter-value="YES" |
97
|
|
|
title="<?= I18N::translate('Show individuals who died more than 100 years ago.') ?>" |
98
|
|
|
type="button" |
99
|
|
|
><?= GedcomTag::getLabel('DEAT') ?>>100 |
100
|
|
|
</button> |
101
|
|
|
<button |
102
|
|
|
class="ui-state-default" |
103
|
|
|
data-filter-column="13" |
104
|
|
|
data-filter-value="Y100" |
105
|
|
|
title="<?= I18N::translate('Show individuals who died within the last 100 years.') ?>" |
106
|
|
|
type="button" |
107
|
|
|
><?= GedcomTag::getLabel('DEAT') ?><=100 |
108
|
|
|
</button> |
109
|
|
|
</div> |
110
|
|
|
<div class="btn-group"> |
111
|
|
|
<button |
112
|
|
|
class="ui-state-default" |
113
|
|
|
data-filter-column="12" |
114
|
|
|
data-filter-value="YES" |
115
|
|
|
title="<?= I18N::translate('Show individuals born more than 100 years ago.') ?>" |
116
|
|
|
type="button" |
117
|
|
|
><?= GedcomTag::getLabel('BIRT') ?>>100 |
118
|
|
|
</button> |
119
|
|
|
<button |
120
|
|
|
class="ui-state-default" |
121
|
|
|
data-filter-column="12" |
122
|
|
|
data-filter-value="Y100" |
123
|
|
|
title="<?= I18N::translate('Show individuals born within the last 100 years.') ?>" |
124
|
|
|
type="button" |
125
|
|
|
><?= GedcomTag::getLabel('BIRT') ?><=100 |
126
|
|
|
</button> |
127
|
|
|
</div> |
128
|
|
|
<div class="btn-group"> |
129
|
|
|
<button |
130
|
|
|
class="ui-state-default" |
131
|
|
|
data-filter-column="14" |
132
|
|
|
data-filter-value="R" |
133
|
|
|
title="<?= I18N::translate('Show “roots” couples or individuals. These individuals may also be called “patriarchs”. They are individuals who have no parents recorded in the database.') ?>" |
134
|
|
|
type="button" |
135
|
|
|
> |
136
|
|
|
<?= I18N::translate('Roots') ?> |
137
|
|
|
</button> |
138
|
|
|
<button |
139
|
|
|
class="ui-state-default" |
140
|
|
|
data-filter-column="14" |
141
|
|
|
data-filter-value="L" |
142
|
|
|
title="<?= I18N::translate('Show “leaves” couples or individuals. These are individuals who are alive but have no children recorded in the database.') ?>" |
143
|
|
|
type="button" |
144
|
|
|
> |
145
|
|
|
<?= I18N::translate('Leaves') ?> |
146
|
|
|
</button> |
147
|
|
|
</div> |
148
|
|
|
</div> |
149
|
|
|
</th> |
150
|
|
|
</tr> |
151
|
|
|
<tr> |
152
|
|
|
<th><?= I18N::translate('Sosa') ?></th> |
153
|
|
|
<th hidden><?= GedcomTag::getLabel('INDI') ?></th> |
154
|
|
|
<th><?= GedcomTag::getLabel('GIVN') ?></th> |
155
|
|
|
<th><?= GedcomTag::getLabel('SURN') ?></th> |
156
|
|
|
<th><?= GedcomTag::getLabel('BIRT') ?></th> |
157
|
|
|
<th><?= GedcomTag::getLabel('PLAC') ?></th> |
158
|
|
|
<?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { ?> |
159
|
|
|
<th><i class="icon-source" title="<?= I18N::translate('Sourced birth') ?>" border="0"></i></th> |
160
|
|
|
<?php } else { ?> |
161
|
|
|
<th></th> |
162
|
|
|
<?php } ?> |
163
|
|
|
<th><?= GedcomTag::getLabel('DEAT') ?></th> |
164
|
|
|
<th><?= GedcomTag::getLabel('AGE') ?></th> |
165
|
|
|
<th><?= GedcomTag::getLabel('PLAC') ?></th> |
166
|
|
|
<?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { ?> |
167
|
|
|
<th><i class="icon-source" title="<?= I18N::translate('Sourced death') ?>" border="0"></i></th> |
168
|
|
|
<?php } else { ?> |
169
|
|
|
<th></th> |
170
|
|
|
<?php } ?> |
171
|
|
|
<th hidden>SEX</th> |
172
|
|
|
<th hidden>BIRT</th> |
173
|
|
|
<th hidden>DEAT</th> |
174
|
|
|
<th hidden>TREE</th> |
175
|
|
|
</tr> |
176
|
|
|
</thead> |
177
|
|
|
<tbody> |
178
|
|
|
|
179
|
|
|
<?php foreach($this->data->get('sosa_list') as $sosa => $person) { |
180
|
|
|
/** @var \Fisharebest\Webtrees\Individual $person */ |
181
|
|
View Code Duplication |
if ($person->isPendingAddtion()) { |
|
|
|
|
182
|
|
|
$class = ' class="new"'; |
183
|
|
|
} elseif ($person->isPendingDeletion()) { |
184
|
|
|
$class = ' class="old"'; |
185
|
|
|
} else { |
186
|
|
|
$class = ''; |
187
|
|
|
} |
188
|
|
|
$dperson = new \MyArtJaub\Webtrees\Individual($person); |
189
|
|
|
?> |
190
|
|
|
<tr <?= $class ?>> |
191
|
|
|
<td class="transparent"><?= $sosa ?></td> |
192
|
|
|
<td hidden><?= $person->getXref() ?></td> |
193
|
|
|
<?php list($surn_givn, $givn_surn) = FunctionsPrintLists::sortableNames($person); ?> |
194
|
|
|
<td colspan="2" data-sort="<?= Filter::escapeHtml($givn_surn) ?>"> |
195
|
|
View Code Duplication |
<?php foreach ($person->getAllNames() as $num=>$name) { |
|
|
|
|
196
|
|
|
if ($name['type']=='NAME') { |
197
|
|
|
$title=''; |
198
|
|
|
} else { |
199
|
|
|
$title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
200
|
|
|
} |
201
|
|
|
if ($num==$person->getPrimaryName()) { |
202
|
|
|
$class=' class="name2"'; |
203
|
|
|
$sex_image=$person->getSexImage(); |
204
|
|
|
} else { |
205
|
|
|
$class=''; |
206
|
|
|
$sex_image=''; |
207
|
|
|
} ?> |
208
|
|
|
<a <?= $title.' '.$class; ?> href="<?= $person->getHtmlUrl() ?>"> |
209
|
|
|
<?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']) ?> |
210
|
|
|
</a> |
211
|
|
|
<?= $sex_image; |
212
|
|
|
echo implode(' ', |
213
|
|
|
\MyArtJaub\Webtrees\Hook\HookProvider::getInstance() |
214
|
|
|
->get('hRecordNameAppend') |
215
|
|
|
->executeOnlyFor(array(Constants::MODULE_MAJ_SOSA_NAME), $person, 'smaller')); |
216
|
|
|
?> |
217
|
|
|
<br/> |
218
|
|
|
<?php } |
219
|
|
|
echo $person->getPrimaryParentsNames('parents details1', 'none'); |
220
|
|
|
?> |
221
|
|
|
</td> |
222
|
|
|
<td hidden data-sort="<?= Filter::escapeHtml($surn_givn) ?>"></td> |
223
|
|
|
<?php $birth_dates = $person->getAllBirthDates(); ?> |
224
|
|
|
<td data-sort="<?= $person->getEstimatedBirthDate()->julianDay() ?>"> |
225
|
|
|
<?php foreach ($birth_dates as $n => $birth_date) { |
226
|
|
|
if ($n > 0) { ?><br/><?php } ?> |
227
|
|
|
<?php echo $birth_date->display(true); |
228
|
|
|
} ?> |
229
|
|
|
</td> |
230
|
|
|
<td> |
231
|
|
|
<?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) { |
232
|
|
|
$tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
233
|
|
|
if ($n > 0) { ?><br><?php } ?> |
234
|
|
|
<a href="'<?= $tmp->getURL() ?>" title="<?= strip_tags($tmp->getFullName()) ?>"> |
235
|
|
|
<?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()) ?> |
236
|
|
|
</a> |
237
|
|
|
<?php } ?> |
238
|
|
|
</td> |
239
|
|
View Code Duplication |
<?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
|
|
|
|
240
|
|
|
$isBSourced = $dperson->isBirthSourced(); ?> |
241
|
|
|
<td data-sort="<?= $isBSourced ?>"><?= FunctionsPrint::formatIsSourcedIcon('E', $isBSourced, 'BIRT', 1, 'medium') ?></td> |
|
|
|
|
242
|
|
|
<?php } else { ?> |
243
|
|
|
<td> </td> |
244
|
|
|
<?php } ?> |
245
|
|
|
<?php $death_dates = $person->getAllDeathDates(); ?> |
246
|
|
|
<td data-sort="<?= $person->getEstimatedDeathDate()->julianDay() ?>"> |
247
|
|
|
<?php foreach ($death_dates as $num => $death_date) { |
248
|
|
|
if ($num) { ?><br/><?php } ?> |
249
|
|
|
<?php echo $death_date->display(true); |
250
|
|
|
} ?> |
251
|
|
|
</td> |
252
|
|
|
<?php if (isset($birth_dates[0]) && isset($death_dates[0])) { |
253
|
|
|
$age_at_death = Date::getAge($birth_dates[0], $death_dates[0], 0); |
254
|
|
|
$age_at_death_sort = Date::getAge($birth_dates[0], $death_dates[0], 2); |
255
|
|
|
} else { |
256
|
|
|
$age_at_death = ''; |
257
|
|
|
$age_at_death_sort = PHP_INT_MAX; |
258
|
|
|
} ?> |
259
|
|
|
<td class="center" data-sort="<?= $age_at_death_sort ?>"><?= $age_at_death ?></td> |
260
|
|
|
<td> |
261
|
|
View Code Duplication |
<?php foreach ($person->getAllDeathPlaces() as $n => $death_place) { |
|
|
|
|
262
|
|
|
$tmp = new Place($death_place, $person->getTree()); |
263
|
|
|
if ($n) { ?><br><?php } ?> |
264
|
|
|
<a href="'<?= $tmp->getURL() ?>" title="<?= strip_tags($tmp->getFullName()) ?>"> |
265
|
|
|
<?= \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()) ?> |
266
|
|
|
</a> |
267
|
|
|
<?php } ?> |
268
|
|
|
</td> |
269
|
|
View Code Duplication |
<?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
|
|
|
|
270
|
|
|
if($person->isDead()) { |
271
|
|
|
$isDSourced = $dperson->isDeathSourced(); ?> |
272
|
|
|
<td data-sort=<?= $isDSourced ?>><?= FunctionsPrint::formatIsSourcedIcon('E', $isDSourced, 'DEAT', 1, 'medium') ?></td> |
|
|
|
|
273
|
|
|
<?php } else { ?> |
274
|
|
|
<td data-sort="-99"> </td> |
275
|
|
|
<?php } |
276
|
|
|
} else { ?> |
277
|
|
|
<td> </td> |
278
|
|
|
<?php } ?> |
279
|
|
|
<td hidden><?= $person->getSex() ?></td> |
280
|
|
|
<td hidden> |
281
|
|
View Code Duplication |
<?php if (!$person->canShow() || Date::compare($person->getEstimatedBirthDate(), new Date(date('Y') - 100)) > 0) { |
|
|
|
|
282
|
|
|
echo 'Y100'; |
283
|
|
|
} else { |
284
|
|
|
echo 'YES'; |
285
|
|
|
} ?> |
286
|
|
|
</td> |
287
|
|
|
<td hidden> |
288
|
|
|
<?php if (isset($death_dates[0]) && Date::compare($death_dates[0], new Date(date('Y') - 100)) > 0) { |
289
|
|
|
echo 'Y100'; |
290
|
|
|
} elseif ($person->isDead()) { |
291
|
|
|
echo 'YES'; |
292
|
|
|
} else { |
293
|
|
|
echo 'N'; |
294
|
|
|
} ?> |
295
|
|
|
</td> |
296
|
|
|
<td hidden> |
297
|
|
|
<?php if (!$person->getChildFamilies()) { |
298
|
|
|
echo 'R'; |
299
|
|
|
} // roots |
300
|
|
|
elseif (!$person->isDead() && $person->getNumberOfChildren() < 1) { |
301
|
|
|
echo 'L'; |
302
|
|
|
} // leaves |
303
|
|
|
else { |
304
|
|
|
echo ' '; |
305
|
|
|
} ?> |
306
|
|
|
</td> |
307
|
|
|
</tr> |
308
|
|
|
<?php } ?> |
309
|
|
|
</tbody> |
310
|
|
|
<tfoot> |
311
|
|
|
<tr> |
312
|
|
|
<th class="ui-state-default" colspan="15"> |
313
|
|
|
<div class="center"> |
314
|
|
|
<?= I18N::translate('Number of Sosa ancestors: %1$s known / %2$s theoretical (%3$s)', |
315
|
|
|
I18N::number($this->data->get('sosa_count')), |
316
|
|
|
I18N::number($this->data->get('sosa_theo')), |
317
|
|
|
I18N::percentage($this->data->get('sosa_ratio'),2) |
318
|
|
|
) ?> |
319
|
|
View Code Duplication |
<?php if($this->data->get('sosa_hidden') > 0) { |
|
|
|
|
320
|
|
|
echo '['. I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))).']'; |
321
|
|
|
} ?> |
322
|
|
|
</div> |
323
|
|
|
</th> |
324
|
|
|
</tr> |
325
|
|
|
<tr> |
326
|
|
|
<th colspan="15"> |
327
|
|
|
<div class="btn-toolbar"> |
328
|
|
|
<div class="btn-group"> |
329
|
|
|
<button type="button" class="ui-state-default btn-toggle-parents"> |
330
|
|
|
<?= I18N::translate('Show parents') ?> |
331
|
|
|
</button> |
332
|
|
|
<button id="btn-toggle-statistics-<?= $table_id ;?>" type="button" class="ui-state-default btn-toggle-statistics"> |
333
|
|
|
<?= I18N::translate('Show statistics charts') ?> |
334
|
|
|
</button> |
335
|
|
|
</div> |
336
|
|
|
</div> |
337
|
|
|
</th> |
338
|
|
|
</tr> |
339
|
|
|
</tfoot> |
340
|
|
|
</table> |
341
|
|
|
<div id="indi_list_table-charts_<?= $table_id; ?>" style="display:none"> |
342
|
|
|
<table class="list-charts"> |
343
|
|
|
<tr> |
344
|
|
|
<td><?= $this->data->get('chart_births') ?></td> |
345
|
|
|
<td><?= $this->data->get('chart_deaths') ?></td> |
346
|
|
|
</tr> |
347
|
|
|
<tr> |
348
|
|
|
<td colspan="2"><?= $this->data->get('chart_ages') ?></td> |
349
|
|
|
</tr> |
350
|
|
|
</table> |
351
|
|
|
</div> |
352
|
|
|
</div> |
353
|
|
|
<?php |
354
|
|
|
} |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
} |
358
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.