1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
4
|
|
|
* |
5
|
|
|
* @package MyArtJaub\Webtrees |
6
|
|
|
* @author Jonathan Jaubart <[email protected]> |
7
|
|
|
* @copyright Copyright (c) 2020, Jonathan Jaubart |
8
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
9
|
|
|
*/ |
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace MyArtJaub\Webtrees\Module; |
13
|
|
|
|
14
|
|
|
use Aura\Router\RouterContainer; |
15
|
|
|
use Fisharebest\Localization\Translation; |
16
|
|
|
use Fisharebest\Webtrees\View; |
17
|
|
|
use Fisharebest\Webtrees\Webtrees; |
18
|
|
|
use Fisharebest\Webtrees\Module\ModuleCustomTrait; |
19
|
|
|
use Fisharebest\Webtrees\Module\ModuleThemeInterface; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* MyArtJaub Module |
23
|
|
|
*/ |
24
|
|
|
trait ModuleMyArtJaubTrait |
25
|
|
|
{ |
26
|
|
|
use ModuleCustomTrait; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::boot() |
30
|
|
|
*/ |
31
|
|
|
public function boot() : void |
32
|
|
|
{ |
33
|
|
|
View::registerNamespace($this->name(), $this->resourcesFolder() . 'views/'); |
|
|
|
|
34
|
|
|
|
35
|
|
|
$this->loadRoutes(app(RouterContainer::class)->getMap()); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::resourcesFolder() |
40
|
|
|
*/ |
41
|
|
|
public function resourcesFolder(): string |
42
|
|
|
{ |
43
|
|
|
return Webtrees::MODULES_DIR . trim($this->name(), '_') . '/resources/'; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleAuthorName() |
48
|
|
|
*/ |
49
|
|
|
public function customModuleAuthorName() : string |
50
|
|
|
{ |
51
|
|
|
return 'Jonathan Jaubart'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl() |
56
|
|
|
*/ |
57
|
|
|
public function customModuleSupportUrl() : string |
58
|
|
|
{ |
59
|
|
|
return 'https://github.com/jon48/webtrees-lib'; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customTranslations() |
64
|
|
|
*/ |
65
|
|
|
public function customTranslations(string $language) : array |
66
|
|
|
{ |
67
|
|
|
$translation_file = $this->resourcesFolder() . 'lang/' . $language . '/messages.php'; |
68
|
|
|
|
69
|
|
|
try { |
70
|
|
|
$translation = new Translation($translation_file); |
71
|
|
|
return $translation->asArray(); |
72
|
|
|
} catch (\Exception $e) { } |
|
|
|
|
73
|
|
|
|
74
|
|
|
return array(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::moduleCssUrl |
79
|
|
|
*/ |
80
|
|
|
public function moduleCssUrl() : string |
81
|
|
|
{ |
82
|
|
|
/** @var ModuleThemeInterface $theme */ |
83
|
|
|
$theme = app(ModuleThemeInterface::class); |
84
|
|
|
$css_file = $this->resourcesFolder() . 'css/' . $theme->name() . '.min.css'; |
85
|
|
|
|
86
|
|
|
if(file_exists($css_file)) { |
87
|
|
|
return $this->assetUrl('css/' . $theme->name() . '.min.css'); |
88
|
|
|
} |
89
|
|
|
else { |
90
|
|
|
return $this->assetUrl('css/default.min.css'); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
} |
95
|
|
|
|