Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+38 -18
View File
@@ -11,29 +11,37 @@
namespace IPS\GeoLocation\Maps;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\GeoLocation;
use IPS\Http\Url;
use IPS\Member;
use IPS\Settings;
use IPS\Theme;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* Mapbox Maps
*/
class _Mapbox
class Mapbox
{
/**
* @brief GeoLocation
*/
public $geoLocation;
public ?GeoLocation $geolocation = NULL;
/**
* Constructor
*
* @param \IPS\GeoLocation $geoLocation Location
* @param GeoLocation $geoLocation Location
* @return void
*/
public function __construct( \IPS\GeoLocation $geoLocation )
public function __construct( GeoLocation $geoLocation )
{
$this->geolocation = $geoLocation;
}
@@ -41,30 +49,41 @@ class _Mapbox
/**
* Render
*
* @param int $width Width
* @param int $height Height
* @param float|NULL $zoom The zoom amount (a value between 0 being totally zoomed out view of the world, and 1 being as fully zoomed in as possible) or NULL to zoom automatically based on how much data is available
* @param int $width Width
* @param int $height Height
* @param float|null $zoom The zoom amount (a value between 0 being totally zoomed out view of the world, and 1 being as fully zoomed in as possible) or NULL to zoom automatically based on how much data is available
* @return string
*/
public function render( $width, $height, $zoom=NULL )
public function render( int $width, int $height, float $zoom=NULL ): string
{
if( !($this->geolocation->long and $this->geolocation->lat ) )
{
return "";
}
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->staticMap( NULL, $this->mapUrl( $width, $height, $zoom ), $this->geolocation->lat, $this->geolocation->long, $width, $height );
/* Check group permissions */
if( Settings::i()->mapbox_groups != '*' and !Member::loggedIn()->inGroup( explode( ",", Settings::i()->mapbox_groups ) ) )
{
return '';
}
if( empty( $zoom ) )
{
$zoom = Settings::i()->mapbox_zoom ?: null;
}
return Theme::i()->getTemplate( 'global', 'core', 'global' )->staticMap( NULL, $this->mapUrl( $width, $height, $zoom ), $this->geolocation->lat, $this->geolocation->long, $width, $height );
}
/**
* Return the map image URL
*
* @param int $width Width
* @param int $height Height
* @param float|NULL $zoom The zoom amount (a value between 0 being totally zoomed out view of the world, and 1 being as fully zoomed in as possible) or NULL to zoom automatically based on how much data is available
* @return \IPS\Http\Url|NULL
* @param int $width Width
* @param int $height Height
* @param float|null $zoom The zoom amount (a value between 0 being totally zoomed out view of the world, and 1 being as fully zoomed in as possible) or NULL to zoom automatically based on how much data is available
* @return Url|NULL
*/
public function mapUrl( $width, $height, $zoom=NULL )
public function mapUrl( int $width, int $height, float $zoom=NULL ): ?Url
{
if( !($this->geolocation->long and $this->geolocation->lat ) )
{
@@ -73,8 +92,9 @@ class _Mapbox
$location = str_replace( ',', '.', $this->geolocation->long ) . ',' . str_replace( ',', '.', $this->geolocation->lat );
return \IPS\Http\Url::external( "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/pin-l-marker+f00({$location})/{$location},14,0,60/{$width}x{$height}@2x" )->setQueryString( array(
'access_token' => \IPS\Settings::i()->mapbox_api_key,
return Url::external( "https://api.mapbox.com/styles/v1/mapbox/streets-v10/static/pin-l-marker+f00({$location})/{$location},14,0,60/{$width}x{$height}@2x" )->setQueryString( array(
'access_token' => Settings::i()->mapbox_api_key,
'zoom' => $zoom
) );
}
}