ILIAS  release_7 Revision v7.30-3-g800a261c036
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{
16 protected static $colors = [
17 "#0e6252", "#107360", "#aa890a", "#c87e0a", "#176437", "#196f3d", "#bf6516", "#a04000", "#1d6fa5", "#1b557a",
18 "#bf2718", "#81261d", "#713b87", "#522764", "#78848c", "#34495e", "#2c3e50", "#566566", "#90175a", "#9e2b6e",
19 "#d22f10", "#666d4e", "#715a32", "#83693a", "#963a30", "#e74c3c"
20 ];
21
26 public function getUrl() : 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 }
40}
An exception for terminatinating execution or to throw for unit testing.
Class ilUserAvatarBase.
Class ilUserAvatarLetter.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41