Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+13 -13
View File
@@ -28,9 +28,9 @@ class _LetterPhoto
protected $fileStorageClass = 'core_Profile';
/**
* @brief Member name
* @brief Member object
*/
protected $name = NULL;
protected $member = NULL;
/**
* @brief Text size
@@ -40,12 +40,12 @@ class _LetterPhoto
/**
* Create a new photo object
*
* @param string $name Member's name
* @param \IPS\Member $member Member object
* @return void
*/
public function __construct( $name='' )
public function __construct( $member )
{
$this->name = $name;
$this->member = $member;
}
/**
@@ -68,7 +68,7 @@ class _LetterPhoto
$this->textSize = ( ( $maxWidth / 2 ) / $letterCount );
/* If we don't have a name, there's nothing to create */
if( !$this->name )
if( !$this->member->name )
{
return NULL;
}
@@ -76,7 +76,7 @@ class _LetterPhoto
/* Get the first character of the name...if we can't detect it, there's again nothing to convert */
$letters = $this->getLetters( $letterCount );
if( !$letters )
if( $letters === NULL )
{
return NULL;
}
@@ -93,7 +93,7 @@ class _LetterPhoto
/* Save the image and return it */
try
{
return \IPS\File::create( $this->fileStorageClass, $letters . '.png', (string) $image, NULL, TRUE );
return \IPS\File::create( $this->fileStorageClass, $letters . '_member_' . $this->member->member_id . '.png', (string) $image, NULL, TRUE, NULL, FALSE );
}
catch( \Exception $e )
{
@@ -111,10 +111,10 @@ class _LetterPhoto
*/
protected function getLetters( $letters=1 )
{
$name = str_replace( array( '<', '>', '=', '-', '+', '"', "'" ), '', $this->name );
$name = str_replace( array( '<', '>', '=', '-', '+', '"', "'" ), '', $this->member->name );
$name = preg_replace( "/(\pP)+/u", '', trim( $name ) );
return mb_strtoupper( mb_substr( $name, 0, $letters ) );
return $name ? mb_strtoupper( mb_substr( $name, 0, $letters ) ) : NULL;
}
/**
@@ -137,7 +137,7 @@ class _LetterPhoto
*
* @return array (RGB value)
*/
protected function generateColorCode()
public function generateColorCode()
{
/* If we've already generated a hue on this page load, use the golden ratio to find a number sufficiently distinct */
if( static::$lastHue )
@@ -154,7 +154,7 @@ class _LetterPhoto
return $this->convertHsvToRgb( $hue, $this->colorCodeSaturation, $this->colorCodeValue );
}
$hue = ( ( ord( \mb_strtolower( $this->name ) ) - 97 ) / 25.0 ) + 0.25;
$hue = ( ( ord( \mb_strtolower( $this->member->name ) ) - 97 ) / 25.0 ) + 0.25;
$hue *= 1.61803398875;
$hue *= (float) ( '1.' . rand() ) / 1;
@@ -225,7 +225,7 @@ class _LetterPhoto
}
}
return array_map( function( $value ) { return $value * 256.0; }, $rgb );
return array_map( function( $value ) { return round( $value * 256.0 ); }, $rgb );
}
/**