@@ -27,52 +27,52 @@ |
||
27 | 27 | */ |
28 | 28 | class AdminConfigController extends MvcController |
29 | 29 | { |
30 | - /** |
|
31 | - * Manage updates sent from the AdminConfig@index form. |
|
32 | - */ |
|
33 | - protected function update() { |
|
34 | - if(Auth::isAdmin()){ |
|
30 | + /** |
|
31 | + * Manage updates sent from the AdminConfig@index form. |
|
32 | + */ |
|
33 | + protected function update() { |
|
34 | + if(Auth::isAdmin()){ |
|
35 | 35 | |
36 | - $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
|
36 | + $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
|
37 | 37 | |
38 | - $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1)); |
|
39 | - $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
40 | - $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER')); |
|
38 | + $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1)); |
|
39 | + $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
40 | + $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER')); |
|
41 | 41 | |
42 | - $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1)); |
|
43 | - $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
44 | - $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER')); |
|
42 | + $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1)); |
|
43 | + $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE)); |
|
44 | + $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER')); |
|
45 | 45 | |
46 | - $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1)); |
|
47 | - $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE')); |
|
46 | + $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1)); |
|
47 | + $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE')); |
|
48 | 48 | |
49 | - FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); |
|
49 | + FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success'); |
|
50 | 50 | |
51 | - return; |
|
52 | - } |
|
53 | - } |
|
51 | + return; |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Pages |
|
57 | - */ |
|
55 | + /** |
|
56 | + * Pages |
|
57 | + */ |
|
58 | 58 | |
59 | - /** |
|
60 | - * AdminConfig@index |
|
61 | - */ |
|
62 | - public function index() { |
|
63 | - $action = Filter::post('action'); |
|
64 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
59 | + /** |
|
60 | + * AdminConfig@index |
|
61 | + */ |
|
62 | + public function index() { |
|
63 | + $action = Filter::post('action'); |
|
64 | + if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
65 | 65 | |
66 | - Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
|
67 | - $ctrl = new PageController(); |
|
68 | - $ctrl |
|
69 | - ->restrictAccess(Auth::isAdmin()) |
|
70 | - ->setPageTitle($this->module->getTitle()); |
|
66 | + Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
|
67 | + $ctrl = new PageController(); |
|
68 | + $ctrl |
|
69 | + ->restrictAccess(Auth::isAdmin()) |
|
70 | + ->setPageTitle($this->module->getTitle()); |
|
71 | 71 | |
72 | - $view_bag = new ViewBag(); |
|
73 | - $view_bag->set('title', $ctrl->getPageTitle()); |
|
74 | - $view_bag->set('module', $this->module); |
|
72 | + $view_bag = new ViewBag(); |
|
73 | + $view_bag->set('title', $ctrl->getPageTitle()); |
|
74 | + $view_bag->set('module', $this->module); |
|
75 | 75 | |
76 | - ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
77 | - } |
|
76 | + ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | \ No newline at end of file |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * Manage updates sent from the AdminConfig@index form. |
32 | 32 | */ |
33 | 33 | protected function update() { |
34 | - if(Auth::isAdmin()){ |
|
34 | + if (Auth::isAdmin()) { |
|
35 | 35 | |
36 | 36 | $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX')); |
37 | 37 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function index() { |
63 | 63 | $action = Filter::post('action'); |
64 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
64 | + if ($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
65 | 65 | |
66 | 66 | Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
67 | 67 | $ctrl = new PageController(); |
@@ -61,7 +61,9 @@ |
||
61 | 61 | */ |
62 | 62 | public function index() { |
63 | 63 | $action = Filter::post('action'); |
64 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
64 | + if($action == 'update' && Filter::checkCsrf()) { |
|
65 | + $this->update(); |
|
66 | + } |
|
65 | 67 | |
66 | 68 | Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
67 | 69 | $ctrl = new PageController(); |
@@ -30,87 +30,87 @@ discard block |
||
30 | 30 | */ |
31 | 31 | class AdminConfigController extends MvcController |
32 | 32 | { |
33 | - /** |
|
34 | - * Manage updates sent from the AdminConfig@index form. |
|
35 | - */ |
|
36 | - protected function update() { |
|
37 | - if(Auth::isAdmin()){ |
|
38 | - $ihooks = HookProvider::getInstance()->getInstalledHooks(); |
|
33 | + /** |
|
34 | + * Manage updates sent from the AdminConfig@index form. |
|
35 | + */ |
|
36 | + protected function update() { |
|
37 | + if(Auth::isAdmin()){ |
|
38 | + $ihooks = HookProvider::getInstance()->getInstalledHooks(); |
|
39 | 39 | |
40 | - $module_names= Database::prepare( |
|
41 | - "SELECT module_name FROM `##module` WHERE status='disabled'" |
|
42 | - )->fetchOneColumn(); |
|
40 | + $module_names= Database::prepare( |
|
41 | + "SELECT module_name FROM `##module` WHERE status='disabled'" |
|
42 | + )->fetchOneColumn(); |
|
43 | 43 | |
44 | - if($ihooks !== null){ |
|
45 | - foreach ($ihooks as $ihook => $params) { |
|
46 | - if(Filter::post('hook-' . $params['id']) === 'yes') { |
|
47 | - $array_hook = explode('#', $ihook); |
|
48 | - //Update status |
|
49 | - $new_status= Filter::postBool('status-' . $params['id']); |
|
50 | - if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
51 | - $previous_status = $params['status']; |
|
52 | - if ($new_status !== null) { |
|
53 | - $new_status= $new_status ? 'enabled' : 'disabled'; |
|
54 | - if($new_status != $previous_status){ |
|
55 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
56 | - switch($new_status){ |
|
57 | - case 'enabled': |
|
58 | - $chook->enable($array_hook[0]); |
|
59 | - break; |
|
60 | - case 'disabled': |
|
61 | - $chook->disable($array_hook[0]); |
|
62 | - break; |
|
63 | - default: |
|
64 | - break; |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
44 | + if($ihooks !== null){ |
|
45 | + foreach ($ihooks as $ihook => $params) { |
|
46 | + if(Filter::post('hook-' . $params['id']) === 'yes') { |
|
47 | + $array_hook = explode('#', $ihook); |
|
48 | + //Update status |
|
49 | + $new_status= Filter::postBool('status-' . $params['id']); |
|
50 | + if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
51 | + $previous_status = $params['status']; |
|
52 | + if ($new_status !== null) { |
|
53 | + $new_status= $new_status ? 'enabled' : 'disabled'; |
|
54 | + if($new_status != $previous_status){ |
|
55 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
56 | + switch($new_status){ |
|
57 | + case 'enabled': |
|
58 | + $chook->enable($array_hook[0]); |
|
59 | + break; |
|
60 | + case 'disabled': |
|
61 | + $chook->disable($array_hook[0]); |
|
62 | + break; |
|
63 | + default: |
|
64 | + break; |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - //Update priority |
|
70 | - $new_priority = Filter::postInteger("moduleorder-{$params['id']}"); |
|
71 | - $previous_priority = $params['priority']; |
|
72 | - if ($new_priority !== null) { |
|
73 | - if($new_priority != $previous_priority){ |
|
74 | - $chook = new Hook($array_hook[1], $array_hook[2]); |
|
75 | - $chook->setPriority($array_hook[0], $new_priority); |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - } |
|
69 | + //Update priority |
|
70 | + $new_priority = Filter::postInteger("moduleorder-{$params['id']}"); |
|
71 | + $previous_priority = $params['priority']; |
|
72 | + if ($new_priority !== null) { |
|
73 | + if($new_priority != $previous_priority){ |
|
74 | + $chook = new Hook($array_hook[1], $array_hook[2]); |
|
75 | + $chook->setPriority($array_hook[0], $new_priority); |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * Pages |
|
86 | - */ |
|
84 | + /** |
|
85 | + * Pages |
|
86 | + */ |
|
87 | 87 | |
88 | - /** |
|
89 | - * AdminConfig@index |
|
90 | - */ |
|
91 | - public function index() { |
|
92 | - HookProvider::getInstance()->updateHooks(); |
|
88 | + /** |
|
89 | + * AdminConfig@index |
|
90 | + */ |
|
91 | + public function index() { |
|
92 | + HookProvider::getInstance()->updateHooks(); |
|
93 | 93 | |
94 | - $action = Filter::post('action'); |
|
95 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
94 | + $action = Filter::post('action'); |
|
95 | + if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
96 | 96 | |
97 | - Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
|
98 | - $ctrl = new PageController(); |
|
99 | - $ctrl |
|
100 | - ->restrictAccess(Auth::isAdmin()) |
|
101 | - ->setPageTitle($this->module->getTitle()); |
|
97 | + Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
|
98 | + $ctrl = new PageController(); |
|
99 | + $ctrl |
|
100 | + ->restrictAccess(Auth::isAdmin()) |
|
101 | + ->setPageTitle($this->module->getTitle()); |
|
102 | 102 | |
103 | - $table_id = 'table-installedhooks-' . Uuid::uuid4(); |
|
103 | + $table_id = 'table-installedhooks-' . Uuid::uuid4(); |
|
104 | 104 | |
105 | - $view_bag = new ViewBag(); |
|
106 | - $view_bag->set('title', $ctrl->getPageTitle()); |
|
107 | - $view_bag->set('table_id', $table_id); |
|
108 | - $view_bag->set('hook_list', HookProvider::getInstance()->getRawInstalledHooks()); |
|
105 | + $view_bag = new ViewBag(); |
|
106 | + $view_bag->set('title', $ctrl->getPageTitle()); |
|
107 | + $view_bag->set('table_id', $table_id); |
|
108 | + $view_bag->set('hook_list', HookProvider::getInstance()->getRawInstalledHooks()); |
|
109 | 109 | |
110 | - $ctrl |
|
111 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
112 | - ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
113 | - ->addInlineJavascript(' |
|
110 | + $ctrl |
|
111 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
112 | + ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) |
|
113 | + ->addInlineJavascript(' |
|
114 | 114 | jQuery(document).ready(function() { |
115 | 115 | jQuery("#'.$table_id.'").dataTable( { |
116 | 116 | '.I18N::datatablesI18N().', |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | }); |
131 | 131 | '); |
132 | 132 | |
133 | - ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
134 | - } |
|
133 | + ViewFactory::make('AdminConfig', $this, $ctrl, $view_bag)->render(); |
|
134 | + } |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | \ No newline at end of file |
@@ -34,26 +34,26 @@ discard block |
||
34 | 34 | * Manage updates sent from the AdminConfig@index form. |
35 | 35 | */ |
36 | 36 | protected function update() { |
37 | - if(Auth::isAdmin()){ |
|
37 | + if (Auth::isAdmin()) { |
|
38 | 38 | $ihooks = HookProvider::getInstance()->getInstalledHooks(); |
39 | 39 | |
40 | - $module_names= Database::prepare( |
|
40 | + $module_names = Database::prepare( |
|
41 | 41 | "SELECT module_name FROM `##module` WHERE status='disabled'" |
42 | 42 | )->fetchOneColumn(); |
43 | 43 | |
44 | - if($ihooks !== null){ |
|
44 | + if ($ihooks !== null) { |
|
45 | 45 | foreach ($ihooks as $ihook => $params) { |
46 | - if(Filter::post('hook-' . $params['id']) === 'yes') { |
|
46 | + if (Filter::post('hook-'.$params['id']) === 'yes') { |
|
47 | 47 | $array_hook = explode('#', $ihook); |
48 | 48 | //Update status |
49 | - $new_status= Filter::postBool('status-' . $params['id']); |
|
50 | - if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
49 | + $new_status = Filter::postBool('status-'.$params['id']); |
|
50 | + if (in_array($array_hook[0], $module_names)) $new_status = false; |
|
51 | 51 | $previous_status = $params['status']; |
52 | 52 | if ($new_status !== null) { |
53 | - $new_status= $new_status ? 'enabled' : 'disabled'; |
|
54 | - if($new_status != $previous_status){ |
|
53 | + $new_status = $new_status ? 'enabled' : 'disabled'; |
|
54 | + if ($new_status != $previous_status) { |
|
55 | 55 | $chook = new Hook($array_hook[1], $array_hook[2]); |
56 | - switch($new_status){ |
|
56 | + switch ($new_status) { |
|
57 | 57 | case 'enabled': |
58 | 58 | $chook->enable($array_hook[0]); |
59 | 59 | break; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $new_priority = Filter::postInteger("moduleorder-{$params['id']}"); |
71 | 71 | $previous_priority = $params['priority']; |
72 | 72 | if ($new_priority !== null) { |
73 | - if($new_priority != $previous_priority){ |
|
73 | + if ($new_priority != $previous_priority) { |
|
74 | 74 | $chook = new Hook($array_hook[1], $array_hook[2]); |
75 | 75 | $chook->setPriority($array_hook[0], $new_priority); |
76 | 76 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | HookProvider::getInstance()->updateHooks(); |
93 | 93 | |
94 | 94 | $action = Filter::post('action'); |
95 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
95 | + if ($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
96 | 96 | |
97 | 97 | Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
98 | 98 | $ctrl = new PageController(); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | ->restrictAccess(Auth::isAdmin()) |
101 | 101 | ->setPageTitle($this->module->getTitle()); |
102 | 102 | |
103 | - $table_id = 'table-installedhooks-' . Uuid::uuid4(); |
|
103 | + $table_id = 'table-installedhooks-'.Uuid::uuid4(); |
|
104 | 104 | |
105 | 105 | $view_bag = new ViewBag(); |
106 | 106 | $view_bag->set('title', $ctrl->getPageTitle()); |
@@ -47,7 +47,9 @@ discard block |
||
47 | 47 | $array_hook = explode('#', $ihook); |
48 | 48 | //Update status |
49 | 49 | $new_status= Filter::postBool('status-' . $params['id']); |
50 | - if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
50 | + if(in_array($array_hook[0], $module_names)) { |
|
51 | + $new_status = false; |
|
52 | + } |
|
51 | 53 | $previous_status = $params['status']; |
52 | 54 | if ($new_status !== null) { |
53 | 55 | $new_status= $new_status ? 'enabled' : 'disabled'; |
@@ -92,7 +94,9 @@ discard block |
||
92 | 94 | HookProvider::getInstance()->updateHooks(); |
93 | 95 | |
94 | 96 | $action = Filter::post('action'); |
95 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
97 | + if($action == 'update' && Filter::checkCsrf()) { |
|
98 | + $this->update(); |
|
99 | + } |
|
96 | 100 | |
97 | 101 | Theme::theme(new AdministrationTheme)->init(Globals::getTree()); |
98 | 102 | $ctrl = new PageController(); |
@@ -32,49 +32,49 @@ discard block |
||
32 | 32 | class MiscExtensionsModule extends AbstractModule |
33 | 33 | implements HookSubscriberInterface, IndividualHeaderExtenderInterface, PageHeaderExtenderInterface, PageFooterExtenderInterface, ModuleConfigInterface |
34 | 34 | { |
35 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
35 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
36 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * {@inheritDoc} |
|
40 | - * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
41 | - */ |
|
42 | - public function getTitle() { |
|
43 | - return I18N::translate('Miscellaneous extensions'); |
|
44 | - } |
|
38 | + /** |
|
39 | + * {@inheritDoc} |
|
40 | + * @see \Fisharebest\Webtrees\Module\AbstractModule::getTitle() |
|
41 | + */ |
|
42 | + public function getTitle() { |
|
43 | + return I18N::translate('Miscellaneous extensions'); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | /** |
47 | 47 | * {@inheritDoc} |
48 | 48 | * @see \Fisharebest\Webtrees\Module\AbstractModule::getDescription() |
49 | 49 | */ |
50 | - public function getDescription() { |
|
51 | - return I18N::translate('Miscellaneous extensions for <strong>webtrees</strong>.'); |
|
52 | - } |
|
50 | + public function getDescription() { |
|
51 | + return I18N::translate('Miscellaneous extensions for <strong>webtrees</strong>.'); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * {@inhericDoc} |
|
56 | - */ |
|
57 | - public function modAction($mod_action) { |
|
58 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
59 | - } |
|
54 | + /** |
|
55 | + * {@inhericDoc} |
|
56 | + */ |
|
57 | + public function modAction($mod_action) { |
|
58 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
59 | + } |
|
60 | 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 | - } |
|
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 | 68 | |
69 | - /** |
|
70 | - * {@inheritDoc} |
|
71 | - * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
72 | - */ |
|
69 | + /** |
|
70 | + * {@inheritDoc} |
|
71 | + * @see \MyArtJaub\Webtrees\Hook\HookSubscriberInterface::getSubscribedHooks() |
|
72 | + */ |
|
73 | 73 | public function getSubscribedHooks() { |
74 | 74 | return array( |
75 | - 'hExtendIndiHeaderLeft' => 20, |
|
76 | - 'hPrintHeader' => 20, |
|
77 | - 'hPrintFooter' => 20 |
|
75 | + 'hExtendIndiHeaderLeft' => 20, |
|
76 | + 'hPrintHeader' => 20, |
|
77 | + 'hPrintFooter' => 20 |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
@@ -89,22 +89,22 @@ discard block |
||
89 | 89 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\IndividualHeaderExtenderInterface::hExtendIndiHeaderLeft() |
90 | 90 | */ |
91 | 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 = ' |
|
92 | + $res = ''; |
|
93 | + $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
|
94 | + $titles = $dindi->getTitles(); |
|
95 | + if(count($titles)>0){ |
|
96 | + $res = ' |
|
97 | 97 | <dl> |
98 | 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); |
|
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 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageHeaderExtenderInterface::hPrintHeader() |
119 | 119 | */ |
120 | 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; |
|
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 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -132,26 +132,26 @@ discard block |
||
132 | 132 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\PageFooterExtenderInterface::hPrintFooter() |
133 | 133 | */ |
134 | 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 | - } |
|
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 | 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; |
|
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 | 155 | } |
156 | 156 | |
157 | 157 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
64 | 64 | */ |
65 | 65 | public function getConfigLink() { |
66 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
66 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | $res = ''; |
93 | 93 | $dindi = new Individual($ctrlIndi->getSignificantIndividual()); |
94 | 94 | $titles = $dindi->getTitles(); |
95 | - if(count($titles)>0){ |
|
95 | + if (count($titles) > 0) { |
|
96 | 96 | $res = ' |
97 | 97 | <dl> |
98 | 98 | <dt class="label">'.I18N::translate('Titles').'</dt>'; |
99 | - foreach($titles as $title=>$props){ |
|
99 | + foreach ($titles as $title=>$props) { |
|
100 | 100 | $res .= |
101 | - '<dd class="field">' . $title. ' ' . |
|
102 | - FunctionsPrint::getListFromArray($props) . |
|
101 | + '<dd class="field">'.$title.' '. |
|
102 | + FunctionsPrint::getListFromArray($props). |
|
103 | 103 | '</dd>'; |
104 | 104 | } |
105 | - $res .= '</dl>'; |
|
105 | + $res .= '</dl>'; |
|
106 | 106 | } |
107 | - return array( 'indi-header-titles' , $res); |
|
107 | + return array('indi-header-titles', $res); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function hPrintHeader() { |
121 | 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')){ |
|
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 | 124 | $html .= $this->getSetting('MAJ_HTML_HEADER', ''); |
125 | 125 | } |
126 | 126 | } |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | public function hPrintFooter() { |
135 | 135 | $wt_tree = Globals::getTree(); |
136 | 136 | $html = ''; |
137 | - if($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1){ |
|
137 | + if ($this->getSetting('MAJ_DISPLAY_CNIL', 0) == 1) { |
|
138 | 138 | $html .= '<br/>'; |
139 | 139 | $html .= '<div class="center">'; |
140 | 140 | $cnil_ref = $this->getSetting('MAJ_CNIL_REFERENCE', ''); |
141 | - if($cnil_ref != ''){ |
|
141 | + if ($cnil_ref != '') { |
|
142 | 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 | 143 | } |
144 | 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.', |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | $html .= '</div>'; |
147 | 147 | } |
148 | 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')){ |
|
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 | 151 | $html .= $this->getSetting('MAJ_HTML_FOOTER', ''); |
152 | 152 | } |
153 | 153 | } |
@@ -16,48 +16,48 @@ |
||
16 | 16 | */ |
17 | 17 | class Globals { |
18 | 18 | |
19 | - /** |
|
20 | - * Get global $WT_TREE variable. |
|
21 | - * |
|
22 | - * @return \Fisharebest\Webtrees\Tree |
|
23 | - */ |
|
24 | - public static function getTree() { |
|
25 | - global $WT_TREE; |
|
19 | + /** |
|
20 | + * Get global $WT_TREE variable. |
|
21 | + * |
|
22 | + * @return \Fisharebest\Webtrees\Tree |
|
23 | + */ |
|
24 | + public static function getTree() { |
|
25 | + global $WT_TREE; |
|
26 | 26 | |
27 | - return $WT_TREE; |
|
28 | - } |
|
27 | + return $WT_TREE; |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Check whether the visitor is a bot. |
|
32 | - * |
|
33 | - * @return boolean |
|
34 | - */ |
|
35 | - public static function isSearchSpider() { |
|
36 | - global $SEARCH_SPIDER; |
|
30 | + /** |
|
31 | + * Check whether the visitor is a bot. |
|
32 | + * |
|
33 | + * @return boolean |
|
34 | + */ |
|
35 | + public static function isSearchSpider() { |
|
36 | + global $SEARCH_SPIDER; |
|
37 | 37 | |
38 | - return $SEARCH_SPIDER; |
|
39 | - } |
|
38 | + return $SEARCH_SPIDER; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get the current controller. |
|
43 | - * |
|
44 | - * @return \Fisharebest\Webtrees\BaseController |
|
45 | - */ |
|
46 | - public static function getController() { |
|
47 | - global $controller; |
|
41 | + /** |
|
42 | + * Get the current controller. |
|
43 | + * |
|
44 | + * @return \Fisharebest\Webtrees\BaseController |
|
45 | + */ |
|
46 | + public static function getController() { |
|
47 | + global $controller; |
|
48 | 48 | |
49 | - return $controller; |
|
50 | - } |
|
49 | + return $controller; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Get the global facts |
|
54 | - * |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public static function getGlobalFacts() { |
|
58 | - global $global_facts; |
|
52 | + /** |
|
53 | + * Get the global facts |
|
54 | + * |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public static function getGlobalFacts() { |
|
58 | + global $global_facts; |
|
59 | 59 | |
60 | - return $global_facts; |
|
61 | - } |
|
60 | + return $global_facts; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | } |
@@ -24,68 +24,68 @@ |
||
24 | 24 | class LineageRootNode extends LineageNode |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var Collection $places Places for the lineage node |
|
29 | - */ |
|
30 | - private $places; |
|
27 | + /** |
|
28 | + * @var Collection $places Places for the lineage node |
|
29 | + */ |
|
30 | + private $places; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var int $nb_children Number of node childs |
|
34 | - */ |
|
35 | - private $nb_children; |
|
32 | + /** |
|
33 | + * @var int $nb_children Number of node childs |
|
34 | + */ |
|
35 | + private $nb_children; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for LineageRootNode |
|
39 | - * |
|
40 | - * @param Individual|null $node_indi |
|
41 | - */ |
|
42 | - public function __construct(?Individual $node_indi = null) |
|
43 | - { |
|
44 | - parent::__construct($node_indi, $this); |
|
45 | - $this->places = new Collection(); |
|
46 | - $this->nb_children = 0; |
|
47 | - } |
|
37 | + /** |
|
38 | + * Constructor for LineageRootNode |
|
39 | + * |
|
40 | + * @param Individual|null $node_indi |
|
41 | + */ |
|
42 | + public function __construct(?Individual $node_indi = null) |
|
43 | + { |
|
44 | + parent::__construct($node_indi, $this); |
|
45 | + $this->places = new Collection(); |
|
46 | + $this->nb_children = 0; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Adds a place to the list of lineage's place |
|
51 | - * |
|
52 | - * @param Place $place |
|
53 | - */ |
|
54 | - public function addPlace(Place $place): void |
|
55 | - { |
|
56 | - $place_name = $place->gedcomName(); |
|
57 | - if (mb_strlen($place_name) > 0) { |
|
58 | - $this->places->put($place_name, $this->places->get($place_name, 0) + 1); |
|
59 | - } |
|
60 | - } |
|
49 | + /** |
|
50 | + * Adds a place to the list of lineage's place |
|
51 | + * |
|
52 | + * @param Place $place |
|
53 | + */ |
|
54 | + public function addPlace(Place $place): void |
|
55 | + { |
|
56 | + $place_name = $place->gedcomName(); |
|
57 | + if (mb_strlen($place_name) > 0) { |
|
58 | + $this->places->put($place_name, $this->places->get($place_name, 0) + 1); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Returns the number of child nodes. |
|
64 | - * This number is more to be used as indication rather than an accurate one. |
|
65 | - * |
|
66 | - * @return int |
|
67 | - */ |
|
68 | - public function numberChildNodes(): int |
|
69 | - { |
|
70 | - return $this->nb_children; |
|
71 | - } |
|
62 | + /** |
|
63 | + * Returns the number of child nodes. |
|
64 | + * This number is more to be used as indication rather than an accurate one. |
|
65 | + * |
|
66 | + * @return int |
|
67 | + */ |
|
68 | + public function numberChildNodes(): int |
|
69 | + { |
|
70 | + return $this->nb_children; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Increments the number of child nodes by one |
|
75 | - * |
|
76 | - */ |
|
77 | - public function incrementChildNodes(): void |
|
78 | - { |
|
79 | - $this->nb_children++; |
|
80 | - } |
|
73 | + /** |
|
74 | + * Increments the number of child nodes by one |
|
75 | + * |
|
76 | + */ |
|
77 | + public function incrementChildNodes(): void |
|
78 | + { |
|
79 | + $this->nb_children++; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Returns the list of place for the lineage |
|
84 | - * |
|
85 | - * @return Collection |
|
86 | - */ |
|
87 | - public function places(): Collection |
|
88 | - { |
|
89 | - return $this->places; |
|
90 | - } |
|
82 | + /** |
|
83 | + * Returns the list of place for the lineage |
|
84 | + * |
|
85 | + * @return Collection |
|
86 | + */ |
|
87 | + public function places(): Collection |
|
88 | + { |
|
89 | + return $this->places; |
|
90 | + } |
|
91 | 91 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function addFamily(Family $fams): object |
69 | 69 | { |
70 | 70 | if (!$this->linked_fams->has($fams->xref())) { |
71 | - $this->linked_fams->put($fams->xref(), (object) [ |
|
71 | + $this->linked_fams->put($fams->xref(), (object)[ |
|
72 | 72 | 'family' => $fams, |
73 | 73 | 'children' => new Collection() |
74 | 74 | ]); |
@@ -135,6 +135,6 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function hasFollowUpSurname(): bool |
137 | 137 | { |
138 | - return mb_strlen($this->followUpSurname()) > 0 ; |
|
138 | + return mb_strlen($this->followUpSurname()) > 0; |
|
139 | 139 | } |
140 | 140 | } |
@@ -25,117 +25,117 @@ |
||
25 | 25 | class LineageNode |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * @var Collection $linked_fams Spouse families linked to the node |
|
30 | - */ |
|
31 | - private $linked_fams; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var ?Individual $node_indi Reference individual for the node |
|
35 | - */ |
|
36 | - private $node_indi; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var LineageRootNode $root_node Root node of the lineage |
|
40 | - */ |
|
41 | - private $root_node; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var ?string $alt_surname Linked surname, used to link to another lineage |
|
45 | - */ |
|
46 | - private $alt_surname; |
|
47 | - |
|
48 | - /** |
|
49 | - * Constructor for Lineage node |
|
50 | - * |
|
51 | - * @param Individual $node_indi Main individual |
|
52 | - * @param LineageRootNode $root_node Node of the lineage root |
|
53 | - * @param null|string $alt_surname Follow-up surname |
|
54 | - */ |
|
55 | - public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null) |
|
56 | - { |
|
57 | - $this->node_indi = $node_indi; |
|
58 | - $this->root_node = $root_node; |
|
59 | - $this->alt_surname = $alt_surname; |
|
60 | - $this->linked_fams = new Collection(); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Add a spouse family to the node |
|
65 | - * |
|
66 | - * @param Family $fams |
|
67 | - * @return stdClass |
|
68 | - */ |
|
69 | - public function addFamily(Family $fams): object |
|
70 | - { |
|
71 | - if (!$this->linked_fams->has($fams->xref())) { |
|
72 | - $this->linked_fams->put($fams->xref(), (object) [ |
|
73 | - 'family' => $fams, |
|
74 | - 'children' => new Collection() |
|
75 | - ]); |
|
76 | - } |
|
77 | - return $this->linked_fams->get($fams->xref()); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Add a child LineageNode to the node |
|
82 | - * |
|
83 | - * @param Family $fams |
|
84 | - * @param LineageNode $child |
|
85 | - */ |
|
86 | - public function addChild(Family $fams, LineageNode $child = null): void |
|
87 | - { |
|
88 | - $this->addFamily($fams)->children->push($child); |
|
89 | - $this->root_node->incrementChildNodes(); |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Returns the node individual |
|
94 | - * |
|
95 | - * @return Individual|NULL |
|
96 | - */ |
|
97 | - public function individual(): ?Individual |
|
98 | - { |
|
99 | - return $this->node_indi; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Returns the lineage root node individual |
|
104 | - * |
|
105 | - * @return LineageRootNode |
|
106 | - */ |
|
107 | - public function rootNode(): LineageRootNode |
|
108 | - { |
|
109 | - return $this->root_node; |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Returns the spouse families linked to the node |
|
114 | - * |
|
115 | - * @return Collection |
|
116 | - */ |
|
117 | - public function families(): Collection |
|
118 | - { |
|
119 | - return $this->linked_fams; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Returns the follow-up surname |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function followUpSurname(): string |
|
128 | - { |
|
129 | - return $this->alt_surname ?? ''; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Indicates whether the node has a follow up surname |
|
134 | - * |
|
135 | - * @return boolean |
|
136 | - */ |
|
137 | - public function hasFollowUpSurname(): bool |
|
138 | - { |
|
139 | - return mb_strlen($this->followUpSurname()) > 0 ; |
|
140 | - } |
|
28 | + /** |
|
29 | + * @var Collection $linked_fams Spouse families linked to the node |
|
30 | + */ |
|
31 | + private $linked_fams; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var ?Individual $node_indi Reference individual for the node |
|
35 | + */ |
|
36 | + private $node_indi; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var LineageRootNode $root_node Root node of the lineage |
|
40 | + */ |
|
41 | + private $root_node; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var ?string $alt_surname Linked surname, used to link to another lineage |
|
45 | + */ |
|
46 | + private $alt_surname; |
|
47 | + |
|
48 | + /** |
|
49 | + * Constructor for Lineage node |
|
50 | + * |
|
51 | + * @param Individual $node_indi Main individual |
|
52 | + * @param LineageRootNode $root_node Node of the lineage root |
|
53 | + * @param null|string $alt_surname Follow-up surname |
|
54 | + */ |
|
55 | + public function __construct(?Individual $node_indi = null, LineageRootNode $root_node, $alt_surname = null) |
|
56 | + { |
|
57 | + $this->node_indi = $node_indi; |
|
58 | + $this->root_node = $root_node; |
|
59 | + $this->alt_surname = $alt_surname; |
|
60 | + $this->linked_fams = new Collection(); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Add a spouse family to the node |
|
65 | + * |
|
66 | + * @param Family $fams |
|
67 | + * @return stdClass |
|
68 | + */ |
|
69 | + public function addFamily(Family $fams): object |
|
70 | + { |
|
71 | + if (!$this->linked_fams->has($fams->xref())) { |
|
72 | + $this->linked_fams->put($fams->xref(), (object) [ |
|
73 | + 'family' => $fams, |
|
74 | + 'children' => new Collection() |
|
75 | + ]); |
|
76 | + } |
|
77 | + return $this->linked_fams->get($fams->xref()); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Add a child LineageNode to the node |
|
82 | + * |
|
83 | + * @param Family $fams |
|
84 | + * @param LineageNode $child |
|
85 | + */ |
|
86 | + public function addChild(Family $fams, LineageNode $child = null): void |
|
87 | + { |
|
88 | + $this->addFamily($fams)->children->push($child); |
|
89 | + $this->root_node->incrementChildNodes(); |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Returns the node individual |
|
94 | + * |
|
95 | + * @return Individual|NULL |
|
96 | + */ |
|
97 | + public function individual(): ?Individual |
|
98 | + { |
|
99 | + return $this->node_indi; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Returns the lineage root node individual |
|
104 | + * |
|
105 | + * @return LineageRootNode |
|
106 | + */ |
|
107 | + public function rootNode(): LineageRootNode |
|
108 | + { |
|
109 | + return $this->root_node; |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Returns the spouse families linked to the node |
|
114 | + * |
|
115 | + * @return Collection |
|
116 | + */ |
|
117 | + public function families(): Collection |
|
118 | + { |
|
119 | + return $this->linked_fams; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Returns the follow-up surname |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function followUpSurname(): string |
|
128 | + { |
|
129 | + return $this->alt_surname ?? ''; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Indicates whether the node has a follow up surname |
|
134 | + * |
|
135 | + * @return boolean |
|
136 | + */ |
|
137 | + public function hasFollowUpSurname(): bool |
|
138 | + { |
|
139 | + return mb_strlen($this->followUpSurname()) > 0 ; |
|
140 | + } |
|
141 | 141 | } |
@@ -107,7 +107,7 @@ |
||
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - return $root_lineages->sort(function (LineageRootNode $a, LineageRootNode $b) { |
|
110 | + return $root_lineages->sort(function(LineageRootNode $a, LineageRootNode $b) { |
|
111 | 111 | |
112 | 112 | if ($a->numberChildNodes() == $b->numberChildNodes()) { |
113 | 113 | return 0; |
@@ -29,221 +29,221 @@ |
||
29 | 29 | class LineageBuilder |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var string $surname Reference surname |
|
34 | - */ |
|
35 | - private $surname; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var Tree $tree Reference tree |
|
39 | - */ |
|
40 | - private $tree; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var IndividualListModule|null $indilist_module |
|
44 | - */ |
|
45 | - private $indilist_module; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var Collection $used_indis Individuals already processed |
|
49 | - */ |
|
50 | - private $used_indis; |
|
51 | - |
|
52 | - /** |
|
53 | - * Constructor for Lineage Builder |
|
54 | - * |
|
55 | - * @param string $surname Reference surname |
|
56 | - * @param Tree $tree Gedcom tree |
|
57 | - */ |
|
58 | - public function __construct($surname, Tree $tree, IndividualListModule $indilist_module) |
|
59 | - { |
|
60 | - $this->surname = $surname; |
|
61 | - $this->tree = $tree; |
|
62 | - $this->indilist_module = $indilist_module; |
|
63 | - $this->used_indis = new Collection(); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Build all patronymic lineages for the reference surname. |
|
68 | - * |
|
69 | - * @return Collection|NULL List of root patronymic lineages |
|
70 | - */ |
|
71 | - public function buildLineages(): ?Collection |
|
72 | - { |
|
73 | - if ($this->indilist_module === null) { |
|
74 | - return null; |
|
75 | - } |
|
76 | - |
|
77 | - $indis = $this->indilist_module->individuals($this->tree, $this->surname, '', '', false, false, I18N::locale()); |
|
78 | - //Warning - the IndividualListModule returns a clone of individuals objects. Cannot be used for object equality |
|
79 | - if (count($indis) == 0) { |
|
80 | - return null; |
|
81 | - } |
|
82 | - |
|
83 | - $root_lineages = new Collection(); |
|
84 | - |
|
85 | - foreach ($indis as $indi) { |
|
86 | - /** @var Individual $indi */ |
|
87 | - if ($this->used_indis->get($indi->xref(), false) === false) { |
|
88 | - $indi_first = $this->getLineageRootIndividual($indi); |
|
89 | - if ($indi_first !== null) { |
|
90 | - // The root lineage needs to be recreated from the Factory, to retrieve the proper object |
|
91 | - $indi_first = Registry::individualFactory()->make($indi_first->xref(), $this->tree); |
|
92 | - } |
|
93 | - if ($indi_first === null) { |
|
94 | - continue; |
|
95 | - } |
|
96 | - $this->used_indis->put($indi_first->xref(), true); |
|
97 | - if ($indi_first->canShow()) { |
|
98 | - //Check if the root individual has brothers and sisters, without parents |
|
99 | - $indi_first_child_family = $indi_first->childFamilies()->first(); |
|
100 | - if ($indi_first_child_family !== null) { |
|
101 | - $root_node = new LineageRootNode(null); |
|
102 | - $root_node->addFamily($indi_first_child_family); |
|
103 | - } else { |
|
104 | - $root_node = new LineageRootNode($indi_first); |
|
105 | - } |
|
106 | - $root_node = $this->buildLineage($root_node); |
|
107 | - $root_lineages->add($root_node); |
|
108 | - } |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - return $root_lineages->sort(function (LineageRootNode $a, LineageRootNode $b) { |
|
113 | - |
|
114 | - if ($a->numberChildNodes() == $b->numberChildNodes()) { |
|
115 | - return 0; |
|
116 | - } |
|
117 | - return ($a->numberChildNodes() > $b->numberChildNodes()) ? -1 : 1; |
|
118 | - }); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Retrieve the root individual, from any individual, by recursion. |
|
123 | - * The Root individual is the individual without a father, or without a mother holding the same name. |
|
124 | - * |
|
125 | - * @param Individual $indi |
|
126 | - * @return Individual|NULL Root individual |
|
127 | - */ |
|
128 | - private function getLineageRootIndividual(Individual $indi): ?Individual |
|
129 | - { |
|
130 | - $child_families = $indi->childFamilies(); |
|
131 | - if ($this->used_indis->get($indi->xref(), false) !== false) { |
|
132 | - return null; |
|
133 | - } |
|
134 | - |
|
135 | - foreach ($child_families as $child_family) { |
|
136 | - /** @var Family $child_family */ |
|
137 | - $child_family->husband(); |
|
138 | - if (($husb = $child_family->husband()) !== null) { |
|
139 | - if ($husb->isPendingAddition() && $husb->privatizeGedcom(Auth::PRIV_HIDE) == '') { |
|
140 | - return $indi; |
|
141 | - } |
|
142 | - return $this->getLineageRootIndividual($husb); |
|
143 | - } elseif (($wife = $child_family->wife()) !== null) { |
|
144 | - if (!($wife->isPendingAddition() && $wife->privatizeGedcom(Auth::PRIV_HIDE) == '')) { |
|
145 | - $indi_surname = $indi->getAllNames()[$indi->getPrimaryName()]['surname']; |
|
146 | - $wife_surname = $wife->getAllNames()[$wife->getPrimaryName()]['surname']; |
|
147 | - if ( |
|
148 | - $indi->canShowName() |
|
149 | - && $wife->canShowName() |
|
150 | - && I18N::comparator()($indi_surname, $wife_surname) == 0 |
|
151 | - ) { |
|
152 | - return $this->getLineageRootIndividual($wife); |
|
153 | - } |
|
154 | - } |
|
155 | - return $indi; |
|
156 | - } |
|
157 | - } |
|
158 | - return $indi; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Computes descendent Lineage from a node. |
|
163 | - * Uses recursion to build the lineage tree |
|
164 | - * |
|
165 | - * @param LineageNode $node |
|
166 | - * @return LineageNode Computed lineage |
|
167 | - */ |
|
168 | - private function buildLineage(LineageNode $node): LineageNode |
|
169 | - { |
|
170 | - $indi_surname = ''; |
|
171 | - |
|
172 | - $indi_node = $node->individual(); |
|
173 | - if ($indi_node !== null) { |
|
174 | - if ($node->families()->count() == 0) { |
|
175 | - foreach ($indi_node->spouseFamilies() as $spouse_family) { |
|
176 | - $node->addFamily($spouse_family); |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - $indi_surname = $indi_node->getAllNames()[$indi_node->getPrimaryName()]['surname'] ?? ''; |
|
181 | - $node->rootNode()->addPlace($indi_node->getBirthPlace()); |
|
182 | - |
|
183 | - //Tag the individual as used |
|
184 | - $this->used_indis->put($indi_node->xref(), true); |
|
185 | - } |
|
186 | - |
|
187 | - foreach ($node->families() as $family_node) { |
|
188 | - /** @var Family $spouse_family */ |
|
189 | - $spouse_family = $family_node->family; |
|
190 | - $spouse_surname = ''; |
|
191 | - $spouse = null; |
|
192 | - if ( |
|
193 | - $indi_node !== null && |
|
194 | - ($spouse = $spouse_family->spouse($indi_node)) !== null && $spouse->canShowName() |
|
195 | - ) { |
|
196 | - $spouse_surname = $spouse->getAllNames()[$spouse->getPrimaryName()]['surname'] ?? ''; |
|
197 | - } |
|
198 | - |
|
199 | - $nb_children = $nb_natural = 0; |
|
200 | - |
|
201 | - foreach ($spouse_family->children() as $child) { |
|
202 | - if (!($child->isPendingAddition() && $child->privatizeGedcom(Auth::PRIV_HIDE) == '')) { |
|
203 | - $child_surname = $child->getAllNames()[$child->getPrimaryName()]['surname'] ?? ''; |
|
204 | - |
|
205 | - $nb_children++; |
|
206 | - if ($indi_node !== null && $indi_node->sex() == 'F') { //If the root individual is the mother |
|
207 | - //Print only lineages of children with the same surname as their mother |
|
208 | - //(supposing they are natural children) |
|
209 | - /** @psalm-suppress RedundantCondition */ |
|
210 | - if ( |
|
211 | - $spouse === null || |
|
212 | - ($spouse_surname !== '' && I18N::comparator()($child_surname, $spouse_surname) != 0) |
|
213 | - ) { |
|
214 | - if (I18N::comparator()($child_surname, $indi_surname) == 0) { |
|
215 | - $nb_natural++; |
|
216 | - $node_child = new LineageNode($child, $node->rootNode()); |
|
217 | - $node_child = $this->buildLineage($node_child); |
|
218 | - $node->addChild($spouse_family, $node_child); |
|
219 | - } |
|
220 | - } |
|
221 | - } else { //If the root individual is the father |
|
222 | - $nb_natural++; |
|
223 | - //Print if the children does not bear the same name as his mother |
|
224 | - //(and different from his father) |
|
225 | - if ( |
|
226 | - mb_strlen($child_surname) == 0 || |
|
227 | - mb_strlen($indi_surname) == 0 || mb_strlen($spouse_surname) == 0 || |
|
228 | - I18N::comparator()($child_surname, $indi_surname) == 0 || |
|
229 | - I18N::comparator()($child_surname, $spouse_surname) != 0 |
|
230 | - ) { |
|
231 | - $node_child = new LineageNode($child, $node->rootNode()); |
|
232 | - $node_child = $this->buildLineage($node_child); |
|
233 | - } else { |
|
234 | - $node_child = new LineageNode($child, $node->rootNode(), $child_surname); |
|
235 | - } |
|
236 | - $node->addChild($spouse_family, $node_child); |
|
237 | - } |
|
238 | - } |
|
239 | - } |
|
240 | - |
|
241 | - //Do not print other children |
|
242 | - if (($nb_children - $nb_natural) > 0) { |
|
243 | - $node->addChild($spouse_family, null); |
|
244 | - } |
|
245 | - } |
|
246 | - |
|
247 | - return $node; |
|
248 | - } |
|
32 | + /** |
|
33 | + * @var string $surname Reference surname |
|
34 | + */ |
|
35 | + private $surname; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var Tree $tree Reference tree |
|
39 | + */ |
|
40 | + private $tree; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var IndividualListModule|null $indilist_module |
|
44 | + */ |
|
45 | + private $indilist_module; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var Collection $used_indis Individuals already processed |
|
49 | + */ |
|
50 | + private $used_indis; |
|
51 | + |
|
52 | + /** |
|
53 | + * Constructor for Lineage Builder |
|
54 | + * |
|
55 | + * @param string $surname Reference surname |
|
56 | + * @param Tree $tree Gedcom tree |
|
57 | + */ |
|
58 | + public function __construct($surname, Tree $tree, IndividualListModule $indilist_module) |
|
59 | + { |
|
60 | + $this->surname = $surname; |
|
61 | + $this->tree = $tree; |
|
62 | + $this->indilist_module = $indilist_module; |
|
63 | + $this->used_indis = new Collection(); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Build all patronymic lineages for the reference surname. |
|
68 | + * |
|
69 | + * @return Collection|NULL List of root patronymic lineages |
|
70 | + */ |
|
71 | + public function buildLineages(): ?Collection |
|
72 | + { |
|
73 | + if ($this->indilist_module === null) { |
|
74 | + return null; |
|
75 | + } |
|
76 | + |
|
77 | + $indis = $this->indilist_module->individuals($this->tree, $this->surname, '', '', false, false, I18N::locale()); |
|
78 | + //Warning - the IndividualListModule returns a clone of individuals objects. Cannot be used for object equality |
|
79 | + if (count($indis) == 0) { |
|
80 | + return null; |
|
81 | + } |
|
82 | + |
|
83 | + $root_lineages = new Collection(); |
|
84 | + |
|
85 | + foreach ($indis as $indi) { |
|
86 | + /** @var Individual $indi */ |
|
87 | + if ($this->used_indis->get($indi->xref(), false) === false) { |
|
88 | + $indi_first = $this->getLineageRootIndividual($indi); |
|
89 | + if ($indi_first !== null) { |
|
90 | + // The root lineage needs to be recreated from the Factory, to retrieve the proper object |
|
91 | + $indi_first = Registry::individualFactory()->make($indi_first->xref(), $this->tree); |
|
92 | + } |
|
93 | + if ($indi_first === null) { |
|
94 | + continue; |
|
95 | + } |
|
96 | + $this->used_indis->put($indi_first->xref(), true); |
|
97 | + if ($indi_first->canShow()) { |
|
98 | + //Check if the root individual has brothers and sisters, without parents |
|
99 | + $indi_first_child_family = $indi_first->childFamilies()->first(); |
|
100 | + if ($indi_first_child_family !== null) { |
|
101 | + $root_node = new LineageRootNode(null); |
|
102 | + $root_node->addFamily($indi_first_child_family); |
|
103 | + } else { |
|
104 | + $root_node = new LineageRootNode($indi_first); |
|
105 | + } |
|
106 | + $root_node = $this->buildLineage($root_node); |
|
107 | + $root_lineages->add($root_node); |
|
108 | + } |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + return $root_lineages->sort(function (LineageRootNode $a, LineageRootNode $b) { |
|
113 | + |
|
114 | + if ($a->numberChildNodes() == $b->numberChildNodes()) { |
|
115 | + return 0; |
|
116 | + } |
|
117 | + return ($a->numberChildNodes() > $b->numberChildNodes()) ? -1 : 1; |
|
118 | + }); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Retrieve the root individual, from any individual, by recursion. |
|
123 | + * The Root individual is the individual without a father, or without a mother holding the same name. |
|
124 | + * |
|
125 | + * @param Individual $indi |
|
126 | + * @return Individual|NULL Root individual |
|
127 | + */ |
|
128 | + private function getLineageRootIndividual(Individual $indi): ?Individual |
|
129 | + { |
|
130 | + $child_families = $indi->childFamilies(); |
|
131 | + if ($this->used_indis->get($indi->xref(), false) !== false) { |
|
132 | + return null; |
|
133 | + } |
|
134 | + |
|
135 | + foreach ($child_families as $child_family) { |
|
136 | + /** @var Family $child_family */ |
|
137 | + $child_family->husband(); |
|
138 | + if (($husb = $child_family->husband()) !== null) { |
|
139 | + if ($husb->isPendingAddition() && $husb->privatizeGedcom(Auth::PRIV_HIDE) == '') { |
|
140 | + return $indi; |
|
141 | + } |
|
142 | + return $this->getLineageRootIndividual($husb); |
|
143 | + } elseif (($wife = $child_family->wife()) !== null) { |
|
144 | + if (!($wife->isPendingAddition() && $wife->privatizeGedcom(Auth::PRIV_HIDE) == '')) { |
|
145 | + $indi_surname = $indi->getAllNames()[$indi->getPrimaryName()]['surname']; |
|
146 | + $wife_surname = $wife->getAllNames()[$wife->getPrimaryName()]['surname']; |
|
147 | + if ( |
|
148 | + $indi->canShowName() |
|
149 | + && $wife->canShowName() |
|
150 | + && I18N::comparator()($indi_surname, $wife_surname) == 0 |
|
151 | + ) { |
|
152 | + return $this->getLineageRootIndividual($wife); |
|
153 | + } |
|
154 | + } |
|
155 | + return $indi; |
|
156 | + } |
|
157 | + } |
|
158 | + return $indi; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Computes descendent Lineage from a node. |
|
163 | + * Uses recursion to build the lineage tree |
|
164 | + * |
|
165 | + * @param LineageNode $node |
|
166 | + * @return LineageNode Computed lineage |
|
167 | + */ |
|
168 | + private function buildLineage(LineageNode $node): LineageNode |
|
169 | + { |
|
170 | + $indi_surname = ''; |
|
171 | + |
|
172 | + $indi_node = $node->individual(); |
|
173 | + if ($indi_node !== null) { |
|
174 | + if ($node->families()->count() == 0) { |
|
175 | + foreach ($indi_node->spouseFamilies() as $spouse_family) { |
|
176 | + $node->addFamily($spouse_family); |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + $indi_surname = $indi_node->getAllNames()[$indi_node->getPrimaryName()]['surname'] ?? ''; |
|
181 | + $node->rootNode()->addPlace($indi_node->getBirthPlace()); |
|
182 | + |
|
183 | + //Tag the individual as used |
|
184 | + $this->used_indis->put($indi_node->xref(), true); |
|
185 | + } |
|
186 | + |
|
187 | + foreach ($node->families() as $family_node) { |
|
188 | + /** @var Family $spouse_family */ |
|
189 | + $spouse_family = $family_node->family; |
|
190 | + $spouse_surname = ''; |
|
191 | + $spouse = null; |
|
192 | + if ( |
|
193 | + $indi_node !== null && |
|
194 | + ($spouse = $spouse_family->spouse($indi_node)) !== null && $spouse->canShowName() |
|
195 | + ) { |
|
196 | + $spouse_surname = $spouse->getAllNames()[$spouse->getPrimaryName()]['surname'] ?? ''; |
|
197 | + } |
|
198 | + |
|
199 | + $nb_children = $nb_natural = 0; |
|
200 | + |
|
201 | + foreach ($spouse_family->children() as $child) { |
|
202 | + if (!($child->isPendingAddition() && $child->privatizeGedcom(Auth::PRIV_HIDE) == '')) { |
|
203 | + $child_surname = $child->getAllNames()[$child->getPrimaryName()]['surname'] ?? ''; |
|
204 | + |
|
205 | + $nb_children++; |
|
206 | + if ($indi_node !== null && $indi_node->sex() == 'F') { //If the root individual is the mother |
|
207 | + //Print only lineages of children with the same surname as their mother |
|
208 | + //(supposing they are natural children) |
|
209 | + /** @psalm-suppress RedundantCondition */ |
|
210 | + if ( |
|
211 | + $spouse === null || |
|
212 | + ($spouse_surname !== '' && I18N::comparator()($child_surname, $spouse_surname) != 0) |
|
213 | + ) { |
|
214 | + if (I18N::comparator()($child_surname, $indi_surname) == 0) { |
|
215 | + $nb_natural++; |
|
216 | + $node_child = new LineageNode($child, $node->rootNode()); |
|
217 | + $node_child = $this->buildLineage($node_child); |
|
218 | + $node->addChild($spouse_family, $node_child); |
|
219 | + } |
|
220 | + } |
|
221 | + } else { //If the root individual is the father |
|
222 | + $nb_natural++; |
|
223 | + //Print if the children does not bear the same name as his mother |
|
224 | + //(and different from his father) |
|
225 | + if ( |
|
226 | + mb_strlen($child_surname) == 0 || |
|
227 | + mb_strlen($indi_surname) == 0 || mb_strlen($spouse_surname) == 0 || |
|
228 | + I18N::comparator()($child_surname, $indi_surname) == 0 || |
|
229 | + I18N::comparator()($child_surname, $spouse_surname) != 0 |
|
230 | + ) { |
|
231 | + $node_child = new LineageNode($child, $node->rootNode()); |
|
232 | + $node_child = $this->buildLineage($node_child); |
|
233 | + } else { |
|
234 | + $node_child = new LineageNode($child, $node->rootNode(), $child_surname); |
|
235 | + } |
|
236 | + $node->addChild($spouse_family, $node_child); |
|
237 | + } |
|
238 | + } |
|
239 | + } |
|
240 | + |
|
241 | + //Do not print other children |
|
242 | + if (($nb_children - $nb_natural) > 0) { |
|
243 | + $node->addChild($spouse_family, null); |
|
244 | + } |
|
245 | + } |
|
246 | + |
|
247 | + return $node; |
|
248 | + } |
|
249 | 249 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | |
57 | 57 | $token = Functions::generateRandomToken(); |
58 | 58 | $this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token); |
59 | - Log::addConfigurationLog($this->module->title() . ' : New token generated.'); |
|
59 | + Log::addConfigurationLog($this->module->title().' : New token generated.'); |
|
60 | 60 | |
61 | 61 | return response(['token' => $token]); |
62 | 62 | } |
@@ -29,35 +29,35 @@ |
||
29 | 29 | */ |
30 | 30 | class TokenGenerate implements RequestHandlerInterface |
31 | 31 | { |
32 | - /** |
|
33 | - * @var AdminTasksModule|null $module |
|
34 | - */ |
|
35 | - private $module; |
|
36 | - |
|
37 | - /** |
|
38 | - * Constructor for TokenGenerate request handler |
|
39 | - * |
|
40 | - * @param ModuleService $module_service |
|
41 | - */ |
|
42 | - public function __construct(ModuleService $module_service) |
|
43 | - { |
|
44 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * {@inheritDoc} |
|
49 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
50 | - */ |
|
51 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
52 | - { |
|
53 | - if ($this->module === null) { |
|
54 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
55 | - } |
|
56 | - |
|
57 | - $token = Functions::generateRandomToken(); |
|
58 | - $this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token); |
|
59 | - Log::addConfigurationLog($this->module->title() . ' : New token generated.'); |
|
60 | - |
|
61 | - return response(['token' => $token]); |
|
62 | - } |
|
32 | + /** |
|
33 | + * @var AdminTasksModule|null $module |
|
34 | + */ |
|
35 | + private $module; |
|
36 | + |
|
37 | + /** |
|
38 | + * Constructor for TokenGenerate request handler |
|
39 | + * |
|
40 | + * @param ModuleService $module_service |
|
41 | + */ |
|
42 | + public function __construct(ModuleService $module_service) |
|
43 | + { |
|
44 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * {@inheritDoc} |
|
49 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
50 | + */ |
|
51 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
52 | + { |
|
53 | + if ($this->module === null) { |
|
54 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
55 | + } |
|
56 | + |
|
57 | + $token = Functions::generateRandomToken(); |
|
58 | + $this->module->setPreference('MAJ_AT_FORCE_EXEC_TOKEN', $token); |
|
59 | + Log::addConfigurationLog($this->module->title() . ' : New token generated.'); |
|
60 | + |
|
61 | + return response(['token' => $token]); |
|
62 | + } |
|
63 | 63 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token); |
74 | 74 | } |
75 | 75 | |
76 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
76 | + return $this->viewResponse($this->module->name().'::admin/config', [ |
|
77 | 77 | 'title' => $this->module->title(), |
78 | 78 | 'trigger_token' => $token, |
79 | 79 | 'trigger_route' => route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']), |
@@ -30,48 +30,48 @@ |
||
30 | 30 | */ |
31 | 31 | class AdminConfigPage implements RequestHandlerInterface |
32 | 32 | { |
33 | - use ViewResponseTrait; |
|
33 | + use ViewResponseTrait; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @var AdminTasksModule|null $module |
|
37 | - */ |
|
38 | - private $module; |
|
35 | + /** |
|
36 | + * @var AdminTasksModule|null $module |
|
37 | + */ |
|
38 | + private $module; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Constructor for Admin Config request handler |
|
42 | - * |
|
43 | - * @param ModuleService $module_service |
|
44 | - */ |
|
45 | - public function __construct(ModuleService $module_service) |
|
46 | - { |
|
47 | - $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
48 | - } |
|
40 | + /** |
|
41 | + * Constructor for Admin Config request handler |
|
42 | + * |
|
43 | + * @param ModuleService $module_service |
|
44 | + */ |
|
45 | + public function __construct(ModuleService $module_service) |
|
46 | + { |
|
47 | + $this->module = $module_service->findByInterface(AdminTasksModule::class)->first(); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * {@inheritDoc} |
|
52 | - * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
53 | - */ |
|
54 | - public function handle(ServerRequestInterface $request): ResponseInterface |
|
55 | - { |
|
56 | - $this->layout = 'layouts/administration'; |
|
50 | + /** |
|
51 | + * {@inheritDoc} |
|
52 | + * @see \Psr\Http\Server\RequestHandlerInterface::handle() |
|
53 | + */ |
|
54 | + public function handle(ServerRequestInterface $request): ResponseInterface |
|
55 | + { |
|
56 | + $this->layout = 'layouts/administration'; |
|
57 | 57 | |
58 | - if ($this->module === null) { |
|
59 | - throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
60 | - } |
|
58 | + if ($this->module === null) { |
|
59 | + throw new HttpNotFoundException(I18N::translate('The attached module could not be found.')); |
|
60 | + } |
|
61 | 61 | |
62 | - $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
63 | - if ($token === '') { |
|
64 | - $token = Functions::generateRandomToken(); |
|
65 | - $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token); |
|
66 | - } |
|
62 | + $token = $this->module->getPreference('MAJ_AT_FORCE_EXEC_TOKEN'); |
|
63 | + if ($token === '') { |
|
64 | + $token = Functions::generateRandomToken(); |
|
65 | + $this->module->setPreference('PAT_FORCE_EXEC_TOKEN', $token); |
|
66 | + } |
|
67 | 67 | |
68 | - return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
69 | - 'title' => $this->module->title(), |
|
70 | - 'trigger_token' => $token, |
|
71 | - 'trigger_route' => route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']), |
|
72 | - 'new_token_route' => route(TokenGenerate::class), |
|
73 | - 'tasks_data_route' => route(TasksList::class), |
|
74 | - 'js_script_url' => $this->module->assetUrl('js/admintasks.min.js') |
|
75 | - ]); |
|
76 | - } |
|
68 | + return $this->viewResponse($this->module->name() . '::admin/config', [ |
|
69 | + 'title' => $this->module->title(), |
|
70 | + 'trigger_token' => $token, |
|
71 | + 'trigger_route' => route(TaskTrigger::class, ['task' => '__TASKNAME__', 'force' => '__TOKEN__']), |
|
72 | + 'new_token_route' => route(TokenGenerate::class), |
|
73 | + 'tasks_data_route' => route(TasksList::class), |
|
74 | + 'js_script_url' => $this->module->assetUrl('js/admintasks.min.js') |
|
75 | + ]); |
|
76 | + } |
|
77 | 77 | } |