1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SleepingOwl\Admin\Display\Column; |
4
|
|
|
|
5
|
|
|
class Url extends NamedColumn |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var string |
9
|
|
|
*/ |
10
|
|
|
protected $view = 'column.url'; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var bool |
14
|
|
|
*/ |
15
|
|
|
protected $isSearchable = true; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var string|bool |
19
|
|
|
*/ |
20
|
|
|
protected $icon = 'fas fa-external-link-square-alt'; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
* @var bool |
25
|
|
|
*/ |
26
|
|
|
protected $text = ''; |
27
|
|
|
protected $textString = false; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var bool |
31
|
|
|
*/ |
32
|
|
|
protected $orderable = true; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
protected $linkAttributes = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
|
|
public function getLinkAttributes() |
43
|
|
|
{ |
44
|
|
|
return $this->linkAttributes; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param array $linkAttributes |
49
|
|
|
* |
50
|
|
|
* @return $this |
51
|
|
|
*/ |
52
|
|
|
public function setLinkAttributes(array $linkAttributes) |
53
|
|
|
{ |
54
|
|
|
$this->linkAttributes = $linkAttributes; |
55
|
|
|
|
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string|bool |
61
|
|
|
*/ |
62
|
|
|
public function getText() |
63
|
|
|
{ |
64
|
|
|
if ($this->textString) { |
65
|
|
|
return $this->text; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $this->getValueFromObject($this->getModel(), $this->text); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string|bool $icon |
73
|
|
|
* |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
|
|
public function setText($text, $textString = false) |
77
|
|
|
{ |
78
|
|
|
$this->text = $text; |
79
|
|
|
$this->textString = $textString; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string|bool |
86
|
|
|
*/ |
87
|
|
|
public function getIcon() |
88
|
|
|
{ |
89
|
|
|
return $this->icon; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string|bool $icon |
94
|
|
|
* |
95
|
|
|
* @return $this |
96
|
|
|
*/ |
97
|
|
|
public function setIcon($icon) |
98
|
|
|
{ |
99
|
|
|
$this->icon = $icon; |
100
|
|
|
|
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return array |
106
|
|
|
*/ |
107
|
|
|
public function toArray() |
108
|
|
|
{ |
109
|
|
|
return parent::toArray() + [ |
110
|
|
|
'linkAttributes' => $this->getLinkAttributes(), |
111
|
|
|
'value' => htmlspecialchars($this->getModelValue()), |
112
|
|
|
'icon' => $this->getIcon(), |
113
|
|
|
'text' => $this->getText(), |
114
|
|
|
]; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|