-
Notifications
You must be signed in to change notification settings - Fork 0
/
UrlColumn.php
52 lines (40 loc) · 1.23 KB
/
UrlColumn.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* Created by PhpStorm.
* User: vadim
* Date: 13.02.16
* Time: 15:12
*/
namespace sibds\grid;
use kartik\icons\Icon;
use kartik\grid\DataColumn;
use yii\helpers\Html;
class UrlColumn extends DataColumn
{
use TranslateTrait;
public $action = 'update';
public $format = 'raw';
public $showLock = false;
public function init()
{
$this->registerTranslations();
parent::init(); // TODO: Change the autogenerated stub
if(empty($this->value))
$this->value = function ($model, $key, $index, $widget) {
$lockIcon = '';
if($this->showLock){
if($model->hasAttribute('locked')&&$model->{$model->lockedAttribute}){
$lockIcon = self::show('eye-slash');
}else{
$lockIcon = self::show('eye');
}
}
return Html::a($lockIcon.$model->{$this->attribute},
[$this->action, 'id'=>$model->id],
['title'=>self::t('messages', 'Edit item'), 'data-pjax'=>0]);
};
}
private static function show($name){
return '<span class="fas fa-'.$name.'"></span> ';
}
}