@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | protected $gedcomrecord; |
24 | 24 | |
25 | 25 | /** @var bool Is the GedcomRecord sourced (cache) */ |
26 | - protected $_issourced=null; |
|
26 | + protected $_issourced = null; |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Contructor for the decorator |
30 | 30 | * |
31 | 31 | * @param \Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in The GedcomRecord to extend |
32 | 32 | */ |
33 | - public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in){ |
|
33 | + public function __construct(\Fisharebest\Webtrees\GedcomRecord $gedcomrecord_in) { |
|
34 | 34 | $this->gedcomrecord = $gedcomrecord_in; |
35 | 35 | } |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return \Fisharebest\Webtrees\GedcomRecord Embedded gedcom record |
41 | 41 | */ |
42 | - public function getDerivedRecord(){ |
|
42 | + public function getDerivedRecord() { |
|
43 | 43 | return $this->gedcomrecord; |
44 | 44 | } |
45 | 45 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (($fact->getDate() || $fact->getPlace()) && $fact->canShow()) { |
71 | 71 | switch ($style) { |
72 | 72 | case 10: |
73 | - return '<i>'.$fact->getLabel().' '. mw\Functions\FunctionsPrint::formatFactDateShort($fact) .' '. mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1') .'</i>'; |
|
73 | + return '<i>'.$fact->getLabel().' '.mw\Functions\FunctionsPrint::formatFactDateShort($fact).' '.mw\Functions\FunctionsPrint::formatFactPlaceShort($fact, '%1').'</i>'; |
|
74 | 74 | default: |
75 | 75 | return $this->gedcomrecord->formatFirstMajorFact($facts, $style); |
76 | 76 | } |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | * @param int $access_level |
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | - public function canDisplayIsSourced($access_level = null){ |
|
88 | + public function canDisplayIsSourced($access_level = null) { |
|
89 | 89 | global $global_facts; |
90 | 90 | |
91 | - if(!$this->gedcomrecord->canShow($access_level)) return false; |
|
92 | - if($access_level === null ) |
|
91 | + if (!$this->gedcomrecord->canShow($access_level)) return false; |
|
92 | + if ($access_level === null) |
|
93 | 93 | $access_level = \Fisharebest\Webtrees\Auth::accessLevel($this->gedcomrecord->getTree()); |
94 | 94 | |
95 | 95 | if (isset($global_facts['SOUR'])) { |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return int Level of sources |
110 | 110 | */ |
111 | - public function isSourced(){ |
|
112 | - if($this->_issourced !== null) return $this->_issourced; |
|
113 | - $this->_issourced=-1; |
|
111 | + public function isSourced() { |
|
112 | + if ($this->_issourced !== null) return $this->_issourced; |
|
113 | + $this->_issourced = -1; |
|
114 | 114 | $sourcesfacts = $this->gedcomrecord->getFacts('SOUR'); |
115 | - foreach($sourcesfacts as $sourcefact){ |
|
116 | - $this->_issourced=max($this->_issourced, 1); |
|
117 | - if($sourcefact->getAttribute('_ACT')){ |
|
118 | - $this->_issourced=max($this->_issourced, 2); |
|
115 | + foreach ($sourcesfacts as $sourcefact) { |
|
116 | + $this->_issourced = max($this->_issourced, 1); |
|
117 | + if ($sourcefact->getAttribute('_ACT')) { |
|
118 | + $this->_issourced = max($this->_issourced, 2); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | return $this->_issourced; |
@@ -127,19 +127,19 @@ discard block |
||
127 | 127 | * @param string $eventslist |
128 | 128 | * @return int Level of sources |
129 | 129 | */ |
130 | - public function isFactSourced($eventslist){ |
|
131 | - if(empty($eventslist)) return 0; |
|
132 | - $isSourced=0; |
|
130 | + public function isFactSourced($eventslist) { |
|
131 | + if (empty($eventslist)) return 0; |
|
132 | + $isSourced = 0; |
|
133 | 133 | $facts = $this->gedcomrecord->getFacts($eventslist); |
134 | - foreach($facts as $fact){ |
|
135 | - if($isSourced < Fact::MAX_IS_SOURCED_LEVEL){ |
|
134 | + foreach ($facts as $fact) { |
|
135 | + if ($isSourced < Fact::MAX_IS_SOURCED_LEVEL) { |
|
136 | 136 | $dfact = new Fact($fact); |
137 | 137 | $tmpIsSourced = $dfact->isSourced(); |
138 | - if($tmpIsSourced != 0) { |
|
139 | - if($isSourced==0) { |
|
140 | - $isSourced = $tmpIsSourced; |
|
138 | + if ($tmpIsSourced != 0) { |
|
139 | + if ($isSourced == 0) { |
|
140 | + $isSourced = $tmpIsSourced; |
|
141 | 141 | } |
142 | - else{ |
|
142 | + else { |
|
143 | 143 | $isSourced = max($isSourced, $tmpIsSourced); |
144 | 144 | } |
145 | 145 | } |
@@ -91,7 +91,7 @@ |
||
91 | 91 | return $wb_controller->config($block_id); |
92 | 92 | } |
93 | 93 | catch (MvcException $ex) { |
94 | - if($ex->getHttpCode() != 200) throw $ex; |
|
94 | + if ($ex->getHttpCode() != 200) throw $ex; |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->view_bag = new ViewBag(); |
71 | 71 | $this->view_bag->set('generation', $this->generation); |
72 | 72 | $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration()); |
73 | - $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0); |
|
73 | + $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0) > 0); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | |
92 | 92 | $this->view_bag->set('title', $controller->getPageTitle()); |
93 | 93 | |
94 | - if($this->view_bag->get('is_setup', false)) { |
|
94 | + if ($this->view_bag->get('is_setup', false)) { |
|
95 | 95 | $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
96 | 96 | $this->view_bag->set('url_module', $this->module->getName()); |
97 | 97 | $this->view_bag->set('url_action', 'SosaList'); |
98 | 98 | $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
99 | 99 | $this->view_bag->set('min_gen', 1); |
100 | 100 | |
101 | - if($this->view_bag->get('has_sosa', false)) { |
|
101 | + if ($this->view_bag->get('has_sosa', false)) { |
|
102 | 102 | $controller->addInlineJavascript(' |
103 | 103 | jQuery("#sosalist-tabs").tabs(); |
104 | 104 | jQuery("#sosalist-tabs").css("visibility", "visible"); |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | "mod" : "'.$this->module->getName().'", |
110 | 110 | "mod_action": "SosaList@sosalist", |
111 | - "ged" : "' . $WT_TREE->getNameUrl(). '", |
|
111 | + "ged" : "' . $WT_TREE->getNameUrl().'", |
|
112 | 112 | "type" : "indi", |
113 | 113 | "gen" : "'.$this->generation.'" |
114 | 114 | }, |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | { |
134 | 134 | "mod" : "'.$this->module->getName().'", |
135 | 135 | "mod_action": "SosaList@sosalist", |
136 | - "ged" : "' . $WT_TREE->getNameUrl(). '", |
|
136 | + "ged" : "' . $WT_TREE->getNameUrl().'", |
|
137 | 137 | "type" : "fam", |
138 | 138 | "gen" : "'.$this->generation.'" |
139 | 139 | }, |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $this->view_bag->set('title', $controller->getPageTitle()); |
174 | 174 | |
175 | - if($this->view_bag->get('is_setup', false)) { |
|
175 | + if ($this->view_bag->get('is_setup', false)) { |
|
176 | 176 | $this->view_bag->set('url_module', $this->module->getName()); |
177 | 177 | $this->view_bag->set('url_action', 'SosaList@missing'); |
178 | 178 | $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
182 | 182 | $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
183 | 183 | |
184 | - $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
184 | + $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation - 1)); |
|
185 | 185 | $this->view_bag->set('perc_sosa', $perc_sosa); |
186 | 186 | |
187 | - if($this->view_bag->get('has_missing', false)) { |
|
188 | - $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
187 | + if ($this->view_bag->get('has_missing', false)) { |
|
188 | + $table_id = 'table-sosa-missing-'.Uuid::uuid4(); |
|
189 | 189 | $this->view_bag->set('table_id', $table_id); |
190 | 190 | |
191 | 191 | $controller |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc; |
196 | 196 | |
197 | 197 | jQuery("#'.$table_id.'").dataTable( { |
198 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
198 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
199 | 199 | '.I18N::datatablesI18N().', |
200 | 200 | jQueryUI: true, |
201 | 201 | autoWidth:false, |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | pagingType: "full_numbers" |
222 | 222 | }); |
223 | 223 | |
224 | - jQuery("#' . $table_id . '") |
|
224 | + jQuery("#' . $table_id.'") |
|
225 | 225 | /* Filter buttons in table header */ |
226 | 226 | .on("click", "button[data-filter-column]", function() { |
227 | 227 | var btn = jQuery(this); |
228 | 228 | // De-activate the other buttons in this button group |
229 | 229 | btn.siblings().removeClass("ui-state-active"); |
230 | 230 | // Apply (or clear) this filter |
231 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
231 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
232 | 232 | if (btn.hasClass("ui-state-active")) { |
233 | 233 | btn.removeClass("ui-state-active"); |
234 | 234 | col.search("").draw(); |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | $unique_indis = array(); |
246 | 246 | $sum_missing_different = 0; |
247 | 247 | $sum_missing_different_without_hidden = 0; |
248 | - foreach($missing_list as $num => $missing_tab) { |
|
249 | - if(isset($unique_indis[$missing_tab['indi']])) { |
|
248 | + foreach ($missing_list as $num => $missing_tab) { |
|
249 | + if (isset($unique_indis[$missing_tab['indi']])) { |
|
250 | 250 | unset($missing_list[$num]); |
251 | 251 | continue; |
252 | 252 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | $this->view_bag->set('missing_list', $missing_list); |
265 | 265 | $this->view_bag->set('missing_diff_count', $sum_missing_different); |
266 | 266 | $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden); |
267 | - $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2)); |
|
267 | + $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation - 2)); |
|
268 | 268 | $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential); |
269 | 269 | } |
270 | 270 | } |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | $controller = new AjaxController(); |
283 | 283 | $controller->restrictAccess($this->generation > 0 || !is_null($type)); |
284 | 284 | |
285 | - switch ($type){ |
|
285 | + switch ($type) { |
|
286 | 286 | case 'indi': |
287 | 287 | $this->renderSosaListIndi($controller); |
288 | 288 | break; |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); |
306 | 306 | $this->view_bag->set('has_sosa', false); |
307 | 307 | |
308 | - if(count($listSosa) > 0) { |
|
308 | + if (count($listSosa) > 0) { |
|
309 | 309 | $this->view_bag->set('has_sosa', true); |
310 | - $table_id = 'table-sosa-indi-' . Uuid::uuid4(); |
|
310 | + $table_id = 'table-sosa-indi-'.Uuid::uuid4(); |
|
311 | 311 | $this->view_bag->set('table_id', $table_id); |
312 | 312 | |
313 | 313 | $controller |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc; |
318 | 318 | |
319 | 319 | jQuery("#'.$table_id.'").dataTable( { |
320 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
321 | - ' . I18N::datatablesI18N() . ', |
|
320 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
321 | + ' . I18N::datatablesI18N().', |
|
322 | 322 | jQueryUI: true, |
323 | 323 | autoWidth: false, |
324 | 324 | processing: true, |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | pagingType: "full_numbers" |
348 | 348 | }); |
349 | 349 | |
350 | - jQuery("#' . $table_id . '") |
|
350 | + jQuery("#' . $table_id.'") |
|
351 | 351 | /* Hide/show parents */ |
352 | 352 | .on("click", ".btn-toggle-parents", function() { |
353 | 353 | jQuery(this).toggleClass("ui-state-active"); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | /* Hide/show statistics */ |
357 | 357 | .on("click", ".btn-toggle-statistics", function() { |
358 | 358 | jQuery(this).toggleClass("ui-state-active"); |
359 | - jQuery("#indi_list_table-charts_' . $table_id . '").slideToggle(); |
|
359 | + jQuery("#indi_list_table-charts_' . $table_id.'").slideToggle(); |
|
360 | 360 | }) |
361 | 361 | /* Filter buttons in table header */ |
362 | 362 | .on("click", "button[data-filter-column]", function() { |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | // De-activate the other buttons in this button group |
365 | 365 | btn.siblings().removeClass("ui-state-active"); |
366 | 366 | // Apply (or clear) this filter |
367 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
367 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
368 | 368 | if (btn.hasClass("ui-state-active")) { |
369 | 369 | btn.removeClass("ui-state-active"); |
370 | 370 | col.search("").draw(); |
@@ -399,30 +399,30 @@ discard block |
||
399 | 399 | $nb_displayed = 0; |
400 | 400 | |
401 | 401 | Individual::load($WT_TREE, $listSosa); |
402 | - foreach($listSosa as $sosa => $pid) { |
|
402 | + foreach ($listSosa as $sosa => $pid) { |
|
403 | 403 | $person = Individual::getInstance($pid, $WT_TREE); |
404 | 404 | if (!$person || !$person->canShowName()) { |
405 | 405 | unset($listSosa[$sosa]); |
406 | 406 | continue; |
407 | 407 | } |
408 | 408 | $nb_displayed++; |
409 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
409 | + if ($birth_dates = $person->getAllBirthDates()) { |
|
410 | 410 | if ( |
411 | 411 | FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
412 | 412 | !isset($unique_indis[$person->getXref()]) |
413 | 413 | ) { |
414 | - $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
414 | + $birt_by_decade[(int)($birth_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | else { |
418 | - $birth_dates[0]=new Date(''); |
|
418 | + $birth_dates[0] = new Date(''); |
|
419 | 419 | } |
420 | 420 | if ($death_dates = $person->getAllDeathDates()) { |
421 | 421 | if ( |
422 | 422 | FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
423 | 423 | !isset($unique_indis[$person->getXref()]) |
424 | 424 | ) { |
425 | - $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
425 | + $deat_by_decade[(int)($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | else { |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | $this->view_bag->set('sosa_list', $listSosa); |
439 | 439 | |
440 | 440 | $this->view_bag->set('sosa_count', count($listSosa)); |
441 | - $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
441 | + $this->view_bag->set('sosa_theo', pow(2, $this->generation - 1)); |
|
442 | 442 | $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
443 | 443 | |
444 | 444 | $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | protected function renderFamSosaListIndi(AjaxController $controller) { |
459 | 459 | global $WT_TREE; |
460 | 460 | |
461 | - $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
461 | + $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation); ; |
|
462 | 462 | $this->view_bag->set('has_sosa', false); |
463 | 463 | |
464 | - if(count($listFamSosa) > 0) { |
|
464 | + if (count($listFamSosa) > 0) { |
|
465 | 465 | $this->view_bag->set('has_sosa', true); |
466 | - $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
466 | + $table_id = 'table-sosa-fam-'.Uuid::uuid4(); |
|
467 | 467 | $this->view_bag->set('table_id', $table_id); |
468 | 468 | |
469 | 469 | $controller |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | jQuery.fn.dataTableExt.oSort["text-desc"] = textCompareDesc; |
474 | 474 | |
475 | 475 | jQuery("#'.$table_id.'").dataTable( { |
476 | - dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
476 | + dom: \'<"H"<"filtersH_' . $table_id.'"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
477 | 477 | '.I18N::datatablesI18N(array(16, 32, 64, 128, -1)).', |
478 | 478 | jQueryUI: true, |
479 | 479 | autoWidth: false, |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | pagingType: "full_numbers" |
501 | 501 | }); |
502 | 502 | |
503 | - jQuery("#' . $table_id . '") |
|
503 | + jQuery("#' . $table_id.'") |
|
504 | 504 | /* Hide/show parents */ |
505 | 505 | .on("click", ".btn-toggle-parents", function() { |
506 | 506 | jQuery(this).toggleClass("ui-state-active"); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | /* Hide/show statistics */ |
510 | 510 | .on("click", ".btn-toggle-statistics", function() { |
511 | 511 | jQuery(this).toggleClass("ui-state-active"); |
512 | - jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle(); |
|
512 | + jQuery("#fam_list_table-charts_' . $table_id.'").slideToggle(); |
|
513 | 513 | }) |
514 | 514 | /* Filter buttons in table header */ |
515 | 515 | .on("click", "button[data-filter-column]", function() { |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | // De-activate the other buttons in this button group |
518 | 518 | btn.siblings().removeClass("ui-state-active"); |
519 | 519 | // Apply (or clear) this filter |
520 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
520 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
521 | 521 | if (btn.hasClass("ui-state-active")) { |
522 | 522 | btn.removeClass("ui-state-active"); |
523 | 523 | col.search("").draw(); |
@@ -537,29 +537,29 @@ discard block |
||
537 | 537 | |
538 | 538 | //-- init chart data |
539 | 539 | $marr_by_age = array(); |
540 | - for ($age=0; $age<=$max_age; $age++) { |
|
540 | + for ($age = 0; $age <= $max_age; $age++) { |
|
541 | 541 | $marr_by_age[$age] = ''; |
542 | 542 | } |
543 | 543 | $birt_by_decade = array(); |
544 | 544 | $marr_by_decade = array(); |
545 | - for ($year=1550; $year<2030; $year+=10) { |
|
545 | + for ($year = 1550; $year < 2030; $year += 10) { |
|
546 | 546 | $birt_by_decade[$year] = ''; |
547 | 547 | $marr_by_decade[$year] = ''; |
548 | 548 | } |
549 | 549 | |
550 | - foreach($listFamSosa as $sosa => $fid) { |
|
550 | + foreach ($listFamSosa as $sosa => $fid) { |
|
551 | 551 | $sfamily = Family::getInstance($fid, $WT_TREE); |
552 | - if(!$sfamily || !$sfamily->canShow()) { |
|
552 | + if (!$sfamily || !$sfamily->canShow()) { |
|
553 | 553 | unset($listFamSosa[$sosa]); |
554 | 554 | continue; |
555 | 555 | } |
556 | - $mdate=$sfamily->getMarriageDate(); |
|
556 | + $mdate = $sfamily->getMarriageDate(); |
|
557 | 557 | |
558 | - if( ($husb = $sfamily->getHusband()) && |
|
558 | + if (($husb = $sfamily->getHusband()) && |
|
559 | 559 | ($hdate = $husb->getBirthDate()) && |
560 | 560 | $hdate->isOK() && $mdate->isOK()) { |
561 | 561 | if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
562 | - $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
562 | + $birt_by_decade[(int)($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
563 | 563 | } |
564 | 564 | $hage = Date::getAge($hdate, $mdate, 0); |
565 | 565 | if ($hage >= 0 && $hage <= $max_age) { |
@@ -567,11 +567,11 @@ discard block |
||
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
570 | - if(($wife = $sfamily->getWife()) && |
|
571 | - ($wdate=$wife->getBirthDate()) && |
|
570 | + if (($wife = $sfamily->getWife()) && |
|
571 | + ($wdate = $wife->getBirthDate()) && |
|
572 | 572 | $wdate->isOK() && $mdate->isOK()) { |
573 | 573 | if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
574 | - $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
574 | + $birt_by_decade[(int)($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
575 | 575 | } |
576 | 576 | $wage = Date::getAge($wdate, $mdate, 0); |
577 | 577 | if ($wage >= 0 && $wage <= $max_age) { |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | } |
581 | 581 | |
582 | 582 | if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
583 | - $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
583 | + $marr_by_decade[(int)($mdate->gregorianYear() / 10) * 10] .= $husb->getSex().$wife->getSex(); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | $listFamSosa[$sosa] = $sfamily; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->tree = $tree; |
59 | 59 | $this->user = $user; |
60 | 60 | |
61 | - $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
61 | + $this->sosa_provider = new SosaProvider($this->tree, $this->user); ; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | public function computeAll() { |
69 | 69 | $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
70 | 70 | $indi = Individual::getInstance($root_id, $this->tree); |
71 | - if($indi){ |
|
71 | + if ($indi) { |
|
72 | 72 | $this->sosa_provider->deleteAll(); |
73 | 73 | $this->addNode($indi, 1); |
74 | 74 | $this->flushTmpSosaTable(true); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public function computeFromIndividual(Individual $indi) { |
86 | 86 | $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
87 | 87 | $current_sosas = $dindi->getSosaNumbers(); |
88 | - foreach($current_sosas as $current_sosa => $gen) { |
|
88 | + foreach ($current_sosas as $current_sosa => $gen) { |
|
89 | 89 | $this->sosa_provider->deleteAncestors($current_sosa); |
90 | 90 | $this->addNode($indi, $current_sosa); |
91 | 91 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | |
112 | 112 | $this->flushTmpSosaTable(); |
113 | 113 | |
114 | - if($fam = $indi->getPrimaryChildFamily()) { |
|
115 | - if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
116 | - if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
114 | + if ($fam = $indi->getPrimaryChildFamily()) { |
|
115 | + if ($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
116 | + if ($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param bool $force Should the flush be forced |
124 | 124 | */ |
125 | 125 | protected function flushTmpSosaTable($force = false) { |
126 | - if( count($this->tmp_sosa_table)> 0 && |
|
127 | - ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
126 | + if (count($this->tmp_sosa_table) > 0 && |
|
127 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)) { |
|
128 | 128 | $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
129 | 129 | $this->tmp_sosa_table = array(); |
130 | 130 | } |
@@ -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 SQL_CACHE COUNT(*) FROM `##individuals`' . |
|
417 | + 'SELECT SQL_CACHE 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 SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
431 | + 'SELECT SQL_CACHE 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 SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
448 | + 'SELECT SQL_CACHE 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 SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
467 | + 'SELECT SQL_CACHE 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 SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
485 | + 'SELECT SQL_CACHE 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 SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
502 | + 'SELECT SQL_CACHE 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,'. |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $view_bag->set('title', $controller->getPageTitle()); |
64 | 64 | $view_bag->set('is_setup', false); |
65 | 65 | |
66 | - if($this->sosa_provider->isSetup()) { |
|
66 | + if ($this->sosa_provider->isSetup()) { |
|
67 | 67 | $view_bag->set('is_setup', true); |
68 | 68 | |
69 | 69 | $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$WT_TREE->getNameUrl().'&gen='); |
85 | 85 | $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$WT_TREE->getNameUrl().'&gen='); |
86 | 86 | |
87 | - $gen_theoretical=1; |
|
88 | - $total_theoretical=0; |
|
89 | - $prev_diff=0; |
|
90 | - $prev_known=0.5; |
|
91 | - $gen_equiv=0; |
|
87 | + $gen_theoretical = 1; |
|
88 | + $total_theoretical = 0; |
|
89 | + $prev_diff = 0; |
|
90 | + $prev_known = 0.5; |
|
91 | + $gen_equiv = 0; |
|
92 | 92 | $generation_stats = array(); |
93 | 93 | |
94 | - foreach($stats_gen as $gen => $tab){ |
|
95 | - $genY1= I18N::translate('-'); |
|
96 | - $genY2= I18N::translate('-'); |
|
97 | - if($tab['firstBirth']>0) $genY1=$tab['firstBirth']; |
|
98 | - if($tab['lastBirth']>0) $genY2=$tab['lastBirth']; |
|
94 | + foreach ($stats_gen as $gen => $tab) { |
|
95 | + $genY1 = I18N::translate('-'); |
|
96 | + $genY2 = I18N::translate('-'); |
|
97 | + if ($tab['firstBirth'] > 0) $genY1 = $tab['firstBirth']; |
|
98 | + if ($tab['lastBirth'] > 0) $genY2 = $tab['lastBirth']; |
|
99 | 99 | $total_theoretical += $gen_theoretical; |
100 | 100 | $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
101 | 101 | $gen_equiv += $perc_sosa_count_theor; |
102 | - $missing=2*$prev_known - $tab['sosaCount']; |
|
103 | - $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
102 | + $missing = 2 * $prev_known - $tab['sosaCount']; |
|
103 | + $gen_diff = $tab['diffSosaTotalCount'] - $prev_diff; |
|
104 | 104 | |
105 | 105 | $generation_stats[$gen] = array( |
106 | 106 | 'gen_min_birth' => $genY1, |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | 'known' => $tab['sosaCount'], |
110 | 110 | 'perc_known' => $perc_sosa_count_theor, |
111 | 111 | 'missing' => $missing, |
112 | - 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
112 | + 'perc_missing' => 1 - Functions::safeDivision($tab['sosaCount'], 2 * $prev_known), |
|
113 | 113 | 'total_known' => $tab['sosaTotalCount'], |
114 | 114 | 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
115 | 115 | 'different' => $gen_diff, |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | ); |
120 | 120 | |
121 | 121 | $gen_theoretical = $gen_theoretical * 2; |
122 | - $prev_known=$tab['sosaCount']; |
|
123 | - $prev_diff=$tab['diffSosaTotalCount']; |
|
122 | + $prev_known = $tab['sosaCount']; |
|
123 | + $prev_diff = $tab['diffSosaTotalCount']; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $view_bag->set('generation_stats', $generation_stats); |
@@ -141,27 +141,27 @@ discard block |
||
141 | 141 | private function htmlAncestorDispersionG2() |
142 | 142 | { |
143 | 143 | $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
144 | - if(count($ancestorsDispGen2) == 0) return; |
|
144 | + if (count($ancestorsDispGen2) == 0) return; |
|
145 | 145 | |
146 | 146 | $size = '600x300'; |
147 | 147 | |
148 | 148 | $total = array_sum($ancestorsDispGen2); |
149 | 149 | $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
150 | - $father = array ( |
|
150 | + $father = array( |
|
151 | 151 | 'color' => '84beff', |
152 | 152 | 'count' => $father_count, |
153 | 153 | 'perc' => Functions::safeDivision($father_count, $total), |
154 | 154 | 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
155 | 155 | ); |
156 | 156 | $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
157 | - $mother = array ( |
|
157 | + $mother = array( |
|
158 | 158 | 'color' => 'ffd1dc', |
159 | 159 | 'count' => $mother_count, |
160 | 160 | 'perc' => Functions::safeDivision($mother_count, $total), |
161 | 161 | 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
162 | 162 | ); |
163 | 163 | $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
164 | - $shared = array ( |
|
164 | + $shared = array( |
|
165 | 165 | 'color' => '777777', |
166 | 166 | 'count' => $shared_count, |
167 | 167 | 'perc' => Functions::safeDivision($shared_count, $total), |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
172 | 172 | $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
173 | 173 | $chl = |
174 | - $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
175 | - $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
176 | - $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
177 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
174 | + $father['name'].' - '.I18N::percentage($father['perc'], 1).'|'. |
|
175 | + $shared['name'].' - '.I18N::percentage($shared['perc'], 1).'|'. |
|
176 | + $mother['name'].' - '.I18N::percentage($mother['perc'], 1); |
|
177 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />"; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
199 | 199 | $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
200 | 200 | $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
201 | - $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
201 | + $total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha; |
|
202 | 202 | |
203 | 203 | $chd = $this->arrayToExtendedEncoding(array( |
204 | 204 | 4095 * Functions::safeDivision($total_fatfat, $total), |
@@ -209,12 +209,12 @@ discard block |
||
209 | 209 | )); |
210 | 210 | $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
211 | 211 | $chl = |
212 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
213 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
214 | - I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
215 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
216 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
217 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
212 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat').' - '.I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1).'|'. |
|
213 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot').' - '.I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1).'|'. |
|
214 | + I18N::translate('Shared').' - '.I18N::percentage(Functions::safeDivision($total_sha, $total), 1).'|'. |
|
215 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat').' - '.I18N::percentage(Functions::safeDivision($total_motfat, $total), 1).'|'. |
|
216 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot').' - '.I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
217 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />"; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -230,9 +230,9 @@ discard block |
||
230 | 230 | if ($value < 0) { |
231 | 231 | $value = 0; |
232 | 232 | } |
233 | - $first = (int) ($value / 64); |
|
233 | + $first = (int)($value / 64); |
|
234 | 234 | $second = $value % 64; |
235 | - $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
235 | + $encoding .= $xencoding[(int)$first].$xencoding[(int)$second]; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | return $encoding; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
77 | 77 | */ |
78 | 78 | public function getConfigLink() { |
79 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
79 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function getMenu(Tree $tree, $reference = null) { |
103 | 103 | $tree_url = $tree ? $tree->getNameUrl() : ''; |
104 | - return new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=Certificate@listAll&ged=' . $tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
104 | + return new Menu($this->getTitle(), 'module.php?mod='.$this->getName().'&mod_action=Certificate@listAll&ged='.$tree_url, 'menu-maj-list-certificate', array('rel' => 'nofollow')); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | public function hFactSourcePrepend($srec) { |
112 | 112 | global $WT_TREE; |
113 | 113 | |
114 | - $html=''; |
|
115 | - $sid=null; |
|
114 | + $html = ''; |
|
115 | + $sid = null; |
|
116 | 116 | |
117 | - if($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)){ |
|
117 | + if ($this->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($WT_TREE)) { |
|
118 | 118 | if (!$srec || strlen($srec) == 0) return $html; |
119 | 119 | |
120 | 120 | $certificate = null; |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | $levelSOUR = substr($subrecords[0], 0, 1); |
123 | 123 | $match = null; |
124 | 124 | if (preg_match('~^'.$levelSOUR.' SOUR @('.WT_REGEX_XREF.')@$~', $subrecords[0], $match)) { |
125 | - $sid=$match[1]; |
|
125 | + $sid = $match[1]; |
|
126 | 126 | }; |
127 | 127 | $nb_subrecords = count($subrecords); |
128 | - for ($i=0; $i < $nb_subrecords; $i++) { |
|
128 | + for ($i = 0; $i < $nb_subrecords; $i++) { |
|
129 | 129 | $subrecords[$i] = trim($subrecords[$i]); |
130 | 130 | $tag = substr($subrecords[$i], 2, 4); |
131 | 131 | $text = substr($subrecords[$i], 7); |
132 | - if($tag == '_ACT') $certificate= new Certificate($text, $WT_TREE, $this->getProvider()); |
|
132 | + if ($tag == '_ACT') $certificate = new Certificate($text, $WT_TREE, $this->getProvider()); |
|
133 | 133 | } |
134 | 134 | |
135 | - if($certificate && $certificate->canShow()) |
|
135 | + if ($certificate && $certificate->canShow()) |
|
136 | 136 | $html = $this->getDisplay_ACT($certificate, $sid); |
137 | 137 | |
138 | 138 | } |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function hHtmlSimpleTagDisplay($tag, $value, $context = null, $contextid = null) { |
161 | 161 | $html = ''; |
162 | - switch($tag){ |
|
162 | + switch ($tag) { |
|
163 | 163 | case '_ACT': |
164 | - if($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
164 | + if ($context == 'SOUR') $html = $this->getDisplay_ACT($value, $contextid); |
|
165 | 165 | break; |
166 | 166 | } |
167 | 167 | return $html; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | $html = ''; |
178 | 178 | |
179 | - switch($tag){ |
|
179 | + switch ($tag) { |
|
180 | 180 | case '_ACT': |
181 | 181 | $element_id = Uuid::uuid4(); |
182 | 182 | $controller |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/autocomplete.js') |
185 | 185 | ->addExternalJavascript(WT_STATIC_URL.WT_MODULES_DIR.$this->getName().'/js/updatecertificatevalues.js'); |
186 | 186 | $certificate = null; |
187 | - if($value){ |
|
187 | + if ($value) { |
|
188 | 188 | $certificate = new Certificate($value, $WT_TREE, $this->getProvider()); |
189 | 189 | } |
190 | 190 | $tabCities = $this->getProvider()->getCitiesList(); |
191 | 191 | $html .= '<select id="certifCity'.$element_id.'" class="_CITY">'; |
192 | - foreach ($tabCities as $cities){ |
|
193 | - $selectedCity=''; |
|
194 | - if($certificate && $cities== $certificate->getCity()) $selectedCity='selected="true"'; |
|
192 | + foreach ($tabCities as $cities) { |
|
193 | + $selectedCity = ''; |
|
194 | + if ($certificate && $cities == $certificate->getCity()) $selectedCity = 'selected="true"'; |
|
195 | 195 | $html .= '<option value="'.$cities.'" '.$selectedCity.' />'.$cities.'</option>'; |
196 | 196 | } |
197 | 197 | $html .= '</select>'; |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hAddSimpleTag() |
210 | 210 | */ |
211 | 211 | public function hAddSimpleTag($context, $level) { |
212 | - switch($context){ |
|
212 | + switch ($context) { |
|
213 | 213 | case 'SOUR': |
214 | 214 | FunctionsEdit::addSimpleTag($level.' _ACT'); |
215 | 215 | break; |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hHasHelpTextTag() |
222 | 222 | */ |
223 | 223 | public function hHasHelpTextTag($tag) { |
224 | - switch($tag){ |
|
224 | + switch ($tag) { |
|
225 | 225 | case '_ACT': |
226 | 226 | return true; |
227 | 227 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @see \MyArtJaub\Webtrees\Hook\HookInterfaces\CustomSimpleTagManagerInterface::hGetHelpTextTag() |
234 | 234 | */ |
235 | 235 | public function hGetHelpTextTag($tag) { |
236 | - switch($tag){ |
|
236 | + switch ($tag) { |
|
237 | 237 | case '_ACT': |
238 | 238 | return array( |
239 | 239 | I18N::translate('Certificate'), |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | public function getProvider() { |
252 | 252 | global $WT_TREE; |
253 | 253 | |
254 | - if(!$this->provider) { |
|
254 | + if (!$this->provider) { |
|
255 | 255 | $root_path = $this->getSetting('MAJ_CERT_ROOTDIR', 'certificates/'); |
256 | 256 | $this->provider = new CertificateFileProvider($root_path, $WT_TREE); |
257 | 257 | } |
@@ -265,9 +265,9 @@ discard block |
||
265 | 265 | * @param Certificate $certificatePath Certificate (as per the GEDCOM) |
266 | 266 | * @param string|null $sid Linked Source ID, if it exists |
267 | 267 | */ |
268 | - protected function getDisplay_ACT(Certificate $certificate, $sid = null){ |
|
268 | + protected function getDisplay_ACT(Certificate $certificate, $sid = null) { |
|
269 | 269 | $html = ''; |
270 | - if($certificate){ |
|
270 | + if ($certificate) { |
|
271 | 271 | $certificate->setSource($sid); |
272 | 272 | $html = $certificate->displayImage('icon'); |
273 | 273 | } |
@@ -33,26 +33,26 @@ discard block |
||
33 | 33 | * Manage updates sent from the AdminConfig@index form. |
34 | 34 | */ |
35 | 35 | protected function update() { |
36 | - if(Auth::isAdmin()){ |
|
36 | + if (Auth::isAdmin()) { |
|
37 | 37 | $ihooks = HookProvider::getInstance()->getInstalledHooks(); |
38 | 38 | |
39 | - $module_names= Database::prepare( |
|
39 | + $module_names = Database::prepare( |
|
40 | 40 | "SELECT module_name FROM `##module` WHERE status='disabled'" |
41 | 41 | )->fetchOneColumn(); |
42 | 42 | |
43 | - if($ihooks !== null){ |
|
43 | + if ($ihooks !== null) { |
|
44 | 44 | foreach ($ihooks as $ihook => $params) { |
45 | - if(Filter::post('hook-' . $params['id']) === 'yes') { |
|
45 | + if (Filter::post('hook-'.$params['id']) === 'yes') { |
|
46 | 46 | $array_hook = explode('#', $ihook); |
47 | 47 | //Update status |
48 | - $new_status= Filter::postBool('status-' . $params['id']); |
|
49 | - if(in_array($array_hook[0], $module_names)) $new_status = false; |
|
48 | + $new_status = Filter::postBool('status-'.$params['id']); |
|
49 | + if (in_array($array_hook[0], $module_names)) $new_status = false; |
|
50 | 50 | $previous_status = $params['status']; |
51 | 51 | if ($new_status !== null) { |
52 | - $new_status= $new_status ? 'enabled' : 'disabled'; |
|
53 | - if($new_status != $previous_status){ |
|
52 | + $new_status = $new_status ? 'enabled' : 'disabled'; |
|
53 | + if ($new_status != $previous_status) { |
|
54 | 54 | $chook = new Hook($array_hook[1], $array_hook[2]); |
55 | - switch($new_status){ |
|
55 | + switch ($new_status) { |
|
56 | 56 | case 'enabled': |
57 | 57 | $chook->enable($array_hook[0]); |
58 | 58 | break; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $new_priority = Filter::postInteger("moduleorder-{$params['id']}"); |
70 | 70 | $previous_priority = $params['priority']; |
71 | 71 | if ($new_priority !== null) { |
72 | - if($new_priority != $previous_priority){ |
|
72 | + if ($new_priority != $previous_priority) { |
|
73 | 73 | $chook = new Hook($array_hook[1], $array_hook[2]); |
74 | 74 | $chook->setPriority($array_hook[0], $new_priority); |
75 | 75 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | HookProvider::getInstance()->updateHooks(); |
94 | 94 | |
95 | 95 | $action = Filter::post('action'); |
96 | - if($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
96 | + if ($action == 'update' && Filter::checkCsrf()) $this->update(); |
|
97 | 97 | |
98 | 98 | Theme::theme(new AdministrationTheme)->init($WT_TREE); |
99 | 99 | $ctrl = new PageController(); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | ->restrictAccess(Auth::isAdmin()) |
102 | 102 | ->setPageTitle($this->module->getTitle()); |
103 | 103 | |
104 | - $table_id = 'table-installedhooks-' . Uuid::uuid4(); |
|
104 | + $table_id = 'table-installedhooks-'.Uuid::uuid4(); |
|
105 | 105 | |
106 | 106 | $view_bag = new ViewBag(); |
107 | 107 | $view_bag->set('title', $ctrl->getPageTitle()); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | $tasks = $this->provider->getTasksToRun($token == $token_submitted, $task_name); |
70 | 70 | |
71 | - foreach($tasks as $task) { |
|
71 | + foreach ($tasks as $task) { |
|
72 | 72 | $task->execute(); |
73 | 73 | } |
74 | 74 | } |
@@ -89,19 +89,19 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | $status = Filter::getBool('status'); |
92 | - $res = array('task' => $task->getName() , 'error' => null); |
|
93 | - try{ |
|
92 | + $res = array('task' => $task->getName(), 'error' => null); |
|
93 | + try { |
|
94 | 94 | $this->provider->setTaskStatus($task, $status); |
95 | 95 | $res['status'] = $status; |
96 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
|
96 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" has been '.($status ? 'enabled' : 'disabled').'.'); |
|
97 | 97 | } |
98 | 98 | catch (\Exception $ex) { |
99 | 99 | $res['error'] = $ex->getMessage(); |
100 | - Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
|
100 | + Log::addErrorLog('Module '.$this->module->getName().' : Admin Task "'.$task->getName().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $controller->pageHeader(); |
104 | - if($res['error']) http_response_code(500); |
|
104 | + if ($res['error']) http_response_code(500); |
|
105 | 105 | |
106 | 106 | $controller->encode($res); |
107 | 107 | } |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | |
139 | 139 | $data = new ViewBag(); |
140 | 140 | $data->set('title', $controller->getPageTitle()); |
141 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl()); |
|
141 | + $data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$WT_TREE->getNameUrl()); |
|
142 | 142 | $data->set('module_title', $this->module->getTitle()); |
143 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@save&ged=' . $WT_TREE->getNameUrl()); |
|
143 | + $data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=Task@save&ged='.$WT_TREE->getNameUrl()); |
|
144 | 144 | $data->set('task', $task); |
145 | 145 | |
146 | 146 | ViewFactory::make('TaskEdit', $this, $controller, $data)->render(); |
@@ -157,17 +157,17 @@ discard block |
||
157 | 157 | && Filter::checkCsrf() |
158 | 158 | ); |
159 | 159 | |
160 | - $task_name = Filter::post('task'); |
|
161 | - $frequency = Filter::postInteger('frequency'); |
|
162 | - $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
163 | - $nb_occur = Filter::postInteger('nb_occur'); |
|
160 | + $task_name = Filter::post('task'); |
|
161 | + $frequency = Filter::postInteger('frequency'); |
|
162 | + $is_limited = Filter::postInteger('is_limited', 0, 1); |
|
163 | + $nb_occur = Filter::postInteger('nb_occur'); |
|
164 | 164 | |
165 | 165 | $task = $this->provider->getTask($task_name, false); |
166 | 166 | |
167 | 167 | $success = false; |
168 | - if($task) { |
|
168 | + if ($task) { |
|
169 | 169 | $task->setFrequency($frequency); |
170 | - if($is_limited == 1) { |
|
170 | + if ($is_limited == 1) { |
|
171 | 171 | $task->setRemainingOccurrences($nb_occur); |
172 | 172 | } |
173 | 173 | else { |
@@ -176,34 +176,34 @@ discard block |
||
176 | 176 | |
177 | 177 | $res = $task->save(); |
178 | 178 | |
179 | - if($res) { |
|
180 | - if($task instanceof MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface) { |
|
179 | + if ($res) { |
|
180 | + if ($task instanceof MyArtJaub\Webtrees\Module\AdminTasks\Model\ConfigurableTaskInterface) { |
|
181 | 181 | $res = $task->saveConfig(); |
182 | 182 | |
183 | - if(!$res) { |
|
183 | + if (!$res) { |
|
184 | 184 | FlashMessages::addMessage(I18N::translate('An error occured while updating the specific settings of administrative task “%s”', $task->getTitle()), 'danger'); |
185 | - Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” specific settings could not be updated. See error log.'); |
|
185 | + Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName().'” specific settings could not be updated. See error log.'); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - if($res) { |
|
189 | + if ($res) { |
|
190 | 190 | FlashMessages::addMessage(I18N::translate('The administrative task “%s” has been successfully updated', $task->getTitle()), 'success'); |
191 | - Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName() .'” has been updated.'); |
|
191 | + Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName().'” has been updated.'); |
|
192 | 192 | $success = true; |
193 | 193 | } |
194 | 194 | } |
195 | 195 | else { |
196 | 196 | FlashMessages::addMessage(I18N::translate('An error occured while updating the administrative task “%s”', $task->getTitle()), 'danger'); |
197 | - Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'. $task->getName() .'” could not be updated. See error log.'); |
|
197 | + Log::addConfigurationLog('Module '.$this->module->getName().' : AdminTask “'.$task->getName().'” could not be updated. See error log.'); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | } |
201 | 201 | |
202 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'; |
|
203 | - if(!$success) { |
|
204 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=Task@edit&task='. $task->getName(); |
|
202 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig'; |
|
203 | + if (!$success) { |
|
204 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=Task@edit&task='.$task->getName(); |
|
205 | 205 | } |
206 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
206 | + header('Location: '.WT_BASE_URL.$redirection_url); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | } |
210 | 210 | \ No newline at end of file |