-
Notifications
You must be signed in to change notification settings - Fork 2
/
GlyphIcon.php
35 lines (28 loc) · 1.07 KB
/
GlyphIcon.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
<?php
/**
* With Yii2 being compatible with Twitter Bootstrap, it only makes sense to support glyphicons as application icon.
*
* Set "image" to the glyphicon name (without prefixes) to change the icon. The default icon is "folder-open"
*/
namespace bedezign\yii2\desktop;
use yii\helpers\Html;
class GlyphIcon extends Icon
{
public function render($type)
{
// Obviously we need the bootstrap assets for this
\yii\bootstrap\BootstrapPluginAsset::register($this->desktop->view);
$glyph = $this->image;
if (!$glyph)
$glyph = 'folder-open';
$attributes = ['class' => "glyphicon glyphicon-$glyph"];
$styles = [];
switch ($type) {
case self::DISPLAY_DOCK: $styles = ['position' => 'relative', 'top' => '3px', 'font-size' => '16px', 'padding-right' => '5px']; break;
case self::DISPLAY_TITLEBAR : $styles = ['float' => 'left', 'margin' => '4px 8px 0 0', 'font-size' => '20px']; break;
case self::DISPLAY_DESKTOP : $styles = ['font-size' => '32px']; break;
}
Html::addCssStyle($attributes, $styles);
return Html::tag('span', '', $attributes);
}
}