ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilUserAvatarLetter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3
10{
14 protected static $colors = [
15 "#1abc9c", "#16a085", "#f1c40f",
16 "#f39c12", "#2ecc71", "#27ae60",
17 "#e67e22", "#d35400", "#3498db",
18 "#2980b9", "#e74c3c", "#c0392b",
19 "#9b59b6", "#8e44ad", "#bdc3c7",
20 "#34495e", "#2c3e50", "#95a5a6",
21 "#7f8c8d", "#ec87bf", "#d870ad",
22 "#f69785", "#9ba37e", "#b49255",
23 "#b49255", "#a94136"
24 ];
25
29 public function getUrl()
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 }
40}
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
Class ilUserAvatarBase.
Class ilUserAvatarLetter.