1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @property text Domain domain name of this subsite. Do not include the URL scheme here |
5
|
|
|
* @property bool IsPrimary Is this the primary subdomain? |
6
|
|
|
*/ |
7
|
|
|
class SubsiteDomain extends DataObject |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* |
11
|
|
|
* @var array |
12
|
|
|
*/ |
13
|
|
|
private static $db = array( |
|
|
|
|
14
|
|
|
"Domain" => "Varchar(255)", |
15
|
|
|
"IsPrimary" => "Boolean", |
16
|
|
|
); |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
private static $has_one = array( |
|
|
|
|
23
|
|
|
"Subsite" => "Subsite", |
24
|
|
|
); |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* |
28
|
|
|
* @var array |
29
|
|
|
*/ |
30
|
|
|
private static $summary_fields=array( |
|
|
|
|
31
|
|
|
'Domain', |
32
|
|
|
'IsPrimary', |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Whenever a Subsite Domain is written, rewrite the hostmap |
37
|
|
|
* |
38
|
|
|
* @return void |
39
|
|
|
*/ |
40
|
|
|
public function onAfterWrite() |
41
|
|
|
{ |
42
|
|
|
Subsite::writeHostMap(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* |
47
|
|
|
* @return \FieldList |
48
|
|
|
*/ |
49
|
|
|
public function getCMSFields() |
50
|
|
|
{ |
51
|
|
|
$fields = new FieldList( |
52
|
|
|
new TextField('Domain', $this->fieldLabel('Domain'), null, 255), |
53
|
|
|
new CheckboxField('IsPrimary', $this->fieldLabel('IsPrimary')) |
54
|
|
|
); |
55
|
|
|
|
56
|
|
|
$this->extend('updateCMSFields', $fields); |
57
|
|
|
return $fields; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* |
62
|
|
|
* @param bool $includerelations |
63
|
|
|
* @return array |
64
|
|
|
*/ |
65
|
|
|
public function fieldLabels($includerelations = true) |
66
|
|
|
{ |
67
|
|
|
$labels = parent::fieldLabels($includerelations); |
68
|
|
|
$labels['Domain'] = _t('SubsiteDomain.DOMAIN', 'Domain'); |
69
|
|
|
$labels['IsPrimary'] = _t('SubsiteDomain.IS_PRIMARY', 'Is Primary Domain'); |
70
|
|
|
|
71
|
|
|
return $labels; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Before writing the Subsite Domain, strip out any HTML the user has entered. |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
|
|
public function onBeforeWrite() |
79
|
|
|
{ |
80
|
|
|
parent::onBeforeWrite(); |
81
|
|
|
|
82
|
|
|
//strip out any HTML to avoid XSS attacks |
83
|
|
|
$this->Domain = Convert::html2raw($this->Domain); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|