1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Label view helper. |
5
|
|
|
* |
6
|
|
|
* @author Leandro Silva <[email protected]> |
7
|
|
|
* |
8
|
|
|
* @category LosUi |
9
|
|
|
* |
10
|
|
|
* @license https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License |
11
|
|
|
* |
12
|
|
|
* @link http://github.com/LansoWeb/LosUi |
13
|
|
|
* @link http://getbootstrap.com/components/#labels |
14
|
|
|
*/ |
15
|
|
|
namespace LosUi\View\Helper; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Label view helper. |
19
|
|
|
* |
20
|
|
|
* @author Leandro Silva <[email protected]> |
21
|
|
|
* |
22
|
|
|
* @category LosUi |
23
|
|
|
* |
24
|
|
|
* @license https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License |
25
|
|
|
* |
26
|
|
|
* @link http://github.com/LansoWeb/LosUi |
27
|
|
|
* @link http://getbootstrap.com/components/#labels |
28
|
|
|
*/ |
29
|
|
|
class Label |
30
|
|
|
{ |
31
|
|
|
protected $format = '<span class="label %s">%s</span>'; |
32
|
|
|
|
33
|
|
|
public function info($label) |
34
|
|
|
{ |
35
|
|
|
return $this->render($label, 'label-info'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function success($label) |
39
|
|
|
{ |
40
|
|
|
return $this->render($label, 'label-success'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function warning($label) |
44
|
|
|
{ |
45
|
|
|
return $this->render($label, 'label-warning'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function primary($label) |
49
|
|
|
{ |
50
|
|
|
return $this->render($label, 'label-primary'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function danger($label) |
54
|
|
|
{ |
55
|
|
|
return $this->render($label, 'label-danger'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function error($label) |
59
|
|
|
{ |
60
|
|
|
return $this->danger($label); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function render($label, $class = ' label-default') |
64
|
|
|
{ |
65
|
|
|
$class = trim($class); |
66
|
|
|
|
67
|
|
|
return sprintf($this->format, $class, $label); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function __invoke($label = null, $class = ' label-default') |
71
|
|
|
{ |
72
|
|
|
if ($label) { |
73
|
|
|
return $this->render($label, $class); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return $this; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|