|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* HiPanel core package |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://hipanel.com/ |
|
6
|
|
|
* @package hipanel-core |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\widgets; |
|
12
|
|
|
|
|
13
|
|
|
class LinkSorter extends \yii\widgets\LinkSorter |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @var boolean whether to show sorter button |
|
17
|
|
|
*/ |
|
18
|
|
|
public $show = false; |
|
19
|
|
|
|
|
20
|
|
|
public $uiModel; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var string CSS classes, that will be applied to the container |
|
24
|
|
|
*/ |
|
25
|
|
|
public $containerClass = 'dropdown'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var string CSS classes, that will be applied to the button |
|
29
|
|
|
*/ |
|
30
|
|
|
public $buttonClass = 'btn btn-sm btn-default dropdown-toggle'; |
|
31
|
|
|
|
|
32
|
|
|
public $options = ['class' => 'dropdown-menu', 'role' => 'menu', 'aria-labelledby' => '']; |
|
33
|
|
|
|
|
34
|
|
|
public $dataProvider; |
|
35
|
|
|
|
|
36
|
|
|
public function run() |
|
37
|
|
|
{ |
|
38
|
|
|
if ($this->show) { |
|
39
|
|
|
parent::run(); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Renders the sort links. |
|
45
|
|
|
* |
|
46
|
|
|
* @return string the rendering result |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function renderSortLinks() |
|
49
|
|
|
{ |
|
50
|
|
|
$attributes = empty($this->attributes) ? array_keys($this->sort->attributes) : $this->attributes; |
|
51
|
|
|
$links = []; |
|
52
|
|
|
foreach ($attributes as $name) { |
|
53
|
|
|
$links[] = $this->sort->link($name); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return $this->render('LinkSorterView', [ |
|
57
|
|
|
'id' => $this->id, |
|
58
|
|
|
'links' => $links, |
|
59
|
|
|
'attributes' => $this->sort->attributes, |
|
60
|
|
|
'options' => array_merge($this->options, ['encode' => false]), |
|
61
|
|
|
'containerClass' => $this->containerClass, |
|
62
|
|
|
'buttonClass' => $this->buttonClass, |
|
63
|
|
|
'uiModel' => $this->uiModel, |
|
64
|
|
|
]); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|