1a69f5655SGreg Roach<?php 2d70512abSGreg Roach 310e06497SGreg Roachdeclare(strict_types=1); 410e06497SGreg Roach 5*6f4ec3caSGreg Roachuse Fisharebest\Webtrees\DB; 6a69f5655SGreg Roachuse Fisharebest\Webtrees\I18N; 77c2c99faSGreg Roachuse Fisharebest\Webtrees\Repository; 87c2c99faSGreg Roachuse Fisharebest\Webtrees\Tree; 9a69f5655SGreg Roachuse Illuminate\Database\Query\Expression; 10a69f5655SGreg Roachuse Illuminate\Database\Query\JoinClause; 117c2c99faSGreg Roachuse Illuminate\Support\Collection; 127c2c99faSGreg Roach 137c2c99faSGreg Roach/** 1436779af1SGreg Roach * @var Collection<int,Repository> $repositories 157c2c99faSGreg Roach * @var Tree $tree 167c2c99faSGreg Roach */ 17d70512abSGreg Roach 18a69f5655SGreg Roach?> 19dd6b2bfcSGreg Roach 20dd6b2bfcSGreg Roach<?php 21dd6b2bfcSGreg Roach// Count the number of linked records. These numbers include private records. 22dd6b2bfcSGreg Roach// It is not good to bypass privacy, but many servers do not have the resources 23dd6b2bfcSGreg Roach// to process privacy for every record in the tree 243fa66c66SGreg Roach$count_sources = DB::table('sources') 250b5fd0a6SGreg Roach ->join('link', static function (JoinClause $join): void { 263fa66c66SGreg Roach $join->on('l_from', '=', 's_id'); 273fa66c66SGreg Roach $join->on('l_file', '=', 's_file'); 283fa66c66SGreg Roach }) 293fa66c66SGreg Roach ->where('l_type', '=', 'REPO') 303fa66c66SGreg Roach ->where('l_file', '=', $tree->id()) 317f5c2944SGreg Roach ->groupBy(['l_to']) 32059898c9SGreg Roach ->pluck(new Expression('COUNT(*) AS total'), 'l_to') 33a962cdb5SGreg Roach ->map(static fn ($n) => (int) $n) 343fa66c66SGreg Roach ->all(); 35dd6b2bfcSGreg Roach?> 36dd6b2bfcSGreg Roach 37dd6b2bfcSGreg Roach<table 383fa66c66SGreg Roach class="table table-bordered table-sm wt-table-repository datatables d-none" 3971d313c5SGreg Roach <?= view('lists/datatables-attributes') ?> 40dd6b2bfcSGreg Roach data-columns="<?= e(json_encode([ 41eef4add8SGreg Roach ['type' => 'html'], 42dd6b2bfcSGreg Roach ['visible' => array_sum($count_sources) > 0], 43dd6b2bfcSGreg Roach ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 44728c8c27SGreg Roach ], JSON_THROW_ON_ERROR)) ?>" 45dd6b2bfcSGreg Roach> 46315eb316SGreg Roach <caption class="visually-hidden"> 47dd6b2bfcSGreg Roach <?= $caption ?? I18N::translate('Repositories') ?> 48dd6b2bfcSGreg Roach </caption> 49dd6b2bfcSGreg Roach 50dd6b2bfcSGreg Roach <thead> 51dd6b2bfcSGreg Roach <tr> 52dd6b2bfcSGreg Roach <th><?= I18N::translate('Repository name') ?></th> 53dd6b2bfcSGreg Roach <th><?= I18N::translate('Sources') ?></th> 54dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 55dd6b2bfcSGreg Roach </tr> 56dd6b2bfcSGreg Roach </thead> 57dd6b2bfcSGreg Roach 58dd6b2bfcSGreg Roach <tbody> 59dd6b2bfcSGreg Roach <?php foreach ($repositories as $repository) : ?> 60b16bf9d4SGreg Roach <tr class="<?= $repository->isPendingAddition() ? 'wt-new' : '' ?> <?= $repository->isPendingDeletion() ? 'wt-old' : '' ?>"> 61dd6b2bfcSGreg Roach <!-- Repository name --> 6239ca88baSGreg Roach <td data-sort="<?= e($repository->sortName()) ?>"> 63dd6b2bfcSGreg Roach <a href="<?= e($repository->url()) ?>"> 6439ca88baSGreg Roach <?= $repository->fullName() ?> 65dd6b2bfcSGreg Roach </a> 66dd6b2bfcSGreg Roach </td> 67dd6b2bfcSGreg Roach 68dd6b2bfcSGreg Roach <!-- Count of linked sources --> 69242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_sources[$repository->xref()] ?? 0 ?>"> 70c0935879SGreg Roach <?= I18N::number($count_sources[$repository->xref()] ?? 0) ?> 71dd6b2bfcSGreg Roach </td> 72dd6b2bfcSGreg Roach 73dd6b2bfcSGreg Roach <!-- Last change --> 74d97083feSGreg Roach <td data-sort="<?= $repository->lastChangeTimestamp()->timestamp() ?>"> 754459dc9aSGreg Roach <?= view('components/datetime', ['timestamp' => $repository->lastChangeTimestamp()]) ?> 76dd6b2bfcSGreg Roach </td> 77dd6b2bfcSGreg Roach </tr> 78dd6b2bfcSGreg Roach <?php endforeach ?> 79dd6b2bfcSGreg Roach </tbody> 80dd6b2bfcSGreg Roach</table> 81