@@ -25,14 +25,14 @@ discard block |
||
25 | 25 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getProviderPlaceId() |
26 | 26 | */ |
27 | 27 | public function getProviderPlaceId(\Fisharebest\Webtrees\Place $place) { |
28 | - if(!$place->isEmpty()) { |
|
29 | - $parent = array_reverse(explode (',', $place->getGedcomName())); |
|
28 | + if (!$place->isEmpty()) { |
|
29 | + $parent = array_reverse(explode(',', $place->getGedcomName())); |
|
30 | 30 | $place_id = 0; |
31 | 31 | $nb_levels = count($parent); |
32 | - for ($i=0; $i < $nb_levels; $i++) { |
|
32 | + for ($i = 0; $i < $nb_levels; $i++) { |
|
33 | 33 | $parent[$i] = trim($parent[$i]); |
34 | - if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | - $pl_id=Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
34 | + if (empty($parent[$i])) $parent[$i] = 'unknown'; // GoogleMap module uses "unknown" while GEDCOM uses , , |
|
35 | + $pl_id = Database::prepare('SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place') |
|
36 | 36 | ->execute(array($i, $place_id, $parent[$i])) |
37 | 37 | ->fetchOne(); |
38 | 38 | if (empty($pl_id)) break; |
@@ -48,12 +48,12 @@ discard block |
||
48 | 48 | * @see \MyArtJaub\Webtrees\Map\MapProviderInterface::getPlaceIcon() |
49 | 49 | */ |
50 | 50 | public function getPlaceIcon(\Fisharebest\Webtrees\Place $place) { |
51 | - if(!$place->isEmpty()){ |
|
51 | + if (!$place->isEmpty()) { |
|
52 | 52 | $place_details = |
53 | 53 | Database::prepare('SELECT pl_icon FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place') |
54 | 54 | ->execute(array($this->getProviderPlaceId($place))) |
55 | 55 | ->fetchOneRow(); |
56 | - if($place_details){ |
|
56 | + if ($place_details) { |
|
57 | 57 | return WT_MODULES_DIR.'googlemap/'.$place_details->pl_icon; |
58 | 58 | } |
59 | 59 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getPossibleHooks() |
72 | 72 | */ |
73 | 73 | public function getPossibleHooks() { |
74 | - static $hooks=null; |
|
74 | + static $hooks = null; |
|
75 | 75 | if ($hooks === null) { |
76 | 76 | $hooks = array(); |
77 | 77 | |
@@ -83,31 +83,31 @@ discard block |
||
83 | 83 | 'SELECT module_name FROM `##module`' |
84 | 84 | )->fetchOneColumn(); |
85 | 85 | |
86 | - foreach($module_names as $module_name) { |
|
86 | + foreach ($module_names as $module_name) { |
|
87 | 87 | $module = Module::getModuleByName($module_name); |
88 | 88 | |
89 | - if($module instanceof HookSubscriberInterface){ |
|
89 | + if ($module instanceof HookSubscriberInterface) { |
|
90 | 90 | $subscribedhooks = $module->getSubscribedHooks(); |
91 | - if(is_array($subscribedhooks)){ |
|
92 | - foreach($subscribedhooks as $key => $value){ |
|
93 | - if(is_int($key)) { |
|
91 | + if (is_array($subscribedhooks)) { |
|
92 | + foreach ($subscribedhooks as $key => $value) { |
|
93 | + if (is_int($key)) { |
|
94 | 94 | $hook_item = $value; |
95 | 95 | $priority = self::DEFAULT_PRIORITY; |
96 | 96 | } |
97 | - else{ |
|
97 | + else { |
|
98 | 98 | $hook_item = explode('#', $key, 2); |
99 | 99 | $priority = $value; |
100 | 100 | } |
101 | - if($hook_item && count($hook_item) == 2){ |
|
101 | + if ($hook_item && count($hook_item) == 2) { |
|
102 | 102 | $hook_func = $hook_item[0]; |
103 | 103 | $hook_cont = $hook_item[1]; |
104 | 104 | } |
105 | - else{ |
|
105 | + else { |
|
106 | 106 | $hook_func = $hook_item[0]; |
107 | 107 | $hook_cont = 'all'; |
108 | 108 | } |
109 | - if(method_exists($module, $hook_func)){ |
|
110 | - $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont]=$priority; |
|
109 | + if (method_exists($module, $hook_func)) { |
|
110 | + $hooks[$module->getName().'#'.$hook_func.'#'.$hook_cont] = $priority; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | * {@inheritDoc} |
122 | 122 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getRawInstalledHooks() |
123 | 123 | */ |
124 | - public function getRawInstalledHooks(){ |
|
125 | - if(self::isModuleOperational()){ |
|
124 | + public function getRawInstalledHooks() { |
|
125 | + if (self::isModuleOperational()) { |
|
126 | 126 | return Database::prepare( |
127 | 127 | "SELECT majh_id AS id, majh_module_name AS module, majh_hook_function AS hook, majh_hook_context as context, majh_module_priority AS priority, majh_status AS status". |
128 | 128 | " FROM `##maj_hooks`". |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | * {@inheritDoc} |
137 | 137 | * @see \MyArtJaub\Webtrees\Hook\HookProviderInterface::getInstalledHooks() |
138 | 138 | */ |
139 | - public function getInstalledHooks(){ |
|
140 | - static $installedhooks =null; |
|
141 | - if($installedhooks===null){ |
|
142 | - $dbhooks=self::getRawInstalledHooks(); |
|
143 | - foreach($dbhooks as $dbhook){ |
|
139 | + public function getInstalledHooks() { |
|
140 | + static $installedhooks = null; |
|
141 | + if ($installedhooks === null) { |
|
142 | + $dbhooks = self::getRawInstalledHooks(); |
|
143 | + foreach ($dbhooks as $dbhook) { |
|
144 | 144 | $installedhooks[($dbhook->module).'#'.($dbhook->hook).'#'.($dbhook->context)] = array('id' => $dbhook->id, 'status' => $dbhook->status, 'priority' => $dbhook->priority); |
145 | 145 | } |
146 | 146 | } |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | */ |
154 | 154 | public function updateHooks() { |
155 | 155 | |
156 | - if(Auth::isAdmin()){ |
|
156 | + if (Auth::isAdmin()) { |
|
157 | 157 | $ihooks = self::getInstalledHooks(); |
158 | 158 | $phooks = self::getPossibleHooks(); |
159 | 159 | |
160 | 160 | // Insert hooks not existing yet in the DB |
161 | - if($phooks !== null){ |
|
162 | - foreach($phooks as $phook => $priority){ |
|
161 | + if ($phooks !== null) { |
|
162 | + foreach ($phooks as $phook => $priority) { |
|
163 | 163 | $array_hook = explode('#', $phook); |
164 | - if($ihooks === null || !array_key_exists($phook, $ihooks)){ |
|
164 | + if ($ihooks === null || !array_key_exists($phook, $ihooks)) { |
|
165 | 165 | $chook = new Hook($array_hook[1], $array_hook[2]); |
166 | 166 | $chook->subscribe($array_hook[0]); |
167 | 167 | $chook->setPriority($array_hook[0], $priority); |
@@ -170,10 +170,10 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | //Remove hooks not existing any more in the file system |
173 | - if($ihooks !== null){ |
|
174 | - foreach(array_keys($ihooks) as $ihook){ |
|
173 | + if ($ihooks !== null) { |
|
174 | + foreach (array_keys($ihooks) as $ihook) { |
|
175 | 175 | $array_hook = explode('#', $ihook); |
176 | - if($phooks === null || !array_key_exists($ihook, $phooks)){ |
|
176 | + if ($phooks === null || !array_key_exists($ihook, $phooks)) { |
|
177 | 177 | $chook = new Hook($array_hook[1], $array_hook[2]); |
178 | 178 | $chook->remove($array_hook[0]); |
179 | 179 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | $ga_id = Filter::getInteger('ga_id'); |
72 | 72 | |
73 | - if($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
73 | + if ($ga_id && $ga = $this->provider->getGeoAnalysis($ga_id)) { |
|
74 | 74 | $data->set('has_analysis', true); |
75 | 75 | $data->set('geoanalysis', $ga); |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | jQuery.get( |
84 | 84 | "module.php", |
85 | 85 | { |
86 | - "mod" : "'. $this->module->getName() .'", |
|
86 | + "mod" : "'. $this->module->getName().'", |
|
87 | 87 | "mod_action": "GeoAnalysis@dataTabs", |
88 | 88 | "ga_id" : "'.$ga_id.'" |
89 | 89 | }, |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $data->set('has_list', false); |
116 | 116 | |
117 | 117 | $ga_list = $this->provider->getGeoAnalysisList(); |
118 | - if(count($ga_list) > 0 ) { |
|
118 | + if (count($ga_list) > 0) { |
|
119 | 119 | $data->set('has_list', true); |
120 | 120 | $data->set('geoanalysislist', $ga_list); |
121 | 121 | } |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | ); |
140 | 140 | |
141 | 141 | $status = Filter::getBool('status'); |
142 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
143 | - try{ |
|
142 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
143 | + try { |
|
144 | 144 | $this->provider->setGeoAnalysisStatus($ga, $status); |
145 | 145 | $res['status'] = $status; |
146 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '. ($status ? 'enabled' : 'disabled') .'.'); |
|
146 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been '.($status ? 'enabled' : 'disabled').'.'); |
|
147 | 147 | } |
148 | 148 | catch (\Exception $ex) { |
149 | 149 | $res['error'] = $ex->getMessage(); |
150 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be ' . ($status ? 'enabled' : 'disabled') .'. Error: '. $ex->getMessage()); |
|
150 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be '.($status ? 'enabled' : 'disabled').'. Error: '.$ex->getMessage()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $controller->pageHeader(); |
154 | - if($res['error']) http_response_code(500); |
|
154 | + if ($res['error']) http_response_code(500); |
|
155 | 155 | |
156 | 156 | $controller->encode($res); |
157 | 157 | } |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | && $ga |
172 | 172 | ); |
173 | 173 | |
174 | - $res = array('geoanalysis' => $ga->getId() , 'error' => null); |
|
175 | - try{ |
|
174 | + $res = array('geoanalysis' => $ga->getId(), 'error' => null); |
|
175 | + try { |
|
176 | 176 | $this->provider->deleteGeoAnalysis($ga); |
177 | 177 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" has been deleted.'); |
178 | 178 | } |
179 | 179 | catch (\Exception $ex) { |
180 | 180 | $res['error'] = $ex->getMessage(); |
181 | - Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '. $ex->getMessage()); |
|
181 | + Log::addErrorLog('Module '.$this->module->getName().' : Geo Analysis ID "'.$ga->getId().'" could not be deleted. Error: '.$ex->getMessage()); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $controller->pageHeader(); |
185 | - if($res['error']) http_response_code(500); |
|
185 | + if ($res['error']) http_response_code(500); |
|
186 | 186 | |
187 | 187 | $controller->encode($res); |
188 | 188 | } |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations()); |
208 | 208 | |
209 | 209 | $flags = array(); |
210 | - if($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
210 | + if ($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) { |
|
211 | 211 | $mapProvider = new GoogleMapsProvider(); |
212 | - foreach($placesDispGeneral['places'] as $place => $count) { |
|
212 | + foreach ($placesDispGeneral['places'] as $place => $count) { |
|
213 | 213 | $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $wt_tree)); |
214 | 214 | } |
215 | 215 | } |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * @param (null|array) $flags Array of flags |
229 | 229 | * @return string HTML code for the general tab |
230 | 230 | */ |
231 | - protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags= null) { |
|
232 | - if(!empty($placesGeneralResults)){ |
|
231 | + protected function htmlPlacesAnalysisGeneralTab(GeoAnalysis $ga, $placesGeneralResults, $flags = null) { |
|
232 | + if (!empty($placesGeneralResults)) { |
|
233 | 233 | $data = new ViewBag(); |
234 | 234 | |
235 | 235 | $nb_found = $placesGeneralResults['knownsum']; |
236 | 236 | $nb_other = 0; |
237 | - if(isset($placesGeneralResults['other'])) $nb_other =$placesGeneralResults['other']; |
|
237 | + if (isset($placesGeneralResults['other'])) $nb_other = $placesGeneralResults['other']; |
|
238 | 238 | $nb_unknown = $placesGeneralResults['unknown']; |
239 | 239 | |
240 | 240 | $data->set('stats_gen_nb_found', $nb_found); |
@@ -243,29 +243,29 @@ discard block |
||
243 | 243 | |
244 | 244 | $data->set('use_flags', $ga->getOptions() && $ga->getOptions()->isUsingFlags()); |
245 | 245 | |
246 | - if($ga->hasMap()) { |
|
246 | + if ($ga->hasMap()) { |
|
247 | 247 | $max = $placesGeneralResults['max']; |
248 | 248 | $map = $ga->getOptions()->getMap(); |
249 | - if($map->isLoaded()) { |
|
249 | + if ($map->isLoaded()) { |
|
250 | 250 | $results_by_subdivs = $map->getSubdivisions(); |
251 | 251 | $places_mappings = $map->getPlacesMappings(); |
252 | 252 | foreach ($placesGeneralResults['places'] as $location => $count) { |
253 | - $levelvalues = array_reverse(array_map('trim',explode(',', $location))); |
|
253 | + $levelvalues = array_reverse(array_map('trim', explode(',', $location))); |
|
254 | 254 | $level_map = $ga->getAnalysisLevel() - $ga->getOptions()->getMapLevel(); |
255 | - if($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | - $levelref = $levelvalues[0] . '@' . $levelvalues[$level_map]; |
|
257 | - if(!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
255 | + if ($level_map >= 0 && $level_map < count($levelvalues)) { |
|
256 | + $levelref = $levelvalues[0].'@'.$levelvalues[$level_map]; |
|
257 | + if (!isset($results_by_subdivs[$levelref])) { $levelref = $levelvalues[0]; } |
|
258 | 258 | } |
259 | 259 | else { |
260 | 260 | $levelref = $levelvalues[0]; |
261 | 261 | } |
262 | - if(isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
263 | - if(isset($results_by_subdivs[$levelref])) { |
|
262 | + if (isset($places_mappings[$levelref])) $levelref = $places_mappings[$levelref]; |
|
263 | + if (isset($results_by_subdivs[$levelref])) { |
|
264 | 264 | $count_subd = isset($results_by_subdivs[$levelref]['count']) ? $results_by_subdivs[$levelref]['count'] : 0; |
265 | - $count_subd += $count; |
|
265 | + $count_subd += $count; |
|
266 | 266 | $results_by_subdivs[$levelref]['count'] = $count_subd; |
267 | 267 | $results_by_subdivs[$levelref]['transparency'] = Functions::safeDivision($count_subd, $max); |
268 | - if($ga->getOptions()->isUsingFlags() && $flags) { |
|
268 | + if ($ga->getOptions()->isUsingFlags() && $flags) { |
|
269 | 269 | $results_by_subdivs[$levelref]['place'] = new Place($location, Globals::getTree()); |
270 | 270 | $results_by_subdivs[$levelref]['flag'] = $flags[$location]; |
271 | 271 | } |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | } |
289 | 289 | } |
290 | 290 | else { |
291 | - $html = '<p class="warning">' . I18N::translate('No data is available for the general analysis.') . '</p>'; |
|
291 | + $html = '<p class="warning">'.I18N::translate('No data is available for the general analysis.').'</p>'; |
|
292 | 292 | } |
293 | 293 | return $html; |
294 | 294 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | * @return string HTML code for the generations tab |
303 | 303 | */ |
304 | 304 | protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null) { |
305 | - if(!empty($placesGenerationsResults) && $ga->getOptions()){ |
|
305 | + if (!empty($placesGenerationsResults) && $ga->getOptions()) { |
|
306 | 306 | $data = new ViewBag(); |
307 | 307 | |
308 | 308 | ksort($placesGenerationsResults); |
@@ -315,26 +315,26 @@ discard block |
||
315 | 315 | $data->set('display_all_places', $display_all_places); |
316 | 316 | |
317 | 317 | $results_by_gen = array(); |
318 | - foreach($placesGenerationsResults as $gen => $genData){ |
|
318 | + foreach ($placesGenerationsResults as $gen => $genData) { |
|
319 | 319 | $sum = 0; |
320 | 320 | $other = 0; |
321 | 321 | $unknown = 0; |
322 | - if(isset($genData['sum'])) $sum = $genData['sum']; |
|
323 | - if(isset($genData['other'])) $other = $genData['other']; |
|
324 | - if(isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
322 | + if (isset($genData['sum'])) $sum = $genData['sum']; |
|
323 | + if (isset($genData['other'])) $other = $genData['other']; |
|
324 | + if (isset($genData['unknown'])) $unknown = $genData['unknown']; |
|
325 | 325 | |
326 | - if($sum > 0) { |
|
326 | + if ($sum > 0) { |
|
327 | 327 | $results_by_gen[$gen]['sum'] = $sum; |
328 | 328 | $results_by_gen[$gen]['other'] = $other; |
329 | 329 | $results_by_gen[$gen]['unknown'] = $unknown; |
330 | 330 | $results_by_gen[$gen]['places'] = array(); |
331 | 331 | arsort($genData['places']); |
332 | 332 | |
333 | - if($display_all_places){ |
|
334 | - foreach($genData['places'] as $placename=> $count){ |
|
333 | + if ($display_all_places) { |
|
334 | + foreach ($genData['places'] as $placename=> $count) { |
|
335 | 335 | $results_by_gen[$gen]['places'][$placename]['count'] = $count; |
336 | 336 | |
337 | - if($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != ''){ |
|
337 | + if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') { |
|
338 | 338 | $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, Globals::getTree()); |
339 | 339 | $results_by_gen[$gen]['places'][$placename]['flag'] = $flag; |
340 | 340 | } |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | } |
343 | 343 | else { |
344 | 344 | $tmp = $genData['places']; |
345 | - if($other > 0) { |
|
345 | + if ($other > 0) { |
|
346 | 346 | $tmp = array_slice($tmp, 0, 5, true); |
347 | 347 | $tmp['other'] = $other; |
348 | 348 | arsort($tmp); |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | |
359 | 359 | } |
360 | 360 | else { |
361 | - $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>'; |
|
361 | + $html = '<p class="warning">'.I18N::translate('No data is available for the generations analysis.').'</p>'; |
|
362 | 362 | } |
363 | 363 | return $html; |
364 | 364 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | $this->is_loaded = false; |
71 | 71 | $this->subdivisions = array(); |
72 | 72 | $this->mappings = array(); |
73 | - if($load) $this->load(); |
|
73 | + if ($load) $this->load(); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | * |
100 | 100 | */ |
101 | 101 | protected function load() { |
102 | - if(file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)){ |
|
102 | + if (file_exists(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename)) { |
|
103 | 103 | $xml = simplexml_load_file(WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'.$this->filename); |
104 | - if($xml){ |
|
104 | + if ($xml) { |
|
105 | 105 | $this->description = trim($xml->displayName); |
106 | 106 | $this->top_level_name = trim($xml->topLevel); |
107 | 107 | $this->canvas = new OutlineMapCanvas( |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | trim($xml->canvas->defaultcolor), |
115 | 115 | trim($xml->canvas->defaultstroke) |
116 | 116 | ); |
117 | - foreach($xml->subdivisions->children() as $subdivision){ |
|
117 | + foreach ($xml->subdivisions->children() as $subdivision) { |
|
118 | 118 | $attributes = $subdivision->attributes(); |
119 | 119 | $key = trim($attributes['name']); |
120 | - if(isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
120 | + if (isset($attributes['parent'])) $key .= '@'.trim($attributes['parent']); |
|
121 | 121 | $this->subdivisions[$key] = array( |
122 | 122 | 'id' => trim($attributes['id']), |
123 | 123 | 'displayname' => trim($attributes['name']), |
124 | 124 | 'coord' => trim($subdivision[0]) |
125 | 125 | ); |
126 | 126 | } |
127 | - if(isset($xml->mappings)) { |
|
128 | - foreach($xml->mappings->children() as $mappings){ |
|
127 | + if (isset($xml->mappings)) { |
|
128 | + foreach ($xml->mappings->children() as $mappings) { |
|
129 | 129 | $attributes = $mappings->attributes(); |
130 | 130 | $this->mappings[trim($attributes['name'])] = trim($attributes['mapto']); |
131 | 131 | } |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | * @return bool |
144 | 144 | */ |
145 | 145 | public function isLoaded() { |
146 | - try{ |
|
147 | - if(!$this->is_loaded) $this->load(); |
|
146 | + try { |
|
147 | + if (!$this->is_loaded) $this->load(); |
|
148 | 148 | } |
149 | 149 | catch (\Exception $ex) { } |
150 | 150 | return $this->is_loaded; |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return string |
164 | 164 | */ |
165 | 165 | public function getDescription() { |
166 | - if(!$this->is_loaded) $this->load(); |
|
166 | + if (!$this->is_loaded) $this->load(); |
|
167 | 167 | return $this->description; |
168 | 168 | } |
169 | 169 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @return string |
173 | 173 | */ |
174 | 174 | public function getTopLevelName() { |
175 | - if(!$this->is_loaded) $this->load(); |
|
175 | + if (!$this->is_loaded) $this->load(); |
|
176 | 176 | return $this->top_level_name; |
177 | 177 | } |
178 | 178 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMapCanvas |
182 | 182 | */ |
183 | 183 | public function getCanvas() { |
184 | - if(!$this->is_loaded) $this->load(); |
|
184 | + if (!$this->is_loaded) $this->load(); |
|
185 | 185 | return $this->canvas; |
186 | 186 | } |
187 | 187 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return array |
191 | 191 | */ |
192 | 192 | public function getSubdivisions() { |
193 | - if(!$this->is_loaded) $this->load(); |
|
193 | + if (!$this->is_loaded) $this->load(); |
|
194 | 194 | return $this->subdivisions; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * @return array |
200 | 200 | */ |
201 | 201 | public function getPlacesMappings() { |
202 | - if(!$this->is_loaded) $this->load(); |
|
202 | + if (!$this->is_loaded) $this->load(); |
|
203 | 203 | return $this->mappings; |
204 | 204 | } |
205 | 205 |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return string |
164 | 164 | */ |
165 | 165 | public function getHtmlUrl() { |
166 | - return 'module.php?mod='. Constants::MODULE_MAJ_GEODISP_NAME . '&mod_action=GeoAnalysis&ga_id=' . $this->getId() . '&ged=' . $this->tree->getNameUrl(); |
|
166 | + return 'module.php?mod='.Constants::MODULE_MAJ_GEODISP_NAME.'&mod_action=GeoAnalysis&ga_id='.$this->getId().'&ged='.$this->tree->getNameUrl(); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -186,53 +186,53 @@ discard block |
||
186 | 186 | $placesDispGeneral = null; |
187 | 187 | $placesDispGenerations = null; |
188 | 188 | |
189 | - if($sosalist && count($sosalist) > 0) { |
|
189 | + if ($sosalist && count($sosalist) > 0) { |
|
190 | 190 | $placesDispGeneral['knownsum'] = 0; |
191 | 191 | $placesDispGeneral['unknown'] = 0; |
192 | 192 | $placesDispGeneral['max'] = 0; |
193 | 193 | $placesDispGeneral['places'] = array(); |
194 | - foreach($sosalist as $sosaid => $gens) { |
|
194 | + foreach ($sosalist as $sosaid => $gens) { |
|
195 | 195 | $sosa = Individual::getIntance($sosaid, $this->tree); |
196 | - $place =$sosa->getSignificantPlace(); |
|
196 | + $place = $sosa->getSignificantPlace(); |
|
197 | 197 | $genstab = explode(',', $gens); |
198 | - $isUnknown=true; |
|
199 | - if($sosa->getDerivedRecord()->canShow() && !is_null($place)){ |
|
200 | - $levels = array_reverse(array_map('trim',explode(',', $place))); |
|
201 | - if(count($levels)>= $this->analysis_level){ |
|
198 | + $isUnknown = true; |
|
199 | + if ($sosa->getDerivedRecord()->canShow() && !is_null($place)) { |
|
200 | + $levels = array_reverse(array_map('trim', explode(',', $place))); |
|
201 | + if (count($levels) >= $this->analysis_level) { |
|
202 | 202 | $toplevelvalues = array(); |
203 | - if($this->hasMap() |
|
203 | + if ($this->hasMap() |
|
204 | 204 | && $this->options->getMap()->isLoaded() |
205 | 205 | && $toplevelvalue = $this->options->getMap()->getTopLevelName() |
206 | 206 | ) { |
207 | - $toplevelvalues = array_map('trim',explode(',', strtolower($toplevelvalue))); |
|
207 | + $toplevelvalues = array_map('trim', explode(',', strtolower($toplevelvalue))); |
|
208 | 208 | } |
209 | - if(!$this->hasMap() |
|
209 | + if (!$this->hasMap() |
|
210 | 210 | || is_null($this->options->getMapLevel()) |
211 | - || ( $this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
211 | + || ($this->options->getMap()->isLoaded() && $this->options->getMap()->getTopLevelName() == '*') |
|
212 | 212 | || ( |
213 | 213 | $this->options->getMapLevel() <= $this->analysis_level |
214 | 214 | && $this->options->getMapLevel() > 0 |
215 | 215 | && count($levels) >= $this->options->getMapLevel() |
216 | - && in_array(strtolower($levels[$this->options->getMapLevel()-1]), $toplevelvalues) |
|
216 | + && in_array(strtolower($levels[$this->options->getMapLevel() - 1]), $toplevelvalues) |
|
217 | 217 | ) |
218 | 218 | ) { |
219 | 219 | $placest = implode(I18N::$list_separator, array_slice($levels, 0, $this->analysis_level)); |
220 | - if(isset($placesDispGeneral['places'][$placest])) { |
|
220 | + if (isset($placesDispGeneral['places'][$placest])) { |
|
221 | 221 | $placesDispGeneral['places'][$placest] += 1; |
222 | 222 | } |
223 | 223 | else { |
224 | 224 | $placesDispGeneral['places'][$placest] = 1; |
225 | 225 | } |
226 | - if($placesDispGeneral['places'][$placest]>$placesDispGeneral['max']) |
|
226 | + if ($placesDispGeneral['places'][$placest] > $placesDispGeneral['max']) |
|
227 | 227 | $placesDispGeneral['max'] = $placesDispGeneral['places'][$placest]; |
228 | - foreach($genstab as $gen) { |
|
229 | - if(isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
228 | + foreach ($genstab as $gen) { |
|
229 | + if (isset($placesDispGenerations[$gen]['places'][$placest])) { |
|
230 | 230 | $placesDispGenerations[$gen]['places'][$placest] += 1; |
231 | 231 | } |
232 | 232 | else { |
233 | 233 | $placesDispGenerations[$gen]['places'][$placest] = 1; |
234 | 234 | } |
235 | - if(isset($placesDispGenerations[$gen]['sum'])) { |
|
235 | + if (isset($placesDispGenerations[$gen]['sum'])) { |
|
236 | 236 | $placesDispGenerations[$gen]['sum'] += 1; |
237 | 237 | } |
238 | 238 | else { |
@@ -240,15 +240,15 @@ discard block |
||
240 | 240 | } |
241 | 241 | } |
242 | 242 | } |
243 | - else{ |
|
244 | - if(isset($placesDispGeneral['other'])) { |
|
243 | + else { |
|
244 | + if (isset($placesDispGeneral['other'])) { |
|
245 | 245 | $placesDispGeneral['other'] += 1; |
246 | 246 | } |
247 | 247 | else { |
248 | 248 | $placesDispGeneral['other'] = 1; |
249 | 249 | } |
250 | - foreach($genstab as $gen) { |
|
251 | - if(isset($placesDispGenerations[$gen]['other'])) { |
|
250 | + foreach ($genstab as $gen) { |
|
251 | + if (isset($placesDispGenerations[$gen]['other'])) { |
|
252 | 252 | $placesDispGenerations[$gen]['other'] += 1; |
253 | 253 | } |
254 | 254 | else { |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | $isUnknown = false; |
261 | 261 | } |
262 | 262 | } |
263 | - if($isUnknown){ |
|
263 | + if ($isUnknown) { |
|
264 | 264 | $placesDispGeneral['unknown'] += 1; |
265 | - foreach($genstab as $gen) { |
|
266 | - if(isset($placesDispGenerations[$gen]['unknown'])) { |
|
265 | + foreach ($genstab as $gen) { |
|
266 | + if (isset($placesDispGenerations[$gen]['unknown'])) { |
|
267 | 267 | $placesDispGenerations[$gen]['unknown'] += 1; |
268 | 268 | } |
269 | 269 | else { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | <form class="form-horizontal" name="newform" method="post" role="form" action="<?php echo $this->data->get('save_url'); ?>" autocomplete="off"> |
46 | 46 | <?php echo Filter::getCsrf(); ?> |
47 | - <?php if(!$is_new) { ?> |
|
47 | + <?php if (!$is_new) { ?> |
|
48 | 48 | <input type="hidden" name="ga_id" value="<?php echo $ga->getId(); ?>"> |
49 | 49 | <?php } ?> |
50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | <?php echo I18N::translate('Description'); ?> |
55 | 55 | </label> |
56 | 56 | <div class="col-sm-9"> |
57 | - <input class="form-control" type="text" id="description" name="description" required maxlength="70" <?php if(!$is_new) echo 'value="' . Filter::escapeHtml($ga->getTitle()) .'"'; ?> dir="auto"> |
|
57 | + <input class="form-control" type="text" id="description" name="description" required maxlength="70" <?php if (!$is_new) echo 'value="'.Filter::escapeHtml($ga->getTitle()).'"'; ?> dir="auto"> |
|
58 | 58 | <p class="small text-muted"> |
59 | 59 | <?php echo I18N::translate('Description to be given to the geographical dispersion analysis. It will be used as the page title for it.'); ?> |
60 | 60 | </p> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | <?php echo I18N::translate('Map'); ?> |
98 | 98 | </label> |
99 | 99 | <div class="col-sm-9"> |
100 | - <?php echo FunctionsEdit::selectEditControl('map_file', $this->data->get('map_list') , null, ($is_new || ! $ga->hasMap()) ? '' : base64_encode($ga->getOptions()->getMap()->getFileName()), 'class="form-control"'); ?> |
|
100 | + <?php echo FunctionsEdit::selectEditControl('map_file', $this->data->get('map_list'), null, ($is_new || !$ga->hasMap()) ? '' : base64_encode($ga->getOptions()->getMap()->getFileName()), 'class="form-control"'); ?> |
|
101 | 101 | <p class="small text-muted"> |
102 | 102 | <?php echo I18N::translate('Map outline to be used for the result display.'); ?> |
103 | 103 | </p> |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | <?php echo I18N::translate('Map parent level'); ?> |
111 | 111 | </label> |
112 | 112 | <div class="col-sm-9"> |
113 | - <?php echo FunctionsEdit::selectEditControl('map_top_level', $places_hierarchy['hierarchy'], null, $is_new || ! $ga->hasMap() ? '' : $ga->getOptions()->getMapLevel() - 1, 'class="form-control"'); ?> |
|
113 | + <?php echo FunctionsEdit::selectEditControl('map_top_level', $places_hierarchy['hierarchy'], null, $is_new || !$ga->hasMap() ? '' : $ga->getOptions()->getMapLevel() - 1, 'class="form-control"'); ?> |
|
114 | 114 | <p class="small text-muted"> |
115 | 115 | <?php echo I18N::translate('Subdivision level of the parent subdivision(s) represented by the map.'); ?><br /> |
116 | 116 | <?php echo I18N::translate('For instance, if the map is intended to represent a country by county analysis, then the map parent level would be “Country”, and the analysis level would be “County”.'); ?> |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | /** @var OutlineMap $map */ |
31 | 31 | $map = $this->data->get('map'); |
32 | 32 | |
33 | - if($map === null) { |
|
34 | - return '<p class="warning">' . |
|
35 | - I18N::translate('The map could not be loaded.') . |
|
33 | + if ($map === null) { |
|
34 | + return '<p class="warning">'. |
|
35 | + I18N::translate('The map could not be loaded.'). |
|
36 | 36 | '</p>'; |
37 | 37 | } |
38 | 38 | |
@@ -82,23 +82,23 @@ discard block |
||
82 | 82 | } |
83 | 83 | }); |
84 | 84 | |
85 | - var paper = new Raphael(document.getElementById("geodispersion_map"), '. $canvas->width .', '. $canvas->height .'); |
|
86 | - var background = paper.rect(0, 0, ' . $canvas->width . ', '. $canvas->height . '); |
|
87 | - background.attr({"fill" : "'. $canvas->background_color .'", "stroke" : "'. $canvas->background_stroke .'", "stroke-width": 1, "stroke-linejoin": "round" }); |
|
88 | - var attr = { fill: "'. $canvas->default_color .'", stroke: "'. $canvas->default_stroke .'", "stroke-width": 1, "stroke-linejoin": "round" }; |
|
85 | + var paper = new Raphael(document.getElementById("geodispersion_map"), '. $canvas->width.', '.$canvas->height.'); |
|
86 | + var background = paper.rect(0, 0, ' . $canvas->width.', '.$canvas->height.'); |
|
87 | + background.attr({"fill" : "'. $canvas->background_color.'", "stroke" : "'.$canvas->background_stroke.'", "stroke-width": 1, "stroke-linejoin": "round" }); |
|
88 | + var attr = { fill: "'. $canvas->default_color.'", stroke: "'.$canvas->default_stroke.'", "stroke-width": 1, "stroke-linejoin": "round" }; |
|
89 | 89 | var map = {}; |
90 | 90 | '; |
91 | 91 | |
92 | - foreach($subdvisions_results as $name => $location){ |
|
93 | - $html.= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | - if(isset($location['transparency'])) { |
|
92 | + foreach ($subdvisions_results as $name => $location) { |
|
93 | + $html .= 'map.area'.$location['id'].' = paper.path("'.$location['coord'].'").attr(attr);'; |
|
94 | + if (isset($location['transparency'])) { |
|
95 | 95 | $textToolTip = '<strong>'.$location['displayname'].'</strong><br/>'; |
96 | - if($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
96 | + if ($this->data->get('use_flags') && $location['flag'] != '') $textToolTip .= '<span class="geodispersion_flag">'.FunctionsPrint::htmlPlaceIcon($location['place'], $location['flag']).'</span><br/>'; |
|
97 | 97 | $textToolTip .= I18N::translate('%d individuals', $location['count']).'<br/>'.I18N::percentage(Functions::safeDivision($location['count'], $nb_found - $nb_other), 1); |
98 | - $html.= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | - $html.= 'map.area'.$location['id'].'.attr({"fill" : "'. $canvas->max_color .'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | - $html.= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | - 'map.area'.$location['id'].'.stop().animate({"fill" : "'. $canvas->hover_color .'", "fill-opacity" : 1}, 100, "linear");'. |
|
98 | + $html .= 'addTip(map.area'.$location['id'].'.node, "'.Filter::escapeJs($textToolTip).'");'; |
|
99 | + $html .= 'map.area'.$location['id'].'.attr({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].' });'; |
|
100 | + $html .= 'map.area'.$location['id'].'.mouseover(function () {'. |
|
101 | + 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->hover_color.'", "fill-opacity" : 1}, 100, "linear");'. |
|
102 | 102 | '});'. |
103 | 103 | 'map.area'.$location['id'].'.mouseout(function () {'. |
104 | 104 | 'map.area'.$location['id'].'.stop().animate({"fill" : "'.$canvas->max_color.'", "fill-opacity" : '.$location['transparency'].'}, 100, "linear");'. |
@@ -71,14 +71,14 @@ discard block |
||
71 | 71 | $data->set('title', $controller->getPageTitle()); |
72 | 72 | $data->set('tree', $wt_tree); |
73 | 73 | |
74 | - $data->set('root_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig'); |
|
74 | + $data->set('root_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig'); |
|
75 | 75 | |
76 | - $table_id = 'table-geoanalysis-' . Uuid::uuid4(); |
|
76 | + $table_id = 'table-geoanalysis-'.Uuid::uuid4(); |
|
77 | 77 | $data->set('table_id', $table_id); |
78 | 78 | |
79 | 79 | $other_trees = array(); |
80 | 80 | foreach (Tree::getAll() as $tree) { |
81 | - if($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
81 | + if ($tree->getTreeId() != $wt_tree->getTreeId()) $other_trees[] = $tree; |
|
82 | 82 | } |
83 | 83 | $data->set('other_trees', $other_trees); |
84 | 84 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | processing: true, |
102 | 102 | serverSide : true, |
103 | 103 | ajax : { |
104 | - url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='. $wt_tree->getNameUrl().'", |
|
104 | + url : "module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@jsonGeoAnalysisList&ged='.$wt_tree->getNameUrl().'", |
|
105 | 105 | type : "POST" |
106 | 106 | }, |
107 | 107 | columns: [ |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | url: "module.php", |
126 | 126 | type: "GET", |
127 | 127 | data: { |
128 | - mod: "' . $this->module->getName() .'", |
|
128 | + mod: "' . $this->module->getName().'", |
|
129 | 129 | mod_action: "GeoAnalysis@setStatus", |
130 | 130 | ga_id: ga_id, |
131 | 131 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom, |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | }, |
134 | 134 | error: function(result, stat, error) { |
135 | 135 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
136 | - alert("' . I18N::translate('An error occured while editing this analysis:') . '" + err); |
|
136 | + alert("' . I18N::translate('An error occured while editing this analysis:').'" + err); |
|
137 | 137 | }, |
138 | 138 | complete: function(result, stat) { |
139 | 139 | geoAnalysisTable.ajax.reload(null, false); |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | url: "module.php", |
147 | 147 | type: "GET", |
148 | 148 | data: { |
149 | - mod: "' . $this->module->getName() .'", |
|
149 | + mod: "' . $this->module->getName().'", |
|
150 | 150 | mod_action: "GeoAnalysis@delete", |
151 | 151 | ga_id: ga_id, |
152 | 152 | ged: typeof gedcom === "undefined" ? WT_GEDCOM : gedcom |
153 | 153 | }, |
154 | 154 | error: function(result, stat, error) { |
155 | 155 | var err = typeof result.responseJSON === "undefined" ? error : result.responseJSON.error; |
156 | - alert("' . I18N::translate('An error occured while deleting this analysis:') . '" + err); |
|
156 | + alert("' . I18N::translate('An error occured while deleting this analysis:').'" + err); |
|
157 | 157 | }, |
158 | 158 | complete: function(result, stat) { |
159 | 159 | geoAnalysisTable.ajax.reload(null, false); |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | |
178 | 178 | // Generate an AJAX/JSON response for datatables to load a block of rows |
179 | 179 | $search = Filter::postArray('search'); |
180 | - if($search) $search = $search['value']; |
|
180 | + if ($search) $search = $search['value']; |
|
181 | 181 | $start = Filter::postInteger('start'); |
182 | 182 | $length = Filter::postInteger('length'); |
183 | 183 | $order = Filter::postArray('order'); |
184 | 184 | |
185 | - foreach($order as $key => &$value) { |
|
186 | - switch($value['column']) { |
|
185 | + foreach ($order as $key => &$value) { |
|
186 | + switch ($value['column']) { |
|
187 | 187 | case 3: |
188 | 188 | $value['column'] = 'majgd_descr'; |
189 | 189 | break; |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | |
205 | 205 | $data = array(); |
206 | 206 | $place_hierarchy = $this->provider->getPlacesHierarchy(); |
207 | - foreach($list as $ga) { |
|
207 | + foreach ($list as $ga) { |
|
208 | 208 | /** @var GeoAnalysis $ga */ |
209 | 209 | |
210 | 210 | $datum = array(); |
211 | - $options= $ga->getOptions(); |
|
211 | + $options = $ga->getOptions(); |
|
212 | 212 | |
213 | 213 | $datum[0] = ' |
214 | 214 | <div class="btn-group"> |
@@ -218,45 +218,44 @@ discard block |
||
218 | 218 | <ul class="dropdown-menu" role="menu"> |
219 | 219 | <li> |
220 | 220 | <a href="#" onclick="return set_geoanalysis_status('. $ga->getId().', '.($ga->isEnabled() ? 'false' : 'true').', \''.Filter::escapeJs($wt_tree->getName()).'\');"> |
221 | - <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> ' . ($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')) . ' |
|
221 | + <i class="fa fa-fw '.($ga->isEnabled() ? 'fa-times' : 'fa-check').'"></i> '.($ga->isEnabled() ? I18N::translate('Disable') : I18N::translate('Enable')).' |
|
222 | 222 | </a> |
223 | 223 | </li> |
224 | 224 | <li> |
225 | 225 | <a href="module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getName().'"> |
226 | - <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit') . ' |
|
226 | + <i class="fa fa-fw fa-pencil"></i> ' . I18N::translate('Edit').' |
|
227 | 227 | </a> |
228 | 228 | </li> |
229 | 229 | <li class="divider" /> |
230 | 230 | <li> |
231 | 231 | <a href="#" onclick="return delete_geoanalysis('. $ga->getId().', \''.Filter::escapeJs($wt_tree->getName()).'\');"> |
232 | - <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete') . ' |
|
232 | + <i class="fa fa-fw fa-trash-o"></i> ' . I18N::translate('Delete').' |
|
233 | 233 | </a> |
234 | 234 | </li> |
235 | 235 | </ul> |
236 | 236 | </div>'; |
237 | 237 | $datum[1] = $ga->getId(); |
238 | 238 | $datum[2] = $ga->isEnabled() ? |
239 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : |
|
240 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
239 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Enabled').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('Disabled').'</span>'; |
|
241 | 240 | $datum[3] = $ga->getTitle(); |
242 | 241 | $analysis_level = $ga->getAnalysisLevel(); |
243 | - if($place_hierarchy['type'] == 'header') { |
|
242 | + if ($place_hierarchy['type'] == 'header') { |
|
244 | 243 | $datum[4] = $place_hierarchy['hierarchy'][$analysis_level - 1]; |
245 | 244 | } else { |
246 | - $datum[4] = $analysis_level . '(' . $place_hierarchy['hierarchy'][$analysis_level - 1] . ')'; |
|
245 | + $datum[4] = $analysis_level.'('.$place_hierarchy['hierarchy'][$analysis_level - 1].')'; |
|
247 | 246 | } |
248 | 247 | $datum[5] = $ga->getAnalysisLevel(); |
249 | 248 | $datum[6] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
250 | 249 | $datum[7] = '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('None').'</span>'; |
251 | - if($ga->hasMap()) { |
|
252 | - if($options->getMap()->isLoaded()) { |
|
250 | + if ($ga->hasMap()) { |
|
251 | + if ($options->getMap()->isLoaded()) { |
|
253 | 252 | $datum[6] = $options->getMap()->getDescription(); |
254 | - $datum[7] = '<span data-toggle="tooltip" title="' . $options->getMap()->getTopLevelName() . '" />'; |
|
253 | + $datum[7] = '<span data-toggle="tooltip" title="'.$options->getMap()->getTopLevelName().'" />'; |
|
255 | 254 | $top_level = $options->getMapLevel(); |
256 | - if($place_hierarchy['type'] == 'header') { |
|
255 | + if ($place_hierarchy['type'] == 'header') { |
|
257 | 256 | $datum[7] .= $place_hierarchy['hierarchy'][$top_level - 1]; |
258 | 257 | } else { |
259 | - $datum[7] .= $top_level . '(' . $place_hierarchy['hierarchy'][$top_level - 1] . ')'; |
|
258 | + $datum[7] .= $top_level.'('.$place_hierarchy['hierarchy'][$top_level - 1].')'; |
|
260 | 259 | } |
261 | 260 | $datum[7] .= '</span>'; |
262 | 261 | } |
@@ -265,8 +264,7 @@ discard block |
||
265 | 264 | } |
266 | 265 | } |
267 | 266 | $datum[8] = $options->isUsingFlags() ? |
268 | - '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : |
|
269 | - '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
267 | + '<i class="fa fa-check"></i><span class="sr-only">'.I18N::translate('Yes').'</span>' : '<i class="fa fa-times"></i><span class="sr-only">'.I18N::translate('No').'</span>'; |
|
270 | 268 | $datum[9] = $options->getMaxDetailsInGen() > 0 ? $options->getMaxDetailsInGen() : I18N::translate('All'); |
271 | 269 | |
272 | 270 | $data[] = $datum; |
@@ -315,24 +313,24 @@ discard block |
||
315 | 313 | $description = Filter::post('description'); |
316 | 314 | $analysislevel = Filter::postInteger('analysislevel'); |
317 | 315 | $use_map = Filter::postBool('use_map'); |
318 | - if($use_map) { |
|
316 | + if ($use_map) { |
|
319 | 317 | $map_file = base64_decode(Filter::post('map_file')); |
320 | - $map_top_level = Filter::postInteger('map_top_level'); |
|
318 | + $map_top_level = Filter::postInteger('map_top_level'); |
|
321 | 319 | } |
322 | 320 | $use_flags = Filter::postBool('use_flags'); |
323 | 321 | $gen_details = Filter::postInteger('gen_details'); |
324 | 322 | |
325 | 323 | $success = false; |
326 | - if($ga_id) { |
|
324 | + if ($ga_id) { |
|
327 | 325 | $ga = $this->provider->getGeoAnalysis($ga_id, false); |
328 | - if($ga) { |
|
326 | + if ($ga) { |
|
329 | 327 | $ga->setTitle($description); |
330 | 328 | $ga->setAnalysisLevel($analysislevel + 1); |
331 | 329 | $options = $ga->getOptions(); |
332 | - if($options) { |
|
330 | + if ($options) { |
|
333 | 331 | $options->setUsingFlags($use_flags); |
334 | 332 | $options->setMaxDetailsInGen($gen_details); |
335 | - if($use_map) { |
|
333 | + if ($use_map) { |
|
336 | 334 | $options->setMap(new OutlineMap($map_file)); |
337 | 335 | $options->setMapLevel($map_top_level + 1); |
338 | 336 | } |
@@ -342,7 +340,7 @@ discard block |
||
342 | 340 | } |
343 | 341 | |
344 | 342 | $res = $this->provider->updateGeoAnalysis($ga); |
345 | - if($res) { |
|
343 | + if ($res) { |
|
346 | 344 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully updated', $res->getTitle()), 'success'); |
347 | 345 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$res->getId().'” has been updated.'); |
348 | 346 | $ga = $res; |
@@ -350,7 +348,7 @@ discard block |
||
350 | 348 | } |
351 | 349 | else { |
352 | 350 | FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger'); |
353 | - Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'. $ga->getId() .'” could not be updated. See error log.'); |
|
351 | + Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” could not be updated. See error log.'); |
|
354 | 352 | } |
355 | 353 | } |
356 | 354 | } else { |
@@ -362,7 +360,7 @@ discard block |
||
362 | 360 | $use_flags, |
363 | 361 | $gen_details |
364 | 362 | ); |
365 | - if($ga) { |
|
363 | + if ($ga) { |
|
366 | 364 | FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success'); |
367 | 365 | Log::addConfigurationLog('Module '.$this->module->getName().' : Geo Analysis ID “'.$ga->getId().'” has been added.'); |
368 | 366 | $success = true; |
@@ -373,16 +371,16 @@ discard block |
||
373 | 371 | } |
374 | 372 | } |
375 | 373 | |
376 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl(); |
|
377 | - if(!$success) { |
|
378 | - if($ga) { |
|
379 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id='. $ga->getId() .'&ged=' . $wt_tree->getNameUrl(); |
|
374 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl(); |
|
375 | + if (!$success) { |
|
376 | + if ($ga) { |
|
377 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@edit&ga_id='.$ga->getId().'&ged='.$wt_tree->getNameUrl(); |
|
380 | 378 | } |
381 | 379 | else { |
382 | - $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $wt_tree->getNameUrl(); |
|
380 | + $redirection_url = 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@add&ged='.$wt_tree->getNameUrl(); |
|
383 | 381 | } |
384 | 382 | } |
385 | - header('Location: ' . WT_BASE_URL . $redirection_url); |
|
383 | + header('Location: '.WT_BASE_URL.$redirection_url); |
|
386 | 384 | |
387 | 385 | } |
388 | 386 | |
@@ -412,7 +410,7 @@ discard block |
||
412 | 410 | '); |
413 | 411 | |
414 | 412 | $data = new ViewBag(); |
415 | - if($ga) { |
|
413 | + if ($ga) { |
|
416 | 414 | $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis')); |
417 | 415 | $data->set('geo_analysis', $ga); |
418 | 416 | } else { |
@@ -420,9 +418,9 @@ discard block |
||
420 | 418 | } |
421 | 419 | |
422 | 420 | $data->set('title', $controller->getPageTitle()); |
423 | - $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $wt_tree->getNameUrl()); |
|
421 | + $data->set('admin_config_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig&ged='.$wt_tree->getNameUrl()); |
|
424 | 422 | $data->set('module_title', $this->module->getTitle()); |
425 | - $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $wt_tree->getNameUrl()); |
|
423 | + $data->set('save_url', 'module.php?mod='.$this->module->getName().'&mod_action=AdminConfig@save&ged='.$wt_tree->getNameUrl()); |
|
426 | 424 | $data->set('places_hierarchy', $this->provider->getPlacesHierarchy()); |
427 | 425 | |
428 | 426 | $map_list = array_map( |
@@ -435,7 +433,7 @@ discard block |
||
435 | 433 | $data->set('map_list', $map_list); |
436 | 434 | |
437 | 435 | $gen_details = array(0 => I18N::translate('All')); |
438 | - for($i = 1; $i <= 10 ; $i++) $gen_details[$i] = $i; |
|
436 | + for ($i = 1; $i <= 10; $i++) $gen_details[$i] = $i; |
|
439 | 437 | $data->set('generation_details', $gen_details); |
440 | 438 | |
441 | 439 | ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render(); |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | * @param User $user |
85 | 85 | */ |
86 | 86 | public function __construct(Tree $tree, User $user = null) { |
87 | - if(self::$default_user === null) |
|
87 | + if (self::$default_user === null) |
|
88 | 88 | self::$default_user = User::find(-1); |
89 | 89 | |
90 | 90 | $this->tree = $tree; |
91 | 91 | $this->user = $user; |
92 | 92 | $this->is_setup = true; |
93 | - if($this->user === null) $this->user = Auth::user(); |
|
94 | - if(strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
93 | + if ($this->user === null) $this->user = Auth::user(); |
|
94 | + if (strlen($this->user->getUserId()) == 0) $this->user = self::$default_user; |
|
95 | 95 | |
96 | 96 | // Check if the user, or the default user, has a root already setup; |
97 | - if(empty($this->getRootIndiId())) { |
|
98 | - if($this->user == self::$default_user) { // If the default user is not setup |
|
97 | + if (empty($this->getRootIndiId())) { |
|
98 | + if ($this->user == self::$default_user) { // If the default user is not setup |
|
99 | 99 | $this->is_setup = false; |
100 | 100 | } |
101 | 101 | else { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | public function getRootIndi() { |
129 | 129 | $root_indi_id = $this->getRootIndiId(); |
130 | - if(!empty($root_indi_id)) { |
|
130 | + if (!empty($root_indi_id)) { |
|
131 | 131 | return Individual::getInstance($root_indi_id, $this->tree); |
132 | 132 | } |
133 | 133 | return null; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * Remove all Sosa entries related to the gedcom file and user |
142 | 142 | */ |
143 | 143 | public function deleteAll() { |
144 | - if(!$this->is_setup) return; |
|
144 | + if (!$this->is_setup) return; |
|
145 | 145 | Database::prepare( |
146 | 146 | 'DELETE FROM `##maj_sosa`'. |
147 | 147 | ' WHERE majs_gedcom_id= :tree_id and majs_user_id = :user_id ') |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | * @param int $sosa |
158 | 158 | */ |
159 | 159 | public function deleteAncestors($sosa) { |
160 | - if(!$this->is_setup) return; |
|
160 | + if (!$this->is_setup) return; |
|
161 | 161 | $gen = Functions::getGeneration($sosa); |
162 | 162 | Database::prepare( |
163 | 163 | 'DELETE FROM `##maj_sosa`'. |
164 | - ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id' . |
|
165 | - ' AND majs_gen >= :gen' . |
|
164 | + ' WHERE majs_gedcom_id=:tree_id and majs_user_id = :user_id'. |
|
165 | + ' AND majs_gen >= :gen'. |
|
166 | 166 | ' AND FLOOR(majs_sosa / (POW(2, (majs_gen - :gen)))) = :sosa' |
167 | 167 | )->execute(array( |
168 | 168 | 'tree_id' => $this->tree->getTreeId(), |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param array $sosa_records |
178 | 178 | */ |
179 | 179 | public function insertOrUpdate($sosa_records) { |
180 | - if(!$this->is_setup) return; |
|
180 | + if (!$this->is_setup) return; |
|
181 | 181 | |
182 | 182 | $treeid = $this->tree->getTreeId(); |
183 | 183 | $userid = $this->user->getUserId(); |
@@ -185,9 +185,9 @@ discard block |
||
185 | 185 | $values_table = array(); |
186 | 186 | |
187 | 187 | $i = 0; |
188 | - foreach ($sosa_records as $row) { |
|
188 | + foreach ($sosa_records as $row) { |
|
189 | 189 | $gen = Functions::getGeneration($row['sosa']); |
190 | - if($gen <= self::MAX_DB_GENERATIONS) { |
|
190 | + if ($gen <= self::MAX_DB_GENERATIONS) { |
|
191 | 191 | $questionmarks_table[] = |
192 | 192 | '(:tree_id'.$i.', :user_id'.$i.', :sosa'.$i.', :indi_id'.$i.', :gen'.$i.', :byear'.$i.', :dyear'.$i.')'; |
193 | 193 | $values_table = array_merge( |
@@ -206,9 +206,9 @@ discard block |
||
206 | 206 | $i++; |
207 | 207 | } |
208 | 208 | |
209 | - $sql = 'REPLACE INTO `##maj_sosa`' . |
|
210 | - ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)' . |
|
211 | - ' VALUES '. implode(',', $questionmarks_table); |
|
209 | + $sql = 'REPLACE INTO `##maj_sosa`'. |
|
210 | + ' (majs_gedcom_id, majs_user_id, majs_sosa, majs_i_id, majs_gen, majs_birth_year, majs_death_year)'. |
|
211 | + ' VALUES '.implode(',', $questionmarks_table); |
|
212 | 212 | Database::prepare($sql)->execute($values_table); |
213 | 213 | } |
214 | 214 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @return array Array of sosa numbers |
225 | 225 | */ |
226 | 226 | public function getSosaNumbers(Individual $indi) { |
227 | - if(!$this->is_setup) return array(); |
|
227 | + if (!$this->is_setup) return array(); |
|
228 | 228 | return Database::prepare( |
229 | 229 | 'SELECT majs_sosa, majs_gen FROM `##maj_sosa`'. |
230 | 230 | ' WHERE majs_i_id=:indi_id AND majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return number Last generation if found, 1 otherwise |
242 | 242 | */ |
243 | 243 | public function getLastGeneration() { |
244 | - if(!$this->is_setup) return; |
|
244 | + if (!$this->is_setup) return; |
|
245 | 245 | return Database::prepare( |
246 | 246 | 'SELECT MAX(majs_gen) FROM `##maj_sosa`'. |
247 | 247 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @return array Associative array of Sosa ancestors, with their generation, comma separated |
262 | 262 | */ |
263 | - public function getAllSosaWithGenerations(){ |
|
264 | - if(!$this->is_setup) return array(); |
|
263 | + public function getAllSosaWithGenerations() { |
|
264 | + if (!$this->is_setup) return array(); |
|
265 | 265 | return Database::prepare( |
266 | - 'SELECT majs_i_id AS indi,' . |
|
267 | - ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations' . |
|
268 | - ' FROM `##maj_sosa`' . |
|
269 | - ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id' . |
|
266 | + 'SELECT majs_i_id AS indi,'. |
|
267 | + ' GROUP_CONCAT(DISTINCT majs_gen ORDER BY majs_gen ASC SEPARATOR ",") AS generations'. |
|
268 | + ' FROM `##maj_sosa`'. |
|
269 | + ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
|
270 | 270 | ' GROUP BY majs_i_id' |
271 | 271 | )->execute(array( |
272 | 272 | 'tree_id' => $this->tree->getTreeId(), |
@@ -280,13 +280,13 @@ discard block |
||
280 | 280 | * @param number $gen Generation |
281 | 281 | * @return array Array of Sosa individuals |
282 | 282 | */ |
283 | - public function getSosaListAtGeneration($gen){ |
|
284 | - if(!$this->is_setup) return array(); |
|
285 | - if(!$this->sosa_list_by_gen) |
|
283 | + public function getSosaListAtGeneration($gen) { |
|
284 | + if (!$this->is_setup) return array(); |
|
285 | + if (!$this->sosa_list_by_gen) |
|
286 | 286 | $this->sosa_list_by_gen = array(); |
287 | 287 | |
288 | - if($gen){ |
|
289 | - if(!isset($this->sosa_list_by_gen[$gen])){ |
|
288 | + if ($gen) { |
|
289 | + if (!isset($this->sosa_list_by_gen[$gen])) { |
|
290 | 290 | $this->sosa_list_by_gen[$gen] = Database::prepare( |
291 | 291 | 'SELECT majs_sosa AS sosa, majs_i_id AS indi'. |
292 | 292 | ' FROM `##maj_sosa`'. |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | * @param number $gen Generation |
312 | 312 | * @return array Array of Sosa families |
313 | 313 | */ |
314 | - public function getFamilySosaListAtGeneration($gen){ |
|
315 | - if(!$this->is_setup) return array(); |
|
316 | - if(!$this->sosa_fam_list_by_gen) |
|
314 | + public function getFamilySosaListAtGeneration($gen) { |
|
315 | + if (!$this->is_setup) return array(); |
|
316 | + if (!$this->sosa_fam_list_by_gen) |
|
317 | 317 | $this->sosa_fam_list_by_gen = array(); |
318 | 318 | |
319 | - if($gen){ |
|
320 | - if(!isset($this->sosa_fam_list_by_gen[$gen])){ |
|
319 | + if ($gen) { |
|
320 | + if (!isset($this->sosa_fam_list_by_gen[$gen])) { |
|
321 | 321 | $this->sosa_fam_list_by_gen[$gen] = Database::prepare( |
322 | 322 | 'SELECT s1.majs_sosa AS sosa, f_id AS fam'. |
323 | 323 | ' FROM `##families`'. |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | * @param number $gen Generation |
348 | 348 | * @return array Array of Sosa individuals |
349 | 349 | */ |
350 | - public function getMissingSosaListAtGeneration($gen){ |
|
351 | - if(!$this->is_setup) return array(); |
|
352 | - if($gen){ |
|
350 | + public function getMissingSosaListAtGeneration($gen) { |
|
351 | + if (!$this->is_setup) return array(); |
|
352 | + if ($gen) { |
|
353 | 353 | return $this->sosa_list_by_gen[$gen] = Database::prepare( |
354 | 354 | 'SELECT schild.majs_sosa sosa, schild.majs_i_id indi, sfat.majs_sosa IS NOT NULL has_father, smot.majs_sosa IS NOT NULL has_mother'. |
355 | 355 | ' FROM `##maj_sosa` schild'. |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | * @return array Statistics array |
387 | 387 | */ |
388 | 388 | public function getStatisticsByGeneration() { |
389 | - if(!$this->is_setup) return array(); |
|
390 | - if(!$this->statistics_tab) { |
|
389 | + if (!$this->is_setup) return array(); |
|
390 | + if (!$this->statistics_tab) { |
|
391 | 391 | $this->statistics_tab = array(); |
392 | - if($maxGeneration = $this->getLastGeneration()) { |
|
392 | + if ($maxGeneration = $this->getLastGeneration()) { |
|
393 | 393 | for ($gen = 1; $gen <= $maxGeneration; $gen++) { |
394 | 394 | $birthStats = $this->getStatsBirthYearInGeneration($gen); |
395 | 395 | $this->statistics_tab[$gen] = array( |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @return int |
413 | 413 | */ |
414 | 414 | public function getTotalIndividuals() { |
415 | - if(!$this->is_setup) return 0; |
|
415 | + if (!$this->is_setup) return 0; |
|
416 | 416 | return Database::prepare( |
417 | - 'SELECT COUNT(*) FROM `##individuals`' . |
|
417 | + 'SELECT COUNT(*) FROM `##individuals`'. |
|
418 | 418 | ' WHERE i_file = :tree_id') |
419 | 419 | ->execute(array('tree_id' => $this->tree->getTreeId())) |
420 | 420 | ->fetchOne() ?: 0; |
@@ -425,10 +425,10 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @return number Number of Sosas |
427 | 427 | */ |
428 | - public function getSosaCount(){ |
|
429 | - if(!$this->is_setup) return 0; |
|
428 | + public function getSosaCount() { |
|
429 | + if (!$this->is_setup) return 0; |
|
430 | 430 | return Database::prepare( |
431 | - 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
431 | + 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
432 | 432 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
433 | 433 | ->execute(array( |
434 | 434 | 'tree_id' => $this->tree->getTreeId(), |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | * @param number $gen Generation |
443 | 443 | * @return number Number of Sosas in generation |
444 | 444 | */ |
445 | - public function getSosaCountAtGeneration($gen){ |
|
446 | - if(!$this->is_setup) return 0; |
|
445 | + public function getSosaCountAtGeneration($gen) { |
|
446 | + if (!$this->is_setup) return 0; |
|
447 | 447 | return Database::prepare( |
448 | - 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
448 | + 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
449 | 449 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
450 | 450 | ' AND majs_gen= :gen') |
451 | 451 | ->execute(array( |
@@ -461,10 +461,10 @@ discard block |
||
461 | 461 | * @param number $gen Generation |
462 | 462 | * @return number Total number of Sosas up to generation |
463 | 463 | */ |
464 | - public function getSosaCountUpToGeneration($gen){ |
|
465 | - if(!$this->is_setup) return 0; |
|
464 | + public function getSosaCountUpToGeneration($gen) { |
|
465 | + if (!$this->is_setup) return 0; |
|
466 | 466 | return Database::prepare( |
467 | - 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' . |
|
467 | + 'SELECT COUNT(majs_sosa) FROM `##maj_sosa`'. |
|
468 | 468 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
469 | 469 | ' AND majs_gen <= :gen') |
470 | 470 | ->execute(array( |
@@ -479,10 +479,10 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return number Total number of distinct individual |
481 | 481 | */ |
482 | - public function getDifferentSosaCount(){ |
|
483 | - if(!$this->is_setup) return 0; |
|
482 | + public function getDifferentSosaCount() { |
|
483 | + if (!$this->is_setup) return 0; |
|
484 | 484 | return Database::prepare( |
485 | - 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
485 | + 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
486 | 486 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id') |
487 | 487 | ->execute(array( |
488 | 488 | 'tree_id' => $this->tree->getTreeId(), |
@@ -496,10 +496,10 @@ discard block |
||
496 | 496 | * @param number $gen Generation |
497 | 497 | * @return number Number of distinct Sosa individuals up to generation |
498 | 498 | */ |
499 | - public function getDifferentSosaCountUpToGeneration($gen){ |
|
500 | - if(!$this->is_setup) return 0; |
|
499 | + public function getDifferentSosaCountUpToGeneration($gen) { |
|
500 | + if (!$this->is_setup) return 0; |
|
501 | 501 | return Database::prepare( |
502 | - 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`' . |
|
502 | + 'SELECT COUNT(DISTINCT majs_i_id) FROM `##maj_sosa`'. |
|
503 | 503 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
504 | 504 | ' AND majs_gen <= :gen') |
505 | 505 | ->execute(array( |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | * @param number $gen Generation |
520 | 520 | * @return array Birth statistics array |
521 | 521 | */ |
522 | - public function getStatsBirthYearInGeneration($gen){ |
|
523 | - if(!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
522 | + public function getStatsBirthYearInGeneration($gen) { |
|
523 | + if (!$this->is_setup) return array('first' => 0, 'avg' => 0, 'last' => 0); |
|
524 | 524 | return Database::prepare( |
525 | 525 | 'SELECT MIN(majs_birth_year) AS first, AVG(majs_birth_year) AS avg, MAX(majs_birth_year) AS last'. |
526 | - ' FROM `##maj_sosa`' . |
|
526 | + ' FROM `##maj_sosa`'. |
|
527 | 527 | ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id'. |
528 | 528 | ' AND majs_gen=:gen AND NOT majs_birth_year = :birth_year') |
529 | 529 | ->execute(array( |
@@ -539,26 +539,26 @@ discard block |
||
539 | 539 | * |
540 | 540 | * @return number|NULL Mean generation time |
541 | 541 | */ |
542 | - public function getMeanGenerationTime(){ |
|
543 | - if(!$this->is_setup) return; |
|
544 | - if(!$this->statistics_tab){ |
|
542 | + public function getMeanGenerationTime() { |
|
543 | + if (!$this->is_setup) return; |
|
544 | + if (!$this->statistics_tab) { |
|
545 | 545 | $this->getStatisticsByGeneration(); |
546 | 546 | } |
547 | 547 | //Linear regression on x=generation and y=birthdate |
548 | 548 | $sum_xy = 0; |
549 | - $sum_x=0; |
|
550 | - $sum_y=0; |
|
551 | - $sum_x2=0; |
|
552 | - $n=count($this->statistics_tab); |
|
553 | - foreach($this->statistics_tab as $gen=>$stats){ |
|
554 | - $sum_xy+=$gen*$stats['avgBirth']; |
|
555 | - $sum_x+=$gen; |
|
556 | - $sum_y+=$stats['avgBirth']; |
|
557 | - $sum_x2+=$gen*$gen; |
|
549 | + $sum_x = 0; |
|
550 | + $sum_y = 0; |
|
551 | + $sum_x2 = 0; |
|
552 | + $n = count($this->statistics_tab); |
|
553 | + foreach ($this->statistics_tab as $gen=>$stats) { |
|
554 | + $sum_xy += $gen * $stats['avgBirth']; |
|
555 | + $sum_x += $gen; |
|
556 | + $sum_y += $stats['avgBirth']; |
|
557 | + $sum_x2 += $gen * $gen; |
|
558 | 558 | } |
559 | - $denom=($n*$sum_x2)-($sum_x*$sum_x); |
|
560 | - if($denom!=0){ |
|
561 | - return -(($n*$sum_xy)-($sum_x*$sum_y))/($denom); |
|
559 | + $denom = ($n * $sum_x2) - ($sum_x * $sum_x); |
|
560 | + if ($denom != 0) { |
|
561 | + return -(($n * $sum_xy) - ($sum_x * $sum_y)) / ($denom); |
|
562 | 562 | } |
563 | 563 | return null; |
564 | 564 | } |
@@ -586,14 +586,14 @@ discard block |
||
586 | 586 | * @return array |
587 | 587 | */ |
588 | 588 | public function getAncestorDispersionForGen($gen) { |
589 | - if(!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
589 | + if (!$this->is_setup || $gen > 11) return array(); // Going further than 11 gen will be out of range in the query |
|
590 | 590 | return Database::prepare( |
591 | 591 | 'SELECT branches, count(i_id)'. |
592 | 592 | ' FROM ('. |
593 | 593 | ' SELECT i_id,'. |
594 | 594 | ' CASE'. |
595 | 595 | ' WHEN CEIL(LOG2(SUM(branch))) = LOG2(SUM(branch)) THEN SUM(branch)'. |
596 | - ' ELSE -1'. // We put all ancestors shared between some branches in the same bucket |
|
596 | + ' ELSE -1'.// We put all ancestors shared between some branches in the same bucket |
|
597 | 597 | ' END branches'. |
598 | 598 | ' FROM ('. |
599 | 599 | ' SELECT DISTINCT majs_i_id i_id,'. |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | * @return array |
627 | 627 | */ |
628 | 628 | public function getTopMultiSosaAncestorsNoTies($limit) { |
629 | - if(!$this->is_setup) return array(); |
|
629 | + if (!$this->is_setup) return array(); |
|
630 | 630 | return Database::prepare( |
631 | 631 | 'SELECT sosa_i_id, sosa_count FROM ('. |
632 | 632 | ' SELECT'. |
@@ -639,20 +639,20 @@ discard block |
||
639 | 639 | ' COUNT(sosa.majs_sosa) sosa_count,'. |
640 | 640 | ' MIN(sosa.majs_sosa) sosa_min'. |
641 | 641 | ' FROM ##maj_sosa AS sosa'. |
642 | - ' LEFT JOIN ##maj_sosa AS sosa_fat ON sosa_fat.majs_sosa = 2 * sosa.majs_sosa'. // Link to sosa's father |
|
642 | + ' LEFT JOIN ##maj_sosa AS sosa_fat ON sosa_fat.majs_sosa = 2 * sosa.majs_sosa'.// Link to sosa's father |
|
643 | 643 | ' AND sosa.majs_gedcom_id = sosa_fat.majs_gedcom_id'. |
644 | 644 | ' AND sosa.majs_user_id = sosa_fat.majs_user_id'. |
645 | - ' LEFT JOIN ##maj_sosa AS sosa_mot on sosa_mot.majs_sosa = (2 * sosa.majs_sosa + 1)'. // Link to sosa's mother |
|
645 | + ' LEFT JOIN ##maj_sosa AS sosa_mot on sosa_mot.majs_sosa = (2 * sosa.majs_sosa + 1)'.// Link to sosa's mother |
|
646 | 646 | ' AND sosa.majs_gedcom_id = sosa_fat.majs_gedcom_id'. |
647 | 647 | ' AND sosa.majs_user_id = sosa_fat.majs_user_id'. |
648 | 648 | ' WHERE sosa.majs_gedcom_id = :tree_id'. |
649 | 649 | ' AND sosa.majs_user_id = :user_id'. |
650 | - ' AND sosa_fat.majs_sosa IS NULL'. // We keep only root individuals, i.e. those with no father or mother |
|
650 | + ' AND sosa_fat.majs_sosa IS NULL'.// We keep only root individuals, i.e. those with no father or mother |
|
651 | 651 | ' AND sosa_mot.majs_sosa IS NULL'. |
652 | 652 | ' GROUP BY sosa.majs_i_id'. |
653 | - ' HAVING COUNT(sosa.majs_sosa) > 1'. // Limit to the duplicate sosas. |
|
653 | + ' HAVING COUNT(sosa.majs_sosa) > 1'.// Limit to the duplicate sosas. |
|
654 | 654 | ' ORDER BY COUNT(sosa.majs_sosa) DESC'. |
655 | - ' LIMIT ' . ($limit + 1) . // We want to select one more than required |
|
655 | + ' LIMIT '.($limit + 1).// We want to select one more than required |
|
656 | 656 | ' ) AS top_sosa,'. |
657 | 657 | ' (SELECT @prev_count := 0, @keep := 0) x'. |
658 | 658 | ' ORDER BY top_sosa.sosa_count ASC'. |