ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilUserAvatarLetter Class Reference

Class ilUserAvatarLetter. More...

+ Inheritance diagram for ilUserAvatarLetter:
+ Collaboration diagram for ilUserAvatarLetter:

Public Member Functions

 getUrl ()
 
- Public Member Functions inherited from ilUserAvatarBase
 setName (string $name)
 
 setUsrId (int $usrId)
 

Static Protected Attributes

static array $colors
 

Additional Inherited Members

- Protected Attributes inherited from ilUserAvatarBase
string $name = ''
 
int $usrId = 0
 

Detailed Description

Member Function Documentation

◆ getUrl()

ilUserAvatarLetter::getUrl ( )

Implements ilUserAvatar.

Definition at line 38 of file class.ilUserAvatarLetter.php.

38  : string
39  {
40  static $amount_of_colors;
41  if (!isset($amount_of_colors)) {
42  $amount_of_colors = count(self::$colors);
43  }
44  // general idea, see https://gist.github.com/vctrfrnndz/fab6f839aaed0de566b0
45  $color = self::$colors[crc32($this->name) % $amount_of_colors];
46  $tpl = new \ilTemplate('tpl.letter_avatar.svg', true, true, 'components/ILIAS/User');
47  $tpl->setVariable('COLOR', $color);
48  $tpl->setVariable('SHORT', $this->name);
49 
50  return 'data:image/svg+xml,' . rawurlencode($tpl->get());
51  }

Field Documentation

◆ $colors

array ilUserAvatarLetter::$colors
staticprotected
Initial value:
= [
"#0e6252", "#107360", "#aa890a", "#c87e0a", "#176437", "#196f3d", "#bf6516", "#a04000", "#1d6fa5", "#1b557a",
"#bf2718", "#81261d", "#713b87", "#522764", "#78848c", "#34495e", "#2c3e50", "#566566", "#90175a", "#9e2b6e",
"#d22f10", "#666d4e", "#715a32", "#83693a", "#963a30", "#e74c3c"
]

Definition at line 32 of file class.ilUserAvatarLetter.php.


The documentation for this class was generated from the following file: