@@ -17,245 +17,245 @@ |
||
17 | 17 | class Location extends DataObject implements PermissionProvider |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - private static $db = array( |
|
24 | - 'Title' => 'Varchar(255)', |
|
25 | - 'Featured' => 'Boolean', |
|
26 | - 'Website' => 'Varchar(255)', |
|
27 | - 'Phone' => 'Varchar(40)', |
|
28 | - 'Email' => 'Varchar(255)', |
|
29 | - 'EmailAddress' => 'Varchar(255)', |
|
30 | - 'ShowInLocator' => 'Boolean', |
|
31 | - 'Import_ID' => 'Int', |
|
32 | - ); |
|
20 | + /** |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + private static $db = array( |
|
24 | + 'Title' => 'Varchar(255)', |
|
25 | + 'Featured' => 'Boolean', |
|
26 | + 'Website' => 'Varchar(255)', |
|
27 | + 'Phone' => 'Varchar(40)', |
|
28 | + 'Email' => 'Varchar(255)', |
|
29 | + 'EmailAddress' => 'Varchar(255)', |
|
30 | + 'ShowInLocator' => 'Boolean', |
|
31 | + 'Import_ID' => 'Int', |
|
32 | + ); |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var array |
|
36 | - */ |
|
37 | - private static $has_one = array( |
|
38 | - 'Category' => 'LocationCategory', |
|
39 | - ); |
|
34 | + /** |
|
35 | + * @var array |
|
36 | + */ |
|
37 | + private static $has_one = array( |
|
38 | + 'Category' => 'LocationCategory', |
|
39 | + ); |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - private static $casting = array( |
|
45 | - 'distance' => 'Decimal(9,3)', |
|
46 | - ); |
|
41 | + /** |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + private static $casting = array( |
|
45 | + 'distance' => 'Decimal(9,3)', |
|
46 | + ); |
|
47 | 47 | |
48 | - /** |
|
49 | - * @var string |
|
50 | - */ |
|
51 | - private static $default_sort = 'Title'; |
|
48 | + /** |
|
49 | + * @var string |
|
50 | + */ |
|
51 | + private static $default_sort = 'Title'; |
|
52 | 52 | |
53 | - /** |
|
54 | - * @var array |
|
55 | - */ |
|
56 | - private static $defaults = array( |
|
57 | - 'ShowInLocator' => true, |
|
58 | - ); |
|
53 | + /** |
|
54 | + * @var array |
|
55 | + */ |
|
56 | + private static $defaults = array( |
|
57 | + 'ShowInLocator' => true, |
|
58 | + ); |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - private static $singular_name = 'Location'; |
|
64 | - /** |
|
65 | - * @var string |
|
66 | - */ |
|
67 | - private static $plural_name = 'Locations'; |
|
60 | + /** |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + private static $singular_name = 'Location'; |
|
64 | + /** |
|
65 | + * @var string |
|
66 | + */ |
|
67 | + private static $plural_name = 'Locations'; |
|
68 | 68 | |
69 | - /** |
|
70 | - * api access via Restful Server module |
|
71 | - * |
|
72 | - * @var bool |
|
73 | - */ |
|
74 | - private static $api_access = true; |
|
69 | + /** |
|
70 | + * api access via Restful Server module |
|
71 | + * |
|
72 | + * @var bool |
|
73 | + */ |
|
74 | + private static $api_access = true; |
|
75 | 75 | |
76 | - /** |
|
77 | - * search fields for Model Admin |
|
78 | - * |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - private static $searchable_fields = array( |
|
82 | - 'Title', |
|
83 | - 'Address', |
|
84 | - 'Suburb', |
|
85 | - 'State', |
|
86 | - 'Postcode', |
|
87 | - 'Country', |
|
88 | - 'Website', |
|
89 | - 'Phone', |
|
90 | - 'Email', |
|
91 | - 'Category.ID', |
|
92 | - 'ShowInLocator', |
|
93 | - 'Featured', |
|
94 | - ); |
|
76 | + /** |
|
77 | + * search fields for Model Admin |
|
78 | + * |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + private static $searchable_fields = array( |
|
82 | + 'Title', |
|
83 | + 'Address', |
|
84 | + 'Suburb', |
|
85 | + 'State', |
|
86 | + 'Postcode', |
|
87 | + 'Country', |
|
88 | + 'Website', |
|
89 | + 'Phone', |
|
90 | + 'Email', |
|
91 | + 'Category.ID', |
|
92 | + 'ShowInLocator', |
|
93 | + 'Featured', |
|
94 | + ); |
|
95 | 95 | |
96 | - /** |
|
97 | - * columns for grid field |
|
98 | - * |
|
99 | - * @var array |
|
100 | - */ |
|
101 | - private static $summary_fields = array( |
|
102 | - 'Title', |
|
103 | - 'Address', |
|
104 | - 'Suburb', |
|
105 | - 'State', |
|
106 | - 'Postcode', |
|
107 | - 'Country', |
|
108 | - 'Category.Name', |
|
109 | - 'ShowInLocator.NiceAsBoolean', |
|
110 | - 'Featured.NiceAsBoolean', |
|
111 | - 'Coords', |
|
112 | - ); |
|
96 | + /** |
|
97 | + * columns for grid field |
|
98 | + * |
|
99 | + * @var array |
|
100 | + */ |
|
101 | + private static $summary_fields = array( |
|
102 | + 'Title', |
|
103 | + 'Address', |
|
104 | + 'Suburb', |
|
105 | + 'State', |
|
106 | + 'Postcode', |
|
107 | + 'Country', |
|
108 | + 'Category.Name', |
|
109 | + 'ShowInLocator.NiceAsBoolean', |
|
110 | + 'Featured.NiceAsBoolean', |
|
111 | + 'Coords', |
|
112 | + ); |
|
113 | 113 | |
114 | - /** |
|
115 | - * Coords status for $summary_fields |
|
116 | - * |
|
117 | - * @return string |
|
118 | - */ |
|
119 | - public function getCoords() |
|
120 | - { |
|
121 | - return ($this->Lat != 0 && $this->Lng != 0) ? 'true' : 'false'; |
|
122 | - } |
|
114 | + /** |
|
115 | + * Coords status for $summary_fields |
|
116 | + * |
|
117 | + * @return string |
|
118 | + */ |
|
119 | + public function getCoords() |
|
120 | + { |
|
121 | + return ($this->Lat != 0 && $this->Lng != 0) ? 'true' : 'false'; |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * custom labels for fields |
|
126 | - * |
|
127 | - * @param bool $includerelations |
|
128 | - * @return array|string |
|
129 | - */ |
|
130 | - public function fieldLabels($includerelations = true) |
|
131 | - { |
|
132 | - $labels = parent::fieldLabels($includerelations); |
|
124 | + /** |
|
125 | + * custom labels for fields |
|
126 | + * |
|
127 | + * @param bool $includerelations |
|
128 | + * @return array|string |
|
129 | + */ |
|
130 | + public function fieldLabels($includerelations = true) |
|
131 | + { |
|
132 | + $labels = parent::fieldLabels($includerelations); |
|
133 | 133 | |
134 | - $labels['Title'] = 'Name'; |
|
135 | - $labels['Suburb'] = 'City'; |
|
136 | - $labels['Postcode'] = 'Postal Code'; |
|
137 | - $labels['ShowInLocator'] = 'Show'; |
|
138 | - $labels['ShowInLocator.NiceAsBoolean'] = 'Show'; |
|
139 | - $labels['Category.Name'] = 'Category'; |
|
140 | - $labels['Category.ID'] = 'Category'; |
|
141 | - $labels['Email'] = 'Email'; |
|
142 | - $labels['Featured.NiceAsBoolean'] = 'Featured'; |
|
143 | - $labels['Coords'] = 'Coords'; |
|
134 | + $labels['Title'] = 'Name'; |
|
135 | + $labels['Suburb'] = 'City'; |
|
136 | + $labels['Postcode'] = 'Postal Code'; |
|
137 | + $labels['ShowInLocator'] = 'Show'; |
|
138 | + $labels['ShowInLocator.NiceAsBoolean'] = 'Show'; |
|
139 | + $labels['Category.Name'] = 'Category'; |
|
140 | + $labels['Category.ID'] = 'Category'; |
|
141 | + $labels['Email'] = 'Email'; |
|
142 | + $labels['Featured.NiceAsBoolean'] = 'Featured'; |
|
143 | + $labels['Coords'] = 'Coords'; |
|
144 | 144 | |
145 | - return $labels; |
|
146 | - } |
|
145 | + return $labels; |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * @return FieldList |
|
150 | - */ |
|
151 | - public function getCMSFields() |
|
152 | - { |
|
153 | - $fields = FieldList::create( |
|
154 | - new TabSet( |
|
155 | - $name = 'Root', |
|
156 | - new Tab( |
|
157 | - $title = 'Main', |
|
158 | - HeaderField::create('ContactHD', 'Contact Information'), |
|
159 | - TextField::create('Title', 'Name'), |
|
160 | - TextField::create('Phone'), |
|
161 | - EmailField::create('Email', 'Email'), |
|
162 | - TextField::create('Website') |
|
163 | - ->setAttribute('placeholder', 'http://'), |
|
164 | - DropdownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title')) |
|
165 | - ->setEmptyString('-- select --'), |
|
166 | - CheckboxField::create('ShowInLocator', 'Show in results') |
|
167 | - ->setDescription('Location will be included in results list'), |
|
168 | - CheckboxField::create('Featured') |
|
169 | - ->setDescription('Location will show at/near the top of the results list') |
|
170 | - ) |
|
171 | - ) |
|
172 | - ); |
|
148 | + /** |
|
149 | + * @return FieldList |
|
150 | + */ |
|
151 | + public function getCMSFields() |
|
152 | + { |
|
153 | + $fields = FieldList::create( |
|
154 | + new TabSet( |
|
155 | + $name = 'Root', |
|
156 | + new Tab( |
|
157 | + $title = 'Main', |
|
158 | + HeaderField::create('ContactHD', 'Contact Information'), |
|
159 | + TextField::create('Title', 'Name'), |
|
160 | + TextField::create('Phone'), |
|
161 | + EmailField::create('Email', 'Email'), |
|
162 | + TextField::create('Website') |
|
163 | + ->setAttribute('placeholder', 'http://'), |
|
164 | + DropdownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title')) |
|
165 | + ->setEmptyString('-- select --'), |
|
166 | + CheckboxField::create('ShowInLocator', 'Show in results') |
|
167 | + ->setDescription('Location will be included in results list'), |
|
168 | + CheckboxField::create('Featured') |
|
169 | + ->setDescription('Location will show at/near the top of the results list') |
|
170 | + ) |
|
171 | + ) |
|
172 | + ); |
|
173 | 173 | |
174 | - // allow to be extended via DataExtension |
|
175 | - $this->extend('updateCMSFields', $fields); |
|
174 | + // allow to be extended via DataExtension |
|
175 | + $this->extend('updateCMSFields', $fields); |
|
176 | 176 | |
177 | - // override Suburb field name |
|
178 | - $fields->dataFieldByName('Suburb')->setTitle('City'); |
|
177 | + // override Suburb field name |
|
178 | + $fields->dataFieldByName('Suburb')->setTitle('City'); |
|
179 | 179 | |
180 | - $fields->removeByName(array( |
|
181 | - 'Import_ID', |
|
182 | - )); |
|
180 | + $fields->removeByName(array( |
|
181 | + 'Import_ID', |
|
182 | + )); |
|
183 | 183 | |
184 | - return $fields; |
|
185 | - } |
|
184 | + return $fields; |
|
185 | + } |
|
186 | 186 | |
187 | - /** |
|
188 | - * @return ValidationResult |
|
189 | - */ |
|
190 | - public function validate() |
|
191 | - { |
|
192 | - $result = parent::validate(); |
|
187 | + /** |
|
188 | + * @return ValidationResult |
|
189 | + */ |
|
190 | + public function validate() |
|
191 | + { |
|
192 | + $result = parent::validate(); |
|
193 | 193 | |
194 | - return $result; |
|
195 | - } |
|
194 | + return $result; |
|
195 | + } |
|
196 | 196 | |
197 | - /** |
|
198 | - * @return bool|string |
|
199 | - */ |
|
200 | - public function EmailAddress() |
|
201 | - { |
|
202 | - Deprecation::notice('3.0', 'Use "$Email" instead.'); |
|
203 | - if ($this->Email) { |
|
204 | - return $this->Email; |
|
205 | - } elseif ($this->EmailAddress) { |
|
206 | - return $this->EmailAddress; |
|
207 | - } |
|
197 | + /** |
|
198 | + * @return bool|string |
|
199 | + */ |
|
200 | + public function EmailAddress() |
|
201 | + { |
|
202 | + Deprecation::notice('3.0', 'Use "$Email" instead.'); |
|
203 | + if ($this->Email) { |
|
204 | + return $this->Email; |
|
205 | + } elseif ($this->EmailAddress) { |
|
206 | + return $this->EmailAddress; |
|
207 | + } |
|
208 | 208 | |
209 | - return false; |
|
210 | - } |
|
209 | + return false; |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @param null|Member $member |
|
214 | - * |
|
215 | - * @return bool |
|
216 | - */ |
|
217 | - public function canView($member = null) |
|
218 | - { |
|
219 | - return true; |
|
220 | - } |
|
212 | + /** |
|
213 | + * @param null|Member $member |
|
214 | + * |
|
215 | + * @return bool |
|
216 | + */ |
|
217 | + public function canView($member = null) |
|
218 | + { |
|
219 | + return true; |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * @param null|Member $member |
|
224 | - * @return bool|int |
|
225 | - */ |
|
226 | - public function canEdit($member = null) |
|
227 | - { |
|
228 | - return Permission::check('Location_EDIT', 'any', $member); |
|
229 | - } |
|
222 | + /** |
|
223 | + * @param null|Member $member |
|
224 | + * @return bool|int |
|
225 | + */ |
|
226 | + public function canEdit($member = null) |
|
227 | + { |
|
228 | + return Permission::check('Location_EDIT', 'any', $member); |
|
229 | + } |
|
230 | 230 | |
231 | - /** |
|
232 | - * @param null|Member $member |
|
233 | - * @return bool|int |
|
234 | - */ |
|
235 | - public function canDelete($member = null) |
|
236 | - { |
|
237 | - return Permission::check('Location_DELETE', 'any', $member); |
|
238 | - } |
|
231 | + /** |
|
232 | + * @param null|Member $member |
|
233 | + * @return bool|int |
|
234 | + */ |
|
235 | + public function canDelete($member = null) |
|
236 | + { |
|
237 | + return Permission::check('Location_DELETE', 'any', $member); |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * @param null|Member $member |
|
242 | - * @return bool|int |
|
243 | - */ |
|
244 | - public function canCreate($member = null) |
|
245 | - { |
|
246 | - return Permission::check('Location_CREATE', 'any', $member); |
|
247 | - } |
|
240 | + /** |
|
241 | + * @param null|Member $member |
|
242 | + * @return bool|int |
|
243 | + */ |
|
244 | + public function canCreate($member = null) |
|
245 | + { |
|
246 | + return Permission::check('Location_CREATE', 'any', $member); |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * @return array |
|
251 | - */ |
|
252 | - public function providePermissions() |
|
253 | - { |
|
254 | - return array( |
|
255 | - 'Location_EDIT' => 'Edit a Location', |
|
256 | - 'Location_DELETE' => 'Delete a Location', |
|
257 | - 'Location_CREATE' => 'Create a Location', |
|
258 | - ); |
|
259 | - } |
|
249 | + /** |
|
250 | + * @return array |
|
251 | + */ |
|
252 | + public function providePermissions() |
|
253 | + { |
|
254 | + return array( |
|
255 | + 'Location_EDIT' => 'Edit a Location', |
|
256 | + 'Location_DELETE' => 'Delete a Location', |
|
257 | + 'Location_CREATE' => 'Create a Location', |
|
258 | + ); |
|
259 | + } |
|
260 | 260 | |
261 | 261 | } |