@@ -31,11 +31,16 @@ |
||
31 | 31 | $nb_levels = count($parent); |
32 | 32 | for ($i=0; $i < $nb_levels; $i++) { |
33 | 33 | $parent[$i] = trim($parent[$i]); |
34 | - if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , , |
|
34 | + if (empty($parent[$i])) { |
|
35 | + $parent[$i]='unknown'; |
|
36 | + } |
|
37 | + // GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | 38 | $pl_id=Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
36 | 39 | ->execute(array($i, $place_id, $parent[$i])) |
37 | 40 | ->fetchOne(); |
38 | - if (empty($pl_id)) break; |
|
41 | + if (empty($pl_id)) { |
|
42 | + break; |
|
43 | + } |
|
39 | 44 | $place_id = $pl_id; |
40 | 45 | } |
41 | 46 | return $place_id; |
@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getProviderPlaceId() |
26 | 26 | */ |
27 | 27 | public function getProviderPlaceId(\Fisharebest\Webtrees\Place $place) { |
28 | - if(!$place->isEmpty()) { |
|
29 | - $parent = array_reverse(explode (',', $place->getGedcomName())); |
|
28 | + if (!$place->isEmpty()) { |
|
29 | + $parent = array_reverse(explode(',', $place->getGedcomName())); |
|
30 | 30 | $place_id = 0; |
31 | 31 | $nb_levels = count($parent); |
32 | - for ($i=0; $i < $nb_levels; $i++) { |
|
32 | + for ($i = 0; $i < $nb_levels; $i++) { |
|
33 | 33 | $parent[$i] = trim($parent[$i]); |
34 | - if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | - $pl_id=Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
34 | + if (empty($parent[$i])) $parent[$i] = 'unknown'; // GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | + $pl_id = Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
36 | 36 | ->execute(array($i, $place_id, $parent[$i])) |
37 | 37 | ->fetchOne(); |
38 | 38 | if (empty($pl_id)) break; |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getPlaceIcon() |
49 | 49 | */ |
50 | 50 | public function getPlaceIcon(\Fisharebest\Webtrees\Place $place) { |
51 | - if(!$place->isEmpty()){ |
|
51 | + if (!$place->isEmpty()) { |
|
52 | 52 | $place_details = |
53 | 53 | Database::prepare('SELECT pl_icon FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place') |
54 | 54 | ->execute(array($this->getProviderPlaceId($place))) |
55 | 55 | ->fetchOneRow(); |
56 | - if($place_details){ |
|
56 | + if ($place_details) { |
|
57 | 57 | return WT_MODULES_DIR.'googlemap/'.$place_details->pl_icon; |
58 | 58 | } |
59 | 59 | } |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * webtrees-lib: MyArtJaub library for webtrees |
|
4 | - * |
|
5 | - * @package MyArtJaub\Webtrees |
|
6 | - * @subpackage Hook |
|
7 | - * @author Jonathan Jaubart <[email protected]> |
|
8 | - * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
9 | - * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10 | - */ |
|
3 | + * webtrees-lib: MyArtJaub library for webtrees |
|
4 | + * |
|
5 | + * @package MyArtJaub\Webtrees |
|
6 | + * @subpackage Hook |
|
7 | + * @author Jonathan Jaubart <[email protected]> |
|
8 | + * @copyright Copyright (c) 2011-2016, Jonathan Jaubart |
|
9 | + * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 |
|
10 | + */ |
|
11 | 11 | namespace MyArtJaub\Webtrees\Hook; |
12 | 12 | |
13 | 13 | use Fisharebest\Webtrees\Database; |
@@ -137,17 +137,17 @@ discard block |
||
137 | 137 | * @return array Results of the hook executions |
138 | 138 | */ |
139 | 139 | public function executeOnlyFor(array $module_names) { |
140 | - $result = array(); |
|
141 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
142 | - $params = func_get_args(); |
|
143 | - array_shift($params); |
|
144 | - foreach ($module_names as $module_name) { |
|
145 | - if($module = Module::getModuleByName($module_name)) { |
|
146 | - $result[] = call_user_func_array(array($module, $this->hook_function), $params); |
|
147 | - } |
|
148 | - } |
|
149 | - } |
|
150 | - return $result; |
|
140 | + $result = array(); |
|
141 | + if(HookProvider::getInstance()->isModuleOperational()){ |
|
142 | + $params = func_get_args(); |
|
143 | + array_shift($params); |
|
144 | + foreach ($module_names as $module_name) { |
|
145 | + if($module = Module::getModuleByName($module_name)) { |
|
146 | + $result[] = call_user_func_array(array($module, $this->hook_function), $params); |
|
147 | + } |
|
148 | + } |
|
149 | + } |
|
150 | + return $result; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $hook_function_in Hook function to be subscribed or executed |
32 | 32 | * @param string $hook_context_in Hook context to be subscribed or executed |
33 | 33 | */ |
34 | - public function __construct($hook_function_in, $hook_context_in = 'all'){ |
|
34 | + public function __construct($hook_function_in, $hook_context_in = 'all') { |
|
35 | 35 | $this->hook_function = $hook_function_in; |
36 | 36 | $this->hook_context = $hook_context_in; |
37 | 37 | } |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param string $hsubscriber Name of the subscriber module |
49 | 49 | */ |
50 | - public function subscribe($hsubscriber){ |
|
51 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
50 | + public function subscribe($hsubscriber) { |
|
51 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
52 | 52 | Database::prepare( |
53 | 53 | "INSERT IGNORE INTO `##maj_hooks` (majh_hook_function, majh_hook_context, majh_module_name)". |
54 | 54 | " VALUES (?, ?, ?)" |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param string $hsubscriber Name of the subscriber module |
63 | 63 | * @param int $priority Priority of execution |
64 | 64 | */ |
65 | - public function setPriority($hsubscriber, $priority){ |
|
66 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
65 | + public function setPriority($hsubscriber, $priority) { |
|
66 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
67 | 67 | Database::prepare( |
68 | 68 | "UPDATE `##maj_hooks`". |
69 | 69 | " SET majh_module_priority=?". |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @param string $hsubscriber Name of the subscriber module |
81 | 81 | */ |
82 | - public function enable($hsubscriber){ |
|
83 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
82 | + public function enable($hsubscriber) { |
|
83 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
84 | 84 | Database::prepare( |
85 | 85 | "UPDATE `##maj_hooks`". |
86 | 86 | " SET majh_status='enabled'". |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param string $hsubscriber Name of the subscriber module |
98 | 98 | */ |
99 | - public function disable($hsubscriber){ |
|
100 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
99 | + public function disable($hsubscriber) { |
|
100 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
101 | 101 | Database::prepare( |
102 | 102 | "UPDATE `##maj_hooks`". |
103 | 103 | " SET majh_status='disabled'". |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @param string $hsubscriber Name of the subscriber module |
115 | 115 | */ |
116 | - public function remove($hsubscriber){ |
|
117 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
116 | + public function remove($hsubscriber) { |
|
117 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
118 | 118 | Database::prepare( |
119 | 119 | "DELETE FROM `##maj_hooks`". |
120 | 120 | " WHERE majh_hook_function=?". |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function executeOnlyFor(array $module_names) { |
140 | 140 | $result = array(); |
141 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
141 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
142 | 142 | $params = func_get_args(); |
143 | 143 | array_shift($params); |
144 | 144 | foreach ($module_names as $module_name) { |
145 | - if($module = Module::getModuleByName($module_name)) { |
|
145 | + if ($module = Module::getModuleByName($module_name)) { |
|
146 | 146 | $result[] = call_user_func_array(array($module, $this->hook_function), $params); |
147 | 147 | } |
148 | 148 | } |
@@ -156,17 +156,17 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return array Results of the hook executions |
158 | 158 | */ |
159 | - public function execute(){ |
|
159 | + public function execute() { |
|
160 | 160 | $result = array(); |
161 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
161 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
162 | 162 | $params = func_get_args(); |
163 | 163 | $sqlquery = ''; |
164 | 164 | $sqlparams = array($this->hook_function); |
165 | - if($this->hook_context != 'all') { |
|
165 | + if ($this->hook_context != 'all') { |
|
166 | 166 | $sqlparams = array($this->hook_function, $this->hook_context); |
167 | 167 | $sqlquery = " OR majh_hook_context=?"; |
168 | 168 | } |
169 | - $module_names=Database::prepare( |
|
169 | + $module_names = Database::prepare( |
|
170 | 170 | "SELECT majh_module_name AS module, majh_module_priority AS priority FROM `##maj_hooks`". |
171 | 171 | " WHERE majh_hook_function = ? AND (majh_hook_context='all'".$sqlquery.") AND majh_status='enabled'". |
172 | 172 | " ORDER BY majh_module_priority ASC, module ASC" |
@@ -183,15 +183,15 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return int Number of active modules |
185 | 185 | */ |
186 | - public function getNumberActiveModules(){ |
|
187 | - if(HookProvider::getInstance()->isModuleOperational()){ |
|
186 | + public function getNumberActiveModules() { |
|
187 | + if (HookProvider::getInstance()->isModuleOperational()) { |
|
188 | 188 | $sqlquery = ''; |
189 | 189 | $sqlparams = array($this->hook_function); |
190 | - if($this->hook_context != 'all') { |
|
190 | + if ($this->hook_context != 'all') { |
|
191 | 191 | $sqlparams = array($this->hook_function, $this->hook_context); |
192 | 192 | $sqlquery = " OR majh_hook_context=?"; |
193 | 193 | } |
194 | - $module_names=Database::prepare( |
|
194 | + $module_names = Database::prepare( |
|
195 | 195 | "SELECT majh_module_name AS modules FROM `##maj_hooks`". |
196 | 196 | " WHERE majh_hook_function = ? AND (majh_hook_context='all'".$sqlquery.") AND majh_status='enabled'" |
197 | 197 | )->execute($sqlparams)->fetchOneColumn(); |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return bool True is active modules exist, false otherwise |
207 | 207 | */ |
208 | - public function hasAnyActiveModule(){ |
|
209 | - return ($this->getNumberActiveModules()>0); |
|
208 | + public function hasAnyActiveModule() { |
|
209 | + return ($this->getNumberActiveModules() > 0); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
@@ -15,66 +15,66 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class AbstractView { |
17 | 17 | |
18 | - /** |
|
19 | - * Reference controller |
|
20 | - * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
21 | - */ |
|
22 | - protected $ctrl; |
|
18 | + /** |
|
19 | + * Reference controller |
|
20 | + * @var \Fisharebest\Webtrees\Controller\BaseController $ctrl |
|
21 | + */ |
|
22 | + protected $ctrl; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Structure containing the data of the view |
|
26 | - * @var ViewBag $data |
|
27 | - */ |
|
28 | - protected $data; |
|
24 | + /** |
|
25 | + * Structure containing the data of the view |
|
26 | + * @var ViewBag $data |
|
27 | + */ |
|
28 | + protected $data; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Constructor |
|
32 | - * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
33 | - * @param ViewBag $data ViewBag holding view data |
|
34 | - */ |
|
35 | - public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
36 | - $this->ctrl = $ctrl; |
|
37 | - $this->data = $data; |
|
38 | - } |
|
30 | + /** |
|
31 | + * Constructor |
|
32 | + * @param \Fisharebest\Webtrees\Controller\BaseController $ctrl Controller |
|
33 | + * @param ViewBag $data ViewBag holding view data |
|
34 | + */ |
|
35 | + public function __construct(\Fisharebest\Webtrees\Controller\BaseController $ctrl, ViewBag $data) { |
|
36 | + $this->ctrl = $ctrl; |
|
37 | + $this->data = $data; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Render the view to the page, including header. |
|
42 | - * |
|
43 | - * @throws \Exception |
|
44 | - */ |
|
45 | - public function render() { |
|
46 | - global $controller; |
|
40 | + /** |
|
41 | + * Render the view to the page, including header. |
|
42 | + * |
|
43 | + * @throws \Exception |
|
44 | + */ |
|
45 | + public function render() { |
|
46 | + global $controller; |
|
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
49 | 49 | |
50 | 50 | $controller = $this->ctrl; |
51 | - $this->ctrl->pageHeader(); |
|
51 | + $this->ctrl->pageHeader(); |
|
52 | 52 | |
53 | - echo $this->renderContent(); |
|
54 | - } |
|
53 | + echo $this->renderContent(); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Render the view to the page, without any header |
|
58 | - */ |
|
59 | - public function renderPartial() { |
|
60 | - echo $this->getHtmlPartial(); |
|
61 | - } |
|
56 | + /** |
|
57 | + * Render the view to the page, without any header |
|
58 | + */ |
|
59 | + public function renderPartial() { |
|
60 | + echo $this->getHtmlPartial(); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Return the HTML code generated by the view, without any header |
|
65 | - */ |
|
66 | - public function getHtmlPartial() { |
|
67 | - ob_start(); |
|
68 | - $html_render = $this->renderContent(); |
|
69 | - $html_buffer = ob_get_clean(); |
|
63 | + /** |
|
64 | + * Return the HTML code generated by the view, without any header |
|
65 | + */ |
|
66 | + public function getHtmlPartial() { |
|
67 | + ob_start(); |
|
68 | + $html_render = $this->renderContent(); |
|
69 | + $html_buffer = ob_get_clean(); |
|
70 | 70 | |
71 | - return empty($html_render) ? $html_buffer : $html_render; |
|
72 | - } |
|
71 | + return empty($html_render) ? $html_buffer : $html_render; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Abstract method containing the details of the view. |
|
76 | - */ |
|
77 | - abstract protected function renderContent(); |
|
74 | + /** |
|
75 | + * Abstract method containing the details of the view. |
|
76 | + */ |
|
77 | + abstract protected function renderContent(); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | \ No newline at end of file |
@@ -45,7 +45,7 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if (!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
49 | 49 | |
50 | 50 | $controller = $this->ctrl; |
51 | 51 | $this->ctrl->pageHeader(); |
@@ -45,7 +45,9 @@ |
||
45 | 45 | public function render() { |
46 | 46 | global $controller; |
47 | 47 | |
48 | - if(!$this->ctrl) throw new \Exception('Controller not initialised'); |
|
48 | + if(!$this->ctrl) { |
|
49 | + throw new \Exception('Controller not initialised'); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | $controller = $this->ctrl; |
51 | 53 | $this->ctrl->pageHeader(); |
@@ -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 | } |
@@ -21,130 +21,130 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class GeoAnalysisProvider { |
23 | 23 | |
24 | - /** |
|
25 | - * Reference tree |
|
26 | - * @var Tree $tree |
|
27 | - */ |
|
28 | - protected $tree; |
|
24 | + /** |
|
25 | + * Reference tree |
|
26 | + * @var Tree $tree |
|
27 | + */ |
|
28 | + protected $tree; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Cached hierarchy of places in the Gedcom file. |
|
32 | - * |
|
33 | - * @var (array|null) $place_hierarchy |
|
34 | - */ |
|
35 | - protected $place_hierarchy; |
|
30 | + /** |
|
31 | + * Cached hierarchy of places in the Gedcom file. |
|
32 | + * |
|
33 | + * @var (array|null) $place_hierarchy |
|
34 | + */ |
|
35 | + protected $place_hierarchy; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor for GeoAnalysis Provider. |
|
39 | - * A provider is defined in relation to a specific tree. |
|
40 | - * |
|
41 | - * @param Tree $tree |
|
42 | - */ |
|
43 | - public function __construct(Tree $tree) { |
|
44 | - $this->tree = $tree; |
|
45 | - $this->place_hierarchy = null; |
|
46 | - } |
|
37 | + /** |
|
38 | + * Constructor for GeoAnalysis Provider. |
|
39 | + * A provider is defined in relation to a specific tree. |
|
40 | + * |
|
41 | + * @param Tree $tree |
|
42 | + */ |
|
43 | + public function __construct(Tree $tree) { |
|
44 | + $this->tree = $tree; |
|
45 | + $this->place_hierarchy = null; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Creates and returns a GeoAnalysis object from a data row. |
|
50 | - * The row data is expected to be an array with the indexes: |
|
51 | - * - majgd_id: geodispersion analysis ID |
|
52 | - * - majgd_descr: geodispersion analysis description/title |
|
53 | - * - majgd_sublevel: Analysis level |
|
54 | - * - majgd_useflagsgen: Use flags in places display |
|
55 | - * - majgd_detailsgen: Number of top places |
|
56 | - * - majgd_map: file name of the map |
|
57 | - * - majgd_toplevel: parent level for the map |
|
58 | - * |
|
59 | - * @param array $row |
|
60 | - * @return GeoAnalysis |
|
61 | - */ |
|
62 | - protected function loadGeoAnalysisFromRow($row) { |
|
63 | - $options = new GeoDisplayOptions(); |
|
64 | - $options |
|
65 | - ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | - ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
48 | + /** |
|
49 | + * Creates and returns a GeoAnalysis object from a data row. |
|
50 | + * The row data is expected to be an array with the indexes: |
|
51 | + * - majgd_id: geodispersion analysis ID |
|
52 | + * - majgd_descr: geodispersion analysis description/title |
|
53 | + * - majgd_sublevel: Analysis level |
|
54 | + * - majgd_useflagsgen: Use flags in places display |
|
55 | + * - majgd_detailsgen: Number of top places |
|
56 | + * - majgd_map: file name of the map |
|
57 | + * - majgd_toplevel: parent level for the map |
|
58 | + * |
|
59 | + * @param array $row |
|
60 | + * @return GeoAnalysis |
|
61 | + */ |
|
62 | + protected function loadGeoAnalysisFromRow($row) { |
|
63 | + $options = new GeoDisplayOptions(); |
|
64 | + $options |
|
65 | + ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
66 | + ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
67 | 67 | |
68 | - if($row['majgd_map']) { |
|
69 | - $options |
|
70 | - ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | - ->setMapLevel($row['majgd_toplevel']); |
|
72 | - } |
|
68 | + if($row['majgd_map']) { |
|
69 | + $options |
|
70 | + ->setMap(new OutlineMap($row['majgd_map'])) |
|
71 | + ->setMapLevel($row['majgd_toplevel']); |
|
72 | + } |
|
73 | 73 | |
74 | - $enabled = true; |
|
75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | - $enabled = false; |
|
77 | - } |
|
74 | + $enabled = true; |
|
75 | + if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | + $enabled = false; |
|
77 | + } |
|
78 | 78 | |
79 | - return new GeoAnalysis( |
|
80 | - $this->tree, |
|
81 | - $row['majgd_id'], |
|
82 | - $row['majgd_descr'], |
|
83 | - $row['majgd_sublevel'], |
|
84 | - $options, |
|
85 | - $enabled |
|
86 | - ); |
|
87 | - } |
|
79 | + return new GeoAnalysis( |
|
80 | + $this->tree, |
|
81 | + $row['majgd_id'], |
|
82 | + $row['majgd_descr'], |
|
83 | + $row['majgd_sublevel'], |
|
84 | + $options, |
|
85 | + $enabled |
|
86 | + ); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Returns the number of geographical analysis (active and inactive). |
|
91 | - * |
|
92 | - * @return int |
|
93 | - */ |
|
94 | - public function getGeoAnalysisCount() { |
|
95 | - return Database::prepare( |
|
96 | - 'SELECT COUNT(majgd_id)' . |
|
97 | - ' FROM `##maj_geodispersion`' . |
|
98 | - ' WHERE majgd_file = :gedcom_id' |
|
99 | - )->execute(array( |
|
100 | - 'gedcom_id' => $this->tree->getTreeId() |
|
101 | - ))->fetchOne(); |
|
102 | - } |
|
89 | + /** |
|
90 | + * Returns the number of geographical analysis (active and inactive). |
|
91 | + * |
|
92 | + * @return int |
|
93 | + */ |
|
94 | + public function getGeoAnalysisCount() { |
|
95 | + return Database::prepare( |
|
96 | + 'SELECT COUNT(majgd_id)' . |
|
97 | + ' FROM `##maj_geodispersion`' . |
|
98 | + ' WHERE majgd_file = :gedcom_id' |
|
99 | + )->execute(array( |
|
100 | + 'gedcom_id' => $this->tree->getTreeId() |
|
101 | + ))->fetchOne(); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Get a geographical analysis by its ID. |
|
106 | - * The function can only search for only enabled analysis, or all. |
|
107 | - * |
|
108 | - * @param int $id geodispersion analysis ID |
|
109 | - * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | - */ |
|
112 | - public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | - $args = array ( |
|
114 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | - 'ga_id' => $id |
|
116 | - ); |
|
104 | + /** |
|
105 | + * Get a geographical analysis by its ID. |
|
106 | + * The function can only search for only enabled analysis, or all. |
|
107 | + * |
|
108 | + * @param int $id geodispersion analysis ID |
|
109 | + * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
110 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
111 | + */ |
|
112 | + public function getGeoAnalysis($id, $only_enabled = true) { |
|
113 | + $args = array ( |
|
114 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
115 | + 'ga_id' => $id |
|
116 | + ); |
|
117 | 117 | |
118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | - ' FROM `##maj_geodispersion`' . |
|
120 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | - if($only_enabled) { |
|
122 | - $sql .= ' AND majgd_status = :status'; |
|
123 | - $args['status'] = 'enabled'; |
|
124 | - } |
|
125 | - $sql .= ' ORDER BY majgd_descr'; |
|
118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | + ' FROM `##maj_geodispersion`' . |
|
120 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
121 | + if($only_enabled) { |
|
122 | + $sql .= ' AND majgd_status = :status'; |
|
123 | + $args['status'] = 'enabled'; |
|
124 | + } |
|
125 | + $sql .= ' ORDER BY majgd_descr'; |
|
126 | 126 | |
127 | - $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
127 | + $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
128 | 128 | |
129 | - if($ga_array) { |
|
130 | - return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | - } |
|
129 | + if($ga_array) { |
|
130 | + return $this->loadGeoAnalysisFromRow($ga_array); |
|
131 | + } |
|
132 | 132 | |
133 | - return null; |
|
134 | - } |
|
133 | + return null; |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | - * When successful, eturns the newly created GeoAnalysis object. |
|
139 | - * |
|
140 | - * @param string $description geodispersion analysis title |
|
141 | - * @param int $analysis_level Analysis level |
|
142 | - * @param string $map_file Filename of the map |
|
143 | - * @param int $map_top_level Parent level of the map |
|
144 | - * @param bool $use_flags Use flag in the place display |
|
145 | - * @param int $gen_details Number of top places to display |
|
146 | - * @return GeoAnalysis |
|
147 | - */ |
|
136 | + /** |
|
137 | + * Add a new geodispersion analysis in the database, in a transactional manner. |
|
138 | + * When successful, eturns the newly created GeoAnalysis object. |
|
139 | + * |
|
140 | + * @param string $description geodispersion analysis title |
|
141 | + * @param int $analysis_level Analysis level |
|
142 | + * @param string $map_file Filename of the map |
|
143 | + * @param int $map_top_level Parent level of the map |
|
144 | + * @param bool $use_flags Use flag in the place display |
|
145 | + * @param int $gen_details Number of top places to display |
|
146 | + * @return GeoAnalysis |
|
147 | + */ |
|
148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
149 | 149 | try{ |
150 | 150 | Database::beginTransaction(); |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
175 | 175 | } |
176 | 176 | return $ga; |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | - * When successful, returns the updated GeoAnalysis object |
|
182 | - * |
|
183 | - * @param GeoAnalysis $ga |
|
184 | - * @return GeoAnalysis |
|
185 | - */ |
|
186 | - public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | - try { |
|
179 | + /** |
|
180 | + * Update a geodispersion analysis in the database, in transactional manner. |
|
181 | + * When successful, returns the updated GeoAnalysis object |
|
182 | + * |
|
183 | + * @param GeoAnalysis $ga |
|
184 | + * @return GeoAnalysis |
|
185 | + */ |
|
186 | + public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
187 | + try { |
|
188 | 188 | Database::beginTransaction(); |
189 | 189 | |
190 | 190 | Database::prepare( |
@@ -217,239 +217,239 @@ discard block |
||
217 | 217 | $ga = null; |
218 | 218 | } |
219 | 219 | return $ga; |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Set the status of a specific analysis. |
|
224 | - * The status can be enabled (true), or disabled (false). |
|
225 | - * |
|
226 | - * @param GeoAnalysis $ga |
|
227 | - * @param bool $status |
|
228 | - */ |
|
229 | - public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | - Database::prepare( |
|
231 | - 'UPDATE `##maj_geodispersion`'. |
|
232 | - ' SET majgd_status = :status'. |
|
233 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | - )->execute(array( |
|
235 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | - 'status' => $status ? 'enabled' : 'disabled', |
|
237 | - 'ga_id' => $ga->getId() |
|
238 | - )); |
|
239 | - } |
|
222 | + /** |
|
223 | + * Set the status of a specific analysis. |
|
224 | + * The status can be enabled (true), or disabled (false). |
|
225 | + * |
|
226 | + * @param GeoAnalysis $ga |
|
227 | + * @param bool $status |
|
228 | + */ |
|
229 | + public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
230 | + Database::prepare( |
|
231 | + 'UPDATE `##maj_geodispersion`'. |
|
232 | + ' SET majgd_status = :status'. |
|
233 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
234 | + )->execute(array( |
|
235 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
236 | + 'status' => $status ? 'enabled' : 'disabled', |
|
237 | + 'ga_id' => $ga->getId() |
|
238 | + )); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Delete a geodispersion analysis from the database. |
|
243 | - * |
|
244 | - * @param GeoAnalysis $ga |
|
245 | - */ |
|
246 | - public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | - Database::prepare( |
|
248 | - 'DELETE FROM `##maj_geodispersion`'. |
|
249 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | - )->execute(array( |
|
251 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | - 'ga_id' => $ga->getId() |
|
253 | - )); |
|
254 | - } |
|
241 | + /** |
|
242 | + * Delete a geodispersion analysis from the database. |
|
243 | + * |
|
244 | + * @param GeoAnalysis $ga |
|
245 | + */ |
|
246 | + public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
247 | + Database::prepare( |
|
248 | + 'DELETE FROM `##maj_geodispersion`'. |
|
249 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
250 | + )->execute(array( |
|
251 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
252 | + 'ga_id' => $ga->getId() |
|
253 | + )); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | - * |
|
259 | - * @return array List of enabled maps |
|
260 | - */ |
|
261 | - public function getGeoAnalysisList(){ |
|
262 | - $res = array(); |
|
256 | + /** |
|
257 | + * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
258 | + * |
|
259 | + * @return array List of enabled maps |
|
260 | + */ |
|
261 | + public function getGeoAnalysisList(){ |
|
262 | + $res = array(); |
|
263 | 263 | |
264 | - $list = Database::prepare( |
|
265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | - ' FROM `##maj_geodispersion`' . |
|
267 | - ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | - ' ORDER BY majgd_descr' |
|
269 | - )->execute(array( |
|
270 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | - 'status' => 'enabled' |
|
272 | - ))->fetchAll(\PDO::FETCH_ASSOC); |
|
264 | + $list = Database::prepare( |
|
265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | + ' FROM `##maj_geodispersion`' . |
|
267 | + ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
268 | + ' ORDER BY majgd_descr' |
|
269 | + )->execute(array( |
|
270 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
271 | + 'status' => 'enabled' |
|
272 | + ))->fetchAll(\PDO::FETCH_ASSOC); |
|
273 | 273 | |
274 | - foreach($list as $ga) { |
|
275 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | - } |
|
274 | + foreach($list as $ga) { |
|
275 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
276 | + } |
|
277 | 277 | |
278 | - return $res; |
|
279 | - } |
|
278 | + return $res; |
|
279 | + } |
|
280 | 280 | |
281 | - /** |
|
282 | - * Return the list of geodispersion analysis matching specified criterias. |
|
283 | - * |
|
284 | - * @param string $search Search criteria in analysis description |
|
285 | - * @param array $order_by Columns to order by |
|
286 | - * @param int $start Offset to start with (for pagination) |
|
287 | - * @param int|null $limit Max number of items to return (for pagination) |
|
288 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | - */ |
|
290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | - $res = array(); |
|
281 | + /** |
|
282 | + * Return the list of geodispersion analysis matching specified criterias. |
|
283 | + * |
|
284 | + * @param string $search Search criteria in analysis description |
|
285 | + * @param array $order_by Columns to order by |
|
286 | + * @param int $start Offset to start with (for pagination) |
|
287 | + * @param int|null $limit Max number of items to return (for pagination) |
|
288 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
289 | + */ |
|
290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
291 | + $res = array(); |
|
292 | 292 | |
293 | - $sql = |
|
294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | - ' FROM `##maj_geodispersion`' . |
|
296 | - ' WHERE majgd_file = :gedcom_id'; |
|
293 | + $sql = |
|
294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | + ' FROM `##maj_geodispersion`' . |
|
296 | + ' WHERE majgd_file = :gedcom_id'; |
|
297 | 297 | |
298 | - $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
298 | + $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
299 | 299 | |
300 | - if($search) { |
|
301 | - $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | - $args['search'] = $search; |
|
303 | - } |
|
300 | + if($search) { |
|
301 | + $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
302 | + $args['search'] = $search; |
|
303 | + } |
|
304 | 304 | |
305 | - if ($order_by) { |
|
306 | - $sql .= ' ORDER BY '; |
|
307 | - foreach ($order_by as $key => $value) { |
|
308 | - if ($key > 0) { |
|
309 | - $sql .= ','; |
|
310 | - } |
|
305 | + if ($order_by) { |
|
306 | + $sql .= ' ORDER BY '; |
|
307 | + foreach ($order_by as $key => $value) { |
|
308 | + if ($key > 0) { |
|
309 | + $sql .= ','; |
|
310 | + } |
|
311 | 311 | |
312 | - switch ($value['dir']) { |
|
313 | - case 'asc': |
|
314 | - $sql .= $value['column'] . ' ASC '; |
|
315 | - break; |
|
316 | - case 'desc': |
|
317 | - $sql .= $value['column'] . ' DESC '; |
|
318 | - break; |
|
319 | - } |
|
320 | - } |
|
321 | - } else { |
|
322 | - $sql .= ' ORDER BY majgd_descr ASC'; |
|
323 | - } |
|
312 | + switch ($value['dir']) { |
|
313 | + case 'asc': |
|
314 | + $sql .= $value['column'] . ' ASC '; |
|
315 | + break; |
|
316 | + case 'desc': |
|
317 | + $sql .= $value['column'] . ' DESC '; |
|
318 | + break; |
|
319 | + } |
|
320 | + } |
|
321 | + } else { |
|
322 | + $sql .= ' ORDER BY majgd_descr ASC'; |
|
323 | + } |
|
324 | 324 | |
325 | - if ($limit) { |
|
326 | - $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | - $args['limit'] = $limit; |
|
328 | - $args['offset'] = $start; |
|
329 | - } |
|
325 | + if ($limit) { |
|
326 | + $sql .= " LIMIT :limit OFFSET :offset"; |
|
327 | + $args['limit'] = $limit; |
|
328 | + $args['offset'] = $start; |
|
329 | + } |
|
330 | 330 | |
331 | - $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
331 | + $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
332 | 332 | |
333 | - foreach($data as $ga) { |
|
334 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | - } |
|
333 | + foreach($data as $ga) { |
|
334 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
335 | + } |
|
336 | 336 | |
337 | - return $res; |
|
338 | - } |
|
337 | + return $res; |
|
338 | + } |
|
339 | 339 | |
340 | - /** |
|
341 | - * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | - * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | - * This is returned as an associative array: |
|
344 | - * - type: describe the source of the data (<em>header<em> / <em>data</em> / <em>none</em>) |
|
345 | - * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | - * |
|
347 | - * @return array |
|
348 | - */ |
|
349 | - public function getPlacesHierarchy() { |
|
350 | - if(!$this->place_hierarchy) { |
|
351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | - $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | - } |
|
354 | - elseif ($place_structure = $this->getPlacesHierarchyFromData()){ |
|
355 | - $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure); |
|
356 | - } |
|
357 | - else { |
|
358 | - $this->place_hierarchy = array('type' => 'none', 'hierarchy' => null); |
|
359 | - } |
|
360 | - } |
|
361 | - return $this->place_hierarchy; |
|
362 | - } |
|
340 | + /** |
|
341 | + * Returns the infered place hierarchy, determined from the Gedcom data. |
|
342 | + * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
343 | + * This is returned as an associative array: |
|
344 | + * - type: describe the source of the data (<em>header<em> / <em>data</em> / <em>none</em>) |
|
345 | + * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
346 | + * |
|
347 | + * @return array |
|
348 | + */ |
|
349 | + public function getPlacesHierarchy() { |
|
350 | + if(!$this->place_hierarchy) { |
|
351 | + if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | + $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
353 | + } |
|
354 | + elseif ($place_structure = $this->getPlacesHierarchyFromData()){ |
|
355 | + $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure); |
|
356 | + } |
|
357 | + else { |
|
358 | + $this->place_hierarchy = array('type' => 'none', 'hierarchy' => null); |
|
359 | + } |
|
360 | + } |
|
361 | + return $this->place_hierarchy; |
|
362 | + } |
|
363 | 363 | |
364 | - /** |
|
365 | - * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
366 | - * The places are reversed compared to normal GEDCOM structure. |
|
367 | - * |
|
368 | - * @return array|null |
|
369 | - */ |
|
370 | - protected function getPlacesHierarchyFromHeader() { |
|
371 | - $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
372 | - $head_place = $head->getFirstFact('PLAC'); |
|
373 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
374 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
375 | - } |
|
376 | - return null; |
|
377 | - } |
|
364 | + /** |
|
365 | + * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
366 | + * The places are reversed compared to normal GEDCOM structure. |
|
367 | + * |
|
368 | + * @return array|null |
|
369 | + */ |
|
370 | + protected function getPlacesHierarchyFromHeader() { |
|
371 | + $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
372 | + $head_place = $head->getFirstFact('PLAC'); |
|
373 | + if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
374 | + return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
375 | + } |
|
376 | + return null; |
|
377 | + } |
|
378 | 378 | |
379 | - /** |
|
380 | - * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
381 | - * It will look for the longest hierarchy in the tree. |
|
382 | - * The places are reversed compared to normal GEDCOM structure. |
|
383 | - * |
|
384 | - * @return array |
|
385 | - */ |
|
386 | - protected function getPlacesHierarchyFromData() { |
|
387 | - $nb_levels = 0; |
|
379 | + /** |
|
380 | + * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
381 | + * It will look for the longest hierarchy in the tree. |
|
382 | + * The places are reversed compared to normal GEDCOM structure. |
|
383 | + * |
|
384 | + * @return array |
|
385 | + */ |
|
386 | + protected function getPlacesHierarchyFromData() { |
|
387 | + $nb_levels = 0; |
|
388 | 388 | |
389 | - //Select all '2 PLAC ' tags in the file and create array |
|
390 | - $places_list=array(); |
|
391 | - $ged_data = Database::prepare( |
|
392 | - 'SELECT i_gedcom AS gedcom'. |
|
393 | - ' FROM `##individuals`'. |
|
394 | - ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
395 | - ' UNION ALL'. |
|
396 | - ' SELECT f_gedcom AS gedcom'. |
|
397 | - ' FROM `##families`'. |
|
398 | - ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
399 | - )->execute(array( |
|
400 | - 'gedcom' => '%2 PLAC %', |
|
401 | - 'gedcom_id' => $this->tree->getTreeId() |
|
402 | - ))->fetchOneColumn(); |
|
403 | - foreach ($ged_data as $ged_datum) { |
|
404 | - $matches = null; |
|
405 | - preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
406 | - foreach ($matches[1] as $match) { |
|
407 | - $places_list[$match]=true; |
|
408 | - } |
|
409 | - } |
|
389 | + //Select all '2 PLAC ' tags in the file and create array |
|
390 | + $places_list=array(); |
|
391 | + $ged_data = Database::prepare( |
|
392 | + 'SELECT i_gedcom AS gedcom'. |
|
393 | + ' FROM `##individuals`'. |
|
394 | + ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
395 | + ' UNION ALL'. |
|
396 | + ' SELECT f_gedcom AS gedcom'. |
|
397 | + ' FROM `##families`'. |
|
398 | + ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
399 | + )->execute(array( |
|
400 | + 'gedcom' => '%2 PLAC %', |
|
401 | + 'gedcom_id' => $this->tree->getTreeId() |
|
402 | + ))->fetchOneColumn(); |
|
403 | + foreach ($ged_data as $ged_datum) { |
|
404 | + $matches = null; |
|
405 | + preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
406 | + foreach ($matches[1] as $match) { |
|
407 | + $places_list[$match]=true; |
|
408 | + } |
|
409 | + } |
|
410 | 410 | |
411 | - // Get the places with higest numbers of levels |
|
412 | - $places_with_high_level = array(); |
|
413 | - $max_level = 0; |
|
411 | + // Get the places with higest numbers of levels |
|
412 | + $places_with_high_level = array(); |
|
413 | + $max_level = 0; |
|
414 | 414 | |
415 | - foreach ($places_list as $place => $value) { |
|
416 | - $levels = array_filter(array_map('trim', explode(",", $place))); |
|
417 | - $parts = count($levels); |
|
418 | - if($parts > $max_level) { |
|
419 | - $max_level = $parts; |
|
420 | - $places_with_high_level = array($place); |
|
421 | - } |
|
422 | - else if ($parts == $max_level) { |
|
423 | - $places_with_high_level[] = $place; |
|
424 | - } |
|
425 | - } |
|
415 | + foreach ($places_list as $place => $value) { |
|
416 | + $levels = array_filter(array_map('trim', explode(",", $place))); |
|
417 | + $parts = count($levels); |
|
418 | + if($parts > $max_level) { |
|
419 | + $max_level = $parts; |
|
420 | + $places_with_high_level = array($place); |
|
421 | + } |
|
422 | + else if ($parts == $max_level) { |
|
423 | + $places_with_high_level[] = $place; |
|
424 | + } |
|
425 | + } |
|
426 | 426 | |
427 | - // If empty array, then return null |
|
428 | - if($max_level == 0) return null; |
|
427 | + // If empty array, then return null |
|
428 | + if($max_level == 0) return null; |
|
429 | 429 | |
430 | - // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used |
|
431 | - usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp')); |
|
432 | - return array_reverse(array_map('trim',explode(',', $places_with_high_level[0]))); |
|
430 | + // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used |
|
431 | + usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp')); |
|
432 | + return array_reverse(array_map('trim',explode(',', $places_with_high_level[0]))); |
|
433 | 433 | |
434 | - } |
|
434 | + } |
|
435 | 435 | |
436 | - /** |
|
437 | - * Returns the list of geodispersion maps available within the maps folder. |
|
438 | - * |
|
439 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
440 | - */ |
|
441 | - public function getOutlineMapsList() { |
|
442 | - $res = array(); |
|
443 | - $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
444 | - if(is_dir($root_path)){ |
|
445 | - $dir = opendir($root_path); |
|
446 | - while (($file=readdir($dir))!== false) { |
|
447 | - if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
448 | - $res[base64_encode($file)] = new OutlineMap($file, true); |
|
449 | - } |
|
450 | - } |
|
451 | - } |
|
452 | - return $res; |
|
453 | - } |
|
436 | + /** |
|
437 | + * Returns the list of geodispersion maps available within the maps folder. |
|
438 | + * |
|
439 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
440 | + */ |
|
441 | + public function getOutlineMapsList() { |
|
442 | + $res = array(); |
|
443 | + $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
444 | + if(is_dir($root_path)){ |
|
445 | + $dir = opendir($root_path); |
|
446 | + while (($file=readdir($dir))!== false) { |
|
447 | + if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
448 | + $res[base64_encode($file)] = new OutlineMap($file, true); |
|
449 | + } |
|
450 | + } |
|
451 | + } |
|
452 | + return $res; |
|
453 | + } |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | \ No newline at end of file |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
66 | 66 | ->setMaxDetailsInGen($row['majgd_detailsgen']); |
67 | 67 | |
68 | - if($row['majgd_map']) { |
|
68 | + if ($row['majgd_map']) { |
|
69 | 69 | $options |
70 | 70 | ->setMap(new OutlineMap($row['majgd_map'])) |
71 | 71 | ->setMapLevel($row['majgd_toplevel']); |
72 | 72 | } |
73 | 73 | |
74 | 74 | $enabled = true; |
75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
75 | + if (isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
76 | 76 | $enabled = false; |
77 | 77 | } |
78 | 78 | |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getGeoAnalysisCount() { |
95 | 95 | return Database::prepare( |
96 | - 'SELECT COUNT(majgd_id)' . |
|
97 | - ' FROM `##maj_geodispersion`' . |
|
96 | + 'SELECT COUNT(majgd_id)'. |
|
97 | + ' FROM `##maj_geodispersion`'. |
|
98 | 98 | ' WHERE majgd_file = :gedcom_id' |
99 | 99 | )->execute(array( |
100 | 100 | 'gedcom_id' => $this->tree->getTreeId() |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
111 | 111 | */ |
112 | 112 | public function getGeoAnalysis($id, $only_enabled = true) { |
113 | - $args = array ( |
|
113 | + $args = array( |
|
114 | 114 | 'gedcom_id' => $this->tree->getTreeId(), |
115 | 115 | 'ga_id' => $id |
116 | 116 | ); |
117 | 117 | |
118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
119 | - ' FROM `##maj_geodispersion`' . |
|
118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'. |
|
119 | + ' FROM `##maj_geodispersion`'. |
|
120 | 120 | ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
121 | - if($only_enabled) { |
|
121 | + if ($only_enabled) { |
|
122 | 122 | $sql .= ' AND majgd_status = :status'; |
123 | 123 | $args['status'] = 'enabled'; |
124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
128 | 128 | |
129 | - if($ga_array) { |
|
129 | + if ($ga_array) { |
|
130 | 130 | return $this->loadGeoAnalysisFromRow($ga_array); |
131 | 131 | } |
132 | 132 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @return GeoAnalysis |
147 | 147 | */ |
148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
149 | - try{ |
|
149 | + try { |
|
150 | 150 | Database::beginTransaction(); |
151 | 151 | |
152 | 152 | Database::prepare( |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | Database::commit(); |
170 | 170 | } |
171 | - catch(\Exception $ex) { |
|
171 | + catch (\Exception $ex) { |
|
172 | 172 | Database::rollback(); |
173 | 173 | $ga = null; |
174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | |
212 | 212 | Database::commit(); |
213 | 213 | } |
214 | - catch(\Exception $ex) { |
|
214 | + catch (\Exception $ex) { |
|
215 | 215 | Database::rollback(); |
216 | - Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
|
216 | + Log::addErrorLog('The Geo Analysis ID “'.$ga->getId().'” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
|
217 | 217 | $ga = null; |
218 | 218 | } |
219 | 219 | return $ga; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return array List of enabled maps |
260 | 260 | */ |
261 | - public function getGeoAnalysisList(){ |
|
261 | + public function getGeoAnalysisList() { |
|
262 | 262 | $res = array(); |
263 | 263 | |
264 | 264 | $list = Database::prepare( |
265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
266 | - ' FROM `##maj_geodispersion`' . |
|
265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen'. |
|
266 | + ' FROM `##maj_geodispersion`'. |
|
267 | 267 | ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
268 | 268 | ' ORDER BY majgd_descr' |
269 | 269 | )->execute(array( |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | 'status' => 'enabled' |
272 | 272 | ))->fetchAll(\PDO::FETCH_ASSOC); |
273 | 273 | |
274 | - foreach($list as $ga) { |
|
274 | + foreach ($list as $ga) { |
|
275 | 275 | $res[] = $this->loadGeoAnalysisFromRow($ga); |
276 | 276 | } |
277 | 277 | |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | * @param int|null $limit Max number of items to return (for pagination) |
288 | 288 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
289 | 289 | */ |
290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null) { |
|
291 | 291 | $res = array(); |
292 | 292 | |
293 | 293 | $sql = |
294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
295 | - ' FROM `##maj_geodispersion`' . |
|
294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'. |
|
295 | + ' FROM `##maj_geodispersion`'. |
|
296 | 296 | ' WHERE majgd_file = :gedcom_id'; |
297 | 297 | |
298 | 298 | $args = array('gedcom_id'=> $this->tree->getTreeId()); |
299 | 299 | |
300 | - if($search) { |
|
300 | + if ($search) { |
|
301 | 301 | $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
302 | 302 | $args['search'] = $search; |
303 | 303 | } |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | |
312 | 312 | switch ($value['dir']) { |
313 | 313 | case 'asc': |
314 | - $sql .= $value['column'] . ' ASC '; |
|
314 | + $sql .= $value['column'].' ASC '; |
|
315 | 315 | break; |
316 | 316 | case 'desc': |
317 | - $sql .= $value['column'] . ' DESC '; |
|
317 | + $sql .= $value['column'].' DESC '; |
|
318 | 318 | break; |
319 | 319 | } |
320 | 320 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | |
331 | 331 | $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
332 | 332 | |
333 | - foreach($data as $ga) { |
|
333 | + foreach ($data as $ga) { |
|
334 | 334 | $res[] = $this->loadGeoAnalysisFromRow($ga); |
335 | 335 | } |
336 | 336 | |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | * @return array |
348 | 348 | */ |
349 | 349 | public function getPlacesHierarchy() { |
350 | - if(!$this->place_hierarchy) { |
|
351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
350 | + if (!$this->place_hierarchy) { |
|
351 | + if ($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
352 | 352 | $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
353 | 353 | } |
354 | - elseif ($place_structure = $this->getPlacesHierarchyFromData()){ |
|
354 | + elseif ($place_structure = $this->getPlacesHierarchyFromData()) { |
|
355 | 355 | $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure); |
356 | 356 | } |
357 | 357 | else { |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | protected function getPlacesHierarchyFromHeader() { |
371 | 371 | $head = GedcomRecord::getInstance('HEAD', $this->tree); |
372 | 372 | $head_place = $head->getFirstFact('PLAC'); |
373 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
374 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
373 | + if ($head_place && $head_place_value = $head_place->getAttribute('FORM')) { |
|
374 | + return array_reverse(array_map('trim', explode(',', $head_place_value))); |
|
375 | 375 | } |
376 | 376 | return null; |
377 | 377 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | $nb_levels = 0; |
388 | 388 | |
389 | 389 | //Select all '2 PLAC ' tags in the file and create array |
390 | - $places_list=array(); |
|
390 | + $places_list = array(); |
|
391 | 391 | $ged_data = Database::prepare( |
392 | 392 | 'SELECT i_gedcom AS gedcom'. |
393 | 393 | ' FROM `##individuals`'. |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $matches = null; |
405 | 405 | preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
406 | 406 | foreach ($matches[1] as $match) { |
407 | - $places_list[$match]=true; |
|
407 | + $places_list[$match] = true; |
|
408 | 408 | } |
409 | 409 | } |
410 | 410 | |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | foreach ($places_list as $place => $value) { |
416 | 416 | $levels = array_filter(array_map('trim', explode(",", $place))); |
417 | 417 | $parts = count($levels); |
418 | - if($parts > $max_level) { |
|
418 | + if ($parts > $max_level) { |
|
419 | 419 | $max_level = $parts; |
420 | 420 | $places_with_high_level = array($place); |
421 | 421 | } |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | // If empty array, then return null |
428 | - if($max_level == 0) return null; |
|
428 | + if ($max_level == 0) return null; |
|
429 | 429 | |
430 | 430 | // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used |
431 | 431 | usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp')); |
432 | - return array_reverse(array_map('trim',explode(',', $places_with_high_level[0]))); |
|
432 | + return array_reverse(array_map('trim', explode(',', $places_with_high_level[0]))); |
|
433 | 433 | |
434 | 434 | } |
435 | 435 | |
@@ -441,9 +441,9 @@ discard block |
||
441 | 441 | public function getOutlineMapsList() { |
442 | 442 | $res = array(); |
443 | 443 | $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
444 | - if(is_dir($root_path)){ |
|
444 | + if (is_dir($root_path)) { |
|
445 | 445 | $dir = opendir($root_path); |
446 | - while (($file=readdir($dir))!== false) { |
|
446 | + while (($file = readdir($dir)) !== false) { |
|
447 | 447 | if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
448 | 448 | $res[base64_encode($file)] = new OutlineMap($file, true); |
449 | 449 | } |
@@ -167,8 +167,7 @@ discard block |
||
167 | 167 | $ga = $this->getGeoAnalysis($id, false); |
168 | 168 | |
169 | 169 | Database::commit(); |
170 | - } |
|
171 | - catch(\Exception $ex) { |
|
170 | + } catch(\Exception $ex) { |
|
172 | 171 | Database::rollback(); |
173 | 172 | $ga = null; |
174 | 173 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
@@ -210,8 +209,7 @@ discard block |
||
210 | 209 | $ga = $this->getGeoAnalysis($ga->getId(), false); |
211 | 210 | |
212 | 211 | Database::commit(); |
213 | - } |
|
214 | - catch(\Exception $ex) { |
|
212 | + } catch(\Exception $ex) { |
|
215 | 213 | Database::rollback(); |
216 | 214 | Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
217 | 215 | $ga = null; |
@@ -350,11 +348,9 @@ discard block |
||
350 | 348 | if(!$this->place_hierarchy) { |
351 | 349 | if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
352 | 350 | $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
353 | - } |
|
354 | - elseif ($place_structure = $this->getPlacesHierarchyFromData()){ |
|
351 | + } elseif ($place_structure = $this->getPlacesHierarchyFromData()){ |
|
355 | 352 | $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $place_structure); |
356 | - } |
|
357 | - else { |
|
353 | + } else { |
|
358 | 354 | $this->place_hierarchy = array('type' => 'none', 'hierarchy' => null); |
359 | 355 | } |
360 | 356 | } |
@@ -418,14 +414,15 @@ discard block |
||
418 | 414 | if($parts > $max_level) { |
419 | 415 | $max_level = $parts; |
420 | 416 | $places_with_high_level = array($place); |
421 | - } |
|
422 | - else if ($parts == $max_level) { |
|
417 | + } else if ($parts == $max_level) { |
|
423 | 418 | $places_with_high_level[] = $place; |
424 | 419 | } |
425 | 420 | } |
426 | 421 | |
427 | 422 | // If empty array, then return null |
428 | - if($max_level == 0) return null; |
|
423 | + if($max_level == 0) { |
|
424 | + return null; |
|
425 | + } |
|
429 | 426 | |
430 | 427 | // Else, return the first alphabetical element -- cannot return random to ensure always the same example if used |
431 | 428 | usort($places_with_high_level, array('Fisharebest\\Webtrees\\I18N', 'strcasecmp')); |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | * {@inhericDoc} |
24 | 24 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
25 | 25 | */ |
26 | - protected function renderContent() { |
|
26 | + protected function renderContent() { |
|
27 | 27 | |
28 | - /** @var Tree $tree */ |
|
29 | - $tree = $this->data->get('tree'); |
|
30 | - $root_url = $this->data->get('root_url'); |
|
31 | - $other_trees = $this->data->get('other_trees'); |
|
32 | - $table_id = $this->data->get('table_id'); |
|
33 | - ?> |
|
28 | + /** @var Tree $tree */ |
|
29 | + $tree = $this->data->get('tree'); |
|
30 | + $root_url = $this->data->get('root_url'); |
|
31 | + $other_trees = $this->data->get('other_trees'); |
|
32 | + $table_id = $this->data->get('table_id'); |
|
33 | + ?> |
|
34 | 34 | <ol class="breadcrumb small"> |
35 | 35 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
36 | 36 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -63,23 +63,23 @@ discard block |
||
63 | 63 | <p> |
64 | 64 | <?php $places_hierarchy = $this->data->get('places_hierarchy'); |
65 | 65 | if($places_hierarchy && $places_hierarchy['type'] != 'none') { |
66 | - switch ($places_hierarchy['type']) { |
|
67 | - case 'header': |
|
68 | - echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: '); |
|
69 | - break; |
|
70 | - case 'data': |
|
71 | - echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.'). |
|
72 | - '<br/>'. |
|
73 | - I18N::translate('Here is an example of your place data: '); |
|
74 | - break; |
|
75 | - default: |
|
76 | - break; |
|
77 | - } |
|
78 | - $str_hierarchy = array(); |
|
79 | - foreach($places_hierarchy['hierarchy'] as $key => $level) { |
|
80 | - $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level); |
|
81 | - } |
|
82 | - echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>'; |
|
66 | + switch ($places_hierarchy['type']) { |
|
67 | + case 'header': |
|
68 | + echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: '); |
|
69 | + break; |
|
70 | + case 'data': |
|
71 | + echo I18N::translate('Your GEDCOM header does not contain any indication of place structure.'). |
|
72 | + '<br/>'. |
|
73 | + I18N::translate('Here is an example of your place data: '); |
|
74 | + break; |
|
75 | + default: |
|
76 | + break; |
|
77 | + } |
|
78 | + $str_hierarchy = array(); |
|
79 | + foreach($places_hierarchy['hierarchy'] as $key => $level) { |
|
80 | + $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level); |
|
81 | + } |
|
82 | + echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>'; |
|
83 | 83 | } |
84 | 84 | ?> |
85 | 85 | </p> |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | </a> |
110 | 110 | |
111 | 111 | <?php |
112 | - } |
|
112 | + } |
|
113 | 113 | |
114 | 114 | } |
115 | 115 | |
116 | 116 | \ No newline at end of file |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | |
42 | 42 | <h2> |
43 | 43 | <?php echo $tree->getTitleHtml(); ?> |
44 | - <?php if(count($other_trees) > 0) {?> |
|
44 | + <?php if (count($other_trees) > 0) {?> |
|
45 | 45 | <div class="btn-group"> |
46 | 46 | <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> |
47 | 47 | <?php echo I18N::translate('Change tree'); ?> |
48 | 48 | <span class="caret"></span> |
49 | 49 | </button> |
50 | - <?php foreach($other_trees as $other_tree) { ?> |
|
50 | + <?php foreach ($other_trees as $other_tree) { ?> |
|
51 | 51 | <ul class="dropdown-menu" role="menu"> |
52 | 52 | <li> |
53 | - <a href="<?php echo $root_url . '&ged=' . $other_tree->getNameUrl(); ?>"> |
|
53 | + <a href="<?php echo $root_url.'&ged='.$other_tree->getNameUrl(); ?>"> |
|
54 | 54 | <i class="fa fa-fw fa-tree"></i> <?php echo $other_tree->getTitleHtml(); ?> |
55 | 55 | </a> |
56 | 56 | </li> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | <p> |
64 | 64 | <?php $places_hierarchy = $this->data->get('places_hierarchy'); |
65 | - if($places_hierarchy && $places_hierarchy['type'] != 'none') { |
|
65 | + if ($places_hierarchy && $places_hierarchy['type'] != 'none') { |
|
66 | 66 | switch ($places_hierarchy['type']) { |
67 | 67 | case 'header': |
68 | 68 | echo I18N::translate('According to the GEDCOM header, the places within your file follows the structure: '); |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | break; |
77 | 77 | } |
78 | 78 | $str_hierarchy = array(); |
79 | - foreach($places_hierarchy['hierarchy'] as $key => $level) { |
|
79 | + foreach ($places_hierarchy['hierarchy'] as $key => $level) { |
|
80 | 80 | $str_hierarchy[] = I18N::translate('(%d) %s', $key + 1, $level); |
81 | 81 | } |
82 | - echo '<strong>' . implode(I18N::$list_separator, $str_hierarchy) . '</strong>'; |
|
82 | + echo '<strong>'.implode(I18N::$list_separator, $str_hierarchy).'</strong>'; |
|
83 | 83 | } |
84 | 84 | ?> |
85 | 85 | </p> |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | </tbody> |
104 | 104 | </table> |
105 | 105 | |
106 | - <a type="button" class="btn btn-primary" href="<?php echo $root_url . '@add&ged=' . $tree->getNameUrl(); ?>" title="<?php echo I18N::translate('Add'); ?>"> |
|
106 | + <a type="button" class="btn btn-primary" href="<?php echo $root_url.'@add&ged='.$tree->getNameUrl(); ?>" title="<?php echo I18N::translate('Add'); ?>"> |
|
107 | 107 | <i class="fa fa-plus"></i> |
108 | 108 | <?php echo I18N::translate('Add'); ?> |
109 | 109 | </a> |