-
Notifications
You must be signed in to change notification settings - Fork 2
/
WebRTCLocalIPWidget.php
43 lines (38 loc) · 1.16 KB
/
WebRTCLocalIPWidget.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
<?php
namespace bubifengyun\WebrtcGetClientLocalIp;
use yii\widgets\InputWidget;
use Yii;
use yii\helpers\Html;
use yii\helpers\Url;
class WebRTCLocalIPWidget extends InputWidget
{
public $hidden = true;
public $attributes;
public $id = 'webrtclocalip';
public $name = 'webrtclocalip';
public function init()
{
parent::init();
}
public function run()
{
$view = $this->getView();
$this->attributes['id'] = $this->id;
if ($this->hasModel()) {
if ($this->hidden) {
$input = Html::activeHiddenInput($this->model, $this->attribute, $this->attributes);
} else {
$input = Html::activeTextInput($this->model, $this->attribute, $this->attributes);
}
} else {
if ($this->hidden) {
$input = Html::hiddenInput($this->name, '', $this->attributes);
} else {
$input = Html::textInput($this->name, '', $this->attributes);
}
}
echo $input;
WebRTCLocalIPAsset::register($view);
$view->registerJs("setoptions({id: '" . $this->id . "'});load();");
}
}