@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function getBaseDataAction(Request $request) { |
| 208 | 208 | $provider = $this->getMapProviderData($request); |
| 209 | - $style = $provider['selectedStyleName'] = '' ? '' : '.' . $provider['selectedStyleName']; |
|
| 209 | + $style = $provider['selectedStyleName'] = '' ? '' : '.' . $provider['selectedStyleName']; |
|
| 210 | 210 | |
| 211 | 211 | switch ($provider['selectedProvIndex']) { |
| 212 | 212 | case 'mapbox': |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | $color = self::LINE_COLORS[log($id, 2) % $color_count]; |
| 294 | 294 | $icon['color'] = $color; //make icon color the same as the line |
| 295 | 295 | $sosa_points[$id] = $event->getLatLonJSArray(); |
| 296 | - $sosa_parent = (int)floor($id / 2); |
|
| 296 | + $sosa_parent = (int) floor($id / 2); |
|
| 297 | 297 | if (array_key_exists($sosa_parent, $sosa_points)) { |
| 298 | 298 | // Would like to use a GeometryCollection to hold LineStrings |
| 299 | 299 | // rather than generate polylines but the MarkerCluster library |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | 'modules/openstreetmap/event-sidebar', |
| 326 | 326 | $event->shortSummary($mapType, $id) |
| 327 | 327 | ), |
| 328 | - 'zoom' => (int)$event->getZoom(), |
|
| 328 | + 'zoom' => (int) $event->getZoom(), |
|
| 329 | 329 | ], |
| 330 | 330 | ]; |
| 331 | 331 | } |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | 'stats' => $placeStats, |
| 396 | 396 | ] |
| 397 | 397 | ), |
| 398 | - 'zoom' => (int)($location->getZoom() ?? 2), |
|
| 398 | + 'zoom' => (int) ($location->getZoom() ?? 2), |
|
| 399 | 399 | ], |
| 400 | 400 | ]; |
| 401 | 401 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $xref = $request->get('reference'); |
| 448 | 448 | $tree = $request->attributes->get('tree'); |
| 449 | 449 | $individual = Individual::getInstance($xref, $tree); |
| 450 | - $generations = (int)$request->get( |
|
| 450 | + $generations = (int) $request->get( |
|
| 451 | 451 | 'generations', |
| 452 | 452 | $tree->getPreference('DEFAULT_PEDIGREE_GENERATIONS') |
| 453 | 453 | ); |
@@ -496,14 +496,14 @@ discard block |
||
| 496 | 496 | function ($item) { |
| 497 | 497 | return preg_replace('/[^a-z\d]/i', '', strtolower($item)); |
| 498 | 498 | }, |
| 499 | - (array)$provider->styles |
|
| 499 | + (array) $provider->styles |
|
| 500 | 500 | ); |
| 501 | 501 | |
| 502 | - $key = preg_replace('/[^a-z\d]/i', '', strtolower((string)$provider->name)); |
|
| 502 | + $key = preg_replace('/[^a-z\d]/i', '', strtolower((string) $provider->name)); |
|
| 503 | 503 | |
| 504 | 504 | self::$map_providers[$key] = [ |
| 505 | - 'name' => (string)$provider->name, |
|
| 506 | - 'styles' => array_combine($style_keys, (array)$provider->styles), |
|
| 505 | + 'name' => (string) $provider->name, |
|
| 506 | + 'styles' => array_combine($style_keys, (array) $provider->styles), |
|
| 507 | 507 | ]; |
| 508 | 508 | } |
| 509 | 509 | } catch (\Exception $ex) { |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | $maxgenerations = $tree->getPreference('MAX_PEDIGREE_GENERATIONS'); |
| 566 | 566 | $generations = $request->get('generations', $tree->getPreference('DEFAULT_PEDIGREE_GENERATIONS')); |
| 567 | 567 | |
| 568 | - return (object)[ |
|
| 568 | + return (object) [ |
|
| 569 | 569 | 'name' => 'modules/openstreetmap/pedigreemap', |
| 570 | 570 | 'data' => [ |
| 571 | 571 | 'assets' => $this->assets(), |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | * @return object |
| 629 | 629 | */ |
| 630 | 630 | public function getAdminConfigAction(Request $request) { |
| 631 | - return (object)[ |
|
| 631 | + return (object) [ |
|
| 632 | 632 | 'name' => 'modules/openstreetmap/admin-config', |
| 633 | 633 | 'data' => [ |
| 634 | 634 | 'title' => I18N::translate('Open Street Maps (Configuration)'), |
@@ -684,8 +684,8 @@ discard block |
||
| 684 | 684 | * @throws \Exception |
| 685 | 685 | */ |
| 686 | 686 | public function getAdminPlacesAction(Request $request) { |
| 687 | - $parent_id = (int)$request->get('parent_id', 0); |
|
| 688 | - $inactive = (bool)$request->get('inactive'); |
|
| 687 | + $parent_id = (int) $request->get('parent_id', 0); |
|
| 688 | + $inactive = (bool) $request->get('inactive'); |
|
| 689 | 689 | $hierarchy = $this->gethierarchy($parent_id); |
| 690 | 690 | $title = I18N::translate('Open Street Maps (Geographic data)'); |
| 691 | 691 | $breadcrumbs = [ |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | } |
| 709 | 709 | $breadcrumbs[] = array_pop($breadcrumbs); |
| 710 | 710 | |
| 711 | - return (object)[ |
|
| 711 | + return (object) [ |
|
| 712 | 712 | 'name' => 'modules/openstreetmap/admin-places', |
| 713 | 713 | 'data' => [ |
| 714 | 714 | 'title' => $title, |
@@ -729,9 +729,9 @@ discard block |
||
| 729 | 729 | * @throws \Exception |
| 730 | 730 | */ |
| 731 | 731 | public function getAdminPlaceEditAction(Request $request) { |
| 732 | - $parent_id = (int)$request->get('parent_id', 0); |
|
| 733 | - $place_id = (int)$request->get('place_id'); |
|
| 734 | - $inactive = (int)$request->get('inactive'); |
|
| 732 | + $parent_id = (int) $request->get('parent_id', 0); |
|
| 733 | + $place_id = (int) $request->get('place_id'); |
|
| 734 | + $inactive = (int) $request->get('inactive'); |
|
| 735 | 735 | $hierarchy = $this->gethierarchy($place_id); |
| 736 | 736 | $fqpn = empty($hierarchy) ? '' : $hierarchy[0]->fqpn; |
| 737 | 737 | $location = new Location($fqpn); |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | } |
| 768 | 768 | $breadcrumbs[] = $place_id === 0 ? I18N::translate('Add') : I18N::translate('Edit'); |
| 769 | 769 | |
| 770 | - return (object)[ |
|
| 770 | + return (object) [ |
|
| 771 | 771 | 'name' => 'modules/openstreetmap/admin-place-edit', |
| 772 | 772 | 'data' => [ |
| 773 | 773 | 'module' => $this->getName(), |
@@ -793,9 +793,9 @@ discard block |
||
| 793 | 793 | */ |
| 794 | 794 | public function postAdminSaveAction(Request $request) { |
| 795 | 795 | if (Filter::checkCsrf()) { |
| 796 | - $parent_id = (int)$request->get('parent_id'); |
|
| 797 | - $place_id = (int)$request->get('place_id'); |
|
| 798 | - $inactive = (int)$request->get('inactive'); |
|
| 796 | + $parent_id = (int) $request->get('parent_id'); |
|
| 797 | + $place_id = (int) $request->get('place_id'); |
|
| 798 | + $inactive = (int) $request->get('inactive'); |
|
| 799 | 799 | $lat = round($request->get('new_place_lati'), 5); // 5 decimal places (locate to within about 1 metre) |
| 800 | 800 | $lat = ($lat < 0 ? 'S' : 'N') . abs($lat); |
| 801 | 801 | $lng = round($request->get('new_place_long'), 5); |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | VALUES (:id, :parent, :level, :place, :lng, :lat, :zoom, :icon)" |
| 815 | 815 | )->execute( |
| 816 | 816 | [ |
| 817 | - 'id' => (int)Database::prepare("SELECT MAX(pl_id)+1 FROM `##placelocation`")->fetchOne(), |
|
| 817 | + 'id' => (int) Database::prepare("SELECT MAX(pl_id)+1 FROM `##placelocation`")->fetchOne(), |
|
| 818 | 818 | 'parent' => $parent_id, |
| 819 | 819 | 'level' => $level, |
| 820 | 820 | 'place' => $request->get('new_place_name'), |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | 'place' => $request->get('new_place_name'), |
| 834 | 834 | 'lat' => $request->get('lati_control') . $lat, |
| 835 | 835 | 'lng' => $request->get('long_control') . $lng, |
| 836 | - 'zoom' => (int)$request->get('new_zoom_factor'), |
|
| 836 | + 'zoom' => (int) $request->get('new_zoom_factor'), |
|
| 837 | 837 | 'icon' => $icon, |
| 838 | 838 | ] |
| 839 | 839 | ); |
@@ -866,9 +866,9 @@ discard block |
||
| 866 | 866 | */ |
| 867 | 867 | public function postAdminDeleteRecordAction(Request $request): RedirectResponse { |
| 868 | 868 | if (Filter::checkCsrf()) { |
| 869 | - $place_id = (int)$request->get('place_id'); |
|
| 870 | - $parent_id = (int)$request->get('parent_id'); |
|
| 871 | - $inactive = (int)$request->get('inactive'); |
|
| 869 | + $place_id = (int) $request->get('place_id'); |
|
| 870 | + $parent_id = (int) $request->get('parent_id'); |
|
| 871 | + $inactive = (int) $request->get('inactive'); |
|
| 872 | 872 | |
| 873 | 873 | try { |
| 874 | 874 | Database::prepare( |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | ); |
| 888 | 888 | } |
| 889 | 889 | // If after deleting there are no more places at this level then go up a level |
| 890 | - $children = (int)Database::prepare( |
|
| 890 | + $children = (int) Database::prepare( |
|
| 891 | 891 | "SELECT COUNT(pl_id) FROM `##placelocation` WHERE pl_parent_id = :parent_id" |
| 892 | 892 | ) |
| 893 | 893 | ->execute(['parent_id' => $parent_id]) |
@@ -920,9 +920,9 @@ discard block |
||
| 920 | 920 | * @throws \Exception |
| 921 | 921 | */ |
| 922 | 922 | public function getAdminExportAction(Request $request) { |
| 923 | - $parent_id = (int)$request->get('parent_id'); |
|
| 923 | + $parent_id = (int) $request->get('parent_id'); |
|
| 924 | 924 | $format = $request->get('format', 'csv'); |
| 925 | - $maxlevel = (int)Database::prepare("SELECT max(pl_level) FROM `##placelocation`")->execute()->fetchOne(); |
|
| 925 | + $maxlevel = (int) Database::prepare("SELECT max(pl_level) FROM `##placelocation`")->execute()->fetchOne(); |
|
| 926 | 926 | $startfqpn = []; |
| 927 | 927 | $hierarchy = $this->gethierarchy($parent_id); |
| 928 | 928 | $geojson = []; |
@@ -974,8 +974,8 @@ discard block |
||
| 974 | 974 | ) |
| 975 | 975 | ) |
| 976 | 976 | ); |
| 977 | - $long = (float)strtr($place['pl_long'], ['E' => '', 'W' => '-', ',' => '.']); |
|
| 978 | - $lati = (float)strtr($place['pl_lati'], ['N' => '', 'S' => '-', ',' => '.']); |
|
| 977 | + $long = (float) strtr($place['pl_long'], ['E' => '', 'W' => '-', ',' => '.']); |
|
| 978 | + $lati = (float) strtr($place['pl_lati'], ['N' => '', 'S' => '-', ',' => '.']); |
|
| 979 | 979 | |
| 980 | 980 | $geojson['features'][] = [ |
| 981 | 981 | 'type' => 'Feature', |
@@ -1007,8 +1007,8 @@ discard block |
||
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | public function getAdminImportFormAction(Request $request) { |
| 1010 | - $parent_id = (int)$request->get('parent_id'); |
|
| 1011 | - $inactive = (int)$request->get('inactive'); |
|
| 1010 | + $parent_id = (int) $request->get('parent_id'); |
|
| 1011 | + $inactive = (int) $request->get('inactive'); |
|
| 1012 | 1012 | $breadcrumbs = [ |
| 1013 | 1013 | route('admin-control-panel') => I18N::translate('Control panel'), |
| 1014 | 1014 | route('admin-modules') => I18N::translate('Module administration'), |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | } |
| 1035 | 1035 | ); |
| 1036 | 1036 | |
| 1037 | - return (object)[ |
|
| 1037 | + return (object) [ |
|
| 1038 | 1038 | 'name' => 'modules/openstreetmap/admin-import-form', |
| 1039 | 1039 | 'data' => [ |
| 1040 | 1040 | 'title' => I18N::translate('Import geographic data'), |
@@ -1098,8 +1098,8 @@ discard block |
||
| 1098 | 1098 | $row = explode($delimiter, $input_array[0]); |
| 1099 | 1099 | $fields = count($row); |
| 1100 | 1100 | if ($fields >= 6 && |
| 1101 | - (bool)preg_match("/[SN][0-9]*\.?[0-9]*/", $row[$fields - 3]) && |
|
| 1102 | - (bool)preg_match("/[EW][0-9]*\.?[0-9]*/", $row[$fields - 4])) { |
|
| 1101 | + (bool) preg_match("/[SN][0-9]*\.?[0-9]*/", $row[$fields - 3]) && |
|
| 1102 | + (bool) preg_match("/[EW][0-9]*\.?[0-9]*/", $row[$fields - 4])) { |
|
| 1103 | 1103 | $filetype = 'csv'; |
| 1104 | 1104 | } |
| 1105 | 1105 | } |
@@ -1155,7 +1155,7 @@ discard block |
||
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | if ($filetype !== '?') { |
| 1158 | - if ((bool)$request->get('cleardatabase')) { |
|
| 1158 | + if ((bool) $request->get('cleardatabase')) { |
|
| 1159 | 1159 | Database::exec("TRUNCATE TABLE `##placelocation`"); |
| 1160 | 1160 | } |
| 1161 | 1161 | //process places |
@@ -1166,10 +1166,10 @@ discard block |
||
| 1166 | 1166 | usort( |
| 1167 | 1167 | $places, |
| 1168 | 1168 | function (array $a, array $b) { |
| 1169 | - if ((int)$a['pl_level'] === (int)$b['pl_level']) { |
|
| 1169 | + if ((int) $a['pl_level'] === (int) $b['pl_level']) { |
|
| 1170 | 1170 | return I18N::strcasecmp($a['fqpn'], $b['fqpn']); |
| 1171 | 1171 | } else { |
| 1172 | - return (int)$a['pl_level'] - (int)$b['pl_level']; |
|
| 1172 | + return (int) $a['pl_level'] - (int) $b['pl_level']; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | } |
| 1175 | 1175 | ); |
@@ -1189,7 +1189,7 @@ discard block |
||
| 1189 | 1189 | )) { |
| 1190 | 1190 | |
| 1191 | 1191 | // overwrite |
| 1192 | - $location->update((object)$place); |
|
| 1192 | + $location->update((object) $place); |
|
| 1193 | 1193 | $updated++; |
| 1194 | 1194 | } elseif (!$valid && $options !== 'update') { |
| 1195 | 1195 | //add |
@@ -1259,7 +1259,7 @@ discard block |
||
| 1259 | 1259 | */ |
| 1260 | 1260 | public function postAdminImportPlacesAction(Request $request) { |
| 1261 | 1261 | $gedcomName = $request->get('ged'); |
| 1262 | - $inactive = (int)$request->get('inactive'); |
|
| 1262 | + $inactive = (int) $request->get('inactive'); |
|
| 1263 | 1263 | $tree = Tree::findByName($gedcomName); |
| 1264 | 1264 | |
| 1265 | 1265 | // Get all the places from the places table ... |
@@ -1478,7 +1478,7 @@ discard block |
||
| 1478 | 1478 | $list = []; |
| 1479 | 1479 | /** @var array $rows */ |
| 1480 | 1480 | foreach ($rows as $row) { |
| 1481 | - if ((bool)$row['inactive'] && !$show_inactive) { |
|
| 1481 | + if ((bool) $row['inactive'] && !$show_inactive) { |
|
| 1482 | 1482 | continue; |
| 1483 | 1483 | } |
| 1484 | 1484 | |
@@ -1489,20 +1489,20 @@ discard block |
||
| 1489 | 1489 | ] |
| 1490 | 1490 | )->fetchOneRow(); |
| 1491 | 1491 | |
| 1492 | - if ((bool)$row['inactive']) { |
|
| 1492 | + if ((bool) $row['inactive']) { |
|
| 1493 | 1493 | $badge = 'danger'; |
| 1494 | - } elseif ((int)$children->no_coord > 0) { |
|
| 1494 | + } elseif ((int) $children->no_coord > 0) { |
|
| 1495 | 1495 | $badge = 'warning'; |
| 1496 | - } elseif ((int)$children->child_count > 0) { |
|
| 1496 | + } elseif ((int) $children->child_count > 0) { |
|
| 1497 | 1497 | $badge = 'info'; |
| 1498 | 1498 | } else { |
| 1499 | 1499 | $badge = 'secondary'; |
| 1500 | 1500 | } |
| 1501 | 1501 | |
| 1502 | - $list[] = (object)array_merge( |
|
| 1502 | + $list[] = (object) array_merge( |
|
| 1503 | 1503 | $row, |
| 1504 | 1504 | [ |
| 1505 | - 'child_count' => (int)$children->child_count, |
|
| 1505 | + 'child_count' => (int) $children->child_count, |
|
| 1506 | 1506 | 'badge' => $badge, |
| 1507 | 1507 | ] |
| 1508 | 1508 | ); |
@@ -1524,7 +1524,7 @@ discard block |
||
| 1524 | 1524 | $row = $statement->execute(['id' => $id])->fetchOneRow(); |
| 1525 | 1525 | $fqpn[] = $row->pl_place; |
| 1526 | 1526 | $row->fqpn = implode(Place::GEDCOM_SEPARATOR, $fqpn); |
| 1527 | - $id = (int)$row->pl_parent_id; |
|
| 1527 | + $id = (int) $row->pl_parent_id; |
|
| 1528 | 1528 | $arr[] = $row; |
| 1529 | 1529 | } |
| 1530 | 1530 | |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | */ |
| 1540 | 1540 | private function buildLevel($parent_id, $placename, &$places) { |
| 1541 | 1541 | $level = array_search('', $placename); |
| 1542 | - $rows = (array)Database::prepare( |
|
| 1542 | + $rows = (array) Database::prepare( |
|
| 1543 | 1543 | "SELECT pl_level, pl_id, pl_place, pl_long, pl_lati, pl_zoom, pl_icon FROM `##placelocation` WHERE pl_parent_id=? ORDER BY pl_place" |
| 1544 | 1544 | ) |
| 1545 | 1545 | ->execute([$parent_id]) |
@@ -1067,9 +1067,11 @@ discard block |
||
| 1067 | 1067 | $delimiter = ''; |
| 1068 | 1068 | $field_names = ['pl_level', 'pl_long', 'pl_lati', 'pl_zoom', 'pl_icon', 'fqpn']; |
| 1069 | 1069 | |
| 1070 | - if ($serverfile !== '') { // first choice is file on server |
|
| 1070 | + if ($serverfile !== '') { |
|
| 1071 | +// first choice is file on server |
|
| 1071 | 1072 | $filename = WT_MODULES_DIR . $this->getName() . '/extra/' . $serverfile; |
| 1072 | - } elseif ($_FILES['localfile']['error'] === UPLOAD_ERR_OK) { // 2nd choice is local file |
|
| 1073 | + } elseif ($_FILES['localfile']['error'] === UPLOAD_ERR_OK) { |
|
| 1074 | +// 2nd choice is local file |
|
| 1073 | 1075 | $filename = $_FILES['localfile']['tmp_name']; |
| 1074 | 1076 | } |
| 1075 | 1077 | |
@@ -1090,7 +1092,8 @@ discard block |
||
| 1090 | 1092 | $delimiter = ','; |
| 1091 | 1093 | } |
| 1092 | 1094 | if ($delimiter !== '') { |
| 1093 | - if (!is_numeric($record[0])) { // lose the header |
|
| 1095 | + if (!is_numeric($record[0])) { |
|
| 1096 | +// lose the header |
|
| 1094 | 1097 | array_shift($input_array); |
| 1095 | 1098 | } |
| 1096 | 1099 | |