-
Notifications
You must be signed in to change notification settings - Fork 22
/
LteInfoBox.php
118 lines (104 loc) · 2.34 KB
/
LteInfoBox.php
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* Created by solly [25.03.17 21:53]
*/
namespace insolita\wgadminlte;
use yii\bootstrap\Widget;
/**
* Class LteInfoBox
*
* @package insolita\wgadminlte
*/
class LteInfoBox extends Widget
{
/**
* @var string
*/
public $icon = 'fa fa-bullhorn';
/**
* @var string
*/
public $bgIconColor = LteConst::COLOR_BLUE;
/**
* if empty - content block will be white
* @var string
*/
public $bgColor = '';
/**
* @var
*/
public $text;
/**
* @var
*/
public $number;
/**
* @var bool
*/
public $showProgress = false;
/**
* @var string
*/
public $description = '';
/**
* @var int
*/
public $progressNumber = 0;
/**
* @var string
*/
public $template
= <<<HTML
<div class="info-box {bgColor}">
<span class="info-box-icon {bgIconColor}">{icon}</span>
<div class="info-box-content">
<span class="info-box-text">{text}</span>
<span class="info-box-number">{number}</span>
{progress}
</div>
</div>
HTML;
/**
* @var string
*/
public $progressTemplate
= <<<HTML
<div class="progress">
<div class="progress-bar {options}" style="width: {number}% "></div>
</div>
<span class="progress-description">
{text}
</span>
HTML;
public function init(){
parent::init();
}
/**
* @return string
*/
public function run()
{
$progress = '';
if ($this->showProgress) {
$progress = strtr(
$this->progressTemplate,
[
'{number}' => $this->progressNumber,
'{text}' => $this->description,
'{options}'=>!$this->bgColor?'bg-'.$this->bgIconColor:''
]
);
}
return strtr(
$this->template,
[
'{icon}' => '<i class="'.$this->icon.'"></i>',
'{text}' => $this->text,
'{bgColor}' => $this->bgColor?'bg-'.$this->bgColor:'',
'{bgIconColor}' => $this->bgIconColor?'bg-'.$this->bgIconColor:'',
'{number}' => $this->number,
'{progress}' => $progress?:$this->description,
]
);
}
}