1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeKoala\Tabulator; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Control\Controller; |
6
|
|
|
use SilverStripe\Control\RequestHandler; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This is the base class for tools (see TabulatorAddNewButton for sample usage) |
10
|
|
|
* For tools handling requests, implement index method (see TabulatorExportButton) |
11
|
|
|
*/ |
12
|
|
|
class AbstractTabulatorTool extends RequestHandler |
13
|
|
|
{ |
14
|
|
|
protected TabulatorGrid $tabulatorGrid; |
15
|
|
|
|
16
|
|
|
protected string $buttonName = ''; |
17
|
|
|
protected string $name = ''; |
18
|
|
|
protected string $link = ''; |
19
|
|
|
protected bool $newWindow = false; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Get the value of tabulatorGrid |
23
|
|
|
*/ |
24
|
|
|
public function getTabulatorGrid(): TabulatorGrid |
25
|
|
|
{ |
26
|
|
|
return $this->tabulatorGrid; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Set the value of tabulatorGrid |
31
|
|
|
*/ |
32
|
|
|
public function setTabulatorGrid(TabulatorGrid $tabulatorGrid): self |
33
|
|
|
{ |
34
|
|
|
$this->tabulatorGrid = $tabulatorGrid; |
35
|
|
|
return $this; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function getName(): string |
39
|
|
|
{ |
40
|
|
|
return $this->name; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function setName($name): self |
44
|
|
|
{ |
45
|
|
|
// Don't overwrite given name with empty val |
46
|
|
|
if ($name) { |
47
|
|
|
$this->name = $name; |
48
|
|
|
} |
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function Link($action = null) |
53
|
|
|
{ |
54
|
|
|
if (!$this->link) { |
55
|
|
|
return Controller::join_links($this->tabulatorGrid->Link('tool/' . $this->name), $action); |
56
|
|
|
} |
57
|
|
|
return $this->link; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function isAdmini() |
61
|
|
|
{ |
62
|
|
|
return $this->tabulatorGrid->getCompatLayer() instanceof AdminiCompat; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get the value of newWindow |
67
|
|
|
*/ |
68
|
|
|
public function getNewWindow(): bool |
69
|
|
|
{ |
70
|
|
|
return $this->newWindow; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Set the value of newWindow |
75
|
|
|
* |
76
|
|
|
* @param bool $newWindow |
77
|
|
|
*/ |
78
|
|
|
public function setNewWindow($newWindow): self |
79
|
|
|
{ |
80
|
|
|
$this->newWindow = $newWindow; |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Get the value of buttonName |
86
|
|
|
*/ |
87
|
|
|
public function getButtonName(): string |
88
|
|
|
{ |
89
|
|
|
return $this->buttonName; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Set the value of buttonName |
94
|
|
|
* |
95
|
|
|
* @param string $buttonName |
96
|
|
|
*/ |
97
|
|
|
public function setButtonName($buttonName): self |
98
|
|
|
{ |
99
|
|
|
$this->buttonName = $buttonName; |
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|