@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | /** @var OutlineMap $map */ |
31 | 31 | $map = $this->data->get('map'); |
32 | 32 | |
33 | - if($map === null) { |
|
34 | - return '<p class="warning">' . |
|
35 | - I18N::translate('The map could not be loaded.') . |
|
33 | + if ($map === null) { |
|
34 | + return '<p class="warning">'. |
|
35 | + I18N::translate('The map could not be loaded.'). |
|
36 | 36 | '</p>'; |
37 | 37 | } |
38 | 38 | |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | } |
83 | 83 | }); |
84 | 84 | |
85 | - var paper = new Raphael(document.getElementById("geodispersion_map"), '. $canvas->width .', '. $canvas->height .'); |
|
86 | - var background = paper.rect(0, 0, ' . $canvas->width . ', '. $canvas->height . '); |
|
87 | - background.attr({"fill" : "'. $canvas->background_color .'", "stroke" : "'. $canvas->background_stroke .'", "stroke-width": 1, "stroke-linejoin": "round" }); |
|
88 | - var attr = { fill: "'. $canvas->default_color .'", stroke: "'. $canvas->default_stroke .'", "stroke-width": 1, "stroke-linejoin": "round" }; |
|
85 | + var paper = new Raphael(document.getElementById("geodispersion_map"), '. $canvas->width.', '.$canvas->height.'); |
|
86 | + var background = paper.rect(0, 0, ' . $canvas->width.', '.$canvas->height.'); |
|
87 | + background.attr({"fill" : "'. $canvas->background_color.'", "stroke" : "'.$canvas->background_stroke.'", "stroke-width": 1, "stroke-linejoin": "round" }); |
|
88 | + var attr = { fill: "'. $canvas->default_color.'", stroke: "'.$canvas->default_stroke.'", "stroke-width": 1, "stroke-linejoin": "round" }; |
|
89 | 89 | var map = {}; |
90 | 90 | '; |
91 | 91 | |
92 | - foreach($subdvisions_results as $name => $location){ |
|
93 | - $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | - if(isset($location['transparency'])) { |
|
92 | + foreach ($subdvisions_results as $name => $location) { |
|
93 | + $html .= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | + if (isset($location['transparency'])) { |
|
95 | 95 | $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
96 | - if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
96 | + if ($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
97 | 97 | $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
98 | - $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | - $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | - $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
98 | + $html .= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | + $html .= 'map.area'.$location['id'].'.attr({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | + $html .= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->hover_color.'", "fill-opacity" : 1}, 100, "linear");'. |
|
102 | 102 | '});'. |
103 | 103 | 'map.area'.$location['id'].'.mouseout(function () {'. |
104 | 104 | 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $data->set('title', $controller->getPageTitle()); |
72 | 72 | $data->set('tree', $wt_tree); |
73 | 73 | |
74 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
74 | + $data->set('root_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig'); |
|
75 | 75 | |
76 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
76 | + $table_id = 'table-geoanalysis-'.Uuid::uuid4(); |
|
77 | 77 | $data->set('table_id', $table_id); |
78 | 78 | |
79 | 79 | $other_trees = array(); |
80 | 80 | foreach (Tree::getAll() as $tree) { |
81 | - if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
81 | + if ($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
82 | 82 | } |
83 | 83 | $data->set('other_trees', $other_trees); |
84 | 84 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | processing: true, |
102 | 102 | serverSide : true, |
103 | 103 | ajax : { |
104 | - url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='. $wt_tree->getNameUrl().'", |
|
104 | + url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='.$wt_tree->getNameUrl().'", |
|
105 | 105 | type : "POST" |
106 | 106 | }, |
107 | 107 | columns: [ |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | url: "module.php", |
126 | 126 | type: "GET", |
127 | 127 | data: { |
128 | - mod: "' . $this->module->getName() .'", |
|
128 | + mod: "' . $this->module->getName().'", |
|
129 | 129 | mod_action: "GeoAnalysis@setStatus", |
130 | 130 | ga_id: ga_id, |
131 | 131 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom, |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | }, |
134 | 134 | error: function(result, stat, error) { |
135 | 135 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
136 | - alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err); |
|
136 | + alert("' . I18N::translate('An error occured while editing this analysis:').'" + err); |
|
137 | 137 | }, |
138 | 138 | complete: function(result, stat) { |
139 | 139 | geoAnalysisTable.ajax.reload(null, false); |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | url: "module.php", |
147 | 147 | type: "GET", |
148 | 148 | data: { |
149 | - mod: "' . $this->module->getName() .'", |
|
149 | + mod: "' . $this->module->getName().'", |
|
150 | 150 | mod_action: "GeoAnalysis@delete", |
151 | 151 | ga_id: ga_id, |
152 | 152 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom |
153 | 153 | }, |
154 | 154 | error: function(result, stat, error) { |
155 | 155 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
156 | - alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err); |
|
156 | + alert("' . I18N::translate('An error occured while deleting this analysis:').'" + err); |
|
157 | 157 | }, |
158 | 158 | complete: function(result, stat) { |
159 | 159 | geoAnalysisTable.ajax.reload(null, false); |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | |
178 | 178 | // Generate an AJAX/JSON response for datatables to load a block of rows |
179 | 179 | $search = Filter::postArray('search'); |
180 | - if($search) $search = $search['value']; |
|
180 | + if ($search) $search = $search['value']; |
|
181 | 181 | $start = Filter::postInteger('start'); |
182 | 182 | $length = Filter::postInteger('length'); |
183 | 183 | $order = Filter::postArray('order'); |
184 | 184 | |
185 | - foreach($order as $key => &$value) { |
|
186 | - switch($value['column']) { |
|
185 | + foreach ($order as $key => &$value) { |
|
186 | + switch ($value['column']) { |
|
187 | 187 | case 3: |
188 | 188 | $value['column'] = 'majgd_descr'; |
189 | 189 | break; |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | |
205 | 205 | $data = array(); |
206 | 206 | $place_hierarchy = $this->provider->getPlacesHierarchy(); |
207 | - foreach($list as $ga) { |
|
207 | + foreach ($list as $ga) { |
|
208 | 208 | /** @var GeoAnalysis $ga */ |
209 | 209 | |
210 | 210 | $datum = array(); |
211 | - $options= $ga->getOptions(); |
|
211 | + $options = $ga->getOptions(); |
|
212 | 212 | |
213 | 213 | $datum[0] = ' |
214 | 214 | <div class="btn-group"> |
@@ -218,45 +218,44 @@ discard block |
||
218 | 218 | <ul class="dropdown-menu" role="menu"> |
219 | 219 | <li> |
220 | 220 | <a href="#" onclick="return set_geoanalysis_status('. $ga->getId().', '.($ga->isEnabled() ? 'false' : 'true').', \''.Filter::escapeJs($wt_tree->getName()).'\');"> |
221 | - <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . ' |
|
221 | + <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).' |
|
222 | 222 | </a> |
223 | 223 | </li> |
224 | 224 | <li> |
225 | 225 | <a href="module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getName().'"> |
226 | - <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . ' |
|
226 | + <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').' |
|
227 | 227 | </a> |
228 | 228 | </li> |
229 | 229 | <li class="divider" /> |
230 | 230 | <li> |
231 | 231 | <a href="#" onclick="return delete_geoanalysis('. $ga->getId().', \''.Filter::escapeJs($wt_tree->getName()).'\');"> |
232 | - <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete') . ' |
|
232 | + <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete').' |
|
233 | 233 | </a> |
234 | 234 | </li> |
235 | 235 | </ul> |
236 | 236 | </div>'; |
237 | 237 | $datum[1] = $ga->getId(); |
238 | 238 | $datum[2] = $ga->isEnabled() ? |
239 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
|
240 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
239 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
241 | 240 | $datum[3] = $ga->getTitle(); |
242 | 241 | $analysis_level = $ga->getAnalysisLevel(); |
243 | - if($place_hierarchy['type'] == 'header') { |
|
242 | + if ($place_hierarchy['type'] == 'header') { |
|
244 | 243 | $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
245 | 244 | } else { |
246 | - $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
245 | + $datum[4] = $analysis_level.'('.$place_hierarchy['hierarchy'][$analysis_level - 1].')'; |
|
247 | 246 | } |
248 | 247 | $datum[5] = $ga->getAnalysisLevel(); |
249 | 248 | $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
250 | 249 | $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
251 | - if($ga->hasMap()) { |
|
252 | - if($options->getMap()->isLoaded()) { |
|
250 | + if ($ga->hasMap()) { |
|
251 | + if ($options->getMap()->isLoaded()) { |
|
253 | 252 | $datum[6] = $options->getMap()->getDescription(); |
254 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
253 | + $datum[7] = '<span data-toggle="tooltip" title="'.$options->getMap()->getTopLevelName().'" />'; |
|
255 | 254 | $top_level = $options->getMapLevel(); |
256 | - if($place_hierarchy['type'] == 'header') { |
|
255 | + if ($place_hierarchy['type'] == 'header') { |
|
257 | 256 | $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
258 | 257 | } else { |
259 | - $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
258 | + $datum[7] .= $top_level.'('.$place_hierarchy['hierarchy'][$top_level - 1].')'; |
|
260 | 259 | } |
261 | 260 | $datum[7] .= '</span>'; |
262 | 261 | } |
@@ -265,8 +264,7 @@ discard block |
||
265 | 264 | } |
266 | 265 | } |
267 | 266 | $datum[8] = $options->isUsingFlags() ? |
268 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
|
269 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
267 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
270 | 268 | $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
271 | 269 | |
272 | 270 | $data[] = $datum; |
@@ -315,24 +313,24 @@ discard block |
||
315 | 313 | $description = Filter::post('description'); |
316 | 314 | $analysislevel = Filter::postInteger('analysislevel'); |
317 | 315 | $use_map = Filter::postBool('use_map'); |
318 | - if($use_map) { |
|
316 | + if ($use_map) { |
|
319 | 317 | $map_file = base64_decode(Filter::post('map_file')); |
320 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
318 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
321 | 319 | } |
322 | 320 | $use_flags = Filter::postBool('use_flags'); |
323 | 321 | $gen_details = Filter::postInteger('gen_details'); |
324 | 322 | |
325 | 323 | $success = false; |
326 | - if($ga_id) { |
|
324 | + if ($ga_id) { |
|
327 | 325 | $ga = $this->provider->getGeoAnalysis($ga_id, false); |
328 | - if($ga) { |
|
326 | + if ($ga) { |
|
329 | 327 | $ga->setTitle($description); |
330 | 328 | $ga->setAnalysisLevel($analysislevel + 1); |
331 | 329 | $options = $ga->getOptions(); |
332 | - if($options) { |
|
330 | + if ($options) { |
|
333 | 331 | $options->setUsingFlags($use_flags); |
334 | 332 | $options->setMaxDetailsInGen($gen_details); |
335 | - if($use_map) { |
|
333 | + if ($use_map) { |
|
336 | 334 | $options->setMap(new OutlineMap($map_file)); |
337 | 335 | $options->setMapLevel($map_top_level + 1); |
338 | 336 | } |
@@ -342,7 +340,7 @@ discard block |
||
342 | 340 | } |
343 | 341 | |
344 | 342 | $res = $this->provider->updateGeoAnalysis($ga); |
345 | - if($res) { |
|
343 | + if ($res) { |
|
346 | 344 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully updated', $res->getTitle()), 'success'); |
347 | 345 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
348 | 346 | $ga = $res; |
@@ -350,7 +348,7 @@ discard block |
||
350 | 348 | } |
351 | 349 | else { |
352 | 350 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
353 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
|
351 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” could not be updated. See error log.'); |
|
354 | 352 | } |
355 | 353 | } |
356 | 354 | } else { |
@@ -362,7 +360,7 @@ discard block |
||
362 | 360 | $use_flags, |
363 | 361 | $gen_details |
364 | 362 | ); |
365 | - if($ga) { |
|
363 | + if ($ga) { |
|
366 | 364 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
367 | 365 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
368 | 366 | $success = true; |
@@ -373,16 +371,16 @@ discard block |
||
373 | 371 | } |
374 | 372 | } |
375 | 373 | |
376 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl(); |
|
377 | - if(!$success) { |
|
378 | - if($ga) { |
|
379 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
|
374 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl(); |
|
375 | + if (!$success) { |
|
376 | + if ($ga) { |
|
377 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getNameUrl(); |
|
380 | 378 | } |
381 | 379 | else { |
382 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
|
380 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@add&ged='.$wt_tree->getNameUrl(); |
|
383 | 381 | } |
384 | 382 | } |
385 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
383 | + header('Location: '.WT_BASE_URL.$redirection_url); |
|
386 | 384 | |
387 | 385 | } |
388 | 386 | |
@@ -412,7 +410,7 @@ discard block |
||
412 | 410 | '); |
413 | 411 | |
414 | 412 | $data = new ViewBag(); |
415 | - if($ga) { |
|
413 | + if ($ga) { |
|
416 | 414 | $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
417 | 415 | $data->set('geo_analysis', $ga); |
418 | 416 | } else { |
@@ -420,9 +418,9 @@ discard block |
||
420 | 418 | } |
421 | 419 | |
422 | 420 | $data->set('title', $controller->getPageTitle()); |
423 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl()); |
|
421 | + $data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl()); |
|
424 | 422 | $data->set('module_title', $this->module->getTitle()); |
425 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl()); |
|
423 | + $data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@save&ged='.$wt_tree->getNameUrl()); |
|
426 | 424 | $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
427 | 425 | |
428 | 426 | $map_list = array_map( |
@@ -435,7 +433,7 @@ discard block |
||
435 | 433 | $data->set('map_list', $map_list); |
436 | 434 | |
437 | 435 | $gen_details = array(0 => I18N::translate('All')); |
438 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
436 | + for ($i = 1; $i <= 10; $i++) $gen_details[$i] = $i; |
|
439 | 437 | $data->set('generation_details', $gen_details); |
440 | 438 | |
441 | 439 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | * @param User $user |
85 | 85 | */ |
86 | 86 | public function __construct(Tree $tree, User $user = null) { |
87 | - if(self::$default_user === null) |
|
87 | + if (self::$default_user === null) |
|
88 | 88 | self::$default_user = User::find(-1); |
89 | 89 | |
90 | 90 | $this->tree = $tree; |
91 | 91 | $this->user = $user; |
92 | 92 | $this->is_setup = true; |
93 | - if($this->user === null) $this->user = Auth::user(); |
|
94 | - if(strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
93 | + if ($this->user === null) $this->user = Auth::user(); |
|
94 | + if (strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
95 | 95 | |
96 | 96 | // Check if the user, or the default user, has a root already setup; |
97 | - if(empty($this->getRootIndiId())) { |
|
98 | - if($this->user == self::$default_user) { // If the default user is not setup |
|
97 | + if (empty($this->getRootIndiId())) { |
|
98 | + if ($this->user == self::$default_user) { // If the default user is not setup |
|
99 | 99 | $this->is_setup = false; |
100 | 100 | } |
101 | 101 | else { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getRootIndi() { |
129 | 129 | $root_indi_id = $this->getRootIndiId(); |
130 | - if(!empty($root_indi_id)) { |
|
130 | + if (!empty($root_indi_id)) { |
|
131 | 131 | return Individual::getInstance($root_indi_id, $this->tree); |
132 | 132 | } |
133 | 133 | return null; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * Remove all Sosa entries related to the gedcom file and user |
142 | 142 | */ |
143 | 143 | public function deleteAll() { |
144 | - if(!$this->is_setup) return; |
|
144 | + if (!$this->is_setup) return; |
|
145 | 145 | Database::prepare( |
146 | 146 | 'DELETE FROM `##maj_sosa`'. |
147 | 147 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | * @param int $sosa |
158 | 158 | */ |
159 | 159 | public function deleteAncestors($sosa) { |
160 | - if(!$this->is_setup) return; |
|
160 | + if (!$this->is_setup) return; |
|
161 | 161 | $gen = Functions::getGeneration($sosa); |
162 | 162 | Database::prepare( |
163 | 163 | 'DELETE FROM `##maj_sosa`'. |
164 | - ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' . |
|
165 | - ' AND majs_gen >= :gen' . |
|
164 | + ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id'. |
|
165 | + ' AND majs_gen >= :gen'. |
|
166 | 166 | ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa' |
167 | 167 | )->execute(array( |
168 | 168 | 'tree_id' => $this->tree->getTreeId(), |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param array $sosa_records |
178 | 178 | */ |
179 | 179 | public function insertOrUpdate($sosa_records) { |
180 | - if(!$this->is_setup) return; |
|
180 | + if (!$this->is_setup) return; |
|
181 | 181 | |
182 | 182 | $treeid = $this->tree->getTreeId(); |
183 | 183 | $userid = $this->user->getUserId(); |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | $values_table = array(); |
186 | 186 | |
187 | 187 | $i = 0; |
188 | - foreach ($sosa_records as $row) { |
|
188 | + foreach ($sosa_records as $row) { |
|
189 | 189 | $gen = Functions::getGeneration($row['sosa']); |
190 | - if($gen <= self::MAX_DB_GENERATIONS) { |
|
190 | + if ($gen <= self::MAX_DB_GENERATIONS) { |
|
191 | 191 | $questionmarks_table[] = |
192 | 192 | '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')'; |
193 | 193 | $values_table = array_merge( |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | $i++; |
207 | 207 | } |
208 | 208 | |
209 | - $sql = 'REPLACE INTO `##maj_sosa`' . |
|
210 | - ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)' . |
|
211 | - ' VALUES '. implode(',', $questionmarks_table); |
|
209 | + $sql = 'REPLACE INTO `##maj_sosa`'. |
|
210 | + ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)'. |
|
211 | + ' VALUES '.implode(',', $questionmarks_table); |
|
212 | 212 | Database::prepare($sql)->execute($values_table); |
213 | 213 | } |
214 | 214 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return array Array of sosa numbers |
225 | 225 | */ |
226 | 226 | public function getSosaNumbers(Individual $indi) { |
227 | - if(!$this->is_setup) return array(); |
|
227 | + if (!$this->is_setup) return array(); |
|
228 | 228 | return Database::prepare( |
229 | 229 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
230 | 230 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return number Last generation if found, 1 otherwise |
242 | 242 | */ |
243 | 243 | public function getLastGeneration() { |
244 | - if(!$this->is_setup) return; |
|
244 | + if (!$this->is_setup) return; |
|
245 | 245 | return Database::prepare( |
246 | 246 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
247 | 247 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
262 | 262 | */ |
263 | - public function getAllSosaWithGenerations(){ |
|
264 | - if(!$this->is_setup) return array(); |
|
263 | + public function getAllSosaWithGenerations() { |
|
264 | + if (!$this->is_setup) return array(); |
|
265 | 265 | return Database::prepare( |
266 | - 'SELECT majs_i_id AS indi,' . |
|
267 | - ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
|
268 | - ' FROM `##maj_sosa`' . |
|
269 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' . |
|
266 | + 'SELECT majs_i_id AS indi,'. |
|
267 | + ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations'. |
|
268 | + ' FROM `##maj_sosa`'. |
|
269 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
270 | 270 | ' GROUP BY majs_i_id' |
271 | 271 | )->execute(array( |
272 | 272 | 'tree_id' => $this->tree->getTreeId(), |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | * @param number $gen Generation |
281 | 281 | * @return array Array of Sosa individuals |
282 | 282 | */ |
283 | - public function getSosaListAtGeneration($gen){ |
|
284 | - if(!$this->is_setup) return array(); |
|
285 | - if(!$this->sosa_list_by_gen) |
|
283 | + public function getSosaListAtGeneration($gen) { |
|
284 | + if (!$this->is_setup) return array(); |
|
285 | + if (!$this->sosa_list_by_gen) |
|
286 | 286 | $this->sosa_list_by_gen = array(); |
287 | 287 | |
288 | - if($gen){ |
|
289 | - if(!isset($this->sosa_list_by_gen[$gen])){ |
|
288 | + if ($gen) { |
|
289 | + if (!isset($this->sosa_list_by_gen[$gen])) { |
|
290 | 290 | $this->sosa_list_by_gen[$gen] = Database::prepare( |
291 | 291 | 'SELECT majs_sosa AS sosa, majs_i_id AS indi'. |
292 | 292 | ' FROM `##maj_sosa`'. |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | * @param number $gen Generation |
312 | 312 | * @return array Array of Sosa families |
313 | 313 | */ |
314 | - public function getFamilySosaListAtGeneration($gen){ |
|
315 | - if(!$this->is_setup) return array(); |
|
316 | - if(!$this->sosa_fam_list_by_gen) |
|
314 | + public function getFamilySosaListAtGeneration($gen) { |
|
315 | + if (!$this->is_setup) return array(); |
|
316 | + if (!$this->sosa_fam_list_by_gen) |
|
317 | 317 | $this->sosa_fam_list_by_gen = array(); |
318 | 318 | |
319 | - if($gen){ |
|
320 | - if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
|
319 | + if ($gen) { |
|
320 | + if (!isset($this->sosa_fam_list_by_gen[$gen])) { |
|
321 | 321 | $this->sosa_fam_list_by_gen[$gen] = Database::prepare( |
322 | 322 | 'SELECT s1.majs_sosa AS sosa, f_id AS fam'. |
323 | 323 | ' FROM `##families`'. |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | * @param number $gen Generation |
348 | 348 | * @return array Array of Sosa individuals |
349 | 349 | */ |
350 | - public function getMissingSosaListAtGeneration($gen){ |
|
351 | - if(!$this->is_setup) return array(); |
|
352 | - if($gen){ |
|
350 | + public function getMissingSosaListAtGeneration($gen) { |
|
351 | + if (!$this->is_setup) return array(); |
|
352 | + if ($gen) { |
|
353 | 353 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
354 | 354 | 'SELECT schild.majs_sosa sosa, schild.majs_i_id indi, sfat.majs_sosa IS NOT NULL has_father, smot.majs_sosa IS NOT NULL has_mother'. |
355 | 355 | ' FROM `##maj_sosa` schild'. |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | * @return array Statistics array |
387 | 387 | */ |
388 | 388 | public function getStatisticsByGeneration() { |
389 | - if(!$this->is_setup) return array(); |
|
390 | - if(!$this->statistics_tab) { |
|
389 | + if (!$this->is_setup) return array(); |
|
390 | + if (!$this->statistics_tab) { |
|
391 | 391 | $this->statistics_tab = array(); |
392 | - if($maxGeneration = $this->getLastGeneration()) { |
|
392 | + if ($maxGeneration = $this->getLastGeneration()) { |
|
393 | 393 | for ($gen = 1; $gen <= $maxGeneration; $gen++) { |
394 | 394 | $birthStats = $this->getStatsBirthYearInGeneration($gen); |
395 | 395 | $this->statistics_tab[$gen] = array( |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @return int |
413 | 413 | */ |
414 | 414 | public function getTotalIndividuals() { |
415 | - if(!$this->is_setup) return 0; |
|
415 | + if (!$this->is_setup) return 0; |
|
416 | 416 | return Database::prepare( |
417 | - 'SELECT COUNT(*) FROM `##individuals`' . |
|
417 | + 'SELECT COUNT(*) FROM `##individuals`'. |
|
418 | 418 | ' WHERE i_file = :tree_id') |
419 | 419 | ->execute(array('tree_id' => $this->tree->getTreeId())) |
420 | 420 | ->fetchOne() ?: 0; |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @return number Number of Sosas |
427 | 427 | */ |
428 | - public function getSosaCount(){ |
|
429 | - if(!$this->is_setup) return 0; |
|
428 | + public function getSosaCount() { |
|
429 | + if (!$this->is_setup) return 0; |
|
430 | 430 | return Database::prepare( |
431 | - 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
431 | + 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
432 | 432 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
433 | 433 | ->execute(array( |
434 | 434 | 'tree_id' => $this->tree->getTreeId(), |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | * @param number $gen Generation |
443 | 443 | * @return number Number of Sosas in generation |
444 | 444 | */ |
445 | - public function getSosaCountAtGeneration($gen){ |
|
446 | - if(!$this->is_setup) return 0; |
|
445 | + public function getSosaCountAtGeneration($gen) { |
|
446 | + if (!$this->is_setup) return 0; |
|
447 | 447 | return Database::prepare( |
448 | - 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
448 | + 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
449 | 449 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
450 | 450 | ' AND majs_gen= :gen') |
451 | 451 | ->execute(array( |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | * @param number $gen Generation |
462 | 462 | * @return number Total number of Sosas up to generation |
463 | 463 | */ |
464 | - public function getSosaCountUpToGeneration($gen){ |
|
465 | - if(!$this->is_setup) return 0; |
|
464 | + public function getSosaCountUpToGeneration($gen) { |
|
465 | + if (!$this->is_setup) return 0; |
|
466 | 466 | return Database::prepare( |
467 | - 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
467 | + 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
468 | 468 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
469 | 469 | ' AND majs_gen <= :gen') |
470 | 470 | ->execute(array( |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return number Total number of distinct individual |
481 | 481 | */ |
482 | - public function getDifferentSosaCount(){ |
|
483 | - if(!$this->is_setup) return 0; |
|
482 | + public function getDifferentSosaCount() { |
|
483 | + if (!$this->is_setup) return 0; |
|
484 | 484 | return Database::prepare( |
485 | - 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
485 | + 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
486 | 486 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
487 | 487 | ->execute(array( |
488 | 488 | 'tree_id' => $this->tree->getTreeId(), |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | * @param number $gen Generation |
497 | 497 | * @return number Number of distinct Sosa individuals up to generation |
498 | 498 | */ |
499 | - public function getDifferentSosaCountUpToGeneration($gen){ |
|
500 | - if(!$this->is_setup) return 0; |
|
499 | + public function getDifferentSosaCountUpToGeneration($gen) { |
|
500 | + if (!$this->is_setup) return 0; |
|
501 | 501 | return Database::prepare( |
502 | - 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
502 | + 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
503 | 503 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
504 | 504 | ' AND majs_gen <= :gen') |
505 | 505 | ->execute(array( |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | * @param number $gen Generation |
520 | 520 | * @return array Birth statistics array |
521 | 521 | */ |
522 | - public function getStatsBirthYearInGeneration($gen){ |
|
523 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
522 | + public function getStatsBirthYearInGeneration($gen) { |
|
523 | + if (!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
524 | 524 | return Database::prepare( |
525 | 525 | 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
526 | - ' FROM `##maj_sosa`' . |
|
526 | + ' FROM `##maj_sosa`'. |
|
527 | 527 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
528 | 528 | ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year') |
529 | 529 | ->execute(array( |
@@ -539,26 +539,26 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return number|NULL Mean generation time |
541 | 541 | */ |
542 | - public function getMeanGenerationTime(){ |
|
543 | - if(!$this->is_setup) return; |
|
544 | - if(!$this->statistics_tab){ |
|
542 | + public function getMeanGenerationTime() { |
|
543 | + if (!$this->is_setup) return; |
|
544 | + if (!$this->statistics_tab) { |
|
545 | 545 | $this->getStatisticsByGeneration(); |
546 | 546 | } |
547 | 547 | //Linear regression on x=generation and y=birthdate |
548 | 548 | $sum_xy = 0; |
549 | - $sum_x=0; |
|
550 | - $sum_y=0; |
|
551 | - $sum_x2=0; |
|
552 | - $n=count($this->statistics_tab); |
|
553 | - foreach($this->statistics_tab as $gen=>$stats){ |
|
554 | - $sum_xy+=$gen*$stats['avgBirth']; |
|
555 | - $sum_x+=$gen; |
|
556 | - $sum_y+=$stats['avgBirth']; |
|
557 | - $sum_x2+=$gen*$gen; |
|
549 | + $sum_x = 0; |
|
550 | + $sum_y = 0; |
|
551 | + $sum_x2 = 0; |
|
552 | + $n = count($this->statistics_tab); |
|
553 | + foreach ($this->statistics_tab as $gen=>$stats) { |
|
554 | + $sum_xy += $gen * $stats['avgBirth']; |
|
555 | + $sum_x += $gen; |
|
556 | + $sum_y += $stats['avgBirth']; |
|
557 | + $sum_x2 += $gen * $gen; |
|
558 | 558 | } |
559 | - $denom=($n*$sum_x2)-($sum_x*$sum_x); |
|
560 | - if($denom!=0){ |
|
561 | - return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom); |
|
559 | + $denom = ($n * $sum_x2) - ($sum_x * $sum_x); |
|
560 | + if ($denom != 0) { |
|
561 | + return -(($n * $sum_xy) - ($sum_x * $sum_y)) / ($denom); |
|
562 | 562 | } |
563 | 563 | return null; |
564 | 564 | } |
@@ -586,14 +586,14 @@ discard block |
||
586 | 586 | * @return array |
587 | 587 | */ |
588 | 588 | public function getAncestorDispersionForGen($gen) { |
589 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
589 | + if (!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
590 | 590 | return Database::prepare( |
591 | 591 | 'SELECT branches, count(i_id)'. |
592 | 592 | ' FROM ('. |
593 | 593 | ' SELECT i_id,'. |
594 | 594 | ' CASE'. |
595 | 595 | ' WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'. |
596 | - ' ELSE -1'. // We put all ancestors shared between some branches in the same bucket |
|
596 | + ' ELSE -1'.// We put all ancestors shared between some branches in the same bucket |
|
597 | 597 | ' END branches'. |
598 | 598 | ' FROM ('. |
599 | 599 | ' SELECT DISTINCT majs_i_id i_id,'. |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @return array |
627 | 627 | */ |
628 | 628 | public function getTopMultiSosaAncestorsNoTies($limit) { |
629 | - if(!$this->is_setup) return array(); |
|
629 | + if (!$this->is_setup) return array(); |
|
630 | 630 | return Database::prepare( |
631 | 631 | 'SELECT sosa_i_id, sosa_count FROM ('. |
632 | 632 | ' SELECT'. |
@@ -639,20 +639,20 @@ discard block |
||
639 | 639 | ' COUNT(sosa.majs_sosa) sosa_count,'. |
640 | 640 | ' MIN(sosa.majs_sosa) sosa_min'. |
641 | 641 | ' FROM ##maj_sosa AS sosa'. |
642 | - ' LEFT JOIN ##maj_sosa AS sosa_fat ON sosa_fat.majs_sosa = 2 * sosa.majs_sosa'. // Link to sosa's father |
|
642 | + ' LEFT JOIN ##maj_sosa AS sosa_fat ON sosa_fat.majs_sosa = 2 * sosa.majs_sosa'.// Link to sosa's father |
|
643 | 643 | ' AND sosa.majs_gedcom_id = sosa_fat.majs_gedcom_id'. |
644 | 644 | ' AND sosa.majs_user_id = sosa_fat.majs_user_id'. |
645 | - ' LEFT JOIN ##maj_sosa AS sosa_mot on sosa_mot.majs_sosa = (2 * sosa.majs_sosa + 1)'. // Link to sosa's mother |
|
645 | + ' LEFT JOIN ##maj_sosa AS sosa_mot on sosa_mot.majs_sosa = (2 * sosa.majs_sosa + 1)'.// Link to sosa's mother |
|
646 | 646 | ' AND sosa.majs_gedcom_id = sosa_fat.majs_gedcom_id'. |
647 | 647 | ' AND sosa.majs_user_id = sosa_fat.majs_user_id'. |
648 | 648 | ' WHERE sosa.majs_gedcom_id = :tree_id'. |
649 | 649 | ' AND sosa.majs_user_id = :user_id'. |
650 | - ' AND sosa_fat.majs_sosa IS NULL'. // We keep only root individuals, i.e. those with no father or mother |
|
650 | + ' AND sosa_fat.majs_sosa IS NULL'.// We keep only root individuals, i.e. those with no father or mother |
|
651 | 651 | ' AND sosa_mot.majs_sosa IS NULL'. |
652 | 652 | ' GROUP BY sosa.majs_i_id'. |
653 | - ' HAVING COUNT(sosa.majs_sosa) > 1'. // Limit to the duplicate sosas. |
|
653 | + ' HAVING COUNT(sosa.majs_sosa) > 1'.// Limit to the duplicate sosas. |
|
654 | 654 | ' ORDER BY COUNT(sosa.majs_sosa) DESC'. |
655 | - ' LIMIT ' . ($limit + 1) . // We want to select one more than required |
|
655 | + ' LIMIT '.($limit + 1).// We want to select one more than required |
|
656 | 656 | ' ) AS top_sosa,'. |
657 | 657 | ' (SELECT @prev_count := 0, @keep := 0) x'. |
658 | 658 | ' ORDER BY top_sosa.sosa_count ASC'. |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->is_loaded = false; |
72 | 72 | $this->subdivisions = array(); |
73 | 73 | $this->mappings = array(); |
74 | - if($load) $this->load(); |
|
74 | + if ($load) $this->load(); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | * |
101 | 101 | */ |
102 | 102 | protected function load() { |
103 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
103 | + if (file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)) { |
|
104 | 104 | $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
105 | - if($xml){ |
|
105 | + if ($xml) { |
|
106 | 106 | $this->description = trim($xml->displayName); |
107 | 107 | $this->top_level_name = trim($xml->topLevel); |
108 | 108 | $this->canvas = new OutlineMapCanvas( |
@@ -115,18 +115,18 @@ discard block |
||
115 | 115 | trim($xml->canvas->defaultcolor), |
116 | 116 | trim($xml->canvas->defaultstroke) |
117 | 117 | ); |
118 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
118 | + foreach ($xml->subdivisions->children() as $subdivision) { |
|
119 | 119 | $attributes = $subdivision->attributes(); |
120 | 120 | $key = I18N::strtolower(trim($attributes['name'])); |
121 | - if(isset($attributes['parent'])) $key .= '@'. I18N::strtolower(trim($attributes['parent'])); |
|
121 | + if (isset($attributes['parent'])) $key .= '@'.I18N::strtolower(trim($attributes['parent'])); |
|
122 | 122 | $this->subdivisions[$key] = array( |
123 | 123 | 'id' => trim($attributes['id']), |
124 | 124 | 'displayname' => trim($attributes['name']), |
125 | 125 | 'coord' => trim($subdivision[0]) |
126 | 126 | ); |
127 | 127 | } |
128 | - if(isset($xml->mappings)) { |
|
129 | - foreach($xml->mappings->children() as $mappings){ |
|
128 | + if (isset($xml->mappings)) { |
|
129 | + foreach ($xml->mappings->children() as $mappings) { |
|
130 | 130 | $attributes = $mappings->attributes(); |
131 | 131 | $this->mappings[I18N::strtolower(trim($attributes['name']))] = I18N::strtolower(trim($attributes['mapto'])); |
132 | 132 | } |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * @return bool |
145 | 145 | */ |
146 | 146 | public function isLoaded() { |
147 | - try{ |
|
148 | - if(!$this->is_loaded) $this->load(); |
|
147 | + try { |
|
148 | + if (!$this->is_loaded) $this->load(); |
|
149 | 149 | } |
150 | 150 | catch (\Exception $ex) { } |
151 | 151 | return $this->is_loaded; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return string |
165 | 165 | */ |
166 | 166 | public function getDescription() { |
167 | - if(!$this->is_loaded) $this->load(); |
|
167 | + if (!$this->is_loaded) $this->load(); |
|
168 | 168 | return $this->description; |
169 | 169 | } |
170 | 170 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return string |
174 | 174 | */ |
175 | 175 | public function getTopLevelName() { |
176 | - if(!$this->is_loaded) $this->load(); |
|
176 | + if (!$this->is_loaded) $this->load(); |
|
177 | 177 | return $this->top_level_name; |
178 | 178 | } |
179 | 179 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
183 | 183 | */ |
184 | 184 | public function getCanvas() { |
185 | - if(!$this->is_loaded) $this->load(); |
|
185 | + if (!$this->is_loaded) $this->load(); |
|
186 | 186 | return $this->canvas; |
187 | 187 | } |
188 | 188 | |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @return array |
192 | 192 | */ |
193 | 193 | public function getSubdivisions() { |
194 | - if(!$this->is_loaded) $this->load(); |
|
194 | + if (!$this->is_loaded) $this->load(); |
|
195 | 195 | return $this->subdivisions; |
196 | 196 | } |
197 | 197 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return array |
201 | 201 | */ |
202 | 202 | public function getPlacesMappings() { |
203 | - if(!$this->is_loaded) $this->load(); |
|
203 | + if (!$this->is_loaded) $this->load(); |
|
204 | 204 | return $this->mappings; |
205 | 205 | } |
206 | 206 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $ga_id = Filter::getInteger('ga_id'); |
72 | 72 | |
73 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
73 | + if ($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | 74 | $data->set('has_analysis', true); |
75 | 75 | $data->set('geoanalysis', $ga); |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | jQuery.get( |
84 | 84 | "module.php", |
85 | 85 | { |
86 | - "mod" : "'. $this->module->getName() .'", |
|
86 | + "mod" : "'. $this->module->getName().'", |
|
87 | 87 | "mod_action": "GeoAnalysis@dataTabs", |
88 | 88 | "ga_id" : "'.$ga_id.'" |
89 | 89 | }, |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $data->set('has_list', false); |
116 | 116 | |
117 | 117 | $ga_list = $this->provider->getGeoAnalysisList(); |
118 | - if(count($ga_list) > 0 ) { |
|
118 | + if (count($ga_list) > 0) { |
|
119 | 119 | $data->set('has_list', true); |
120 | 120 | $data->set('geoanalysislist', $ga_list); |
121 | 121 | } |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | ); |
140 | 140 | |
141 | 141 | $status = Filter::getBool('status'); |
142 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | - try{ |
|
142 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
143 | + try { |
|
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
|
146 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '.($status ? 'enabled' : 'disabled').'.'); |
|
147 | 147 | } |
148 | 148 | catch (\Exception $ex) { |
149 | 149 | $res['error'] = $ex->getMessage(); |
150 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
|
150 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
154 | + if ($res['error']) http_response_code(500); |
|
155 | 155 | |
156 | 156 | $controller->encode($res); |
157 | 157 | } |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | && $ga |
172 | 172 | ); |
173 | 173 | |
174 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | - try{ |
|
174 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
175 | + try { |
|
176 | 176 | $this->provider->deleteGeoAnalysis($ga); |
177 | 177 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | 178 | } |
179 | 179 | catch (\Exception $ex) { |
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
|
181 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '.$ex->getMessage()); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $controller->pageHeader(); |
185 | - if($res['error']) http_response_code(500); |
|
185 | + if ($res['error']) http_response_code(500); |
|
186 | 186 | |
187 | 187 | $controller->encode($res); |
188 | 188 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
208 | 208 | |
209 | 209 | $flags = array(); |
210 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
210 | + if ($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | 211 | $mapProvider = new GoogleMapsProvider(); |
212 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
212 | + foreach ($placesDispGeneral['places'] as $place => $count) { |
|
213 | 213 | $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
214 | 214 | } |
215 | 215 | } |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * @param (null|array) $flags Array of flags |
229 | 229 | * @return string HTML code for the general tab |
230 | 230 | */ |
231 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | - if(!empty($placesGeneralResults)){ |
|
231 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags = null) { |
|
232 | + if (!empty($placesGeneralResults)) { |
|
233 | 233 | $data = new ViewBag(); |
234 | 234 | |
235 | 235 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 236 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
237 | + if (isset($placesGeneralResults['other'])) $nb_other = $placesGeneralResults['other']; |
|
238 | 238 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 239 | |
240 | 240 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -243,30 +243,30 @@ discard block |
||
243 | 243 | |
244 | 244 | $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
245 | 245 | |
246 | - if($ga->hasMap()) { |
|
246 | + if ($ga->hasMap()) { |
|
247 | 247 | $max = $placesGeneralResults['max']; |
248 | 248 | $map = $ga->getOptions()->getMap(); |
249 | - if($map->isLoaded()) { |
|
249 | + if ($map->isLoaded()) { |
|
250 | 250 | $results_by_subdivs = $map->getSubdivisions(); |
251 | 251 | $places_mappings = $map->getPlacesMappings(); |
252 | 252 | foreach ($placesGeneralResults['places'] as $location => $count) { |
253 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
253 | + $levelvalues = array_reverse(array_map('trim', explode(',', $location))); |
|
254 | 254 | $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
255 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | - $levelref = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]); |
|
257 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
255 | + if ($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | + $levelref = I18N::strtolower($levelvalues[0].'@'.$levelvalues[$level_map]); |
|
257 | + if (!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | 258 | } |
259 | 259 | else { |
260 | 260 | $levelref = $levelvalues[0]; |
261 | 261 | } |
262 | 262 | $levelref = I18N::strtolower($levelref); |
263 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
264 | - if(isset($results_by_subdivs[$levelref])) { |
|
263 | + if (isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
264 | + if (isset($results_by_subdivs[$levelref])) { |
|
265 | 265 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
266 | - $count_subd += $count; |
|
266 | + $count_subd += $count; |
|
267 | 267 | $results_by_subdivs[$levelref]['count'] = $count_subd; |
268 | 268 | $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
269 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
269 | + if ($ga->getOptions()->isUsingFlags() && $flags) { |
|
270 | 270 | $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
271 | 271 | $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
272 | 272 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | } |
291 | 291 | else { |
292 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
292 | + $html = '<p class="warning">'.I18N::translate('No data is available for the general analysis.').'</p>'; |
|
293 | 293 | } |
294 | 294 | return $html; |
295 | 295 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @return string HTML code for the generations tab |
304 | 304 | */ |
305 | 305 | protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
306 | - if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
306 | + if (!empty($placesGenerationsResults) && $ga->getOptions()) { |
|
307 | 307 | $data = new ViewBag(); |
308 | 308 | |
309 | 309 | ksort($placesGenerationsResults); |
@@ -316,26 +316,26 @@ discard block |
||
316 | 316 | $data->set('display_all_places', $display_all_places); |
317 | 317 | |
318 | 318 | $results_by_gen = array(); |
319 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
319 | + foreach ($placesGenerationsResults as $gen => $genData) { |
|
320 | 320 | $sum = 0; |
321 | 321 | $other = 0; |
322 | 322 | $unknown = 0; |
323 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | - if(isset($genData['other'])) $other = $genData['other']; |
|
325 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
323 | + if (isset($genData['sum'])) $sum = $genData['sum']; |
|
324 | + if (isset($genData['other'])) $other = $genData['other']; |
|
325 | + if (isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
326 | 326 | |
327 | - if($sum > 0) { |
|
327 | + if ($sum > 0) { |
|
328 | 328 | $results_by_gen[$gen]['sum'] = $sum; |
329 | 329 | $results_by_gen[$gen]['other'] = $other; |
330 | 330 | $results_by_gen[$gen]['unknown'] = $unknown; |
331 | 331 | $results_by_gen[$gen]['places'] = array(); |
332 | 332 | arsort($genData['places']); |
333 | 333 | |
334 | - if($display_all_places){ |
|
335 | - foreach($genData['places'] as $placename=> $count){ |
|
334 | + if ($display_all_places) { |
|
335 | + foreach ($genData['places'] as $placename=> $count) { |
|
336 | 336 | $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
337 | 337 | |
338 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
338 | + if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') { |
|
339 | 339 | $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
340 | 340 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
341 | 341 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | } |
344 | 344 | else { |
345 | 345 | $tmp = $genData['places']; |
346 | - if($other > 0) { |
|
346 | + if ($other > 0) { |
|
347 | 347 | $tmp = array_slice($tmp, 0, 5, true); |
348 | 348 | $tmp['other'] = $other; |
349 | 349 | arsort($tmp); |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | |
360 | 360 | } |
361 | 361 | else { |
362 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
362 | + $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'</p>'; |
|
363 | 363 | } |
364 | 364 | return $html; |
365 | 365 | } |