ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
30 public function getUrl() : string
31 {
32 static $amount_of_colors;
33 if (!isset($amount_of_colors)) {
34 $amount_of_colors = count(self::$colors);
35 }
36 // general idea, see https://gist.github.com/vctrfrnndz/fab6f839aaed0de566b0
37 $color = self::$colors[crc32($this->name) % $amount_of_colors];
38 $tpl = new \ilTemplate('tpl.letter_avatar.svg', true, true, 'Services/User');
39 $tpl->setVariable('COLOR', $color);
40 $tpl->setVariable('SHORT', $this->name);
41
42 return 'data:image/svg+xml,' . rawurlencode($tpl->get());
43 }
44}
An exception for terminatinating execution or to throw for unit testing.
Class ilUserAvatarBase.
Class ilUserAvatarLetter.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl