-
Notifications
You must be signed in to change notification settings - Fork 1
/
PanelWidget.php
55 lines (47 loc) · 1.61 KB
/
PanelWidget.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
<?php
namespace derekisbusy\panel;
use yii\base\Widget;
use yii\helpers\Html;
use yii\helpers\Json;
use yii\web\View;
class PanelWidget extends Widget{
public $pluginOptions=[];
public $defaultPluginOptions=[];
public $title;
public $content;
public $footer;
public $type = 'info';
public $widget=true;
public $collapsable=true;
public $collapse=false;
const TYPE_INFO = 'info';
const TYPE_DEFAULT = 'default';
const TYPE_DANGER = 'danger';
const TYPE_PRIMARY = 'primary';
const TYPE_SUCCESS = 'success';
public function init(){
parent::init();
if($this->widget) {
PanelWidgetAsset::register($this->view);
$this->view->registerJs("jQuery('#".$this->getId()."').bootstrap_panel(".Json::encode(array_merge($this->defaultPluginOptions,$this->pluginOptions), JSON_UNESCAPED_SLASHES).");",
View::POS_READY);
}
$style=$this->collapse ? 'display:none' : '';
echo Html::beginTag('div', ['class'=>'panel panel-'.$this->type.' panel-widget','id'=>$this->getId()]);
echo Html::tag('div', $this->title, ['class'=>'panel-heading']);
echo Html::beginTag('div', ['class'=>'panel-body','style'=>$style]);
}
public function run(){
echo $this->content;
echo Html::endTag('div');
if($this->footer)
echo Html::tag('div', $this->footer, ['class'=>'panel-footer']);
echo Html::endTag('div');
}
public static function begin($config = array()) {
parent::begin($config);
}
public static function end() {
parent::end();
}
}