@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * {@inhericDoc} |
23 | 23 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
24 | 24 | */ |
25 | - protected function renderContent() { |
|
25 | + protected function renderContent() { |
|
26 | 26 | |
27 | - $table_id = $this->data->get('table_id'); |
|
28 | - ?> |
|
27 | + $table_id = $this->data->get('table_id'); |
|
28 | + ?> |
|
29 | 29 | <ol class="breadcrumb small"> |
30 | 30 | <li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li> |
31 | 31 | <li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li> |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | </table> |
69 | 69 | |
70 | 70 | <?php |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | } |
74 | 74 | |
75 | 75 | \ No newline at end of file |
@@ -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();"> |
@@ -29,66 +29,66 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class SosaConfigController extends MvcController |
31 | 31 | { |
32 | - /** |
|
33 | - * Check if the user can update the sosa ancestors list |
|
34 | - * |
|
35 | - * @return bool |
|
36 | - */ |
|
37 | - protected function canUpdate() { |
|
38 | - global $WT_TREE; |
|
32 | + /** |
|
33 | + * Check if the user can update the sosa ancestors list |
|
34 | + * |
|
35 | + * @return bool |
|
36 | + */ |
|
37 | + protected function canUpdate() { |
|
38 | + global $WT_TREE; |
|
39 | 39 | |
40 | - $user_id = Filter::postInteger('userid', -1) ?: Filter::getInteger('userid', -1); |
|
41 | - return Auth::check() && |
|
42 | - ( |
|
43 | - $user_id == Auth::user()->getUserId() || // Allow update for yourself |
|
44 | - ($user_id == -1 && Auth::isManager($WT_TREE)) // Allow a manager to update the default user |
|
45 | - ); |
|
46 | - } |
|
40 | + $user_id = Filter::postInteger('userid', -1) ?: Filter::getInteger('userid', -1); |
|
41 | + return Auth::check() && |
|
42 | + ( |
|
43 | + $user_id == Auth::user()->getUserId() || // Allow update for yourself |
|
44 | + ($user_id == -1 && Auth::isManager($WT_TREE)) // Allow a manager to update the default user |
|
45 | + ); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Saves Sosa's user preferences (root individual for the user). |
|
50 | - * |
|
51 | - * @param BaseController $controller |
|
52 | - * @return bool True is saving successfull |
|
53 | - */ |
|
54 | - protected function update(BaseController $controller) { |
|
55 | - global $WT_TREE; |
|
56 | - if($this->canUpdate() && Filter::checkCsrf()) |
|
57 | - { |
|
58 | - $indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE); |
|
59 | - $user = User::find(Filter::postInteger('userid', -1)); |
|
48 | + /** |
|
49 | + * Saves Sosa's user preferences (root individual for the user). |
|
50 | + * |
|
51 | + * @param BaseController $controller |
|
52 | + * @return bool True is saving successfull |
|
53 | + */ |
|
54 | + protected function update(BaseController $controller) { |
|
55 | + global $WT_TREE; |
|
56 | + if($this->canUpdate() && Filter::checkCsrf()) |
|
57 | + { |
|
58 | + $indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE); |
|
59 | + $user = User::find(Filter::postInteger('userid', -1)); |
|
60 | 60 | |
61 | - if($user && $indi) { |
|
62 | - $WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref()); |
|
63 | - $controller->addInlineJavascript(' |
|
61 | + if($user && $indi) { |
|
62 | + $WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref()); |
|
63 | + $controller->addInlineJavascript(' |
|
64 | 64 | $( document ).ready(function() { |
65 | 65 | majComputeSosa('.$user->getUserId().'); |
66 | 66 | });'); |
67 | - FlashMessages::addMessage(I18N::translate('The preferences have been updated.')); |
|
68 | - return true; |
|
69 | - } |
|
70 | - } |
|
71 | - FlashMessages::addMessage(I18N::translate('An error occurred while saving data...'), 'danger'); |
|
72 | - return false; |
|
73 | - } |
|
67 | + FlashMessages::addMessage(I18N::translate('The preferences have been updated.')); |
|
68 | + return true; |
|
69 | + } |
|
70 | + } |
|
71 | + FlashMessages::addMessage(I18N::translate('An error occurred while saving data...'), 'danger'); |
|
72 | + return false; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * Pages |
|
77 | - */ |
|
75 | + /** |
|
76 | + * Pages |
|
77 | + */ |
|
78 | 78 | |
79 | - /** |
|
80 | - * SosaConfig@index |
|
81 | - */ |
|
82 | - public function index() { |
|
83 | - global $WT_TREE; |
|
79 | + /** |
|
80 | + * SosaConfig@index |
|
81 | + */ |
|
82 | + public function index() { |
|
83 | + global $WT_TREE; |
|
84 | 84 | |
85 | - $controller = new PageController(); |
|
86 | - $controller |
|
87 | - ->setPageTitle(I18N::translate('Sosa Configuration')) |
|
88 | - ->restrictAccess(Auth::check()) |
|
89 | - ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) |
|
90 | - ->addInlineJavascript('autocomplete();') |
|
91 | - ->addInlineJavascript(' |
|
85 | + $controller = new PageController(); |
|
86 | + $controller |
|
87 | + ->setPageTitle(I18N::translate('Sosa Configuration')) |
|
88 | + ->restrictAccess(Auth::check()) |
|
89 | + ->addExternalJavascript(WT_AUTOCOMPLETE_JS_URL) |
|
90 | + ->addInlineJavascript('autocomplete();') |
|
91 | + ->addInlineJavascript(' |
|
92 | 92 | $( document ).ready(function() { |
93 | 93 | $("#bt_sosa_compute").click(function() { |
94 | 94 | majComputeSosa($("#maj_sosa_input_userid, #maj-sosa-config-select option:selected").val()); |
@@ -105,83 +105,83 @@ discard block |
||
105 | 105 | }); |
106 | 106 | }'); |
107 | 107 | |
108 | - $action = Filter::post('action'); |
|
109 | - if($action === 'update') $this->update($controller); |
|
108 | + $action = Filter::post('action'); |
|
109 | + if($action === 'update') $this->update($controller); |
|
110 | 110 | |
111 | - $view_bag = new ViewBag(); |
|
112 | - $view_bag->set('title', $controller->getPageTitle()); |
|
113 | - $view_bag->set('tree', $WT_TREE); |
|
114 | - $view_bag->set('form_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaConfig&ged='.$WT_TREE->getNameUrl()); |
|
111 | + $view_bag = new ViewBag(); |
|
112 | + $view_bag->set('title', $controller->getPageTitle()); |
|
113 | + $view_bag->set('tree', $WT_TREE); |
|
114 | + $view_bag->set('form_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaConfig&ged='.$WT_TREE->getNameUrl()); |
|
115 | 115 | |
116 | - $users_root = array(); |
|
117 | - $users_js_array = 'var users_array = [];'; |
|
118 | - if(Auth::check()) { |
|
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 . '";'; |
|
116 | + $users_root = array(); |
|
117 | + $users_js_array = 'var users_array = [];'; |
|
118 | + if(Auth::check()) { |
|
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 . '";'; |
|
122 | 122 | |
123 | - if(Auth::isManager($WT_TREE)) { |
|
124 | - $default_user = User::find(-1); |
|
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 . '";'; |
|
128 | - } |
|
129 | - } |
|
130 | - $view_bag->set('users_settings', $users_root); |
|
123 | + if(Auth::isManager($WT_TREE)) { |
|
124 | + $default_user = User::find(-1); |
|
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 . '";'; |
|
128 | + } |
|
129 | + } |
|
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 | }); |
136 | 136 | '); |
137 | 137 | |
138 | - ViewFactory::make('SosaConfig', $this, $controller, $view_bag)->render(); |
|
139 | - } |
|
138 | + ViewFactory::make('SosaConfig', $this, $controller, $view_bag)->render(); |
|
139 | + } |
|
140 | 140 | |
141 | - /** |
|
142 | - * SosaConfig@computeAll |
|
143 | - */ |
|
144 | - public function computeAll() { |
|
145 | - global $WT_TREE; |
|
141 | + /** |
|
142 | + * SosaConfig@computeAll |
|
143 | + */ |
|
144 | + public function computeAll() { |
|
145 | + global $WT_TREE; |
|
146 | 146 | |
147 | - $controller = new AjaxController(); |
|
148 | - $controller->restrictAccess($this->canUpdate()); |
|
147 | + $controller = new AjaxController(); |
|
148 | + $controller->restrictAccess($this->canUpdate()); |
|
149 | 149 | |
150 | - $view_bag = new ViewBag(); |
|
151 | - $view_bag->set('is_success', false); |
|
150 | + $view_bag = new ViewBag(); |
|
151 | + $view_bag->set('is_success', false); |
|
152 | 152 | |
153 | - $user = User::find(Filter::getInteger('userid', -1)); |
|
154 | - if($user) { |
|
155 | - $calculator = new SosaCalculator($WT_TREE, $user); |
|
156 | - if($calculator->computeAll()) $view_bag->set('is_success', true); |
|
157 | - } |
|
158 | - ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
|
159 | - } |
|
153 | + $user = User::find(Filter::getInteger('userid', -1)); |
|
154 | + if($user) { |
|
155 | + $calculator = new SosaCalculator($WT_TREE, $user); |
|
156 | + if($calculator->computeAll()) $view_bag->set('is_success', true); |
|
157 | + } |
|
158 | + ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * SosaConfig@computePartial |
|
163 | - */ |
|
164 | - public function computePartial() { |
|
165 | - global $WT_TREE; |
|
161 | + /** |
|
162 | + * SosaConfig@computePartial |
|
163 | + */ |
|
164 | + public function computePartial() { |
|
165 | + global $WT_TREE; |
|
166 | 166 | |
167 | - $controller = new AjaxController(); |
|
168 | - $controller->restrictAccess($this->canUpdate()); |
|
167 | + $controller = new AjaxController(); |
|
168 | + $controller->restrictAccess($this->canUpdate()); |
|
169 | 169 | |
170 | - $view_bag = new ViewBag(); |
|
171 | - $view_bag->set('is_success', false); |
|
170 | + $view_bag = new ViewBag(); |
|
171 | + $view_bag->set('is_success', false); |
|
172 | 172 | |
173 | - $user = User::find(Filter::getInteger('userid', -1)); |
|
174 | - $indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE); |
|
173 | + $user = User::find(Filter::getInteger('userid', -1)); |
|
174 | + $indi = Individual::getInstance(Filter::get('pid', WT_REGEX_XREF), $WT_TREE); |
|
175 | 175 | |
176 | - if($user && $indi) { |
|
177 | - $calculator = new SosaCalculator($WT_TREE, $user); |
|
178 | - if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
179 | - } |
|
180 | - else { |
|
181 | - $view_bag->set('error', I18N::translate('Non existing individual')); |
|
182 | - } |
|
176 | + if($user && $indi) { |
|
177 | + $calculator = new SosaCalculator($WT_TREE, $user); |
|
178 | + if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
179 | + } |
|
180 | + else { |
|
181 | + $view_bag->set('error', I18N::translate('Non existing individual')); |
|
182 | + } |
|
183 | 183 | |
184 | - ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
|
185 | - } |
|
184 | + ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
|
185 | + } |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | \ No newline at end of file |
@@ -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')); |
@@ -106,7 +106,9 @@ discard block |
||
106 | 106 | }'); |
107 | 107 | |
108 | 108 | $action = Filter::post('action'); |
109 | - if($action === 'update') $this->update($controller); |
|
109 | + if($action === 'update') { |
|
110 | + $this->update($controller); |
|
111 | + } |
|
110 | 112 | |
111 | 113 | $view_bag = new ViewBag(); |
112 | 114 | $view_bag->set('title', $controller->getPageTitle()); |
@@ -153,7 +155,9 @@ discard block |
||
153 | 155 | $user = User::find(Filter::getInteger('userid', -1)); |
154 | 156 | if($user) { |
155 | 157 | $calculator = new SosaCalculator($WT_TREE, $user); |
156 | - if($calculator->computeAll()) $view_bag->set('is_success', true); |
|
158 | + if($calculator->computeAll()) { |
|
159 | + $view_bag->set('is_success', true); |
|
160 | + } |
|
157 | 161 | } |
158 | 162 | ViewFactory::make('SosaComputeResult', $this, $controller, $view_bag)->render(); |
159 | 163 | } |
@@ -175,9 +179,10 @@ discard block |
||
175 | 179 | |
176 | 180 | if($user && $indi) { |
177 | 181 | $calculator = new SosaCalculator($WT_TREE, $user); |
178 | - if($calculator->computeFromIndividual($indi)) $view_bag->set('is_success', true); |
|
179 | - } |
|
180 | - else { |
|
182 | + if($calculator->computeFromIndividual($indi)) { |
|
183 | + $view_bag->set('is_success', true); |
|
184 | + } |
|
185 | + } else { |
|
181 | 186 | $view_bag->set('error', I18N::translate('Non existing individual')); |
182 | 187 | } |
183 | 188 |
@@ -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 | } |
@@ -114,8 +114,12 @@ |
||
114 | 114 | $this->flushTmpSosaTable(); |
115 | 115 | |
116 | 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); |
|
117 | + if($husb = $fam->getHusband()) { |
|
118 | + $this->addNode($husb, 2 * $sosa); |
|
119 | + } |
|
120 | + if($wife = $fam->getWife()) { |
|
121 | + $this->addNode($wife, 2 * $sosa + 1); |
|
122 | + } |
|
119 | 123 | } |
120 | 124 | } |
121 | 125 |
@@ -19,116 +19,116 @@ |
||
19 | 19 | */ |
20 | 20 | class SosaCalculator { |
21 | 21 | |
22 | - /** |
|
23 | - * Maximium size for the temporary Sosa table |
|
24 | - * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | - */ |
|
26 | - const TMP_SOSA_TABLE_LIMIT = 1000; |
|
22 | + /** |
|
23 | + * Maximium size for the temporary Sosa table |
|
24 | + * @var int TMP_SOSA_TABLE_LIMIT |
|
25 | + */ |
|
26 | + const TMP_SOSA_TABLE_LIMIT = 1000; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Reference user |
|
30 | - * @var Fisharebest\Webtrees\User $user |
|
31 | - */ |
|
32 | - protected $user; |
|
28 | + /** |
|
29 | + * Reference user |
|
30 | + * @var Fisharebest\Webtrees\User $user |
|
31 | + */ |
|
32 | + protected $user; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Reference tree |
|
36 | - * @var Fisharebest\Webtrees\Tree $tree |
|
37 | - */ |
|
38 | - protected $tree; |
|
34 | + /** |
|
35 | + * Reference tree |
|
36 | + * @var Fisharebest\Webtrees\Tree $tree |
|
37 | + */ |
|
38 | + protected $tree; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Sosa Provider for the calculator |
|
42 | - * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | - */ |
|
44 | - protected $sosa_provider; |
|
40 | + /** |
|
41 | + * Sosa Provider for the calculator |
|
42 | + * @var \MyArtJaub\Webtrees\Module\Sosa\Model\SosaCalculator $sosa_provider |
|
43 | + */ |
|
44 | + protected $sosa_provider; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Temporary Sosa table, used during construction |
|
48 | - * @var array $tmp_sosa_table |
|
49 | - */ |
|
50 | - protected $tmp_sosa_table; |
|
46 | + /** |
|
47 | + * Temporary Sosa table, used during construction |
|
48 | + * @var array $tmp_sosa_table |
|
49 | + */ |
|
50 | + protected $tmp_sosa_table; |
|
51 | 51 | |
52 | - /** |
|
53 | - * Constructor for the Sosa Calculator |
|
54 | - * @param Tree $tree |
|
55 | - * @param User $user |
|
56 | - */ |
|
57 | - public function __construct(Tree $tree, User $user) { |
|
58 | - $this->tree = $tree; |
|
59 | - $this->user = $user; |
|
52 | + /** |
|
53 | + * Constructor for the Sosa Calculator |
|
54 | + * @param Tree $tree |
|
55 | + * @param User $user |
|
56 | + */ |
|
57 | + public function __construct(Tree $tree, User $user) { |
|
58 | + $this->tree = $tree; |
|
59 | + $this->user = $user; |
|
60 | 60 | |
61 | - $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | - } |
|
61 | + $this->sosa_provider = new SosaProvider($this->tree, $this->user);; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Compute all Sosa ancestors from the user's root individual. |
|
66 | - * @return bool Result of the computation |
|
67 | - */ |
|
68 | - public function computeAll() { |
|
69 | - $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | - $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | - if($indi){ |
|
72 | - $this->sosa_provider->deleteAll(); |
|
73 | - $this->addNode($indi, 1); |
|
74 | - $this->flushTmpSosaTable(true); |
|
75 | - return true; |
|
76 | - } |
|
77 | - return false; |
|
78 | - } |
|
64 | + /** |
|
65 | + * Compute all Sosa ancestors from the user's root individual. |
|
66 | + * @return bool Result of the computation |
|
67 | + */ |
|
68 | + public function computeAll() { |
|
69 | + $root_id = $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
70 | + $indi = Individual::getInstance($root_id, $this->tree); |
|
71 | + if($indi){ |
|
72 | + $this->sosa_provider->deleteAll(); |
|
73 | + $this->addNode($indi, 1); |
|
74 | + $this->flushTmpSosaTable(true); |
|
75 | + return true; |
|
76 | + } |
|
77 | + return false; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Compute all Sosa Ancestors from a specified Individual |
|
82 | - * @param Individual $indi |
|
83 | - * @return bool Result of the computation |
|
84 | - */ |
|
85 | - public function computeFromIndividual(Individual $indi) { |
|
86 | - $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
87 | - $current_sosas = $dindi->getSosaNumbers(); |
|
88 | - foreach($current_sosas as $current_sosa => $gen) { |
|
89 | - $this->sosa_provider->deleteAncestors($current_sosa); |
|
90 | - $this->addNode($indi, $current_sosa); |
|
91 | - } |
|
92 | - $this->flushTmpSosaTable(true); |
|
93 | - return true; |
|
94 | - } |
|
80 | + /** |
|
81 | + * Compute all Sosa Ancestors from a specified Individual |
|
82 | + * @param Individual $indi |
|
83 | + * @return bool Result of the computation |
|
84 | + */ |
|
85 | + public function computeFromIndividual(Individual $indi) { |
|
86 | + $dindi = new \MyArtJaub\Webtrees\Individual($indi); |
|
87 | + $current_sosas = $dindi->getSosaNumbers(); |
|
88 | + foreach($current_sosas as $current_sosa => $gen) { |
|
89 | + $this->sosa_provider->deleteAncestors($current_sosa); |
|
90 | + $this->addNode($indi, $current_sosa); |
|
91 | + } |
|
92 | + $this->flushTmpSosaTable(true); |
|
93 | + return true; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Recursive method to add individual to the Sosa table, and flush it regularly |
|
98 | - * @param Individual $indi Individual to add |
|
99 | - * @param int $sosa Individual's sosa |
|
100 | - */ |
|
101 | - protected function addNode(Individual $indi, $sosa) { |
|
102 | - $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
103 | - $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
96 | + /** |
|
97 | + * Recursive method to add individual to the Sosa table, and flush it regularly |
|
98 | + * @param Individual $indi Individual to add |
|
99 | + * @param int $sosa Individual's sosa |
|
100 | + */ |
|
101 | + protected function addNode(Individual $indi, $sosa) { |
|
102 | + $birth_year = $indi->getEstimatedBirthDate()->gregorianYear(); |
|
103 | + $death_year = $indi->getEstimatedDeathDate()->gregorianYear(); |
|
104 | 104 | |
105 | - $this->tmp_sosa_table[] = array( |
|
106 | - 'indi' => $indi->getXref(), |
|
107 | - 'sosa' => $sosa, |
|
108 | - 'birth_year' => $birth_year, |
|
109 | - 'death_year' => $death_year |
|
110 | - ); |
|
105 | + $this->tmp_sosa_table[] = array( |
|
106 | + 'indi' => $indi->getXref(), |
|
107 | + 'sosa' => $sosa, |
|
108 | + 'birth_year' => $birth_year, |
|
109 | + 'death_year' => $death_year |
|
110 | + ); |
|
111 | 111 | |
112 | - $this->flushTmpSosaTable(); |
|
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); |
|
117 | - } |
|
118 | - } |
|
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 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
122 | - * |
|
123 | - * @param bool $force Should the flush be forced |
|
124 | - */ |
|
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)){ |
|
128 | - $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
129 | - $this->tmp_sosa_table = array(); |
|
130 | - } |
|
131 | - } |
|
120 | + /** |
|
121 | + * Write sosas in the table, if the number of items is superior to the limit, or if forced. |
|
122 | + * |
|
123 | + * @param bool $force Should the flush be forced |
|
124 | + */ |
|
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)){ |
|
128 | + $this->sosa_provider->insertOrUpdate($this->tmp_sosa_table); |
|
129 | + $this->tmp_sosa_table = array(); |
|
130 | + } |
|
131 | + } |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | 135 | \ No newline at end of file |
@@ -84,21 +84,25 @@ discard block |
||
84 | 84 | * @param User $user |
85 | 85 | */ |
86 | 86 | public function __construct(Tree $tree, User $user = null) { |
87 | - if(self::$default_user === null) |
|
88 | - self::$default_user = User::find(-1); |
|
87 | + if(self::$default_user === null) { |
|
88 | + self::$default_user = User::find(-1); |
|
89 | + } |
|
89 | 90 | |
90 | 91 | $this->tree = $tree; |
91 | 92 | $this->user = $user; |
92 | 93 | $this->is_setup = true; |
93 | - if($this->user === null) $this->user = Auth::user(); |
|
94 | - if(strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
94 | + if($this->user === null) { |
|
95 | + $this->user = Auth::user(); |
|
96 | + } |
|
97 | + if(strlen($this->user->getUserId()) == 0) { |
|
98 | + $this->user = self::$default_user; |
|
99 | + } |
|
95 | 100 | |
96 | 101 | // Check if the user, or the default user, has a root already setup; |
97 | 102 | if(!$this->getRootIndi()) { |
98 | 103 | if($this->user == self::$default_user) { // If the default user is not setup |
99 | 104 | $this->is_setup = false; |
100 | - } |
|
101 | - else { |
|
105 | + } else { |
|
102 | 106 | $this->user = self::$default_user; |
103 | 107 | $this->is_setup = $this->getRootIndi() === null; |
104 | 108 | } |
@@ -129,7 +133,9 @@ discard block |
||
129 | 133 | * Remove all Sosa entries related to the gedcom file and user |
130 | 134 | */ |
131 | 135 | public function deleteAll() { |
132 | - if(!$this->is_setup) return; |
|
136 | + if(!$this->is_setup) { |
|
137 | + return; |
|
138 | + } |
|
133 | 139 | Database::prepare( |
134 | 140 | 'DELETE FROM `##maj_sosa`'. |
135 | 141 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -145,7 +151,9 @@ discard block |
||
145 | 151 | * @param int $sosa |
146 | 152 | */ |
147 | 153 | public function deleteAncestors($sosa) { |
148 | - if(!$this->is_setup) return; |
|
154 | + if(!$this->is_setup) { |
|
155 | + return; |
|
156 | + } |
|
149 | 157 | $gen = Functions::getGeneration($sosa); |
150 | 158 | Database::prepare( |
151 | 159 | 'DELETE FROM `##maj_sosa`'. |
@@ -165,7 +173,9 @@ discard block |
||
165 | 173 | * @param array $sosa_records |
166 | 174 | */ |
167 | 175 | public function insertOrUpdate($sosa_records) { |
168 | - if(!$this->is_setup) return; |
|
176 | + if(!$this->is_setup) { |
|
177 | + return; |
|
178 | + } |
|
169 | 179 | |
170 | 180 | $treeid = $this->tree->getTreeId(); |
171 | 181 | $userid = $this->user->getUserId(); |
@@ -212,7 +222,9 @@ discard block |
||
212 | 222 | * @return array Array of sosa numbers |
213 | 223 | */ |
214 | 224 | public function getSosaNumbers(Individual $indi) { |
215 | - if(!$this->is_setup) return array(); |
|
225 | + if(!$this->is_setup) { |
|
226 | + return array(); |
|
227 | + } |
|
216 | 228 | return Database::prepare( |
217 | 229 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
218 | 230 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -229,7 +241,9 @@ discard block |
||
229 | 241 | * @return number Last generation if found, 1 otherwise |
230 | 242 | */ |
231 | 243 | public function getLastGeneration() { |
232 | - if(!$this->is_setup) return; |
|
244 | + if(!$this->is_setup) { |
|
245 | + return; |
|
246 | + } |
|
233 | 247 | return Database::prepare( |
234 | 248 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
235 | 249 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -250,7 +264,9 @@ discard block |
||
250 | 264 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
251 | 265 | */ |
252 | 266 | public function getAllSosaWithGenerations(){ |
253 | - if(!$this->is_setup) return array(); |
|
267 | + if(!$this->is_setup) { |
|
268 | + return array(); |
|
269 | + } |
|
254 | 270 | return Database::prepare( |
255 | 271 | 'SELECT majs_i_id AS indi,' . |
256 | 272 | ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
@@ -270,9 +286,12 @@ discard block |
||
270 | 286 | * @return array Array of Sosa individuals |
271 | 287 | */ |
272 | 288 | public function getSosaListAtGeneration($gen){ |
273 | - if(!$this->is_setup) return array(); |
|
274 | - if(!$this->sosa_list_by_gen) |
|
275 | - $this->sosa_list_by_gen = array(); |
|
289 | + if(!$this->is_setup) { |
|
290 | + return array(); |
|
291 | + } |
|
292 | + if(!$this->sosa_list_by_gen) { |
|
293 | + $this->sosa_list_by_gen = array(); |
|
294 | + } |
|
276 | 295 | |
277 | 296 | if($gen){ |
278 | 297 | if(!isset($this->sosa_list_by_gen[$gen])){ |
@@ -301,9 +320,12 @@ discard block |
||
301 | 320 | * @return array Array of Sosa families |
302 | 321 | */ |
303 | 322 | public function getFamilySosaListAtGeneration($gen){ |
304 | - if(!$this->is_setup) return array(); |
|
305 | - if(!$this->sosa_fam_list_by_gen) |
|
306 | - $this->sosa_fam_list_by_gen = array(); |
|
323 | + if(!$this->is_setup) { |
|
324 | + return array(); |
|
325 | + } |
|
326 | + if(!$this->sosa_fam_list_by_gen) { |
|
327 | + $this->sosa_fam_list_by_gen = array(); |
|
328 | + } |
|
307 | 329 | |
308 | 330 | if($gen){ |
309 | 331 | if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
@@ -337,7 +359,9 @@ discard block |
||
337 | 359 | * @return array Array of Sosa individuals |
338 | 360 | */ |
339 | 361 | public function getMissingSosaListAtGeneration($gen){ |
340 | - if(!$this->is_setup) return array(); |
|
362 | + if(!$this->is_setup) { |
|
363 | + return array(); |
|
364 | + } |
|
341 | 365 | if($gen){ |
342 | 366 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
343 | 367 | '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'. |
@@ -375,7 +399,9 @@ discard block |
||
375 | 399 | * @return array Statistics array |
376 | 400 | */ |
377 | 401 | public function getStatisticsByGeneration() { |
378 | - if(!$this->is_setup) return array(); |
|
402 | + if(!$this->is_setup) { |
|
403 | + return array(); |
|
404 | + } |
|
379 | 405 | if(!$this->statistics_tab) { |
380 | 406 | $this->statistics_tab = array(); |
381 | 407 | if($maxGeneration = $this->getLastGeneration()) { |
@@ -401,7 +427,9 @@ discard block |
||
401 | 427 | * @return int |
402 | 428 | */ |
403 | 429 | public function getTotalIndividuals() { |
404 | - if(!$this->is_setup) return 0; |
|
430 | + if(!$this->is_setup) { |
|
431 | + return 0; |
|
432 | + } |
|
405 | 433 | return Database::prepare( |
406 | 434 | 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' . |
407 | 435 | ' WHERE i_file = :tree_id') |
@@ -415,7 +443,9 @@ discard block |
||
415 | 443 | * @return number Number of Sosas |
416 | 444 | */ |
417 | 445 | public function getSosaCount(){ |
418 | - if(!$this->is_setup) return 0; |
|
446 | + if(!$this->is_setup) { |
|
447 | + return 0; |
|
448 | + } |
|
419 | 449 | return Database::prepare( |
420 | 450 | 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
421 | 451 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -432,7 +462,9 @@ discard block |
||
432 | 462 | * @return number Number of Sosas in generation |
433 | 463 | */ |
434 | 464 | public function getSosaCountAtGeneration($gen){ |
435 | - if(!$this->is_setup) return 0; |
|
465 | + if(!$this->is_setup) { |
|
466 | + return 0; |
|
467 | + } |
|
436 | 468 | return Database::prepare( |
437 | 469 | 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
438 | 470 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -451,7 +483,9 @@ discard block |
||
451 | 483 | * @return number Total number of Sosas up to generation |
452 | 484 | */ |
453 | 485 | public function getSosaCountUpToGeneration($gen){ |
454 | - if(!$this->is_setup) return 0; |
|
486 | + if(!$this->is_setup) { |
|
487 | + return 0; |
|
488 | + } |
|
455 | 489 | return Database::prepare( |
456 | 490 | 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
457 | 491 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -469,7 +503,9 @@ discard block |
||
469 | 503 | * @return number Total number of distinct individual |
470 | 504 | */ |
471 | 505 | public function getDifferentSosaCount(){ |
472 | - if(!$this->is_setup) return 0; |
|
506 | + if(!$this->is_setup) { |
|
507 | + return 0; |
|
508 | + } |
|
473 | 509 | return Database::prepare( |
474 | 510 | 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
475 | 511 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
@@ -486,7 +522,9 @@ discard block |
||
486 | 522 | * @return number Number of distinct Sosa individuals up to generation |
487 | 523 | */ |
488 | 524 | public function getDifferentSosaCountUpToGeneration($gen){ |
489 | - if(!$this->is_setup) return 0; |
|
525 | + if(!$this->is_setup) { |
|
526 | + return 0; |
|
527 | + } |
|
490 | 528 | return Database::prepare( |
491 | 529 | 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
492 | 530 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
@@ -509,7 +547,9 @@ discard block |
||
509 | 547 | * @return array Birth statistics array |
510 | 548 | */ |
511 | 549 | public function getStatsBirthYearInGeneration($gen){ |
512 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
550 | + if(!$this->is_setup) { |
|
551 | + return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
552 | + } |
|
513 | 553 | return Database::prepare( |
514 | 554 | 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
515 | 555 | ' FROM `##maj_sosa`' . |
@@ -529,7 +569,9 @@ discard block |
||
529 | 569 | * @return number|NULL Mean generation time |
530 | 570 | */ |
531 | 571 | public function getMeanGenerationTime(){ |
532 | - if(!$this->is_setup) return; |
|
572 | + if(!$this->is_setup) { |
|
573 | + return; |
|
574 | + } |
|
533 | 575 | if(!$this->statistics_tab){ |
534 | 576 | $this->getStatisticsByGeneration(); |
535 | 577 | } |
@@ -575,7 +617,10 @@ discard block |
||
575 | 617 | * @return array |
576 | 618 | */ |
577 | 619 | 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 |
|
620 | + if(!$this->is_setup || $gen > 11) { |
|
621 | + return array(); |
|
622 | + } |
|
623 | + // Going further than 11 gen will be out of range in the query |
|
579 | 624 | return Database::prepare( |
580 | 625 | 'SELECT branches, count(i_id)'. |
581 | 626 | ' FROM ('. |
@@ -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' |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | * @param int $ged_id ID of the gedcom file |
262 | 262 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
263 | 263 | */ |
264 | - public function getAllSosaWithGenerations(){ |
|
265 | - if(!$this->is_setup) return array(); |
|
264 | + public function getAllSosaWithGenerations() { |
|
265 | + if (!$this->is_setup) return array(); |
|
266 | 266 | return Database::prepare( |
267 | - 'SELECT majs_i_id AS indi,' . |
|
268 | - ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
|
269 | - ' FROM `##maj_sosa`' . |
|
270 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' . |
|
267 | + 'SELECT majs_i_id AS indi,'. |
|
268 | + ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations'. |
|
269 | + ' FROM `##maj_sosa`'. |
|
270 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
271 | 271 | ' GROUP BY majs_i_id' |
272 | 272 | )->execute(array( |
273 | 273 | 'tree_id' => $this->tree->getTreeId(), |
@@ -281,13 +281,13 @@ discard block |
||
281 | 281 | * @param number $gen Generation |
282 | 282 | * @return array Array of Sosa individuals |
283 | 283 | */ |
284 | - public function getSosaListAtGeneration($gen){ |
|
285 | - if(!$this->is_setup) return array(); |
|
286 | - if(!$this->sosa_list_by_gen) |
|
284 | + public function getSosaListAtGeneration($gen) { |
|
285 | + if (!$this->is_setup) return array(); |
|
286 | + if (!$this->sosa_list_by_gen) |
|
287 | 287 | $this->sosa_list_by_gen = array(); |
288 | 288 | |
289 | - if($gen){ |
|
290 | - if(!isset($this->sosa_list_by_gen[$gen])){ |
|
289 | + if ($gen) { |
|
290 | + if (!isset($this->sosa_list_by_gen[$gen])) { |
|
291 | 291 | $this->sosa_list_by_gen[$gen] = Database::prepare( |
292 | 292 | 'SELECT majs_sosa AS sosa, majs_i_id AS indi'. |
293 | 293 | ' FROM `##maj_sosa`'. |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | * @param number $gen Generation |
313 | 313 | * @return array Array of Sosa families |
314 | 314 | */ |
315 | - public function getFamilySosaListAtGeneration($gen){ |
|
316 | - if(!$this->is_setup) return array(); |
|
317 | - if(!$this->sosa_fam_list_by_gen) |
|
315 | + public function getFamilySosaListAtGeneration($gen) { |
|
316 | + if (!$this->is_setup) return array(); |
|
317 | + if (!$this->sosa_fam_list_by_gen) |
|
318 | 318 | $this->sosa_fam_list_by_gen = array(); |
319 | 319 | |
320 | - if($gen){ |
|
321 | - if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
|
320 | + if ($gen) { |
|
321 | + if (!isset($this->sosa_fam_list_by_gen[$gen])) { |
|
322 | 322 | $this->sosa_fam_list_by_gen[$gen] = Database::prepare( |
323 | 323 | 'SELECT s1.majs_sosa AS sosa, f_id AS fam'. |
324 | 324 | ' FROM `##families`'. |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | * @param number $gen Generation |
349 | 349 | * @return array Array of Sosa individuals |
350 | 350 | */ |
351 | - public function getMissingSosaListAtGeneration($gen){ |
|
352 | - if(!$this->is_setup) return array(); |
|
353 | - if($gen){ |
|
351 | + public function getMissingSosaListAtGeneration($gen) { |
|
352 | + if (!$this->is_setup) return array(); |
|
353 | + if ($gen) { |
|
354 | 354 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
355 | 355 | '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'. |
356 | 356 | ' FROM `##maj_sosa` schild'. |
@@ -387,10 +387,10 @@ discard block |
||
387 | 387 | * @return array Statistics array |
388 | 388 | */ |
389 | 389 | public function getStatisticsByGeneration() { |
390 | - if(!$this->is_setup) return array(); |
|
391 | - if(!$this->statistics_tab) { |
|
390 | + if (!$this->is_setup) return array(); |
|
391 | + if (!$this->statistics_tab) { |
|
392 | 392 | $this->statistics_tab = array(); |
393 | - if($maxGeneration = $this->getLastGeneration()) { |
|
393 | + if ($maxGeneration = $this->getLastGeneration()) { |
|
394 | 394 | for ($gen = 1; $gen <= $maxGeneration; $gen++) { |
395 | 395 | $birthStats = $this->getStatsBirthYearInGeneration($gen); |
396 | 396 | $this->statistics_tab[$gen] = array( |
@@ -413,9 +413,9 @@ discard block |
||
413 | 413 | * @return int |
414 | 414 | */ |
415 | 415 | public function getTotalIndividuals() { |
416 | - if(!$this->is_setup) return 0; |
|
416 | + if (!$this->is_setup) return 0; |
|
417 | 417 | return Database::prepare( |
418 | - 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' . |
|
418 | + 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`'. |
|
419 | 419 | ' WHERE i_file = :tree_id') |
420 | 420 | ->execute(array('tree_id' => $this->tree->getTreeId())) |
421 | 421 | ->fetchOne() ?: 0; |
@@ -426,10 +426,10 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @return number Number of Sosas |
428 | 428 | */ |
429 | - public function getSosaCount(){ |
|
430 | - if(!$this->is_setup) return 0; |
|
429 | + public function getSosaCount() { |
|
430 | + if (!$this->is_setup) return 0; |
|
431 | 431 | return Database::prepare( |
432 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
432 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
433 | 433 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
434 | 434 | ->execute(array( |
435 | 435 | 'tree_id' => $this->tree->getTreeId(), |
@@ -443,10 +443,10 @@ discard block |
||
443 | 443 | * @param number $gen Generation |
444 | 444 | * @return number Number of Sosas in generation |
445 | 445 | */ |
446 | - public function getSosaCountAtGeneration($gen){ |
|
447 | - if(!$this->is_setup) return 0; |
|
446 | + public function getSosaCountAtGeneration($gen) { |
|
447 | + if (!$this->is_setup) return 0; |
|
448 | 448 | return Database::prepare( |
449 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
449 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
450 | 450 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
451 | 451 | ' AND majs_gen= :gen') |
452 | 452 | ->execute(array( |
@@ -462,10 +462,10 @@ discard block |
||
462 | 462 | * @param number $gen Generation |
463 | 463 | * @return number Total number of Sosas up to generation |
464 | 464 | */ |
465 | - public function getSosaCountUpToGeneration($gen){ |
|
466 | - if(!$this->is_setup) return 0; |
|
465 | + public function getSosaCountUpToGeneration($gen) { |
|
466 | + if (!$this->is_setup) return 0; |
|
467 | 467 | return Database::prepare( |
468 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
468 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
469 | 469 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
470 | 470 | ' AND majs_gen <= :gen') |
471 | 471 | ->execute(array( |
@@ -480,10 +480,10 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @return number Total number of distinct individual |
482 | 482 | */ |
483 | - public function getDifferentSosaCount(){ |
|
484 | - if(!$this->is_setup) return 0; |
|
483 | + public function getDifferentSosaCount() { |
|
484 | + if (!$this->is_setup) return 0; |
|
485 | 485 | return Database::prepare( |
486 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
486 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
487 | 487 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
488 | 488 | ->execute(array( |
489 | 489 | 'tree_id' => $this->tree->getTreeId(), |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | * @param number $gen Generation |
498 | 498 | * @return number Number of distinct Sosa individuals up to generation |
499 | 499 | */ |
500 | - public function getDifferentSosaCountUpToGeneration($gen){ |
|
501 | - if(!$this->is_setup) return 0; |
|
500 | + public function getDifferentSosaCountUpToGeneration($gen) { |
|
501 | + if (!$this->is_setup) return 0; |
|
502 | 502 | return Database::prepare( |
503 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
503 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
504 | 504 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
505 | 505 | ' AND majs_gen <= :gen') |
506 | 506 | ->execute(array( |
@@ -520,11 +520,11 @@ discard block |
||
520 | 520 | * @param number $gen Generation |
521 | 521 | * @return array Birth statistics array |
522 | 522 | */ |
523 | - public function getStatsBirthYearInGeneration($gen){ |
|
524 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
523 | + public function getStatsBirthYearInGeneration($gen) { |
|
524 | + if (!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
525 | 525 | return Database::prepare( |
526 | 526 | 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
527 | - ' FROM `##maj_sosa`' . |
|
527 | + ' FROM `##maj_sosa`'. |
|
528 | 528 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
529 | 529 | ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year') |
530 | 530 | ->execute(array( |
@@ -540,26 +540,26 @@ discard block |
||
540 | 540 | * |
541 | 541 | * @return number|NULL Mean generation time |
542 | 542 | */ |
543 | - public function getMeanGenerationTime(){ |
|
544 | - if(!$this->is_setup) return; |
|
545 | - if(!$this->statistics_tab){ |
|
543 | + public function getMeanGenerationTime() { |
|
544 | + if (!$this->is_setup) return; |
|
545 | + if (!$this->statistics_tab) { |
|
546 | 546 | $this->getStatisticsByGeneration(); |
547 | 547 | } |
548 | 548 | //Linear regression on x=generation and y=birthdate |
549 | 549 | $sum_xy = 0; |
550 | - $sum_x=0; |
|
551 | - $sum_y=0; |
|
552 | - $sum_x2=0; |
|
553 | - $n=count($this->statistics_tab); |
|
554 | - foreach($this->statistics_tab as $gen=>$stats){ |
|
555 | - $sum_xy+=$gen*$stats['avgBirth']; |
|
556 | - $sum_x+=$gen; |
|
557 | - $sum_y+=$stats['avgBirth']; |
|
558 | - $sum_x2+=$gen*$gen; |
|
550 | + $sum_x = 0; |
|
551 | + $sum_y = 0; |
|
552 | + $sum_x2 = 0; |
|
553 | + $n = count($this->statistics_tab); |
|
554 | + foreach ($this->statistics_tab as $gen=>$stats) { |
|
555 | + $sum_xy += $gen * $stats['avgBirth']; |
|
556 | + $sum_x += $gen; |
|
557 | + $sum_y += $stats['avgBirth']; |
|
558 | + $sum_x2 += $gen * $gen; |
|
559 | 559 | } |
560 | - $denom=($n*$sum_x2)-($sum_x*$sum_x); |
|
561 | - if($denom!=0){ |
|
562 | - return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom); |
|
560 | + $denom = ($n * $sum_x2) - ($sum_x * $sum_x); |
|
561 | + if ($denom != 0) { |
|
562 | + return -(($n * $sum_xy) - ($sum_x * $sum_y)) / ($denom); |
|
563 | 563 | } |
564 | 564 | return null; |
565 | 565 | } |
@@ -587,14 +587,14 @@ discard block |
||
587 | 587 | * @return array |
588 | 588 | */ |
589 | 589 | public function getAncestorDispersionForGen($gen) { |
590 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
590 | + if (!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
591 | 591 | return Database::prepare( |
592 | 592 | 'SELECT branches, count(i_id)'. |
593 | 593 | ' FROM ('. |
594 | 594 | ' SELECT i_id,'. |
595 | 595 | ' CASE'. |
596 | 596 | ' WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'. |
597 | - ' ELSE -1'. // We put all ancestors shared between some branches in the same bucket |
|
597 | + ' ELSE -1'.// We put all ancestors shared between some branches in the same bucket |
|
598 | 598 | ' END branches'. |
599 | 599 | ' FROM ('. |
600 | 600 | ' SELECT DISTINCT majs_i_id i_id,'. |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | /** |
278 | 278 | * Get an associative array of Sosa individuals in generation G. Keys are Sosa numbers, values individuals. |
279 | 279 | * |
280 | - * @param number $gen Generation |
|
280 | + * @param integer $gen Generation |
|
281 | 281 | * @return array Array of Sosa individuals |
282 | 282 | */ |
283 | 283 | public function getSosaListAtGeneration($gen){ |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | /** |
309 | 309 | * Get an associative array of Sosa families in generation G. Keys are Sosa numbers for the husband, values families. |
310 | 310 | * |
311 | - * @param number $gen Generation |
|
311 | + * @param integer $gen Generation |
|
312 | 312 | * @return array Array of Sosa families |
313 | 313 | */ |
314 | 314 | public function getFamilySosaListAtGeneration($gen){ |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | /** |
345 | 345 | * Get an associative array of Sosa individuals in generation G who are missing parents. Keys are Sosa numbers, values individuals. |
346 | 346 | * |
347 | - * @param number $gen Generation |
|
347 | + * @param integer $gen Generation |
|
348 | 348 | * @return array Array of Sosa individuals |
349 | 349 | */ |
350 | 350 | public function getMissingSosaListAtGeneration($gen){ |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | /** |
440 | 440 | * Get the number of Sosa in a specific generation. |
441 | 441 | * |
442 | - * @param number $gen Generation |
|
443 | - * @return number Number of Sosas in generation |
|
442 | + * @param integer $gen Generation |
|
443 | + * @return integer Number of Sosas in generation |
|
444 | 444 | */ |
445 | 445 | public function getSosaCountAtGeneration($gen){ |
446 | 446 | if(!$this->is_setup) return 0; |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | /** |
459 | 459 | * Get the total number of Sosa up to a specific generation. |
460 | 460 | * |
461 | - * @param number $gen Generation |
|
461 | + * @param integer $gen Generation |
|
462 | 462 | * @return number Total number of Sosas up to generation |
463 | 463 | */ |
464 | 464 | public function getSosaCountUpToGeneration($gen){ |
@@ -493,7 +493,7 @@ discard block |
||
493 | 493 | /** |
494 | 494 | * Get the number of distinct Sosa individual up to a specific generation. |
495 | 495 | * |
496 | - * @param number $gen Generation |
|
496 | + * @param integer $gen Generation |
|
497 | 497 | * @return number Number of distinct Sosa individuals up to generation |
498 | 498 | */ |
499 | 499 | public function getDifferentSosaCountUpToGeneration($gen){ |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * - last : Last birth year in generation |
517 | 517 | * - avg : Average birth year |
518 | 518 | * |
519 | - * @param number $gen Generation |
|
519 | + * @param integer $gen Generation |
|
520 | 520 | * @return array Birth statistics array |
521 | 521 | */ |
522 | 522 | public function getStatsBirthYearInGeneration($gen){ |
@@ -22,389 +22,389 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class SosaProvider { |
24 | 24 | |
25 | - /** |
|
26 | - * Maximum number of generation the database is able to hold. |
|
27 | - * @var int MAX_DB_GENERATIONS |
|
28 | - */ |
|
29 | - const MAX_DB_GENERATIONS = 64; |
|
30 | - |
|
31 | - /** |
|
32 | - * System's default user (ID -1 in the database |
|
33 | - * @var User $default_user |
|
34 | - */ |
|
35 | - protected static $default_user; |
|
36 | - |
|
37 | - /** |
|
38 | - * Reference user |
|
39 | - * @var User $user |
|
40 | - */ |
|
41 | - protected $user; |
|
42 | - |
|
43 | - /** |
|
44 | - * Reference tree |
|
45 | - * @var Tree $tree |
|
46 | - */ |
|
47 | - protected $tree; |
|
48 | - |
|
49 | - /** |
|
50 | - * Cached list of Sosa Individuals by generation |
|
51 | - * Format: key = generation, value = array ( sosa => Individual ID) |
|
52 | - * @var array $sosa_list_by_gen |
|
53 | - */ |
|
54 | - protected $sosa_list_by_gen; |
|
55 | - |
|
56 | - /** |
|
57 | - * Cached list of Sosa Families by generation |
|
58 | - * Format: key = generation, value = array ( sosa => Family ID) |
|
59 | - * @var unknown $sosa_fam_list_by_gen |
|
60 | - */ |
|
61 | - protected $sosa_fam_list_by_gen; |
|
62 | - |
|
63 | - /** |
|
64 | - * Cached array of statistics by generation |
|
65 | - * Format: key = generation, |
|
66 | - * value = array( |
|
67 | - * sosaCount, sosaTotalCount, diffSosaTotalCount, firstBirth, lastBirth, avgBirth |
|
68 | - * ) |
|
69 | - * @var array $statistics_tab |
|
70 | - */ |
|
71 | - protected $statistics_tab; |
|
72 | - |
|
73 | - /** |
|
74 | - * Has the provider's initialisation completed |
|
75 | - * @var bool $is_setup |
|
76 | - */ |
|
77 | - protected $is_setup; |
|
78 | - |
|
79 | - /** |
|
80 | - * Constructor for Sosa Provider. |
|
81 | - * A provider is defined in relation to a specific tree and reference user. |
|
82 | - * |
|
83 | - * @param Tree $tree |
|
84 | - * @param User $user |
|
85 | - */ |
|
86 | - public function __construct(Tree $tree, User $user = null) { |
|
87 | - if(self::$default_user === null) |
|
88 | - self::$default_user = User::find(-1); |
|
25 | + /** |
|
26 | + * Maximum number of generation the database is able to hold. |
|
27 | + * @var int MAX_DB_GENERATIONS |
|
28 | + */ |
|
29 | + const MAX_DB_GENERATIONS = 64; |
|
30 | + |
|
31 | + /** |
|
32 | + * System's default user (ID -1 in the database |
|
33 | + * @var User $default_user |
|
34 | + */ |
|
35 | + protected static $default_user; |
|
36 | + |
|
37 | + /** |
|
38 | + * Reference user |
|
39 | + * @var User $user |
|
40 | + */ |
|
41 | + protected $user; |
|
42 | + |
|
43 | + /** |
|
44 | + * Reference tree |
|
45 | + * @var Tree $tree |
|
46 | + */ |
|
47 | + protected $tree; |
|
48 | + |
|
49 | + /** |
|
50 | + * Cached list of Sosa Individuals by generation |
|
51 | + * Format: key = generation, value = array ( sosa => Individual ID) |
|
52 | + * @var array $sosa_list_by_gen |
|
53 | + */ |
|
54 | + protected $sosa_list_by_gen; |
|
55 | + |
|
56 | + /** |
|
57 | + * Cached list of Sosa Families by generation |
|
58 | + * Format: key = generation, value = array ( sosa => Family ID) |
|
59 | + * @var unknown $sosa_fam_list_by_gen |
|
60 | + */ |
|
61 | + protected $sosa_fam_list_by_gen; |
|
62 | + |
|
63 | + /** |
|
64 | + * Cached array of statistics by generation |
|
65 | + * Format: key = generation, |
|
66 | + * value = array( |
|
67 | + * sosaCount, sosaTotalCount, diffSosaTotalCount, firstBirth, lastBirth, avgBirth |
|
68 | + * ) |
|
69 | + * @var array $statistics_tab |
|
70 | + */ |
|
71 | + protected $statistics_tab; |
|
72 | + |
|
73 | + /** |
|
74 | + * Has the provider's initialisation completed |
|
75 | + * @var bool $is_setup |
|
76 | + */ |
|
77 | + protected $is_setup; |
|
78 | + |
|
79 | + /** |
|
80 | + * Constructor for Sosa Provider. |
|
81 | + * A provider is defined in relation to a specific tree and reference user. |
|
82 | + * |
|
83 | + * @param Tree $tree |
|
84 | + * @param User $user |
|
85 | + */ |
|
86 | + public function __construct(Tree $tree, User $user = null) { |
|
87 | + if(self::$default_user === null) |
|
88 | + self::$default_user = User::find(-1); |
|
89 | 89 | |
90 | - $this->tree = $tree; |
|
91 | - $this->user = $user; |
|
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; |
|
90 | + $this->tree = $tree; |
|
91 | + $this->user = $user; |
|
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; |
|
95 | 95 | |
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 |
|
99 | - $this->is_setup = false; |
|
100 | - } |
|
101 | - else { |
|
102 | - $this->user = self::$default_user; |
|
103 | - $this->is_setup = $this->getRootIndiId() === null; |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Returns is the Provider has been successfully set up |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function isSetup() { |
|
113 | - return $this->is_setup; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Return the root individual ID for the reference tree and user. |
|
118 | - * @return string Individual ID |
|
119 | - */ |
|
120 | - public function getRootIndiId() { |
|
121 | - return $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Return the root individual for the reference tree and user. |
|
126 | - * @return Individual Individual |
|
127 | - */ |
|
128 | - public function getRootIndi() { |
|
129 | - $root_indi_id = $this->getRootIndiId(); |
|
130 | - if(!empty($root_indi_id)) { |
|
131 | - return Individual::getInstance($root_indi_id, $this->tree); |
|
132 | - } |
|
133 | - return null; |
|
134 | - } |
|
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 |
|
99 | + $this->is_setup = false; |
|
100 | + } |
|
101 | + else { |
|
102 | + $this->user = self::$default_user; |
|
103 | + $this->is_setup = $this->getRootIndiId() === null; |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Returns is the Provider has been successfully set up |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function isSetup() { |
|
113 | + return $this->is_setup; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Return the root individual ID for the reference tree and user. |
|
118 | + * @return string Individual ID |
|
119 | + */ |
|
120 | + public function getRootIndiId() { |
|
121 | + return $this->tree->getUserPreference($this->user, 'MAJ_SOSA_ROOT_ID'); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Return the root individual for the reference tree and user. |
|
126 | + * @return Individual Individual |
|
127 | + */ |
|
128 | + public function getRootIndi() { |
|
129 | + $root_indi_id = $this->getRootIndiId(); |
|
130 | + if(!empty($root_indi_id)) { |
|
131 | + return Individual::getInstance($root_indi_id, $this->tree); |
|
132 | + } |
|
133 | + return null; |
|
134 | + } |
|
135 | 135 | |
136 | - /***************** |
|
136 | + /***************** |
|
137 | 137 | * DATA CRUD LAYER |
138 | 138 | *****************/ |
139 | 139 | |
140 | - /** |
|
141 | - * Remove all Sosa entries related to the gedcom file and user |
|
142 | - */ |
|
143 | - public function deleteAll() { |
|
144 | - if(!$this->is_setup) return; |
|
145 | - Database::prepare( |
|
146 | - 'DELETE FROM `##maj_sosa`'. |
|
147 | - ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
|
148 | - ->execute(array( |
|
149 | - 'tree_id' => $this->tree->getTreeId(), |
|
150 | - 'user_id' => $this->user->getUserId() |
|
151 | - )); |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Remove all ancestors of a sosa number |
|
156 | - * |
|
157 | - * @param int $sosa |
|
158 | - */ |
|
159 | - public function deleteAncestors($sosa) { |
|
160 | - if(!$this->is_setup) return; |
|
161 | - $gen = Functions::getGeneration($sosa); |
|
162 | - Database::prepare( |
|
163 | - 'DELETE FROM `##maj_sosa`'. |
|
164 | - ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' . |
|
165 | - ' AND majs_gen >= :gen' . |
|
166 | - ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa' |
|
167 | - )->execute(array( |
|
168 | - 'tree_id' => $this->tree->getTreeId(), |
|
169 | - 'user_id' => $this->user->getUserId(), |
|
170 | - 'gen' => $gen, |
|
171 | - 'sosa' => $sosa |
|
172 | - )); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Insert (or update if already existing) a list of Sosa individuals |
|
177 | - * @param array $sosa_records |
|
178 | - */ |
|
179 | - public function insertOrUpdate($sosa_records) { |
|
180 | - if(!$this->is_setup) return; |
|
140 | + /** |
|
141 | + * Remove all Sosa entries related to the gedcom file and user |
|
142 | + */ |
|
143 | + public function deleteAll() { |
|
144 | + if(!$this->is_setup) return; |
|
145 | + Database::prepare( |
|
146 | + 'DELETE FROM `##maj_sosa`'. |
|
147 | + ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
|
148 | + ->execute(array( |
|
149 | + 'tree_id' => $this->tree->getTreeId(), |
|
150 | + 'user_id' => $this->user->getUserId() |
|
151 | + )); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Remove all ancestors of a sosa number |
|
156 | + * |
|
157 | + * @param int $sosa |
|
158 | + */ |
|
159 | + public function deleteAncestors($sosa) { |
|
160 | + if(!$this->is_setup) return; |
|
161 | + $gen = Functions::getGeneration($sosa); |
|
162 | + Database::prepare( |
|
163 | + 'DELETE FROM `##maj_sosa`'. |
|
164 | + ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' . |
|
165 | + ' AND majs_gen >= :gen' . |
|
166 | + ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa' |
|
167 | + )->execute(array( |
|
168 | + 'tree_id' => $this->tree->getTreeId(), |
|
169 | + 'user_id' => $this->user->getUserId(), |
|
170 | + 'gen' => $gen, |
|
171 | + 'sosa' => $sosa |
|
172 | + )); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Insert (or update if already existing) a list of Sosa individuals |
|
177 | + * @param array $sosa_records |
|
178 | + */ |
|
179 | + public function insertOrUpdate($sosa_records) { |
|
180 | + if(!$this->is_setup) return; |
|
181 | 181 | |
182 | - $treeid = $this->tree->getTreeId(); |
|
183 | - $userid = $this->user->getUserId(); |
|
184 | - $questionmarks_table = array(); |
|
185 | - $values_table = array(); |
|
182 | + $treeid = $this->tree->getTreeId(); |
|
183 | + $userid = $this->user->getUserId(); |
|
184 | + $questionmarks_table = array(); |
|
185 | + $values_table = array(); |
|
186 | 186 | |
187 | - $i = 0; |
|
188 | - foreach ($sosa_records as $row) { |
|
189 | - $gen = Functions::getGeneration($row['sosa']); |
|
190 | - if($gen <= self::MAX_DB_GENERATIONS) { |
|
191 | - $questionmarks_table[] = |
|
192 | - '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')'; |
|
193 | - $values_table = array_merge( |
|
194 | - $values_table, |
|
195 | - array( |
|
196 | - 'tree_id'.$i => $treeid, |
|
197 | - 'user_id'.$i => $userid, |
|
198 | - 'sosa'.$i => $row['sosa'], |
|
199 | - 'indi_id'.$i => $row['indi'], |
|
200 | - 'gen'.$i => Functions::getGeneration($row['sosa']), |
|
201 | - 'byear'.$i => $row['birth_year'], |
|
202 | - 'dyear'.$i => $row['death_year'] |
|
203 | - ) |
|
204 | - ); |
|
205 | - } |
|
206 | - $i++; |
|
207 | - } |
|
187 | + $i = 0; |
|
188 | + foreach ($sosa_records as $row) { |
|
189 | + $gen = Functions::getGeneration($row['sosa']); |
|
190 | + if($gen <= self::MAX_DB_GENERATIONS) { |
|
191 | + $questionmarks_table[] = |
|
192 | + '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')'; |
|
193 | + $values_table = array_merge( |
|
194 | + $values_table, |
|
195 | + array( |
|
196 | + 'tree_id'.$i => $treeid, |
|
197 | + 'user_id'.$i => $userid, |
|
198 | + 'sosa'.$i => $row['sosa'], |
|
199 | + 'indi_id'.$i => $row['indi'], |
|
200 | + 'gen'.$i => Functions::getGeneration($row['sosa']), |
|
201 | + 'byear'.$i => $row['birth_year'], |
|
202 | + 'dyear'.$i => $row['death_year'] |
|
203 | + ) |
|
204 | + ); |
|
205 | + } |
|
206 | + $i++; |
|
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); |
|
212 | - Database::prepare($sql)->execute($values_table); |
|
213 | - } |
|
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 | + Database::prepare($sql)->execute($values_table); |
|
213 | + } |
|
214 | 214 | |
215 | - /**************** |
|
215 | + /**************** |
|
216 | 216 | * SIMPLE QUERIES |
217 | 217 | ****************/ |
218 | 218 | |
219 | - /** |
|
220 | - * Returns the list of Sosa numbers to which an individual is related. |
|
221 | - * Format: key = sosa number, value = generation for the Sosa number |
|
222 | - * |
|
223 | - * @param Individual $indi |
|
224 | - * @return array Array of sosa numbers |
|
225 | - */ |
|
226 | - public function getSosaNumbers(Individual $indi) { |
|
227 | - if(!$this->is_setup) return array(); |
|
228 | - return Database::prepare( |
|
229 | - 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
|
230 | - ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
|
231 | - )->execute(array( |
|
232 | - 'indi_id' => $indi->getXref(), |
|
233 | - 'tree_id' => $this->tree->getTreeId(), |
|
234 | - 'user_id' => $this->user->getUserId() |
|
235 | - ))->fetchAssoc(); |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * Get the last generation of Sosa ancestors |
|
240 | - * |
|
241 | - * @return number Last generation if found, 1 otherwise |
|
242 | - */ |
|
243 | - public function getLastGeneration() { |
|
244 | - if(!$this->is_setup) return; |
|
245 | - return Database::prepare( |
|
246 | - 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
|
247 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
|
248 | - )->execute(array( |
|
249 | - 'tree_id' => $this->tree->getTreeId(), |
|
250 | - 'user_id' => $this->user->getUserId() |
|
251 | - ))->fetchOne() ?: 1; |
|
252 | - } |
|
253 | - |
|
254 | - /************* |
|
219 | + /** |
|
220 | + * Returns the list of Sosa numbers to which an individual is related. |
|
221 | + * Format: key = sosa number, value = generation for the Sosa number |
|
222 | + * |
|
223 | + * @param Individual $indi |
|
224 | + * @return array Array of sosa numbers |
|
225 | + */ |
|
226 | + public function getSosaNumbers(Individual $indi) { |
|
227 | + if(!$this->is_setup) return array(); |
|
228 | + return Database::prepare( |
|
229 | + 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
|
230 | + ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
|
231 | + )->execute(array( |
|
232 | + 'indi_id' => $indi->getXref(), |
|
233 | + 'tree_id' => $this->tree->getTreeId(), |
|
234 | + 'user_id' => $this->user->getUserId() |
|
235 | + ))->fetchAssoc(); |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * Get the last generation of Sosa ancestors |
|
240 | + * |
|
241 | + * @return number Last generation if found, 1 otherwise |
|
242 | + */ |
|
243 | + public function getLastGeneration() { |
|
244 | + if(!$this->is_setup) return; |
|
245 | + return Database::prepare( |
|
246 | + 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
|
247 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
|
248 | + )->execute(array( |
|
249 | + 'tree_id' => $this->tree->getTreeId(), |
|
250 | + 'user_id' => $this->user->getUserId() |
|
251 | + ))->fetchOne() ?: 1; |
|
252 | + } |
|
253 | + |
|
254 | + /************* |
|
255 | 255 | * SOSA LISTS |
256 | 256 | *************/ |
257 | 257 | |
258 | - /** |
|
259 | - * Return the list of all sosas, with the generations it belongs to |
|
260 | - * |
|
261 | - * @return array Associative array of Sosa ancestors, with their generation, comma separated |
|
262 | - */ |
|
263 | - public function getAllSosaWithGenerations(){ |
|
264 | - if(!$this->is_setup) return array(); |
|
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' . |
|
270 | - ' GROUP BY majs_i_id' |
|
271 | - )->execute(array( |
|
272 | - 'tree_id' => $this->tree->getTreeId(), |
|
273 | - 'user_id' => $this->user->getUserId() |
|
274 | - ))->fetchAssoc(); |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Get an associative array of Sosa individuals in generation G. Keys are Sosa numbers, values individuals. |
|
279 | - * |
|
280 | - * @param number $gen Generation |
|
281 | - * @return array Array of Sosa individuals |
|
282 | - */ |
|
283 | - public function getSosaListAtGeneration($gen){ |
|
284 | - if(!$this->is_setup) return array(); |
|
285 | - if(!$this->sosa_list_by_gen) |
|
286 | - $this->sosa_list_by_gen = array(); |
|
258 | + /** |
|
259 | + * Return the list of all sosas, with the generations it belongs to |
|
260 | + * |
|
261 | + * @return array Associative array of Sosa ancestors, with their generation, comma separated |
|
262 | + */ |
|
263 | + public function getAllSosaWithGenerations(){ |
|
264 | + if(!$this->is_setup) return array(); |
|
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' . |
|
270 | + ' GROUP BY majs_i_id' |
|
271 | + )->execute(array( |
|
272 | + 'tree_id' => $this->tree->getTreeId(), |
|
273 | + 'user_id' => $this->user->getUserId() |
|
274 | + ))->fetchAssoc(); |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Get an associative array of Sosa individuals in generation G. Keys are Sosa numbers, values individuals. |
|
279 | + * |
|
280 | + * @param number $gen Generation |
|
281 | + * @return array Array of Sosa individuals |
|
282 | + */ |
|
283 | + public function getSosaListAtGeneration($gen){ |
|
284 | + if(!$this->is_setup) return array(); |
|
285 | + if(!$this->sosa_list_by_gen) |
|
286 | + $this->sosa_list_by_gen = array(); |
|
287 | 287 | |
288 | - if($gen){ |
|
289 | - if(!isset($this->sosa_list_by_gen[$gen])){ |
|
290 | - $this->sosa_list_by_gen[$gen] = Database::prepare( |
|
291 | - 'SELECT majs_sosa AS sosa, majs_i_id AS indi'. |
|
292 | - ' FROM `##maj_sosa`'. |
|
293 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
294 | - ' AND majs_gen = :gen'. |
|
295 | - ' ORDER BY majs_sosa ASC') |
|
296 | - ->execute(array( |
|
297 | - 'tree_id' => $this->tree->getTreeId(), |
|
298 | - 'user_id' => $this->user->getUserId(), |
|
299 | - 'gen' => $gen |
|
300 | - )) |
|
301 | - ->fetchAssoc(); |
|
302 | - } |
|
303 | - return $this->sosa_list_by_gen[$gen]; |
|
304 | - } |
|
305 | - return array(); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Get an associative array of Sosa families in generation G. Keys are Sosa numbers for the husband, values families. |
|
310 | - * |
|
311 | - * @param number $gen Generation |
|
312 | - * @return array Array of Sosa families |
|
313 | - */ |
|
314 | - public function getFamilySosaListAtGeneration($gen){ |
|
315 | - if(!$this->is_setup) return array(); |
|
316 | - if(!$this->sosa_fam_list_by_gen) |
|
317 | - $this->sosa_fam_list_by_gen = array(); |
|
288 | + if($gen){ |
|
289 | + if(!isset($this->sosa_list_by_gen[$gen])){ |
|
290 | + $this->sosa_list_by_gen[$gen] = Database::prepare( |
|
291 | + 'SELECT majs_sosa AS sosa, majs_i_id AS indi'. |
|
292 | + ' FROM `##maj_sosa`'. |
|
293 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
294 | + ' AND majs_gen = :gen'. |
|
295 | + ' ORDER BY majs_sosa ASC') |
|
296 | + ->execute(array( |
|
297 | + 'tree_id' => $this->tree->getTreeId(), |
|
298 | + 'user_id' => $this->user->getUserId(), |
|
299 | + 'gen' => $gen |
|
300 | + )) |
|
301 | + ->fetchAssoc(); |
|
302 | + } |
|
303 | + return $this->sosa_list_by_gen[$gen]; |
|
304 | + } |
|
305 | + return array(); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Get an associative array of Sosa families in generation G. Keys are Sosa numbers for the husband, values families. |
|
310 | + * |
|
311 | + * @param number $gen Generation |
|
312 | + * @return array Array of Sosa families |
|
313 | + */ |
|
314 | + public function getFamilySosaListAtGeneration($gen){ |
|
315 | + if(!$this->is_setup) return array(); |
|
316 | + if(!$this->sosa_fam_list_by_gen) |
|
317 | + $this->sosa_fam_list_by_gen = array(); |
|
318 | 318 | |
319 | - if($gen){ |
|
320 | - if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
|
321 | - $this->sosa_fam_list_by_gen[$gen] = Database::prepare( |
|
322 | - 'SELECT s1.majs_sosa AS sosa, f_id AS fam'. |
|
323 | - ' FROM `##families`'. |
|
324 | - ' INNER JOIN `##maj_sosa` AS s1 ON (`##families`.f_husb = s1.majs_i_id AND `##families`.f_file = s1.majs_gedcom_id)'. |
|
325 | - ' INNER JOIN `##maj_sosa` AS s2 ON (`##families`.f_wife = s2.majs_i_id AND `##families`.f_file = s2.majs_gedcom_id)'. |
|
326 | - ' WHERE s1.majs_sosa + 1 = s2.majs_sosa'. |
|
327 | - ' AND s1.majs_gedcom_id= :tree_id AND s1.majs_user_id=:user_id'. |
|
328 | - ' AND s2.majs_gedcom_id= :tree_id AND s2.majs_user_id=:user_id'. |
|
329 | - ' AND s1.majs_gen = :gen'. |
|
330 | - ' ORDER BY s1.majs_sosa ASC' |
|
331 | - ) |
|
332 | - ->execute(array( |
|
333 | - 'tree_id' => $this->tree->getTreeId(), |
|
334 | - 'user_id' => $this->user->getUserId(), |
|
335 | - 'gen' => $gen |
|
336 | - )) |
|
337 | - ->fetchAssoc(); |
|
338 | - } |
|
339 | - return $this->sosa_fam_list_by_gen[$gen]; |
|
340 | - } |
|
341 | - return array(); |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Get an associative array of Sosa individuals in generation G who are missing parents. Keys are Sosa numbers, values individuals. |
|
346 | - * |
|
347 | - * @param number $gen Generation |
|
348 | - * @return array Array of Sosa individuals |
|
349 | - */ |
|
350 | - public function getMissingSosaListAtGeneration($gen){ |
|
351 | - if(!$this->is_setup) return array(); |
|
352 | - if($gen){ |
|
353 | - return $this->sosa_list_by_gen[$gen] = Database::prepare( |
|
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 | - ' FROM `##maj_sosa` schild'. |
|
356 | - ' LEFT JOIN `##maj_sosa` sfat ON ((schild.majs_sosa * 2) = sfat.majs_sosa AND schild.majs_gedcom_id = sfat.majs_gedcom_id AND schild.majs_user_id = sfat.majs_user_id)'. |
|
357 | - ' LEFT JOIN `##maj_sosa` smot ON ((schild.majs_sosa * 2 + 1) = smot.majs_sosa AND schild.majs_gedcom_id = smot.majs_gedcom_id AND schild.majs_user_id = smot.majs_user_id)'. |
|
358 | - ' WHERE schild.majs_gedcom_id = :tree_id AND schild.majs_user_id = :user_id'. |
|
359 | - ' AND schild.majs_gen = :gen'. |
|
360 | - ' AND (sfat.majs_sosa IS NULL OR smot.majs_sosa IS NULL)'. |
|
361 | - ' ORDER BY schild.majs_sosa ASC') |
|
362 | - ->execute(array( |
|
363 | - 'tree_id' => $this->tree->getTreeId(), |
|
364 | - 'user_id' => $this->user->getUserId(), |
|
365 | - 'gen' => $gen - 1 |
|
366 | - ))->fetchAll(\PDO::FETCH_ASSOC); |
|
367 | - } |
|
368 | - return array(); |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - |
|
373 | - /************* |
|
319 | + if($gen){ |
|
320 | + if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
|
321 | + $this->sosa_fam_list_by_gen[$gen] = Database::prepare( |
|
322 | + 'SELECT s1.majs_sosa AS sosa, f_id AS fam'. |
|
323 | + ' FROM `##families`'. |
|
324 | + ' INNER JOIN `##maj_sosa` AS s1 ON (`##families`.f_husb = s1.majs_i_id AND `##families`.f_file = s1.majs_gedcom_id)'. |
|
325 | + ' INNER JOIN `##maj_sosa` AS s2 ON (`##families`.f_wife = s2.majs_i_id AND `##families`.f_file = s2.majs_gedcom_id)'. |
|
326 | + ' WHERE s1.majs_sosa + 1 = s2.majs_sosa'. |
|
327 | + ' AND s1.majs_gedcom_id= :tree_id AND s1.majs_user_id=:user_id'. |
|
328 | + ' AND s2.majs_gedcom_id= :tree_id AND s2.majs_user_id=:user_id'. |
|
329 | + ' AND s1.majs_gen = :gen'. |
|
330 | + ' ORDER BY s1.majs_sosa ASC' |
|
331 | + ) |
|
332 | + ->execute(array( |
|
333 | + 'tree_id' => $this->tree->getTreeId(), |
|
334 | + 'user_id' => $this->user->getUserId(), |
|
335 | + 'gen' => $gen |
|
336 | + )) |
|
337 | + ->fetchAssoc(); |
|
338 | + } |
|
339 | + return $this->sosa_fam_list_by_gen[$gen]; |
|
340 | + } |
|
341 | + return array(); |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Get an associative array of Sosa individuals in generation G who are missing parents. Keys are Sosa numbers, values individuals. |
|
346 | + * |
|
347 | + * @param number $gen Generation |
|
348 | + * @return array Array of Sosa individuals |
|
349 | + */ |
|
350 | + public function getMissingSosaListAtGeneration($gen){ |
|
351 | + if(!$this->is_setup) return array(); |
|
352 | + if($gen){ |
|
353 | + return $this->sosa_list_by_gen[$gen] = Database::prepare( |
|
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 | + ' FROM `##maj_sosa` schild'. |
|
356 | + ' LEFT JOIN `##maj_sosa` sfat ON ((schild.majs_sosa * 2) = sfat.majs_sosa AND schild.majs_gedcom_id = sfat.majs_gedcom_id AND schild.majs_user_id = sfat.majs_user_id)'. |
|
357 | + ' LEFT JOIN `##maj_sosa` smot ON ((schild.majs_sosa * 2 + 1) = smot.majs_sosa AND schild.majs_gedcom_id = smot.majs_gedcom_id AND schild.majs_user_id = smot.majs_user_id)'. |
|
358 | + ' WHERE schild.majs_gedcom_id = :tree_id AND schild.majs_user_id = :user_id'. |
|
359 | + ' AND schild.majs_gen = :gen'. |
|
360 | + ' AND (sfat.majs_sosa IS NULL OR smot.majs_sosa IS NULL)'. |
|
361 | + ' ORDER BY schild.majs_sosa ASC') |
|
362 | + ->execute(array( |
|
363 | + 'tree_id' => $this->tree->getTreeId(), |
|
364 | + 'user_id' => $this->user->getUserId(), |
|
365 | + 'gen' => $gen - 1 |
|
366 | + ))->fetchAll(\PDO::FETCH_ASSOC); |
|
367 | + } |
|
368 | + return array(); |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + |
|
373 | + /************* |
|
374 | 374 | * STATISTICS |
375 | 375 | *************/ |
376 | - /** |
|
377 | - * Get the statistic array detailed by generation. |
|
378 | - * Statistics for each generation are: |
|
379 | - * - The number of Sosa in generation |
|
380 | - * - The number of Sosa up to generation |
|
381 | - * - The number of distinct Sosa up to generation |
|
382 | - * - The year of the first birth in generation |
|
383 | - * - The year of the last birth in generation |
|
384 | - * - The average year of birth in generation |
|
385 | - * |
|
386 | - * @return array Statistics array |
|
387 | - */ |
|
388 | - public function getStatisticsByGeneration() { |
|
389 | - if(!$this->is_setup) return array(); |
|
390 | - if(!$this->statistics_tab) { |
|
391 | - $this->statistics_tab = array(); |
|
392 | - if($maxGeneration = $this->getLastGeneration()) { |
|
393 | - for ($gen = 1; $gen <= $maxGeneration; $gen++) { |
|
394 | - $birthStats = $this->getStatsBirthYearInGeneration($gen); |
|
395 | - $this->statistics_tab[$gen] = array( |
|
396 | - 'sosaCount' => $this->getSosaCountAtGeneration($gen), |
|
397 | - 'sosaTotalCount' => $this->getSosaCountUpToGeneration($gen), |
|
398 | - 'diffSosaTotalCount' => $this->getDifferentSosaCountUpToGeneration($gen), |
|
399 | - 'firstBirth' => $birthStats['first'], |
|
400 | - 'lastBirth' => $birthStats['last'], |
|
401 | - 'avgBirth' => $birthStats['avg'] |
|
402 | - ); |
|
403 | - } |
|
404 | - } |
|
405 | - } |
|
406 | - return $this->statistics_tab; |
|
407 | - } |
|
376 | + /** |
|
377 | + * Get the statistic array detailed by generation. |
|
378 | + * Statistics for each generation are: |
|
379 | + * - The number of Sosa in generation |
|
380 | + * - The number of Sosa up to generation |
|
381 | + * - The number of distinct Sosa up to generation |
|
382 | + * - The year of the first birth in generation |
|
383 | + * - The year of the last birth in generation |
|
384 | + * - The average year of birth in generation |
|
385 | + * |
|
386 | + * @return array Statistics array |
|
387 | + */ |
|
388 | + public function getStatisticsByGeneration() { |
|
389 | + if(!$this->is_setup) return array(); |
|
390 | + if(!$this->statistics_tab) { |
|
391 | + $this->statistics_tab = array(); |
|
392 | + if($maxGeneration = $this->getLastGeneration()) { |
|
393 | + for ($gen = 1; $gen <= $maxGeneration; $gen++) { |
|
394 | + $birthStats = $this->getStatsBirthYearInGeneration($gen); |
|
395 | + $this->statistics_tab[$gen] = array( |
|
396 | + 'sosaCount' => $this->getSosaCountAtGeneration($gen), |
|
397 | + 'sosaTotalCount' => $this->getSosaCountUpToGeneration($gen), |
|
398 | + 'diffSosaTotalCount' => $this->getDifferentSosaCountUpToGeneration($gen), |
|
399 | + 'firstBirth' => $birthStats['first'], |
|
400 | + 'lastBirth' => $birthStats['last'], |
|
401 | + 'avgBirth' => $birthStats['avg'] |
|
402 | + ); |
|
403 | + } |
|
404 | + } |
|
405 | + } |
|
406 | + return $this->statistics_tab; |
|
407 | + } |
|
408 | 408 | |
409 | 409 | /** |
410 | 410 | * How many individuals exist in the tree. |
@@ -412,205 +412,205 @@ discard block |
||
412 | 412 | * @return int |
413 | 413 | */ |
414 | 414 | public function getTotalIndividuals() { |
415 | - if(!$this->is_setup) return 0; |
|
416 | - return Database::prepare( |
|
417 | - 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' . |
|
418 | - ' WHERE i_file = :tree_id') |
|
419 | - ->execute(array('tree_id' => $this->tree->getTreeId())) |
|
420 | - ->fetchOne() ?: 0; |
|
415 | + if(!$this->is_setup) return 0; |
|
416 | + return Database::prepare( |
|
417 | + 'SELECT SQL_CACHE COUNT(*) FROM `##individuals`' . |
|
418 | + ' WHERE i_file = :tree_id') |
|
419 | + ->execute(array('tree_id' => $this->tree->getTreeId())) |
|
420 | + ->fetchOne() ?: 0; |
|
421 | 421 | } |
422 | 422 | |
423 | - /** |
|
424 | - * Get the total Sosa count for all generations |
|
425 | - * |
|
426 | - * @return number Number of Sosas |
|
427 | - */ |
|
428 | - public function getSosaCount(){ |
|
429 | - if(!$this->is_setup) return 0; |
|
430 | - return Database::prepare( |
|
431 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
432 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
|
433 | - ->execute(array( |
|
434 | - 'tree_id' => $this->tree->getTreeId(), |
|
435 | - 'user_id' => $this->user->getUserId() |
|
436 | - ))->fetchOne() ?: 0; |
|
437 | - } |
|
438 | - |
|
439 | - /** |
|
440 | - * Get the number of Sosa in a specific generation. |
|
441 | - * |
|
442 | - * @param number $gen Generation |
|
443 | - * @return number Number of Sosas in generation |
|
444 | - */ |
|
445 | - public function getSosaCountAtGeneration($gen){ |
|
446 | - if(!$this->is_setup) return 0; |
|
447 | - return Database::prepare( |
|
448 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
449 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
450 | - ' AND majs_gen= :gen') |
|
451 | - ->execute(array( |
|
452 | - 'tree_id' => $this->tree->getTreeId(), |
|
453 | - 'user_id' => $this->user->getUserId(), |
|
454 | - 'gen' => $gen |
|
455 | - ))->fetchOne() ?: 0; |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * Get the total number of Sosa up to a specific generation. |
|
460 | - * |
|
461 | - * @param number $gen Generation |
|
462 | - * @return number Total number of Sosas up to generation |
|
463 | - */ |
|
464 | - public function getSosaCountUpToGeneration($gen){ |
|
465 | - if(!$this->is_setup) return 0; |
|
466 | - return Database::prepare( |
|
467 | - 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
468 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
469 | - ' AND majs_gen <= :gen') |
|
470 | - ->execute(array( |
|
471 | - 'tree_id' => $this->tree->getTreeId(), |
|
472 | - 'user_id' => $this->user->getUserId(), |
|
473 | - 'gen' => $gen |
|
474 | - ))->fetchOne() ?: 0; |
|
475 | - } |
|
476 | - |
|
477 | - /** |
|
478 | - * Get the total number of distinct Sosa individual for all generations. |
|
479 | - * |
|
480 | - * @return number Total number of distinct individual |
|
481 | - */ |
|
482 | - public function getDifferentSosaCount(){ |
|
483 | - if(!$this->is_setup) return 0; |
|
484 | - return Database::prepare( |
|
485 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
486 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
|
487 | - ->execute(array( |
|
488 | - 'tree_id' => $this->tree->getTreeId(), |
|
489 | - 'user_id' => $this->user->getUserId() |
|
490 | - ))->fetchOne() ?: 0; |
|
491 | - } |
|
492 | - |
|
493 | - /** |
|
494 | - * Get the number of distinct Sosa individual up to a specific generation. |
|
495 | - * |
|
496 | - * @param number $gen Generation |
|
497 | - * @return number Number of distinct Sosa individuals up to generation |
|
498 | - */ |
|
499 | - public function getDifferentSosaCountUpToGeneration($gen){ |
|
500 | - if(!$this->is_setup) return 0; |
|
501 | - return Database::prepare( |
|
502 | - 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
503 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
504 | - ' AND majs_gen <= :gen') |
|
505 | - ->execute(array( |
|
506 | - 'tree_id' => $this->tree->getTreeId(), |
|
507 | - 'user_id' => $this->user->getUserId(), |
|
508 | - 'gen' => $gen |
|
509 | - ))->fetchOne() ?: 0; |
|
510 | - } |
|
511 | - |
|
512 | - /** |
|
513 | - * Get an array of birth statistics for a specific generation |
|
514 | - * Statistics are : |
|
515 | - * - first : First birth year in generation |
|
516 | - * - last : Last birth year in generation |
|
517 | - * - avg : Average birth year |
|
518 | - * |
|
519 | - * @param number $gen Generation |
|
520 | - * @return array Birth statistics array |
|
521 | - */ |
|
522 | - public function getStatsBirthYearInGeneration($gen){ |
|
523 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
524 | - return Database::prepare( |
|
525 | - 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
|
526 | - ' FROM `##maj_sosa`' . |
|
527 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
528 | - ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year') |
|
529 | - ->execute(array( |
|
530 | - 'tree_id' => $this->tree->getTreeId(), |
|
531 | - 'user_id' => $this->user->getUserId(), |
|
532 | - 'gen' => $gen, |
|
533 | - 'birth_year' => 0)) |
|
534 | - ->fetchOneRow(\PDO::FETCH_ASSOC) ?: array('first' => 0, 'avg' => 0, 'last' => 0); |
|
535 | - } |
|
536 | - |
|
537 | - /** |
|
538 | - * Get the mean generation time, based on a linear regression of birth years and generations |
|
539 | - * |
|
540 | - * @return number|NULL Mean generation time |
|
541 | - */ |
|
542 | - public function getMeanGenerationTime(){ |
|
543 | - if(!$this->is_setup) return; |
|
544 | - if(!$this->statistics_tab){ |
|
545 | - $this->getStatisticsByGeneration(); |
|
546 | - } |
|
547 | - //Linear regression on x=generation and y=birthdate |
|
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; |
|
558 | - } |
|
559 | - $denom=($n*$sum_x2)-($sum_x*$sum_x); |
|
560 | - if($denom!=0){ |
|
561 | - return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom); |
|
562 | - } |
|
563 | - return null; |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * Return a computed array of statistics about the dispersion of ancestors across the ancestors |
|
568 | - * at a specified generation. |
|
569 | - * This statistics cannot be used for generations above 11, as it would cause a out of range in MySQL |
|
570 | - * |
|
571 | - * Format: |
|
572 | - * - key : a base-2 representation of the ancestor at generation G for which exclusive ancestors have been found, |
|
573 | - * -1 is used for shared ancestors |
|
574 | - * For instance base2(0100) = base10(4) represent the maternal grand father |
|
575 | - * - values: number of ancestors exclusively in the ancestors of the ancestor in key |
|
576 | - * |
|
577 | - * For instance a result at generation 3 could be : |
|
578 | - * array ( -1 => 12 -> 12 ancestors are shared by the grand-parents |
|
579 | - * base10(1) => 32 -> 32 ancestors are exclusive to the paternal grand-father |
|
580 | - * base10(2) => 25 -> 25 ancestors are exclusive to the paternal grand-mother |
|
581 | - * base10(4) => 12 -> 12 ancestors are exclusive to the maternal grand-father |
|
582 | - * base10(8) => 30 -> 30 ancestors are exclusive to the maternal grand-mother |
|
583 | - * ) |
|
584 | - * |
|
585 | - * @param int $gen Reference generation |
|
586 | - * @return array |
|
587 | - */ |
|
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 |
|
590 | - return Database::prepare( |
|
591 | - 'SELECT branches, count(i_id)'. |
|
592 | - ' FROM ('. |
|
593 | - ' SELECT i_id,'. |
|
594 | - ' CASE'. |
|
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 |
|
597 | - ' END branches'. |
|
598 | - ' FROM ('. |
|
599 | - ' SELECT DISTINCT majs_i_id i_id,'. |
|
600 | - ' POW(2, FLOOR(majs_sosa / POW(2, (majs_gen - :gen))) - POW(2, :gen -1)) branch'. |
|
601 | - ' FROM `##maj_sosa`'. |
|
602 | - ' WHERE majs_gedcom_id = :tree_id AND majs_user_id = :user_id'. |
|
603 | - ' AND majs_gen >= :gen'. |
|
604 | - ' ) indistat'. |
|
605 | - ' GROUP BY i_id'. |
|
606 | - ') grouped'. |
|
607 | - ' GROUP BY branches') |
|
608 | - ->execute(array( |
|
609 | - 'tree_id' => $this->tree->getTreeId(), |
|
610 | - 'user_id' => $this->user->getUserId(), |
|
611 | - 'gen' => $gen |
|
612 | - ))->fetchAssoc() ?: array(); |
|
613 | - } |
|
423 | + /** |
|
424 | + * Get the total Sosa count for all generations |
|
425 | + * |
|
426 | + * @return number Number of Sosas |
|
427 | + */ |
|
428 | + public function getSosaCount(){ |
|
429 | + if(!$this->is_setup) return 0; |
|
430 | + return Database::prepare( |
|
431 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
432 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
|
433 | + ->execute(array( |
|
434 | + 'tree_id' => $this->tree->getTreeId(), |
|
435 | + 'user_id' => $this->user->getUserId() |
|
436 | + ))->fetchOne() ?: 0; |
|
437 | + } |
|
438 | + |
|
439 | + /** |
|
440 | + * Get the number of Sosa in a specific generation. |
|
441 | + * |
|
442 | + * @param number $gen Generation |
|
443 | + * @return number Number of Sosas in generation |
|
444 | + */ |
|
445 | + public function getSosaCountAtGeneration($gen){ |
|
446 | + if(!$this->is_setup) return 0; |
|
447 | + return Database::prepare( |
|
448 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
449 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
450 | + ' AND majs_gen= :gen') |
|
451 | + ->execute(array( |
|
452 | + 'tree_id' => $this->tree->getTreeId(), |
|
453 | + 'user_id' => $this->user->getUserId(), |
|
454 | + 'gen' => $gen |
|
455 | + ))->fetchOne() ?: 0; |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * Get the total number of Sosa up to a specific generation. |
|
460 | + * |
|
461 | + * @param number $gen Generation |
|
462 | + * @return number Total number of Sosas up to generation |
|
463 | + */ |
|
464 | + public function getSosaCountUpToGeneration($gen){ |
|
465 | + if(!$this->is_setup) return 0; |
|
466 | + return Database::prepare( |
|
467 | + 'SELECT SQL_CACHE COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
468 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
469 | + ' AND majs_gen <= :gen') |
|
470 | + ->execute(array( |
|
471 | + 'tree_id' => $this->tree->getTreeId(), |
|
472 | + 'user_id' => $this->user->getUserId(), |
|
473 | + 'gen' => $gen |
|
474 | + ))->fetchOne() ?: 0; |
|
475 | + } |
|
476 | + |
|
477 | + /** |
|
478 | + * Get the total number of distinct Sosa individual for all generations. |
|
479 | + * |
|
480 | + * @return number Total number of distinct individual |
|
481 | + */ |
|
482 | + public function getDifferentSosaCount(){ |
|
483 | + if(!$this->is_setup) return 0; |
|
484 | + return Database::prepare( |
|
485 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
486 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
|
487 | + ->execute(array( |
|
488 | + 'tree_id' => $this->tree->getTreeId(), |
|
489 | + 'user_id' => $this->user->getUserId() |
|
490 | + ))->fetchOne() ?: 0; |
|
491 | + } |
|
492 | + |
|
493 | + /** |
|
494 | + * Get the number of distinct Sosa individual up to a specific generation. |
|
495 | + * |
|
496 | + * @param number $gen Generation |
|
497 | + * @return number Number of distinct Sosa individuals up to generation |
|
498 | + */ |
|
499 | + public function getDifferentSosaCountUpToGeneration($gen){ |
|
500 | + if(!$this->is_setup) return 0; |
|
501 | + return Database::prepare( |
|
502 | + 'SELECT SQL_CACHE COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
503 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
504 | + ' AND majs_gen <= :gen') |
|
505 | + ->execute(array( |
|
506 | + 'tree_id' => $this->tree->getTreeId(), |
|
507 | + 'user_id' => $this->user->getUserId(), |
|
508 | + 'gen' => $gen |
|
509 | + ))->fetchOne() ?: 0; |
|
510 | + } |
|
511 | + |
|
512 | + /** |
|
513 | + * Get an array of birth statistics for a specific generation |
|
514 | + * Statistics are : |
|
515 | + * - first : First birth year in generation |
|
516 | + * - last : Last birth year in generation |
|
517 | + * - avg : Average birth year |
|
518 | + * |
|
519 | + * @param number $gen Generation |
|
520 | + * @return array Birth statistics array |
|
521 | + */ |
|
522 | + public function getStatsBirthYearInGeneration($gen){ |
|
523 | + if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
524 | + return Database::prepare( |
|
525 | + 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
|
526 | + ' FROM `##maj_sosa`' . |
|
527 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
528 | + ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year') |
|
529 | + ->execute(array( |
|
530 | + 'tree_id' => $this->tree->getTreeId(), |
|
531 | + 'user_id' => $this->user->getUserId(), |
|
532 | + 'gen' => $gen, |
|
533 | + 'birth_year' => 0)) |
|
534 | + ->fetchOneRow(\PDO::FETCH_ASSOC) ?: array('first' => 0, 'avg' => 0, 'last' => 0); |
|
535 | + } |
|
536 | + |
|
537 | + /** |
|
538 | + * Get the mean generation time, based on a linear regression of birth years and generations |
|
539 | + * |
|
540 | + * @return number|NULL Mean generation time |
|
541 | + */ |
|
542 | + public function getMeanGenerationTime(){ |
|
543 | + if(!$this->is_setup) return; |
|
544 | + if(!$this->statistics_tab){ |
|
545 | + $this->getStatisticsByGeneration(); |
|
546 | + } |
|
547 | + //Linear regression on x=generation and y=birthdate |
|
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; |
|
558 | + } |
|
559 | + $denom=($n*$sum_x2)-($sum_x*$sum_x); |
|
560 | + if($denom!=0){ |
|
561 | + return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom); |
|
562 | + } |
|
563 | + return null; |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Return a computed array of statistics about the dispersion of ancestors across the ancestors |
|
568 | + * at a specified generation. |
|
569 | + * This statistics cannot be used for generations above 11, as it would cause a out of range in MySQL |
|
570 | + * |
|
571 | + * Format: |
|
572 | + * - key : a base-2 representation of the ancestor at generation G for which exclusive ancestors have been found, |
|
573 | + * -1 is used for shared ancestors |
|
574 | + * For instance base2(0100) = base10(4) represent the maternal grand father |
|
575 | + * - values: number of ancestors exclusively in the ancestors of the ancestor in key |
|
576 | + * |
|
577 | + * For instance a result at generation 3 could be : |
|
578 | + * array ( -1 => 12 -> 12 ancestors are shared by the grand-parents |
|
579 | + * base10(1) => 32 -> 32 ancestors are exclusive to the paternal grand-father |
|
580 | + * base10(2) => 25 -> 25 ancestors are exclusive to the paternal grand-mother |
|
581 | + * base10(4) => 12 -> 12 ancestors are exclusive to the maternal grand-father |
|
582 | + * base10(8) => 30 -> 30 ancestors are exclusive to the maternal grand-mother |
|
583 | + * ) |
|
584 | + * |
|
585 | + * @param int $gen Reference generation |
|
586 | + * @return array |
|
587 | + */ |
|
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 |
|
590 | + return Database::prepare( |
|
591 | + 'SELECT branches, count(i_id)'. |
|
592 | + ' FROM ('. |
|
593 | + ' SELECT i_id,'. |
|
594 | + ' CASE'. |
|
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 |
|
597 | + ' END branches'. |
|
598 | + ' FROM ('. |
|
599 | + ' SELECT DISTINCT majs_i_id i_id,'. |
|
600 | + ' POW(2, FLOOR(majs_sosa / POW(2, (majs_gen - :gen))) - POW(2, :gen -1)) branch'. |
|
601 | + ' FROM `##maj_sosa`'. |
|
602 | + ' WHERE majs_gedcom_id = :tree_id AND majs_user_id = :user_id'. |
|
603 | + ' AND majs_gen >= :gen'. |
|
604 | + ' ) indistat'. |
|
605 | + ' GROUP BY i_id'. |
|
606 | + ') grouped'. |
|
607 | + ' GROUP BY branches') |
|
608 | + ->execute(array( |
|
609 | + 'tree_id' => $this->tree->getTreeId(), |
|
610 | + 'user_id' => $this->user->getUserId(), |
|
611 | + 'gen' => $gen |
|
612 | + ))->fetchAssoc() ?: array(); |
|
613 | + } |
|
614 | 614 | |
615 | 615 | |
616 | 616 | } |
@@ -431,8 +431,7 @@ discard block |
||
431 | 431 | ) { |
432 | 432 | $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
433 | 433 | } |
434 | - } |
|
435 | - else { |
|
434 | + } else { |
|
436 | 435 | $birth_dates[0]=new Date(''); |
437 | 436 | } |
438 | 437 | if ($death_dates = $person->getAllDeathDates()) { |
@@ -443,8 +442,7 @@ discard block |
||
443 | 442 | ) { |
444 | 443 | $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
445 | 444 | } |
446 | - } |
|
447 | - else { |
|
445 | + } else { |
|
448 | 446 | $death_dates[0] = new Date(''); |
449 | 447 | } |
450 | 448 | $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
@@ -36,70 +36,70 @@ discard block |
||
36 | 36 | */ |
37 | 37 | class SosaListController extends MvcController |
38 | 38 | { |
39 | - /** |
|
40 | - * Sosa Provider for the controller |
|
41 | - * @var SosaProvider $sosa_provider |
|
42 | - */ |
|
43 | - protected $sosa_provider; |
|
39 | + /** |
|
40 | + * Sosa Provider for the controller |
|
41 | + * @var SosaProvider $sosa_provider |
|
42 | + */ |
|
43 | + protected $sosa_provider; |
|
44 | 44 | |
45 | - /** |
|
46 | - * Generation used for the controller |
|
47 | - * @var int $generation |
|
48 | - */ |
|
49 | - protected $generation; |
|
45 | + /** |
|
46 | + * Generation used for the controller |
|
47 | + * @var int $generation |
|
48 | + */ |
|
49 | + protected $generation; |
|
50 | 50 | |
51 | - /** |
|
52 | - * ViewBag to hold data for the controller |
|
53 | - * @var ViewBag $view_bag |
|
54 | - */ |
|
55 | - protected $view_bag; |
|
51 | + /** |
|
52 | + * ViewBag to hold data for the controller |
|
53 | + * @var ViewBag $view_bag |
|
54 | + */ |
|
55 | + protected $view_bag; |
|
56 | 56 | |
57 | - /** |
|
58 | - * {@inheritDoc} |
|
59 | - * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module) |
|
60 | - */ |
|
61 | - public function __construct(AbstractModule $module) { |
|
62 | - global $WT_TREE; |
|
57 | + /** |
|
58 | + * {@inheritDoc} |
|
59 | + * @see \MyArtJaub\Webtrees\Mvc\Controller\MvcController::__construct(AbstractModule $module) |
|
60 | + */ |
|
61 | + public function __construct(AbstractModule $module) { |
|
62 | + global $WT_TREE; |
|
63 | 63 | |
64 | - parent::__construct($module); |
|
64 | + parent::__construct($module); |
|
65 | 65 | |
66 | - $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
66 | + $this->sosa_provider = new SosaProvider($WT_TREE, Auth::user()); |
|
67 | 67 | |
68 | - $this->generation = Filter::getInteger('gen'); |
|
68 | + $this->generation = Filter::getInteger('gen'); |
|
69 | 69 | |
70 | - $this->view_bag = new ViewBag(); |
|
71 | - $this->view_bag->set('generation', $this->generation); |
|
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); |
|
70 | + $this->view_bag = new ViewBag(); |
|
71 | + $this->view_bag->set('generation', $this->generation); |
|
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); |
|
74 | 74 | |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * Pages |
|
80 | - */ |
|
78 | + /** |
|
79 | + * Pages |
|
80 | + */ |
|
81 | 81 | |
82 | - /** |
|
83 | - * SosaList@index |
|
84 | - */ |
|
85 | - public function index() { |
|
86 | - global $WT_TREE; |
|
82 | + /** |
|
83 | + * SosaList@index |
|
84 | + */ |
|
85 | + public function index() { |
|
86 | + global $WT_TREE; |
|
87 | 87 | |
88 | - $controller = new PageController(); |
|
89 | - $controller |
|
90 | - ->setPageTitle(I18N::translate('Sosa Ancestors')); |
|
88 | + $controller = new PageController(); |
|
89 | + $controller |
|
90 | + ->setPageTitle(I18N::translate('Sosa Ancestors')); |
|
91 | 91 | |
92 | - $this->view_bag->set('title', $controller->getPageTitle()); |
|
92 | + $this->view_bag->set('title', $controller->getPageTitle()); |
|
93 | 93 | |
94 | - if($this->view_bag->get('is_setup', false)) { |
|
95 | - $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
|
96 | - $this->view_bag->set('url_module', $this->module->getName()); |
|
97 | - $this->view_bag->set('url_action', 'SosaList'); |
|
98 | - $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
99 | - $this->view_bag->set('min_gen', 1); |
|
94 | + if($this->view_bag->get('is_setup', false)) { |
|
95 | + $this->view_bag->set('has_sosa', $this->generation > 0 && $this->sosa_provider->getSosaCountAtGeneration($this->generation) > 0); |
|
96 | + $this->view_bag->set('url_module', $this->module->getName()); |
|
97 | + $this->view_bag->set('url_action', 'SosaList'); |
|
98 | + $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
99 | + $this->view_bag->set('min_gen', 1); |
|
100 | 100 | |
101 | - if($this->view_bag->get('has_sosa', false)) { |
|
102 | - $controller->addInlineJavascript(' |
|
101 | + if($this->view_bag->get('has_sosa', false)) { |
|
102 | + $controller->addInlineJavascript(' |
|
103 | 103 | jQuery("#sosalist-tabs").tabs(); |
104 | 104 | jQuery("#sosalist-tabs").css("visibility", "visible"); |
105 | 105 | |
@@ -153,44 +153,44 @@ discard block |
||
153 | 153 | ); |
154 | 154 | |
155 | 155 | '); |
156 | - } |
|
157 | - } |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render(); |
|
160 | - } |
|
159 | + ViewFactory::make('SosaList', $this, $controller, $this->view_bag)->render(); |
|
160 | + } |
|
161 | 161 | |
162 | 162 | |
163 | - /** |
|
164 | - * SosaList@missing |
|
165 | - */ |
|
166 | - public function missing() { |
|
167 | - global $WT_TREE; |
|
163 | + /** |
|
164 | + * SosaList@missing |
|
165 | + */ |
|
166 | + public function missing() { |
|
167 | + global $WT_TREE; |
|
168 | 168 | |
169 | - $controller = new PageController(); |
|
170 | - $controller |
|
171 | - ->setPageTitle(I18N::translate('Missing Ancestors')); |
|
169 | + $controller = new PageController(); |
|
170 | + $controller |
|
171 | + ->setPageTitle(I18N::translate('Missing Ancestors')); |
|
172 | 172 | |
173 | - $this->view_bag->set('title', $controller->getPageTitle()); |
|
173 | + $this->view_bag->set('title', $controller->getPageTitle()); |
|
174 | 174 | |
175 | - if($this->view_bag->get('is_setup', false)) { |
|
176 | - $this->view_bag->set('url_module', $this->module->getName()); |
|
177 | - $this->view_bag->set('url_action', 'SosaList@missing'); |
|
178 | - $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
179 | - $this->view_bag->set('min_gen', 2); |
|
175 | + if($this->view_bag->get('is_setup', false)) { |
|
176 | + $this->view_bag->set('url_module', $this->module->getName()); |
|
177 | + $this->view_bag->set('url_action', 'SosaList@missing'); |
|
178 | + $this->view_bag->set('url_ged', $WT_TREE->getNameUrl()); |
|
179 | + $this->view_bag->set('min_gen', 2); |
|
180 | 180 | |
181 | - $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
|
182 | - $this->view_bag->set('has_missing', $this->generation > 0 && count($missing_list) > 0); |
|
181 | + $missing_list = $this->sosa_provider->getMissingSosaListAtGeneration($this->generation); |
|
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)); |
|
185 | - $this->view_bag->set('perc_sosa', $perc_sosa); |
|
184 | + $perc_sosa = Functions::safeDivision($this->sosa_provider->getSosaCountAtGeneration($this->generation), pow(2, $this->generation -1)); |
|
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(); |
|
189 | - $this->view_bag->set('table_id', $table_id); |
|
187 | + if($this->view_bag->get('has_missing', false)) { |
|
188 | + $table_id = 'table-sosa-missing-' . Uuid::uuid4(); |
|
189 | + $this->view_bag->set('table_id', $table_id); |
|
190 | 190 | |
191 | - $controller |
|
192 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
193 | - ->addInlineJavascript(' |
|
191 | + $controller |
|
192 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
193 | + ->addInlineJavascript(' |
|
194 | 194 | /* Initialise datatables */ |
195 | 195 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
196 | 196 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
@@ -250,77 +250,77 @@ discard block |
||
250 | 250 | jQuery(".loading-image").css("display", "none"); |
251 | 251 | '); |
252 | 252 | |
253 | - $unique_indis = array(); |
|
254 | - $sum_missing_different = 0; |
|
255 | - $sum_missing_different_without_hidden = 0; |
|
256 | - foreach($missing_list as $num => $missing_tab) { |
|
257 | - if(isset($unique_indis[$missing_tab['indi']])) { |
|
258 | - unset($missing_list[$num]); |
|
259 | - continue; |
|
260 | - } |
|
261 | - $sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
262 | - $person = Individual::getInstance($missing_tab['indi'], $WT_TREE); |
|
263 | - if (!$person || !$person->canShowName()) { |
|
264 | - unset($missing_list[$num]); |
|
265 | - continue; |
|
266 | - } |
|
267 | - $sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
268 | - $unique_indis[$person->getXref()] = true; |
|
269 | - $missing_tab['indi'] = $person; |
|
270 | - $missing_list[$num] = $missing_tab; |
|
271 | - } |
|
272 | - $this->view_bag->set('missing_list', $missing_list); |
|
273 | - $this->view_bag->set('missing_diff_count', $sum_missing_different); |
|
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)); |
|
276 | - $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential); |
|
277 | - } |
|
278 | - } |
|
253 | + $unique_indis = array(); |
|
254 | + $sum_missing_different = 0; |
|
255 | + $sum_missing_different_without_hidden = 0; |
|
256 | + foreach($missing_list as $num => $missing_tab) { |
|
257 | + if(isset($unique_indis[$missing_tab['indi']])) { |
|
258 | + unset($missing_list[$num]); |
|
259 | + continue; |
|
260 | + } |
|
261 | + $sum_missing_different += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
262 | + $person = Individual::getInstance($missing_tab['indi'], $WT_TREE); |
|
263 | + if (!$person || !$person->canShowName()) { |
|
264 | + unset($missing_list[$num]); |
|
265 | + continue; |
|
266 | + } |
|
267 | + $sum_missing_different_without_hidden += !$missing_tab['has_father'] + !$missing_tab['has_mother']; |
|
268 | + $unique_indis[$person->getXref()] = true; |
|
269 | + $missing_tab['indi'] = $person; |
|
270 | + $missing_list[$num] = $missing_tab; |
|
271 | + } |
|
272 | + $this->view_bag->set('missing_list', $missing_list); |
|
273 | + $this->view_bag->set('missing_diff_count', $sum_missing_different); |
|
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)); |
|
276 | + $this->view_bag->set('perc_sosa_potential', $perc_sosa_potential); |
|
277 | + } |
|
278 | + } |
|
279 | 279 | |
280 | - ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render(); |
|
281 | - } |
|
280 | + ViewFactory::make('SosaListMissing', $this, $controller, $this->view_bag)->render(); |
|
281 | + } |
|
282 | 282 | |
283 | - /** |
|
284 | - * SosaList@sosalist |
|
285 | - */ |
|
286 | - public function sosalist() { |
|
283 | + /** |
|
284 | + * SosaList@sosalist |
|
285 | + */ |
|
286 | + public function sosalist() { |
|
287 | 287 | |
288 | - $type = Filter::get('type', 'indi|fam', null); |
|
288 | + $type = Filter::get('type', 'indi|fam', null); |
|
289 | 289 | |
290 | - $controller = new AjaxController(); |
|
291 | - $controller->restrictAccess($this->generation > 0 || !is_null($type)); |
|
290 | + $controller = new AjaxController(); |
|
291 | + $controller->restrictAccess($this->generation > 0 || !is_null($type)); |
|
292 | 292 | |
293 | - switch ($type){ |
|
294 | - case 'indi': |
|
295 | - $this->renderSosaListIndi($controller); |
|
296 | - break; |
|
297 | - case 'fam': |
|
298 | - $this->renderFamSosaListIndi($controller); |
|
299 | - break; |
|
300 | - default: |
|
301 | - break; |
|
302 | - } |
|
293 | + switch ($type){ |
|
294 | + case 'indi': |
|
295 | + $this->renderSosaListIndi($controller); |
|
296 | + break; |
|
297 | + case 'fam': |
|
298 | + $this->renderFamSosaListIndi($controller); |
|
299 | + break; |
|
300 | + default: |
|
301 | + break; |
|
302 | + } |
|
303 | 303 | |
304 | - } |
|
304 | + } |
|
305 | 305 | |
306 | - /** |
|
307 | - * Render the Ajax response for the sortable table of Sosa individuals |
|
308 | - * @param AjaxController $controller |
|
309 | - */ |
|
310 | - protected function renderSosaListIndi(AjaxController $controller) { |
|
311 | - global $WT_TREE; |
|
306 | + /** |
|
307 | + * Render the Ajax response for the sortable table of Sosa individuals |
|
308 | + * @param AjaxController $controller |
|
309 | + */ |
|
310 | + protected function renderSosaListIndi(AjaxController $controller) { |
|
311 | + global $WT_TREE; |
|
312 | 312 | |
313 | - $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); |
|
314 | - $this->view_bag->set('has_sosa', false); |
|
313 | + $listSosa = $this->sosa_provider->getSosaListAtGeneration($this->generation); |
|
314 | + $this->view_bag->set('has_sosa', false); |
|
315 | 315 | |
316 | - if(count($listSosa) > 0) { |
|
317 | - $this->view_bag->set('has_sosa', true); |
|
318 | - $table_id = 'table-sosa-indi-' . Uuid::uuid4(); |
|
319 | - $this->view_bag->set('table_id', $table_id); |
|
316 | + if(count($listSosa) > 0) { |
|
317 | + $this->view_bag->set('has_sosa', true); |
|
318 | + $table_id = 'table-sosa-indi-' . Uuid::uuid4(); |
|
319 | + $this->view_bag->set('table_id', $table_id); |
|
320 | 320 | |
321 | - $controller |
|
322 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
323 | - ->addInlineJavascript(' |
|
321 | + $controller |
|
322 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
323 | + ->addInlineJavascript(' |
|
324 | 324 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
325 | 325 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
326 | 326 | jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);}; |
@@ -396,96 +396,96 @@ discard block |
||
396 | 396 | jQuery("#btn-toggle-statistics-'.$table_id.'").click(); |
397 | 397 | '); |
398 | 398 | |
399 | - $stats = new Stats($WT_TREE); |
|
399 | + $stats = new Stats($WT_TREE); |
|
400 | 400 | |
401 | - // Bad data can cause "longest life" to be huge, blowing memory limits |
|
402 | - $max_age = min($WT_TREE->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1; |
|
403 | - // Inititialise chart data |
|
404 | - $deat_by_age = array(); |
|
405 | - for ($age = 0; $age <= $max_age; $age++) { |
|
406 | - $deat_by_age[$age] = ''; |
|
407 | - } |
|
408 | - $birt_by_decade = array(); |
|
409 | - $deat_by_decade = array(); |
|
410 | - for ($year = 1550; $year < 2030; $year += 10) { |
|
411 | - $birt_by_decade[$year] = ''; |
|
412 | - $deat_by_decade[$year] = ''; |
|
413 | - } |
|
401 | + // Bad data can cause "longest life" to be huge, blowing memory limits |
|
402 | + $max_age = min($WT_TREE->getPreference('MAX_ALIVE_AGE'), $stats->LongestLifeAge()) + 1; |
|
403 | + // Inititialise chart data |
|
404 | + $deat_by_age = array(); |
|
405 | + for ($age = 0; $age <= $max_age; $age++) { |
|
406 | + $deat_by_age[$age] = ''; |
|
407 | + } |
|
408 | + $birt_by_decade = array(); |
|
409 | + $deat_by_decade = array(); |
|
410 | + for ($year = 1550; $year < 2030; $year += 10) { |
|
411 | + $birt_by_decade[$year] = ''; |
|
412 | + $deat_by_decade[$year] = ''; |
|
413 | + } |
|
414 | 414 | |
415 | - $unique_indis = array(); // Don't double-count indis with multiple names. |
|
416 | - $nb_displayed = 0; |
|
415 | + $unique_indis = array(); // Don't double-count indis with multiple names. |
|
416 | + $nb_displayed = 0; |
|
417 | 417 | |
418 | - Individual::load($WT_TREE, $listSosa); |
|
419 | - foreach($listSosa as $sosa => $pid) { |
|
420 | - $person = Individual::getInstance($pid, $WT_TREE); |
|
421 | - if (!$person || !$person->canShowName()) { |
|
422 | - unset($listSosa[$sosa]); |
|
423 | - continue; |
|
424 | - } |
|
425 | - $nb_displayed++; |
|
426 | - if ($birth_dates=$person->getAllBirthDates()) { |
|
427 | - if ( |
|
428 | - FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
|
429 | - !isset($unique_indis[$person->getXref()]) |
|
430 | - ) { |
|
431 | - $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
432 | - } |
|
433 | - } |
|
434 | - else { |
|
435 | - $birth_dates[0]=new Date(''); |
|
436 | - } |
|
437 | - if ($death_dates = $person->getAllDeathDates()) { |
|
438 | - if ( |
|
439 | - FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
|
440 | - !isset($unique_indis[$person->getXref()]) |
|
441 | - ) { |
|
442 | - $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
443 | - } |
|
444 | - } |
|
445 | - else { |
|
446 | - $death_dates[0] = new Date(''); |
|
447 | - } |
|
448 | - $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
449 | - if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) { |
|
450 | - $deat_by_age[$age] .= $person->getSex(); |
|
451 | - } |
|
452 | - $listSosa[$sosa] = $person; |
|
453 | - $unique_indis[$person->getXref()] = true; |
|
454 | - } |
|
455 | - $this->view_bag->set('sosa_list', $listSosa); |
|
418 | + Individual::load($WT_TREE, $listSosa); |
|
419 | + foreach($listSosa as $sosa => $pid) { |
|
420 | + $person = Individual::getInstance($pid, $WT_TREE); |
|
421 | + if (!$person || !$person->canShowName()) { |
|
422 | + unset($listSosa[$sosa]); |
|
423 | + continue; |
|
424 | + } |
|
425 | + $nb_displayed++; |
|
426 | + if ($birth_dates=$person->getAllBirthDates()) { |
|
427 | + if ( |
|
428 | + FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
|
429 | + !isset($unique_indis[$person->getXref()]) |
|
430 | + ) { |
|
431 | + $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
432 | + } |
|
433 | + } |
|
434 | + else { |
|
435 | + $birth_dates[0]=new Date(''); |
|
436 | + } |
|
437 | + if ($death_dates = $person->getAllDeathDates()) { |
|
438 | + if ( |
|
439 | + FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
|
440 | + !isset($unique_indis[$person->getXref()]) |
|
441 | + ) { |
|
442 | + $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
443 | + } |
|
444 | + } |
|
445 | + else { |
|
446 | + $death_dates[0] = new Date(''); |
|
447 | + } |
|
448 | + $age = Date::getAge($birth_dates[0], $death_dates[0], 0); |
|
449 | + if (!isset($unique_indis[$person->getXref()]) && $age >= 0 && $age <= $max_age) { |
|
450 | + $deat_by_age[$age] .= $person->getSex(); |
|
451 | + } |
|
452 | + $listSosa[$sosa] = $person; |
|
453 | + $unique_indis[$person->getXref()] = true; |
|
454 | + } |
|
455 | + $this->view_bag->set('sosa_list', $listSosa); |
|
456 | 456 | |
457 | - $this->view_bag->set('sosa_count', count($listSosa)); |
|
458 | - $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
459 | - $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
|
457 | + $this->view_bag->set('sosa_count', count($listSosa)); |
|
458 | + $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
459 | + $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
|
460 | 460 | |
461 | - $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
|
461 | + $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
|
462 | 462 | |
463 | - $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
464 | - $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death'))); |
|
465 | - $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year'))); |
|
466 | - } |
|
463 | + $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
464 | + $this->view_bag->set('chart_deaths', FunctionsPrintLists::chartByDecade($deat_by_decade, I18N::translate('Decade of death'))); |
|
465 | + $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($deat_by_age, I18N::translate('Age related to death year'))); |
|
466 | + } |
|
467 | 467 | |
468 | - ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render(); |
|
469 | - } |
|
468 | + ViewFactory::make('SosaListIndi', $this, $controller, $this->view_bag)->render(); |
|
469 | + } |
|
470 | 470 | |
471 | - /** |
|
472 | - * Render the Ajax response for the sortable table of Sosa family |
|
473 | - * @param AjaxController $controller |
|
474 | - */ |
|
475 | - protected function renderFamSosaListIndi(AjaxController $controller) { |
|
476 | - global $WT_TREE; |
|
471 | + /** |
|
472 | + * Render the Ajax response for the sortable table of Sosa family |
|
473 | + * @param AjaxController $controller |
|
474 | + */ |
|
475 | + protected function renderFamSosaListIndi(AjaxController $controller) { |
|
476 | + global $WT_TREE; |
|
477 | 477 | |
478 | - $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
479 | - $this->view_bag->set('has_sosa', false); |
|
478 | + $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
479 | + $this->view_bag->set('has_sosa', false); |
|
480 | 480 | |
481 | - if(count($listFamSosa) > 0) { |
|
482 | - $this->view_bag->set('has_sosa', true); |
|
483 | - $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
484 | - $this->view_bag->set('table_id', $table_id); |
|
481 | + if(count($listFamSosa) > 0) { |
|
482 | + $this->view_bag->set('has_sosa', true); |
|
483 | + $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
484 | + $this->view_bag->set('table_id', $table_id); |
|
485 | 485 | |
486 | - $controller |
|
487 | - ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
488 | - ->addInlineJavascript(' |
|
486 | + $controller |
|
487 | + ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) |
|
488 | + ->addInlineJavascript(' |
|
489 | 489 | jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))}; |
490 | 490 | jQuery.fn.dataTableExt.oSort["unicode-desc" ]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))}; |
491 | 491 | jQuery.fn.dataTableExt.oSort["num-html-asc" ]=function(a,b) {a=parseFloat(a.replace(/<[^<]*>/, "")); b=parseFloat(b.replace(/<[^<]*>/, "")); return (a<b) ? -1 : (a>b ? 1 : 0);}; |
@@ -561,67 +561,67 @@ discard block |
||
561 | 561 | jQuery("#btn-toggle-statistics-'.$table_id.'").click(); |
562 | 562 | '); |
563 | 563 | |
564 | - $stats = new Stats($WT_TREE); |
|
565 | - $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; |
|
564 | + $stats = new Stats($WT_TREE); |
|
565 | + $max_age = max($stats->oldestMarriageMaleAge(), $stats->oldestMarriageFemaleAge()) + 1; |
|
566 | 566 | |
567 | - //-- init chart data |
|
568 | - $marr_by_age = array(); |
|
569 | - for ($age=0; $age<=$max_age; $age++) { |
|
570 | - $marr_by_age[$age] = ''; |
|
571 | - } |
|
572 | - $birt_by_decade = array(); |
|
573 | - $marr_by_decade = array(); |
|
574 | - for ($year=1550; $year<2030; $year+=10) { |
|
575 | - $birt_by_decade[$year] = ''; |
|
576 | - $marr_by_decade[$year] = ''; |
|
577 | - } |
|
567 | + //-- init chart data |
|
568 | + $marr_by_age = array(); |
|
569 | + for ($age=0; $age<=$max_age; $age++) { |
|
570 | + $marr_by_age[$age] = ''; |
|
571 | + } |
|
572 | + $birt_by_decade = array(); |
|
573 | + $marr_by_decade = array(); |
|
574 | + for ($year=1550; $year<2030; $year+=10) { |
|
575 | + $birt_by_decade[$year] = ''; |
|
576 | + $marr_by_decade[$year] = ''; |
|
577 | + } |
|
578 | 578 | |
579 | - foreach($listFamSosa as $sosa => $fid) { |
|
580 | - $sfamily = Family::getInstance($fid, $WT_TREE); |
|
581 | - if(!$sfamily || !$sfamily->canShow()) { |
|
582 | - unset($sfamily[$sosa]); |
|
583 | - continue; |
|
584 | - } |
|
585 | - $mdate=$sfamily->getMarriageDate(); |
|
579 | + foreach($listFamSosa as $sosa => $fid) { |
|
580 | + $sfamily = Family::getInstance($fid, $WT_TREE); |
|
581 | + if(!$sfamily || !$sfamily->canShow()) { |
|
582 | + unset($sfamily[$sosa]); |
|
583 | + continue; |
|
584 | + } |
|
585 | + $mdate=$sfamily->getMarriageDate(); |
|
586 | 586 | |
587 | - if( ($husb = $sfamily->getHusband()) && |
|
588 | - ($hdate = $husb->getBirthDate()) && |
|
589 | - $hdate->isOK() && $mdate->isOK()) { |
|
590 | - if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
|
591 | - $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
592 | - } |
|
593 | - $hage = Date::getAge($hdate, $mdate, 0); |
|
594 | - if ($hage >= 0 && $hage <= $max_age) { |
|
595 | - $marr_by_age[$hage] .= $husb->getSex(); |
|
596 | - } |
|
597 | - } |
|
587 | + if( ($husb = $sfamily->getHusband()) && |
|
588 | + ($hdate = $husb->getBirthDate()) && |
|
589 | + $hdate->isOK() && $mdate->isOK()) { |
|
590 | + if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
|
591 | + $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
592 | + } |
|
593 | + $hage = Date::getAge($hdate, $mdate, 0); |
|
594 | + if ($hage >= 0 && $hage <= $max_age) { |
|
595 | + $marr_by_age[$hage] .= $husb->getSex(); |
|
596 | + } |
|
597 | + } |
|
598 | 598 | |
599 | - if(($wife = $sfamily->getWife()) && |
|
600 | - ($wdate=$wife->getBirthDate()) && |
|
601 | - $wdate->isOK() && $mdate->isOK()) { |
|
602 | - if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
|
603 | - $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
604 | - } |
|
605 | - $wage = Date::getAge($wdate, $mdate, 0); |
|
606 | - if ($wage >= 0 && $wage <= $max_age) { |
|
607 | - $marr_by_age[$wage] .= $wife->getSex(); |
|
608 | - } |
|
609 | - } |
|
599 | + if(($wife = $sfamily->getWife()) && |
|
600 | + ($wdate=$wife->getBirthDate()) && |
|
601 | + $wdate->isOK() && $mdate->isOK()) { |
|
602 | + if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
|
603 | + $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
604 | + } |
|
605 | + $wage = Date::getAge($wdate, $mdate, 0); |
|
606 | + if ($wage >= 0 && $wage <= $max_age) { |
|
607 | + $marr_by_age[$wage] .= $wife->getSex(); |
|
608 | + } |
|
609 | + } |
|
610 | 610 | |
611 | - if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
|
612 | - $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
613 | - } |
|
611 | + if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
|
612 | + $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
613 | + } |
|
614 | 614 | |
615 | - $listFamSosa[$sosa] = $sfamily; |
|
616 | - } |
|
617 | - $this->view_bag->set('sosa_list', $listFamSosa); |
|
615 | + $listFamSosa[$sosa] = $sfamily; |
|
616 | + } |
|
617 | + $this->view_bag->set('sosa_list', $listFamSosa); |
|
618 | 618 | |
619 | - $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
620 | - $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage'))); |
|
621 | - $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage'))); |
|
622 | - } |
|
619 | + $this->view_bag->set('chart_births', FunctionsPrintLists::chartByDecade($birt_by_decade, I18N::translate('Decade of birth'))); |
|
620 | + $this->view_bag->set('chart_marriages', FunctionsPrintLists::chartByDecade($marr_by_decade, I18N::translate('Decade of marriage'))); |
|
621 | + $this->view_bag->set('chart_ages', FunctionsPrintLists::chartByAge($marr_by_age, I18N::translate('Age in year of marriage'))); |
|
622 | + } |
|
623 | 623 | |
624 | - ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render(); |
|
625 | - } |
|
624 | + ViewFactory::make('SosaListFam', $this, $controller, $this->view_bag)->render(); |
|
625 | + } |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | \ No newline at end of file |
@@ -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 |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | 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);}; |
199 | 199 | |
200 | 200 | jQuery("#'.$table_id.'").dataTable( { |
201 | - dom: \'<"H"<"filtersH_' . $table_id . '">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
201 | + dom: \'<"H"<"filtersH_' . $table_id.'">T<"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
202 | 202 | '.I18N::datatablesI18N().', |
203 | 203 | jQueryUI: true, |
204 | 204 | autoWidth:false, |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | pagingType: "full_numbers" |
230 | 230 | }); |
231 | 231 | |
232 | - jQuery("#' . $table_id . '") |
|
232 | + jQuery("#' . $table_id.'") |
|
233 | 233 | /* Filter buttons in table header */ |
234 | 234 | .on("click", "button[data-filter-column]", function() { |
235 | 235 | var btn = jQuery(this); |
236 | 236 | // De-activate the other buttons in this button group |
237 | 237 | btn.siblings().removeClass("ui-state-active"); |
238 | 238 | // Apply (or clear) this filter |
239 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
239 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
240 | 240 | if (btn.hasClass("ui-state-active")) { |
241 | 241 | btn.removeClass("ui-state-active"); |
242 | 242 | 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,30 +416,30 @@ 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 | 428 | FunctionsPrint::isDateWithinChartsRange($birth_dates[0]) && |
429 | 429 | !isset($unique_indis[$person->getXref()]) |
430 | 430 | ) { |
431 | - $birt_by_decade[(int)($birth_dates[0]->gregorianYear()/10)*10] .= $person->getSex(); |
|
431 | + $birt_by_decade[(int)($birth_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | else { |
435 | - $birth_dates[0]=new Date(''); |
|
435 | + $birth_dates[0] = new Date(''); |
|
436 | 436 | } |
437 | 437 | if ($death_dates = $person->getAllDeathDates()) { |
438 | 438 | if ( |
439 | 439 | FunctionsPrint::isDateWithinChartsRange($death_dates[0]) && |
440 | 440 | !isset($unique_indis[$person->getXref()]) |
441 | 441 | ) { |
442 | - $deat_by_decade[(int) ($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
442 | + $deat_by_decade[(int)($death_dates[0]->gregorianYear() / 10) * 10] .= $person->getSex(); |
|
443 | 443 | } |
444 | 444 | } |
445 | 445 | else { |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | $this->view_bag->set('sosa_list', $listSosa); |
456 | 456 | |
457 | 457 | $this->view_bag->set('sosa_count', count($listSosa)); |
458 | - $this->view_bag->set('sosa_theo', pow(2, $this->generation-1)); |
|
458 | + $this->view_bag->set('sosa_theo', pow(2, $this->generation - 1)); |
|
459 | 459 | $this->view_bag->set('sosa_ratio', Functions::safeDivision($this->view_bag->get('sosa_count'), $this->view_bag->get('sosa_theo'))); |
460 | 460 | |
461 | 461 | $this->view_bag->set('sosa_hidden', $this->view_bag->get('sosa_count') - $nb_displayed); |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | protected function renderFamSosaListIndi(AjaxController $controller) { |
476 | 476 | global $WT_TREE; |
477 | 477 | |
478 | - $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation);; |
|
478 | + $listFamSosa = $this->sosa_provider->getFamilySosaListAtGeneration($this->generation); ; |
|
479 | 479 | $this->view_bag->set('has_sosa', false); |
480 | 480 | |
481 | - if(count($listFamSosa) > 0) { |
|
481 | + if (count($listFamSosa) > 0) { |
|
482 | 482 | $this->view_bag->set('has_sosa', true); |
483 | - $table_id = 'table-sosa-fam-' . Uuid::uuid4(); |
|
483 | + $table_id = 'table-sosa-fam-'.Uuid::uuid4(); |
|
484 | 484 | $this->view_bag->set('table_id', $table_id); |
485 | 485 | |
486 | 486 | $controller |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | 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);}; |
493 | 493 | |
494 | 494 | jQuery("#'.$table_id.'").dataTable( { |
495 | - dom: \'<"H"<"filtersH_' . $table_id . '"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_' . $table_id . '">>\', |
|
495 | + dom: \'<"H"<"filtersH_' . $table_id.'"><"dt-clear">pf<"dt-clear">irl>t<"F"pl<"dt-clear"><"filtersF_'.$table_id.'">>\', |
|
496 | 496 | '.I18N::datatablesI18N(array(16, 32, 64, 128, -1)).', |
497 | 497 | jQueryUI: true, |
498 | 498 | autoWidth: false, |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | pagingType: "full_numbers" |
530 | 530 | }); |
531 | 531 | |
532 | - jQuery("#' . $table_id . '") |
|
532 | + jQuery("#' . $table_id.'") |
|
533 | 533 | /* Hide/show parents */ |
534 | 534 | .on("click", ".btn-toggle-parents", function() { |
535 | 535 | jQuery(this).toggleClass("ui-state-active"); |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | /* Hide/show statistics */ |
539 | 539 | .on("click", ".btn-toggle-statistics", function() { |
540 | 540 | jQuery(this).toggleClass("ui-state-active"); |
541 | - jQuery("#fam_list_table-charts_' . $table_id . '").slideToggle(); |
|
541 | + jQuery("#fam_list_table-charts_' . $table_id.'").slideToggle(); |
|
542 | 542 | }) |
543 | 543 | /* Filter buttons in table header */ |
544 | 544 | .on("click", "button[data-filter-column]", function() { |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | // De-activate the other buttons in this button group |
547 | 547 | btn.siblings().removeClass("ui-state-active"); |
548 | 548 | // Apply (or clear) this filter |
549 | - var col = jQuery("#' . $table_id . '").DataTable().column(btn.data("filter-column")); |
|
549 | + var col = jQuery("#' . $table_id.'").DataTable().column(btn.data("filter-column")); |
|
550 | 550 | if (btn.hasClass("ui-state-active")) { |
551 | 551 | btn.removeClass("ui-state-active"); |
552 | 552 | col.search("").draw(); |
@@ -566,29 +566,29 @@ discard block |
||
566 | 566 | |
567 | 567 | //-- init chart data |
568 | 568 | $marr_by_age = array(); |
569 | - for ($age=0; $age<=$max_age; $age++) { |
|
569 | + for ($age = 0; $age <= $max_age; $age++) { |
|
570 | 570 | $marr_by_age[$age] = ''; |
571 | 571 | } |
572 | 572 | $birt_by_decade = array(); |
573 | 573 | $marr_by_decade = array(); |
574 | - for ($year=1550; $year<2030; $year+=10) { |
|
574 | + for ($year = 1550; $year < 2030; $year += 10) { |
|
575 | 575 | $birt_by_decade[$year] = ''; |
576 | 576 | $marr_by_decade[$year] = ''; |
577 | 577 | } |
578 | 578 | |
579 | - foreach($listFamSosa as $sosa => $fid) { |
|
579 | + foreach ($listFamSosa as $sosa => $fid) { |
|
580 | 580 | $sfamily = Family::getInstance($fid, $WT_TREE); |
581 | - if(!$sfamily || !$sfamily->canShow()) { |
|
581 | + if (!$sfamily || !$sfamily->canShow()) { |
|
582 | 582 | unset($sfamily[$sosa]); |
583 | 583 | continue; |
584 | 584 | } |
585 | - $mdate=$sfamily->getMarriageDate(); |
|
585 | + $mdate = $sfamily->getMarriageDate(); |
|
586 | 586 | |
587 | - if( ($husb = $sfamily->getHusband()) && |
|
587 | + if (($husb = $sfamily->getHusband()) && |
|
588 | 588 | ($hdate = $husb->getBirthDate()) && |
589 | 589 | $hdate->isOK() && $mdate->isOK()) { |
590 | 590 | if (FunctionsPrint::isDateWithinChartsRange($hdate)) { |
591 | - $birt_by_decade[(int) ($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
591 | + $birt_by_decade[(int)($hdate->gregorianYear() / 10) * 10] .= $husb->getSex(); |
|
592 | 592 | } |
593 | 593 | $hage = Date::getAge($hdate, $mdate, 0); |
594 | 594 | if ($hage >= 0 && $hage <= $max_age) { |
@@ -596,11 +596,11 @@ discard block |
||
596 | 596 | } |
597 | 597 | } |
598 | 598 | |
599 | - if(($wife = $sfamily->getWife()) && |
|
600 | - ($wdate=$wife->getBirthDate()) && |
|
599 | + if (($wife = $sfamily->getWife()) && |
|
600 | + ($wdate = $wife->getBirthDate()) && |
|
601 | 601 | $wdate->isOK() && $mdate->isOK()) { |
602 | 602 | if (FunctionsPrint::isDateWithinChartsRange($wdate)) { |
603 | - $birt_by_decade[(int) ($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
603 | + $birt_by_decade[(int)($wdate->gregorianYear() / 10) * 10] .= $wife->getSex(); |
|
604 | 604 | } |
605 | 605 | $wage = Date::getAge($wdate, $mdate, 0); |
606 | 606 | if ($wage >= 0 && $wage <= $max_age) { |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | } |
610 | 610 | |
611 | 611 | if ($mdate->isOK() && FunctionsPrint::isDateWithinChartsRange($mdate) && $husb && $wife) { |
612 | - $marr_by_decade[(int) ($mdate->gregorianYear() / 10) * 10] .= $husb->getSex() . $wife->getSex(); |
|
612 | + $marr_by_decade[(int)($mdate->gregorianYear() / 10) * 10] .= $husb->getSex().$wife->getSex(); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | $listFamSosa[$sosa] = $sfamily; |
@@ -22,18 +22,18 @@ |
||
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' . |
|
36 | - ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
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 | + ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
37 | 37 | ); |
38 | 38 | } |
39 | 39 | } |
@@ -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 | } |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | * {@inhericDoc} |
24 | 24 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
25 | 25 | */ |
26 | - protected function renderContent() { |
|
27 | - ?> |
|
26 | + protected function renderContent() { |
|
27 | + ?> |
|
28 | 28 | <div id="maj-sosa-list-page" class="center"> |
29 | 29 | <h2><?php echo $this->data->get('title'); ?></h2> |
30 | 30 | |
31 | 31 | <?php if($this->data->get('is_setup')) { |
32 | - $selectedgen = $this->data->get('generation'); |
|
33 | - $this->renderSosaHeader(); |
|
34 | - if($this->data->get('has_sosa') ) { |
|
35 | - if($selectedgen > 0) { |
|
36 | - ?> |
|
32 | + $selectedgen = $this->data->get('generation'); |
|
33 | + $this->renderSosaHeader(); |
|
34 | + if($this->data->get('has_sosa') ) { |
|
35 | + if($selectedgen > 0) { |
|
36 | + ?> |
|
37 | 37 | <div id="sosalist-tabs"> |
38 | 38 | <ul> |
39 | 39 | <li><a href="#sosalist-indi"><?php echo I18N::translate('Individuals'); ?></a></li> |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | <?php } else { ?> |
54 | 54 | <p class="warning"><?php echo I18N::translate('No ancestor has been found for generation %d', $selectedgen); ?></p> |
55 | 55 | <?php } |
56 | - } |
|
56 | + } |
|
57 | 57 | } else { ?> |
58 | 58 | <p class="warning"><?php echo I18N::translate('The list could not be displayed. Reasons might be:'); ?><br/> |
59 | 59 | <ul> |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | <?php } ?> |
65 | 65 | </div> |
66 | 66 | <?php |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Render the common header to Sosa Lists, made of the generation selector, and the generation navigator |
|
71 | - */ |
|
72 | - protected function renderSosaHeader() { |
|
73 | - $selectedgen = $this->data->get('generation'); |
|
74 | - $max_gen = $this->data->get('max_gen'); |
|
75 | - ?> |
|
69 | + /** |
|
70 | + * Render the common header to Sosa Lists, made of the generation selector, and the generation navigator |
|
71 | + */ |
|
72 | + protected function renderSosaHeader() { |
|
73 | + $selectedgen = $this->data->get('generation'); |
|
74 | + $max_gen = $this->data->get('max_gen'); |
|
75 | + ?> |
|
76 | 76 | |
77 | 77 | <form method="get" name="setgen" action="module.php"> |
78 | 78 | <input type="hidden" name="mod" value="<?php echo $this->data->get('url_module');?>"> |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | <?php |
119 | 119 | } |
120 | - } |
|
120 | + } |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
124 | 124 | \ No newline at end of file |
@@ -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 } ?> |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | * {@inhericDoc} |
24 | 24 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
25 | 25 | */ |
26 | - protected function renderContent() { |
|
27 | - ?> |
|
26 | + protected function renderContent() { |
|
27 | + ?> |
|
28 | 28 | <div id="maj-sosa-stats-page"> |
29 | 29 | <h2><?php echo $this->data->get('title'); ?></h2> |
30 | 30 | |
31 | 31 | <?php if($this->data->get('is_setup')) { |
32 | - $general_stats = $this->data->get('general_stats'); ?> |
|
32 | + $general_stats = $this->data->get('general_stats'); ?> |
|
33 | 33 | <h3><?php echo I18N::translate('General statistics'); ?></h3> |
34 | 34 | <div class="maj-table"> |
35 | 35 | <div class="maj-row"> |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | <?php } else { ?> |
135 | 135 | <div class="warning"><?php echo I18N::translate('No Sosa root individual has been defined.'); ?></div> |
136 | 136 | <?php } |
137 | - } |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | |
141 | 141 | \ No newline at end of file |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | <?php |
31 | 31 | /** @var \Fisharebest\Webtrees\Individual $root_indi */ |
32 | 32 | $root_indi = $this->data->get('root_indi'); |
33 | - if($root_indi !== null && $root_indi->canShowName()) { ?> |
|
33 | + if ($root_indi !== null && $root_indi->canShowName()) { ?> |
|
34 | 34 | <h4 class="center"><?= I18N::translate('%s: %s', I18N::translate('Root individual'), $root_indi->getFullName()); ?><h4> |
35 | 35 | <?php } ?> |
36 | 36 | |
37 | - <?php if($this->data->get('is_setup')) { |
|
37 | + <?php if ($this->data->get('is_setup')) { |
|
38 | 38 | $general_stats = $this->data->get('general_stats'); ?> |
39 | 39 | <h3><?php echo I18N::translate('General statistics'); ?></h3> |
40 | 40 | <div class="maj-table"> |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | </div> |
57 | 57 | <div class="maj-row"> |
58 | 58 | <div class="label"><?php echo I18N::translate('Mean generation time'); ?></div> |
59 | - <div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1)); ?></div> |
|
59 | + <div class="value"><?php echo I18N::plural('%s year', '%s years', $general_stats['mean_gen_time'], I18N::number($general_stats['mean_gen_time'], 1)); ?></div> |
|
60 | 60 | </div> |
61 | 61 | </div> |
62 | 62 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | </tr> |
97 | 97 | </thead> |
98 | 98 | <tbody> |
99 | - <?php foreach($this->data->get('generation_stats') as $gen => $row) { ?> |
|
99 | + <?php foreach ($this->data->get('generation_stats') as $gen => $row) { ?> |
|
100 | 100 | <tr class="maj-row"> |
101 | 101 | <td class="label"><?php echo I18N::translate('<strong>G%d</strong>', $gen); ?></td> |
102 | 102 | <td class="label"><?php echo I18N::translate('%1$s <> %2$s', $row['gen_min_birth'], $row['gen_max_birth']); ?></td> |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | <td class="value"><?php echo I18N::number($row['different']); ?></td> |
111 | 111 | <td class="value left percent_container"> |
112 | 112 | <div class="percent_frame"> |
113 | - <div class="percent_cell" style="width:<?php echo 100*$row['perc_different'] ?>%;"> |
|
113 | + <div class="percent_cell" style="width:<?php echo 100 * $row['perc_different'] ?>%;"> |
|
114 | 114 | <?php echo I18N::percentage($row['perc_different']); ?> |
115 | 115 | </div> |
116 | 116 | </div> |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | <tfoot> |
124 | 124 | <tr class="maj-row"> |
125 | 125 | <td class="label" colspan="13"> |
126 | - <?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'),2)); ?> |
|
126 | + <?php echo I18N::translate('Generation-equivalent: %s generations', I18N::number($this->data->get('equivalent_gen'), 2)); ?> |
|
127 | 127 | </td> |
128 | 128 | </tr> |
129 | 129 | </tfoot> |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | |
133 | 133 | <h3><?php echo I18N::translate('Known Sosa ancestors\' family dispersion'); ?></h3> |
134 | 134 | <div class="center"> |
135 | - <?php echo $this->data->get('chart_img_g2') ?: '' ; ?> |
|
136 | - <?php echo $this->data->get('chart_img_g3') ?: '' ; ?> |
|
135 | + <?php echo $this->data->get('chart_img_g2') ?: ''; ?> |
|
136 | + <?php echo $this->data->get('chart_img_g3') ?: ''; ?> |
|
137 | 137 | <!-- <canvas id="chart_ancestors_g2" width="300" height="300"></canvas> --> |
138 | 138 | </div> |
139 | 139 |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * {@inhericDoc} |
33 | 33 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
34 | 34 | */ |
35 | - protected function renderContent() { |
|
35 | + protected function renderContent() { |
|
36 | 36 | |
37 | - if($this->data->get('has_sosa', false)) { |
|
38 | - $table_id = $this->data->get('table_id'); |
|
39 | - ?> |
|
37 | + if($this->data->get('has_sosa', false)) { |
|
38 | + $table_id = $this->data->get('table_id'); |
|
39 | + ?> |
|
40 | 40 | |
41 | 41 | <div id="sosa-fam-list" class="sosa-list"> |
42 | 42 | <table id="<?php echo $table_id; ?>"> |
@@ -187,59 +187,59 @@ discard block |
||
187 | 187 | <tbody> |
188 | 188 | |
189 | 189 | <?php foreach($this->data->get('sosa_list') as $sosa => $family) { |
190 | - /** @var \Fisharebest\Webtrees\Family $person */ |
|
190 | + /** @var \Fisharebest\Webtrees\Family $person */ |
|
191 | 191 | |
192 | - //PERSO Create decorator for Family |
|
193 | - $dfamily = new Family($family); |
|
192 | + //PERSO Create decorator for Family |
|
193 | + $dfamily = new Family($family); |
|
194 | 194 | |
195 | - $husb = $family->getHusband(); |
|
196 | - if (is_null($husb)) { |
|
197 | - $husb = new Individual('H', '0 @H@ INDI', null, $family->getTree()); |
|
198 | - } |
|
199 | - $dhusb = new \MyArtJaub\Webtrees\Individual($husb); |
|
200 | - $wife = $family->getWife(); |
|
201 | - if (is_null($wife)) { |
|
202 | - $wife = new Individual('W', '0 @W@ INDI', null, $family->getTree()); |
|
203 | - } |
|
204 | - $dwife = new \MyArtJaub\Webtrees\Individual($wife); |
|
195 | + $husb = $family->getHusband(); |
|
196 | + if (is_null($husb)) { |
|
197 | + $husb = new Individual('H', '0 @H@ INDI', null, $family->getTree()); |
|
198 | + } |
|
199 | + $dhusb = new \MyArtJaub\Webtrees\Individual($husb); |
|
200 | + $wife = $family->getWife(); |
|
201 | + if (is_null($wife)) { |
|
202 | + $wife = new Individual('W', '0 @W@ INDI', null, $family->getTree()); |
|
203 | + } |
|
204 | + $dwife = new \MyArtJaub\Webtrees\Individual($wife); |
|
205 | 205 | |
206 | - $mdate=$family->getMarriageDate(); |
|
206 | + $mdate=$family->getMarriageDate(); |
|
207 | 207 | |
208 | - if ($family->isPendingAddtion()) { |
|
209 | - $class = ' class="new"'; |
|
210 | - } elseif ($family->isPendingDeletion()) { |
|
211 | - $class = ' class="old"'; |
|
212 | - } else { |
|
213 | - $class = ''; |
|
214 | - } |
|
215 | - ?> |
|
208 | + if ($family->isPendingAddtion()) { |
|
209 | + $class = ' class="new"'; |
|
210 | + } elseif ($family->isPendingDeletion()) { |
|
211 | + $class = ' class="old"'; |
|
212 | + } else { |
|
213 | + $class = ''; |
|
214 | + } |
|
215 | + ?> |
|
216 | 216 | <tr <?php echo $class?>> |
217 | 217 | <td class="transparent"><?php echo I18N::translate('%1$d/%2$d', $sosa, ($sosa + 1) % 10); ?></td> |
218 | 218 | <td class="transparent"><?php echo $sosa; ?></td> |
219 | 219 | <!-- HUSBAND --> |
220 | 220 | <td colspan="2"> |
221 | 221 | <?php foreach ($husb->getAllNames() as $num=>$name) { |
222 | - if ($name['type']=='NAME') { |
|
223 | - $title=''; |
|
224 | - } else { |
|
225 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $husb)).'"'; |
|
226 | - } |
|
227 | - if ($num==$husb->getPrimaryName()) { |
|
228 | - $class=' class="name2"'; |
|
229 | - $sex_image=$husb->getSexImage(); |
|
230 | - list($surn, $givn)=explode(',', $name['sort']); |
|
231 | - } else { |
|
232 | - $class=''; |
|
233 | - $sex_image=''; |
|
234 | - } ?> |
|
222 | + if ($name['type']=='NAME') { |
|
223 | + $title=''; |
|
224 | + } else { |
|
225 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $husb)).'"'; |
|
226 | + } |
|
227 | + if ($num==$husb->getPrimaryName()) { |
|
228 | + $class=' class="name2"'; |
|
229 | + $sex_image=$husb->getSexImage(); |
|
230 | + list($surn, $givn)=explode(',', $name['sort']); |
|
231 | + } else { |
|
232 | + $class=''; |
|
233 | + $sex_image=''; |
|
234 | + } ?> |
|
235 | 235 | <a <?php echo $title.' '.$class; ?> href="<?php echo $husb->getHtmlUrl(); ?>"> |
236 | 236 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
237 | 237 | </a> |
238 | 238 | <?php echo $sex_image.FunctionsPrint::formatSosaNumbers($dhusb->getSosaNumbers(), 1, 'smaller'); ?> |
239 | 239 | <br/> |
240 | 240 | <?php } |
241 | - echo $husb->getPrimaryParentsNames('parents details1', 'none'); |
|
242 | - ?> |
|
241 | + echo $husb->getPrimaryParentsNames('parents details1', 'none'); |
|
242 | + ?> |
|
243 | 243 | </td> |
244 | 244 | <!-- Dummy column to match colspan in header --> |
245 | 245 | <td style="display:none;"></td> |
@@ -255,27 +255,27 @@ discard block |
||
255 | 255 | <!-- WIFE --> |
256 | 256 | <td colspan="2"> |
257 | 257 | <?php foreach ($wife->getAllNames() as $num=>$name) { |
258 | - if ($name['type']=='NAME') { |
|
259 | - $title=''; |
|
260 | - } else { |
|
261 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $wife)).'"'; |
|
262 | - } |
|
263 | - if ($num==$wife->getPrimaryName()) { |
|
264 | - $class=' class="name2"'; |
|
265 | - $sex_image=$wife->getSexImage(); |
|
266 | - list($surn, $givn)=explode(',', $name['sort']); |
|
267 | - } else { |
|
268 | - $class=''; |
|
269 | - $sex_image=''; |
|
270 | - } ?> |
|
258 | + if ($name['type']=='NAME') { |
|
259 | + $title=''; |
|
260 | + } else { |
|
261 | + $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $wife)).'"'; |
|
262 | + } |
|
263 | + if ($num==$wife->getPrimaryName()) { |
|
264 | + $class=' class="name2"'; |
|
265 | + $sex_image=$wife->getSexImage(); |
|
266 | + list($surn, $givn)=explode(',', $name['sort']); |
|
267 | + } else { |
|
268 | + $class=''; |
|
269 | + $sex_image=''; |
|
270 | + } ?> |
|
271 | 271 | <a <?php echo $title.' '.$class; ?> href="<?php echo $wife->getHtmlUrl(); ?>"> |
272 | 272 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
273 | 273 | </a> |
274 | 274 | <?php echo $sex_image.FunctionsPrint::formatSosaNumbers($dwife->getSosaNumbers(), 1, 'smaller'); ?> |
275 | 275 | <br/> |
276 | 276 | <?php } |
277 | - echo $wife->getPrimaryParentsNames('parents details1', 'none'); |
|
278 | - ?> |
|
277 | + echo $wife->getPrimaryParentsNames('parents details1', 'none'); |
|
278 | + ?> |
|
279 | 279 | </td> |
280 | 280 | <!-- Dummy column to match colspan in header --> |
281 | 281 | <td style="display:none;"></td> |
@@ -289,31 +289,31 @@ discard block |
||
289 | 289 | <td><?php Date::getAge($wdate, $mdate, 2); ?></td> |
290 | 290 | <td><?php Date::getAge($wdate, $mdate, 1); ?></td> |
291 | 291 | <td><?php |
292 | - if ($marriage_dates = $family->getAllMarriageDates()) { |
|
293 | - foreach ($marriage_dates as $n => $marriage_date) { |
|
294 | - if ($n) { echo '<br>'; } ?> |
|
292 | + if ($marriage_dates = $family->getAllMarriageDates()) { |
|
293 | + foreach ($marriage_dates as $n => $marriage_date) { |
|
294 | + if ($n) { echo '<br>'; } ?> |
|
295 | 295 | <div><?php echo $marriage_date->display(true); ?></div> |
296 | 296 | <?php } |
297 | - } elseif ($family->getFacts('_NMR')) { |
|
298 | - echo I18N::translate('no'); |
|
299 | - } elseif ($family->getFacts('MARR')) { |
|
300 | - echo I18N::translate('yes'); |
|
301 | - } else { |
|
302 | - echo ' '; |
|
303 | - } ?> |
|
297 | + } elseif ($family->getFacts('_NMR')) { |
|
298 | + echo I18N::translate('no'); |
|
299 | + } elseif ($family->getFacts('MARR')) { |
|
300 | + echo I18N::translate('yes'); |
|
301 | + } else { |
|
302 | + echo ' '; |
|
303 | + } ?> |
|
304 | 304 | </td> |
305 | 305 | <td><?php echo $marriage_dates ? $marriage_date->julianDay() : 0; ?></td> |
306 | 306 | <td><?php |
307 | - foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) { |
|
308 | - $tmp = new Place($marriage_place, $family->getTree()); |
|
309 | - if ($n) { ?><br><?php } ?> |
|
307 | + foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) { |
|
308 | + $tmp = new Place($marriage_place, $family->getTree()); |
|
309 | + if ($n) { ?><br><?php } ?> |
|
310 | 310 | <a href="'<?php echo $tmp->getURL(); ?>" title="<?php echo strip_tags($tmp->getFullName()); ?>"> |
311 | 311 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($tmp->getShortName()); ?> |
312 | 312 | </a> |
313 | 313 | <?php } ?> |
314 | 314 | </td> |
315 | 315 | <?php if (ModuleManager::getInstance()->isOperational(Constants::MODULE_MAJ_ISSOURCED_NAME)) { |
316 | - $isMSourced = $dfamily->isMarriageSourced(); ?> |
|
316 | + $isMSourced = $dfamily->isMarriageSourced(); ?> |
|
317 | 317 | <td><?php echo FunctionsPrint::formatIsSourcedIcon('E', $isMSourced, 'MARR', 1, 'medium'); ?></td> |
318 | 318 | <td><?php echo $isMSourced; ?></td> |
319 | 319 | <?php } else { ?> |
@@ -326,30 +326,30 @@ discard block |
||
326 | 326 | <td><?php |
327 | 327 | if (!$mdate->isOK()) { echo 'U'; } |
328 | 328 | else { |
329 | - if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } |
|
330 | - else { echo 'YES'; } |
|
329 | + if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } |
|
330 | + else { echo 'YES'; } |
|
331 | 331 | } |
332 | 332 | if ($family->getFacts(WT_EVENTS_DIV)) { echo 'D'; } |
333 | 333 | if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) { |
334 | - echo 'M'; |
|
334 | + echo 'M'; |
|
335 | 335 | } ?> |
336 | 336 | </td> |
337 | 337 | <td><?php |
338 | - if ($husb->isDead() && $wife->isDead()) { echo 'Y'; } |
|
339 | - if ($husb->isDead() && !$wife->isDead()) { |
|
340 | - if ($wife->getSex() == 'F') { echo 'H'; } |
|
341 | - if ($wife->getSex() == 'M') { echo 'W'; } // male partners |
|
342 | - } |
|
343 | - if (!$husb->isDead() && $wife->isDead()) { |
|
344 | - if ($husb->getSex() == 'M') { echo 'W'; } |
|
345 | - if ($husb->getSex() == 'F') { echo 'H'; } // female partners |
|
346 | - } |
|
347 | - if (!$husb->isDead() && !$wife->isDead()) { echo 'N'; } ?> |
|
338 | + if ($husb->isDead() && $wife->isDead()) { echo 'Y'; } |
|
339 | + if ($husb->isDead() && !$wife->isDead()) { |
|
340 | + if ($wife->getSex() == 'F') { echo 'H'; } |
|
341 | + if ($wife->getSex() == 'M') { echo 'W'; } // male partners |
|
342 | + } |
|
343 | + if (!$husb->isDead() && $wife->isDead()) { |
|
344 | + if ($husb->getSex() == 'M') { echo 'W'; } |
|
345 | + if ($husb->getSex() == 'F') { echo 'H'; } // female partners |
|
346 | + } |
|
347 | + if (!$husb->isDead() && !$wife->isDead()) { echo 'N'; } ?> |
|
348 | 348 | </td> |
349 | 349 | <td><?php |
350 | - if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } |
|
351 | - elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { echo 'L'; } |
|
352 | - else { echo ' '; } ?> |
|
350 | + if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } |
|
351 | + elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { echo 'L'; } |
|
352 | + else { echo ' '; } ?> |
|
353 | 353 | </td> |
354 | 354 | </tr> |
355 | 355 | <?php } ?> |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | <p class="warning"><?php echo I18N::translate('No family has been found for generation %d', $this->data->get('generation')); ?></p> |
388 | 388 | <?php |
389 | 389 | } |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | 392 | } |
393 | 393 | |
394 | 394 | \ No newline at end of file |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | protected function renderContent() { |
36 | 36 | |
37 | - if($this->data->get('has_sosa', false)) { |
|
37 | + if ($this->data->get('has_sosa', false)) { |
|
38 | 38 | $table_id = $this->data->get('table_id'); |
39 | 39 | ?> |
40 | 40 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | class="ui-state-default" |
53 | 53 | title="<?php echo I18N::translate('Show individuals who are alive or couples where both partners are alive.'); ?>" |
54 | 54 | > |
55 | - <?php echo I18N::translate('Both alive');?> |
|
55 | + <?php echo I18N::translate('Both alive'); ?> |
|
56 | 56 | </button> |
57 | 57 | <button |
58 | 58 | type="button" |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | class="ui-state-default" |
62 | 62 | title="<?php echo I18N::translate('Show couples where only the female partner is deceased.'); ?>" |
63 | 63 | > |
64 | - <?php echo I18N::translate('Widower');?> |
|
64 | + <?php echo I18N::translate('Widower'); ?> |
|
65 | 65 | </button> |
66 | 66 | <button |
67 | 67 | type="button" |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | </thead> |
187 | 187 | <tbody> |
188 | 188 | |
189 | - <?php foreach($this->data->get('sosa_list') as $sosa => $family) { |
|
189 | + <?php foreach ($this->data->get('sosa_list') as $sosa => $family) { |
|
190 | 190 | /** @var \Fisharebest\Webtrees\Family $person */ |
191 | 191 | |
192 | 192 | //PERSO Create decorator for Family |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | } |
204 | 204 | $dwife = new \MyArtJaub\Webtrees\Individual($wife); |
205 | 205 | |
206 | - $mdate=$family->getMarriageDate(); |
|
206 | + $mdate = $family->getMarriageDate(); |
|
207 | 207 | |
208 | 208 | if ($family->isPendingAddtion()) { |
209 | 209 | $class = ' class="new"'; |
@@ -219,18 +219,18 @@ discard block |
||
219 | 219 | <!-- HUSBAND --> |
220 | 220 | <td colspan="2"> |
221 | 221 | <?php foreach ($husb->getAllNames() as $num=>$name) { |
222 | - if ($name['type']=='NAME') { |
|
223 | - $title=''; |
|
222 | + if ($name['type'] == 'NAME') { |
|
223 | + $title = ''; |
|
224 | 224 | } else { |
225 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $husb)).'"'; |
|
225 | + $title = 'title="'.strip_tags(GedcomTag::getLabel($name['type'], $husb)).'"'; |
|
226 | 226 | } |
227 | - if ($num==$husb->getPrimaryName()) { |
|
228 | - $class=' class="name2"'; |
|
229 | - $sex_image=$husb->getSexImage(); |
|
230 | - list($surn, $givn)=explode(',', $name['sort']); |
|
227 | + if ($num == $husb->getPrimaryName()) { |
|
228 | + $class = ' class="name2"'; |
|
229 | + $sex_image = $husb->getSexImage(); |
|
230 | + list($surn, $givn) = explode(',', $name['sort']); |
|
231 | 231 | } else { |
232 | - $class=''; |
|
233 | - $sex_image=''; |
|
232 | + $class = ''; |
|
233 | + $sex_image = ''; |
|
234 | 234 | } ?> |
235 | 235 | <a <?php echo $title.' '.$class; ?> href="<?php echo $husb->getHtmlUrl(); ?>"> |
236 | 236 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
@@ -244,29 +244,29 @@ discard block |
||
244 | 244 | <!-- Dummy column to match colspan in header --> |
245 | 245 | <td style="display:none;"></td> |
246 | 246 | <td> |
247 | - <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> |
|
247 | + <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)).'AAAA'.Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> |
|
248 | 248 | </td> |
249 | 249 | <td> |
250 | - <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
|
250 | + <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)).'AAAA'.Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
|
251 | 251 | </td> |
252 | - <?php $hdate=$husb->getBirthDate(); ?> |
|
252 | + <?php $hdate = $husb->getBirthDate(); ?> |
|
253 | 253 | <td><?php Date::getAge($hdate, $mdate, 2); ?></td> |
254 | 254 | <td><?php Date::getAge($hdate, $mdate, 1); ?></td> |
255 | 255 | <!-- WIFE --> |
256 | 256 | <td colspan="2"> |
257 | 257 | <?php foreach ($wife->getAllNames() as $num=>$name) { |
258 | - if ($name['type']=='NAME') { |
|
259 | - $title=''; |
|
258 | + if ($name['type'] == 'NAME') { |
|
259 | + $title = ''; |
|
260 | 260 | } else { |
261 | - $title='title="'.strip_tags(GedcomTag::getLabel($name['type'], $wife)).'"'; |
|
261 | + $title = 'title="'.strip_tags(GedcomTag::getLabel($name['type'], $wife)).'"'; |
|
262 | 262 | } |
263 | - if ($num==$wife->getPrimaryName()) { |
|
264 | - $class=' class="name2"'; |
|
265 | - $sex_image=$wife->getSexImage(); |
|
266 | - list($surn, $givn)=explode(',', $name['sort']); |
|
263 | + if ($num == $wife->getPrimaryName()) { |
|
264 | + $class = ' class="name2"'; |
|
265 | + $sex_image = $wife->getSexImage(); |
|
266 | + list($surn, $givn) = explode(',', $name['sort']); |
|
267 | 267 | } else { |
268 | - $class=''; |
|
269 | - $sex_image=''; |
|
268 | + $class = ''; |
|
269 | + $sex_image = ''; |
|
270 | 270 | } ?> |
271 | 271 | <a <?php echo $title.' '.$class; ?> href="<?php echo $wife->getHtmlUrl(); ?>"> |
272 | 272 | <?php echo \Fisharebest\Webtrees\Functions\FunctionsPrint::highlightSearchHits($name['full']); ?> |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | <!-- Dummy column to match colspan in header --> |
281 | 281 | <td style="display:none;"></td> |
282 | 282 | <td> |
283 | - <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)) . 'AAAA' . Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> |
|
283 | + <?php echo Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)).'AAAA'.Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)); ?> |
|
284 | 284 | </td> |
285 | 285 | <td> |
286 | - <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)) . 'AAAA' . Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
|
286 | + <?php echo Filter::escapeHtml(str_replace('@N.N.', 'AAAA', $surn)).'AAAA'.Filter::escapeHtml(str_replace('@P.N.', 'AAAA', $givn)); ?> |
|
287 | 287 | </td> |
288 | - <?php $wdate=$wife->getBirthDate(); ?> |
|
288 | + <?php $wdate = $wife->getBirthDate(); ?> |
|
289 | 289 | <td><?php Date::getAge($wdate, $mdate, 2); ?></td> |
290 | 290 | <td><?php Date::getAge($wdate, $mdate, 1); ?></td> |
291 | 291 | <td><?php |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | echo ' '; |
303 | 303 | } ?> |
304 | 304 | </td> |
305 | - <td><?php echo $marriage_dates ? $marriage_date->julianDay() : 0; ?></td> |
|
305 | + <td><?php echo $marriage_dates ? $marriage_date->julianDay() : 0; ?></td> |
|
306 | 306 | <td><?php |
307 | 307 | foreach ($family->getAllMarriagePlaces() as $n => $marriage_place) { |
308 | 308 | $tmp = new Place($marriage_place, $family->getTree()); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | <button type="button" class="ui-state-default btn-toggle-parents"> |
363 | 363 | <?php echo I18N::translate('Show parents') ?> |
364 | 364 | </button> |
365 | - <button id="btn-toggle-statistics-<?php echo $table_id ;?>" type="button" class="ui-state-default btn-toggle-statistics"> |
|
365 | + <button id="btn-toggle-statistics-<?php echo $table_id; ?>" type="button" class="ui-state-default btn-toggle-statistics"> |
|
366 | 366 | <?php echo I18N::translate('Show statistics charts') ?> |
367 | 367 | </button> |
368 | 368 | </div> |
@@ -324,10 +324,8 @@ discard block |
||
324 | 324 | <td><?php echo I18N::number($nchi); ?></td> |
325 | 325 | <td><?php echo $nchi; ?></td> |
326 | 326 | <td><?php |
327 | - if (!$mdate->isOK()) { echo 'U'; } |
|
328 | - else { |
|
329 | - if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } |
|
330 | - else { echo 'YES'; } |
|
327 | + if (!$mdate->isOK()) { echo 'U'; } else { |
|
328 | + if (Date::compare($mdate, new Date(date('Y') - 100)) > 0) { echo 'Y100'; } else { echo 'YES'; } |
|
331 | 329 | } |
332 | 330 | if ($family->getFacts(WT_EVENTS_DIV)) { echo 'D'; } |
333 | 331 | if (count($husb->getSpouseFamilies()) > 1 || count($wife->getSpouseFamilies()) > 1) { |
@@ -347,9 +345,7 @@ discard block |
||
347 | 345 | if (!$husb->isDead() && !$wife->isDead()) { echo 'N'; } ?> |
348 | 346 | </td> |
349 | 347 | <td><?php |
350 | - if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } |
|
351 | - elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { echo 'L'; } |
|
352 | - else { echo ' '; } ?> |
|
348 | + if (!$husb->getChildFamilies() && !$wife->getChildFamilies()) { echo 'R'; } elseif (!$husb->isDead() && !$wife->isDead() && $family->getNumberOfChildren() < 1) { echo 'L'; } else { echo ' '; } ?> |
|
353 | 349 | </td> |
354 | 350 | </tr> |
355 | 351 | <?php } ?> |