1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use SilverStripe\Elastica\ElasticaUtil; |
4
|
|
|
|
5
|
|
|
class SearchableField extends DataObject { |
6
|
|
|
private static $db = array( |
7
|
|
|
'Name' => 'Varchar', // the name of the field, e.g. Title |
8
|
|
|
'ClazzName' => 'Varchar', // the ClassName this field belongs to |
9
|
|
|
'Type' => 'Varchar', // the elasticsearch indexing type, |
10
|
|
|
'ShowHighlights' => 'Boolean', // calculate highlights in Elasticsearch |
11
|
|
|
'Autocomplete' => 'Boolean', // Use this to check for autocomplete fields, |
12
|
|
|
'IsInSiteTree' => 'Boolean' // Set to true if this field originates from a SiteTree object |
13
|
|
|
); |
14
|
|
|
|
15
|
|
|
|
16
|
|
|
private static $belongs_many_many = array( |
|
|
|
|
17
|
|
|
'ElasticSearchPages' => 'ElasticSearchPage' |
18
|
|
|
); |
19
|
|
|
|
20
|
|
|
private static $has_one = array('SearchableClass' => 'SearchableClass'); |
21
|
|
|
|
22
|
|
|
private static $display_fields = array('Name'); |
|
|
|
|
23
|
|
|
|
24
|
|
|
|
25
|
|
|
public function getCMSFields() { |
26
|
|
|
$fields = new FieldList(); |
27
|
|
|
$fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) ); |
28
|
|
|
$mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) ); |
29
|
|
|
$fields->addFieldToTab( 'Root.Main', $cf = new TextField( 'ClazzName', 'Class sourced from') ); |
30
|
|
|
$fields->addFieldToTab( 'Root.Main', $nf = new TextField( 'Name', 'Name') ); |
31
|
|
|
$cf->setDisabled(true); |
32
|
|
|
$nf->setDisabled(true); |
33
|
|
|
$cf->setReadOnly(true); |
34
|
|
|
$nf->setReadOnly(true); |
35
|
|
|
|
36
|
|
|
return $fields; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/* |
40
|
|
|
Deletion/inactivity is handled by scripts. Not end user deletable |
41
|
|
|
*/ |
42
|
|
|
public function canDelete($member = null) { |
43
|
|
|
return false; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/* |
47
|
|
|
Creation is handled by scripts at build time, not end user creatable |
48
|
|
|
*/ |
49
|
|
|
public function canCreate($member = null) { |
50
|
|
|
return false; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
public function HumanReadableSearchable() { |
55
|
|
|
echo $this->Searchable; |
|
|
|
|
56
|
|
|
return ElasticaUtil::showBooleanHumanReadable($this->Searchable); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
This check marks private properties in classes that are never used. Those properties can be removed.