Completed
Push — openstreetmap ( e9f60f...b0b563 )
by Greg
14:54 queued 06:15
created
app/Module/OpenStreetMapModule.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function getBaseDataAction(Request $request) {
212 212
 		$provider = $this->getMapProviderData($request);
213
-		$style    = $provider['selectedStyleName']    = '' ? '' : '.' . $provider['selectedStyleName'];
213
+		$style    = $provider['selectedStyleName'] = '' ? '' : '.' . $provider['selectedStyleName'];
214 214
 
215 215
 		switch ($provider['selectedProvIndex']) {
216 216
 			case 'mapbox':
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 						$color            = self::LINE_COLORS[log($id, 2) % $color_count];
298 298
 						$icon['color']    = $color; //make icon color the same as the line
299 299
 						$sosa_points[$id] = $event->getLatLonJSArray();
300
-						$sosa_parent      = (int)floor($id / 2);
300
+						$sosa_parent      = (int) floor($id / 2);
301 301
 						if (array_key_exists($sosa_parent, $sosa_points)) {
302 302
 							// Would like to use a GeometryCollection to hold LineStrings
303 303
 							// rather than generate polylines but the MarkerCluster library
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 								'modules/openstreetmap/event-sidebar',
330 330
 								$event->shortSummary($mapType, $id)
331 331
 							),
332
-							'zoom' => (int)$event->getZoom(),
332
+							'zoom' => (int) $event->getZoom(),
333 333
 						],
334 334
 					];
335 335
 				}
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 							'stats'    => $placeStats,
400 400
 						]
401 401
 					),
402
-					'zoom' => (int)($location->getZoom() ?? 2),
402
+					'zoom' => (int) ($location->getZoom() ?? 2),
403 403
 				],
404 404
 			];
405 405
 		}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		$xref        = $request->get('reference');
452 452
 		$tree        = $request->attributes->get('tree');
453 453
 		$individual  = Individual::getInstance($xref, $tree);
454
-		$generations = (int)$request->get(
454
+		$generations = (int) $request->get(
455 455
 			'generations',
456 456
 			$tree->getPreference('DEFAULT_PEDIGREE_GENERATIONS')
457 457
 		);
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
 						function ($item) {
501 501
 							return preg_replace('/[^a-z\d]/i', '', strtolower($item));
502 502
 						},
503
-						(array)$provider->styles
503
+						(array) $provider->styles
504 504
 					);
505 505
 
506
-					$key = preg_replace('/[^a-z\d]/i', '', strtolower((string)$provider->name));
506
+					$key = preg_replace('/[^a-z\d]/i', '', strtolower((string) $provider->name));
507 507
 
508 508
 					self::$map_providers[$key] = [
509
-						'name'   => (string)$provider->name,
510
-						'styles' => array_combine($style_keys, (array)$provider->styles),
509
+						'name'   => (string) $provider->name,
510
+						'styles' => array_combine($style_keys, (array) $provider->styles),
511 511
 					];
512 512
 				}
