Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -596,9 +596,39 @@ abstract class _ActiveRecord
|
||||
$photo->file = \IPS\File::get( static::$coverPhotoStorageExtension, $this->$photoCol );
|
||||
$photo->offset = $this->$photoOffset;
|
||||
}
|
||||
|
||||
$photo->editable = $this->canEdit();
|
||||
$photo->object = $this;
|
||||
|
||||
|
||||
return $photo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a random hex color for a background
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function coverPhotoBackgroundColor()
|
||||
{
|
||||
return '#' . dechex( mt_rand( 0x000000, 0xFFFFFF ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cover photo background color based on a string
|
||||
*
|
||||
* @param string $string Some string to base background color on
|
||||
* @return string
|
||||
*/
|
||||
protected function staticCoverPhotoBackgroundColor( $string )
|
||||
{
|
||||
$integer = 0;
|
||||
|
||||
for( $i=0, $j=\strlen($string); $i<$j; $i++ )
|
||||
{
|
||||
$integer = ord( \substr( $string, $i, 1 ) ) + ( ( $integer << 5 ) - $integer );
|
||||
$integer = $integer & $integer;
|
||||
}
|
||||
|
||||
return "hsl(" . ( $integer % 360 ) . ", 100%, 80% )";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user