1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Hosting Plugin for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-hosting |
6
|
|
|
* @package hipanel-module-hosting |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\hosting\grid; |
12
|
|
|
|
13
|
|
|
use hipanel\grid\ActionColumn; |
14
|
|
|
use hipanel\grid\MainColumn; |
15
|
|
|
use hipanel\modules\hosting\widgets\backup\ObjectLabelWidget; |
16
|
|
|
use hipanel\modules\server\grid\ServerColumn; |
17
|
|
|
use Yii; |
18
|
|
|
use yii\helpers\Html; |
19
|
|
|
|
20
|
|
|
class BackupGridView extends \hipanel\grid\BoxedGridView |
21
|
|
|
{ |
22
|
|
|
public function columns() |
23
|
|
|
{ |
24
|
|
|
return array_merge(parent::columns(), [ |
25
|
|
|
'id' => [ |
26
|
|
|
'format' => 'html', |
27
|
|
|
'attribute' => 'id', |
28
|
|
|
'value' => function ($model) { |
29
|
|
|
return Html::tag('span', $model->id, ['class' => 'bold']); |
30
|
|
|
}, |
31
|
|
|
], |
32
|
|
|
'object_id' => [ |
33
|
|
|
'class' => MainColumn::class, |
34
|
|
|
'filterAttribute' => 'id', |
35
|
|
|
'attribute' => 'object_id', |
36
|
|
|
], |
37
|
|
|
'backup' => [ |
38
|
|
|
'class' => MainColumn::class, |
39
|
|
|
'filterAttribute' => 'backup_like', |
40
|
|
|
], |
41
|
|
|
'server' => [ |
42
|
|
|
'class' => ServerColumn::class, |
43
|
|
|
], |
44
|
|
|
'account' => [ |
45
|
|
|
'class' => AccountColumn::class, |
46
|
|
|
], |
47
|
|
|
'object' => [ |
48
|
|
|
'format' => 'raw', |
49
|
|
|
'attribute' => 'name', |
50
|
|
|
'filterAttribute' => 'name_like', |
51
|
|
|
'value' => function ($model) { |
52
|
|
|
$labelType = ObjectLabelWidget::widget(compact('model')); |
53
|
|
|
return $labelType . ' ' . |
54
|
|
|
Html::a($model->name, ["@{$model->object}/view", 'id' => $model->object_id], ['data-pjax' => 0]); |
55
|
|
|
}, |
56
|
|
|
], |
57
|
|
|
'name' => [ |
58
|
|
|
'format' => 'raw', |
59
|
|
|
'attribute' => 'name', |
60
|
|
|
'value' => function ($model) { |
61
|
|
|
return Html::a($model->name, ["@{$model->object}/view", 'id' => $model->object_id], ['data-pjax' => 0]); |
62
|
|
|
}, |
63
|
|
|
], |
64
|
|
|
'size' => [ |
65
|
|
|
'filter' => false, |
66
|
|
|
'value' => function ($model) { |
67
|
|
|
return Yii::$app->formatter->asShortSize($model->size, 2); |
68
|
|
|
}, |
69
|
|
|
], |
70
|
|
|
'time' => [ |
71
|
|
|
'filter' => false, |
72
|
|
|
'value' => function ($model) { |
73
|
|
|
return Yii::$app->formatter->asDatetime($model->time); |
74
|
|
|
}, |
75
|
|
|
], |
76
|
|
|
'actions' => [ |
77
|
|
|
'class' => ActionColumn::class, |
78
|
|
|
'template' => '{view} {delete}', |
79
|
|
|
], |
80
|
|
|
'inner_actions' => [ |
81
|
|
|
'class' => ActionColumn::class, |
82
|
|
|
'template' => '{deleteBackup}', |
83
|
|
|
'buttons' => [ |
84
|
|
|
'deleteBackup' => function ($url, $model, $key) { |
|
|
|
|
85
|
|
|
return Html::a('<i class="fa fa-trash-o"></i> ' . Yii::t('hipanel', 'Delete'), ['/hosting/backup/delete', 'id' => $model->id], [ |
86
|
|
|
'aria-label' => Yii::t('hipanel', 'Delete'), |
87
|
|
|
'class' => 'btn btn-danger btn-xs', |
88
|
|
|
'data' => [ |
89
|
|
|
'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'), |
90
|
|
|
'method' => 'POST', |
91
|
|
|
'data-pjax' => '0', |
92
|
|
|
], |
93
|
|
|
]); |
94
|
|
|
}, |
95
|
|
|
], |
96
|
|
|
], |
97
|
|
|
]); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.