|
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-2017, 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\grid\RefColumn; |
|
16
|
|
|
use hipanel\modules\hosting\models\Account; |
|
17
|
|
|
use hipanel\modules\hosting\widgets\account\State; |
|
18
|
|
|
use hipanel\modules\hosting\widgets\account\Type; |
|
19
|
|
|
use hipanel\modules\server\grid\ServerColumn; |
|
20
|
|
|
use hipanel\widgets\ArraySpoiler; |
|
21
|
|
|
use Yii; |
|
22
|
|
|
use yii\helpers\Html; |
|
23
|
|
|
|
|
24
|
|
|
class AccountGridView extends \hipanel\grid\BoxedGridView |
|
25
|
|
|
{ |
|
26
|
|
|
public function columns() |
|
27
|
|
|
{ |
|
28
|
|
|
return array_merge(parent::columns(), [ |
|
29
|
|
|
'account' => [ |
|
30
|
|
|
'class' => MainColumn::class, |
|
31
|
|
|
'label' => Yii::t('hipanel', 'Account'), |
|
32
|
|
|
'attribute' => 'login', |
|
33
|
|
|
'filterAttribute' => 'login_like', |
|
34
|
|
|
], |
|
35
|
|
|
'state' => [ |
|
36
|
|
|
'class' => RefColumn::class, |
|
37
|
|
|
'format' => 'raw', |
|
38
|
|
|
'i18nDictionary' => 'hipanel:hosting', |
|
39
|
|
|
'value' => function ($model) { |
|
40
|
|
|
return State::widget(compact('model')); |
|
41
|
|
|
}, |
|
42
|
|
|
'gtype' => 'state,account', |
|
43
|
|
|
], |
|
44
|
|
|
'server' => [ |
|
45
|
|
|
'class' => ServerColumn::class, |
|
46
|
|
|
], |
|
47
|
|
|
'sshftp_ips' => [ |
|
48
|
|
|
'attribute' => 'sshftp_ips', |
|
49
|
|
|
'format' => 'raw', |
|
50
|
|
|
'value' => function ($model) { |
|
51
|
|
|
return ArraySpoiler::widget([ |
|
52
|
|
|
'data' => $model->sshftp_ips, |
|
53
|
|
|
'visibleCount' => 3, |
|
54
|
|
|
]); |
|
55
|
|
|
}, |
|
56
|
|
|
], |
|
57
|
|
|
'actions' => [ |
|
58
|
|
|
'class' => ActionColumn::class, |
|
59
|
|
|
'template' => '{view} {delete}', |
|
60
|
|
|
], |
|
61
|
|
|
'type' => [ |
|
62
|
|
|
'class' => RefColumn::class, |
|
63
|
|
|
'i18nDictionary' => 'hipanel:hosting', |
|
64
|
|
|
'format' => 'raw', |
|
65
|
|
|
'value' => function ($model) { |
|
66
|
|
|
return Type::widget(compact('model')); |
|
67
|
|
|
}, |
|
68
|
|
|
'gtype' => 'type,account', |
|
69
|
|
|
], |
|
70
|
|
|
'access_data' => [ |
|
71
|
|
|
'format' => 'raw', |
|
72
|
|
|
'label' => Yii::t('hipanel:hosting:account', 'Access data'), |
|
73
|
|
|
'value' => function (Account $model): string { |
|
74
|
|
|
return Yii::t('hipanel:hosting:account', '{ip_label} {ip} {login_label} {login}', [ |
|
75
|
|
|
'ip_label' => Html::tag('b', Yii::t('hipanel', 'IP:')), |
|
76
|
|
|
'login_label' => Html::tag('b', Yii::t('hipanel', 'Login:')), |
|
77
|
|
|
'ip' => $model->ip, |
|
|
|
|
|
|
78
|
|
|
'login' => $model->login]); |
|
|
|
|
|
|
79
|
|
|
} |
|
80
|
|
|
] |
|
81
|
|
|
]); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.