-
Notifications
You must be signed in to change notification settings - Fork 3
/
PlaceholderModule.php
100 lines (77 loc) · 3.19 KB
/
PlaceholderModule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace Cissee\Webtrees\Module\SharedPlaces;
use Cissee\WebtreesExt\AbstractModule;
use Cissee\WebtreesExt\Module\ModuleMetaInterface;
use Cissee\WebtreesExt\Module\ModuleMetaTrait;
use Fisharebest\Webtrees\FlashMessages;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
use Fisharebest\Webtrees\Module\ModuleCustomTrait;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Webtrees;
use Vesta\CommonI18N;
use Vesta\VestaModuleTrait;
class PlaceholderModule extends AbstractModule implements
ModuleCustomInterface,
ModuleMetaInterface {
use ModuleCustomTrait, ModuleMetaTrait, VestaModuleTrait {
VestaModuleTrait::customTranslations insteadof ModuleCustomTrait;
VestaModuleTrait::getAssetAction insteadof ModuleCustomTrait;
VestaModuleTrait::assetUrl insteadof ModuleCustomTrait;
ModuleMetaTrait::customModuleVersion insteadof ModuleCustomTrait;
ModuleMetaTrait::customModuleLatestVersion insteadof ModuleCustomTrait;
}
////////
use SharedPlacesModuleTrait;
public function customModuleLatestMetaDatasJsonUrl(): string {
return 'https://raw.githubusercontent.com/vesta-webtrees-2-custom-modules/vesta_shared_places/master/metadata.json';
}
////////
public function customModuleMetaDatasJson(): string {
return file_get_contents(__DIR__ . '/metadata.json');
}
public function customModuleAuthorName(): string {
return 'Richard Cissée';
}
public function customModuleSupportUrl(): string {
return 'https://cissee.de';
}
public function description(): string {
$min_version = $this->minRequiredWebtreesVersion();
//min version check
$version_ok = version_compare(Webtrees::VERSION, $min_version) >= 0;
if (!$version_ok) {
return CommonI18N::noopModuleMin($min_version);
}
$max_version = $this->minUnsupportedWebtreesVersion();
//max version check (allow current dev version though)
$version_ok = (Webtrees::VERSION === $max_version.'-dev') || (version_compare($max_version, Webtrees::VERSION) > 0);
if (!$version_ok) {
return CommonI18N::noopModuleMax($max_version);
}
return '';
}
public function ifIncompatible(): ?PlaceholderModule {
$min_version = $this->minRequiredWebtreesVersion();
//min version check
$version_ok = version_compare(Webtrees::VERSION, $min_version) >= 0;
if (!$version_ok) {
return $this;
}
$max_version = $this->minUnsupportedWebtreesVersion();
//max version check (allow current dev version though)
$version_ok = (Webtrees::VERSION === $max_version.'-dev') || (version_compare($max_version, Webtrees::VERSION) > 0);
if (!$version_ok) {
return $this;
}
return null;
}
public function boot(): void {
//flash, but only once per day
$title = $this->title();
$cache = Registry::cache()->file();
$key = $title . '-placeholder-flash';
$cache->remember($key, function () use ($title) {
FlashMessages::addMessage(CommonI18N::noopModuleMessage($title));
}, 24*3600);
}
}