|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* webtrees-lib: MyArtJaub library for webtrees |
|
4
|
|
|
* |
|
5
|
|
|
* @package MyArtJaub\Webtrees |
|
6
|
|
|
* @subpackage MiscExtensions |
|
7
|
|
|
* @author Jonathan Jaubart <[email protected]> |
|
8
|
|
|
* @copyright Copyright (c) 2009-2016, Jonathan Jaubart |
|
9
|
|
|
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10
|
|
|
*/ |
|
11
|
|
|
namespace MyArtJaub\Webtrees\Module; |
|
12
|
|
|
|
|
13
|
|
|
use Fisharebest\Webtrees\Auth; |
|
14
|
|
|
use Fisharebest\Webtrees\Controller\IndividualController; |
|
15
|
|
|
use Fisharebest\Webtrees\Filter; |
|
16
|
|
|
use Fisharebest\Webtrees\I18N; |
|
17
|
|
|
use Fisharebest\Webtrees\Module\AbstractModule; |
|
18
|
|
|
use Fisharebest\Webtrees\Module\ModuleConfigInterface; |
|
19
|
|
|
use Fisharebest\Webtrees\Theme; |
|
20
|
|
|
use Fisharebest\Webtrees\User; |
|
21
|
|
|
use MyArtJaub\Webtrees\Functions\FunctionsPrint; |
|
22
|
|
|
use MyArtJaub\Webtrees\Globals; |
|
23
|
|
|
use MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtenderInterface; |
|
24
|
|
|
use MyArtJaub\Webtrees\Hook\HookInterfaces\PageFooterExtenderInterface; |
|
25
|
|
|
use MyArtJaub\Webtrees\Hook\HookInterfaces\PageHeaderExtenderInterface; |
|
26
|
|
|
use MyArtJaub\Webtrees\Hook\HookSubscriberInterface; |
|
27
|
|
|
use MyArtJaub\Webtrees\Individual; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* MiscExtension Module |
|
31
|
|
|
*/ |
|
32
|
|
|
class MiscExtensionsModule extends AbstractModule |
|
33
|
|
|
implements HookSubscriberInterface, IndividualHeaderExtenderInterface, PageHeaderExtenderInterface, PageFooterExtenderInterface, ModuleConfigInterface |
|
34
|
|
|
{ |
|
35
|
|
|
/** @var string For custom modules - link for support, upgrades, etc. */ |
|
36
|
|
|
const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* {@inheritDoc} |
|
40
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
41
|
|
|
*/ |
|
42
|
|
|
public function getTitle() { |
|
43
|
|
|
return I18N::translate('Miscellaneous extensions'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritDoc} |
|
48
|
|
|
* @see \Fisharebest\Webtrees\Module\AbstractModule::getDescription() |
|
49
|
|
|
*/ |
|
50
|
|
|
public function getDescription() { |
|
51
|
|
|
return I18N::translate('Miscellaneous extensions for <strong>webtrees</strong>.'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* {@inhericDoc} |
|
56
|
|
|
*/ |
|
57
|
|
|
public function modAction($mod_action) { |
|
58
|
|
|
\MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* {@inhericDoc} |
|
63
|
|
|
* @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getConfigLink() { |
|
66
|
|
|
return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritDoc} |
|
71
|
|
|
* @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
72
|
|
|
*/ |
|
73
|
|
|
public function getSubscribedHooks() { |
|
74
|
|
|
return array( |
|
75
|
|
|
'hExtendIndiHeaderLeft' => 20, |
|
76
|
|
|
'hPrintHeader' => 20, |
|
77
|
|
|
'hPrintFooter' => 20 |
|
78
|
|
|
); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritDoc} |
|
83
|
|
|
* @see \MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtenderInterface::hExtendIndiHeaderIcons() |
|
84
|
|
|
*/ |
|
85
|
|
|
public function hExtendIndiHeaderIcons(IndividualController $ctrlIndi) { } |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* {@inheritDoc} |
|
89
|
|
|
* @see \MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtenderInterface::hExtendIndiHeaderLeft() |
|
90
|
|
|
*/ |
|
91
|
|
|
public function hExtendIndiHeaderLeft(IndividualController $ctrlIndi) { |
|
92
|
|
|
$res = ''; |
|
93
|
|
|
$dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
|
94
|
|
|
$titles = $dindi->getTitles(); |
|
95
|
|
|
if(count($titles)>0){ |
|
96
|
|
|
$res = ' |
|
97
|
|
|
<dl> |
|
98
|
|
|
<dt class="label">'.I18N::translate('Titles').'</dt>'; |
|
99
|
|
|
foreach($titles as $title=>$props){ |
|
100
|
|
|
$res .= |
|
101
|
|
|
'<dd class="field">' . $title. ' ' . |
|
102
|
|
|
FunctionsPrint::getListFromArray($props) . |
|
103
|
|
|
'</dd>'; |
|
104
|
|
|
} |
|
105
|
|
|
$res .= '</dl>'; |
|
106
|
|
|
} |
|
107
|
|
|
return array( 'indi-header-titles' , $res); |
|
|
|
|
|
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* {@inheritDoc} |
|
112
|
|
|
* @see \MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtenderInterface::hExtendIndiHeaderRight() |
|
113
|
|
|
*/ |
|
114
|
|
|
public function hExtendIndiHeaderRight(IndividualController $ctrlIndi) { } |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* {@inheritDoc} |
|
118
|
|
|
* @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageHeaderExtenderInterface::hPrintHeader() |
|
119
|
|
|
*/ |
|
120
|
|
|
public function hPrintHeader() { |
|
121
|
|
|
$html = ''; |
|
122
|
|
|
if($this->getSetting('MAJ_ADD_HTML_HEADER', 0) == 1){ |
|
123
|
|
|
if(Auth::accessLevel(Globals::getTree()) >= $this->getSetting('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE) && !Filter::getBool('noheader')){ |
|
124
|
|
|
$html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
|
125
|
|
|
} |
|
126
|
|
|
} |
|
127
|
|
|
return $html; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* {@inheritDoc} |
|
132
|
|
|
* @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageFooterExtenderInterface::hPrintFooter() |
|
133
|
|
|
*/ |
|
134
|
|
|
public function hPrintFooter() { |
|
135
|
|
|
$wt_tree = Globals::getTree(); |
|
136
|
|
|
$html = ''; |
|
137
|
|
|
if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
138
|
|
|
$html .= '<br/>'; |
|
139
|
|
|
$html .= '<div class="center">'; |
|
140
|
|
|
$cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
|
141
|
|
|
if($cnil_ref != ''){ |
|
142
|
|
|
$html .= I18N::translate('This site has been notified to the French National Commission for Data protection (CNIL) and registered under number %s. ', $cnil_ref); |
|
143
|
|
|
} |
|
144
|
|
|
$html .= I18N::translate('In accordance with the French Data protection Act (<em>Loi Informatique et Libertés</em>) of January 6th, 1978, you have the right to access, modify, rectify and delete personal information that pertains to you. To exercice this right, please contact %s, and provide your name, address and a proof of your identity.', |
|
145
|
|
|
Theme::theme()->contactLink(User::find($wt_tree->getPreference('WEBMASTER_USER_ID')))); |
|
|
|
|
|
|
146
|
|
|
$html .= '</div>'; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
if($this->getSetting('MAJ_ADD_HTML_FOOTER', 0) == 1){ |
|
150
|
|
|
if(Auth::accessLevel($wt_tree) >= $this->getSetting('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE) && !Filter::getBool('nofooter')){ |
|
151
|
|
|
$html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
|
return $html; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
} |
|
158
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: