1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @package elemental |
5
|
|
|
*/ |
6
|
|
|
class ElementContact extends BaseElement |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
|
9
|
|
|
private static $db = array( |
|
|
|
|
10
|
|
|
'ContactName' => 'Varchar(255)', |
11
|
|
|
'Phone' => 'Varchar(100)', |
12
|
|
|
'Mobile' => 'Varchar(100)', |
13
|
|
|
'Fax' => 'Varchar(100)', |
14
|
|
|
'Email' => 'Varchar(255)', |
15
|
|
|
'Website' => 'Varchar(255)', |
16
|
|
|
); |
17
|
|
|
|
18
|
|
|
private static $extensions = array( |
|
|
|
|
19
|
|
|
'Addressable', |
20
|
|
|
'Geocodable' |
21
|
|
|
); |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private static $title = "Contact Element"; |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @return FieldList |
30
|
|
|
*/ |
31
|
|
|
public function getCMSFields() |
32
|
|
|
{ |
33
|
|
|
$this->beforeUpdateCMSFields(function ($fields) { |
34
|
|
|
$fields->addFieldsToTab('Root.Main', array( |
35
|
|
|
Textfield::create('ContactName', 'Name'), |
36
|
|
|
TextField::create('Phone', 'Phone'), |
37
|
|
|
TextField::create('Mobile', 'Mobile'), |
38
|
|
|
TextField::create('Fax', 'Fax'), |
39
|
|
|
EmailField::create('Email', 'Email'), |
40
|
|
|
$website = TextField::create('Website', 'Website') |
41
|
|
|
)); |
42
|
|
|
|
43
|
|
|
$website->setRightTitle('e.g '.Director::absoluteBaseURL()); |
44
|
|
|
}); |
45
|
|
|
|
46
|
|
|
return parent::getCMSFields(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Return the obfuscated email. |
51
|
|
|
* |
52
|
|
|
* @return string |
|
|
|
|
53
|
|
|
*/ |
54
|
|
|
public function ObfuscatedEmail() |
55
|
|
|
{ |
56
|
|
|
return ($this->Email) ? Email::obfuscate($this->Email, 'hex') : null; |
|
|
|
|
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
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.