|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
5
|
|
|
* |
|
6
|
|
|
* @package MyArtJaub\Webtrees |
|
7
|
|
|
* @subpackage IsSourced |
|
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\IsSourced\Hooks; |
|
16
|
|
|
|
|
17
|
|
|
use Fisharebest\Webtrees\GedcomRecord; |
|
18
|
|
|
use Fisharebest\Webtrees\Individual; |
|
19
|
|
|
use Fisharebest\Webtrees\Module\ModuleInterface; |
|
20
|
|
|
use MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface; |
|
21
|
|
|
use MyArtJaub\Webtrees\Module\IsSourced\Services\SourceStatusService; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Hook for displaying the source status for a record next to its name. |
|
25
|
|
|
*/ |
|
26
|
|
|
class IsSourcedStatusHook implements RecordNameTextExtenderInterface |
|
27
|
|
|
{ |
|
28
|
|
|
private ModuleInterface $module; |
|
29
|
|
|
private SourceStatusService $source_status_service; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Constructor for IsSourcedStatusHook |
|
33
|
|
|
* |
|
34
|
|
|
* @param ModuleInterface $module |
|
35
|
|
|
* @param SourceStatusService $source_status_service |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct(ModuleInterface $module, SourceStatusService $source_status_service) |
|
38
|
|
|
{ |
|
39
|
|
|
$this->module = $module; |
|
40
|
|
|
$this->source_status_service = $source_status_service; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritDoc} |
|
45
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\HookInterface::module() |
|
46
|
|
|
*/ |
|
47
|
|
|
public function module(): ModuleInterface |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->module; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* {@inheritDoc} |
|
54
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNamePrepend() |
|
55
|
|
|
*/ |
|
56
|
|
|
public function recordNamePrepend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
57
|
|
|
{ |
|
58
|
|
|
return ''; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inheritDoc} |
|
63
|
|
|
* @see \MyArtJaub\Webtrees\Contracts\Hooks\RecordNameTextExtenderInterface::recordNameAppend() |
|
64
|
|
|
*/ |
|
65
|
|
|
public function recordNameAppend(GedcomRecord $record, bool $use_long = false, string $size = ''): string |
|
66
|
|
|
{ |
|
67
|
|
|
if ($use_long && $record instanceof Individual) { |
|
68
|
|
|
return view($this->module()->name() . '::hooks/name-append', [ |
|
69
|
|
|
'module_name' => $this->module()->name(), |
|
70
|
|
|
'source_status_service' => $this->source_status_service, |
|
71
|
|
|
'individual' => $record, |
|
72
|
|
|
'size_style' => $size |
|
73
|
|
|
]); |
|
74
|
|
|
} |
|
75
|
|
|
return ''; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|