@@ -35,8 +35,8 @@ |
||
35 | 35 | $surn = str_replace('@N.N.', 'AAAA', $surn); |
36 | 36 | |
37 | 37 | return array( |
38 | - $surn . 'AAAA' . $givn, |
|
39 | - $givn . 'AAAA' . $surn, |
|
38 | + $surn.'AAAA'.$givn, |
|
39 | + $givn.'AAAA'.$surn, |
|
40 | 40 | ); |
41 | 41 | } |
42 | 42 |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | <input type="hidden" name="ged" value="<?= $this->data->get('url_ged') ?>"> |
40 | 40 | <select name="city"> |
41 | 41 | <?php foreach ($cities as $city) { ?> |
42 | - <option value="<?= Functions::encryptToSafeBase64($city) ?>" <?php if(trim($city) == trim($selected_city)) echo 'selected="selected"'?> ><?= $city ?></option> |
|
42 | + <option value="<?= Functions::encryptToSafeBase64($city) ?>" <?php if (trim($city) == trim($selected_city)) echo 'selected="selected"'?> ><?= $city ?></option> |
|
43 | 43 | <?php } ?> |
44 | 44 | </select> |
45 | 45 | <input type="submit" value="<?= I18N::translate('Show') ?>" /> |
46 | 46 | </form> |
47 | 47 | |
48 | - <?php if($this->data->get('has_list', false)) { ?> |
|
48 | + <?php if ($this->data->get('has_list', false)) { ?> |
|
49 | 49 | <div class="loading-image"> </div> |
50 | 50 | <div class="certificate-list"> |
51 | 51 | <table id="<?= $this->data->get('table_id') ?>"> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | ?> |
63 | 63 | <tr> |
64 | 64 | <!-- Certificate date --> |
65 | - <?php if($date = $certificate->getCertificateDate()) { ?> |
|
65 | + <?php if ($date = $certificate->getCertificateDate()) { ?> |
|
66 | 66 | <td data-sort="<?= $date->julianDay() ?>"><?= $date->display() ?></td> |
67 | 67 | <?php } else { ?> |
68 | 68 | <td data-sort="0"> </td> |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | <?php |
74 | 74 | $name = $certificate->getCertificateDetails() ?: ''; |
75 | 75 | $sortname = ""; |
76 | - $ct_names=preg_match("/([A-Z]{2,})/", $name, $match); |
|
77 | - if($ct_names > 0) $sortname = $match[1].'_'; |
|
76 | + $ct_names = preg_match("/([A-Z]{2,})/", $name, $match); |
|
77 | + if ($ct_names > 0) $sortname = $match[1].'_'; |
|
78 | 78 | $sortname .= $name; |
79 | 79 | ?> |
80 | 80 | <td data-sort="<?= Filter::escapeHtml($sortname) ?>"> |
@@ -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 | } |
@@ -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,'. |
@@ -57,7 +57,7 @@ |
||
57 | 57 | public function getConfigLink() { |
58 | 58 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
59 | 59 | |
60 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
60 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param \Fisharebest\Webtrees\Fact $fact_in The Fact to extend |
40 | 40 | */ |
41 | - public function __construct(\Fisharebest\Webtrees\Fact $fact_in){ |
|
41 | + public function __construct(\Fisharebest\Webtrees\Fact $fact_in) { |
|
42 | 42 | $this->fact = $fact_in; |
43 | 43 | } |
44 | 44 | |
@@ -54,22 +54,22 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return int Level of sources |
56 | 56 | */ |
57 | - public function isSourced(){ |
|
58 | - $isSourced=0; |
|
57 | + public function isSourced() { |
|
58 | + $isSourced = 0; |
|
59 | 59 | $date = $this->fact->getDate(); |
60 | - if($date->isOK()) { |
|
61 | - $isSourced=-1; |
|
62 | - if($date->qual1=='' && $date->minimumJulianDay() == $date->maximumJulianDay()){ |
|
63 | - $isSourced=-2; |
|
60 | + if ($date->isOK()) { |
|
61 | + $isSourced = -1; |
|
62 | + if ($date->qual1 == '' && $date->minimumJulianDay() == $date->maximumJulianDay()) { |
|
63 | + $isSourced = -2; |
|
64 | 64 | $citations = $this->fact->getCitations(); |
65 | - foreach($citations as $citation){ |
|
66 | - $isSourced=max($isSourced, 1); |
|
67 | - if(preg_match('/3 _ACT (.*)/', $citation) ){ |
|
68 | - $isSourced=max($isSourced, 2); |
|
65 | + foreach ($citations as $citation) { |
|
66 | + $isSourced = max($isSourced, 1); |
|
67 | + if (preg_match('/3 _ACT (.*)/', $citation)) { |
|
68 | + $isSourced = max($isSourced, 2); |
|
69 | 69 | preg_match_all("/4 DATE (.*)/", $citation, $datessource, PREG_SET_ORDER); |
70 | - foreach($datessource as $daterec){ |
|
70 | + foreach ($datessource as $daterec) { |
|
71 | 71 | $datesource = new Date($daterec[1]); |
72 | - if(abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN){ |
|
72 | + if (abs($datesource->julianDay() - $date->julianDay()) < self::DATE_PRECISION_MARGIN) { |
|
73 | 73 | $isSourced = max($isSourced, 3); //If this level increases, do not forget to change the constant MAX_IS_SOURCED_LEVEL |
74 | 74 | } |
75 | 75 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function index(PageController $parent_controller, Tree $tree, $block_id, $template) { |
46 | 46 | $view_bag = new ViewBag(); |
47 | 47 | |
48 | - if($parent_controller && $tree) { |
|
48 | + if ($parent_controller && $tree) { |
|
49 | 49 | |
50 | 50 | $view_bag->set('tree', $tree); |
51 | 51 | $view_bag->set('indi', $parent_controller->getSignificantIndividual()); |
@@ -64,22 +64,22 @@ discard block |
||
64 | 64 | '); |
65 | 65 | |
66 | 66 | if (Auth::isAdmin()) { |
67 | - $title='<a class="icon-admin" title="'.I18N::translate('Preferences').'" href="block_edit.php?block_id='.$block_id.'&ged=' . $tree->getNameHtml() . '&ctype=gedcom"></a>'; |
|
67 | + $title = '<a class="icon-admin" title="'.I18N::translate('Preferences').'" href="block_edit.php?block_id='.$block_id.'&ged='.$tree->getNameHtml().'&ctype=gedcom"></a>'; |
|
68 | 68 | } else { |
69 | - $title=''; |
|
69 | + $title = ''; |
|
70 | 70 | } |
71 | - $title .='<span dir="auto">'.$tree->getTitleHtml().'</span>'; |
|
71 | + $title .= '<span dir="auto">'.$tree->getTitleHtml().'</span>'; |
|
72 | 72 | |
73 | 73 | $piwik_enabled = $this->module->getBlockSetting($block_id, 'piwik_enabled', false); |
74 | 74 | $view_bag->set('piwik_enabled', $piwik_enabled); |
75 | - if($piwik_enabled) { |
|
75 | + if ($piwik_enabled) { |
|
76 | 76 | $parent_controller->addInlineJavascript( |
77 | 77 | '$("#piwik_stats") |
78 | 78 | .load("module.php?mod='.$this->module->getName().'&mod_action=Piwik&block_id='.$block_id.'");' |
79 | 79 | ); |
80 | 80 | } |
81 | 81 | |
82 | - $content = ViewFactory::make('WelcomeBlock', $this, new BaseController(), $view_bag)->getHtmlPartial(); |
|
82 | + $content = ViewFactory::make('WelcomeBlock', $this, new BaseController(), $view_bag)->getHtmlPartial(); |
|
83 | 83 | |
84 | 84 | if ($template) { |
85 | 85 | return Theme::theme()->formatBlock($id, $title, $class, $content); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function config($block_id = null) { |
100 | 100 | |
101 | - if(empty($block_id)) throw new MvcException(404); |
|
101 | + if (empty($block_id)) throw new MvcException(404); |
|
102 | 102 | |
103 | 103 | if (Filter::postBool('save') && Filter::checkCsrf()) { |
104 | 104 | $this->module->setBlockSetting($block_id, 'piwik_enabled', Filter::postBool('piwik_enabled')); |
@@ -36,20 +36,20 @@ discard block |
||
36 | 36 | '<table> |
37 | 37 | <tr> |
38 | 38 | <td> |
39 | - <a href="pedigree.php?rootid=' . $indi->getXref() . '&ged=' . $tree->getNameUrl() . '"> |
|
40 | - <i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . ' |
|
39 | + <a href="pedigree.php?rootid=' . $indi->getXref().'&ged='.$tree->getNameUrl().'"> |
|
40 | + <i class="icon-pedigree"></i><br>' . I18N::translate('Default chart').' |
|
41 | 41 | </a> |
42 | 42 | </td> |
43 | 43 | <td> |
44 | - <a href="individual.php?pid=' . $indi->getXref() . '&ged=' . $tree->getNameUrl() . '"> |
|
45 | - <i class="icon-indis"></i><br>' . I18N::translate('Default individual') . ' |
|
44 | + <a href="individual.php?pid=' . $indi->getXref().'&ged='.$tree->getNameUrl().'"> |
|
45 | + <i class="icon-indis"></i><br>' . I18N::translate('Default individual').' |
|
46 | 46 | </a> |
47 | 47 | </td>'; |
48 | 48 | |
49 | 49 | if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) { |
50 | 50 | $content .= ' |
51 | 51 | <td> |
52 | - <a href="' . WT_LOGIN_URL . '?action=register"> |
|
52 | + <a href="' . WT_LOGIN_URL.'?action=register"> |
|
53 | 53 | <i class="icon-user_add"></i><br>'.I18N::translate('Request a new user account').' |
54 | 54 | </a> |
55 | 55 | </td>'; |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | </table>'; |
60 | 60 | |
61 | 61 | // Piwik Statistics |
62 | - if ($this->data->get('piwik_enabled', false)){ |
|
62 | + if ($this->data->get('piwik_enabled', false)) { |
|
63 | 63 | $content .= ' |
64 | 64 | <div class="center"> |
65 | 65 | <div id="piwik_stats"> |
66 | - <i class="icon-loading-small"></i> ' . I18N::translate('Retrieving Piwik statistics...') . ' |
|
66 | + <i class="icon-loading-small"></i> ' . I18N::translate('Retrieving Piwik statistics...').' |
|
67 | 67 | </div> |
68 | 68 | </div>'; |
69 | 69 | } |
70 | 70 | |
71 | - $content .= '<hr />'; |
|
71 | + $content .= '<hr />'; |
|
72 | 72 | |
73 | 73 | // Login section - based on login_block |
74 | 74 | if (Auth::check()) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | <div class="center"> |
77 | 77 | <form method="post" action="logout.php" name="logoutform" onsubmit="return true;"> |
78 | 78 | <br>' . |
79 | - I18N::translate('You are signed in as %s.', '<a href="edituser.php" class="name2">' . Auth::user()->getRealNameHtml() . '</a>') . |
|
79 | + I18N::translate('You are signed in as %s.', '<a href="edituser.php" class="name2">'.Auth::user()->getRealNameHtml().'</a>'). |
|
80 | 80 | '<br><br> |
81 | 81 | <input type="submit" value="'.I18N::translate('sign out').'"> |
82 | 82 | <br><br> |
@@ -98,34 +98,34 @@ discard block |
||
98 | 98 | </label> |
99 | 99 | </div> |
100 | 100 | <div> |
101 | - <input type="submit" value="'. I18N::translate('sign in'). '"> |
|
101 | + <input type="submit" value="'. I18N::translate('sign in').'"> |
|
102 | 102 | </div> |
103 | 103 | <div> |
104 | 104 | <a href="#" id="maj-passwd_click">'. I18N::translate('Request a new password').'</a> |
105 | 105 | </div>'; |
106 | 106 | if (Site::getPreference('USE_REGISTRATION_MODULE')) { |
107 | - $content.= ' |
|
107 | + $content .= ' |
|
108 | 108 | <div> |
109 | - <a href="'.WT_LOGIN_URL.'?action=register">'. I18N::translate('Request a new user account').'</a> |
|
109 | + <a href="'.WT_LOGIN_URL.'?action=register">'.I18N::translate('Request a new user account').'</a> |
|
110 | 110 | </div>'; |
111 | 111 | } |
112 | - $content.= ' |
|
112 | + $content .= ' |
|
113 | 113 | </form>'; // close "login-form" |
114 | 114 | |
115 | 115 | // hidden New Password block |
116 | - $content.= ' |
|
116 | + $content .= ' |
|
117 | 117 | <div id="maj-new_passwd"> |
118 | 118 | <form id="maj-new_passwd_form" name="new_passwd_form" action="'.WT_LOGIN_URL.'" method="post"> |
119 | 119 | <input type="hidden" name="time" value=""> |
120 | 120 | <input type="hidden" name="action" value="requestpw"> |
121 | 121 | <h4>'. I18N::translate('Lost password request').'</h4> |
122 | 122 | <div> |
123 | - <label for="maj-new_passwd_username">'. I18N::translate('Username or email address') . ' |
|
123 | + <label for="maj-new_passwd_username">'. I18N::translate('Username or email address').' |
|
124 | 124 | <input type="text" id="maj-new_passwd_username" name="new_passwd_username" value=""> |
125 | 125 | </label> |
126 | 126 | </div> |
127 | 127 | <div> |
128 | - <input type="submit" value="'. I18N::translate('Continue'). '"> |
|
128 | + <input type="submit" value="'. I18N::translate('Continue').'"> |
|
129 | 129 | </div> |
130 | 130 | </form> |
131 | 131 | </div> |