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_sources = DB::table('sources') 103fa66c66SGreg Roach ->join('link', function (JoinClause $join): void { 113fa66c66SGreg Roach $join->on('l_from', '=', 's_id'); 123fa66c66SGreg Roach $join->on('l_file', '=', 's_file'); 133fa66c66SGreg Roach }) 143fa66c66SGreg Roach ->where('l_type', '=', 'REPO') 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(); 20dd6b2bfcSGreg Roach?> 21dd6b2bfcSGreg Roach 22dd6b2bfcSGreg Roach<table 233fa66c66SGreg Roach class="table table-bordered table-sm wt-table-repository datatables d-none" 2471d313c5SGreg Roach <?= view('lists/datatables-attributes') ?> 25dd6b2bfcSGreg Roach data-columns="<?= e(json_encode([ 26dd6b2bfcSGreg Roach null, 27dd6b2bfcSGreg Roach ['visible' => array_sum($count_sources) > 0], 28dd6b2bfcSGreg Roach ['visible' => (bool) $tree->getPreference('SHOW_LAST_CHANGE'), 'searchable' => false], 29dd6b2bfcSGreg Roach ])) ?>" 30dd6b2bfcSGreg Roach> 31dd6b2bfcSGreg Roach <caption class="sr-only"> 32dd6b2bfcSGreg Roach <?= $caption ?? I18N::translate('Repositories') ?> 33dd6b2bfcSGreg Roach </caption> 34dd6b2bfcSGreg Roach 35dd6b2bfcSGreg Roach <thead> 36dd6b2bfcSGreg Roach <tr> 37dd6b2bfcSGreg Roach <th><?= I18N::translate('Repository name') ?></th> 38dd6b2bfcSGreg Roach <th><?= I18N::translate('Sources') ?></th> 39dd6b2bfcSGreg Roach <th><?= I18N::translate('Last change') ?></th> 40dd6b2bfcSGreg Roach </tr> 41dd6b2bfcSGreg Roach </thead> 42dd6b2bfcSGreg Roach 43dd6b2bfcSGreg Roach <tbody> 44dd6b2bfcSGreg Roach <?php foreach ($repositories as $repository) : ?> 45dd6b2bfcSGreg Roach <tr class="<?= $repository->isPendingDeletion() ? 'old' : ($repository->isPendingAddition() ? 'new' : '') ?>"> 46dd6b2bfcSGreg Roach <!-- Repository name --> 47dd6b2bfcSGreg Roach <td data-sort="<?= e($repository->getSortName()) ?>"> 48dd6b2bfcSGreg Roach <a href="<?= e($repository->url()) ?>"> 49dd6b2bfcSGreg Roach <?= $repository->getFullName() ?> 50dd6b2bfcSGreg Roach </a> 51dd6b2bfcSGreg Roach </td> 52dd6b2bfcSGreg Roach 53dd6b2bfcSGreg Roach <!-- Count of linked sources --> 54*242a7862SGreg Roach <td class="text-center" data-sort="<?= $count_sources[$repository->xref()] ?? 0 ?>"> 55c0935879SGreg Roach <?= I18N::number($count_sources[$repository->xref()] ?? 0) ?> 56dd6b2bfcSGreg Roach </td> 57dd6b2bfcSGreg Roach 58dd6b2bfcSGreg Roach <!-- Last change --> 59dd6b2bfcSGreg Roach <td data-sort="<?= $repository->lastChangeTimestamp(true) ?>"> 60dd6b2bfcSGreg Roach <?= $repository->lastChangeTimestamp() ?> 61dd6b2bfcSGreg Roach </td> 62dd6b2bfcSGreg Roach </tr> 63dd6b2bfcSGreg Roach <?php endforeach ?> 64dd6b2bfcSGreg Roach </tbody> 65dd6b2bfcSGreg Roach</table> 66