Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: Image query
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 23 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Queries;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Image query for GraphQL API
|
||||
*/
|
||||
class _Image
|
||||
{
|
||||
/*
|
||||
* @brief Query description
|
||||
*/
|
||||
public static $description = "Returns a gallery image";
|
||||
|
||||
/*
|
||||
* Query arguments
|
||||
*/
|
||||
public function args()
|
||||
{
|
||||
return array(
|
||||
'id' => TypeRegistry::nonNull( TypeRegistry::id() )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the query return type
|
||||
*/
|
||||
public function type()
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves this query
|
||||
*
|
||||
* @param mixed Value passed into this resolver
|
||||
* @param array Arguments
|
||||
* @param array Context values
|
||||
* @return \IPS\gallery\Image
|
||||
*/
|
||||
public function resolve($val, $args, $context, $info)
|
||||
{
|
||||
try
|
||||
{
|
||||
$topic = \IPS\gallery\Image::loadAndCheckPerms( $args['id'] );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
throw new \IPS\Api\GraphQL\SafeException( 'NO_IMAGE', '1F294/2', 400 );
|
||||
}
|
||||
|
||||
if( !$topic->can('read') )
|
||||
{
|
||||
throw new \IPS\Api\GraphQL\SafeException( 'INVALID_ID', '2F294/9', 403 );
|
||||
}
|
||||
|
||||
return $topic;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: Gallery queries
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 23 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\Types;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forums queries for GraphQL API
|
||||
*/
|
||||
abstract class _Query
|
||||
{
|
||||
/**
|
||||
* Get the supported query types in this app
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function queries()
|
||||
{
|
||||
return [
|
||||
'image' => new \IPS\gallery\api\GraphQL\Queries\Image(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: Types registry
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 23 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\Types;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gallery type registry. GraphQL requires exactly one instance of each type,
|
||||
* so we'll generate singletons here.
|
||||
* @todo automate this somehow?
|
||||
*/
|
||||
class _TypeRegistry
|
||||
{
|
||||
protected static $album;
|
||||
protected static $albumComment;
|
||||
protected static $albumItem;
|
||||
protected static $image;
|
||||
protected static $imageComment;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// Defined to suppress static warnings
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImageType
|
||||
*/
|
||||
public static function album()
|
||||
{
|
||||
return self::$album ?: (self::$album = new \IPS\gallery\api\GraphQL\Types\AlbumType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlbumCommentType
|
||||
*/
|
||||
public static function albumComment()
|
||||
{
|
||||
return self::$albumComment ?: (self::$albumComment = new \IPS\gallery\api\GraphQL\Types\AlbumCommentType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AlbumCommentType
|
||||
*/
|
||||
public static function albumItem()
|
||||
{
|
||||
return self::$albumItem ?: (self::$albumItem = new \IPS\gallery\api\GraphQL\Types\AlbumItemType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImageType
|
||||
*/
|
||||
public static function image()
|
||||
{
|
||||
return self::$image ?: (self::$image = new \IPS\gallery\api\GraphQL\Types\ImageType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ImageCommentType
|
||||
*/
|
||||
public static function imageComment()
|
||||
{
|
||||
return self::$imageComment ?: (self::$imageComment = new \IPS\gallery\api\GraphQL\Types\ImageCommentType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: AlbumComment Type
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 23 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* AlbumCommentType for GraphQL API
|
||||
*/
|
||||
class _AlbumCommentType extends \IPS\Content\Api\GraphQL\CommentType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $commentClass = '\IPS\gallery\Album\Comment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_AlbumComment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An album comment';
|
||||
|
||||
/**
|
||||
* Get the item type that goes with this item type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
public static function getItemType()
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::album();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
$defaultFields = parent::fields();
|
||||
return $defaultFields;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: Album Item Type
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 24 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* AlbumItemType for GraphQL API
|
||||
*/
|
||||
class _AlbumItemType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $itemClass = '\IPS\gallery\Album\Item';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_AlbumItem';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An album';
|
||||
|
||||
/*
|
||||
* @brief Follow data passed in to FollowType resolver
|
||||
*/
|
||||
protected static $followData = array('app' => 'gallery', 'area' => 'album');
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
// Extend our fields with image-specific stuff
|
||||
$defaultFields = parent::fields();
|
||||
|
||||
// Remove duplicated fields
|
||||
unset( $defaultFields['views'] );
|
||||
unset( $defaultFields['poll'] );
|
||||
unset( $defaultFields['hasPoll'] );
|
||||
|
||||
return $defaultFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comment type that goes with this item type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
protected static function getCommentType()
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::albumComment();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: Album Type
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 24 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* AlbumType for GraphQL API
|
||||
*/
|
||||
class _AlbumType extends \IPS\Node\Api\GraphQL\NodeType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $nodeClass = '\IPS\gallery\Album';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_Album';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An album';
|
||||
|
||||
/*
|
||||
* @brief Follow data passed in to FollowType resolver
|
||||
*/
|
||||
protected static $followData = array('app' => 'gallery', 'area' => 'album');
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
$defaultFields = parent::fields();
|
||||
$albumFields = array(
|
||||
'owner' => [
|
||||
'type' => \IPS\core\api\GraphQL\TypeRegistry::member(),
|
||||
'resolve' => function ($album) {
|
||||
return $album->owner();
|
||||
}
|
||||
],
|
||||
'lastImage' => [
|
||||
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::image(),
|
||||
'resolve' => function ($album) {
|
||||
return $album->lastImage();
|
||||
}
|
||||
],
|
||||
'latestImages' => [
|
||||
'type' => TypeRegistry::listOf( \IPS\gallery\api\GraphQL\TypeRegistry::image() ),
|
||||
'resolve' => function ($album) {
|
||||
return $album->_latestImages;
|
||||
}
|
||||
],
|
||||
'item' => [
|
||||
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::albumItem(),
|
||||
'resolve' => function ($album) {
|
||||
return $album->asItem();
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
// Remove unnecessary fields
|
||||
unset( $defaultFields['children'] );
|
||||
|
||||
return array_merge( $defaultFields, $albumFields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the item type that goes with this node type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
public static function getItemType()
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: ImageComment Type
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 23 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageCommentType for GraphQL API
|
||||
*/
|
||||
class _ImageCommentType extends \IPS\Content\Api\GraphQL\CommentType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $commentClass = '\IPS\gallery\Image\Comment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_ImageComment';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An image comment';
|
||||
|
||||
/**
|
||||
* Get the item type that goes with this item type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
public static function getItemType()
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::image();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
$defaultFields = parent::fields();
|
||||
return $defaultFields;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief GraphQL: Image Type
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @since 23 Feb 2019
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\gallery\api\GraphQL\Types;
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use IPS\Api\GraphQL\TypeRegistry;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* ImageType for GraphQL API
|
||||
*/
|
||||
class _ImageType extends \IPS\Content\Api\GraphQL\ItemType
|
||||
{
|
||||
/*
|
||||
* @brief The item classname we use for this type
|
||||
*/
|
||||
protected static $itemClass = '\IPS\gallery\Image';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type name
|
||||
*/
|
||||
protected static $typeName = 'gallery_Image';
|
||||
|
||||
/*
|
||||
* @brief GraphQL type description
|
||||
*/
|
||||
protected static $typeDescription = 'An image';
|
||||
|
||||
/*
|
||||
* @brief Follow data passed in to FollowType resolver
|
||||
*/
|
||||
protected static $followData = array('app' => 'gallery', 'area' => 'image');
|
||||
|
||||
/**
|
||||
* Return the fields available in this type
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fields()
|
||||
{
|
||||
// Extend our fields with image-specific stuff
|
||||
$defaultFields = parent::fields();
|
||||
$imageFields = array(
|
||||
'caption' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return $image->caption;
|
||||
}
|
||||
],
|
||||
'hasAlbum' => [
|
||||
'type' => TypeRegistry::boolean(),
|
||||
'resolve' => function ($image) {
|
||||
return (bool) $image->album_id;
|
||||
}
|
||||
],
|
||||
'album' => [
|
||||
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::album(),
|
||||
'resolve' => function ($image) {
|
||||
if( $image->album_id )
|
||||
{
|
||||
return \IPS\gallery\Album::load( $image->album_id );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
],
|
||||
'nextImage' => [
|
||||
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::image(),
|
||||
'resolve' => function ($image) {
|
||||
return $image->nextItem();
|
||||
}
|
||||
],
|
||||
'prevImage' => [
|
||||
'type' => \IPS\gallery\api\GraphQL\TypeRegistry::image(),
|
||||
'resolve' => function ($image) {
|
||||
return $image->prevItem();
|
||||
}
|
||||
],
|
||||
'credit' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return $image->credit_info;
|
||||
}
|
||||
],
|
||||
'copyright' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return $image->copyright;
|
||||
}
|
||||
],
|
||||
'isMedia' => [
|
||||
'type' => TypeRegistry::boolean(),
|
||||
'resolve' => function ($image) {
|
||||
return (bool) $image->media;
|
||||
}
|
||||
],
|
||||
'maskedFileName' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return (string) \IPS\File::get( 'gallery_Images', $image->masked_file_name )->url;
|
||||
}
|
||||
],
|
||||
'originalFileName' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return (string) \IPS\File::get( 'gallery_Images', $image->original_file_name )->url;
|
||||
}
|
||||
],
|
||||
'smallFileName' => [
|
||||
'type' => TypeRegistry::string(),
|
||||
'resolve' => function ($image) {
|
||||
return (string) \IPS\File::get( 'gallery_Images', $image->small_file_name )->url;
|
||||
}
|
||||
],
|
||||
'fileSize' => [
|
||||
'type' => TypeRegistry::int(),
|
||||
'resolve' => function ($image) {
|
||||
return $image->file_size;
|
||||
}
|
||||
],
|
||||
'location' => [
|
||||
'type' => \IPS\GeoLocation\Api\GraphQL\TypeRegistry::geolocation(),
|
||||
'resolve' => function ($image) {
|
||||
if( $image->gps_raw )
|
||||
{
|
||||
return \IPS\GeoLocation::buildFromJson( $image->gps_raw );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
],
|
||||
'dims' => [
|
||||
'type' => new ObjectType([
|
||||
'name' => 'gallery_ImageSize',
|
||||
'fields' => [
|
||||
'width' => [
|
||||
'type' => TypeRegistry::int(),
|
||||
'resolve' => function ($size) {
|
||||
return $size[0];
|
||||
}
|
||||
],
|
||||
'height' => [
|
||||
'type' => TypeRegistry::int(),
|
||||
'resolve' => function ($size) {
|
||||
return $size[1];
|
||||
}
|
||||
]
|
||||
]
|
||||
]),
|
||||
'args' => [
|
||||
'size' => TypeRegistry::string()
|
||||
],
|
||||
'resolve' => function ($image, $args) {
|
||||
$imageSizes = json_decode( $image->data, true );
|
||||
|
||||
if( isset( $imageSizes[ $args['size'] ] ) ){
|
||||
return $imageSizes[ $args['size'] ];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
// Duplicate fields that have different names in topics
|
||||
/*$topicFields['forum'] = $defaultFields['container'];
|
||||
$topicFields['posts'] = $defaultFields['comments'];
|
||||
$topicFields['postCount'] = $defaultFields['commentCount'];
|
||||
$topicFields['lastPostAuthor'] = $defaultFields['lastCommentAuthor'];
|
||||
$topicFields['lastPostDate'] = $defaultFields['lastCommentDate'];*/
|
||||
|
||||
// Remove duplicated fields
|
||||
unset( $defaultFields['poll'] );
|
||||
unset( $defaultFields['hasPoll'] );
|
||||
|
||||
return array_merge( $defaultFields, $imageFields );
|
||||
}
|
||||
|
||||
/*public static function args()
|
||||
{
|
||||
return array_merge( parent::args(), array(
|
||||
'password' => [
|
||||
'type' => TypeRegistry::string()
|
||||
]
|
||||
));
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Get the comment type that goes with this item type
|
||||
*
|
||||
* @return ObjectType
|
||||
*/
|
||||
protected static function getCommentType()
|
||||
{
|
||||
return \IPS\gallery\api\GraphQL\TypeRegistry::imageComment();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user