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\GedcomRecord; |
19
|
|
|
use Fisharebest\Webtrees\Individual; |
20
|
|
|
use Fisharebest\Webtrees\Module\ModuleInterface; |
21
|
|
|
use MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface; |
22
|
|
|
use MyArtJaub\Webtrees\Module\Sosa\Services\SosaRecordsService; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Hook for displaying an icon next to Sosa ancestors' display name. |
26
|
|
|
*/ |
27
|
|
|
class SosaIconHook implements RecordNameTextExtenderInterface |
28
|
|
|
{ |
29
|
|
|
private ModuleInterface $module; |
30
|
|
|
private SosaRecordsService $sosa_records_service; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Constructor for SosaIconHook |
34
|
|
|
* |
35
|
|
|
* @param ModuleInterface $module |
36
|
|
|
* @param SosaRecordsService $sosa_records_service |
37
|
|
|
*/ |
38
|
|
|
public function __construct(ModuleInterface $module, SosaRecordsService $sosa_records_service) |
39
|
|
|
{ |
40
|
|
|
$this->module = $module; |
41
|
|
|
$this->sosa_records_service = $sosa_records_service; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritDoc} |
46
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
47
|
|
|
*/ |
48
|
|
|
public function module(): ModuleInterface |
49
|
|
|
{ |
50
|
|
|
return $this->module; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritDoc} |
55
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
56
|
|
|
*/ |
57
|
|
|
public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
58
|
|
|
{ |
59
|
|
|
return ''; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritDoc} |
64
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
65
|
|
|
*/ |
66
|
|
|
public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
67
|
|
|
{ |
68
|
|
|
if ( |
69
|
|
|
$record instanceof Individual && |
70
|
|
|
$this->sosa_records_service->isSosa($record->tree(), Auth::user(), $record) |
71
|
|
|
) { |
72
|
|
|
return view($this->module->name() . '::icons/sosa', [ 'size_style' => $size ]); |
73
|
|
|
} |
74
|
|
|
return ''; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|