1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
5
|
|
|
* |
6
|
|
|
* @package MyArtJaub\Webtrees |
7
|
|
|
* @subpackage Sosa |
8
|
|
|
* @author Jonathan Jaubart <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2011-2022, Jonathan Jaubart |
10
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
declare(strict_types=1); |
14
|
|
|
|
15
|
|
|
namespace MyArtJaub\Webtrees\Module\Sosa\Hooks; |
16
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\Auth; |
18
|
|
|
use Fisharebest\Webtrees\DefaultUser; |
19
|
|
|
use Fisharebest\Webtrees\GedcomRecord; |
20
|
|
|
use Fisharebest\Webtrees\Individual; |
21
|
|
|
use Fisharebest\Webtrees\Module\ModuleInterface; |
22
|
|
|
use MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface; |
23
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Services\SosaRecordsService; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Hook for displaying an icon next to Sosa ancestors' display name. |
27
|
|
|
*/ |
28
|
|
|
class SosaIconHook implements RecordNameTextExtenderInterface |
29
|
|
|
{ |
30
|
|
|
private ModuleInterface $module; |
31
|
|
|
private SosaRecordsService $sosa_records_service; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Constructor for SosaIconHook |
35
|
|
|
* |
36
|
|
|
* @param ModuleInterface $module |
37
|
|
|
* @param SosaRecordsService $sosa_records_service |
38
|
|
|
*/ |
39
|
|
|
public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service) |
40
|
|
|
{ |
41
|
|
|
$this->module = $module; |
42
|
|
|
$this->sosa_records_service = $sosa_records_service; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritDoc} |
47
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
48
|
|
|
*/ |
49
|
|
|
public function module(): ModuleInterface |
50
|
|
|
{ |
51
|
|
|
return $this->module; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritDoc} |
56
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
57
|
|
|
*/ |
58
|
|
|
public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
59
|
|
|
{ |
60
|
|
|
return ''; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritDoc} |
65
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
66
|
|
|
*/ |
67
|
|
|
public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
68
|
|
|
{ |
69
|
|
|
$current_user = Auth::check() ? Auth::user() : new DefaultUser(); |
70
|
|
|
if ( |
71
|
|
|
$record instanceof Individual && |
72
|
|
|
$this->sosa_records_service->isSosa($record->tree(), $current_user, $record) |
73
|
|
|
) { |
74
|
|
|
return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
75
|
|
|
} |
76
|
|
|
return ''; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|