forked from Sammaye/yii2-outdated-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutdatedBrowser.php
36 lines (26 loc) · 987 Bytes
/
OutdatedBrowser.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
<?php
namespace biller\outdatedBrowser;
use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
class OutdatedBrowser extends Widget {
public $bgColor = '#f25648';
public $color = '#ffffff';
public $lowerThan = 'transform';
public $language = 'en';
public $onlyIe7 = false;
private $bundle;
public function run() {
$this->bundle = OutdatedBrowserAsset::register($this->view);
$data = ArrayHelper::toArray($this, [
self::class => ['bgColor', 'color', 'lowerThan', 'languagePath']
]);
$js = $this->render('widget', ['data' => $data, 'onlyIe7' => $this->onlyIe7]);
$this->view->registerJs($js);
$div = Html::tag('div', '', ['id' => 'outdated']);
return $this->onlyIe7 ? "<!--[if lt IE 8]>$div<![endif]-->" : $div;
}
public function getLanguagePath() {
return "{$this->bundle->baseUrl}/lang/es.html";
}
}