ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ($name)
 
Parameters
string$name
More...
 
 setUsrId ($usrId)
 
Parameters
int$usrId
More...
 

Static Protected Attributes

static $colors
 

Additional Inherited Members

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

Detailed Description

Member Function Documentation

◆ getUrl()

ilUserAvatarLetter::getUrl ( )
Returns
string
Exceptions
ilTemplateException

Implements ilUserAvatar.

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

References $tpl.

26  : string
27  {
28  static $amount_of_colors;
29  if (!isset($amount_of_colors)) {
30  $amount_of_colors = count(self::$colors);
31  }
32  // general idea, see https://gist.github.com/vctrfrnndz/fab6f839aaed0de566b0
33  $color = self::$colors[crc32($this->name) % $amount_of_colors];
34  $tpl = new \ilTemplate('tpl.letter_avatar.svg', true, true, 'Services/User');
35  $tpl->setVariable('COLOR', $color);
36  $tpl->setVariable('SHORT', $this->name);
37 
38  return 'data:image/svg+xml,' . rawurlencode($tpl->get());
39  }
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

Field Documentation

◆ $colors

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 16 of file class.ilUserAvatarLetter.php.


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