Completed
Push — feature/code-analysis ( 92a398...85ebc7 )
by Jonathan
03:02
created
src/Webtrees/Module/Sosa/SosaListController.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         $this->view_bag = new ViewBag();
70 70
         $this->view_bag->set('generation', $this->generation);
71 71
         $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration());
72
-        $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0);
72
+        $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0) > 0);
73 73
         
74 74
     }
75 75
     
@@ -89,14 +89,14 @@  discard block
 block discarded – undo
89 89
 
90 90
         $this->view_bag->set('title', $controller->getPageTitle());
91 91
         
92
-        if($this->view_bag->get('is_setup', false)) {
92
+        if ($this->view_bag->get('is_setup', false)) {
93 93
             $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0);
94 94
             $this->view_bag->set('url_module', $this->module->getName());
95 95
             $this->view_bag->set('url_action', 'SosaList');
96 96
             $this->view_bag->set('url_ged', $wt_tree->getNameUrl()); 
97 97
             $this->view_bag->set('min_gen', 1);
98 98
             
99
-            if($this->view_bag->get('has_sosa', false)) {            
99
+            if ($this->view_bag->get('has_sosa', false)) {            
100 100
                 $controller->addInlineJavascript('
101 101
             		jQuery("#sosalist-tabs").tabs();
102 102
             		jQuery("#sosalist-tabs").css("visibility", "visible");
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             			{
107 107
                             "mod" : "'.$this->module->getName().'",
108 108
                             "mod_action": "SosaList@sosalist",
109
-                            "ged" : "' . $wt_tree->getNameUrl(). '",
109
+                            "ged" : "' . $wt_tree->getNameUrl().'",
110 110
                             "type" : "indi",
111 111
                             "gen" : "'.$this->generation.'"
112 112
                         },
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
                         {
132 132
                             "mod" : "'.$this->module->getName().'",
133 133
                             "mod_action": "SosaList@sosalist",
134
-                            "ged" : "' . $wt_tree->getNameUrl(). '",
134
+                            "ged" : "' . $wt_tree->getNameUrl().'",
135 135
                             "type" : "fam",
136 136
                             "gen" : "'.$this->generation.'"
137 137
                         },
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         
170 170
         $this->view_bag->set('title', $controller->getPageTitle());
171 171
         
172
-        if($this->view_bag->get('is_setup', false)) {
172
+        if ($this->view_bag->get('is_setup', false)) {
173 173
             $this->view_bag->set('url_module', $this->module->getName());
174 174
             $this->view_bag->set('url_action', 'SosaList@missing');
175 175
             $this->view_bag->set('url_ged', $wt_tree->getNameUrl());
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
             $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation);
179 179
             $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0);
180 180
             
181
-            $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1));
181
+            $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation - 1));
182 182
             $this->view_bag->set('perc_sosa', $perc_sosa);
183 183
             
184
-            if($this->view_bag->get('has_missing', false)) {
185
-                $table_id = 'table-sosa-missing-' . Uuid::uuid4();
184
+            if ($this->view_bag->get('has_missing', false)) {
185
+                $table_id = 'table-sosa-missing-'.Uuid::uuid4();
186 186
                 $this->view_bag->set('table_id', $table_id);
187 187
                 
188 188
                 $controller
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 				    jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
193 193
                     
194 194
     				jQuery("#'.$table_id.'").dataTable( {
195
-                        dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
195
+                        dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\',
196 196
     					'.I18N::datatablesI18N().',
197 197
     					jQueryUI: true,
198 198
     					autoWidth:false,
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
     					pagingType: "full_numbers"
219 219
     			   });
220 220
     			
221
-    				jQuery("#' . $table_id . '")
221
+    				jQuery("#' . $table_id.'")
222 222
     				/* Filter buttons in table header */
223 223
     				.on("click", "button[data-filter-column]", function() {
224 224
     					var btn = jQuery(this);
225 225
     					// De-activate the other buttons in this button group
226 226
     					btn.siblings().removeClass("ui-state-active");
227 227
     					// Apply (or clear) this filter
228
-    					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
228
+    					var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column"));
229 229
     					if (btn.hasClass("ui-state-active")) {
230 230
     						btn.removeClass("ui-state-active");
231 231
     						col.search("").draw();
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
                 $unique_indis = array();
243 243
                 $sum_missing_different = 0;
244 244
                 $sum_missing_different_without_hidden = 0;
245
-                foreach($missing_list as $num => $missing_tab) {
246
-                    if(isset($unique_indis[$missing_tab['indi']])) {
245
+                foreach ($missing_list as $num => $missing_tab) {
246
+                    if (isset($unique_indis[$missing_tab['indi']])) {
247 247
                         unset($missing_list[$num]);
248 248
                         continue;
249 249
                     }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
                 $this->view_bag->set('missing_list', $missing_list);
262 262
                 $this->view_bag->set('missing_diff_count', $sum_missing_different);
263 263
                 $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden);
264
-                $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2));
264
+                $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation - 2));
265 265
                 $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential);
266 266
             }            
267 267
         }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         $controller = new AjaxController();
280 280
         $controller->restrictAccess($this->generation > 0 || !is_null($type));
281 281
         
282
-        switch ($type){
282
+        switch ($type) {
283 283
             case 'indi':
284 284
                 $this->renderSosaListIndi($controller);
285 285
                 break;
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
         $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); 
302 302
         $this->view_bag->set('has_sosa', false);
303 303
         
304
-        if(count($listSosa) > 0) {
304
+        if (count($listSosa) > 0) {
305 305
             $this->view_bag->set('has_sosa', true);
306
-            $table_id = 'table-sosa-indi-' . Uuid::uuid4();
306
+            $table_id = 'table-sosa-indi-'.Uuid::uuid4();
307 307
             $this->view_bag->set('table_id', $table_id);
308 308
                      
309 309
             $controller
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
                 jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
314 314
                 
315 315
                 jQuery("#'.$table_id.'").dataTable( {
316
-					dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
317
-					' . I18N::datatablesI18N() . ',
316
+					dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\',
317
+					' . I18N::datatablesI18N().',
318 318
 					jQueryUI: true,
319 319
 					autoWidth: false,
320 320
 					processing: true,
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 					pagingType: "full_numbers"
344 344
 			   });
345 345
             
346
-				jQuery("#' . $table_id . '")
346
+				jQuery("#' . $table_id.'")
347 347
 				/* Hide/show parents */
348 348
 				.on("click", ".btn-toggle-parents", function() {
349 349
 					jQuery(this).toggleClass("ui-state-active");
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				/* Hide/show statistics */
353 353
 				.on("click", ".btn-toggle-statistics", function() {
354 354
 					jQuery(this).toggleClass("ui-state-active");
355
-					jQuery("#indi_list_table-charts_' . $table_id . '").slideToggle();
355
+					jQuery("#indi_list_table-charts_' . $table_id.'").slideToggle();
356 356
 				})
357 357
 				/* Filter buttons in table header */
358 358
 				.on("click", "button[data-filter-column]", function() {
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 					// De-activate the other buttons in this button group
361 361
 					btn.siblings().removeClass("ui-state-active");
362 362
 					// Apply (or clear) this filter
363
-					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
363
+					var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column"));
364 364
 					if (btn.hasClass("ui-state-active")) {
365 365
 						btn.removeClass("ui-state-active");
366 366
 						col.search("").draw();
@@ -395,30 +395,30 @@  discard block
 block discarded – undo
395 395
             $nb_displayed = 0;
396 396
             
397 397
             Individual::load($wt_tree, $listSosa);
398
-            foreach($listSosa as $sosa => $pid) {
398
+            foreach ($listSosa as $sosa => $pid) {
399 399
                 $person = Individual::getInstance($pid, $wt_tree);
400 400
                 if (!$person || !$person->canShowName()) {
401 401
                     unset($listSosa[$sosa]);
402 402
                     continue;
403 403
                 }
404 404
                 $nb_displayed++;
405
-                if ($birth_dates=$person->getAllBirthDates()) {
405
+                if ($birth_dates = $person->getAllBirthDates()) {
406 406
                     if (
407 407
                         FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) &&
408 408
                         !isset($unique_indis[$person->getXref()])
409 409
                         ) {
410
-                        $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex();
410
+                        $birt_by_decade[(int)($birth_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
411 411
                     }
412 412
                 }
413 413
                 else {
414
-                    $birth_dates[0]=new Date('');
414
+                    $birth_dates[0] = new Date('');
415 415
                 }
416 416
                 if ($death_dates = $person->getAllDeathDates()) {
417 417
                     if (
418 418
                         FunctionsPrint::isDateWithinChartsRange($death_dates[0]) &&
419 419
                         !isset($unique_indis[$person->getXref()])
420 420
                         ) {
421
-                        $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
421
+                        $deat_by_decade[(int)($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex();
422 422
                     }
423 423
                 }
424 424
                 else {
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
             $this->view_bag->set('sosa_list', $listSosa);   
435 435
             
436 436
             $this->view_bag->set('sosa_count', count($listSosa));
437
-            $this->view_bag->set('sosa_theo', pow(2, $this->generation-1));
437
+            $this->view_bag->set('sosa_theo', pow(2, $this->generation - 1));
438 438
             $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo')));
439 439
             
440 440
             $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed);
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
      */
454 454
     protected function renderFamSosaListIndi(AjaxController $controller) {
455 455
         $wt_tree = Globals::getTree();
456
-        $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);;
456
+        $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation); ;
457 457
         $this->view_bag->set('has_sosa', false);
458 458
         
459
-        if(count($listFamSosa) > 0) {
459
+        if (count($listFamSosa) > 0) {
460 460
             $this->view_bag->set('has_sosa', true);
461
-            $table_id = 'table-sosa-fam-' . Uuid::uuid4();
461
+            $table_id = 'table-sosa-fam-'.Uuid::uuid4();
462 462
             $this->view_bag->set('table_id', $table_id);
463 463
              
464 464
             $controller
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc;
469 469
                 
470 470
                 jQuery("#'.$table_id.'").dataTable( {
471
-					dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\',
471
+					dom: \'<"H"<"filtersH_' . $table_id.'"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\',
472 472
                     '.I18N::datatablesI18N(array(16, 32, 64, 128, -1)).',
473 473
 					jQueryUI: true,
474 474
 					autoWidth: false,
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 					pagingType: "full_numbers"
496 496
 			   });
497 497
 					
498
-				jQuery("#' . $table_id . '")
498
+				jQuery("#' . $table_id.'")
499 499
 				/* Hide/show parents */
500 500
 				.on("click", ".btn-toggle-parents", function() {
501 501
 					jQuery(this).toggleClass("ui-state-active");
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 				/* Hide/show statistics */
505 505
 				.on("click",  ".btn-toggle-statistics", function() {
506 506
 					jQuery(this).toggleClass("ui-state-active");
507
-					jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle();
507
+					jQuery("#fam_list_table-charts_' . $table_id.'").slideToggle();
508 508
 				})
509 509
 				/* Filter buttons in table header */
510 510
 				.on("click", "button[data-filter-column]", function() {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 					// De-activate the other buttons in this button group
513 513
 					btn.siblings().removeClass("ui-state-active");
514 514
 					// Apply (or clear) this filter
515
-					var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column"));
515
+					var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column"));
516 516
 					if (btn.hasClass("ui-state-active")) {
517 517
 						btn.removeClass("ui-state-active");
518 518
 						col.search("").draw();
@@ -532,29 +532,29 @@  discard block
 block discarded – undo
532 532
             
533 533
             //-- init chart data
534 534
     		$marr_by_age = array();
535
-    		for ($age=0; $age<=$max_age; $age++) {
535
+    		for ($age = 0; $age <= $max_age; $age++) {
536 536
     			$marr_by_age[$age] = '';
537 537
     		}
538 538
     		$birt_by_decade = array();
539 539
     		$marr_by_decade = array();
540
-    		for ($year=1550; $year<2030; $year+=10) {
540
+    		for ($year = 1550; $year < 2030; $year += 10) {
541 541
     			$birt_by_decade[$year] = '';
542 542
     			$marr_by_decade[$year] = '';
543 543
     		}
544 544
     		
545
-            foreach($listFamSosa as $sosa => $fid) {
545
+            foreach ($listFamSosa as $sosa => $fid) {
546 546
                 $sfamily = Family::getInstance($fid, $wt_tree);
547
-                if(!$sfamily || !$sfamily->canShow()) {
547
+                if (!$sfamily || !$sfamily->canShow()) {
548 548
                     unset($listFamSosa[$sosa]);
549 549
                     continue;
550 550
                 }
551
-                $mdate=$sfamily->getMarriageDate();
551
+                $mdate = $sfamily->getMarriageDate();
552 552
                 
553
-                if( ($husb = $sfamily->getHusband()) && 
553
+                if (($husb = $sfamily->getHusband()) && 
554 554
                     ($hdate = $husb->getBirthDate()) && 
555 555
                     $hdate->isOK() && $mdate->isOK()) {
556 556
                     if (FunctionsPrint::isDateWithinChartsRange($hdate)) {
557
-                        $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
557
+                        $birt_by_decade[(int)($hdate->gregorianYear() / 10) * 10] .= $husb->getSex();
558 558
                     }
559 559
                     $hage = Date::getAge($hdate, $mdate, 0);
560 560
                     if ($hage >= 0 && $hage <= $max_age) {
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
                     }
563 563
                 }
564 564
                 
565
-                if(($wife = $sfamily->getWife()) &&
566
-                    ($wdate=$wife->getBirthDate()) &&
565
+                if (($wife = $sfamily->getWife()) &&
566
+                    ($wdate = $wife->getBirthDate()) &&
567 567
                     $wdate->isOK() && $mdate->isOK()) {
568 568
                     if (FunctionsPrint::isDateWithinChartsRange($wdate)) {
569
-                        $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
569
+                        $birt_by_decade[(int)($wdate->gregorianYear() / 10) * 10] .= $wife->getSex();
570 570
                     }
571 571
                     $wage = Date::getAge($wdate, $mdate, 0);
572 572
                     if ($wage >= 0 && $wage <= $max_age) {
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
                 }                
576 576
 
577 577
                 if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) {
578
-                    $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex();
578
+                    $marr_by_decade[(int)($mdate->gregorianYear() / 10) * 10] .= $husb->getSex().$wife->getSex();
579 579
                 }
580 580
                 
581 581
                 $listFamSosa[$sosa] = $sfamily;
Please login to merge, or discard this patch.