|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Contact extends DataObject |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
private static $db = array( |
|
|
|
|
|
|
6
|
|
|
'FirstName' => 'Varchar(50)', |
|
7
|
|
|
'Surname' => 'Varchar(50)', |
|
8
|
|
|
'Email' => 'EmailAddress', |
|
9
|
|
|
'BusinessName' => 'Varchar(50)', |
|
10
|
|
|
'Website' => 'Varchar(50)', |
|
11
|
|
|
'IsProfessional' => 'Boolean', |
|
12
|
|
|
'IsVisible' => 'Boolean', |
|
13
|
|
|
'IsHighlighted' => 'Boolean', |
|
14
|
|
|
'Reference' => 'Varchar(50)' |
|
15
|
|
|
); |
|
16
|
|
|
|
|
17
|
|
|
private static $has_one = array( |
|
|
|
|
|
|
18
|
|
|
'Location' => 'ContactLocation', |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
private static $many_many = array( |
|
|
|
|
|
|
22
|
|
|
'Type' => 'ContactCategory' |
|
23
|
|
|
); |
|
24
|
|
|
|
|
25
|
|
|
private static $summary_fields = array( |
|
|
|
|
|
|
26
|
|
|
'Title' => 'Name', |
|
27
|
|
|
'BusinessName' => 'BusinessName' |
|
28
|
|
|
); |
|
29
|
|
|
|
|
30
|
|
|
private static $field_labels = array( |
|
|
|
|
|
|
31
|
|
|
'LocationID' => 'Locationnnn' |
|
32
|
|
|
); |
|
33
|
|
|
|
|
34
|
|
|
private static $searchable_fields = array( |
|
|
|
|
|
|
35
|
|
|
'Email' => 'PartialMatchFilter', |
|
36
|
|
|
'FirstName' => 'PartialMatchFilter', |
|
37
|
|
|
'Surname' => 'PartialMatchFilter', |
|
38
|
|
|
'BusinessName' => 'PartialMatchFilter', |
|
39
|
|
|
'Website' => 'PartialMatchFilter', |
|
40
|
|
|
'IsProfessional' => 'ExactMatchFilter', |
|
41
|
|
|
'IsVisible' => 'ExactMatchFilter', |
|
42
|
|
|
'IsHighlighted' => 'ExactMatchFilter', |
|
43
|
|
|
'Reference' => 'PartialMatchFilter' |
|
44
|
|
|
); |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @inherited |
|
48
|
|
|
*/ |
|
49
|
|
|
private static $casting = array( |
|
|
|
|
|
|
50
|
|
|
'Title' => "Varchar" |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inherited |
|
55
|
|
|
*/ |
|
56
|
|
|
private static $default_sort = array( |
|
|
|
|
|
|
57
|
|
|
'BusinessName' => "ASC" |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
private static $singular_name = 'Contact'; |
|
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
private static $plural_name = 'Contacts'; |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @return String |
|
66
|
|
|
*/ |
|
67
|
|
|
public function Title() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->getTitle(); |
|
70
|
|
|
} |
|
71
|
|
|
public function getTitle() |
|
72
|
|
|
{ |
|
73
|
|
|
return implode(' ', array($this->FirstName, $this->Surname)); |
|
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function getCMSFields() |
|
77
|
|
|
{ |
|
78
|
|
|
$fields = parent::getCMSfields(); |
|
79
|
|
|
$locationField = $fields->dataFieldByName('LocationID'); |
|
80
|
|
|
$fields->replaceField( |
|
81
|
|
|
'LocationID', |
|
82
|
|
|
DropdownField::create('LocationID', $locationField->Title(), ContactLocation::get()->map()) |
|
83
|
|
|
); |
|
84
|
|
|
return $fields; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.