aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/LicenseAvatar.php
blob: c0a429d38e143cb132f08e7859ae6567f1393538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php

/*
 * Copyright (C) 2020 - Rasmus Fuhse
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */


/**
 * This class represents the image-picture of a license.
 */
class LicenseAvatar extends Avatar
{
    public const AVATAR_TYPE = 'licenses';
    protected const CREATE_CHUNKED_FOLDERS = false;

    public function getImageTag($size = Avatar::MEDIUM, $opt = [])
    {
        if (!$this->is_customized()) {
            return "";
        }

        return parent::getImageTag($size, $opt);
    }

    /**
     * Returns the CSS class to use for this avatar image.
     *
     * @param string  $size one of the constants Avatar::(NORMAL|MEDIUM|SMALL)
     * @return string CSS class to use for the avatar
     */
    protected function getCssClass($size)
    {
        return sprintf(
            'license-avatar-%s license-%s',
            $size,
            $this->user_id
        );
    }

    /**
     * Return the default title of the avatar.
     * @return string the default title
     */
    public function getDefaultTitle()
    {
        return License::find($this->user_id)->name;
    }

    /**
     * Return if avatar is visible to the current user.
     * @return boolean: true if visible
     */
    protected function checkAvatarVisibility()
    {
        return true;
    }

    /**
     * Return the dimension of a size
     *
     * @param  string $size the dimension of a size
     * @return array a tupel of integers [width, height]
     */
    public static function getDimension($size)
    {
        $dimensions = [
            Avatar::NORMAL => [300, 100],
            Avatar::MEDIUM => [120, 40],
            Avatar::SMALL  => [60, 20]
        ];
        return $dimensions[$size];
    }
}