1a69f5655SGreg Roach<?php 2d70512abSGreg Roach 3a69f5655SGreg Roachuse Fisharebest\Webtrees\I18N; 4a69f5655SGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 5a69f5655SGreg Roachuse Illuminate\Database\Query\Expression; 6a69f5655SGreg Roachuse Illuminate\Database\Query\JoinClause; 7d70512abSGreg Roach 8a69f5655SGreg Roach?> 9dd6b2bfcSGreg Roach 10dd6b2bfcSGreg Roach<?php 11dd6b2bfcSGreg Roach// Count the number of linked records. These numbers include private records. 12dd6b2bfcSGreg Roach// It is not good to bypass privacy, but many servers do not have the resources 13dd6b2bfcSGreg Roach// to process privacy for every record in the tree 143fa66c66SGreg Roach$count_individuals = DB::table('individuals') 150b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 163fa66c66SGreg Roach $join->on('l_from', '=', 'i_id'); 173fa66c66SGreg Roach $join->on('l_file', '=', 'i_file'); 183fa66c66SGreg Roach }) 193fa66c66SGreg Roach ->where('l_type', '=', 'NOTE') 203fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 217f5c2944SGreg Roach ->groupBy(['l_to']) 22a69f5655SGreg Roach ->select(['l_to', new Expression('COUNT(*) AS total')]) 233fa66c66SGreg Roach ->pluck('total', 'l_to') 243fa66c66SGreg Roach ->all(); 253fa66c66SGreg Roach 263fa66c66SGreg Roach$count_families = DB::table('families') 270b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 283fa66c66SGreg Roach $join->on('l_from', '=', 'f_id'); 293fa66c66SGreg Roach $join->on('l_file', '=', 'f_file'); 303fa66c66SGreg Roach }) 313fa66c66SGreg Roach ->where('l_type', '=', 'NOTE') 323fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 337f5c2944SGreg Roach ->groupBy(['l_to']) 34a69f5655SGreg Roach ->select(['l_to', new Expression('COUNT(*) AS total')]) 353fa66c66SGreg Roach ->pluck('total', 'l_to') 363fa66c66SGreg Roach ->all(); 373fa66c66SGreg Roach 383fa66c66SGreg Roach$count_sources = DB::table('sources') 390b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 403fa66c66SGreg Roach $join->on('l_from', '=', 's_id'); 413fa66c66SGreg Roach $join->on('l_file', '=', 's_file'); 423fa66c66SGreg Roach }) 433fa66c66SGreg Roach ->where('l_type', '=', 'NOTE') 443fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 457f5c2944SGreg Roach ->groupBy(['l_to']) 46a69f5655SGreg Roach ->select(['l_to', new Expression('COUNT(*) AS total')]) 473fa66c66SGreg Roach ->pluck('total', 'l_to') 483fa66c66SGreg Roach ->all(); 49dd6b2bfcSGreg Roach?> 50dd6b2bfcSGreg Roach 51dd6b2bfcSGreg Roach<table 52*b4139381SGreg Roach class="table table-bordered table-sm wt-table-media datatables d-none" 53*b4139381SGreg Roach <?= view('lists/datatables-attributes') ?> 54dd6b2bfcSGreg Roach data-columns="<?= e(json_encode([ 55dd6b2bfcSGreg Roach null, 56dd6b2bfcSGreg Roach null, 57dd6b2bfcSGreg Roach ['visible' => array_sum($count_individuals) > 0], 58dd6b2bfcSGreg Roach ['visible' => array_sum($count_families) > 0], 59dd6b2bfcSGreg Roach ['visible' => array_sum($count_sources) > 0], 60dd6b2bfcSGreg Roach ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 61dd6b2bfcSGreg Roach ])) ?>" 62dd6b2bfcSGreg Roach> 63dd6b2bfcSGreg Roach <caption class="sr-only"> 64dd6b2bfcSGreg Roach <?= $caption ?? I18N::translate('Media objects') ?> 65dd6b2bfcSGreg Roach </caption> 66dd6b2bfcSGreg Roach 67dd6b2bfcSGreg Roach <thead> 68dd6b2bfcSGreg Roach <tr> 69dd6b2bfcSGreg Roach <th><?= I18N::translate('Media') ?></th> 70dd6b2bfcSGreg Roach <th><?= I18N::translate('Title') ?></th> 71dd6b2bfcSGreg Roach <th><?= I18N::translate('Individuals') ?></th> 72dd6b2bfcSGreg Roach <th><?= I18N::translate('Families') ?></th> 73dd6b2bfcSGreg Roach <th><?= I18N::translate('Sources') ?></th> 74dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 75dd6b2bfcSGreg Roach </tr> 76dd6b2bfcSGreg Roach </thead> 77dd6b2bfcSGreg Roach 78dd6b2bfcSGreg Roach <tbody> 79dd6b2bfcSGreg Roach <?php foreach ($media_objects as $media_object) : ?> 8017dd427eSGreg Roach <tr class="<?= $media_object->isPendingDeletion() ? 'wt-old' : ($media_object->isPendingAddition() ? 'wt-new' : '') ?>"> 81dd6b2bfcSGreg Roach <!-- Thumbnails--> 8239ca88baSGreg Roach <td data-sort="<?= e($media_object->sortName()) ?>"> 83dd6b2bfcSGreg Roach <?php foreach ($media_object->mediaFiles() as $media_file) : ?> 84dd6b2bfcSGreg Roach <?= $media_file->displayImage(100, 100, 'contain', []) ?> 85dd6b2bfcSGreg Roach <?php endforeach ?> 86dd6b2bfcSGreg Roach </td> 87dd6b2bfcSGreg Roach 88dd6b2bfcSGreg Roach <!-- Title --> 8939ca88baSGreg Roach <td data-sort="<?= e($media_object->sortName()) ?>"> 90dd6b2bfcSGreg Roach <a href="<?= e($media_object->url()) ?>"> 9139ca88baSGreg Roach <?= $media_object->fullName() ?> 92dd6b2bfcSGreg Roach </a> 93dd6b2bfcSGreg Roach </td> 94dd6b2bfcSGreg Roach 95dd6b2bfcSGreg Roach <!-- Count of linked individuals --> 96242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_individuals[$media_object->xref()] ?? 0 ?>"> 97c0935879SGreg Roach <?= I18N::number($count_individuals[$media_object->xref()] ?? 0) ?> 98dd6b2bfcSGreg Roach </td> 99dd6b2bfcSGreg Roach 100dd6b2bfcSGreg Roach <!-- Count of linked families --> 101242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_families[$media_object->xref()] ?? 0 ?>"> 102c0935879SGreg Roach <?= I18N::number($count_families[$media_object->xref()] ?? 0) ?> 103dd6b2bfcSGreg Roach </td> 104dd6b2bfcSGreg Roach 105dd6b2bfcSGreg Roach <!-- Count of sources --> 106242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_sources[$media_object->xref()] ?? 0 ?>"> 107c0935879SGreg Roach <?= I18N::number($count_sources[$media_object->xref()] ?? 0) ?> 108dd6b2bfcSGreg Roach </td> 109dd6b2bfcSGreg Roach 110dd6b2bfcSGreg Roach <!-- Last change --> 1114459dc9aSGreg Roach <td data-sort="<?= $media_object->lastChangeTimestamp()->unix() ?>"> 1124459dc9aSGreg Roach <?= view('components/datetime', ['timestamp' => $media_object->lastChangeTimestamp()]) ?> 113dd6b2bfcSGreg Roach </td> 114dd6b2bfcSGreg Roach </tr> 115dd6b2bfcSGreg Roach <?php endforeach ?> 116dd6b2bfcSGreg Roach </tbody> 117dd6b2bfcSGreg Roach</table> 118