1<?php 2use Fisharebest\Webtrees\I18N; 3use Illuminate\Database\Capsule\Manager as DB; 4use Illuminate\Database\Query\Expression; 5use Illuminate\Database\Query\JoinClause; 6?> 7 8<?php 9// Count the number of linked records. These numbers include private records. 10// It is not good to bypass privacy, but many servers do not have the resources 11// to process privacy for every record in the tree 12$count_sources = DB::table('sources') 13 ->join('link', static function (JoinClause $join): void { 14 $join->on('l_from', '=', 's_id'); 15 $join->on('l_file', '=', 's_file'); 16 }) 17 ->where('l_type', '=', 'REPO') 18 ->where('l_file', '=', $tree->id()) 19 ->groupBy(['l_to']) 20 ->select(['l_to', new Expression('COUNT(*) AS total')]) 21 ->pluck('total', 'l_to') 22 ->all(); 23?> 24 25<table 26 class="table table-bordered table-sm wt-table-repository datatables d-none" 27 <?= view('lists/datatables-attributes') ?> 28 data-auto-width="false" 29 data-columns="<?= e(json_encode([ 30 null, 31 ['visible' => array_sum($count_sources) > 0], 32 ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 33 ])) ?>" 34> 35 <caption class="sr-only"> 36 <?= $caption ?? I18N::translate('Repositories') ?> 37 </caption> 38 39 <thead> 40 <tr> 41 <th><?= I18N::translate('Repository name') ?></th> 42 <th><?= I18N::translate('Sources') ?></th> 43 <th><?= I18N::translate('Last change') ?></th> 44 </tr> 45 </thead> 46 47 <tbody> 48 <?php foreach ($repositories as $repository) : ?> 49 <tr class="<?= $repository->isPendingDeletion() ? 'wt-old' : ($repository->isPendingAddition() ? 'wt-new' : '') ?>"> 50 <!-- Repository name --> 51 <td data-sort="<?= e($repository->sortName()) ?>"> 52 <a href="<?= e($repository->url()) ?>"> 53 <?= $repository->fullName() ?> 54 </a> 55 </td> 56 57 <!-- Count of linked sources --> 58 <td class="text-center" data-sort="<?= $count_sources[$repository->xref()] ?? 0 ?>"> 59 <?= I18N::number($count_sources[$repository->xref()] ?? 0) ?> 60 </td> 61 62 <!-- Last change --> 63 <td data-sort="<?= $repository->lastChangeTimestamp()->unix() ?>"> 64 <?= view('components/datetime', ['timestamp' => $repository->lastChangeTimestamp()]) ?> 65 </td> 66 </tr> 67 <?php endforeach ?> 68 </tbody> 69</table> 70