1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created for IG Monitoring. |
4
|
|
|
* User: jakim <[email protected]> |
5
|
|
|
* Date: 16.08.2018 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace app\modules\admin\components\grid; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
use app\dictionaries\AccountInvalidationType; |
12
|
|
|
use app\modules\admin\models\Account; |
13
|
|
|
use jakim\ig\Url; |
14
|
|
|
use yii\grid\DataColumn; |
15
|
|
|
use yii\helpers\ArrayHelper; |
16
|
|
|
use yii\helpers\Html; |
17
|
|
|
|
18
|
|
|
class AccountColumn extends DataColumn |
19
|
|
|
{ |
20
|
|
|
public $format = 'raw'; |
21
|
|
|
public $displayDashboardLink = false; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param Account $model |
25
|
|
|
* @param mixed $key |
26
|
|
|
* @param int $index |
27
|
|
|
* @return string |
28
|
|
|
*/ |
29
|
|
|
public function getDataCellValue($model, $key, $index) |
30
|
|
|
{ |
31
|
|
|
$html = []; |
32
|
|
|
|
33
|
|
|
if ($this->displayDashboardLink || $model->monitoring) { |
34
|
|
|
$html[] = Html::a(ArrayHelper::getValue($model, 'displayName') ?: $model->usernamePrefixed, ['account/dashboard', 'id' => $model->id]); |
35
|
|
|
} else { |
36
|
|
|
$html[] = $model->{$this->attribute}; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if ($model->is_verified) { |
40
|
|
|
$html[] = ' <i class="fa fa-check-circle text-sm text-blue" data-toggle="tooltip" data-placement="top" title="Verified"></i>'; |
41
|
|
|
} |
42
|
|
|
if ($model->is_business) { |
43
|
|
|
$html[] = sprintf(' <i class="fa fa-briefcase text-sm text-muted" data-toggle="tooltip" data-placement="top" title="%s"></i>', Html::encode($model->business_category)); |
44
|
|
|
} |
45
|
|
|
$html[] = Html::a(' <span class="fa fa-external-link text-sm fa-fw"></span>', Url::account($model->username), ['target' => '_blank']); |
46
|
|
|
|
47
|
|
|
if (!$model->is_valid) { |
48
|
|
|
$html[] = sprintf( |
49
|
|
|
'<span class="fa fa-exclamation-triangle text-danger pull-right" data-toggle="tooltip" data-placement="top" title="%s, attempts: %s"></span>', |
50
|
|
|
AccountInvalidationType::getLabel($model->invalidation_type_id, 'Unknown reason'), |
51
|
|
|
$model->invalidation_count |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
if ($model->disabled) { |
55
|
|
|
$html[] = '<span class="fa fa-exclamation-triangle text-danger pull-right" title="Not found."></span>'; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return implode(" \n", $html); |
59
|
|
|
} |
60
|
|
|
} |