1a69f5655SGreg Roach<?php 2d70512abSGreg Roach 3a69f5655SGreg Roachuse Fisharebest\Webtrees\I18N; 47c2c99faSGreg Roachuse Fisharebest\Webtrees\Repository; 57c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree; 6a69f5655SGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 7a69f5655SGreg Roachuse Illuminate\Database\Query\Expression; 8a69f5655SGreg Roachuse Illuminate\Database\Query\JoinClause; 97c2c99faSGreg Roachuse Illuminate\Support\Collection; 107c2c99faSGreg Roach 117c2c99faSGreg Roach/** 127c2c99faSGreg Roach * @var Collection<Repository> $repositories 137c2c99faSGreg Roach * @var Tree $tree 147c2c99faSGreg Roach */ 15d70512abSGreg Roach 16a69f5655SGreg Roach?> 17dd6b2bfcSGreg Roach 18dd6b2bfcSGreg Roach<?php 19dd6b2bfcSGreg Roach// Count the number of linked records. These numbers include private records. 20dd6b2bfcSGreg Roach// It is not good to bypass privacy, but many servers do not have the resources 21dd6b2bfcSGreg Roach// to process privacy for every record in the tree 223fa66c66SGreg Roach$count_sources = DB::table('sources') 230b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 243fa66c66SGreg Roach $join->on('l_from', '=', 's_id'); 253fa66c66SGreg Roach $join->on('l_file', '=', 's_file'); 263fa66c66SGreg Roach }) 273fa66c66SGreg Roach ->where('l_type', '=', 'REPO') 283fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 297f5c2944SGreg Roach ->groupBy(['l_to']) 30a69f5655SGreg Roach ->select(['l_to', new Expression('COUNT(*) AS total')]) 313fa66c66SGreg Roach ->pluck('total', 'l_to') 323fa66c66SGreg Roach ->all(); 33dd6b2bfcSGreg Roach?> 34dd6b2bfcSGreg Roach 35dd6b2bfcSGreg Roach<table 363fa66c66SGreg Roach class="table table-bordered table-sm wt-table-repository datatables d-none" 3771d313c5SGreg Roach <?= view('lists/datatables-attributes') ?> 38dd6b2bfcSGreg Roach data-columns="<?= e(json_encode([ 39eef4add8SGreg Roach ['type' => 'html'], 40dd6b2bfcSGreg Roach ['visible' => array_sum($count_sources) > 0], 41dd6b2bfcSGreg Roach ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 42*728c8c27SGreg Roach ], JSON_THROW_ON_ERROR)) ?>" 43dd6b2bfcSGreg Roach> 44315eb316SGreg Roach <caption class="visually-hidden"> 45dd6b2bfcSGreg Roach <?= $caption ?? I18N::translate('Repositories') ?> 46dd6b2bfcSGreg Roach </caption> 47dd6b2bfcSGreg Roach 48dd6b2bfcSGreg Roach <thead> 49dd6b2bfcSGreg Roach <tr> 50dd6b2bfcSGreg Roach <th><?= I18N::translate('Repository name') ?></th> 51dd6b2bfcSGreg Roach <th><?= I18N::translate('Sources') ?></th> 52dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 53dd6b2bfcSGreg Roach </tr> 54dd6b2bfcSGreg Roach </thead> 55dd6b2bfcSGreg Roach 56dd6b2bfcSGreg Roach <tbody> 57dd6b2bfcSGreg Roach <?php foreach ($repositories as $repository) : ?> 58b16bf9d4SGreg Roach <tr class="<?= $repository->isPendingAddition() ? 'wt-new' : '' ?> <?= $repository->isPendingDeletion() ? 'wt-old' : '' ?>"> 59dd6b2bfcSGreg Roach <!-- Repository name --> 6039ca88baSGreg Roach <td data-sort="<?= e($repository->sortName()) ?>"> 61dd6b2bfcSGreg Roach <a href="<?= e($repository->url()) ?>"> 6239ca88baSGreg Roach <?= $repository->fullName() ?> 63dd6b2bfcSGreg Roach </a> 64dd6b2bfcSGreg Roach </td> 65dd6b2bfcSGreg Roach 66dd6b2bfcSGreg Roach <!-- Count of linked sources --> 67242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_sources[$repository->xref()] ?? 0 ?>"> 68c0935879SGreg Roach <?= I18N::number($count_sources[$repository->xref()] ?? 0) ?> 69dd6b2bfcSGreg Roach </td> 70dd6b2bfcSGreg Roach 71dd6b2bfcSGreg Roach <!-- Last change --> 724459dc9aSGreg Roach <td data-sort="<?= $repository->lastChangeTimestamp()->unix() ?>"> 734459dc9aSGreg Roach <?= view('components/datetime', ['timestamp' => $repository->lastChangeTimestamp()]) ?> 74dd6b2bfcSGreg Roach </td> 75dd6b2bfcSGreg Roach </tr> 76dd6b2bfcSGreg Roach <?php endforeach ?> 77dd6b2bfcSGreg Roach </tbody> 78dd6b2bfcSGreg Roach</table> 79