@@ -144,14 +144,15 @@ discard block |
||
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | 146 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
147 | - } |
|
148 | - catch (\Exception $ex) { |
|
147 | + } catch (\Exception $ex) { |
|
149 | 148 | $res['error'] = $ex->getMessage(); |
150 | 149 | Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
151 | 150 | } |
152 | 151 | |
153 | 152 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
153 | + if($res['error']) { |
|
154 | + http_response_code(500); |
|
155 | + } |
|
155 | 156 | |
156 | 157 | $controller->encode($res); |
157 | 158 | } |
@@ -175,14 +176,15 @@ discard block |
||
175 | 176 | try{ |
176 | 177 | $this->provider->deleteGeoAnalysis($ga); |
177 | 178 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | - } |
|
179 | - catch (\Exception $ex) { |
|
179 | + } catch (\Exception $ex) { |
|
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | 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']) { |
|
186 | + http_response_code(500); |
|
187 | + } |
|
186 | 188 | |
187 | 189 | $controller->encode($res); |
188 | 190 | } |
@@ -234,7 +236,9 @@ discard block |
||
234 | 236 | |
235 | 237 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 238 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
239 | + if(isset($placesGeneralResults['other'])) { |
|
240 | + $nb_other =$placesGeneralResults['other']; |
|
241 | + } |
|
238 | 242 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 243 | |
240 | 244 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -255,12 +259,13 @@ discard block |
||
255 | 259 | if($level_map >= 0 && $level_map < count($levelvalues)) { |
256 | 260 | $levelref = I18N::strtolower($levelvalues[0] . '@' . $levelvalues[$level_map]); |
257 | 261 | if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
258 | - } |
|
259 | - else { |
|
262 | + } else { |
|
260 | 263 | $levelref = $levelvalues[0]; |
261 | 264 | } |
262 | 265 | $levelref = I18N::strtolower($levelref); |
263 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
266 | + if(isset($places_mappings[$levelref])) { |
|
267 | + $levelref = $places_mappings[$levelref]; |
|
268 | + } |
|
264 | 269 | if(isset($results_by_subdivs[$levelref])) { |
265 | 270 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
266 | 271 | $count_subd += $count; |
@@ -278,8 +283,7 @@ discard block |
||
278 | 283 | } |
279 | 284 | |
280 | 285 | $html = ViewFactory::make('GeoAnalysisTabGeneralMap', $this, new BaseController(), $data)->getHtmlPartial(); |
281 | - } |
|
282 | - else { |
|
286 | + } else { |
|
283 | 287 | $results = $placesGeneralResults['places']; |
284 | 288 | arsort($results); |
285 | 289 | $data->set('results', $results); |
@@ -287,8 +291,7 @@ discard block |
||
287 | 291 | |
288 | 292 | $html = ViewFactory::make('GeoAnalysisTabGeneralTable', $this, new BaseController(), $data)->getHtmlPartial(); |
289 | 293 | } |
290 | - } |
|
291 | - else { |
|
294 | + } else { |
|
292 | 295 | $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
293 | 296 | } |
294 | 297 | return $html; |
@@ -320,9 +323,15 @@ discard block |
||
320 | 323 | $sum = 0; |
321 | 324 | $other = 0; |
322 | 325 | $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']; |
|
326 | + if(isset($genData['sum'])) { |
|
327 | + $sum = $genData['sum']; |
|
328 | + } |
|
329 | + if(isset($genData['other'])) { |
|
330 | + $other = $genData['other']; |
|
331 | + } |
|
332 | + if(isset($genData['unknown'])) { |
|
333 | + $unknown = $genData['unknown']; |
|
334 | + } |
|
326 | 335 | |
327 | 336 | if($sum > 0) { |
328 | 337 | $results_by_gen[$gen]['sum'] = $sum; |
@@ -340,8 +349,7 @@ discard block |
||
340 | 349 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
341 | 350 | } |
342 | 351 | } |
343 | - } |
|
344 | - else { |
|
352 | + } else { |
|
345 | 353 | $tmp = $genData['places']; |
346 | 354 | if($other > 0) { |
347 | 355 | $tmp = array_slice($tmp, 0, 5, true); |
@@ -357,8 +365,7 @@ discard block |
||
357 | 365 | |
358 | 366 | $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial(); |
359 | 367 | |
360 | - } |
|
361 | - else { |
|
368 | + } else { |
|
362 | 369 | $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
363 | 370 | } |
364 | 371 | return $html; |
@@ -95,7 +95,9 @@ discard block |
||
95 | 95 | * @return ImageBuilder |
96 | 96 | */ |
97 | 97 | public function setExpireOffset($expireOffset) { |
98 | - if($expireOffset) $this->expire_offset = $expireOffset; |
|
98 | + if($expireOffset) { |
|
99 | + $this->expire_offset = $expireOffset; |
|
100 | + } |
|
99 | 101 | return $this; |
100 | 102 | } |
101 | 103 | |
@@ -115,7 +117,9 @@ discard block |
||
115 | 117 | * @return ImageBuilder |
116 | 118 | */ |
117 | 119 | public function setShowWatermark($show_watermark) { |
118 | - if(!is_null($show_watermark)) $this->show_watermark = $show_watermark; |
|
120 | + if(!is_null($show_watermark)) { |
|
121 | + $this->show_watermark = $show_watermark; |
|
122 | + } |
|
119 | 123 | return $this; |
120 | 124 | } |
121 | 125 | |
@@ -126,7 +130,9 @@ discard block |
||
126 | 130 | * @return ImageBuilder |
127 | 131 | */ |
128 | 132 | public function setFontMaxSize($font_max_size) { |
129 | - if($font_max_size) $this->font_max_size = $font_max_size; |
|
133 | + if($font_max_size) { |
|
134 | + $this->font_max_size = $font_max_size; |
|
135 | + } |
|
130 | 136 | return $this; |
131 | 137 | } |
132 | 138 | |
@@ -137,7 +143,9 @@ discard block |
||
137 | 143 | * @return ImageBuilder |
138 | 144 | */ |
139 | 145 | public function setFontColor($font_color) { |
140 | - if($font_color) $this->font_color = $font_color; |
|
146 | + if($font_color) { |
|
147 | + $this->font_color = $font_color; |
|
148 | + } |
|
141 | 149 | return $this; |
142 | 150 | } |
143 | 151 | |
@@ -148,7 +156,9 @@ discard block |
||
148 | 156 | * @return ImageBuilder |
149 | 157 | */ |
150 | 158 | public function setAsAttachment($is_attachement) { |
151 | - if(is_bool($is_attachement)) $this->as_attachment = $is_attachement; |
|
159 | + if(is_bool($is_attachement)) { |
|
160 | + $this->as_attachment = $is_attachement; |
|
161 | + } |
|
152 | 162 | return $this; |
153 | 163 | } |
154 | 164 | |
@@ -300,8 +310,7 @@ discard block |
||
300 | 310 | // text to watermark with |
301 | 311 | if(method_exists($this->media, 'getWatermarkText')) { |
302 | 312 | $word1_text = $this->media->getWatermarkText(); |
303 | - } |
|
304 | - else { |
|
313 | + } else { |
|
305 | 314 | $word1_text = $this->media->getTitle(); |
306 | 315 | } |
307 | 316 |
@@ -93,8 +93,12 @@ discard block |
||
93 | 93 | foreach($stats_gen as $gen => $tab){ |
94 | 94 | $genY1= I18N::translate('-'); |
95 | 95 | $genY2= I18N::translate('-'); |
96 | - if($tab['firstBirth']>0) $genY1=$tab['firstEstimatedBirth']; |
|
97 | - if($tab['lastBirth']>0) $genY2=$tab['lastEstimatedBirth']; |
|
96 | + if($tab['firstBirth']>0) { |
|
97 | + $genY1=$tab['firstEstimatedBirth']; |
|
98 | + } |
|
99 | + if($tab['lastBirth']>0) { |
|
100 | + $genY2=$tab['lastEstimatedBirth']; |
|
101 | + } |
|
98 | 102 | $total_theoretical += $gen_theoretical; |
99 | 103 | $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
100 | 104 | $missing=2*$prev_known - $tab['sosaCount']; |
@@ -169,7 +173,9 @@ discard block |
||
169 | 173 | private function htmlAncestorDispersionG2() |
170 | 174 | { |
171 | 175 | $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
172 | - if(count($ancestorsDispGen2) == 0) return; |
|
176 | + if(count($ancestorsDispGen2) == 0) { |
|
177 | + return; |
|
178 | + } |
|
173 | 179 | |
174 | 180 | $size = '600x300'; |
175 | 181 | |
@@ -251,7 +257,9 @@ discard block |
||
251 | 257 | */ |
252 | 258 | private function htmlAncestorGenDepthG3() { |
253 | 259 | $ancestorsGenDepth3 = $this->sosa_provider->getGenerationDepthStatsAtGen(3); |
254 | - if(count($ancestorsGenDepth3) == 0) return; |
|
260 | + if(count($ancestorsGenDepth3) == 0) { |
|
261 | + return; |
|
262 | + } |
|
255 | 263 | |
256 | 264 | $ancestors = array(); |
257 | 265 | $chd_mean = array(); |
@@ -262,8 +270,7 @@ discard block |
||
262 | 270 | if($ancestor !== null && $ancestor->canShowName()) { |
263 | 271 | $tmp = $ancestor->getAllNames(); |
264 | 272 | $ancestors[] = Filter::escapeUrl($tmp[$ancestor->getPrimaryName()]['fullNN']); |
265 | - } |
|
266 | - else { |
|
273 | + } else { |
|
267 | 274 | $ancestors[] = I18N::translate('Sosa %s', I18N::number($sosa)); |
268 | 275 | } |
269 | 276 | $chd_mean[] = $genDepthStat['mean_gen_depth']; |
@@ -84,21 +84,25 @@ 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) |
|
88 | - self::$default_user = User::find(-1); |
|
87 | + if(self::$default_user === null) { |
|
88 | + self::$default_user = User::find(-1); |
|
89 | + } |
|
89 | 90 | |
90 | 91 | $this->tree = $tree; |
91 | 92 | $this->user = $user; |
92 | 93 | $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; |
|
94 | + if($this->user === null) { |
|
95 | + $this->user = Auth::user(); |
|
96 | + } |
|
97 | + if(strlen($this->user->getUserId()) == 0) { |
|
98 | + $this->user = self::$default_user; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | // Check if the user, or the default user, has a root already setup; |
97 | 102 | if(empty($this->getRootIndiId())) { |
98 | 103 | if($this->user == self::$default_user) { // If the default user is not setup |
99 | 104 | $this->is_setup = false; |
100 | - } |
|
101 | - else { |
|
105 | + } else { |
|
102 | 106 | $this->user = self::$default_user; |
103 | 107 | $this->is_setup = $this->getRootIndiId() === null; |
104 | 108 | } |
@@ -159,7 +163,9 @@ discard block |
||
159 | 163 | * Remove all Sosa entries related to the gedcom file and user |
160 | 164 | */ |
161 | 165 | public function deleteAll() { |
162 | - if(!$this->is_setup) return; |
|
166 | + if(!$this->is_setup) { |
|
167 | + return; |
|
168 | + } |
|
163 | 169 | Database::prepare( |
164 | 170 | 'DELETE FROM `##maj_sosa`'. |
165 | 171 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -175,7 +181,9 @@ discard block |
||
175 | 181 | * @param int $sosa |
176 | 182 | */ |
177 | 183 | public function deleteAncestors($sosa) { |
178 | - if(!$this->is_setup) return; |
|
184 | + if(!$this->is_setup) { |
|
185 | + return; |
|
186 | + } |
|
179 | 187 | $gen = Functions::getGeneration($sosa); |
180 | 188 | Database::prepare( |
181 | 189 | 'DELETE FROM `##maj_sosa`'. |
@@ -195,7 +203,9 @@ discard block |
||
195 | 203 | * @param array $sosa_records |
196 | 204 | */ |
197 | 205 | public function insertOrUpdate($sosa_records) { |
198 | - if(!$this->is_setup) return; |
|
206 | + if(!$this->is_setup) { |
|
207 | + return; |
|
208 | + } |
|
199 | 209 | |
200 | 210 | $treeid = $this->tree->getTreeId(); |
201 | 211 | $userid = $this->user->getUserId(); |
@@ -244,7 +254,9 @@ discard block |
||
244 | 254 | * @return array Array of sosa numbers |
245 | 255 | */ |
246 | 256 | public function getSosaNumbers(Individual $indi) { |
247 | - if(!$this->is_setup) return array(); |
|
257 | + if(!$this->is_setup) { |
|
258 | + return array(); |
|
259 | + } |
|
248 | 260 | return Database::prepare( |
249 | 261 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
250 | 262 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -261,7 +273,9 @@ discard block |
||
261 | 273 | * @return number Last generation if found, 1 otherwise |
262 | 274 | */ |
263 | 275 | public function getLastGeneration() { |
264 | - if(!$this->is_setup) return; |
|
276 | + if(!$this->is_setup) { |
|
277 | + return; |
|
278 | + } |
|
265 | 279 | return Database::prepare( |
266 | 280 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
267 | 281 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -281,7 +295,9 @@ discard block |
||
281 | 295 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
282 | 296 | */ |
283 | 297 | public function getAllSosaWithGenerations(){ |
284 | - if(!$this->is_setup) return array(); |
|
298 | + if(!$this->is_setup) { |
|
299 | + return array(); |
|
300 | + } |
|
285 | 301 | return Database::prepare( |
286 | 302 | 'SELECT majs_i_id AS indi,' . |
287 | 303 | ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
@@ -301,9 +317,12 @@ discard block |
||
301 | 317 | * @return array Array of Sosa individuals |
302 | 318 | */ |
303 | 319 | public function getSosaListAtGeneration($gen){ |
304 | - if(!$this->is_setup) return array(); |
|
305 | - if(!$this->sosa_list_by_gen) |
|
306 | - $this->sosa_list_by_gen = array(); |
|
320 | + if(!$this->is_setup) { |
|
321 | + return array(); |
|
322 | + } |
|
323 | + if(!$this->sosa_list_by_gen) { |
|
324 | + $this->sosa_list_by_gen = array(); |
|
325 | + } |
|
307 | 326 | |
308 | 327 | if($gen){ |
309 | 328 | if(!isset($this->sosa_list_by_gen[$gen])){ |
@@ -332,9 +351,12 @@ discard block |
||
332 | 351 | * @return array Array of Sosa families |
333 | 352 | */ |
334 | 353 | public function getFamilySosaListAtGeneration($gen){ |
335 | - if(!$this->is_setup) return array(); |
|
336 | - if(!$this->sosa_fam_list_by_gen) |
|
337 | - $this->sosa_fam_list_by_gen = array(); |
|
354 | + if(!$this->is_setup) { |
|
355 | + return array(); |
|
356 | + } |
|
357 | + if(!$this->sosa_fam_list_by_gen) { |
|
358 | + $this->sosa_fam_list_by_gen = array(); |
|
359 | + } |
|
338 | 360 | |
339 | 361 | if($gen){ |
340 | 362 | if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
@@ -368,7 +390,9 @@ discard block |
||
368 | 390 | * @return array Array of Sosa individuals |
369 | 391 | */ |
370 | 392 | public function getMissingSosaListAtGeneration($gen){ |
371 | - if(!$this->is_setup) return array(); |
|
393 | + if(!$this->is_setup) { |
|
394 | + return array(); |
|
395 | + } |
|
372 | 396 | if($gen){ |
373 | 397 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
374 | 398 | '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'. |
@@ -408,7 +432,9 @@ discard block |
||
408 | 432 | * @return array Statistics array |
409 | 433 | */ |
410 | 434 | public function getStatisticsByGeneration() { |
411 | - if(!$this->is_setup) return array(); |
|
435 | + if(!$this->is_setup) { |
|
436 | + return array(); |
|
437 | + } |
|
412 | 438 | if(!$this->statistics_tab) { |
413 | 439 | $this->statistics_tab = array(); |
414 | 440 | if($maxGeneration = $this->getLastGeneration()) { |
@@ -436,7 +462,9 @@ discard block |
||
436 | 462 | * @return int |
437 | 463 | */ |
438 | 464 | public function getTotalIndividuals() { |
439 | - if(!$this->is_setup) return 0; |
|
465 | + if(!$this->is_setup) { |
|
466 | + return 0; |
|
467 | + } |
|
440 | 468 | return Database::prepare( |
441 | 469 | 'SELECT COUNT(*) FROM `##individuals`' . |
442 | 470 | ' WHERE i_file = :tree_id') |
@@ -450,7 +478,9 @@ discard block |
||
450 | 478 | * @return number Number of Sosas |
451 | 479 | */ |
452 | 480 | public function getSosaCount(){ |
453 | - if(!$this->is_setup) return 0; |
|
481 | + if(!$this->is_setup) { |
|
482 | + return 0; |
|
483 | + } |
|
454 | 484 | return Database::prepare( |
455 | 485 | 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
456 | 486 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -467,7 +497,9 @@ discard block |
||
467 | 497 | * @return number Number of Sosas in generation |
468 | 498 | */ |
469 | 499 | public function getSosaCountAtGeneration($gen){ |
470 | - if(!$this->is_setup) return 0; |
|
500 | + if(!$this->is_setup) { |
|
501 | + return 0; |
|
502 | + } |
|
471 | 503 | return Database::prepare( |
472 | 504 | 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
473 | 505 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -486,7 +518,9 @@ discard block |
||
486 | 518 | * @return number Total number of Sosas up to generation |
487 | 519 | */ |
488 | 520 | public function getSosaCountUpToGeneration($gen){ |
489 | - if(!$this->is_setup) return 0; |
|
521 | + if(!$this->is_setup) { |
|
522 | + return 0; |
|
523 | + } |
|
490 | 524 | return Database::prepare( |
491 | 525 | 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
492 | 526 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -504,7 +538,9 @@ discard block |
||
504 | 538 | * @return number Total number of distinct individual |
505 | 539 | */ |
506 | 540 | public function getDifferentSosaCount(){ |
507 | - if(!$this->is_setup) return 0; |
|
541 | + if(!$this->is_setup) { |
|
542 | + return 0; |
|
543 | + } |
|
508 | 544 | return Database::prepare( |
509 | 545 | 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
510 | 546 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -521,7 +557,9 @@ discard block |
||
521 | 557 | * @return number Number of distinct Sosa individuals up to generation |
522 | 558 | */ |
523 | 559 | public function getDifferentSosaCountUpToGeneration($gen){ |
524 | - if(!$this->is_setup) return 0; |
|
560 | + if(!$this->is_setup) { |
|
561 | + return 0; |
|
562 | + } |
|
525 | 563 | return Database::prepare( |
526 | 564 | 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
527 | 565 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -546,7 +584,9 @@ discard block |
||
546 | 584 | * @return array Birth statistics array |
547 | 585 | */ |
548 | 586 | public function getStatsBirthYearInGeneration($gen){ |
549 | - if(!$this->is_setup) return array('first' => 0, 'first_est' => 0, 'avg' => 0, 'last' => 0, 'last_est' => 0); |
|
587 | + if(!$this->is_setup) { |
|
588 | + return array('first' => 0, 'first_est' => 0, 'avg' => 0, 'last' => 0, 'last_est' => 0); |
|
589 | + } |
|
550 | 590 | return Database::prepare( |
551 | 591 | 'SELECT'. |
552 | 592 | ' MIN(majs_birth_year) AS first, MIN(majs_birth_year_est) AS first_est,'. |
@@ -568,7 +608,9 @@ discard block |
||
568 | 608 | * @return number|NULL Mean generation time |
569 | 609 | */ |
570 | 610 | public function getMeanGenerationTime(){ |
571 | - if(!$this->is_setup) return; |
|
611 | + if(!$this->is_setup) { |
|
612 | + return; |
|
613 | + } |
|
572 | 614 | if(!$this->statistics_tab){ |
573 | 615 | $this->getStatisticsByGeneration(); |
574 | 616 | } |
@@ -610,7 +652,9 @@ discard block |
||
610 | 652 | * @return array |
611 | 653 | */ |
612 | 654 | public function getGenerationDepthStatsAtGen($gen) { |
613 | - if(!$this->is_setup) return array(); |
|
655 | + if(!$this->is_setup) { |
|
656 | + return array(); |
|
657 | + } |
|
614 | 658 | $gen_depth_stats_raw = Database::prepare( |
615 | 659 | 'SELECT stats_by_gen.root_ancestor AS root_ancestor_sosa,'. |
616 | 660 | ' sosa_list.majs_i_id as root_ancestor_id,'. |
@@ -685,7 +729,10 @@ discard block |
||
685 | 729 | * @return array |
686 | 730 | */ |
687 | 731 | public function getAncestorDispersionForGen($gen) { |
688 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
732 | + if(!$this->is_setup || $gen > 11) { |
|
733 | + return array(); |
|
734 | + } |
|
735 | + // Going further than 11 gen will be out of range in the query |
|
689 | 736 | return Database::prepare( |
690 | 737 | 'SELECT branches, count(i_id)'. |
691 | 738 | ' FROM ('. |
@@ -725,7 +772,9 @@ discard block |
||
725 | 772 | * @return array |
726 | 773 | */ |
727 | 774 | public function getTopMultiSosaAncestorsNoTies($limit) { |
728 | - if(!$this->is_setup) return array(); |
|
775 | + if(!$this->is_setup) { |
|
776 | + return array(); |
|
777 | + } |
|
729 | 778 | return Database::prepare( |
730 | 779 | 'SELECT sosa_i_id, sosa_count FROM ('. |
731 | 780 | ' SELECT'. |
@@ -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')); |
@@ -78,7 +78,9 @@ discard block |
||
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()) { |
|
82 | + $other_trees[] = $tree; |
|
83 | + } |
|
82 | 84 | } |
83 | 85 | $data->set('other_trees', $other_trees); |
84 | 86 | |
@@ -177,7 +179,9 @@ discard block |
||
177 | 179 | |
178 | 180 | // Generate an AJAX/JSON response for datatables to load a block of rows |
179 | 181 | $search = Filter::postArray('search'); |
180 | - if($search) $search = $search['value']; |
|
182 | + if($search) { |
|
183 | + $search = $search['value']; |
|
184 | + } |
|
181 | 185 | $start = Filter::postInteger('start'); |
182 | 186 | $length = Filter::postInteger('length'); |
183 | 187 | $order = Filter::postArray('order'); |
@@ -263,8 +267,7 @@ discard block |
||
263 | 267 | $datum[7] .= $top_level; |
264 | 268 | } |
265 | 269 | $datum[7] .= '</span>'; |
266 | - } |
|
267 | - else { |
|
270 | + } else { |
|
268 | 271 | $datum[6] = I18N::translate('Error when loading map.'); |
269 | 272 | } |
270 | 273 | } |
@@ -339,8 +342,7 @@ discard block |
||
339 | 342 | if($use_map) { |
340 | 343 | $options->setMap(new OutlineMap($map_file)); |
341 | 344 | $options->setMapLevel($map_top_level + 1); |
342 | - } |
|
343 | - else { |
|
345 | + } else { |
|
344 | 346 | $options->setMap(null); |
345 | 347 | } |
346 | 348 | } |
@@ -351,8 +353,7 @@ discard block |
||
351 | 353 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
352 | 354 | $ga = $res; |
353 | 355 | $success = true; |
354 | - } |
|
355 | - else { |
|
356 | + } else { |
|
356 | 357 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
357 | 358 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
358 | 359 | } |
@@ -370,8 +371,7 @@ discard block |
||
370 | 371 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
371 | 372 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
372 | 373 | $success = true; |
373 | - } |
|
374 | - else { |
|
374 | + } else { |
|
375 | 375 | FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger'); |
376 | 376 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis “'.$description.'” could not be added. See error log.'); |
377 | 377 | } |
@@ -381,8 +381,7 @@ discard block |
||
381 | 381 | if(!$success) { |
382 | 382 | if($ga) { |
383 | 383 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
384 | - } |
|
385 | - else { |
|
384 | + } else { |
|
386 | 385 | $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
387 | 386 | } |
388 | 387 | } |
@@ -439,7 +438,9 @@ discard block |
||
439 | 438 | $data->set('map_list', $map_list); |
440 | 439 | |
441 | 440 | $gen_details = array(0 => I18N::translate('All')); |
442 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
441 | + for($i = 1; $i <= 10 ; $i++) { |
|
442 | + $gen_details[$i] = $i; |
|
443 | + } |
|
443 | 444 | $data->set('generation_details', $gen_details); |
444 | 445 | |
445 | 446 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |