@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param \Fisharebest\Webtrees\Controller\IndividualController $ctrl_individual_in The Individual Controller to extend |
| 34 | 34 | */ |
| 35 | - public function __construct(fw\Controller\IndividualController $ctrl_individual_in){ |
|
| 35 | + public function __construct(fw\Controller\IndividualController $ctrl_individual_in) { |
|
| 36 | 36 | $this->ctrl_individual = $ctrl_individual_in; |
| 37 | 37 | $this->dindi = new mw\Individual($this->ctrl_individual->getSignificantIndividual()); |
| 38 | 38 | } |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
| 45 | 45 | */ |
| 46 | - public function printHeaderExtensions(){ |
|
| 46 | + public function printHeaderExtensions() { |
|
| 47 | 47 | $hook_extend_indi_header_left = new mw\Hook\Hook('hExtendIndiHeaderLeft'); |
| 48 | 48 | $hook_extend_indi_header_right = new mw\Hook\Hook('hExtendIndiHeaderRight'); |
| 49 | 49 | $hook_extend_indi_header_left = $hook_extend_indi_header_left->execute($this->ctrl_individual); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | echo '<div id="indi_perso_header">', |
| 53 | 53 | '<div id="indi_perso_header_left">'; |
| 54 | 54 | foreach ($hook_extend_indi_header_left as $div) { |
| 55 | - if(count($div)==2){ |
|
| 55 | + if (count($div) == 2) { |
|
| 56 | 56 | echo '<div id="', $div[0], '" class="indi_perso_header_left_div">', |
| 57 | 57 | $div[1], '</div>'; |
| 58 | 58 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | echo '</div>', |
| 61 | 61 | '<div id="indi_perso_header_right">'; |
| 62 | 62 | foreach ($hook_extend_indi_header_right as $div) { |
| 63 | - if(count($div)==2){ |
|
| 63 | + if (count($div) == 2) { |
|
| 64 | 64 | echo '<div id="', $div[0], '" class="indi_perso_header_right_div">', |
| 65 | 65 | $div[1], '</div>'; |
| 66 | 66 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @uses \MyArtJaub\Webtrees\Hook\Hook |
| 77 | 77 | */ |
| 78 | - public function printHeaderExtraIcons(){ |
|
| 78 | + public function printHeaderExtraIcons() { |
|
| 79 | 79 | $hook_extend_indi_header_icons = new Hook('hExtendIndiHeaderIcons'); |
| 80 | 80 | $hook_extend_indi_header_icons = $hook_extend_indi_header_icons->execute($this->ctrl_individual); |
| 81 | 81 | |
@@ -24,16 +24,16 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function upgrade() { |
| 26 | 26 | Database::exec( |
| 27 | - 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
| 28 | - ' majat_name VARCHAR(32) NOT NULL,'. |
|
| 29 | - ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
| 30 | - ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
| 31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
| 32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
| 33 | - ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
| 34 | - ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
| 35 | - ' PRIMARY KEY (majat_name)'. |
|
| 36 | - ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
| 27 | + 'CREATE TABLE IF NOT EXISTS `##maj_admintasks` ('. |
|
| 28 | + ' majat_name VARCHAR(32) NOT NULL,'. |
|
| 29 | + ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
|
| 30 | + ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
|
| 31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
| 32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
| 33 | + ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
|
| 34 | + ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
|
| 35 | + ' PRIMARY KEY (majat_name)'. |
|
| 36 | + ') COLLATE utf8_unicode_ci ENGINE=InnoDB' |
|
| 37 | 37 | ); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -28,8 +28,8 @@ |
||
| 28 | 28 | ' majat_name VARCHAR(32) NOT NULL,'. |
| 29 | 29 | ' majat_status ENUM(\'enabled\',\'disabled\') NOT NULL DEFAULT \'disabled\','. |
| 30 | 30 | ' majat_last_run DATETIME NOT NULL DEFAULT \'2000-01-01 00:00:00\','. |
| 31 | - ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'. // 0 means error, 1 is success |
|
| 32 | - ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'. // In min, Default every week |
|
| 31 | + ' majat_last_result TINYINT(1) NOT NULL DEFAULT 1,'.// 0 means error, 1 is success |
|
| 32 | + ' majat_frequency INTEGER NOT NULL DEFAULT 10080,'.// In min, Default every week |
|
| 33 | 33 | ' majat_nb_occur SMALLINT NOT NULL DEFAULT 0,'. |
| 34 | 34 | ' majat_running TINYINT(1) NOT NULL DEFAULT 0,'. |
| 35 | 35 | ' PRIMARY KEY (majat_name)'. |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
| 66 | 66 | ->setMaxDetailsInGen($row['majgd_detailsgen']); |
| 67 | 67 | |
| 68 | - if($row['majgd_map']) { |
|
| 68 | + if ($row['majgd_map']) { |
|
| 69 | 69 | $options |
| 70 | 70 | ->setMap(new OutlineMap($row['majgd_map'])) |
| 71 | 71 | ->setMapLevel($row['majgd_toplevel']); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $enabled = true; |
| 75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
| 75 | + if (isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
| 76 | 76 | $enabled = false; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | public function getGeoAnalysisCount() { |
| 95 | 95 | return Database::prepare( |
| 96 | - 'SELECT COUNT(majgd_id)' . |
|
| 97 | - ' FROM `##maj_geodispersion`' . |
|
| 96 | + 'SELECT COUNT(majgd_id)'. |
|
| 97 | + ' FROM `##maj_geodispersion`'. |
|
| 98 | 98 | ' WHERE majgd_file = :gedcom_id' |
| 99 | 99 | )->execute(array( |
| 100 | 100 | 'gedcom_id' => $this->tree->getTreeId() |
@@ -110,15 +110,15 @@ discard block |
||
| 110 | 110 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
| 111 | 111 | */ |
| 112 | 112 | public function getGeoAnalysis($id, $only_enabled = true) { |
| 113 | - $args = array ( |
|
| 113 | + $args = array( |
|
| 114 | 114 | 'gedcom_id' => $this->tree->getTreeId(), |
| 115 | 115 | 'ga_id' => $id |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
| 119 | - ' FROM `##maj_geodispersion`' . |
|
| 118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'. |
|
| 119 | + ' FROM `##maj_geodispersion`'. |
|
| 120 | 120 | ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
| 121 | - if($only_enabled) { |
|
| 121 | + if ($only_enabled) { |
|
| 122 | 122 | $sql .= ' AND majgd_status = :status'; |
| 123 | 123 | $args['status'] = 'enabled'; |
| 124 | 124 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
| 128 | 128 | |
| 129 | - if($ga_array) { |
|
| 129 | + if ($ga_array) { |
|
| 130 | 130 | return $this->loadGeoAnalysisFromRow($ga_array); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @return GeoAnalysis |
| 147 | 147 | */ |
| 148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
| 149 | - try{ |
|
| 149 | + try { |
|
| 150 | 150 | Database::beginTransaction(); |
| 151 | 151 | |
| 152 | 152 | Database::prepare( |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | Database::commit(); |
| 170 | 170 | } |
| 171 | - catch(\Exception $ex) { |
|
| 171 | + catch (\Exception $ex) { |
|
| 172 | 172 | Database::rollback(); |
| 173 | 173 | $ga = null; |
| 174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | Database::commit(); |
| 213 | 213 | } |
| 214 | - catch(\Exception $ex) { |
|
| 214 | + catch (\Exception $ex) { |
|
| 215 | 215 | Database::rollback(); |
| 216 | - Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
|
| 216 | + Log::addErrorLog('The Geo Analysis ID “'.$ga->getId().'” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
|
| 217 | 217 | $ga = null; |
| 218 | 218 | } |
| 219 | 219 | return $ga; |
@@ -258,12 +258,12 @@ discard block |
||
| 258 | 258 | * |
| 259 | 259 | * @return array List of enabled maps |
| 260 | 260 | */ |
| 261 | - public function getGeoAnalysisList(){ |
|
| 261 | + public function getGeoAnalysisList() { |
|
| 262 | 262 | $res = array(); |
| 263 | 263 | |
| 264 | 264 | $list = Database::prepare( |
| 265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
| 266 | - ' FROM `##maj_geodispersion`' . |
|
| 265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen'. |
|
| 266 | + ' FROM `##maj_geodispersion`'. |
|
| 267 | 267 | ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
| 268 | 268 | ' ORDER BY majgd_descr' |
| 269 | 269 | )->execute(array( |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | 'status' => 'enabled' |
| 272 | 272 | ))->fetchAll(\PDO::FETCH_ASSOC); |
| 273 | 273 | |
| 274 | - foreach($list as $ga) { |
|
| 274 | + foreach ($list as $ga) { |
|
| 275 | 275 | $res[] = $this->loadGeoAnalysisFromRow($ga); |
| 276 | 276 | } |
| 277 | 277 | |
@@ -287,17 +287,17 @@ discard block |
||
| 287 | 287 | * @param int|null $limit Max number of items to return (for pagination) |
| 288 | 288 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
| 289 | 289 | */ |
| 290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
| 290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null) { |
|
| 291 | 291 | $res = array(); |
| 292 | 292 | |
| 293 | 293 | $sql = |
| 294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
| 295 | - ' FROM `##maj_geodispersion`' . |
|
| 294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status'. |
|
| 295 | + ' FROM `##maj_geodispersion`'. |
|
| 296 | 296 | ' WHERE majgd_file = :gedcom_id'; |
| 297 | 297 | |
| 298 | 298 | $args = array('gedcom_id'=> $this->tree->getTreeId()); |
| 299 | 299 | |
| 300 | - if($search) { |
|
| 300 | + if ($search) { |
|
| 301 | 301 | $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
| 302 | 302 | $args['search'] = $search; |
| 303 | 303 | } |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | switch ($value['dir']) { |
| 313 | 313 | case 'asc': |
| 314 | - $sql .= $value['column'] . ' ASC '; |
|
| 314 | + $sql .= $value['column'].' ASC '; |
|
| 315 | 315 | break; |
| 316 | 316 | case 'desc': |
| 317 | - $sql .= $value['column'] . ' DESC '; |
|
| 317 | + $sql .= $value['column'].' DESC '; |
|
| 318 | 318 | break; |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
| 332 | 332 | |
| 333 | - foreach($data as $ga) { |
|
| 333 | + foreach ($data as $ga) { |
|
| 334 | 334 | $res[] = $this->loadGeoAnalysisFromRow($ga); |
| 335 | 335 | } |
| 336 | 336 | |
@@ -347,8 +347,8 @@ discard block |
||
| 347 | 347 | * @return array |
| 348 | 348 | */ |
| 349 | 349 | public function getPlacesHierarchy() { |
| 350 | - if(!$this->place_hierarchy) { |
|
| 351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
| 350 | + if (!$this->place_hierarchy) { |
|
| 351 | + if ($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
| 352 | 352 | $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
| 353 | 353 | } |
| 354 | 354 | else { |
@@ -367,8 +367,8 @@ discard block |
||
| 367 | 367 | protected function getPlacesHierarchyFromHeader() { |
| 368 | 368 | $head = GedcomRecord::getInstance('HEAD', $this->tree); |
| 369 | 369 | $head_place = $head->getFirstFact('PLAC'); |
| 370 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
| 371 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
| 370 | + if ($head_place && $head_place_value = $head_place->getAttribute('FORM')) { |
|
| 371 | + return array_reverse(array_map('trim', explode(',', $head_place_value))); |
|
| 372 | 372 | } |
| 373 | 373 | return null; |
| 374 | 374 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | $nb_levels = 0; |
| 385 | 385 | |
| 386 | 386 | //Select all '2 PLAC ' tags in the file and create array |
| 387 | - $places_list=array(); |
|
| 387 | + $places_list = array(); |
|
| 388 | 388 | $ged_data = Database::prepare( |
| 389 | 389 | 'SELECT i_gedcom AS gedcom'. |
| 390 | 390 | ' FROM `##individuals`'. |
@@ -401,33 +401,33 @@ discard block |
||
| 401 | 401 | $matches = null; |
| 402 | 402 | preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
| 403 | 403 | foreach ($matches[1] as $match) { |
| 404 | - $places_list[$match]=true; |
|
| 404 | + $places_list[$match] = true; |
|
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | // Unique list of places |
| 409 | - $places_list=array_keys($places_list); |
|
| 409 | + $places_list = array_keys($places_list); |
|
| 410 | 410 | |
| 411 | 411 | //sort the array, limit to unique values, and count them |
| 412 | 412 | usort($places_list, array('I18N', 'strcasecmp')); |
| 413 | 413 | |
| 414 | 414 | //calculate maximum no. of levels to display |
| 415 | 415 | $has_found_good_example = false; |
| 416 | - foreach($places_list as $place){ |
|
| 416 | + foreach ($places_list as $place) { |
|
| 417 | 417 | $levels = explode(",", $place); |
| 418 | 418 | $parts = count($levels); |
| 419 | - if ($parts >= $nb_levels){ |
|
| 419 | + if ($parts >= $nb_levels) { |
|
| 420 | 420 | $nb_levels = $parts; |
| 421 | - if(!$has_found_good_example){ |
|
| 421 | + if (!$has_found_good_example) { |
|
| 422 | 422 | $random_place = $place; |
| 423 | - if(min(array_map('strlen', $levels)) > 0){ |
|
| 423 | + if (min(array_map('strlen', $levels)) > 0) { |
|
| 424 | 424 | $has_found_good_example = true; |
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - return array_reverse(array_map('trim',explode(',', $random_place))); |
|
| 430 | + return array_reverse(array_map('trim', explode(',', $random_place))); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -438,9 +438,9 @@ discard block |
||
| 438 | 438 | public function getOutlineMapsList() { |
| 439 | 439 | $res = array(); |
| 440 | 440 | $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
| 441 | - if(is_dir($root_path)){ |
|
| 441 | + if (is_dir($root_path)) { |
|
| 442 | 442 | $dir = opendir($root_path); |
| 443 | - while (($file=readdir($dir))!== false) { |
|
| 443 | + while (($file = readdir($dir)) !== false) { |
|
| 444 | 444 | if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
| 445 | 445 | $res[base64_encode($file)] = new OutlineMap($file, true); |
| 446 | 446 | } |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | /** |
| 90 | 90 | * Returns the number of geographical analysis (active and inactive). |
| 91 | 91 | * |
| 92 | - * @return int |
|
| 92 | + * @return string|null |
|
| 93 | 93 | */ |
| 94 | 94 | public function getGeoAnalysisCount() { |
| 95 | 95 | return Database::prepare( |
@@ -167,8 +167,7 @@ discard block |
||
| 167 | 167 | $ga = $this->getGeoAnalysis($id, false); |
| 168 | 168 | |
| 169 | 169 | Database::commit(); |
| 170 | - } |
|
| 171 | - catch(\Exception $ex) { |
|
| 170 | + } catch(\Exception $ex) { |
|
| 172 | 171 | Database::rollback(); |
| 173 | 172 | $ga = null; |
| 174 | 173 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
@@ -210,8 +209,7 @@ discard block |
||
| 210 | 209 | $ga = $this->getGeoAnalysis($ga->getId(), false); |
| 211 | 210 | |
| 212 | 211 | Database::commit(); |
| 213 | - } |
|
| 214 | - catch(\Exception $ex) { |
|
| 212 | + } catch(\Exception $ex) { |
|
| 215 | 213 | Database::rollback(); |
| 216 | 214 | Log::addErrorLog('The Geo Analysis ID “' . $ga->getId() . '” failed to be updated. Transaction rollbacked. Exception: '.$ex->getMessage()); |
| 217 | 215 | $ga = null; |
@@ -350,8 +348,7 @@ discard block |
||
| 350 | 348 | if(!$this->place_hierarchy) { |
| 351 | 349 | if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
| 352 | 350 | $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
| 353 | - } |
|
| 354 | - else { |
|
| 351 | + } else { |
|
| 355 | 352 | $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
| 356 | 353 | } |
| 357 | 354 | } |
@@ -21,130 +21,130 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class GeoAnalysisProvider { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Reference tree |
|
| 26 | - * @var Tree $tree |
|
| 27 | - */ |
|
| 28 | - protected $tree; |
|
| 24 | + /** |
|
| 25 | + * Reference tree |
|
| 26 | + * @var Tree $tree |
|
| 27 | + */ |
|
| 28 | + protected $tree; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Cached hierarchy of places in the Gedcom file. |
|
| 32 | - * |
|
| 33 | - * @var (array|null) $place_hierarchy |
|
| 34 | - */ |
|
| 35 | - protected $place_hierarchy; |
|
| 30 | + /** |
|
| 31 | + * Cached hierarchy of places in the Gedcom file. |
|
| 32 | + * |
|
| 33 | + * @var (array|null) $place_hierarchy |
|
| 34 | + */ |
|
| 35 | + protected $place_hierarchy; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Constructor for GeoAnalysis Provider. |
|
| 39 | - * A provider is defined in relation to a specific tree. |
|
| 40 | - * |
|
| 41 | - * @param Tree $tree |
|
| 42 | - */ |
|
| 43 | - public function __construct(Tree $tree) { |
|
| 44 | - $this->tree = $tree; |
|
| 45 | - $this->place_hierarchy = null; |
|
| 46 | - } |
|
| 37 | + /** |
|
| 38 | + * Constructor for GeoAnalysis Provider. |
|
| 39 | + * A provider is defined in relation to a specific tree. |
|
| 40 | + * |
|
| 41 | + * @param Tree $tree |
|
| 42 | + */ |
|
| 43 | + public function __construct(Tree $tree) { |
|
| 44 | + $this->tree = $tree; |
|
| 45 | + $this->place_hierarchy = null; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Creates and returns a GeoAnalysis object from a data row. |
|
| 50 | - * The row data is expected to be an array with the indexes: |
|
| 51 | - * - majgd_id: geodispersion analysis ID |
|
| 52 | - * - majgd_descr: geodispersion analysis description/title |
|
| 53 | - * - majgd_sublevel: Analysis level |
|
| 54 | - * - majgd_useflagsgen: Use flags in places display |
|
| 55 | - * - majgd_detailsgen: Number of top places |
|
| 56 | - * - majgd_map: file name of the map |
|
| 57 | - * - majgd_toplevel: parent level for the map |
|
| 58 | - * |
|
| 59 | - * @param array $row |
|
| 60 | - * @return GeoAnalysis |
|
| 61 | - */ |
|
| 62 | - protected function loadGeoAnalysisFromRow($row) { |
|
| 63 | - $options = new GeoDisplayOptions(); |
|
| 64 | - $options |
|
| 65 | - ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
| 66 | - ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
| 48 | + /** |
|
| 49 | + * Creates and returns a GeoAnalysis object from a data row. |
|
| 50 | + * The row data is expected to be an array with the indexes: |
|
| 51 | + * - majgd_id: geodispersion analysis ID |
|
| 52 | + * - majgd_descr: geodispersion analysis description/title |
|
| 53 | + * - majgd_sublevel: Analysis level |
|
| 54 | + * - majgd_useflagsgen: Use flags in places display |
|
| 55 | + * - majgd_detailsgen: Number of top places |
|
| 56 | + * - majgd_map: file name of the map |
|
| 57 | + * - majgd_toplevel: parent level for the map |
|
| 58 | + * |
|
| 59 | + * @param array $row |
|
| 60 | + * @return GeoAnalysis |
|
| 61 | + */ |
|
| 62 | + protected function loadGeoAnalysisFromRow($row) { |
|
| 63 | + $options = new GeoDisplayOptions(); |
|
| 64 | + $options |
|
| 65 | + ->setUsingFlags($row['majgd_useflagsgen'] == 'yes') |
|
| 66 | + ->setMaxDetailsInGen($row['majgd_detailsgen']); |
|
| 67 | 67 | |
| 68 | - if($row['majgd_map']) { |
|
| 69 | - $options |
|
| 70 | - ->setMap(new OutlineMap($row['majgd_map'])) |
|
| 71 | - ->setMapLevel($row['majgd_toplevel']); |
|
| 72 | - } |
|
| 68 | + if($row['majgd_map']) { |
|
| 69 | + $options |
|
| 70 | + ->setMap(new OutlineMap($row['majgd_map'])) |
|
| 71 | + ->setMapLevel($row['majgd_toplevel']); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $enabled = true; |
|
| 75 | - if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
| 76 | - $enabled = false; |
|
| 77 | - } |
|
| 74 | + $enabled = true; |
|
| 75 | + if(isset($row['majgd_status']) && $row['majgd_status'] == 'disabled') { |
|
| 76 | + $enabled = false; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - return new GeoAnalysis( |
|
| 80 | - $this->tree, |
|
| 81 | - $row['majgd_id'], |
|
| 82 | - $row['majgd_descr'], |
|
| 83 | - $row['majgd_sublevel'], |
|
| 84 | - $options, |
|
| 85 | - $enabled |
|
| 86 | - ); |
|
| 87 | - } |
|
| 79 | + return new GeoAnalysis( |
|
| 80 | + $this->tree, |
|
| 81 | + $row['majgd_id'], |
|
| 82 | + $row['majgd_descr'], |
|
| 83 | + $row['majgd_sublevel'], |
|
| 84 | + $options, |
|
| 85 | + $enabled |
|
| 86 | + ); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Returns the number of geographical analysis (active and inactive). |
|
| 91 | - * |
|
| 92 | - * @return int |
|
| 93 | - */ |
|
| 94 | - public function getGeoAnalysisCount() { |
|
| 95 | - return Database::prepare( |
|
| 96 | - 'SELECT COUNT(majgd_id)' . |
|
| 97 | - ' FROM `##maj_geodispersion`' . |
|
| 98 | - ' WHERE majgd_file = :gedcom_id' |
|
| 99 | - )->execute(array( |
|
| 100 | - 'gedcom_id' => $this->tree->getTreeId() |
|
| 101 | - ))->fetchOne(); |
|
| 102 | - } |
|
| 89 | + /** |
|
| 90 | + * Returns the number of geographical analysis (active and inactive). |
|
| 91 | + * |
|
| 92 | + * @return int |
|
| 93 | + */ |
|
| 94 | + public function getGeoAnalysisCount() { |
|
| 95 | + return Database::prepare( |
|
| 96 | + 'SELECT COUNT(majgd_id)' . |
|
| 97 | + ' FROM `##maj_geodispersion`' . |
|
| 98 | + ' WHERE majgd_file = :gedcom_id' |
|
| 99 | + )->execute(array( |
|
| 100 | + 'gedcom_id' => $this->tree->getTreeId() |
|
| 101 | + ))->fetchOne(); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Get a geographical analysis by its ID. |
|
| 106 | - * The function can only search for only enabled analysis, or all. |
|
| 107 | - * |
|
| 108 | - * @param int $id geodispersion analysis ID |
|
| 109 | - * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
| 110 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
| 111 | - */ |
|
| 112 | - public function getGeoAnalysis($id, $only_enabled = true) { |
|
| 113 | - $args = array ( |
|
| 114 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 115 | - 'ga_id' => $id |
|
| 116 | - ); |
|
| 104 | + /** |
|
| 105 | + * Get a geographical analysis by its ID. |
|
| 106 | + * The function can only search for only enabled analysis, or all. |
|
| 107 | + * |
|
| 108 | + * @param int $id geodispersion analysis ID |
|
| 109 | + * @param bool $only_enabled Search for only enabled geodispersion analysis |
|
| 110 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis|NULL |
|
| 111 | + */ |
|
| 112 | + public function getGeoAnalysis($id, $only_enabled = true) { |
|
| 113 | + $args = array ( |
|
| 114 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 115 | + 'ga_id' => $id |
|
| 116 | + ); |
|
| 117 | 117 | |
| 118 | - $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
| 119 | - ' FROM `##maj_geodispersion`' . |
|
| 120 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
| 121 | - if($only_enabled) { |
|
| 122 | - $sql .= ' AND majgd_status = :status'; |
|
| 123 | - $args['status'] = 'enabled'; |
|
| 124 | - } |
|
| 125 | - $sql .= ' ORDER BY majgd_descr'; |
|
| 118 | + $sql = 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
| 119 | + ' FROM `##maj_geodispersion`' . |
|
| 120 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id'; |
|
| 121 | + if($only_enabled) { |
|
| 122 | + $sql .= ' AND majgd_status = :status'; |
|
| 123 | + $args['status'] = 'enabled'; |
|
| 124 | + } |
|
| 125 | + $sql .= ' ORDER BY majgd_descr'; |
|
| 126 | 126 | |
| 127 | - $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
| 127 | + $ga_array = Database::prepare($sql)->execute($args)->fetchOneRow(\PDO::FETCH_ASSOC); |
|
| 128 | 128 | |
| 129 | - if($ga_array) { |
|
| 130 | - return $this->loadGeoAnalysisFromRow($ga_array); |
|
| 131 | - } |
|
| 129 | + if($ga_array) { |
|
| 130 | + return $this->loadGeoAnalysisFromRow($ga_array); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return null; |
|
| 134 | - } |
|
| 133 | + return null; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - /** |
|
| 137 | - * Add a new geodispersion analysis in the database, in a transactional manner. |
|
| 138 | - * When successful, eturns the newly created GeoAnalysis object. |
|
| 139 | - * |
|
| 140 | - * @param string $description geodispersion analysis title |
|
| 141 | - * @param int $analysis_level Analysis level |
|
| 142 | - * @param string $map_file Filename of the map |
|
| 143 | - * @param int $map_top_level Parent level of the map |
|
| 144 | - * @param bool $use_flags Use flag in the place display |
|
| 145 | - * @param int $gen_details Number of top places to display |
|
| 146 | - * @return GeoAnalysis |
|
| 147 | - */ |
|
| 136 | + /** |
|
| 137 | + * Add a new geodispersion analysis in the database, in a transactional manner. |
|
| 138 | + * When successful, eturns the newly created GeoAnalysis object. |
|
| 139 | + * |
|
| 140 | + * @param string $description geodispersion analysis title |
|
| 141 | + * @param int $analysis_level Analysis level |
|
| 142 | + * @param string $map_file Filename of the map |
|
| 143 | + * @param int $map_top_level Parent level of the map |
|
| 144 | + * @param bool $use_flags Use flag in the place display |
|
| 145 | + * @param int $gen_details Number of top places to display |
|
| 146 | + * @return GeoAnalysis |
|
| 147 | + */ |
|
| 148 | 148 | public function createGeoAnalysis($description, $analysis_level, $map_file, $map_top_level, $use_flags, $gen_details) { |
| 149 | 149 | try{ |
| 150 | 150 | Database::beginTransaction(); |
@@ -174,17 +174,17 @@ discard block |
||
| 174 | 174 | Log::addErrorLog('A new Geo Analysis failed to be created. Transaction rollbacked. Parameters ['.$description.', '.$analysis_level.','.$map_file.','.$map_top_level.','.$use_flags.', '.$gen_details.']. Exception: '.$ex->getMessage()); |
| 175 | 175 | } |
| 176 | 176 | return $ga; |
| 177 | - } |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Update a geodispersion analysis in the database, in transactional manner. |
|
| 181 | - * When successful, returns the updated GeoAnalysis object |
|
| 182 | - * |
|
| 183 | - * @param GeoAnalysis $ga |
|
| 184 | - * @return GeoAnalysis |
|
| 185 | - */ |
|
| 186 | - public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
| 187 | - try { |
|
| 179 | + /** |
|
| 180 | + * Update a geodispersion analysis in the database, in transactional manner. |
|
| 181 | + * When successful, returns the updated GeoAnalysis object |
|
| 182 | + * |
|
| 183 | + * @param GeoAnalysis $ga |
|
| 184 | + * @return GeoAnalysis |
|
| 185 | + */ |
|
| 186 | + public function updateGeoAnalysis(GeoAnalysis $ga) { |
|
| 187 | + try { |
|
| 188 | 188 | Database::beginTransaction(); |
| 189 | 189 | |
| 190 | 190 | Database::prepare( |
@@ -217,236 +217,236 @@ discard block |
||
| 217 | 217 | $ga = null; |
| 218 | 218 | } |
| 219 | 219 | return $ga; |
| 220 | - } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Set the status of a specific analysis. |
|
| 224 | - * The status can be enabled (true), or disabled (false). |
|
| 225 | - * |
|
| 226 | - * @param GeoAnalysis $ga |
|
| 227 | - * @param bool $status |
|
| 228 | - */ |
|
| 229 | - public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
| 230 | - Database::prepare( |
|
| 231 | - 'UPDATE `##maj_geodispersion`'. |
|
| 232 | - ' SET majgd_status = :status'. |
|
| 233 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
| 234 | - )->execute(array( |
|
| 235 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 236 | - 'status' => $status ? 'enabled' : 'disabled', |
|
| 237 | - 'ga_id' => $ga->getId() |
|
| 238 | - )); |
|
| 239 | - } |
|
| 222 | + /** |
|
| 223 | + * Set the status of a specific analysis. |
|
| 224 | + * The status can be enabled (true), or disabled (false). |
|
| 225 | + * |
|
| 226 | + * @param GeoAnalysis $ga |
|
| 227 | + * @param bool $status |
|
| 228 | + */ |
|
| 229 | + public function setGeoAnalysisStatus(GeoAnalysis $ga, $status) { |
|
| 230 | + Database::prepare( |
|
| 231 | + 'UPDATE `##maj_geodispersion`'. |
|
| 232 | + ' SET majgd_status = :status'. |
|
| 233 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
| 234 | + )->execute(array( |
|
| 235 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 236 | + 'status' => $status ? 'enabled' : 'disabled', |
|
| 237 | + 'ga_id' => $ga->getId() |
|
| 238 | + )); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - /** |
|
| 242 | - * Delete a geodispersion analysis from the database. |
|
| 243 | - * |
|
| 244 | - * @param GeoAnalysis $ga |
|
| 245 | - */ |
|
| 246 | - public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
| 247 | - Database::prepare( |
|
| 248 | - 'DELETE FROM `##maj_geodispersion`'. |
|
| 249 | - ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
| 250 | - )->execute(array( |
|
| 251 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 252 | - 'ga_id' => $ga->getId() |
|
| 253 | - )); |
|
| 254 | - } |
|
| 241 | + /** |
|
| 242 | + * Delete a geodispersion analysis from the database. |
|
| 243 | + * |
|
| 244 | + * @param GeoAnalysis $ga |
|
| 245 | + */ |
|
| 246 | + public function deleteGeoAnalysis(GeoAnalysis $ga) { |
|
| 247 | + Database::prepare( |
|
| 248 | + 'DELETE FROM `##maj_geodispersion`'. |
|
| 249 | + ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id' |
|
| 250 | + )->execute(array( |
|
| 251 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 252 | + 'ga_id' => $ga->getId() |
|
| 253 | + )); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
| 258 | - * |
|
| 259 | - * @return array List of enabled maps |
|
| 260 | - */ |
|
| 261 | - public function getGeoAnalysisList(){ |
|
| 262 | - $res = array(); |
|
| 256 | + /** |
|
| 257 | + * Return the list of geodispersion analysis recorded and enabled for a specific GEDCOM |
|
| 258 | + * |
|
| 259 | + * @return array List of enabled maps |
|
| 260 | + */ |
|
| 261 | + public function getGeoAnalysisList(){ |
|
| 262 | + $res = array(); |
|
| 263 | 263 | |
| 264 | - $list = Database::prepare( |
|
| 265 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
| 266 | - ' FROM `##maj_geodispersion`' . |
|
| 267 | - ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
| 268 | - ' ORDER BY majgd_descr' |
|
| 269 | - )->execute(array( |
|
| 270 | - 'gedcom_id' => $this->tree->getTreeId(), |
|
| 271 | - 'status' => 'enabled' |
|
| 272 | - ))->fetchAll(\PDO::FETCH_ASSOC); |
|
| 264 | + $list = Database::prepare( |
|
| 265 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen' . |
|
| 266 | + ' FROM `##maj_geodispersion`' . |
|
| 267 | + ' WHERE majgd_file = :gedcom_id AND majgd_status = :status'. |
|
| 268 | + ' ORDER BY majgd_descr' |
|
| 269 | + )->execute(array( |
|
| 270 | + 'gedcom_id' => $this->tree->getTreeId(), |
|
| 271 | + 'status' => 'enabled' |
|
| 272 | + ))->fetchAll(\PDO::FETCH_ASSOC); |
|
| 273 | 273 | |
| 274 | - foreach($list as $ga) { |
|
| 275 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
| 276 | - } |
|
| 274 | + foreach($list as $ga) { |
|
| 275 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - return $res; |
|
| 279 | - } |
|
| 278 | + return $res; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - /** |
|
| 282 | - * Return the list of geodispersion analysis matching specified criterias. |
|
| 283 | - * |
|
| 284 | - * @param string $search Search criteria in analysis description |
|
| 285 | - * @param array $order_by Columns to order by |
|
| 286 | - * @param int $start Offset to start with (for pagination) |
|
| 287 | - * @param int|null $limit Max number of items to return (for pagination) |
|
| 288 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
| 289 | - */ |
|
| 290 | - public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
| 291 | - $res = array(); |
|
| 281 | + /** |
|
| 282 | + * Return the list of geodispersion analysis matching specified criterias. |
|
| 283 | + * |
|
| 284 | + * @param string $search Search criteria in analysis description |
|
| 285 | + * @param array $order_by Columns to order by |
|
| 286 | + * @param int $start Offset to start with (for pagination) |
|
| 287 | + * @param int|null $limit Max number of items to return (for pagination) |
|
| 288 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysis[] |
|
| 289 | + */ |
|
| 290 | + public function getFilteredGeoAnalysisList($search = null, $order_by = null, $start = 0, $limit = null){ |
|
| 291 | + $res = array(); |
|
| 292 | 292 | |
| 293 | - $sql = |
|
| 294 | - 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
| 295 | - ' FROM `##maj_geodispersion`' . |
|
| 296 | - ' WHERE majgd_file = :gedcom_id'; |
|
| 293 | + $sql = |
|
| 294 | + 'SELECT majgd_id, majgd_descr, majgd_sublevel, majgd_map, majgd_toplevel, majgd_useflagsgen, majgd_detailsgen, majgd_status' . |
|
| 295 | + ' FROM `##maj_geodispersion`' . |
|
| 296 | + ' WHERE majgd_file = :gedcom_id'; |
|
| 297 | 297 | |
| 298 | - $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
| 298 | + $args = array('gedcom_id'=> $this->tree->getTreeId()); |
|
| 299 | 299 | |
| 300 | - if($search) { |
|
| 301 | - $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
| 302 | - $args['search'] = $search; |
|
| 303 | - } |
|
| 300 | + if($search) { |
|
| 301 | + $sql .= ' AND majgd_descr LIKE CONCAT(\'%\', :search, \'%\')'; |
|
| 302 | + $args['search'] = $search; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - if ($order_by) { |
|
| 306 | - $sql .= ' ORDER BY '; |
|
| 307 | - foreach ($order_by as $key => $value) { |
|
| 308 | - if ($key > 0) { |
|
| 309 | - $sql .= ','; |
|
| 310 | - } |
|
| 305 | + if ($order_by) { |
|
| 306 | + $sql .= ' ORDER BY '; |
|
| 307 | + foreach ($order_by as $key => $value) { |
|
| 308 | + if ($key > 0) { |
|
| 309 | + $sql .= ','; |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - switch ($value['dir']) { |
|
| 313 | - case 'asc': |
|
| 314 | - $sql .= $value['column'] . ' ASC '; |
|
| 315 | - break; |
|
| 316 | - case 'desc': |
|
| 317 | - $sql .= $value['column'] . ' DESC '; |
|
| 318 | - break; |
|
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } else { |
|
| 322 | - $sql .= ' ORDER BY majgd_descr ASC'; |
|
| 323 | - } |
|
| 312 | + switch ($value['dir']) { |
|
| 313 | + case 'asc': |
|
| 314 | + $sql .= $value['column'] . ' ASC '; |
|
| 315 | + break; |
|
| 316 | + case 'desc': |
|
| 317 | + $sql .= $value['column'] . ' DESC '; |
|
| 318 | + break; |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } else { |
|
| 322 | + $sql .= ' ORDER BY majgd_descr ASC'; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - if ($limit) { |
|
| 326 | - $sql .= " LIMIT :limit OFFSET :offset"; |
|
| 327 | - $args['limit'] = $limit; |
|
| 328 | - $args['offset'] = $start; |
|
| 329 | - } |
|
| 325 | + if ($limit) { |
|
| 326 | + $sql .= " LIMIT :limit OFFSET :offset"; |
|
| 327 | + $args['limit'] = $limit; |
|
| 328 | + $args['offset'] = $start; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
| 331 | + $data = Database::prepare($sql)->execute($args)->fetchAll(\PDO::FETCH_ASSOC); |
|
| 332 | 332 | |
| 333 | - foreach($data as $ga) { |
|
| 334 | - $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
| 335 | - } |
|
| 333 | + foreach($data as $ga) { |
|
| 334 | + $res[] = $this->loadGeoAnalysisFromRow($ga); |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | - return $res; |
|
| 338 | - } |
|
| 337 | + return $res; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - /** |
|
| 341 | - * Returns the infered place hierarchy, determined from the Gedcom data. |
|
| 342 | - * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
| 343 | - * This is returned as an associative array: |
|
| 344 | - * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
| 345 | - * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
| 346 | - * |
|
| 347 | - * @return array |
|
| 348 | - */ |
|
| 349 | - public function getPlacesHierarchy() { |
|
| 350 | - if(!$this->place_hierarchy) { |
|
| 351 | - if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
| 352 | - $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
| 353 | - } |
|
| 354 | - else { |
|
| 355 | - $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - return $this->place_hierarchy; |
|
| 359 | - } |
|
| 340 | + /** |
|
| 341 | + * Returns the infered place hierarchy, determined from the Gedcom data. |
|
| 342 | + * Depending on the data, it can be based on the Gedcom Header description, or from a place example. |
|
| 343 | + * This is returned as an associative array: |
|
| 344 | + * - type: describe the source of the data (<em>header<em> / <em>data</em>) |
|
| 345 | + * - hierarchy: an array of the place hierarchy (in reverse order of the gedcom) |
|
| 346 | + * |
|
| 347 | + * @return array |
|
| 348 | + */ |
|
| 349 | + public function getPlacesHierarchy() { |
|
| 350 | + if(!$this->place_hierarchy) { |
|
| 351 | + if($place_structure = $this->getPlacesHierarchyFromHeader()) { |
|
| 352 | + $this->place_hierarchy = array('type' => 'header', 'hierarchy' => $place_structure); |
|
| 353 | + } |
|
| 354 | + else { |
|
| 355 | + $this->place_hierarchy = array('type' => 'data', 'hierarchy' => $this->getPlacesHierarchyFromData()); |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + return $this->place_hierarchy; |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - /** |
|
| 362 | - * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
| 363 | - * The places are reversed compared to normal GEDCOM structure. |
|
| 364 | - * |
|
| 365 | - * @return array|null |
|
| 366 | - */ |
|
| 367 | - protected function getPlacesHierarchyFromHeader() { |
|
| 368 | - $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
| 369 | - $head_place = $head->getFirstFact('PLAC'); |
|
| 370 | - if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
| 371 | - return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
| 372 | - } |
|
| 373 | - return null; |
|
| 374 | - } |
|
| 361 | + /** |
|
| 362 | + * Returns an array of the place hierarchy, as defined in the GEDCOM header. |
|
| 363 | + * The places are reversed compared to normal GEDCOM structure. |
|
| 364 | + * |
|
| 365 | + * @return array|null |
|
| 366 | + */ |
|
| 367 | + protected function getPlacesHierarchyFromHeader() { |
|
| 368 | + $head = GedcomRecord::getInstance('HEAD', $this->tree); |
|
| 369 | + $head_place = $head->getFirstFact('PLAC'); |
|
| 370 | + if($head_place && $head_place_value = $head_place->getAttribute('FORM')){ |
|
| 371 | + return array_reverse(array_map('trim',explode(',', $head_place_value))); |
|
| 372 | + } |
|
| 373 | + return null; |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
| 378 | - * It will look for the longest hierarchy in the tree. |
|
| 379 | - * The places are reversed compared to normal GEDCOM structure. |
|
| 380 | - * |
|
| 381 | - * @return array |
|
| 382 | - */ |
|
| 383 | - protected function getPlacesHierarchyFromData() { |
|
| 384 | - $nb_levels = 0; |
|
| 376 | + /** |
|
| 377 | + * Returns an array of the place hierarchy, based on a random example of place within the GEDCOM. |
|
| 378 | + * It will look for the longest hierarchy in the tree. |
|
| 379 | + * The places are reversed compared to normal GEDCOM structure. |
|
| 380 | + * |
|
| 381 | + * @return array |
|
| 382 | + */ |
|
| 383 | + protected function getPlacesHierarchyFromData() { |
|
| 384 | + $nb_levels = 0; |
|
| 385 | 385 | |
| 386 | - //Select all '2 PLAC ' tags in the file and create array |
|
| 387 | - $places_list=array(); |
|
| 388 | - $ged_data = Database::prepare( |
|
| 389 | - 'SELECT i_gedcom AS gedcom'. |
|
| 390 | - ' FROM `##individuals`'. |
|
| 391 | - ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
| 392 | - ' UNION ALL'. |
|
| 393 | - 'SELECT f_gedcom AS gedcom'. |
|
| 394 | - ' FROM `##families`'. |
|
| 395 | - ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
| 396 | - )->execute(array( |
|
| 397 | - 'gedcom' => '%\n2 PLAC %', |
|
| 398 | - 'gedcom_id' => $this->tree->getTreeId() |
|
| 399 | - ))->fetchOneColumn(); |
|
| 400 | - foreach ($ged_data as $ged_datum) { |
|
| 401 | - $matches = null; |
|
| 402 | - preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
| 403 | - foreach ($matches[1] as $match) { |
|
| 404 | - $places_list[$match]=true; |
|
| 405 | - } |
|
| 406 | - } |
|
| 386 | + //Select all '2 PLAC ' tags in the file and create array |
|
| 387 | + $places_list=array(); |
|
| 388 | + $ged_data = Database::prepare( |
|
| 389 | + 'SELECT i_gedcom AS gedcom'. |
|
| 390 | + ' FROM `##individuals`'. |
|
| 391 | + ' WHERE i_gedcom LIKE :gedcom AND i_file = :gedcom_id'. |
|
| 392 | + ' UNION ALL'. |
|
| 393 | + 'SELECT f_gedcom AS gedcom'. |
|
| 394 | + ' FROM `##families`'. |
|
| 395 | + ' WHERE f_gedcom LIKE :gedcom AND f_file = :gedcom_id' |
|
| 396 | + )->execute(array( |
|
| 397 | + 'gedcom' => '%\n2 PLAC %', |
|
| 398 | + 'gedcom_id' => $this->tree->getTreeId() |
|
| 399 | + ))->fetchOneColumn(); |
|
| 400 | + foreach ($ged_data as $ged_datum) { |
|
| 401 | + $matches = null; |
|
| 402 | + preg_match_all('/\n2 PLAC (.+)/', $ged_datum, $matches); |
|
| 403 | + foreach ($matches[1] as $match) { |
|
| 404 | + $places_list[$match]=true; |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - // Unique list of places |
|
| 409 | - $places_list=array_keys($places_list); |
|
| 408 | + // Unique list of places |
|
| 409 | + $places_list=array_keys($places_list); |
|
| 410 | 410 | |
| 411 | - //sort the array, limit to unique values, and count them |
|
| 412 | - usort($places_list, array('I18N', 'strcasecmp')); |
|
| 411 | + //sort the array, limit to unique values, and count them |
|
| 412 | + usort($places_list, array('I18N', 'strcasecmp')); |
|
| 413 | 413 | |
| 414 | - //calculate maximum no. of levels to display |
|
| 415 | - $has_found_good_example = false; |
|
| 416 | - foreach($places_list as $place){ |
|
| 417 | - $levels = explode(",", $place); |
|
| 418 | - $parts = count($levels); |
|
| 419 | - if ($parts >= $nb_levels){ |
|
| 420 | - $nb_levels = $parts; |
|
| 421 | - if(!$has_found_good_example){ |
|
| 422 | - $random_place = $place; |
|
| 423 | - if(min(array_map('strlen', $levels)) > 0){ |
|
| 424 | - $has_found_good_example = true; |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - } |
|
| 414 | + //calculate maximum no. of levels to display |
|
| 415 | + $has_found_good_example = false; |
|
| 416 | + foreach($places_list as $place){ |
|
| 417 | + $levels = explode(",", $place); |
|
| 418 | + $parts = count($levels); |
|
| 419 | + if ($parts >= $nb_levels){ |
|
| 420 | + $nb_levels = $parts; |
|
| 421 | + if(!$has_found_good_example){ |
|
| 422 | + $random_place = $place; |
|
| 423 | + if(min(array_map('strlen', $levels)) > 0){ |
|
| 424 | + $has_found_good_example = true; |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | 429 | |
| 430 | - return array_reverse(array_map('trim',explode(',', $random_place))); |
|
| 431 | - } |
|
| 430 | + return array_reverse(array_map('trim',explode(',', $random_place))); |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | - /** |
|
| 434 | - * Returns the list of geodispersion maps available within the maps folder. |
|
| 435 | - * |
|
| 436 | - * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
| 437 | - */ |
|
| 438 | - public function getOutlineMapsList() { |
|
| 439 | - $res = array(); |
|
| 440 | - $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
| 441 | - if(is_dir($root_path)){ |
|
| 442 | - $dir = opendir($root_path); |
|
| 443 | - while (($file=readdir($dir))!== false) { |
|
| 444 | - if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
| 445 | - $res[base64_encode($file)] = new OutlineMap($file, true); |
|
| 446 | - } |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - return $res; |
|
| 450 | - } |
|
| 433 | + /** |
|
| 434 | + * Returns the list of geodispersion maps available within the maps folder. |
|
| 435 | + * |
|
| 436 | + * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\OutlineMap[] |
|
| 437 | + */ |
|
| 438 | + public function getOutlineMapsList() { |
|
| 439 | + $res = array(); |
|
| 440 | + $root_path = WT_ROOT.WT_MODULES_DIR.Constants::MODULE_MAJ_GEODISP_NAME.'/maps/'; |
|
| 441 | + if(is_dir($root_path)){ |
|
| 442 | + $dir = opendir($root_path); |
|
| 443 | + while (($file=readdir($dir))!== false) { |
|
| 444 | + if (preg_match('/^[a-zA-Z0-9_]+.xml$/', $file)) { |
|
| 445 | + $res[base64_encode($file)] = new OutlineMap($file, true); |
|
| 446 | + } |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + return $res; |
|
| 450 | + } |
|
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | \ No newline at end of file |
@@ -219,7 +219,7 @@ |
||
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * Convert an array to Google Chart encoding |
| 222 | - * @param arrat $a Array to encode |
|
| 222 | + * @param integer[] $a Array to encode |
|
| 223 | 223 | * @return string |
| 224 | 224 | */ |
| 225 | 225 | private function arrayToExtendedEncoding($a) { |
@@ -94,8 +94,12 @@ discard block |
||
| 94 | 94 | foreach($stats_gen as $gen => $tab){ |
| 95 | 95 | $genY1= I18N::translate('-'); |
| 96 | 96 | $genY2= I18N::translate('-'); |
| 97 | - if($tab['firstBirth']>0) $genY1=$tab['firstBirth']; |
|
| 98 | - if($tab['lastBirth']>0) $genY2=$tab['lastBirth']; |
|
| 97 | + if($tab['firstBirth']>0) { |
|
| 98 | + $genY1=$tab['firstBirth']; |
|
| 99 | + } |
|
| 100 | + if($tab['lastBirth']>0) { |
|
| 101 | + $genY2=$tab['lastBirth']; |
|
| 102 | + } |
|
| 99 | 103 | $total_theoretical += $gen_theoretical; |
| 100 | 104 | $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
| 101 | 105 | $gen_equiv += $perc_sosa_count_theor; |
@@ -141,7 +145,9 @@ discard block |
||
| 141 | 145 | private function htmlAncestorDispersionG2() |
| 142 | 146 | { |
| 143 | 147 | $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
| 144 | - if(count($ancestorsDispGen2) == 0) return; |
|
| 148 | + if(count($ancestorsDispGen2) == 0) { |
|
| 149 | + return; |
|
| 150 | + } |
|
| 145 | 151 | |
| 146 | 152 | $size = '600x300'; |
| 147 | 153 | |
@@ -27,229 +27,229 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class SosaStatsController extends MvcController |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * Sosa Provider for the controller |
|
| 32 | - * @var SosaProvider $sosa_provider |
|
| 33 | - */ |
|
| 34 | - protected $sosa_provider; |
|
| 30 | + /** |
|
| 31 | + * Sosa Provider for the controller |
|
| 32 | + * @var SosaProvider $sosa_provider |
|
| 33 | + */ |
|
| 34 | + protected $sosa_provider; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Constructor for SosaStatsController |
|
| 38 | - * @param AbstractModule $module |
|
| 39 | - */ |
|
| 40 | - public function __construct(AbstractModule $module) { |
|
| 41 | - parent::__construct($module); |
|
| 36 | + /** |
|
| 37 | + * Constructor for SosaStatsController |
|
| 38 | + * @param AbstractModule $module |
|
| 39 | + */ |
|
| 40 | + public function __construct(AbstractModule $module) { |
|
| 41 | + parent::__construct($module); |
|
| 42 | 42 | |
| 43 | - $this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user()); |
|
| 44 | - } |
|
| 43 | + $this->sosa_provider = new SosaProvider(Globals::getTree(), Auth::user()); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Pages |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * Pages |
|
| 48 | + */ |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * SosaStats@index |
|
| 52 | - */ |
|
| 53 | - public function index() { |
|
| 54 | - $wt_tree = Globals::getTree(); |
|
| 55 | - $controller = new PageController(); |
|
| 56 | - $controller |
|
| 57 | - ->setPageTitle(I18N::translate('Sosa Statistics')) |
|
| 58 | - ->addInlineJavascript('$(".help_tooltip").tooltip();') |
|
| 59 | - ; |
|
| 50 | + /** |
|
| 51 | + * SosaStats@index |
|
| 52 | + */ |
|
| 53 | + public function index() { |
|
| 54 | + $wt_tree = Globals::getTree(); |
|
| 55 | + $controller = new PageController(); |
|
| 56 | + $controller |
|
| 57 | + ->setPageTitle(I18N::translate('Sosa Statistics')) |
|
| 58 | + ->addInlineJavascript('$(".help_tooltip").tooltip();') |
|
| 59 | + ; |
|
| 60 | 60 | |
| 61 | - $view_bag = new ViewBag(); |
|
| 62 | - $view_bag->set('title', $controller->getPageTitle()); |
|
| 63 | - $view_bag->set('is_setup', false); |
|
| 61 | + $view_bag = new ViewBag(); |
|
| 62 | + $view_bag->set('title', $controller->getPageTitle()); |
|
| 63 | + $view_bag->set('is_setup', false); |
|
| 64 | 64 | |
| 65 | - if($this->sosa_provider->isSetup()) { |
|
| 66 | - $view_bag->set('is_setup', true); |
|
| 65 | + if($this->sosa_provider->isSetup()) { |
|
| 66 | + $view_bag->set('is_setup', true); |
|
| 67 | 67 | |
| 68 | - $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
|
| 68 | + $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
|
| 69 | 69 | |
| 70 | - $sosaCount = $this->sosa_provider->getSosaCount(); |
|
| 71 | - $diffSosaCount = $this->sosa_provider->getDifferentSosaCount(); |
|
| 70 | + $sosaCount = $this->sosa_provider->getSosaCount(); |
|
| 71 | + $diffSosaCount = $this->sosa_provider->getDifferentSosaCount(); |
|
| 72 | 72 | |
| 73 | - $general_stats = array( |
|
| 74 | - 'sosa_count' => $sosaCount, |
|
| 75 | - 'distinct_count' => $diffSosaCount, |
|
| 76 | - 'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()), |
|
| 77 | - 'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount), |
|
| 78 | - 'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime() |
|
| 79 | - ); |
|
| 80 | - $view_bag->set('general_stats', $general_stats); |
|
| 73 | + $general_stats = array( |
|
| 74 | + 'sosa_count' => $sosaCount, |
|
| 75 | + 'distinct_count' => $diffSosaCount, |
|
| 76 | + 'sosa_rate' => Functions::safeDivision($diffSosaCount, $this->sosa_provider->getTotalIndividuals()), |
|
| 77 | + 'pedi_collapse' => 1 - Functions::safeDivision($diffSosaCount, $sosaCount), |
|
| 78 | + 'mean_gen_time' => $this->sosa_provider->getMeanGenerationTime() |
|
| 79 | + ); |
|
| 80 | + $view_bag->set('general_stats', $general_stats); |
|
| 81 | 81 | |
| 82 | - $stats_gen = $this->sosa_provider->getStatisticsByGeneration(); |
|
| 83 | - $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen='); |
|
| 84 | - $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen='); |
|
| 82 | + $stats_gen = $this->sosa_provider->getStatisticsByGeneration(); |
|
| 83 | + $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen='); |
|
| 84 | + $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen='); |
|
| 85 | 85 | |
| 86 | - $gen_theoretical=1; |
|
| 87 | - $total_theoretical=0; |
|
| 88 | - $prev_diff=0; |
|
| 89 | - $prev_known=0.5; |
|
| 90 | - $gen_equiv=0; |
|
| 91 | - $generation_stats = array(); |
|
| 86 | + $gen_theoretical=1; |
|
| 87 | + $total_theoretical=0; |
|
| 88 | + $prev_diff=0; |
|
| 89 | + $prev_known=0.5; |
|
| 90 | + $gen_equiv=0; |
|
| 91 | + $generation_stats = array(); |
|
| 92 | 92 | |
| 93 | - foreach($stats_gen as $gen => $tab){ |
|
| 94 | - $genY1= I18N::translate('-'); |
|
| 95 | - $genY2= I18N::translate('-'); |
|
| 96 | - if($tab['firstBirth']>0) $genY1=$tab['firstBirth']; |
|
| 97 | - if($tab['lastBirth']>0) $genY2=$tab['lastBirth']; |
|
| 98 | - $total_theoretical += $gen_theoretical; |
|
| 99 | - $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
|
| 100 | - $gen_equiv += $perc_sosa_count_theor; |
|
| 101 | - $missing=2*$prev_known - $tab['sosaCount']; |
|
| 102 | - $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
| 93 | + foreach($stats_gen as $gen => $tab){ |
|
| 94 | + $genY1= I18N::translate('-'); |
|
| 95 | + $genY2= I18N::translate('-'); |
|
| 96 | + if($tab['firstBirth']>0) $genY1=$tab['firstBirth']; |
|
| 97 | + if($tab['lastBirth']>0) $genY2=$tab['lastBirth']; |
|
| 98 | + $total_theoretical += $gen_theoretical; |
|
| 99 | + $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
|
| 100 | + $gen_equiv += $perc_sosa_count_theor; |
|
| 101 | + $missing=2*$prev_known - $tab['sosaCount']; |
|
| 102 | + $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
| 103 | 103 | |
| 104 | - $generation_stats[$gen] = array( |
|
| 105 | - 'gen_min_birth' => $genY1, |
|
| 106 | - 'gen_max_birth' => $genY2, |
|
| 107 | - 'theoretical' => $gen_theoretical, |
|
| 108 | - 'known' => $tab['sosaCount'], |
|
| 109 | - 'perc_known' => $perc_sosa_count_theor, |
|
| 110 | - 'missing' => $missing, |
|
| 111 | - 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
| 112 | - 'total_known' => $tab['sosaTotalCount'], |
|
| 113 | - 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
|
| 114 | - 'different' => $gen_diff, |
|
| 115 | - 'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']), |
|
| 116 | - 'total_different' => $tab['diffSosaTotalCount'], |
|
| 117 | - 'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount']) |
|
| 118 | - ); |
|
| 104 | + $generation_stats[$gen] = array( |
|
| 105 | + 'gen_min_birth' => $genY1, |
|
| 106 | + 'gen_max_birth' => $genY2, |
|
| 107 | + 'theoretical' => $gen_theoretical, |
|
| 108 | + 'known' => $tab['sosaCount'], |
|
| 109 | + 'perc_known' => $perc_sosa_count_theor, |
|
| 110 | + 'missing' => $missing, |
|
| 111 | + 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
| 112 | + 'total_known' => $tab['sosaTotalCount'], |
|
| 113 | + 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
|
| 114 | + 'different' => $gen_diff, |
|
| 115 | + 'perc_different' => Functions::safeDivision($gen_diff, $tab['sosaCount']), |
|
| 116 | + 'total_different' => $tab['diffSosaTotalCount'], |
|
| 117 | + 'pedi_collapse' => 1 - Functions::safeDivision($tab['diffSosaTotalCount'], $tab['sosaTotalCount']) |
|
| 118 | + ); |
|
| 119 | 119 | |
| 120 | - $gen_theoretical = $gen_theoretical * 2; |
|
| 121 | - $prev_known=$tab['sosaCount']; |
|
| 122 | - $prev_diff=$tab['diffSosaTotalCount']; |
|
| 123 | - } |
|
| 120 | + $gen_theoretical = $gen_theoretical * 2; |
|
| 121 | + $prev_known=$tab['sosaCount']; |
|
| 122 | + $prev_diff=$tab['diffSosaTotalCount']; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - $view_bag->set('generation_stats', $generation_stats); |
|
| 126 | - $view_bag->set('equivalent_gen', $gen_equiv); |
|
| 125 | + $view_bag->set('generation_stats', $generation_stats); |
|
| 126 | + $view_bag->set('equivalent_gen', $gen_equiv); |
|
| 127 | 127 | |
| 128 | - $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10); |
|
| 129 | - $top10ancestors = array(); |
|
| 130 | - if($top10multiancestors !== null && count($top10multiancestors)) { |
|
| 131 | - foreach($top10multiancestors as $pid => $count) { |
|
| 132 | - $indi = Individual::getInstance($pid, $wt_tree); |
|
| 133 | - if($indi !== null && $indi->canShowName()) { |
|
| 134 | - array_key_exists($count, $top10ancestors) ? |
|
| 135 | - $top10ancestors[$count][] = $indi: |
|
| 136 | - $top10ancestors[$count] = array($count => $indi); |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - $view_bag->set('top10multiancestors', $top10ancestors); |
|
| 128 | + $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10); |
|
| 129 | + $top10ancestors = array(); |
|
| 130 | + if($top10multiancestors !== null && count($top10multiancestors)) { |
|
| 131 | + foreach($top10multiancestors as $pid => $count) { |
|
| 132 | + $indi = Individual::getInstance($pid, $wt_tree); |
|
| 133 | + if($indi !== null && $indi->canShowName()) { |
|
| 134 | + array_key_exists($count, $top10ancestors) ? |
|
| 135 | + $top10ancestors[$count][] = $indi: |
|
| 136 | + $top10ancestors[$count] = array($count => $indi); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + $view_bag->set('top10multiancestors', $top10ancestors); |
|
| 141 | 141 | |
| 142 | - $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2()); |
|
| 143 | - $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3()); |
|
| 142 | + $view_bag->set('chart_img_g2', $this->htmlAncestorDispersionG2()); |
|
| 143 | + $view_bag->set('chart_img_g3', $this->htmlAncestorDispersionG3()); |
|
| 144 | 144 | |
| 145 | - } |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render(); |
|
| 148 | - } |
|
| 147 | + ViewFactory::make('SosaStats', $this, $controller, $view_bag)->render(); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Returns HTML code for a graph showing the dispersion of ancestors across father & mother |
|
| 152 | - * @return string HTML code |
|
| 153 | - */ |
|
| 154 | - private function htmlAncestorDispersionG2() |
|
| 155 | - { |
|
| 156 | - $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
|
| 157 | - if(count($ancestorsDispGen2) == 0) return; |
|
| 150 | + /** |
|
| 151 | + * Returns HTML code for a graph showing the dispersion of ancestors across father & mother |
|
| 152 | + * @return string HTML code |
|
| 153 | + */ |
|
| 154 | + private function htmlAncestorDispersionG2() |
|
| 155 | + { |
|
| 156 | + $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
|
| 157 | + if(count($ancestorsDispGen2) == 0) return; |
|
| 158 | 158 | |
| 159 | - $size = '600x300'; |
|
| 159 | + $size = '600x300'; |
|
| 160 | 160 | |
| 161 | - $total = array_sum($ancestorsDispGen2); |
|
| 162 | - $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
| 163 | - $father = array ( |
|
| 164 | - 'color' => '84beff', |
|
| 165 | - 'count' => $father_count, |
|
| 166 | - 'perc' => Functions::safeDivision($father_count, $total), |
|
| 167 | - 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
|
| 168 | - ); |
|
| 169 | - $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
| 170 | - $mother = array ( |
|
| 171 | - 'color' => 'ffd1dc', |
|
| 172 | - 'count' => $mother_count, |
|
| 173 | - 'perc' => Functions::safeDivision($mother_count, $total), |
|
| 174 | - 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
|
| 175 | - ); |
|
| 176 | - $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
| 177 | - $shared = array ( |
|
| 178 | - 'color' => '777777', |
|
| 179 | - 'count' => $shared_count, |
|
| 180 | - 'perc' => Functions::safeDivision($shared_count, $total), |
|
| 181 | - 'name' => I18N::translate('Shared') |
|
| 182 | - ); |
|
| 161 | + $total = array_sum($ancestorsDispGen2); |
|
| 162 | + $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
| 163 | + $father = array ( |
|
| 164 | + 'color' => '84beff', |
|
| 165 | + 'count' => $father_count, |
|
| 166 | + 'perc' => Functions::safeDivision($father_count, $total), |
|
| 167 | + 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
|
| 168 | + ); |
|
| 169 | + $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
| 170 | + $mother = array ( |
|
| 171 | + 'color' => 'ffd1dc', |
|
| 172 | + 'count' => $mother_count, |
|
| 173 | + 'perc' => Functions::safeDivision($mother_count, $total), |
|
| 174 | + 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
|
| 175 | + ); |
|
| 176 | + $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
| 177 | + $shared = array ( |
|
| 178 | + 'color' => '777777', |
|
| 179 | + 'count' => $shared_count, |
|
| 180 | + 'perc' => Functions::safeDivision($shared_count, $total), |
|
| 181 | + 'name' => I18N::translate('Shared') |
|
| 182 | + ); |
|
| 183 | 183 | |
| 184 | - $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
|
| 185 | - $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
|
| 186 | - $chl = |
|
| 187 | - $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
| 188 | - $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
| 189 | - $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
| 190 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
| 191 | - } |
|
| 184 | + $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
|
| 185 | + $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
|
| 186 | + $chl = |
|
| 187 | + $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
| 188 | + $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
| 189 | + $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
| 190 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents |
|
| 195 | - * @return string HTML code |
|
| 196 | - */ |
|
| 197 | - private function htmlAncestorDispersionG3() |
|
| 198 | - { |
|
| 199 | - $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); |
|
| 193 | + /** |
|
| 194 | + * Returns HTML code for a graph showing the dispersion of ancestors across grand-parents |
|
| 195 | + * @return string HTML code |
|
| 196 | + */ |
|
| 197 | + private function htmlAncestorDispersionG3() |
|
| 198 | + { |
|
| 199 | + $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(3); |
|
| 200 | 200 | |
| 201 | - $size = '700x300'; |
|
| 201 | + $size = '700x300'; |
|
| 202 | 202 | |
| 203 | - $color_motmot = 'ffd1dc'; |
|
| 204 | - $color_motfat = 'b998a0'; |
|
| 205 | - $color_fatfat = '577292'; |
|
| 206 | - $color_fatmot = '84beff'; |
|
| 207 | - $color_shared = '777777'; |
|
| 203 | + $color_motmot = 'ffd1dc'; |
|
| 204 | + $color_motfat = 'b998a0'; |
|
| 205 | + $color_fatfat = '577292'; |
|
| 206 | + $color_fatmot = '84beff'; |
|
| 207 | + $color_shared = '777777'; |
|
| 208 | 208 | |
| 209 | - $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
| 210 | - $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
| 211 | - $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
|
| 212 | - $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
|
| 213 | - $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
| 214 | - $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
| 209 | + $total_fatfat = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
|
| 210 | + $total_fatmot = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
|
| 211 | + $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
|
| 212 | + $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
|
| 213 | + $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
|
| 214 | + $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
| 215 | 215 | |
| 216 | - $chd = $this->arrayToExtendedEncoding(array( |
|
| 217 | - 4095 * Functions::safeDivision($total_fatfat, $total), |
|
| 218 | - 4095 * Functions::safeDivision($total_fatmot, $total), |
|
| 219 | - 4095 * Functions::safeDivision($total_sha, $total), |
|
| 220 | - 4095 * Functions::safeDivision($total_motfat, $total), |
|
| 221 | - 4095 * Functions::safeDivision($total_motmot, $total) |
|
| 222 | - )); |
|
| 223 | - $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
|
| 224 | - $chl = |
|
| 225 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
| 226 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
| 227 | - I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
| 228 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
| 229 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
| 230 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
| 231 | - } |
|
| 216 | + $chd = $this->arrayToExtendedEncoding(array( |
|
| 217 | + 4095 * Functions::safeDivision($total_fatfat, $total), |
|
| 218 | + 4095 * Functions::safeDivision($total_fatmot, $total), |
|
| 219 | + 4095 * Functions::safeDivision($total_sha, $total), |
|
| 220 | + 4095 * Functions::safeDivision($total_motfat, $total), |
|
| 221 | + 4095 * Functions::safeDivision($total_motmot, $total) |
|
| 222 | + )); |
|
| 223 | + $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
|
| 224 | + $chl = |
|
| 225 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
| 226 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
| 227 | + I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
| 228 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
| 229 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
| 230 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - /** |
|
| 234 | - * Convert an array to Google Chart encoding |
|
| 235 | - * @param arrat $a Array to encode |
|
| 236 | - * @return string |
|
| 237 | - */ |
|
| 238 | - private function arrayToExtendedEncoding($a) { |
|
| 239 | - $xencoding = WT_GOOGLE_CHART_ENCODING; |
|
| 233 | + /** |
|
| 234 | + * Convert an array to Google Chart encoding |
|
| 235 | + * @param arrat $a Array to encode |
|
| 236 | + * @return string |
|
| 237 | + */ |
|
| 238 | + private function arrayToExtendedEncoding($a) { |
|
| 239 | + $xencoding = WT_GOOGLE_CHART_ENCODING; |
|
| 240 | 240 | |
| 241 | - $encoding = ''; |
|
| 242 | - foreach ($a as $value) { |
|
| 243 | - if ($value < 0) { |
|
| 244 | - $value = 0; |
|
| 245 | - } |
|
| 246 | - $first = (int) ($value / 64); |
|
| 247 | - $second = $value % 64; |
|
| 248 | - $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
| 249 | - } |
|
| 241 | + $encoding = ''; |
|
| 242 | + foreach ($a as $value) { |
|
| 243 | + if ($value < 0) { |
|
| 244 | + $value = 0; |
|
| 245 | + } |
|
| 246 | + $first = (int) ($value / 64); |
|
| 247 | + $second = $value % 64; |
|
| 248 | + $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - return $encoding; |
|
| 252 | - } |
|
| 251 | + return $encoding; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | 254 | |
| 255 | 255 | } |
| 256 | 256 | \ No newline at end of file |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $view_bag->set('title', $controller->getPageTitle()); |
| 63 | 63 | $view_bag->set('is_setup', false); |
| 64 | 64 | |
| 65 | - if($this->sosa_provider->isSetup()) { |
|
| 65 | + if ($this->sosa_provider->isSetup()) { |
|
| 66 | 66 | $view_bag->set('is_setup', true); |
| 67 | 67 | |
| 68 | 68 | $view_bag->set('root_indi', $this->sosa_provider->getRootIndi()); |
@@ -83,23 +83,23 @@ discard block |
||
| 83 | 83 | $view_bag->set('missinganc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList@missing&ged='.$wt_tree->getNameUrl().'&gen='); |
| 84 | 84 | $view_bag->set('sosaanc_url', 'module.php?mod='.$this->module->getName().'&mod_action=SosaList&ged='.$wt_tree->getNameUrl().'&gen='); |
| 85 | 85 | |
| 86 | - $gen_theoretical=1; |
|
| 87 | - $total_theoretical=0; |
|
| 88 | - $prev_diff=0; |
|
| 89 | - $prev_known=0.5; |
|
| 90 | - $gen_equiv=0; |
|
| 86 | + $gen_theoretical = 1; |
|
| 87 | + $total_theoretical = 0; |
|
| 88 | + $prev_diff = 0; |
|
| 89 | + $prev_known = 0.5; |
|
| 90 | + $gen_equiv = 0; |
|
| 91 | 91 | $generation_stats = array(); |
| 92 | 92 | |
| 93 | - foreach($stats_gen as $gen => $tab){ |
|
| 94 | - $genY1= I18N::translate('-'); |
|
| 95 | - $genY2= I18N::translate('-'); |
|
| 96 | - if($tab['firstBirth']>0) $genY1=$tab['firstBirth']; |
|
| 97 | - if($tab['lastBirth']>0) $genY2=$tab['lastBirth']; |
|
| 93 | + foreach ($stats_gen as $gen => $tab) { |
|
| 94 | + $genY1 = I18N::translate('-'); |
|
| 95 | + $genY2 = I18N::translate('-'); |
|
| 96 | + if ($tab['firstBirth'] > 0) $genY1 = $tab['firstBirth']; |
|
| 97 | + if ($tab['lastBirth'] > 0) $genY2 = $tab['lastBirth']; |
|
| 98 | 98 | $total_theoretical += $gen_theoretical; |
| 99 | 99 | $perc_sosa_count_theor = Functions::safeDivision($tab['sosaCount'], $gen_theoretical); |
| 100 | 100 | $gen_equiv += $perc_sosa_count_theor; |
| 101 | - $missing=2*$prev_known - $tab['sosaCount']; |
|
| 102 | - $gen_diff=$tab['diffSosaTotalCount']-$prev_diff; |
|
| 101 | + $missing = 2 * $prev_known - $tab['sosaCount']; |
|
| 102 | + $gen_diff = $tab['diffSosaTotalCount'] - $prev_diff; |
|
| 103 | 103 | |
| 104 | 104 | $generation_stats[$gen] = array( |
| 105 | 105 | 'gen_min_birth' => $genY1, |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | 'known' => $tab['sosaCount'], |
| 109 | 109 | 'perc_known' => $perc_sosa_count_theor, |
| 110 | 110 | 'missing' => $missing, |
| 111 | - 'perc_missing' => 1-Functions::safeDivision($tab['sosaCount'], 2*$prev_known), |
|
| 111 | + 'perc_missing' => 1 - Functions::safeDivision($tab['sosaCount'], 2 * $prev_known), |
|
| 112 | 112 | 'total_known' => $tab['sosaTotalCount'], |
| 113 | 113 | 'perc_total_known' => Functions::safeDivision($tab['sosaTotalCount'], $total_theoretical), |
| 114 | 114 | 'different' => $gen_diff, |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | 120 | $gen_theoretical = $gen_theoretical * 2; |
| 121 | - $prev_known=$tab['sosaCount']; |
|
| 122 | - $prev_diff=$tab['diffSosaTotalCount']; |
|
| 121 | + $prev_known = $tab['sosaCount']; |
|
| 122 | + $prev_diff = $tab['diffSosaTotalCount']; |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $view_bag->set('generation_stats', $generation_stats); |
@@ -127,13 +127,12 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | $top10multiancestors = $this->sosa_provider->getTopMultiSosaAncestorsNoTies(10); |
| 129 | 129 | $top10ancestors = array(); |
| 130 | - if($top10multiancestors !== null && count($top10multiancestors)) { |
|
| 131 | - foreach($top10multiancestors as $pid => $count) { |
|
| 130 | + if ($top10multiancestors !== null && count($top10multiancestors)) { |
|
| 131 | + foreach ($top10multiancestors as $pid => $count) { |
|
| 132 | 132 | $indi = Individual::getInstance($pid, $wt_tree); |
| 133 | - if($indi !== null && $indi->canShowName()) { |
|
| 133 | + if ($indi !== null && $indi->canShowName()) { |
|
| 134 | 134 | array_key_exists($count, $top10ancestors) ? |
| 135 | - $top10ancestors[$count][] = $indi: |
|
| 136 | - $top10ancestors[$count] = array($count => $indi); |
|
| 135 | + $top10ancestors[$count][] = $indi : $top10ancestors[$count] = array($count => $indi); |
|
| 137 | 136 | } |
| 138 | 137 | } |
| 139 | 138 | } |
@@ -154,27 +153,27 @@ discard block |
||
| 154 | 153 | private function htmlAncestorDispersionG2() |
| 155 | 154 | { |
| 156 | 155 | $ancestorsDispGen2 = $this->sosa_provider->getAncestorDispersionForGen(2); |
| 157 | - if(count($ancestorsDispGen2) == 0) return; |
|
| 156 | + if (count($ancestorsDispGen2) == 0) return; |
|
| 158 | 157 | |
| 159 | 158 | $size = '600x300'; |
| 160 | 159 | |
| 161 | 160 | $total = array_sum($ancestorsDispGen2); |
| 162 | 161 | $father_count = array_key_exists(1, $ancestorsDispGen2) ? $ancestorsDispGen2[1] : 0; |
| 163 | - $father = array ( |
|
| 162 | + $father = array( |
|
| 164 | 163 | 'color' => '84beff', |
| 165 | 164 | 'count' => $father_count, |
| 166 | 165 | 'perc' => Functions::safeDivision($father_count, $total), |
| 167 | 166 | 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fat') |
| 168 | 167 | ); |
| 169 | 168 | $mother_count = array_key_exists(2, $ancestorsDispGen2) ? $ancestorsDispGen2[2] : 0; |
| 170 | - $mother = array ( |
|
| 169 | + $mother = array( |
|
| 171 | 170 | 'color' => 'ffd1dc', |
| 172 | 171 | 'count' => $mother_count, |
| 173 | 172 | 'perc' => Functions::safeDivision($mother_count, $total), |
| 174 | 173 | 'name' => \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('mot') |
| 175 | 174 | ); |
| 176 | 175 | $shared_count = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
| 177 | - $shared = array ( |
|
| 176 | + $shared = array( |
|
| 178 | 177 | 'color' => '777777', |
| 179 | 178 | 'count' => $shared_count, |
| 180 | 179 | 'perc' => Functions::safeDivision($shared_count, $total), |
@@ -184,10 +183,10 @@ discard block |
||
| 184 | 183 | $chd = $this->arrayToExtendedEncoding(array(4095 * $father['perc'], 4095 * $shared['perc'], 4095 * $mother['perc'])); |
| 185 | 184 | $chart_title = I18N::translate('Known Sosa ancestors\' dispersion'); |
| 186 | 185 | $chl = |
| 187 | - $father['name'] . ' - ' . I18N::percentage($father['perc'], 1) . '|' . |
|
| 188 | - $shared['name'] . ' - ' . I18N::percentage($shared['perc'], 1) . '|' . |
|
| 189 | - $mother['name'] . ' - ' . I18N::percentage($mother['perc'], 1); |
|
| 190 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
| 186 | + $father['name'].' - '.I18N::percentage($father['perc'], 1).'|'. |
|
| 187 | + $shared['name'].' - '.I18N::percentage($shared['perc'], 1).'|'. |
|
| 188 | + $mother['name'].' - '.I18N::percentage($mother['perc'], 1); |
|
| 189 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$father['color']},{$shared['color']},{$mother['color']}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />"; |
|
| 191 | 190 | } |
| 192 | 191 | |
| 193 | 192 | /** |
@@ -211,7 +210,7 @@ discard block |
||
| 211 | 210 | $total_motfat = array_key_exists(4, $ancestorsDispGen2) ? $ancestorsDispGen2[4] : 0; |
| 212 | 211 | $total_motmot = array_key_exists(8, $ancestorsDispGen2) ? $ancestorsDispGen2[8] : 0; |
| 213 | 212 | $total_sha = array_key_exists(-1, $ancestorsDispGen2) ? $ancestorsDispGen2[-1] : 0; |
| 214 | - $total = $total_fatfat + $total_fatmot + $total_motfat+ $total_motmot + $total_sha; |
|
| 213 | + $total = $total_fatfat + $total_fatmot + $total_motfat + $total_motmot + $total_sha; |
|
| 215 | 214 | |
| 216 | 215 | $chd = $this->arrayToExtendedEncoding(array( |
| 217 | 216 | 4095 * Functions::safeDivision($total_fatfat, $total), |
@@ -222,12 +221,12 @@ discard block |
||
| 222 | 221 | )); |
| 223 | 222 | $chart_title = I18N::translate('Known Sosa ancestors\' dispersion - G3'); |
| 224 | 223 | $chl = |
| 225 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1) . '|' . |
|
| 226 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1) . '|' . |
|
| 227 | - I18N::translate('Shared') . ' - ' . I18N::percentage(Functions::safeDivision($total_sha, $total), 1) . '|' . |
|
| 228 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat') . ' - ' . I18N::percentage(Functions::safeDivision($total_motfat, $total), 1) . '|' . |
|
| 229 | - \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot') . ' - ' . I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
| 230 | - return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; |
|
| 224 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatfat').' - '.I18N::percentage(Functions::safeDivision($total_fatfat, $total), 1).'|'. |
|
| 225 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('fatmot').' - '.I18N::percentage(Functions::safeDivision($total_fatmot, $total), 1).'|'. |
|
| 226 | + I18N::translate('Shared').' - '.I18N::percentage(Functions::safeDivision($total_sha, $total), 1).'|'. |
|
| 227 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motfat').' - '.I18N::percentage(Functions::safeDivision($total_motfat, $total), 1).'|'. |
|
| 228 | + \Fisharebest\Webtrees\Functions\Functions::getRelationshipNameFromPath('motmot').' - '.I18N::percentage(Functions::safeDivision($total_motmot, $total), 1); |
|
| 229 | + return "<img src=\"https://chart.googleapis.com/chart?cht=p&chp=1.5708&chd=e:{$chd}&chs={$size}&chco={$color_fatfat},{$color_fatmot},{$color_shared},{$color_motfat},{$color_motmot}&chf=bg,s,ffffff00&chl={$chl}\" alt=\"".$chart_title."\" title=\"".$chart_title."\" />"; |
|
| 231 | 230 | } |
| 232 | 231 | |
| 233 | 232 | /** |
@@ -243,9 +242,9 @@ discard block |
||
| 243 | 242 | if ($value < 0) { |
| 244 | 243 | $value = 0; |
| 245 | 244 | } |
| 246 | - $first = (int) ($value / 64); |
|
| 245 | + $first = (int)($value / 64); |
|
| 247 | 246 | $second = $value % 64; |
| 248 | - $encoding .= $xencoding[(int) $first] . $xencoding[(int) $second]; |
|
| 247 | + $encoding .= $xencoding[(int)$first].$xencoding[(int)$second]; |
|
| 249 | 248 | } |
| 250 | 249 | |
| 251 | 250 | return $encoding; |
@@ -18,35 +18,35 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Dispatcher implements DispatcherInterface { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var Dispatcher $instance Singleton pattern instance |
|
| 23 | - */ |
|
| 24 | - private static $instance = null; |
|
| 21 | + /** |
|
| 22 | + * @var Dispatcher $instance Singleton pattern instance |
|
| 23 | + */ |
|
| 24 | + private static $instance = null; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Returns the *Dispatcher* instance of this class. |
|
| 28 | - * |
|
| 29 | - * @return Dispatcher The *Singleton* instance. |
|
| 30 | - */ |
|
| 31 | - public static function getInstance() |
|
| 32 | - { |
|
| 33 | - if (null === static::$instance) { |
|
| 34 | - static::$instance = new static(); |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * Returns the *Dispatcher* instance of this class. |
|
| 28 | + * |
|
| 29 | + * @return Dispatcher The *Singleton* instance. |
|
| 30 | + */ |
|
| 31 | + public static function getInstance() |
|
| 32 | + { |
|
| 33 | + if (null === static::$instance) { |
|
| 34 | + static::$instance = new static(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - return static::$instance; |
|
| 38 | - } |
|
| 37 | + return static::$instance; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * Protected constructor. |
|
| 42 | - */ |
|
| 43 | - protected function __construct() {} |
|
| 41 | + * Protected constructor. |
|
| 42 | + */ |
|
| 43 | + protected function __construct() {} |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * {@inheritdoc } |
|
| 47 | - * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle() |
|
| 48 | - */ |
|
| 49 | - public function handle(fw\Module\AbstractModule $module, $request) { |
|
| 45 | + /** |
|
| 46 | + * {@inheritdoc } |
|
| 47 | + * @see \MyArtJaub\Webtrees\Mvc\DispatcherInterface::handle() |
|
| 48 | + */ |
|
| 49 | + public function handle(fw\Module\AbstractModule $module, $request) { |
|
| 50 | 50 | |
| 51 | 51 | $fq_modclass_name = get_class($module); |
| 52 | 52 | $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
| 68 | 68 | if(class_exists($ctrl_class) |
| 69 | - && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
|
| 69 | + && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
|
| 70 | 70 | && $ctrl = new $ctrl_class($module) ) { |
| 71 | 71 | if(method_exists($ctrl, $method)) { |
| 72 | - try { |
|
| 73 | - call_user_func_array(array($ctrl, $method), array()); |
|
| 74 | - } |
|
| 75 | - catch (MvcException $ex) { |
|
| 76 | - if(!headers_sent()) { |
|
| 77 | - http_response_code($ex->getHttpCode()); |
|
| 78 | - } |
|
| 79 | - echo $ex->getMessage(); |
|
| 80 | - } |
|
| 72 | + try { |
|
| 73 | + call_user_func_array(array($ctrl, $method), array()); |
|
| 74 | + } |
|
| 75 | + catch (MvcException $ex) { |
|
| 76 | + if(!headers_sent()) { |
|
| 77 | + http_response_code($ex->getHttpCode()); |
|
| 78 | + } |
|
| 79 | + echo $ex->getMessage(); |
|
| 80 | + } |
|
| 81 | 81 | } |
| 82 | 82 | else { |
| 83 | 83 | throw new \Exception('The page requested does not exist'); |
@@ -86,27 +86,27 @@ discard block |
||
| 86 | 86 | else { |
| 87 | 87 | throw new \Exception('The page requested does not exist'); |
| 88 | 88 | } |
| 89 | - } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Private clone method to prevent cloning of the instance of the |
|
| 93 | - * *Dispatcher* instance. |
|
| 94 | - * |
|
| 95 | - * @return void |
|
| 96 | - */ |
|
| 97 | - private function __clone() |
|
| 98 | - { |
|
| 99 | - } |
|
| 91 | + /** |
|
| 92 | + * Private clone method to prevent cloning of the instance of the |
|
| 93 | + * *Dispatcher* instance. |
|
| 94 | + * |
|
| 95 | + * @return void |
|
| 96 | + */ |
|
| 97 | + private function __clone() |
|
| 98 | + { |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - /** |
|
| 102 | - * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
| 103 | - * instance. |
|
| 104 | - * |
|
| 105 | - * @return void |
|
| 106 | - */ |
|
| 107 | - private function __wakeup() |
|
| 108 | - { |
|
| 109 | - } |
|
| 101 | + /** |
|
| 102 | + * Private unserialize method to prevent unserializing of the *Dispatcher* |
|
| 103 | + * instance. |
|
| 104 | + * |
|
| 105 | + * @return void |
|
| 106 | + */ |
|
| 107 | + private function __wakeup() |
|
| 108 | + { |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | 111 | } |
| 112 | 112 | |
@@ -49,10 +49,10 @@ discard block |
||
| 49 | 49 | public function handle(fw\Module\AbstractModule $module, $request) { |
| 50 | 50 | |
| 51 | 51 | $fq_modclass_name = get_class($module); |
| 52 | - $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')) . '\\'; |
|
| 52 | + $ctrl_namespace = substr($fq_modclass_name, 0, - strlen('Module')).'\\'; |
|
| 53 | 53 | |
| 54 | - $args = explode( '@', $request, 2); |
|
| 55 | - switch(count($args)) { |
|
| 54 | + $args = explode('@', $request, 2); |
|
| 55 | + switch (count($args)) { |
|
| 56 | 56 | case 1: |
| 57 | 57 | $ctrl_name = $args[0]; |
| 58 | 58 | $method = 'index'; |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | break; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $ctrl_class = $ctrl_namespace . $ctrl_name . 'Controller'; |
|
| 68 | - if(class_exists($ctrl_class) |
|
| 67 | + $ctrl_class = $ctrl_namespace.$ctrl_name.'Controller'; |
|
| 68 | + if (class_exists($ctrl_class) |
|
| 69 | 69 | && is_subclass_of($ctrl_class, '\\MyArtJaub\\Webtrees\\Mvc\\Controller\\MvcController') |
| 70 | - && $ctrl = new $ctrl_class($module) ) { |
|
| 71 | - if(method_exists($ctrl, $method)) { |
|
| 70 | + && $ctrl = new $ctrl_class($module)) { |
|
| 71 | + if (method_exists($ctrl, $method)) { |
|
| 72 | 72 | try { |
| 73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
| 74 | 74 | } |
| 75 | 75 | catch (MvcException $ex) { |
| 76 | - if(!headers_sent()) { |
|
| 76 | + if (!headers_sent()) { |
|
| 77 | 77 | http_response_code($ex->getHttpCode()); |
| 78 | 78 | } |
| 79 | 79 | echo $ex->getMessage(); |
@@ -71,19 +71,16 @@ |
||
| 71 | 71 | if(method_exists($ctrl, $method)) { |
| 72 | 72 | try { |
| 73 | 73 | call_user_func_array(array($ctrl, $method), array()); |
| 74 | - } |
|
| 75 | - catch (MvcException $ex) { |
|
| 74 | + } catch (MvcException $ex) { |
|
| 76 | 75 | if(!headers_sent()) { |
| 77 | 76 | http_response_code($ex->getHttpCode()); |
| 78 | 77 | } |
| 79 | 78 | echo $ex->getMessage(); |
| 80 | 79 | } |
| 81 | - } |
|
| 82 | - else { |
|
| 80 | + } else { |
|
| 83 | 81 | throw new \Exception('The page requested does not exist'); |
| 84 | 82 | } |
| 85 | - } |
|
| 86 | - else { |
|
| 83 | + } else { |
|
| 87 | 84 | throw new \Exception('The page requested does not exist'); |
| 88 | 85 | } |
| 89 | 86 | } |
@@ -16,52 +16,52 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class MvcException extends \Exception { |
| 18 | 18 | |
| 19 | - /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
|
| 20 | - protected static $VALID_HTTP = array( |
|
| 21 | - 100, 101, |
|
| 22 | - 200, 201, 202, 203, 204, 205, 206, |
|
| 23 | - 300, 301, 302, 303, 304, 305, 306, 307, |
|
| 24 | - 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, |
|
| 25 | - 500, 501, 502, 503, 504, 505 |
|
| 26 | - ); |
|
| 19 | + /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
|
| 20 | + protected static $VALID_HTTP = array( |
|
| 21 | + 100, 101, |
|
| 22 | + 200, 201, 202, 203, 204, 205, 206, |
|
| 23 | + 300, 301, 302, 303, 304, 305, 306, 307, |
|
| 24 | + 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, |
|
| 25 | + 500, 501, 502, 503, 504, 505 |
|
| 26 | + ); |
|
| 27 | 27 | |
| 28 | - /** @var int $http_code */ |
|
| 29 | - protected $http_code; |
|
| 28 | + /** @var int $http_code */ |
|
| 29 | + protected $http_code; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Constructor for MvcException |
|
| 33 | - * |
|
| 34 | - * @param int $http_code |
|
| 35 | - * @param string $message |
|
| 36 | - * @param int $code |
|
| 37 | - * @param \Throwable $previous |
|
| 38 | - */ |
|
| 39 | - public function __construct($http_code = 500, $message = "", $code = 0, \Throwable $previous = null) { |
|
| 40 | - parent::__construct($message, $code, $previous); |
|
| 31 | + /** |
|
| 32 | + * Constructor for MvcException |
|
| 33 | + * |
|
| 34 | + * @param int $http_code |
|
| 35 | + * @param string $message |
|
| 36 | + * @param int $code |
|
| 37 | + * @param \Throwable $previous |
|
| 38 | + */ |
|
| 39 | + public function __construct($http_code = 500, $message = "", $code = 0, \Throwable $previous = null) { |
|
| 40 | + parent::__construct($message, $code, $previous); |
|
| 41 | 41 | |
| 42 | - $this->http_code = in_array($http_code, self::$VALID_HTTP) ? $http_code : 500; |
|
| 43 | - } |
|
| 42 | + $this->http_code = in_array($http_code, self::$VALID_HTTP) ? $http_code : 500; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Get the HTTP code |
|
| 47 | - * |
|
| 48 | - * @return int |
|
| 49 | - */ |
|
| 50 | - public function getHttpCode() { |
|
| 51 | - return $this->http_code; |
|
| 52 | - } |
|
| 45 | + /** |
|
| 46 | + * Get the HTTP code |
|
| 47 | + * |
|
| 48 | + * @return int |
|
| 49 | + */ |
|
| 50 | + public function getHttpCode() { |
|
| 51 | + return $this->http_code; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Set the HTTP code |
|
| 56 | - * |
|
| 57 | - * @param int $http_code |
|
| 58 | - * @throws InvalidArgumentException Thrown if not valid Http code |
|
| 59 | - */ |
|
| 60 | - public function setHttpCode($http_code) { |
|
| 61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
| 62 | - throw new \InvalidArgumentException('Invalid HTTP code'); |
|
| 63 | - $this->http_code= $http_code; |
|
| 64 | - } |
|
| 54 | + /** |
|
| 55 | + * Set the HTTP code |
|
| 56 | + * |
|
| 57 | + * @param int $http_code |
|
| 58 | + * @throws InvalidArgumentException Thrown if not valid Http code |
|
| 59 | + */ |
|
| 60 | + public function setHttpCode($http_code) { |
|
| 61 | + if(!in_array($http_code, self::$VALID_HTTP)) |
|
| 62 | + throw new \InvalidArgumentException('Invalid HTTP code'); |
|
| 63 | + $this->http_code= $http_code; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | class MvcException extends \Exception { |
| 18 | 18 | |
| 19 | 19 | /** @var int[] $VALID_HTTP List of valid HTTP codes */ |
| 20 | - protected static $VALID_HTTP = array( |
|
| 20 | + protected static $VALID_HTTP = array( |
|
| 21 | 21 | 100, 101, |
| 22 | 22 | 200, 201, 202, 203, 204, 205, 206, |
| 23 | 23 | 300, 301, 302, 303, 304, 305, 306, 307, |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | * @throws InvalidArgumentException Thrown if not valid Http code |
| 59 | 59 | */ |
| 60 | 60 | public function setHttpCode($http_code) { |
| 61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
| 61 | + if (!in_array($http_code, self::$VALID_HTTP)) |
|
| 62 | 62 | throw new \InvalidArgumentException('Invalid HTTP code'); |
| 63 | - $this->http_code= $http_code; |
|
| 63 | + $this->http_code = $http_code; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | } |
@@ -58,8 +58,9 @@ |
||
| 58 | 58 | * @throws InvalidArgumentException Thrown if not valid Http code |
| 59 | 59 | */ |
| 60 | 60 | public function setHttpCode($http_code) { |
| 61 | - if(!in_array($http_code, self::$VALID_HTTP)) |
|
| 62 | - throw new \InvalidArgumentException('Invalid HTTP code'); |
|
| 61 | + if(!in_array($http_code, self::$VALID_HTTP)) { |
|
| 62 | + throw new \InvalidArgumentException('Invalid HTTP code'); |
|
| 63 | + } |
|
| 63 | 64 | $this->http_code= $http_code; |
| 64 | 65 | } |
| 65 | 66 | |
@@ -19,59 +19,59 @@ |
||
| 19 | 19 | * Hooks Module. |
| 20 | 20 | */ |
| 21 | 21 | class HooksModule extends AbstractModule implements ModuleConfigInterface, DependentInterface { |
| 22 | - // How to update the database schema for this module |
|
| 23 | - const SCHEMA_TARGET_VERSION = 1; |
|
| 24 | - const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
| 25 | - const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\Hooks\Schema'; |
|
| 22 | + // How to update the database schema for this module |
|
| 23 | + const SCHEMA_TARGET_VERSION = 1; |
|
| 24 | + const SCHEMA_SETTING_NAME = 'MAJ_HOOKS_SCHEMA_VERSION'; |
|
| 25 | + const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\Hooks\Schema'; |
|
| 26 | 26 | |
| 27 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 28 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 27 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 28 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * {@inhericDoc} |
|
| 32 | - */ |
|
| 33 | - public function getTitle() { |
|
| 34 | - return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
| 35 | - } |
|
| 30 | + /** |
|
| 31 | + * {@inhericDoc} |
|
| 32 | + */ |
|
| 33 | + public function getTitle() { |
|
| 34 | + return /* I18N: Name of the “Hooks” module */ I18N::translate('Hooks'); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * {@inhericDoc} |
|
| 39 | - */ |
|
| 40 | - public function getDescription() { |
|
| 41 | - return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
| 42 | - } |
|
| 37 | + /** |
|
| 38 | + * {@inhericDoc} |
|
| 39 | + */ |
|
| 40 | + public function getDescription() { |
|
| 41 | + return /* I18N: Description of the “Hooks” module */ I18N::translate('Implements hooks management.'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * {@inhericDoc} |
|
| 46 | - */ |
|
| 47 | - public function modAction($mod_action) { |
|
| 48 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 44 | + /** |
|
| 45 | + * {@inhericDoc} |
|
| 46 | + */ |
|
| 47 | + public function modAction($mod_action) { |
|
| 48 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 49 | 49 | |
| 50 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 51 | - } |
|
| 50 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * {@inhericDoc} |
|
| 55 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 56 | - */ |
|
| 57 | - public function getConfigLink() { |
|
| 58 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 53 | + /** |
|
| 54 | + * {@inhericDoc} |
|
| 55 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 56 | + */ |
|
| 57 | + public function getConfigLink() { |
|
| 58 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 59 | 59 | |
| 60 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 61 | - } |
|
| 60 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * {@inheritDoc} |
|
| 65 | - * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
| 66 | - */ |
|
| 67 | - public function validatePrerequisites() { |
|
| 68 | - try { |
|
| 69 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 70 | - return true; |
|
| 71 | - } |
|
| 72 | - catch (\Exception $ex) { } |
|
| 73 | - return false; |
|
| 74 | - } |
|
| 63 | + /** |
|
| 64 | + * {@inheritDoc} |
|
| 65 | + * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
| 66 | + */ |
|
| 67 | + public function validatePrerequisites() { |
|
| 68 | + try { |
|
| 69 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 70 | + return true; |
|
| 71 | + } |
|
| 72 | + catch (\Exception $ex) { } |
|
| 73 | + return false; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | } |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | try { |
| 69 | 69 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
| 70 | 70 | return true; |
| 71 | - } |
|
| 72 | - catch (\Exception $ex) { } |
|
| 71 | + } catch (\Exception $ex) { } |
|
| 73 | 72 | return false; |
| 74 | 73 | } |
| 75 | 74 | |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | public function getConfigLink() { |
| 58 | 58 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
| 59 | 59 | |
| 60 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 60 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -79,8 +79,7 @@ |
||
| 79 | 79 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
| 80 | 80 | |
| 81 | 81 | return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME)); |
| 82 | - } |
|
| 83 | - catch (\Exception $ex) { } |
|
| 82 | + } catch (\Exception $ex) { } |
|
| 84 | 83 | return false; |
| 85 | 84 | } |
| 86 | 85 | |
@@ -25,86 +25,86 @@ |
||
| 25 | 25 | class GeoDispersionModule extends AbstractModule implements ModuleConfigInterface, DependentInterface { |
| 26 | 26 | |
| 27 | 27 | // How to update the database schema for this module |
| 28 | - const SCHEMA_TARGET_VERSION = 1; |
|
| 29 | - const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
| 30 | - const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\GeoDispersion\Schema'; |
|
| 28 | + const SCHEMA_TARGET_VERSION = 1; |
|
| 29 | + const SCHEMA_SETTING_NAME = 'MAJ_GEODISP_SCHEMA_VERSION'; |
|
| 30 | + const SCHEMA_MIGRATION_PREFIX = '\MyArtJaub\Webtrees\Module\GeoDispersion\Schema'; |
|
| 31 | 31 | |
| 32 | - /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 33 | - const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 32 | + /** @var string For custom modules - link for support, upgrades, etc. */ |
|
| 33 | + const CUSTOM_WEBSITE = 'https://github.com/jon48/webtrees-lib'; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * GeoDispersion analysis provider |
|
| 37 | - * @var \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider $provider |
|
| 38 | - */ |
|
| 39 | - protected $provider; |
|
| 35 | + /** |
|
| 36 | + * GeoDispersion analysis provider |
|
| 37 | + * @var \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider $provider |
|
| 38 | + */ |
|
| 39 | + protected $provider; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * {@inhericDoc} |
|
| 43 | - */ |
|
| 44 | - public function getTitle() { |
|
| 45 | - return /* I18N: Name of the “Hooks” module */ I18N::translate('Geographical Dispersion'); |
|
| 46 | - } |
|
| 41 | + /** |
|
| 42 | + * {@inhericDoc} |
|
| 43 | + */ |
|
| 44 | + public function getTitle() { |
|
| 45 | + return /* I18N: Name of the “Hooks” module */ I18N::translate('Geographical Dispersion'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inhericDoc} |
|
| 50 | - */ |
|
| 51 | - public function getDescription() { |
|
| 52 | - return /* I18N: Description of the “Hooks” module */ I18N::translate('Display the geographical dispersion of the root person’s Sosa ancestors.'); |
|
| 53 | - } |
|
| 48 | + /** |
|
| 49 | + * {@inhericDoc} |
|
| 50 | + */ |
|
| 51 | + public function getDescription() { |
|
| 52 | + return /* I18N: Description of the “Hooks” module */ I18N::translate('Display the geographical dispersion of the root person’s Sosa ancestors.'); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * {@inhericDoc} |
|
| 57 | - */ |
|
| 58 | - public function modAction($mod_action) { |
|
| 59 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 55 | + /** |
|
| 56 | + * {@inhericDoc} |
|
| 57 | + */ |
|
| 58 | + public function modAction($mod_action) { |
|
| 59 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 60 | 60 | |
| 61 | - \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 62 | - } |
|
| 61 | + \MyArtJaub\Webtrees\Mvc\Dispatcher::getInstance()->handle($this, $mod_action); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * {@inhericDoc} |
|
| 66 | - * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 67 | - */ |
|
| 68 | - public function getConfigLink() { |
|
| 69 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 64 | + /** |
|
| 65 | + * {@inhericDoc} |
|
| 66 | + * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink() |
|
| 67 | + */ |
|
| 68 | + public function getConfigLink() { |
|
| 69 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 70 | 70 | |
| 71 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 72 | - } |
|
| 71 | + return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * {@inhericDoc} |
|
| 76 | - * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
| 77 | - */ |
|
| 78 | - public function validatePrerequisites() { |
|
| 79 | - try { |
|
| 80 | - Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 74 | + /** |
|
| 75 | + * {@inhericDoc} |
|
| 76 | + * @see \MyArtJaub\Webtrees\Module\DependentInterface::validatePrerequisites() |
|
| 77 | + */ |
|
| 78 | + public function validatePrerequisites() { |
|
| 79 | + try { |
|
| 80 | + Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
|
| 81 | 81 | |
| 82 | - return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME)); |
|
| 83 | - } |
|
| 84 | - catch (\Exception $ex) { } |
|
| 85 | - return false; |
|
| 86 | - } |
|
| 82 | + return !is_null(Module::getModuleByName(Constants::MODULE_MAJ_SOSA_NAME)); |
|
| 83 | + } |
|
| 84 | + catch (\Exception $ex) { } |
|
| 85 | + return false; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Get the GeoAnalysis Provider (initialise it if not done yet). |
| 90 | 90 | * |
| 91 | 91 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider |
| 92 | 92 | */ |
| 93 | - public function getProvider() { |
|
| 94 | - if(!$this->provider) { |
|
| 95 | - $this->provider = new GeoAnalysisProvider(Globals::getTree()); |
|
| 96 | - } |
|
| 97 | - return $this->provider; |
|
| 98 | - } |
|
| 93 | + public function getProvider() { |
|
| 94 | + if(!$this->provider) { |
|
| 95 | + $this->provider = new GeoAnalysisProvider(Globals::getTree()); |
|
| 96 | + } |
|
| 97 | + return $this->provider; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | 100 | /** |
| 101 | 101 | * Set the GeoAnalysis Provider. |
| 102 | 102 | * |
| 103 | 103 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider |
| 104 | 104 | */ |
| 105 | - public function setProvider(GeoAnalysisProvider $provider) { |
|
| 106 | - $this->provider = $provider; |
|
| 107 | - } |
|
| 105 | + public function setProvider(GeoAnalysisProvider $provider) { |
|
| 106 | + $this->provider = $provider; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | public function getConfigLink() { |
| 69 | 69 | Database::updateSchema(self::SCHEMA_MIGRATION_PREFIX, self::SCHEMA_SETTING_NAME, self::SCHEMA_TARGET_VERSION); |
| 70 | 70 | |
| 71 | - return 'module.php?mod=' . $this->getName() . '&mod_action=AdminConfig'; |
|
| 71 | + return 'module.php?mod='.$this->getName().'&mod_action=AdminConfig'; |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return \MyArtJaub\Webtrees\Module\GeoDispersion\Model\GeoAnalysisProvider |
| 92 | 92 | */ |
| 93 | 93 | public function getProvider() { |
| 94 | - if(!$this->provider) { |
|
| 94 | + if (!$this->provider) { |
|
| 95 | 95 | $this->provider = new GeoAnalysisProvider(Globals::getTree()); |
| 96 | 96 | } |
| 97 | 97 | return $this->provider; |
@@ -24,9 +24,9 @@ discard block |
||
| 24 | 24 | * {@inhericDoc} |
| 25 | 25 | * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent() |
| 26 | 26 | */ |
| 27 | - protected function renderContent() { |
|
| 27 | + protected function renderContent() { |
|
| 28 | 28 | |
| 29 | - ?> |
|
| 29 | + ?> |
|
| 30 | 30 | |
| 31 | 31 | <div id="maj-sosa-config-page"> |
| 32 | 32 | <h2><?php echo $this->data->get('title'); ?></h2> |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | </div> |
| 47 | 47 | <div class="value"> |
| 48 | 48 | <?php |
| 49 | - $users = $this->data->get('users_settings'); |
|
| 50 | - if(count($users) == 1) { |
|
| 51 | - $root_indi = $users[0]['rootid']; ?> |
|
| 49 | + $users = $this->data->get('users_settings'); |
|
| 50 | + if(count($users) == 1) { |
|
| 51 | + $root_indi = $users[0]['rootid']; ?> |
|
| 52 | 52 | <label> |
| 53 | 53 | <input id="maj_sosa_input_userid" type="hidden" name="userid" value="<?php echo $users[0]['user']->getUserId(); ?>" /> |
| 54 | 54 | <?php echo $users[0]['user']->getRealNameHtml() ?> |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | <?php } else if(count($users) > 1) { ?> |
| 57 | 57 | <select id='maj-sosa-config-select' name="userid"> |
| 58 | 58 | <?php |
| 59 | - $root_indi = $users[0]['rootid']; |
|
| 60 | - foreach ($this->data->get('users_settings') as $user) { ?> |
|
| 59 | + $root_indi = $users[0]['rootid']; |
|
| 60 | + foreach ($this->data->get('users_settings') as $user) { ?> |
|
| 61 | 61 | <option value="<?php echo $user['user']->getUserId(); ?>"><?php echo $user['user']->getRealNameHtml() ?></option> |
| 62 | 62 | <?php } ?> |
| 63 | 63 | </select> |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | </form> |
| 81 | 81 | |
| 82 | 82 | <?php |
| 83 | - } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | \ No newline at end of file |
@@ -47,13 +47,13 @@ |
||
| 47 | 47 | <div class="value"> |
| 48 | 48 | <?php |
| 49 | 49 | $users = $this->data->get('users_settings'); |
| 50 | - if(count($users) == 1) { |
|
| 51 | - $root_indi = $users[0]['rootid']; ?> |
|
| 50 | + if (count($users) == 1) { |
|
| 51 | + $root_indi = $users[0]['rootid']; ?> |
|
| 52 | 52 | <label> |
| 53 | 53 | <input id="maj_sosa_input_userid" type="hidden" name="userid" value="<?php echo $users[0]['user']->getUserId(); ?>" /> |
| 54 | 54 | <?php echo $users[0]['user']->getRealNameHtml() ?> |
| 55 | 55 | </label> |
| 56 | - <?php } else if(count($users) > 1) { ?> |
|
| 56 | + <?php } else if (count($users) > 1) { ?> |
|
| 57 | 57 | <select id='maj-sosa-config-select' name="userid"> |
| 58 | 58 | <?php |
| 59 | 59 | $root_indi = $users[0]['rootid']; |