@@ -40,7 +40,7 @@ |
||
40 | 40 | <?php echo I18N::translate('In order to do so, use the following URL, with the optional parameter <em>%s</em> if you only want to force the execution of one task: ', 'task'); ?> |
41 | 41 | </p> |
42 | 42 | <p> |
43 | - <code><?php echo $this->data->get('trigger_url_root') .'&force=<span id="token_url">'. $this->data->get('trigger_token') .'</span>[&task='. I18N::translate('task_name').']'; ?></code> |
|
43 | + <code><?php echo $this->data->get('trigger_url_root').'&force=<span id="token_url">'.$this->data->get('trigger_token').'</span>[&task='.I18N::translate('task_name').']'; ?></code> |
|
44 | 44 | </p> |
45 | 45 | <p> |
46 | 46 | <button id="bt_genforcetoken" class="bt bt-primary" onClick="generate_force_token();"> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $user_id = Filter::postInteger('userid', -1) ?: Filter::getInteger('userid', -1); |
41 | 41 | return Auth::check() && |
42 | 42 | ( |
43 | - $user_id == Auth::user()->getUserId() || // Allow update for yourself |
|
43 | + $user_id == Auth::user()->getUserId() || // Allow update for yourself |
|
44 | 44 | ($user_id == -1 && Auth::isManager($WT_TREE)) // Allow a manager to update the default user |
45 | 45 | ); |
46 | 46 | } |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | protected function update(BaseController $controller) { |
55 | 55 | global $WT_TREE; |
56 | - if($this->canUpdate() && Filter::checkCsrf()) |
|
56 | + if ($this->canUpdate() && Filter::checkCsrf()) |
|
57 | 57 | { |
58 | 58 | $indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE); |
59 | 59 | $user = User::find(Filter::postInteger('userid', -1)); |
60 | 60 | |
61 | - if($user && $indi) { |
|
61 | + if ($user && $indi) { |
|
62 | 62 | $WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref()); |
63 | 63 | $controller->addInlineJavascript(' |
64 | 64 | $( document ).ready(function() { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | function majComputeSosa(user_id) { |
99 | 99 | jQuery("#bt_sosa_compute").prop( "disabled", true ); |
100 | - jQuery("#bt_sosa_computing").empty().html("<i class=\"icon-loading-small\"></i> '. I18N::translate('Computing...') .'"); |
|
100 | + jQuery("#bt_sosa_computing").empty().html("<i class=\"icon-loading-small\"></i> '. I18N::translate('Computing...').'"); |
|
101 | 101 | jQuery("#bt_sosa_computing").load( |
102 | 102 | "module.php?mod='.$this->module->getName().'&mod_action=SosaConfig@computeAll&ged='.$WT_TREE->getNameUrl().'&userid=" + user_id, |
103 | 103 | function() { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | }'); |
107 | 107 | |
108 | 108 | $action = Filter::post('action'); |
109 | - if($action === 'update') $this->update($controller); |
|
109 | + if ($action === 'update') $this->update($controller); |
|
110 | 110 | |
111 | 111 | $view_bag = new ViewBag(); |
112 | 112 | $view_bag->set('title', $controller->getPageTitle()); |
@@ -115,21 +115,21 @@ discard block |
||
115 | 115 | |
116 | 116 | $users_root = array(); |
117 | 117 | $users_js_array = 'var users_array = [];'; |
118 | - if(Auth::check()) { |
|
118 | + if (Auth::check()) { |
|
119 | 119 | $root_id = $WT_TREE->getUserPreference(Auth::user(), 'MAJ_SOSA_ROOT_ID'); |
120 | - $users_root[] = array( 'user' => Auth::user(), 'rootid' => $root_id); |
|
121 | - $users_js_array .= 'users_array["'.Auth::user()->getUserId().'"] = "' . $root_id . '";'; |
|
120 | + $users_root[] = array('user' => Auth::user(), 'rootid' => $root_id); |
|
121 | + $users_js_array .= 'users_array["'.Auth::user()->getUserId().'"] = "'.$root_id.'";'; |
|
122 | 122 | |
123 | - if(Auth::isManager($WT_TREE)) { |
|
123 | + if (Auth::isManager($WT_TREE)) { |
|
124 | 124 | $default_user = User::find(-1); |
125 | 125 | $default_root_id = $WT_TREE->getUserPreference($default_user, 'MAJ_SOSA_ROOT_ID'); |
126 | - $users_root[] = array( 'user' => $default_user, 'rootid' => $default_root_id); |
|
127 | - $users_js_array .= 'users_array["'.$default_user->getUserId().'"] = "' . $default_root_id . '";'; |
|
126 | + $users_root[] = array('user' => $default_user, 'rootid' => $default_root_id); |
|
127 | + $users_js_array .= 'users_array["'.$default_user->getUserId().'"] = "'.$default_root_id.'";'; |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | $view_bag->set('users_settings', $users_root); |
131 | 131 | |
132 | - $controller->addInlineJavascript($users_js_array . ' |
|
132 | + $controller->addInlineJavascript($users_js_array.' |
|
133 | 133 | $("#maj-sosa-config-select").change(function() { |
134 | 134 | $("#rootid").val(users_array[this.value]); |
135 | 135 | }); |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | $view_bag->set('is_success', false); |
152 | 152 | |
153 | 153 | $user = User::find(Filter::getInteger('userid', -1)); |
154 | - if($user) { |
|
154 | + if ($user) { |
|
155 | 155 | $calculator = new SosaCalculator($WT_TREE, $user); |
156 | - if($calculator->computeAll()) $view_bag->set('is_success', true); |
|
156 | + if ($calculator->computeAll()) $view_bag->set('is_success', true); |
|
157 | 157 | } |
158 | 158 | ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
159 | 159 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | $user = User::find(Filter::getInteger('userid', -1)); |
174 | 174 | $indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE); |
175 | 175 | |
176 | - if($user && $indi) { |
|
176 | + if ($user && $indi) { |
|
177 | 177 | $calculator = new SosaCalculator($WT_TREE, $user); |
178 | - if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
178 | + if ($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
179 | 179 | } |
180 | 180 | else { |
181 | 181 | $view_bag->set('error', I18N::translate('Non existing individual')); |
@@ -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 | $tmp_sosatable = array(); |
74 | 74 | $this->addNode($indi, 1); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $tmp_sosatable = array(); |
88 | 88 | $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
89 | 89 | $current_sosas = $dindi->getSosaNumbers(); |
90 | - foreach($current_sosas as $current_sosa => $gen) { |
|
90 | + foreach ($current_sosas as $current_sosa => $gen) { |
|
91 | 91 | $this->sosa_provider->deleteAncestors($current_sosa); |
92 | 92 | $this->addNode($indi, $current_sosa); |
93 | 93 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | |
114 | 114 | $this->flushTmpSosaTable(); |
115 | 115 | |
116 | - if($fam = $indi->getPrimaryChildFamily()) { |
|
117 | - if($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
118 | - if($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
116 | + if ($fam = $indi->getPrimaryChildFamily()) { |
|
117 | + if ($husb = $fam->getHusband()) $this->addNode($husb, 2 * $sosa); |
|
118 | + if ($wife = $fam->getWife()) $this->addNode($wife, 2 * $sosa + 1); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param bool $force Should the flush be forced |
126 | 126 | */ |
127 | 127 | protected function flushTmpSosaTable($force = false) { |
128 | - if( count($this->tmp_sosa_table)> 0 && |
|
129 | - ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)){ |
|
128 | + if (count($this->tmp_sosa_table) > 0 && |
|
129 | + ($force || count($this->tmp_sosa_table) >= self::TMP_SOSA_TABLE_LIMIT)) { |
|
130 | 130 | $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
131 | 131 | $this->tmp_sosa_table = array(); |
132 | 132 | } |
@@ -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(!$this->getRootIndi()) { |
|
98 | - if($this->user == self::$default_user) { // If the default user is not setup |
|
97 | + if (!$this->getRootIndi()) { |
|
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 { |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * Remove all Sosa entries related to the gedcom file and user |
130 | 130 | */ |
131 | 131 | public function deleteAll() { |
132 | - if(!$this->is_setup) return; |
|
132 | + if (!$this->is_setup) return; |
|
133 | 133 | Database::prepare( |
134 | 134 | 'DELETE FROM `##maj_sosa`'. |
135 | 135 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | * @param int $sosa |
146 | 146 | */ |
147 | 147 | public function deleteAncestors($sosa) { |
148 | - if(!$this->is_setup) return; |
|
148 | + if (!$this->is_setup) return; |
|
149 | 149 | $gen = Functions::getGeneration($sosa); |
150 | 150 | Database::prepare( |
151 | 151 | 'DELETE FROM `##maj_sosa`'. |
152 | - ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' . |
|
153 | - ' AND majs_gen >= :gen' . |
|
152 | + ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id'. |
|
153 | + ' AND majs_gen >= :gen'. |
|
154 | 154 | ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa' |
155 | 155 | )->execute(array( |
156 | 156 | 'tree_id' => $this->tree->getTreeId(), |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @param array $sosa_records |
166 | 166 | */ |
167 | 167 | public function insertOrUpdate($sosa_records) { |
168 | - if(!$this->is_setup) return; |
|
168 | + if (!$this->is_setup) return; |
|
169 | 169 | |
170 | 170 | $treeid = $this->tree->getTreeId(); |
171 | 171 | $userid = $this->user->getUserId(); |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | $values_table = array(); |
174 | 174 | |
175 | 175 | $i = 0; |
176 | - foreach ($sosa_records as $row) { |
|
176 | + foreach ($sosa_records as $row) { |
|
177 | 177 | $gen = Functions::getGeneration($row['sosa']); |
178 | - if($gen <= self::MAX_DB_GENERATIONS) { |
|
178 | + if ($gen <= self::MAX_DB_GENERATIONS) { |
|
179 | 179 | $questionmarks_table[] = |
180 | 180 | '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')'; |
181 | 181 | $values_table = array_merge( |
@@ -194,9 +194,9 @@ discard block |
||
194 | 194 | $i++; |
195 | 195 | } |
196 | 196 | |
197 | - $sql = 'REPLACE INTO `##maj_sosa`' . |
|
198 | - ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)' . |
|
199 | - ' VALUES '. implode(',', $questionmarks_table); |
|
197 | + $sql = 'REPLACE INTO `##maj_sosa`'. |
|
198 | + ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)'. |
|
199 | + ' VALUES '.implode(',', $questionmarks_table); |
|
200 | 200 | Database::prepare($sql)->execute($values_table); |
201 | 201 | } |
202 | 202 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @return array Array of sosa numbers |
213 | 213 | */ |
214 | 214 | public function getSosaNumbers(Individual $indi) { |
215 | - if(!$this->is_setup) return array(); |
|
215 | + if (!$this->is_setup) return array(); |
|
216 | 216 | return Database::prepare( |
217 | 217 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
218 | 218 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return number Last generation if found, 1 otherwise |
230 | 230 | */ |
231 | 231 | public function getLastGeneration() { |
232 | - if(!$this->is_setup) return; |
|
232 | + if (!$this->is_setup) return; |
|
233 | 233 | return Database::prepare( |
234 | 234 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
235 | 235 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | * @param int $ged_id ID of the gedcom file |
250 | 250 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
251 | 251 | */ |
252 | - public function getAllSosaWithGenerations(){ |
|
253 | - if(!$this->is_setup) return array(); |
|
252 | + public function getAllSosaWithGenerations() { |
|
253 | + if (!$this->is_setup) return array(); |
|
254 | 254 | return Database::prepare( |
255 | - 'SELECT majs_i_id AS indi,' . |
|
256 | - ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
|
257 | - ' FROM `##maj_sosa`' . |
|
258 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' . |
|
255 | + 'SELECT majs_i_id AS indi,'. |
|
256 | + ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations'. |
|
257 | + ' FROM `##maj_sosa`'. |
|
258 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
259 | 259 | ' GROUP BY majs_i_id' |
260 | 260 | )->execute(array( |
261 | 261 | 'tree_id' => $this->tree->getTreeId(), |
@@ -269,13 +269,13 @@ discard block |
||
269 | 269 | * @param number $gen Generation |
270 | 270 | * @return array Array of Sosa individuals |
271 | 271 | */ |
272 | - public function getSosaListAtGeneration($gen){ |
|
273 | - if(!$this->is_setup) return array(); |
|
274 | - if(!$this->sosa_list_by_gen) |
|
272 | + public function getSosaListAtGeneration($gen) { |
|
273 | + if (!$this->is_setup) return array(); |
|
274 | + if (!$this->sosa_list_by_gen) |
|
275 | 275 | $this->sosa_list_by_gen = array(); |
276 | 276 | |
277 | - if($gen){ |
|
278 | - if(!isset($this->sosa_list_by_gen[$gen])){ |
|
277 | + if ($gen) { |
|
278 | + if (!isset($this->sosa_list_by_gen[$gen])) { |
|
279 | 279 | $this->sosa_list_by_gen[$gen] = Database::prepare( |
280 | 280 | 'SELECT majs_sosa AS sosa, majs_i_id AS indi'. |
281 | 281 | ' FROM `##maj_sosa`'. |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | * @param number $gen Generation |
301 | 301 | * @return array Array of Sosa families |
302 | 302 | */ |
303 | - public function getFamilySosaListAtGeneration($gen){ |
|
304 | - if(!$this->is_setup) return array(); |
|
305 | - if(!$this->sosa_fam_list_by_gen) |
|
303 | + public function getFamilySosaListAtGeneration($gen) { |
|
304 | + if (!$this->is_setup) return array(); |
|
305 | + if (!$this->sosa_fam_list_by_gen) |
|
306 | 306 | $this->sosa_fam_list_by_gen = array(); |
307 | 307 | |
308 | - if($gen){ |
|
309 | - if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
|
308 | + if ($gen) { |
|
309 | + if (!isset($this->sosa_fam_list_by_gen[$gen])) { |
|
310 | 310 | $this->sosa_fam_list_by_gen[$gen] = Database::prepare( |
311 | 311 | 'SELECT s1.majs_sosa AS sosa, f_id AS fam'. |
312 | 312 | ' FROM `##families`'. |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * @param number $gen Generation |
337 | 337 | * @return array Array of Sosa individuals |
338 | 338 | */ |
339 | - public function getMissingSosaListAtGeneration($gen){ |
|
340 | - if(!$this->is_setup) return array(); |
|
341 | - if($gen){ |
|
339 | + public function getMissingSosaListAtGeneration($gen) { |
|
340 | + if (!$this->is_setup) return array(); |
|
341 | + if ($gen) { |
|
342 | 342 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
343 | 343 | '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'. |
344 | 344 | ' FROM `##maj_sosa` schild'. |
@@ -375,10 +375,10 @@ discard block |
||
375 | 375 | * @return array Statistics array |
376 | 376 | */ |
377 | 377 | public function getStatisticsByGeneration() { |
378 | - if(!$this->is_setup) return array(); |
|
379 | - if(!$this->statistics_tab) { |
|
378 | + if (!$this->is_setup) return array(); |
|
379 | + if (!$this->statistics_tab) { |
|
380 | 380 | $this->statistics_tab = array(); |
381 | - if($maxGeneration = $this->getLastGeneration()) { |
|
381 | + if ($maxGeneration = $this->getLastGeneration()) { |
|
382 | 382 | for ($gen = 1; $gen <= $maxGeneration; $gen++) { |
383 | 383 | $birthStats = $this->getStatsBirthYearInGeneration($gen); |
384 | 384 | $this->statistics_tab[$gen] = array( |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | * @return int |
402 | 402 | */ |
403 | 403 | public function getTotalIndividuals() { |
404 | - if(!$this->is_setup) return 0; |
|
404 | + if (!$this->is_setup) return 0; |
|
405 | 405 | return Database::prepare( |
406 | - 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' . |
|
406 | + 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`'. |
|
407 | 407 | ' WHERE i_file = :tree_id') |
408 | 408 | ->execute(array('tree_id' => $this->tree->getTreeId())) |
409 | 409 | ->fetchOne() ?: 0; |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return number Number of Sosas |
416 | 416 | */ |
417 | - public function getSosaCount(){ |
|
418 | - if(!$this->is_setup) return 0; |
|
417 | + public function getSosaCount() { |
|
418 | + if (!$this->is_setup) return 0; |
|
419 | 419 | return Database::prepare( |
420 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
420 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
421 | 421 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
422 | 422 | ->execute(array( |
423 | 423 | 'tree_id' => $this->tree->getTreeId(), |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | * @param number $gen Generation |
432 | 432 | * @return number Number of Sosas in generation |
433 | 433 | */ |
434 | - public function getSosaCountAtGeneration($gen){ |
|
435 | - if(!$this->is_setup) return 0; |
|
434 | + public function getSosaCountAtGeneration($gen) { |
|
435 | + if (!$this->is_setup) return 0; |
|
436 | 436 | return Database::prepare( |
437 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
437 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
438 | 438 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
439 | 439 | ' AND majs_gen= :gen') |
440 | 440 | ->execute(array( |
@@ -450,10 +450,10 @@ discard block |
||
450 | 450 | * @param number $gen Generation |
451 | 451 | * @return number Total number of Sosas up to generation |
452 | 452 | */ |
453 | - public function getSosaCountUpToGeneration($gen){ |
|
454 | - if(!$this->is_setup) return 0; |
|
453 | + public function getSosaCountUpToGeneration($gen) { |
|
454 | + if (!$this->is_setup) return 0; |
|
455 | 455 | return Database::prepare( |
456 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
456 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
457 | 457 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
458 | 458 | ' AND majs_gen <= :gen') |
459 | 459 | ->execute(array( |
@@ -468,10 +468,10 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return number Total number of distinct individual |
470 | 470 | */ |
471 | - public function getDifferentSosaCount(){ |
|
472 | - if(!$this->is_setup) return 0; |
|
471 | + public function getDifferentSosaCount() { |
|
472 | + if (!$this->is_setup) return 0; |
|
473 | 473 | return Database::prepare( |
474 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
474 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
475 | 475 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
476 | 476 | ->execute(array( |
477 | 477 | 'tree_id' => $this->tree->getTreeId(), |
@@ -485,10 +485,10 @@ discard block |
||
485 | 485 | * @param number $gen Generation |
486 | 486 | * @return number Number of distinct Sosa individuals up to generation |
487 | 487 | */ |
488 | - public function getDifferentSosaCountUpToGeneration($gen){ |
|
489 | - if(!$this->is_setup) return 0; |
|
488 | + public function getDifferentSosaCountUpToGeneration($gen) { |
|
489 | + if (!$this->is_setup) return 0; |
|
490 | 490 | return Database::prepare( |
491 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
491 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
492 | 492 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
493 | 493 | ' AND majs_gen <= :gen') |
494 | 494 | ->execute(array( |
@@ -508,11 +508,11 @@ discard block |
||
508 | 508 | * @param number $gen Generation |
509 | 509 | * @return array Birth statistics array |
510 | 510 | */ |
511 | - public function getStatsBirthYearInGeneration($gen){ |
|
512 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
511 | + public function getStatsBirthYearInGeneration($gen) { |
|
512 | + if (!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
513 | 513 | return Database::prepare( |
514 | 514 | 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
515 | - ' FROM `##maj_sosa`' . |
|
515 | + ' FROM `##maj_sosa`'. |
|
516 | 516 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
517 | 517 | ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year') |
518 | 518 | ->execute(array( |
@@ -528,26 +528,26 @@ discard block |
||
528 | 528 | * |
529 | 529 | * @return number|NULL Mean generation time |
530 | 530 | */ |
531 | - public function getMeanGenerationTime(){ |
|
532 | - if(!$this->is_setup) return; |
|
533 | - if(!$this->statistics_tab){ |
|
531 | + public function getMeanGenerationTime() { |
|
532 | + if (!$this->is_setup) return; |
|
533 | + if (!$this->statistics_tab) { |
|
534 | 534 | $this->getStatisticsByGeneration(); |
535 | 535 | } |
536 | 536 | //Linear regression on x=generation and y=birthdate |
537 | 537 | $sum_xy = 0; |
538 | - $sum_x=0; |
|
539 | - $sum_y=0; |
|
540 | - $sum_x2=0; |
|
541 | - $n=count($this->statistics_tab); |
|
542 | - foreach($this->statistics_tab as $gen=>$stats){ |
|
543 | - $sum_xy+=$gen*$stats['avgBirth']; |
|
544 | - $sum_x+=$gen; |
|
545 | - $sum_y+=$stats['avgBirth']; |
|
546 | - $sum_x2+=$gen*$gen; |
|
538 | + $sum_x = 0; |
|
539 | + $sum_y = 0; |
|
540 | + $sum_x2 = 0; |
|
541 | + $n = count($this->statistics_tab); |
|
542 | + foreach ($this->statistics_tab as $gen=>$stats) { |
|
543 | + $sum_xy += $gen * $stats['avgBirth']; |
|
544 | + $sum_x += $gen; |
|
545 | + $sum_y += $stats['avgBirth']; |
|
546 | + $sum_x2 += $gen * $gen; |
|
547 | 547 | } |
548 | - $denom=($n*$sum_x2)-($sum_x*$sum_x); |
|
549 | - if($denom!=0){ |
|
550 | - return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom); |
|
548 | + $denom = ($n * $sum_x2) - ($sum_x * $sum_x); |
|
549 | + if ($denom != 0) { |
|
550 | + return -(($n * $sum_xy) - ($sum_x * $sum_y)) / ($denom); |
|
551 | 551 | } |
552 | 552 | return null; |
553 | 553 | } |
@@ -575,14 +575,14 @@ discard block |
||
575 | 575 | * @return array |
576 | 576 | */ |
577 | 577 | public function getAncestorDispersionForGen($gen) { |
578 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
578 | + if (!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
579 | 579 | return Database::prepare( |
580 | 580 | 'SELECT branches, count(i_id)'. |
581 | 581 | ' FROM ('. |
582 | 582 | ' SELECT i_id,'. |
583 | 583 | ' CASE'. |
584 | 584 | ' WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'. |
585 | - ' ELSE -1'. // We put all ancestors shared between some branches in the same bucket |
|
585 | + ' ELSE -1'.// We put all ancestors shared between some branches in the same bucket |
|
586 | 586 | ' END branches'. |
587 | 587 | ' FROM ('. |
588 | 588 | ' SELECT DISTINCT majs_i_id i_id,'. |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->view_bag = new ViewBag(); |
70 | 70 | $this->view_bag->set('generation', $this->generation); |
71 | 71 | $this->view_bag->set('max_gen', $this->sosa_provider->getLastGeneration()); |
72 | - $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0)> 0); |
|
72 | + $this->view_bag->set('is_setup', $this->sosa_provider->isSetup() && $this->view_bag->get('max_gen', 0) > 0); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -90,14 +90,14 @@ discard block |
||
90 | 90 | |
91 | 91 | $this->view_bag->set('title', $controller->getPageTitle()); |
92 | 92 | |
93 | - if($this->view_bag->get('is_setup', false)) { |
|
93 | + if ($this->view_bag->get('is_setup', false)) { |
|
94 | 94 | $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
95 | 95 | $this->view_bag->set('url_module', $this->module->getName()); |
96 | 96 | $this->view_bag->set('url_action', 'SosaList'); |
97 | 97 | $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
98 | 98 | $this->view_bag->set('min_gen', 1); |
99 | 99 | |
100 | - if($this->view_bag->get('has_sosa', false)) { |
|
100 | + if ($this->view_bag->get('has_sosa', false)) { |
|
101 | 101 | $controller->addInlineJavascript(' |
102 | 102 | jQuery("#sosalist-tabs").tabs(); |
103 | 103 | jQuery("#sosalist-tabs").css("visibility", "visible"); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | "mod" : "'.$this->module->getName().'", |
109 | 109 | "mod_action": "SosaList@sosalist", |
110 | - "ged" : "' . $WT_TREE->getNameUrl(). '", |
|
110 | + "ged" : "' . $WT_TREE->getNameUrl().'", |
|
111 | 111 | "type" : "indi", |
112 | 112 | "gen" : "'.$this->generation.'" |
113 | 113 | }, |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | { |
133 | 133 | "mod" : "'.$this->module->getName().'", |
134 | 134 | "mod_action": "SosaList@sosalist", |
135 | - "ged" : "' . $WT_TREE->getNameUrl(). '", |
|
135 | + "ged" : "' . $WT_TREE->getNameUrl().'", |
|
136 | 136 | "type" : "fam", |
137 | 137 | "gen" : "'.$this->generation.'" |
138 | 138 | }, |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $this->view_bag->set('title', $controller->getPageTitle()); |
173 | 173 | |
174 | - if($this->view_bag->get('is_setup', false)) { |
|
174 | + if ($this->view_bag->get('is_setup', false)) { |
|
175 | 175 | $this->view_bag->set('url_module', $this->module->getName()); |
176 | 176 | $this->view_bag->set('url_action', 'SosaList@missing'); |
177 | 177 | $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
181 | 181 | $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
182 | 182 | |
183 | - $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
183 | + $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation - 1)); |
|
184 | 184 | $this->view_bag->set('perc_sosa', $perc_sosa); |
185 | 185 | |
186 | - if($this->view_bag->get('has_missing', false)) { |
|
187 | - $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
186 | + if ($this->view_bag->get('has_missing', false)) { |
|
187 | + $table_id = 'table-sosa-missing-'.Uuid::uuid4(); |
|
188 | 188 | $this->view_bag->set('table_id', $table_id); |
189 | 189 | |
190 | 190 | $controller |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
198 | 198 | |
199 | 199 | jQuery("#'.$table_id.'").dataTable( { |
200 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
200 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
201 | 201 | '.I18N::datatablesI18N().', |
202 | 202 | jQueryUI: true, |
203 | 203 | autoWidth:false, |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | pagingType: "full_numbers" |
229 | 229 | }); |
230 | 230 | |
231 | - jQuery("#' . $table_id . '") |
|
231 | + jQuery("#' . $table_id.'") |
|
232 | 232 | /* Filter buttons in table header */ |
233 | 233 | .on("click", "button[data-filter-column]", function() { |
234 | 234 | var btn = jQuery(this); |
235 | 235 | // De-activate the other buttons in this button group |
236 | 236 | btn.siblings().removeClass("ui-state-active"); |
237 | 237 | // Apply (or clear) this filter |
238 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
238 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
239 | 239 | if (btn.hasClass("ui-state-active")) { |
240 | 240 | btn.removeClass("ui-state-active"); |
241 | 241 | col.search("").draw(); |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | $unique_indis = array(); |
254 | 254 | $sum_missing_different = 0; |
255 | 255 | $sum_missing_different_without_hidden = 0; |
256 | - foreach($missing_list as $num => $missing_tab) { |
|
257 | - if(isset($unique_indis[$missing_tab['indi']])) { |
|
256 | + foreach ($missing_list as $num => $missing_tab) { |
|
257 | + if (isset($unique_indis[$missing_tab['indi']])) { |
|
258 | 258 | unset($missing_list[$num]); |
259 | 259 | continue; |
260 | 260 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $this->view_bag->set('missing_list', $missing_list); |
273 | 273 | $this->view_bag->set('missing_diff_count', $sum_missing_different); |
274 | 274 | $this->view_bag->set('missing_hidden', $sum_missing_different - $sum_missing_different_without_hidden); |
275 | - $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation-2)); |
|
275 | + $perc_sosa_potential = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation - 1), pow(2, $this->generation - 2)); |
|
276 | 276 | $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential); |
277 | 277 | } |
278 | 278 | } |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $controller = new AjaxController(); |
291 | 291 | $controller->restrictAccess($this->generation > 0 || !is_null($type)); |
292 | 292 | |
293 | - switch ($type){ |
|
293 | + switch ($type) { |
|
294 | 294 | case 'indi': |
295 | 295 | $this->renderSosaListIndi($controller); |
296 | 296 | break; |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); |
314 | 314 | $this->view_bag->set('has_sosa', false); |
315 | 315 | |
316 | - if(count($listSosa) > 0) { |
|
316 | + if (count($listSosa) > 0) { |
|
317 | 317 | $this->view_bag->set('has_sosa', true); |
318 | - $table_id = 'table-sosa-indi-' . Uuid::uuid4(); |
|
318 | + $table_id = 'table-sosa-indi-'.Uuid::uuid4(); |
|
319 | 319 | $this->view_bag->set('table_id', $table_id); |
320 | 320 | |
321 | 321 | $controller |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
328 | 328 | |
329 | 329 | jQuery("#'.$table_id.'").dataTable( { |
330 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
331 | - ' . I18N::datatablesI18N() . ', |
|
330 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
331 | + ' . I18N::datatablesI18N().', |
|
332 | 332 | jQueryUI: true, |
333 | 333 | autoWidth: false, |
334 | 334 | processing: true, |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | pagingType: "full_numbers" |
365 | 365 | }); |
366 | 366 | |
367 | - jQuery("#' . $table_id . '") |
|
367 | + jQuery("#' . $table_id.'") |
|
368 | 368 | /* Hide/show parents */ |
369 | 369 | .on("click", ".btn-toggle-parents", function() { |
370 | 370 | jQuery(this).toggleClass("ui-state-active"); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | /* Hide/show statistics */ |
374 | 374 | .on("click", ".btn-toggle-statistics", function() { |
375 | 375 | jQuery(this).toggleClass("ui-state-active"); |
376 | - jQuery("#indi_list_table-charts_' . $table_id . '").slideToggle(); |
|
376 | + jQuery("#indi_list_table-charts_' . $table_id.'").slideToggle(); |
|
377 | 377 | }) |
378 | 378 | /* Filter buttons in table header */ |
379 | 379 | .on("click", "button[data-filter-column]", function() { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | // De-activate the other buttons in this button group |
382 | 382 | btn.siblings().removeClass("ui-state-active"); |
383 | 383 | // Apply (or clear) this filter |
384 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
384 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
385 | 385 | if (btn.hasClass("ui-state-active")) { |
386 | 386 | btn.removeClass("ui-state-active"); |
387 | 387 | col.search("").draw(); |
@@ -416,24 +416,24 @@ discard block |
||
416 | 416 | $nb_displayed = 0; |
417 | 417 | |
418 | 418 | Individual::load($WT_TREE, $listSosa); |
419 | - foreach($listSosa as $sosa => $pid) { |
|
419 | + foreach ($listSosa as $sosa => $pid) { |
|
420 | 420 | $person = Individual::getInstance($pid, $WT_TREE); |
421 | 421 | if (!$person || !$person->canShowName()) { |
422 | 422 | unset($listSosa[$sosa]); |
423 | 423 | continue; |
424 | 424 | } |
425 | 425 | $nb_displayed++; |
426 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
426 | + if ($birth_dates = $person->getAllBirthDates()) { |
|
427 | 427 | if ( |
428 | - $birth_dates[0]->gregorianYear()>=1550 && |
|
429 | - $birth_dates[0]->gregorianYear()<2030 && |
|
428 | + $birth_dates[0]->gregorianYear() >= 1550 && |
|
429 | + $birth_dates[0]->gregorianYear() < 2030 && |
|
430 | 430 | !isset($unique_indis[$person->getXref()]) |
431 | 431 | ) { |
432 | - $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
432 | + $birt_by_decade[(int)($birth_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
433 | 433 | } |
434 | 434 | } |
435 | 435 | else { |
436 | - $birth_dates[0]=new Date(''); |
|
436 | + $birth_dates[0] = new Date(''); |
|
437 | 437 | } |
438 | 438 | if ($death_dates = $person->getAllDeathDates()) { |
439 | 439 | if ( |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | $death_dates[0]->gregorianYear() < 2030 && |
442 | 442 | !isset($unique_indis[$person->getXref()]) |
443 | 443 | ) { |
444 | - $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
444 | + $deat_by_decade[(int)($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
445 | 445 | } |
446 | 446 | } |
447 | 447 | else { |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $this->view_bag->set('sosa_list', $listSosa); |
458 | 458 | |
459 | 459 | $this->view_bag->set('sosa_count', count($listSosa)); |
460 | - $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
460 | + $this->view_bag->set('sosa_theo', pow(2, $this->generation - 1)); |
|
461 | 461 | $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
462 | 462 | |
463 | 463 | $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
@@ -477,12 +477,12 @@ discard block |
||
477 | 477 | protected function renderFamSosaListIndi(AjaxController $controller) { |
478 | 478 | global $WT_TREE; |
479 | 479 | |
480 | - $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
480 | + $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation); ; |
|
481 | 481 | $this->view_bag->set('has_sosa', false); |
482 | 482 | |
483 | - if(count($listFamSosa) > 0) { |
|
483 | + if (count($listFamSosa) > 0) { |
|
484 | 484 | $this->view_bag->set('has_sosa', true); |
485 | - $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
485 | + $table_id = 'table-sosa-fam-'.Uuid::uuid4(); |
|
486 | 486 | $this->view_bag->set('table_id', $table_id); |
487 | 487 | |
488 | 488 | $controller |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | jQuery.fn.dataTableExt.oSort["num-html-desc"]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a>b) ? -1 : (a<b ? 1 : 0);}; |
495 | 495 | |
496 | 496 | jQuery("#'.$table_id.'").dataTable( { |
497 | - dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
497 | + dom: \'<"H"<"filtersH_' . $table_id.'"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
498 | 498 | '.I18N::datatablesI18N(array(16, 32, 64, 128, -1)).', |
499 | 499 | jQueryUI: true, |
500 | 500 | autoWidth: false, |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | pagingType: "full_numbers" |
532 | 532 | }); |
533 | 533 | |
534 | - jQuery("#' . $table_id . '") |
|
534 | + jQuery("#' . $table_id.'") |
|
535 | 535 | /* Hide/show parents */ |
536 | 536 | .on("click", ".btn-toggle-parents", function() { |
537 | 537 | jQuery(this).toggleClass("ui-state-active"); |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | /* Hide/show statistics */ |
541 | 541 | .on("click", ".btn-toggle-statistics", function() { |
542 | 542 | jQuery(this).toggleClass("ui-state-active"); |
543 | - jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle(); |
|
543 | + jQuery("#fam_list_table-charts_' . $table_id.'").slideToggle(); |
|
544 | 544 | }) |
545 | 545 | /* Filter buttons in table header */ |
546 | 546 | .on("click", "button[data-filter-column]", function() { |
@@ -548,7 +548,7 @@ discard block |
||
548 | 548 | // De-activate the other buttons in this button group |
549 | 549 | btn.siblings().removeClass("ui-state-active"); |
550 | 550 | // Apply (or clear) this filter |
551 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
551 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
552 | 552 | if (btn.hasClass("ui-state-active")) { |
553 | 553 | btn.removeClass("ui-state-active"); |
554 | 554 | col.search("").draw(); |
@@ -568,29 +568,29 @@ discard block |
||
568 | 568 | |
569 | 569 | //-- init chart data |
570 | 570 | $marr_by_age = array(); |
571 | - for ($age=0; $age<=$max_age; $age++) { |
|
571 | + for ($age = 0; $age <= $max_age; $age++) { |
|
572 | 572 | $marr_by_age[$age] = ''; |
573 | 573 | } |
574 | 574 | $birt_by_decade = array(); |
575 | 575 | $marr_by_decade = array(); |
576 | - for ($year=1550; $year<2030; $year+=10) { |
|
576 | + for ($year = 1550; $year < 2030; $year += 10) { |
|
577 | 577 | $birt_by_decade[$year] = ''; |
578 | 578 | $marr_by_decade[$year] = ''; |
579 | 579 | } |
580 | 580 | |
581 | - foreach($listFamSosa as $sosa => $fid) { |
|
581 | + foreach ($listFamSosa as $sosa => $fid) { |
|
582 | 582 | $sfamily = Family::getInstance($fid, $WT_TREE); |
583 | - if(!$sfamily || !$sfamily->canShow()) { |
|
583 | + if (!$sfamily || !$sfamily->canShow()) { |
|
584 | 584 | unset($sfamily[$sosa]); |
585 | 585 | continue; |
586 | 586 | } |
587 | - $mdate=$sfamily->getMarriageDate(); |
|
587 | + $mdate = $sfamily->getMarriageDate(); |
|
588 | 588 | |
589 | - if( ($husb = $sfamily->getHusband()) && |
|
589 | + if (($husb = $sfamily->getHusband()) && |
|
590 | 590 | ($hdate = $husb->getBirthDate()) && |
591 | 591 | $hdate->isOK() && $mdate->isOK()) { |
592 | 592 | if ($hdate->gregorianYear() >= 1550 && $hdate->gregorianYear() < 2030) { |
593 | - $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
593 | + $birt_by_decade[(int)($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
594 | 594 | } |
595 | 595 | $hage = Date::getAge($hdate, $mdate, 0); |
596 | 596 | if ($hage >= 0 && $hage <= $max_age) { |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | } |
599 | 599 | } |
600 | 600 | |
601 | - if(($wife = $sfamily->getWife()) && |
|
602 | - ($wdate=$wife->getBirthDate()) && |
|
601 | + if (($wife = $sfamily->getWife()) && |
|
602 | + ($wdate = $wife->getBirthDate()) && |
|
603 | 603 | $wdate->isOK() && $mdate->isOK()) { |
604 | 604 | if ($wdate->gregorianYear() >= 1550 && $wdate->gregorianYear() < 2030) { |
605 | - $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
605 | + $birt_by_decade[(int)($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
606 | 606 | } |
607 | 607 | $wage = Date::getAge($wdate, $mdate, 0); |
608 | 608 | if ($wage >= 0 && $wage <= $max_age) { |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | } |
612 | 612 | |
613 | 613 | if ($mdate->isOK() && $mdate->gregorianYear() >= 1550 && $mdate->gregorianYear() < 2030 && $husb && $wife) { |
614 | - $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
614 | + $marr_by_decade[(int)($mdate->gregorianYear() / 10) * 10] .= $husb->getSex().$wife->getSex(); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | $listFamSosa[$sosa] = $sfamily; |
@@ -22,17 +22,17 @@ |
||
22 | 22 | public function upgrade() { |
23 | 23 | |
24 | 24 | Database::exec( |
25 | - 'CREATE TABLE IF NOT EXISTS `##maj_sosa` (' . |
|
26 | - ' majs_gedcom_id INTEGER NOT NULL,' . |
|
27 | - ' majs_user_id INTEGER NOT NULL DEFAULT -1,' . |
|
28 | - ' majs_sosa BIGINT UNSIGNED NOT NULL,' . // Allow to calculate sosa on 64 generations |
|
29 | - ' majs_i_id VARCHAR(20) NOT NULL,' . |
|
30 | - ' majs_gen TINYINT NULL,' . |
|
31 | - ' majs_birth_year SMALLINT NULL,' . |
|
32 | - ' majs_death_year SMALLINT NULL,' . |
|
33 | - ' PRIMARY KEY (majs_gedcom_id, majs_user_id, majs_sosa),' . |
|
34 | - ' FOREIGN KEY `##gedcom_id_fk1` (majs_gedcom_id) REFERENCES `##gedcom` (gedcom_id) ON DELETE CASCADE,' . |
|
35 | - ' FOREIGN KEY `##user_id_fk1` (majs_user_id) REFERENCES `##user` (user_id) ON DELETE CASCADE' . |
|
25 | + 'CREATE TABLE IF NOT EXISTS `##maj_sosa` ('. |
|
26 | + ' majs_gedcom_id INTEGER NOT NULL,'. |
|
27 | + ' majs_user_id INTEGER NOT NULL DEFAULT -1,'. |
|
28 | + ' majs_sosa BIGINT UNSIGNED NOT NULL,'.// Allow to calculate sosa on 64 generations |
|
29 | + ' majs_i_id VARCHAR(20) NOT NULL,'. |
|
30 | + ' majs_gen TINYINT NULL,'. |
|
31 | + ' majs_birth_year SMALLINT NULL,'. |
|
32 | + ' majs_death_year SMALLINT NULL,'. |
|
33 | + ' PRIMARY KEY (majs_gedcom_id, majs_user_id, majs_sosa),'. |
|
34 | + ' FOREIGN KEY `##gedcom_id_fk1` (majs_gedcom_id) REFERENCES `##gedcom` (gedcom_id) ON DELETE CASCADE,'. |
|
35 | + ' FOREIGN KEY `##user_id_fk1` (majs_user_id) REFERENCES `##user` (user_id) ON DELETE CASCADE'. |
|
36 | 36 | ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
37 | 37 | ); |
38 | 38 | } |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | <div id="maj-sosa-list-page" class="center"> |
29 | 29 | <h2><?php echo $this->data->get('title'); ?></h2> |
30 | 30 | |
31 | - <?php if($this->data->get('is_setup')) { |
|
31 | + <?php if ($this->data->get('is_setup')) { |
|
32 | 32 | $selectedgen = $this->data->get('generation'); |
33 | 33 | $this->renderSosaHeader(); |
34 | - if($this->data->get('has_sosa') ) { |
|
35 | - if($selectedgen > 0) { |
|
34 | + if ($this->data->get('has_sosa')) { |
|
35 | + if ($selectedgen > 0) { |
|
36 | 36 | ?> |
37 | 37 | <div id="sosalist-tabs"> |
38 | 38 | <ul> |
@@ -75,9 +75,9 @@ discard block |
||
75 | 75 | ?> |
76 | 76 | |
77 | 77 | <form method="get" name="setgen" action="module.php"> |
78 | - <input type="hidden" name="mod" value="<?php echo $this->data->get('url_module');?>"> |
|
79 | - <input type="hidden" name="mod_action" value="<?php echo $this->data->get('url_action');?>"> |
|
80 | - <input type="hidden" name="ged" value="<?php echo $this->data->get('url_ged');?>"> |
|
78 | + <input type="hidden" name="mod" value="<?php echo $this->data->get('url_module'); ?>"> |
|
79 | + <input type="hidden" name="mod_action" value="<?php echo $this->data->get('url_action'); ?>"> |
|
80 | + <input type="hidden" name="ged" value="<?php echo $this->data->get('url_ged'); ?>"> |
|
81 | 81 | <div class="maj-table"> |
82 | 82 | <div class="maj-row"> |
83 | 83 | <div class="label"><?php echo I18N::translate('Choose generation') ?></div> |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | <div class="maj-row"> |
86 | 86 | <div class="value"> |
87 | 87 | <select name="gen"> |
88 | - <?php for($i=$this->data->get('min_gen'); $i <= $max_gen;$i++) {?> |
|
88 | + <?php for ($i = $this->data->get('min_gen'); $i <= $max_gen; $i++) {?> |
|
89 | 89 | <option value="<?php echo $i; ?>" |
90 | - <?php if($selectedgen && $selectedgen==$i) { ?> selected="true" <?php } ?> |
|
90 | + <?php if ($selectedgen && $selectedgen == $i) { ?> selected="true" <?php } ?> |
|
91 | 91 | ><?php echo I18N::translate('Generation %d', $i); ?> |
92 | 92 | </option> |
93 | 93 | <?php } ?> |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | </div> |
96 | 96 | </div> |
97 | 97 | </div> |
98 | - <input type="submit" value="<?php echo I18N::translate('Show');?>" /> |
|
98 | + <input type="submit" value="<?php echo I18N::translate('Show'); ?>" /> |
|
99 | 99 | <br /> |
100 | 100 | </form> |
101 | - <?php if($selectedgen > 0) { ?> |
|
101 | + <?php if ($selectedgen > 0) { ?> |
|
102 | 102 | <h4> |
103 | - <?php if($selectedgen > $this->data->get('min_gen')) { ?> |
|
104 | - <a href="module.php?mod=<?php echo $this->data->get('url_module');?>&mod_action=<?php echo $this->data->get('url_action');?>&ged=<?php echo $this->data->get('url_ged');?>&gen=<?php echo $selectedgen-1; ?>"> |
|
103 | + <?php if ($selectedgen > $this->data->get('min_gen')) { ?> |
|
104 | + <a href="module.php?mod=<?php echo $this->data->get('url_module'); ?>&mod_action=<?php echo $this->data->get('url_action'); ?>&ged=<?php echo $this->data->get('url_ged'); ?>&gen=<?php echo $selectedgen - 1; ?>"> |
|
105 | 105 | <i class="icon-ldarrow" title="<?php echo I18N::translate('Previous generation'); ?>" ></i> |
106 | 106 | </a> |
107 | 107 | |
108 | 108 | <?php } ?> |
109 | 109 | <?php echo I18N::translate('Generation %d', $selectedgen); ?> |
110 | - <?php if($selectedgen < $max_gen) { ?> |
|
110 | + <?php if ($selectedgen < $max_gen) { ?> |
|
111 | 111 | |
112 | - <a href="module.php?mod=<?php echo $this->data->get('url_module');?>&mod_action=<?php echo $this->data->get('url_action');?>&ged=<?php echo $this->data->get('url_ged');?>&gen=<?php echo $selectedgen+1; ?>"> |
|
112 | + <a href="module.php?mod=<?php echo $this->data->get('url_module'); ?>&mod_action=<?php echo $this->data->get('url_action'); ?>&ged=<?php echo $this->data->get('url_ged'); ?>&gen=<?php echo $selectedgen + 1; ?>"> |
|
113 | 113 | <i class="icon-rdarrow" title="<?php echo I18N::translate('Next generation'); ?>" ></i> |
114 | 114 | </a> |
115 | 115 | <?php } ?> |
@@ -48,13 +48,13 @@ |
||
48 | 48 | <div class="value"> |
49 | 49 | <?php |
50 | 50 | $users = $this->data->get('users_settings'); |
51 | - if(count($users) == 1) { |
|
51 | + if (count($users) == 1) { |
|
52 | 52 | ?> |
53 | 53 | <label> |
54 | 54 | <input id="maj_sosa_input_userid" type="hidden" name="userid" value="<?php echo $users[0]['user']->getUserId(); ?>" /> |
55 | 55 | <?php echo $users[0]['user']->getRealNameHtml() ?> |
56 | 56 | </label> |
57 | - <?php } else if(count($users) > 1) { ?> |
|
57 | + <?php } else if (count($users) > 1) { ?> |
|
58 | 58 | <select id='maj-sosa-config-select' name="userid"> |
59 | 59 | <?php |
60 | 60 | $root_indi = $users[0]['rootid']; |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | */ |
34 | 34 | protected function renderContent() { |
35 | 35 | |
36 | - if($this->data->get('has_sosa', false)) { |
|
36 | + if ($this->data->get('has_sosa', false)) { |
|
37 | 37 | $table_id = $this->data->get('table_id'); |
38 | 38 | ?> |
39 | 39 | |
40 | 40 | <div id="sosa-indi-list" class="sosa-list"> |
41 | - <table id="<?php echo $table_id;?>"> |
|
41 | + <table id="<?php echo $table_id; ?>"> |
|
42 | 42 | <thead> |
43 | 43 | <tr> |
44 | 44 | <th colspan="22"> |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | </thead> |
186 | 186 | <tbody> |
187 | 187 | |
188 | - <?php foreach($this->data->get('sosa_list') as $sosa => $person) { |
|
188 | + <?php foreach ($this->data->get('sosa_list') as $sosa => $person) { |
|
189 | 189 | /** @var \Fisharebest\Webtrees\Individual $person */ |
190 | 190 | if ($person->isPendingAddtion()) { |
191 | 191 | $class = ' class="new"'; |
@@ -201,18 +201,18 @@ discard block |
||
201 | 201 | <td class="transparent"><?php echo $person->getXref(); ?></td> |
202 | 202 | <td colspan="2"> |
203 | 203 | <?php foreach ($person->getAllNames() as $num=>$name) { |
204 | - if ($name['type']=='NAME') { |
|
205 | - $title=''; |
|
204 | + if ($name['type'] == 'NAME') { |
|
205 | + $title = ''; |
|
206 | 206 | } else { |
207 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
207 | + $title = 'title="'.strip_tags(GedcomTag::getLabel($name['type'], $person)).'"'; |
|
208 | 208 | } |
209 | - if ($num==$person->getPrimaryName()) { |
|
210 | - $class=' class="name2"'; |
|
211 | - $sex_image=$person->getSexImage(); |
|
212 | - list($surn, $givn)=explode(',', $name['sort']); |
|
209 | + if ($num == $person->getPrimaryName()) { |
|
210 | + $class = ' class="name2"'; |
|
211 | + $sex_image = $person->getSexImage(); |
|
212 | + list($surn, $givn) = explode(',', $name['sort']); |
|
213 | 213 | } else { |
214 | - $class=''; |
|
215 | - $sex_image=''; |
|
214 | + $class = ''; |
|
215 | + $sex_image = ''; |
|
216 | 216 | } ?> |
217 | 217 | <a <?php echo $title.' '.$class; ?> href="<?php echo $person->getHtmlUrl(); ?>"> |
218 | 218 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
@@ -225,20 +225,20 @@ discard block |
||
225 | 225 | </td> |
226 | 226 | <td style="display:none;"></td> |
227 | 227 | <td> |
228 | - <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> |
|
228 | + <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)).'AAAA'.Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> |
|
229 | 229 | </td> |
230 | 230 | <td> |
231 | - <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
|
231 | + <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)).'AAAA'.Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
|
232 | 232 | </td> |
233 | 233 | <td> |
234 | 234 | <?php |
235 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
235 | + if ($birth_dates = $person->getAllBirthDates()) { |
|
236 | 236 | foreach ($birth_dates as $num=>$birth_date) { |
237 | 237 | if ($num) { ?><br/><?php } ?> |
238 | 238 | <?php echo $birth_date->display(true); |
239 | 239 | } |
240 | 240 | } else { |
241 | - $birth_date=$person->getEstimatedBirthDate(); |
|
241 | + $birth_date = $person->getEstimatedBirthDate(); |
|
242 | 242 | if ($person->getTree()->getPreference('SHOW_EST_LIST_DATES')) { |
243 | 243 | $birth_date->display(true); |
244 | 244 | } else { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | } |
249 | 249 | ?> |
250 | 250 | </td> |
251 | - <td><?php echo $birth_date->julianDay();?></td> |
|
251 | + <td><?php echo $birth_date->julianDay(); ?></td> |
|
252 | 252 | <td> |
253 | 253 | <?php foreach ($person->getAllBirthPlaces() as $n => $birth_place) { |
254 | 254 | $tmp = new \Fisharebest\Webtrees\Place($birth_place, $person->getTree()); |
@@ -343,10 +343,10 @@ discard block |
||
343 | 343 | <?php echo I18N::translate('Number of Sosa ancestors: %1$s known / %2$s theoretical (%3$s)', |
344 | 344 | I18N::number($this->data->get('sosa_count')), |
345 | 345 | I18N::number($this->data->get('sosa_theo')), |
346 | - I18N::percentage($this->data->get('sosa_ratio'),2) |
|
346 | + I18N::percentage($this->data->get('sosa_ratio'), 2) |
|
347 | 347 | ); ?> |
348 | - <?php if($this->data->get('sosa_hidden') > 0) { |
|
349 | - echo '['. I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))).']'; |
|
348 | + <?php if ($this->data->get('sosa_hidden') > 0) { |
|
349 | + echo '['.I18N::translate('%s hidden', I18N::number($this->data->get('sosa_hidden'))).']'; |
|
350 | 350 | } ?> |
351 | 351 | </div> |
352 | 352 | </th> |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | <button type="button" class="ui-state-default btn-toggle-parents"> |
359 | 359 | <?php echo I18N::translate('Show parents') ?> |
360 | 360 | </button> |
361 | - <button id="btn-toggle-statistics-<?php echo $table_id ;?>" type="button" class="ui-state-default btn-toggle-statistics"> |
|
361 | + <button id="btn-toggle-statistics-<?php echo $table_id; ?>" type="button" class="ui-state-default btn-toggle-statistics"> |
|
362 | 362 | <?php echo I18N::translate('Show statistics charts') ?> |
363 | 363 | </button> |
364 | 364 | </div> |