ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

Implements ilUserAvatar.

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

References $tpl.

30  {
31  // general idea, see https://gist.github.com/vctrfrnndz/fab6f839aaed0de566b0
32  $color = self::$colors[$this->usrId % count(self::$colors)];
33  $tpl = new \ilTemplate('tpl.letter_avatar.svg', true, true, 'Services/User');
34  $tpl->setVariable('COLOR', $color);
35  $tpl->setVariable('SHORT', $this->name);
36  $data_src = 'data:image/svg+xml,' . rawurlencode($tpl->get());
37 
38  return $data_src;
39  }
$tpl
Definition: ilias.php:10

Field Documentation

◆ $colors

ilUserAvatarLetter::$colors
staticprotected
Initial value:
= [
"#1abc9c", "#16a085", "#f1c40f",
"#f39c12", "#2ecc71", "#27ae60",
"#e67e22", "#d35400", "#3498db",
"#2980b9", "#e74c3c", "#c0392b",
"#9b59b6", "#8e44ad", "#bdc3c7",
"#34495e", "#2c3e50", "#95a5a6",
"#7f8c8d", "#ec87bf", "#d870ad",
"#f69785", "#9ba37e", "#b49255",
"#b49255", "#a94136"
]

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


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