513 513
 			} catch (\Exception $ex) {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		$maxgenerations = $tree->getPreference('MAX_PEDIGREE_GENERATIONS');
570 570
 		$generations    = $request->get('generations', $tree->getPreference('DEFAULT_PEDIGREE_GENERATIONS'));
571 571
 
572
-		return (object)[
572
+		return (object) [
573 573
 			'name' => 'modules/openstreetmap/pedigreemap',
574 574
 			'data' => [
575 575
 				'assets' => $this->assets(),
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	 * @return object
633 633
 	 */
634 634
 	public function getAdminConfigAction(Request $request) {
635
-		return (object)[
635
+		return (object) [
636 636
 			'name' => 'modules/openstreetmap/admin-config',
637 637
 			'data' => [
638 638
 				'title'        => I18N::translate('Open Street Maps (Configuration)'),
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 	 * @throws \Exception
689 689
 	 */
690 690
 	public function getAdminPlacesAction(Request $request) {
691
-		$parent_id   = (int)$request->get('parent_id', 0);
692
-		$inactive    = (bool)$request->get('inactive');
691
+		$parent_id   = (int) $request->get('parent_id', 0);
692
+		$inactive    = (bool) $request->get('inactive');
693 693
 		$hierarchy   = $this->gethierarchy($parent_id);
694 694
 		$title       = I18N::translate('Open Street Maps (Geographic data)');
695 695
 		$breadcrumbs = [
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 		}
713 713
 		$breadcrumbs[] = array_pop($breadcrumbs);
714 714
 
715
-		return (object)[
715
+		return (object) [
716 716
 			'name' => 'modules/openstreetmap/admin-places',
717 717
 			'data' => [
718 718
 				'title'       => $title,
@@ -733,9 +733,9 @@  discard block
 block discarded – undo
733 733
 	 * @throws \Exception
734 734
 	 */
735 735
 	public function getAdminPlaceEditAction(Request $request) {
736
-		$parent_id = (int)$request->get('parent_id', 0);
737
-		$place_id  = (int)$request->get('place_id');
738
-		$inactive  = (int)$request->get('inactive');
736
+		$parent_id = (int) $request->get('parent_id', 0);
737
+		$place_id  = (int) $request->get('place_id');
738
+		$inactive  = (int) $request->get('inactive');
739 739
 		$hierarchy = $this->gethierarchy($place_id);
740 740
 		$fqpn      = empty($hierarchy) ? '' : $hierarchy[0]->fqpn;
741 741
 		$location  = new Location($fqpn);
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		}
772 772
 		$breadcrumbs[] = $place_id === 0 ? I18N::translate('Add') : I18N::translate('Edit');
773 773
 
774
-		return (object)[
774
+		return (object) [
775 775
 			'name' => 'modules/openstreetmap/admin-place-edit',
776 776
 			'data' => [
777 777
 				'module'      => $this->getName(),
@@ -797,9 +797,9 @@  discard block
 block discarded – undo
797 797
 	 */
798 798
 	public function postAdminSaveAction(Request $request) {
799 799
 		if (Filter::checkCsrf()) {
800
-			$parent_id = (int)$request->get('parent_id');
801
-			$place_id  = (int)$request->get('place_id');
802
-			$inactive  = (int)$request->get('inactive');
800
+			$parent_id = (int) $request->get('parent_id');
801
+			$place_id  = (int) $request->get('place_id');
802
+			$inactive  = (int) $request->get('inactive');
803 803
 			$lat       = round($request->get('new_place_lati'), 5); // 5 decimal places (locate to within about 1 metre)
804 804
 			$lat       = ($lat < 0 ? 'S' : 'N') . abs($lat);
805 805
 			$lng       = round($request->get('new_place_long'), 5);
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 						  VALUES (:id, :parent, :level, :place, :lng, :lat, :zoom, :icon)"
819 819
 				)->execute(
820 820
 					[
821
-					'id'     => (int)Database::prepare("SELECT MAX(pl_id)+1 FROM `##placelocation`")->fetchOne(),
821
+					'id'     => (int) Database::prepare("SELECT MAX(pl_id)+1 FROM `##placelocation`")->fetchOne(),
822 822
 					'parent' => $parent_id,
823 823
 					'level'  => $level,
824 824
 					'place'  => $request->get('new_place_name'),
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
 					'place' => $request->get('new_place_name'),
838 838
 					'lat'   => $request->get('lati_control') . $lat,
839 839
 					'lng'   => $request->get('long_control') . $lng,
840
-					'zoom'  => (int)$request->get('new_zoom_factor'),
840
+					'zoom'  => (int) $request->get('new_zoom_factor'),
841 841
 					'icon'  => $icon,
842 842
 				]
843 843
 				);
@@ -870,9 +870,9 @@  discard block
 block discarded – undo
870 870
 	 */
871 871
 	public function postAdminDeleteRecordAction(Request $request): RedirectResponse {
872 872
 		if (Filter::checkCsrf()) {
873
-			$place_id  = (int)$request->get('place_id');
874
-			$parent_id = (int)$request->get('parent_id');
875
-			$inactive  = (int)$request->get('inactive');
873
+			$place_id  = (int) $request->get('place_id');
874
+			$parent_id = (int) $request->get('parent_id');
875
+			$inactive  = (int) $request->get('inactive');
876 876
 
877 877
 			try {
878 878
 				Database::prepare(
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 				);
892 892
 			}
893 893
 			// If after deleting there are no more places at this level then go up a level
894
-			$children = (int)Database::prepare(
894
+			$children = (int) Database::prepare(
895 895
 				"SELECT COUNT(pl_id) FROM `##placelocation` WHERE pl_parent_id = :parent_id"
896 896
 			)
897 897
 				->execute(['parent_id' => $parent_id])
@@ -924,9 +924,9 @@  discard block
 block discarded – undo
924 924
 	 * @throws \Exception
925 925
 	 */
926 926
 	public function getAdminExportAction(Request $request) {
927
-		$parent_id = (int)$request->get('parent_id');
927
+		$parent_id = (int) $request->get('parent_id');
928 928
 		$format    = $request->get('format', 'csv');
929
-		$maxlevel  = (int)Database::prepare("SELECT max(pl_level) FROM `##placelocation`")->execute()->fetchOne();
929
+		$maxlevel  = (int) Database::prepare("SELECT max(pl_level) FROM `##placelocation`")->execute()->fetchOne();
930 930
 		$startfqpn = [];
931 931
 		$hierarchy = $this->gethierarchy($parent_id);
932 932
 		$geojson   = [];
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
 							)
979 979
 						)
980 980
 					);
981
-					$long = (float)strtr($place['pl_long'], ['E' => '', 'W' => '-', ',' => '.']);
982
-					$lati = (float)strtr($place['pl_lati'], ['N' => '', 'S' => '-', ',' => '.']);
981
+					$long = (float) strtr($place['pl_long'], ['E' => '', 'W' => '-', ',' => '.']);
982
+					$lati = (float) strtr($place['pl_lati'], ['N' => '', 'S' => '-', ',' => '.']);
983 983
 
984 984
 					$geojson['features'][] = [
985 985
 						'type'     => 'Feature',
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
 	 * @return object
1017 1017
 	 */
1018 1018
 	public function getAdminImportFormAction(Request $request) {
1019
-		$parent_id   = (int)$request->get('parent_id');
1020
-		$inactive    = (int)$request->get('inactive');
1019
+		$parent_id   = (int) $request->get('parent_id');
1020
+		$inactive    = (int) $request->get('inactive');
1021 1021
 		$breadcrumbs = [
1022 1022
 			route('admin-control-panel') => I18N::translate('Control panel'),
1023 1023
 			route('admin-modules')       => I18N::translate('Module administration'),
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 			}
1044 1044
 		);
1045 1045
 
1046
-		return (object)[
1046
+		return (object) [
1047 1047
 			'name' => 'modules/openstreetmap/admin-import-form',
1048 1048
 			'data' => [
1049 1049
 				'title'       => I18N::translate('Import geographic data'),
@@ -1107,8 +1107,8 @@  discard block
 block discarded – undo
1107 1107
 					$row    = explode($delimiter, $input_array[0]);
1108 1108
 					$fields = count($row);
1109 1109
 					if ($fields >= 6 &&
1110
-						(bool)preg_match("/[SN][0-9]*\.?[0-9]*/", $row[$fields - 3]) &&
1111
-						(bool)preg_match("/[EW][0-9]*\.?[0-9]*/", $row[$fields - 4])) {
1110
+						(bool) preg_match("/[SN][0-9]*\.?[0-9]*/", $row[$fields - 3]) &&
1111
+						(bool) preg_match("/[EW][0-9]*\.?[0-9]*/", $row[$fields - 4])) {
1112 1112
 						$filetype = 'csv';
1113 1113
 					}
1114 1114
 				}
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 			}
1165 1165
 
1166 1166
 			if ($filetype !== '?') {
1167
-				if ((bool)$request->get('cleardatabase')) {
1167
+				if ((bool) $request->get('cleardatabase')) {
1168 1168
 					Database::exec("TRUNCATE TABLE `##placelocation`");
1169 1169
 				}
1170 1170
 				//process places
@@ -1175,10 +1175,10 @@  discard block
 block discarded – undo
1175 1175
 				usort(
1176 1176
 					$places,
1177 1177
 					function (array $a, array $b) {
1178
-						if ((int)$a['pl_level'] === (int)$b['pl_level']) {
1178
+						if ((int) $a['pl_level'] === (int) $b['pl_level']) {
1179 1179
 							return I18N::strcasecmp($a['fqpn'], $b['fqpn']);
1180 1180
 						} else {
1181
-							return (int)$a['pl_level'] - (int)$b['pl_level'];
1181
+							return (int) $a['pl_level'] - (int) $b['pl_level'];
1182 1182
 						}
1183 1183
 					}
1184 1184
 				);
@@ -1198,7 +1198,7 @@  discard block
 block discarded – undo
1198 1198
 						)) {
1199 1199
 
1200 1200
 						// overwrite
1201
-						$location->update((object)$place);
1201
+						$location->update((object) $place);
1202 1202
 						$updated++;
1203 1203
 					} elseif (!$valid && $options !== 'update') {
1204 1204
 						//add
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 	 */
1269 1269
 	public function postAdminImportPlacesAction(Request $request) {
1270 1270
 		$gedcomName = $request->get('ged');
1271
-		$inactive   = (int)$request->get('inactive');
1271
+		$inactive   = (int) $request->get('inactive');
1272 1272
 		$tree       = Tree::findByName($gedcomName);
1273 1273
 
1274 1274
 		// Get all the places from the places table ...
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
 		$list = [];
1488 1488
 		/** @var array $rows */
1489 1489
 		foreach ($rows as $row) {
1490
-			if ((bool)$row['inactive'] && !$show_inactive) {
1490
+			if ((bool) $row['inactive'] && !$show_inactive) {
1491 1491
 				continue;
1492 1492
 			}
1493 1493
 
@@ -1498,20 +1498,20 @@  discard block
 block discarded – undo
1498 1498
 				]
1499 1499
 			)->fetchOneRow();
1500 1500
 
1501
-			if ((bool)$row['inactive']) {
1501
+			if ((bool) $row['inactive']) {
1502 1502
 				$badge = 'danger';
1503
-			} elseif ((int)$children->no_coord > 0) {
1503
+			} elseif ((int) $children->no_coord > 0) {
1504 1504
 				$badge = 'warning';
1505
-			} elseif ((int)$children->child_count > 0) {
1505
+			} elseif ((int) $children->child_count > 0) {
1506 1506
 				$badge = 'info';
1507 1507
 			} else {
1508 1508
 				$badge = 'secondary';
1509 1509
 			}
1510 1510
 
1511
-			$list[] = (object)array_merge(
1511
+			$list[] = (object) array_merge(
1512 1512
 				$row,
1513 1513
 				[
1514
-					'child_count' => (int)$children->child_count,
1514
+					'child_count' => (int) $children->child_count,
1515 1515
 					'badge'       => $badge,
1516 1516
 				]
1517 1517
 			);
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
 			$row       = $statement->execute(['id' => $id])->fetchOneRow();
1534 1534
 			$fqpn[]    = $row->pl_place;
1535 1535
 			$row->fqpn = implode(Place::GEDCOM_SEPARATOR, $fqpn);
1536
-			$id        = (int)$row->pl_parent_id;
1536
+			$id        = (int) $row->pl_parent_id;
1537 1537
 			$arr[]     = $row;
1538 1538
 		}
1539 1539
 
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 	 */
1549 1549
 	private function buildLevel($parent_id, $placename, &$places) {
1550 1550
 		$level = array_search('', $placename);
1551
-		$rows  = (array)Database::prepare(
1551
+		$rows  = (array) Database::prepare(
1552 1552
 			"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"
1553 1553
 		)
1554 1554
 			->execute([$parent_id])
Please login to merge, or discard this patch.