1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Firesphere\SearchBackend\Models; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Forms\FieldList; |
6
|
|
|
use SilverStripe\Forms\ReadonlyField; |
7
|
|
|
use SilverStripe\ORM\DataObject; |
8
|
|
|
use SilverStripe\Security\Member; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class \Firesphere\SearchBackend\Models\DirtyClass |
12
|
|
|
* |
13
|
|
|
* @property string $Type |
14
|
|
|
* @property string $Class |
15
|
|
|
* @property string $IDs |
16
|
|
|
*/ |
17
|
|
|
class DirtyClass extends DataObject |
18
|
|
|
{ |
19
|
|
|
private static $table_name = 'DirtyClass'; |
|
|
|
|
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string Singular name |
23
|
|
|
*/ |
24
|
|
|
private static $singular_name = 'Dirty class'; |
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var string Plural name |
27
|
|
|
*/ |
28
|
|
|
private static $plural_name = 'Dirty classes'; |
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var array Database fields |
31
|
|
|
*/ |
32
|
|
|
private static $db = [ |
|
|
|
|
33
|
|
|
'Type' => 'Varchar(6)', |
34
|
|
|
'Class' => 'Varchar(512)', |
35
|
|
|
'IDs' => 'Varchar(255)', |
36
|
|
|
]; |
37
|
|
|
/** |
38
|
|
|
* @var array Summary fields in CMS |
39
|
|
|
*/ |
40
|
|
|
private static $summary_fields = [ |
|
|
|
|
41
|
|
|
'Class', |
42
|
|
|
'Type', |
43
|
|
|
'IDs', |
44
|
|
|
]; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Make the CMS fields readable |
48
|
|
|
* |
49
|
|
|
* @return FieldList |
50
|
|
|
*/ |
51
|
|
|
public function getCMSFields() |
52
|
|
|
{ |
53
|
|
|
$fields = parent::getCMSFields(); |
54
|
|
|
$fields->removeByName(['Class', 'IDs']); |
55
|
|
|
|
56
|
|
|
$class = singleton($this->Class)->plural_name(); |
57
|
|
|
|
58
|
|
|
$IDs = json_decode($this->IDs, true); |
59
|
|
|
|
60
|
|
|
$fields->addFieldsToTab('Root.Main', [ |
61
|
|
|
ReadonlyField::create('Class', 'Class', $class), |
62
|
|
|
ReadonlyField::create('IDs', _t(self::class . '.DIRTYIDS', 'Dirty IDs'), $IDs), |
63
|
|
|
]); |
64
|
|
|
|
65
|
|
|
return $fields; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Nope, can't delete these |
70
|
|
|
* |
71
|
|
|
* @param null|Member $member |
72
|
|
|
* @return bool |
73
|
|
|
*/ |
74
|
|
|
public function canDelete($member = null) |
75
|
|
|
{ |
76
|
|
|
return false; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Nope, can't edit these |
81
|
|
|
* |
82
|
|
|
* @param null|Member $member |
83
|
|
|
* @return bool |
84
|
|
|
*/ |
85
|
|
|
public function canEdit($member = null) |
86
|
|
|
{ |
87
|
|
|
return false; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Nope, can't create these |
92
|
|
|
* |
93
|
|
|
* @param null|Member $member |
94
|
|
|
* @param array $context |
95
|
|
|
* @return bool |
96
|
|
|
*/ |
97
|
|
|
public function canCreate($member = null, $context = []) |
98
|
|
|
{ |
99
|
|
|
return false; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|