Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,23 +11,30 @@
|
||||
namespace IPS\Geolocation\Api\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use UnderflowException;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
use function strtoupper;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Base class for GeoLocation
|
||||
*/
|
||||
class _GeoLocationType extends ObjectType
|
||||
class GeoLocationType extends ObjectType
|
||||
{
|
||||
/**
|
||||
* Get root type
|
||||
*
|
||||
* @return array
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -106,20 +113,20 @@ class _GeoLocationType extends ObjectType
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
protected static function buildAddressPiece($geolocation, $type)
|
||||
protected static function buildAddressPiece($geolocation, $type): string
|
||||
{
|
||||
$output = array();
|
||||
if ( $geolocation->$type )
|
||||
{
|
||||
if ( $type == 'country' )
|
||||
{
|
||||
if( $geolocation->country !== \IPS\GeoLocation::buildFromJson( \IPS\Settings::i()->site_address )->country )
|
||||
if( $geolocation->country !== GeoLocation::buildFromJson( Settings::i()->site_address )->country )
|
||||
{
|
||||
try
|
||||
{
|
||||
$output[] = \IPS\Member::loggedIn()->language()->get( htmlspecialchars( 'country-' . $geolocation->country, ENT_DISALLOWED, 'UTF-8', FALSE ), FALSE, array( 'strtoupper' => TRUE ) );
|
||||
$output[] = strtoupper( Member::loggedIn()->language()->get( htmlspecialchars( 'country-' . $geolocation->country, ENT_DISALLOWED, 'UTF-8', FALSE ) ) );
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException $e )
|
||||
{
|
||||
$output[] = htmlspecialchars( $geolocation->country, ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
}
|
||||
@@ -127,7 +134,7 @@ class _GeoLocationType extends ObjectType
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( \is_array( $geolocation->$type ) )
|
||||
if ( is_array( $geolocation->$type ) )
|
||||
{
|
||||
foreach ( $geolocation->$type as $v )
|
||||
{
|
||||
|
||||
@@ -10,21 +10,21 @@
|
||||
*/
|
||||
|
||||
namespace IPS\GeoLocation\Api\GraphQL;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use function defined;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* \IPS\GeoLocation base types
|
||||
*/
|
||||
class _TypeRegistry
|
||||
class TypeRegistry
|
||||
{
|
||||
protected static $geolocation;
|
||||
protected static ?GeoLocationType $geolocation;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -37,8 +37,8 @@ class _TypeRegistry
|
||||
/**
|
||||
* @return GeoLocationType
|
||||
*/
|
||||
public static function geolocation()
|
||||
public static function geolocation() : GeoLocationType
|
||||
{
|
||||
return self::$geolocation ?: (self::$geolocation = new \IPS\GeoLocation\Api\GraphQL\GeoLocationType());
|
||||
return self::$geolocation ?: (self::$geolocation = new GeoLocationType());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user