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_sources = DB::table('sources') 150b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 163fa66c66SGreg Roach $join->on('l_from', '=', 's_id'); 173fa66c66SGreg Roach $join->on('l_file', '=', 's_file'); 183fa66c66SGreg Roach }) 193fa66c66SGreg Roach ->where('l_type', '=', 'REPO') 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(); 25dd6b2bfcSGreg Roach?> 26dd6b2bfcSGreg Roach 27dd6b2bfcSGreg Roach<table 283fa66c66SGreg Roach class="table table-bordered table-sm wt-table-repository datatables d-none" 2971d313c5SGreg Roach <?= view('lists/datatables-attributes') ?> 30dd6b2bfcSGreg Roach data-columns="<?= e(json_encode([ 31dd6b2bfcSGreg Roach null, 32dd6b2bfcSGreg Roach ['visible' => array_sum($count_sources) > 0], 33dd6b2bfcSGreg Roach ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 34dd6b2bfcSGreg Roach ])) ?>" 35dd6b2bfcSGreg Roach> 36dd6b2bfcSGreg Roach <caption class="sr-only"> 37dd6b2bfcSGreg Roach <?= $caption ?? I18N::translate('Repositories') ?> 38dd6b2bfcSGreg Roach </caption> 39dd6b2bfcSGreg Roach 40dd6b2bfcSGreg Roach <thead> 41dd6b2bfcSGreg Roach <tr> 42dd6b2bfcSGreg Roach <th><?= I18N::translate('Repository name') ?></th> 43dd6b2bfcSGreg Roach <th><?= I18N::translate('Sources') ?></th> 44dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 45dd6b2bfcSGreg Roach </tr> 46dd6b2bfcSGreg Roach </thead> 47dd6b2bfcSGreg Roach 48dd6b2bfcSGreg Roach <tbody> 49dd6b2bfcSGreg Roach <?php foreach ($repositories as $repository) : ?> 50*b16bf9d4SGreg Roach <tr class="<?= $repository->isPendingAddition() ? 'wt-new' : '' ?> <?= $repository->isPendingDeletion() ? 'wt-old' : '' ?>"> 51dd6b2bfcSGreg Roach <!-- Repository name --> 5239ca88baSGreg Roach <td data-sort="<?= e($repository->sortName()) ?>"> 53dd6b2bfcSGreg Roach <a href="<?= e($repository->url()) ?>"> 5439ca88baSGreg Roach <?= $repository->fullName() ?> 55dd6b2bfcSGreg Roach </a> 56dd6b2bfcSGreg Roach </td> 57dd6b2bfcSGreg Roach 58dd6b2bfcSGreg Roach <!-- Count of linked sources --> 59242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_sources[$repository->xref()] ?? 0 ?>"> 60c0935879SGreg Roach <?= I18N::number($count_sources[$repository->xref()] ?? 0) ?> 61dd6b2bfcSGreg Roach </td> 62dd6b2bfcSGreg Roach 63dd6b2bfcSGreg Roach <!-- Last change --> 644459dc9aSGreg Roach <td data-sort="<?= $repository->lastChangeTimestamp()->unix() ?>"> 654459dc9aSGreg Roach <?= view('components/datetime', ['timestamp' => $repository->lastChangeTimestamp()]) ?> 66dd6b2bfcSGreg Roach </td> 67dd6b2bfcSGreg Roach </tr> 68dd6b2bfcSGreg Roach <?php endforeach ?> 69dd6b2bfcSGreg Roach </tbody> 70dd6b2bfcSGreg Roach</table> 71