99
1010use rmrevin \yii \fontawesome \component \Icon ;
1111use yii \base \Widget ;
12+ use yii \bootstrap \Nav ;
1213use yii \helpers \Html ;
1314
1415class Panel extends Widget
1516{
1617 /**
17- * @var string[]
18+ * @var array the configuration array for creating a [[Dropdown]] widget
1819 */
1920 protected $ tools = [];
2021
@@ -49,23 +50,38 @@ class Panel extends Widget
4950 public $ removable = false ;
5051
5152 /**
52- * Inits tool buttons
53+ * @var array|string, optional, the configuration array for creating a [[Dropdown]] widget,
54+ * or a string representing the dropdown menu.
55+ */
56+ public $ headerMenu = [];
57+
58+ /**
59+ * Init tool buttons
5360 */
5461 protected function initTools ()
5562 {
5663 if ($ this ->expandable === true || $ this ->collapsable === true ) {
57- $ this ->tools [] = Html::tag (
58- 'a ' ,
59- new Icon ('chevron- ' . ($ this ->expandable === true ? 'down ' : 'up ' )),
60- ['class ' => 'collapse-link ' ]
61- );
64+ $ this ->tools [] = [
65+ 'encode ' => false ,
66+ 'label ' => new Icon ('chevron- ' . ($ this ->expandable === true ? 'down ' : 'up ' )),
67+ 'linkOptions ' => ['class ' => 'collapse-link ' ],
68+ 'url ' => null ,
69+ ];
70+ }
71+ if (empty ($ this ->headerMenu ) === false ) {
72+ $ this ->tools [] = [
73+ 'encode ' => false ,
74+ 'items ' => $ this ->headerMenu ,
75+ 'label ' => new Icon ('wrench ' ),
76+ ];
6277 }
6378 if ($ this ->removable === true ) {
64- $ this ->tools [] = Html::tag (
65- 'a ' ,
66- new Icon ('close ' ),
67- ['class ' => 'close-link ' ]
68- );
79+ $ this ->tools [] = [
80+ 'encode ' => false ,
81+ 'label ' => new Icon ('close ' ),
82+ 'linkOptions ' => ['class ' => 'close-link ' ],
83+ 'url ' => null ,
84+ ];
6985 }
7086 }
7187
@@ -82,10 +98,14 @@ public function init()
8298 echo Html::beginTag ('div ' , ['class ' => 'x_title ' ]);
8399 echo Html::tag ('h2 ' , ($ this ->icon !== null ? new Icon ($ this ->icon ) . ' ' : '' ) . $ this ->header );
84100 if (empty ($ this ->tools ) === false ) {
85- echo Html::tag (
86- 'ul ' ,
87- '<li> ' . implode ("</li> \n<li> " , $ this ->tools ) . '</li> ' ,
88- ['class ' => 'nav navbar-right panel_toolbox ' ]
101+ echo Nav::widget (
102+ [
103+ 'dropDownCaret ' => '' ,
104+ 'items ' => $ this ->tools ,
105+ 'options ' => [
106+ 'class ' => 'nav navbar-right panel_toolbox ' ,
107+ ],
108+ ]
89109 );
90110 }
91111 echo Html::tag ('div ' , null , ['class ' => 'clearfix ' ]);
0 commit comments