1dd6b2bfcSGreg Roach<?php use Fisharebest\Webtrees\I18N; ?> 23fa66c66SGreg Roach<?php use Illuminate\Database\Query\JoinClause; ?> 33fa66c66SGreg Roach<?php use Illuminate\Database\Capsule\Manager as DB; ?> 4dd6b2bfcSGreg Roach 5dd6b2bfcSGreg Roach<?php 6dd6b2bfcSGreg Roach// Count the number of linked records. These numbers include private records. 7dd6b2bfcSGreg Roach// It is not good to bypass privacy, but many servers do not have the resources 8dd6b2bfcSGreg Roach// to process privacy for every record in the tree 93fa66c66SGreg Roach$count_individuals = DB::table('individuals') 100b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 113fa66c66SGreg Roach $join->on('l_from', '=', 'i_id'); 123fa66c66SGreg Roach $join->on('l_file', '=', 'i_file'); 133fa66c66SGreg Roach }) 143fa66c66SGreg Roach ->where('l_type', '=', 'NOTE') 153fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 163fa66c66SGreg Roach ->groupBy('l_to') 173fa66c66SGreg Roach ->select(['l_to', DB::raw('COUNT(*) AS total')]) 183fa66c66SGreg Roach ->pluck('total', 'l_to') 193fa66c66SGreg Roach ->all(); 203fa66c66SGreg Roach 213fa66c66SGreg Roach$count_families = DB::table('families') 220b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 233fa66c66SGreg Roach $join->on('l_from', '=', 'f_id'); 243fa66c66SGreg Roach $join->on('l_file', '=', 'f_file'); 253fa66c66SGreg Roach }) 263fa66c66SGreg Roach ->where('l_type', '=', 'NOTE') 273fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 283fa66c66SGreg Roach ->groupBy('l_to') 293fa66c66SGreg Roach ->select(['l_to', DB::raw('COUNT(*) AS total')]) 303fa66c66SGreg Roach ->pluck('total', 'l_to') 313fa66c66SGreg Roach ->all(); 323fa66c66SGreg Roach 333fa66c66SGreg Roach$count_sources = DB::table('sources') 340b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 353fa66c66SGreg Roach $join->on('l_from', '=', 's_id'); 363fa66c66SGreg Roach $join->on('l_file', '=', 's_file'); 373fa66c66SGreg Roach }) 383fa66c66SGreg Roach ->where('l_type', '=', 'NOTE') 393fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 403fa66c66SGreg Roach ->groupBy('l_to') 413fa66c66SGreg Roach ->select(['l_to', DB::raw('COUNT(*) AS total')]) 423fa66c66SGreg Roach ->pluck('total', 'l_to') 433fa66c66SGreg Roach ->all(); 44dd6b2bfcSGreg Roach?> 45dd6b2bfcSGreg Roach 46dd6b2bfcSGreg Roach<table 47dd6b2bfcSGreg Roach class="table table-bordered table-sm wt-table-media datatables" 48dd6b2bfcSGreg Roach data-columns="<?= e(json_encode([ 49dd6b2bfcSGreg Roach null, 50dd6b2bfcSGreg Roach null, 51dd6b2bfcSGreg Roach ['visible' => array_sum($count_individuals) > 0], 52dd6b2bfcSGreg Roach ['visible' => array_sum($count_families) > 0], 53dd6b2bfcSGreg Roach ['visible' => array_sum($count_sources) > 0], 54dd6b2bfcSGreg Roach ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 55dd6b2bfcSGreg Roach ])) ?>" 56dd6b2bfcSGreg Roach data-state-save="true" 57dd6b2bfcSGreg Roach> 58dd6b2bfcSGreg Roach <caption class="sr-only"> 59dd6b2bfcSGreg Roach <?= $caption ?? I18N::translate('Media objects') ?> 60dd6b2bfcSGreg Roach </caption> 61dd6b2bfcSGreg Roach 62dd6b2bfcSGreg Roach <thead> 63dd6b2bfcSGreg Roach <tr> 64dd6b2bfcSGreg Roach <th><?= I18N::translate('Media') ?></th> 65dd6b2bfcSGreg Roach <th><?= I18N::translate('Title') ?></th> 66dd6b2bfcSGreg Roach <th><?= I18N::translate('Individuals') ?></th> 67dd6b2bfcSGreg Roach <th><?= I18N::translate('Families') ?></th> 68dd6b2bfcSGreg Roach <th><?= I18N::translate('Sources') ?></th> 69dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 70dd6b2bfcSGreg Roach </tr> 71dd6b2bfcSGreg Roach </thead> 72dd6b2bfcSGreg Roach 73dd6b2bfcSGreg Roach <tbody> 74dd6b2bfcSGreg Roach <?php foreach ($media_objects as $media_object) : ?> 75*17dd427eSGreg Roach <tr class="<?= $media_object->isPendingDeletion() ? 'wt-old' : ($media_object->isPendingAddition() ? 'wt-new' : '') ?>"> 76dd6b2bfcSGreg Roach <!-- Thumbnails--> 7739ca88baSGreg Roach <td data-sort="<?= e($media_object->sortName()) ?>"> 78dd6b2bfcSGreg Roach <?php foreach ($media_object->mediaFiles() as $media_file) : ?> 79dd6b2bfcSGreg Roach <?= $media_file->displayImage(100, 100, 'contain', []) ?> 80dd6b2bfcSGreg Roach <?php endforeach ?> 81dd6b2bfcSGreg Roach </td> 82dd6b2bfcSGreg Roach 83dd6b2bfcSGreg Roach <!-- Title --> 8439ca88baSGreg Roach <td data-sort="<?= e($media_object->sortName()) ?>"> 85dd6b2bfcSGreg Roach <a href="<?= e($media_object->url()) ?>"> 8639ca88baSGreg Roach <?= $media_object->fullName() ?> 87dd6b2bfcSGreg Roach </a> 88dd6b2bfcSGreg Roach </td> 89dd6b2bfcSGreg Roach 90dd6b2bfcSGreg Roach <!-- Count of linked individuals --> 91242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_individuals[$media_object->xref()] ?? 0 ?>"> 92c0935879SGreg Roach <?= I18N::number($count_individuals[$media_object->xref()] ?? 0) ?> 93dd6b2bfcSGreg Roach </td> 94dd6b2bfcSGreg Roach 95dd6b2bfcSGreg Roach <!-- Count of linked families --> 96242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_families[$media_object->xref()] ?? 0 ?>"> 97c0935879SGreg Roach <?= I18N::number($count_families[$media_object->xref()] ?? 0) ?> 98dd6b2bfcSGreg Roach </td> 99dd6b2bfcSGreg Roach 100dd6b2bfcSGreg Roach <!-- Count of sources --> 101242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_sources[$media_object->xref()] ?? 0 ?>"> 102c0935879SGreg Roach <?= I18N::number($count_sources[$media_object->xref()] ?? 0) ?> 103dd6b2bfcSGreg Roach </td> 104dd6b2bfcSGreg Roach 105dd6b2bfcSGreg Roach <!-- Last change --> 1064459dc9aSGreg Roach <td data-sort="<?= $media_object->lastChangeTimestamp()->unix() ?>"> 1074459dc9aSGreg Roach <?= view('components/datetime', ['timestamp' => $media_object->lastChangeTimestamp()]) ?> 108dd6b2bfcSGreg Roach </td> 109dd6b2bfcSGreg Roach </tr> 110dd6b2bfcSGreg Roach <?php endforeach ?> 111dd6b2bfcSGreg Roach </tbody> 112dd6b2bfcSGreg Roach</table> 113