1 | <?php |
||
11 | class SubsiteDomain extends DataObject |
||
12 | { |
||
13 | /** |
||
14 | * |
||
15 | * @var array |
||
16 | */ |
||
17 | private static $db = array( |
||
|
|||
18 | "Domain" => "Varchar(255)", |
||
19 | "Protocol" => "Enum('http,https,automatic','automatic')", |
||
20 | "IsPrimary" => "Boolean", |
||
21 | ); |
||
22 | |||
23 | /** |
||
24 | * Specifies that this subsite is http only |
||
25 | */ |
||
26 | const PROTOCOL_HTTP = 'http'; |
||
27 | |||
28 | /** |
||
29 | * Specifies that this subsite is https only |
||
30 | */ |
||
31 | const PROTOCOL_HTTPS = 'https'; |
||
32 | |||
33 | /** |
||
34 | * Specifies that this subsite supports both http and https |
||
35 | */ |
||
36 | const PROTOCOL_AUTOMATIC = 'automatic'; |
||
37 | |||
38 | /** |
||
39 | * Get the descriptive title for this domain |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | public function getTitle() |
||
47 | |||
48 | /** |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | private static $has_one = array( |
||
53 | "Subsite" => "Subsite", |
||
54 | ); |
||
55 | |||
56 | /** |
||
57 | * @config |
||
58 | * @var array |
||
59 | */ |
||
60 | private static $summary_fields = array( |
||
61 | 'Domain', |
||
62 | 'IsPrimary', |
||
63 | ); |
||
64 | |||
65 | /** |
||
66 | * @config |
||
67 | * @var array |
||
68 | */ |
||
69 | private static $casting = array( |
||
70 | 'SubstitutedDomain' => 'Varchar', |
||
71 | 'FullProtocol' => 'Varchar', |
||
72 | 'AbsoluteLink' => 'Varchar', |
||
73 | ); |
||
74 | |||
75 | /** |
||
76 | * Whenever a Subsite Domain is written, rewrite the hostmap |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | public function onAfterWrite() |
||
84 | |||
85 | /** |
||
86 | * |
||
87 | * @return \FieldList |
||
88 | */ |
||
89 | public function getCMSFields() |
||
119 | |||
120 | /** |
||
121 | * |
||
122 | * @param bool $includerelations |
||
123 | * @return array |
||
124 | */ |
||
125 | public function fieldLabels($includerelations = true) |
||
134 | |||
135 | /** |
||
136 | * Get the link to this subsite |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | public function Link() |
||
144 | |||
145 | /** |
||
146 | * Gets the full protocol (including ://) for this domain |
||
147 | * |
||
148 | * @return string |
||
149 | */ |
||
150 | public function getFullProtocol() |
||
167 | |||
168 | /** |
||
169 | * Retrieves domain name with wildcards substituted with actual values |
||
170 | * |
||
171 | * @todo Refactor domains into separate wildcards / primary domains |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getSubstitutedDomain() |
||
192 | |||
193 | /** |
||
194 | * Get absolute link for this domain |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | public function getAbsoluteLink() |
||
202 | |||
203 | /** |
||
204 | * Get absolute baseURL for this domain |
||
205 | * |
||
206 | * @return string |
||
207 | */ |
||
208 | public function absoluteBaseURL() |
||
215 | } |
||
216 |