Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
Showing only changes of commit d60b1dd776 - Show all commits

View File

@ -124,7 +124,7 @@ function _iterateToml(TomlBuilder $builder, iterable $data, mixed $parentKey = N
/** /**
* Serialize config data into a Toml file * Serialize config data into a Toml file
* *
* @param mixed $data * @param iterable $data
* @return string * @return string
*/ */
function arrayToToml(iterable $data): string function arrayToToml(iterable $data): string
@ -157,7 +157,7 @@ function tomlToArray(string $toml): array
* @param mixed $array * @param mixed $array
* @return bool * @return bool
*/ */
function isSequentialArray($array): bool function isSequentialArray(mixed $array): bool
{ {
if ( ! is_array($array)) if ( ! is_array($array))
{ {
@ -270,7 +270,7 @@ function getLocalImg (string $kitsuUrl, $webp = TRUE): string
$parts = parse_url($kitsuUrl); $parts = parse_url($kitsuUrl);
if ($parts === FALSE) if ($parts === FALSE || ! array_key_exists('path', $parts))
{ {
return 'images/placeholder.webp'; return 'images/placeholder.webp';
} }
@ -296,22 +296,35 @@ function getLocalImg (string $kitsuUrl, $webp = TRUE): string
* @param int|null $width * @param int|null $width
* @param int|null $height * @param int|null $height
* @param string $text * @param string $text
* @return bool
*/ */
function createPlaceholderImage (string $path, ?int $width, ?int $height, $text = 'Image Unavailable'): void function createPlaceholderImage (string $path, ?int $width, ?int $height, $text = 'Image Unavailable'): bool
{ {
$width = $width ?? 200; $width = $width ?? 200;
$height = $height ?? 200; $height = $height ?? 200;
$img = imagecreatetruecolor($width, $height); $img = imagecreatetruecolor($width, $height);
if ($img === FALSE)
{
return FALSE;
}
imagealphablending($img, TRUE); imagealphablending($img, TRUE);
$path = rtrim($path, '/'); $path = rtrim($path, '/');
// Background is the first color by default // Background is the first color by default
$fillColor = imagecolorallocatealpha($img, 255, 255, 255, 127); $fillColor = imagecolorallocatealpha($img, 255, 255, 255, 127);
if ($fillColor === FALSE)
{
return FALSE;
}
imagefill($img, 0, 0, $fillColor); imagefill($img, 0, 0, $fillColor);
$textColor = imagecolorallocate($img, 64, 64, 64); $textColor = imagecolorallocate($img, 64, 64, 64);
if ($textColor === FALSE)
{
return FALSE;
}
imagealphablending($img, TRUE); imagealphablending($img, TRUE);
@ -333,12 +346,18 @@ function createPlaceholderImage (string $path, ?int $width, ?int $height, $text
imagedestroy($img); imagedestroy($img);
$pngImage = imagecreatefrompng($path . '/placeholder.png'); $pngImage = imagecreatefrompng($path . '/placeholder.png');
if ($pngImage === FALSE)
{
return FALSE;
}
imagealphablending($pngImage, TRUE); imagealphablending($pngImage, TRUE);
imagesavealpha($pngImage, TRUE); imagesavealpha($pngImage, TRUE);
imagewebp($pngImage, $path . '/placeholder.webp'); imagewebp($pngImage, $path . '/placeholder.webp');
imagedestroy($pngImage); imagedestroy($pngImage);
return TRUE;
} }
/** /**