Completed
Push — openstreetmap ( f189bb...923bcc )
by Greg
08:51
created
app/Module/OpenStreetMapModule.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 						$color            = self::LINE_COLORS[log($id, 2) % $color_count];
297 297
 						$icon['color']    = $color; //make icon color the same as the line
298 298
 						$sosa_points[$id] = $event->getLatLonJSArray();
299
-						$sosa_parent      = (int)floor($id / 2);
299
+						$sosa_parent      = (int) floor($id / 2);
300 300
 						if (array_key_exists($sosa_parent, $sosa_points)) {
301 301
 							// Would like to use a GeometryCollection to hold LineStrings
302 302
 							// rather than generate polylines but the MarkerCluster library
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 								'modules/openstreetmap/event-sidebar',
329 329
 								$event->shortSummary($mapType, $id)
330 330
 							),
331
-							'zoom'     => (int)$event->getZoom(),
331
+							'zoom'     => (int) $event->getZoom(),
332 332
 						],
333 333
 					];
334 334
 				}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 							'stats'    => $placeStats,
399 399
 						]
400 400
 					),
401
-					'zoom'    => (int)($location->getZoom() ?? 2),
401
+					'zoom'    => (int) ($location->getZoom() ?? 2),
402 402
 				],
403 403
 			];
404 404
 		}
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 		$xref        = $request->get('reference');
451 451
 		$tree        = $request->attributes->get('tree');
452 452
 		$individual  = Individual::getInstance($xref, $tree);
453
-		$generations = (int)$request->get(
453
+		$generations = (int) $request->get(
454 454
 			'generations',
455 455
 			$tree->getPreference('DEFAULT_PEDIGREE_GENERATIONS')
456 456
 		);
@@ -499,14 +499,14 @@  discard block
 block discarded – undo
499 499
 						function ($item) {
500 500
 							return preg_replace('/[^a-z\d]/i', '', strtolower($item));
501 501
 						},
502
-						(array)$provider->styles
502
+						(array) $provider->styles
503 503
 					);
504 504
 
505
-					$key = preg_replace('/[^a-z\d]/i', '', strtolower((string)$provider->name));
505
+					$key = preg_replace('/[^a-z\d]/i', '', strtolower((string) $provider->name));
506 506
 
507 507
 					self::$map_providers[$key] = [
508
-						'name'   => (string)$provider->name,
509
-						'styles' => array_combine($style_keys, (array)$provider->styles),
508
+						'name'   => (string) $provider->name,
509
+						'styles' => array_combine($style_keys, (array) $provider->styles),
510 510
 					];
511 511
 				}
512 512
 			} catch (\Exception $ex) {
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 					'provider' => 'openstreetmap',
516 516
 					'style'    => 'mapnik',
517 517
 				];
518
-				self::$map_providers  = [
518
+				self::$map_providers = [
519 519
 					'openstreetmap' => [
520 520
 						'name'   => 'OpenStreetMap',
521 521
 						'styles' => ['mapnik' => 'Mapnik'],
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		$maxgenerations = $tree->getPreference('MAX_PEDIGREE_GENERATIONS');
569 569
 		$generations    = $request->get('generations', $tree->getPreference('DEFAULT_PEDIGREE_GENERATIONS'));
570 570
 
571
-		return (object)[
571
+		return (object) [
572 572
 			'name' => 'modules/openstreetmap/pedigreemap',
573 573
 			'data' => [
574 574
 				'assets'         => $this->assets(),
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 	 * @return object
632 632
 	 */
633 633
 	public function getAdminConfigAction(Request $request) {
634
-		return (object)[
634
+		return (object) [
635 635
 			'name' => 'modules/openstreetmap/admin-config',
636 636
 			'data' => [
637 637
 				'title'        => I18N::translate('Open Street Maps (Configuration)'),
@@ -687,8 +687,8 @@  discard block
 block discarded – undo
687 687
 	 * @throws \Exception
688 688
 	 */
689 689
 	public function getAdminPlacesAction(Request $request) {
690
-		$parent_id   = (int)$request->get('parent_id', 0);
691
-		$inactive    = (bool)$request->get('inactive');
690
+		$parent_id   = (int) $request->get('parent_id', 0);
691
+		$inactive    = (bool) $request->get('inactive');
692 692
 		$hierarchy   = $this->gethierarchy($parent_id);
693 693
 		$title       = I18N::translate('Open Street Maps (Geographic data)');
694 694
 		$breadcrumbs = [
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 		$breadcrumbs[] = array_pop($breadcrumbs);
713 713
 
714
-		return (object)[
714
+		return (object) [
715 715
 			'name' => 'modules/openstreetmap/admin-places',
716 716
 			'data' => [
717 717
 				'title'       => $title,
@@ -732,9 +732,9 @@  discard block
 block discarded – undo
732 732
 	 * @throws \Exception
733 733
 	 */
734 734
 	public function getAdminPlaceEditAction(Request $request) {
735
-		$parent_id = (int)$request->get('parent_id', 0);
736
-		$place_id  = (int)$request->get('place_id');
737
-		$inactive  = (int)$request->get('inactive');
735
+		$parent_id = (int) $request->get('parent_id', 0);
736
+		$place_id  = (int) $request->get('place_id');
737
+		$inactive  = (int) $request->get('inactive');
738 738
 		$hierarchy = $this->gethierarchy($place_id);
739 739
 		$fqpn      = empty($hierarchy) ? '' : $hierarchy[0]->fqpn;
740 740
 		$location  = new Location($fqpn);
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 		}
771 771
 		$breadcrumbs[] = $place_id === 0 ? I18N::translate('Add') : I18N::translate('Edit');
772 772
 
773
-		return (object)[
773
+		return (object) [
774 774
 			'name' => 'modules/openstreetmap/admin-place-edit',
775 775
 			'data' => [
776 776
 				'module'      => $this->getName(),
@@ -796,9 +796,9 @@  discard block
 block discarded – undo
796 796
 	 */
797 797
 	public function postAdminSaveAction(Request $request): RedirectResponse {
798 798
 		if (Filter::checkCsrf()) {
799
-			$parent_id = (int)$request->get('parent_id');
800
-			$place_id  = (int)$request->get('place_id');
801
-			$inactive  = (int)$request->get('inactive');
799
+			$parent_id = (int) $request->get('parent_id');
800
+			$place_id  = (int) $request->get('place_id');
801
+			$inactive  = (int) $request->get('inactive');
802 802
 			$lat       = round($request->get('new_place_lati'), 5); // 5 decimal places (locate to within about 1 metre)
803 803
 			$lat       = ($lat < 0 ? 'S' : 'N') . abs($lat);
804 804
 			$lng       = round($request->get('new_place_long'), 5);
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 						  VALUES (:id, :parent, :level, :place, :lng, :lat, :zoom, :icon)"
818 818
 				)->execute(
819 819
 					[
820
-						'id'     => (int)Database::prepare("SELECT MAX(pl_id)+1 FROM `##placelocation`")->fetchOne(),
820
+						'id'     => (int) Database::prepare("SELECT MAX(pl_id)+1 FROM `##placelocation`")->fetchOne(),
821 821
 						'parent' => $parent_id,
822 822
 						'level'  => $level,
823 823
 						'place'  => $request->get('new_place_name'),
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 						'place' => $request->get('new_place_name'),
837 837
 						'lat'   => $request->get('lati_control') . $lat,
838 838
 						'lng'   => $request->get('long_control') . $lng,
839
-						'zoom'  => (int)$request->get('new_zoom_factor'),
839
+						'zoom'  => (int) $request->get('new_zoom_factor'),
840 840
 						'icon'  => $icon,
841 841
 					]
842 842
 				);
@@ -869,9 +869,9 @@  discard block
 block discarded – undo
869 869
 	 */
870 870
 	public function postAdminDeleteRecordAction(Request $request): RedirectResponse {
871 871
 		if (Filter::checkCsrf()) {
872
-			$place_id  = (int)$request->get('place_id');
873
-			$parent_id = (int)$request->get('parent_id');
874
-			$inactive  = (int)$request->get('inactive');
872
+			$place_id  = (int) $request->get('place_id');
873
+			$parent_id = (int) $request->get('parent_id');
874
+			$inactive  = (int) $request->get('inactive');
875 875
 
876 876
 			try {
877 877
 				Database::prepare(
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 				);
891 891
 			}
892 892
 			// If after deleting there are no more places at this level then go up a level
893
-			$children = (int)Database::prepare(
893
+			$children = (int) Database::prepare(
894 894
 				"SELECT COUNT(pl_id) FROM `##placelocation` WHERE pl_parent_id = :parent_id"
895 895
 			)
896 896
 				->execute(['parent_id' => $parent_id])
@@ -923,9 +923,9 @@  discard block
 block discarded – undo
923 923
 	 * @throws \Exception
924 924
 	 */
925 925
 	public function getAdminExportAction(Request $request): RedirectResponse {
926
-		$parent_id = (int)$request->get('parent_id');
926
+		$parent_id = (int) $request->get('parent_id');
927 927
 		$format    = $request->get('format', 'csv');
928
-		$maxlevel  = (int)Database::prepare("SELECT max(pl_level) FROM `##placelocation`")->execute()->fetchOne();
928
+		$maxlevel  = (int) Database::prepare("SELECT max(pl_level) FROM `##placelocation`")->execute()->fetchOne();
929 929
 		$startfqpn = [];
930 930
 		$hierarchy = $this->gethierarchy($parent_id);
931 931
 		$geojson   = [];
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
 							)
978 978
 						)
979 979
 					);
980
-					$long = (float)strtr($place['pl_long'], ['E' => '', 'W' => '-', ',' => '.']);
981
-					$lati = (float)strtr($place['pl_lati'], ['N' => '', 'S' => '-', ',' => '.']);
980
+					$long = (float) strtr($place['pl_long'], ['E' => '', 'W' => '-', ',' => '.']);
981
+					$lati = (float) strtr($place['pl_lati'], ['N' => '', 'S' => '-', ',' => '.']);
982 982
 
983 983
 					$geojson['features'][] = [
984 984
 						'type'       => 'Feature',
@@ -1014,8 +1014,8 @@  discard block
 block discarded – undo
1014 1014
 	 * @return object
1015 1015
 	 */
1016 1016
 	public function getAdminImportFormAction(Request $request) {
1017
-		$parent_id   = (int)$request->get('parent_id');
1018
-		$inactive    = (int)$request->get('inactive');
1017
+		$parent_id   = (int) $request->get('parent_id');
1018
+		$inactive    = (int) $request->get('inactive');
1019 1019
 		$breadcrumbs = [
1020 1020
 			route('admin-control-panel') => I18N::translate('Control panel'),
1021 1021
 			route('admin-modules')       => I18N::translate('Module administration'),
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
 			)                            => $this->getTitle() . ' (' . I18N::translate('Geographic data') . ')',
1031 1031
 			I18N::translate('Import file'),
1032 1032
 		];
1033
-		$files       = $this->findFiles(WT_MODULES_DIR . $this->getName() . '/extra', ['csv', 'geojson', 'json']);
1033
+		$files = $this->findFiles(WT_MODULES_DIR . $this->getName() . '/extra', ['csv', 'geojson', 'json']);
1034 1034
 		uasort(
1035 1035
 			$files,
1036 1036
 			function ($a, $b) {
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 			}
1042 1042
 		);
1043 1043
 
1044
-		return (object)[
1044
+		return (object) [
1045 1045
 			'name' => 'modules/openstreetmap/admin-import-form',
1046 1046
 			'data' => [
1047 1047
 				'title'       => I18N::translate('Import geographic data'),
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
 					$row    = explode($delimiter, $input_array[0]);
1106 1106
 					$fields = count($row);
1107 1107
 					if ($fields >= 6 &&
1108
-					    (bool)preg_match("/[SN][0-9]*\.?[0-9]*/", $row[$fields - 3]) &&
1109
-					    (bool)preg_match("/[EW][0-9]*\.?[0-9]*/", $row[$fields - 4])) {
1108
+					    (bool) preg_match("/[SN][0-9]*\.?[0-9]*/", $row[$fields - 3]) &&
1109
+					    (bool) preg_match("/[EW][0-9]*\.?[0-9]*/", $row[$fields - 4])) {
1110 1110
 						$filetype = 'csv';
1111 1111
 					}
1112 1112
 				}
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 							}
1147 1147
 						);
1148 1148
 						// convert separate place fields into a comma separated placename
1149
-						$row[]    = implode(
1149
+						$row[] = implode(
1150 1150
 							Place::GEDCOM_SEPARATOR,
1151 1151
 							array_filter(
1152 1152
 								array_reverse(
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 			}
1163 1163
 
1164 1164
 			if ($filetype !== '?') {
1165
-				if ((bool)$request->get('cleardatabase')) {
1165
+				if ((bool) $request->get('cleardatabase')) {
1166 1166
 					Database::exec("TRUNCATE TABLE `##placelocation`");
1167 1167
 				}
1168 1168
 				//process places
@@ -1173,10 +1173,10 @@  discard block
 block discarded – undo
1173 1173
 				usort(
1174 1174
 					$places,
1175 1175
 					function (array $a, array $b) {
1176
-						if ((int)$a['pl_level'] === (int)$b['pl_level']) {
1176
+						if ((int) $a['pl_level'] === (int) $b['pl_level']) {
1177 1177
 							return I18N::strcasecmp($a['fqpn'], $b['fqpn']);
1178 1178
 						} else {
1179
-							return (int)$a['pl_level'] - (int)$b['pl_level'];
1179
+							return (int) $a['pl_level'] - (int) $b['pl_level'];
1180 1180
 						}
1181 1181
 					}
1182 1182
 				);
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 						)) {
1197 1197
 
1198 1198
 						// overwrite
1199
-						$location->update((object)$place);
1199
+						$location->update((object) $place);
1200 1200
 						$updated++;
1201 1201
 					} elseif (!$valid && $options !== 'update') {
1202 1202
 						//add
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 	 */
1267 1267
 	public function postAdminImportPlacesAction(Request $request): RedirectResponse {
1268 1268
 		$gedcomName = $request->get('ged');
1269
-		$inactive   = (int)$request->get('inactive');
1269
+		$inactive   = (int) $request->get('inactive');
1270 1270
 		$tree       = Tree::findByName($gedcomName);
1271 1271
 
1272 1272
 		// Get all the places from the places table ...
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
 				"INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place)" .
1323 1323
 				" VALUES (:id, :parent, :level, :place)"
1324 1324
 			);
1325
-			$checkRecordQry  = Database::prepare(
1325
+			$checkRecordQry = Database::prepare(
1326 1326
 				"SELECT pl1.pl_id" .
1327 1327
 				" FROM	  `##placelocation` AS pl1" .
1328 1328
 				" LEFT JOIN `##placelocation` AS pl2 ON (pl1.pl_parent_id = pl2.pl_id)" .
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 		$list = [];
1486 1486
 		/** @var array $rows */
1487 1487
 		foreach ($rows as $row) {
1488
-			if ((bool)$row['inactive'] && !$show_inactive) {
1488
+			if ((bool) $row['inactive'] && !$show_inactive) {
1489 1489
 				continue;
1490 1490
 			}
1491 1491
 
@@ -1496,20 +1496,20 @@  discard block
 block discarded – undo
1496 1496
 				]
1497 1497
 			)->fetchOneRow();
1498 1498
 
1499
-			if ((bool)$row['inactive']) {
1499
+			if ((bool) $row['inactive']) {
1500 1500
 				$badge = 'danger';
1501
-			} elseif ((int)$children->no_coord > 0) {
1501
+			} elseif ((int) $children->no_coord > 0) {
1502 1502
 				$badge = 'warning';
1503
-			} elseif ((int)$children->child_count > 0) {
1503
+			} elseif ((int) $children->child_count > 0) {
1504 1504
 				$badge = 'info';
1505 1505
 			} else {
1506 1506
 				$badge = 'secondary';
1507 1507
 			}
1508 1508
 
1509
-			$list[] = (object)array_merge(
1509
+			$list[] = (object) array_merge(
1510 1510
 				$row,
1511 1511
 				[
1512
-					'child_count' => (int)$children->child_count,
1512
+					'child_count' => (int) $children->child_count,
1513 1513
 					'badge'       => $badge,
1514 1514
 				]
1515 1515
 			);
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
 			$row       = $statement->execute(['id' => $id])->fetchOneRow();
1532 1532
 			$fqpn[]    = $row->pl_place;
1533 1533
 			$row->fqpn = implode(Place::GEDCOM_SEPARATOR, $fqpn);
1534
-			$id        = (int)$row->pl_parent_id;
1534
+			$id        = (int) $row->pl_parent_id;
1535 1535
 			$arr[]     = $row;
1536 1536
 		}
1537 1537
 
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
 	 */
1547 1547
 	private function buildLevel($parent_id, $placename, &$places) {
1548 1548
 		$level = array_search('', $placename);
1549
-		$rows  = (array)Database::prepare(
1549
+		$rows  = (array) Database::prepare(
1550 1550
 			"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"
1551 1551
 		)
1552 1552
 			->execute([$parent_id])
Please login to merge, or discard this patch.