Completed
Pull Request — master (#88)
by Jason
02:47
created
code/Locator.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -220,7 +220,7 @@
 block discarded – undo
220 220
 
221 221
     /**
222 222
      * @param array $searchCriteria
223
-     * @return mixed
223
+     * @return Locator_Controller
224 224
      */
225 225
     public function Items($searchCriteria = array())
226 226
     {
Please login to merge, or discard this patch.
Spacing   +17 added lines, -21 removed lines patch added patch discarded remove patch
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
         Requirements::javascript('framework/thirdparty/jquery/jquery.js');
137 137
         if (Locator::getLocations()) {
138
-            Requirements::javascript('http://maps.google.com/maps/api/js?key='.$key);
138
+            Requirements::javascript('http://maps.google.com/maps/api/js?key=' . $key);
139 139
             Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
140 140
             Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
141 141
         }
@@ -143,24 +143,20 @@  discard block
 block discarded – undo
143 143
         Requirements::css('locator/css/map.css');
144 144
 
145 145
         $featured = (Locator::getLocations(array('Featured' => 1))->count() > 0) ?
146
-            'featuredLocations: true' :
147
-            'featuredLocations: false';
146
+            'featuredLocations: true' : 'featuredLocations: false';
148 147
 
149 148
         // map config based on user input in Settings tab
150 149
         // AutoGeocode or Full Map
151 150
         $load = ($this->data()->AutoGeocode) ?
152
-            'autoGeocode: true, fullMapStart: false,' :
153
-            'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,';
151
+            'autoGeocode: true, fullMapStart: false,' : 'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,';
154 152
 
155 153
         $base = Director::baseFolder();
156
-        $themePath = $base.'/'.$themeDir;
154
+        $themePath = $base . '/' . $themeDir;
157 155
 
158
-        $listTemplatePath = (file_exists($themePath.'/templates/location-list-description.html')) ?
159
-            $themeDir.'/templates/location-list-description.html' :
160
-            'locator/templates/location-list-description.html';
161
-        $infowindowTemplatePath = (file_exists($themePath.'/templates/infowindow-description.html')) ?
162
-            $themeDir.'/templates/infowindow-description.html' :
163
-            'locator/templates/infowindow-description.html';
156
+        $listTemplatePath = (file_exists($themePath . '/templates/location-list-description.html')) ?
157
+            $themeDir . '/templates/location-list-description.html' : 'locator/templates/location-list-description.html';
158
+        $infowindowTemplatePath = (file_exists($themePath . '/templates/infowindow-description.html')) ?
159
+            $themeDir . '/templates/infowindow-description.html' : 'locator/templates/infowindow-description.html';
164 160
 
165 161
         // in page or modal
166 162
         $modal = ($this->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false';
@@ -172,22 +168,22 @@  discard block
 block discarded – undo
172 168
         unset($vars['url']);
173 169
         $url = '';
174 170
         if (count($vars)) {
175
-            $url .= '?'.http_build_query($vars);
171
+            $url .= '?' . http_build_query($vars);
176 172
         }
177
-        $link = $this->Link().'xml.xml'.$url;
173
+        $link = $this->Link() . 'xml.xml' . $url;
178 174
 
179 175
         // init map
180 176
         if (Locator::getLocations()) {
181 177
             Requirements::customScript("
182 178
                 $(function($) {
183 179
                     $('#map-container').storeLocator({
184
-                        ".$load."
185
-                        dataLocation: '".$link."',
186
-                        listTemplatePath: '".$listTemplatePath."',
187
-                        infowindowTemplatePath: '".$infowindowTemplatePath."',
180
+                        ".$load . "
181
+                        dataLocation: '".$link . "',
182
+                        listTemplatePath: '".$listTemplatePath . "',
183
+                        infowindowTemplatePath: '".$infowindowTemplatePath . "',
188 184
                         originMarker: true,
189
-                        ".$modal.',
190
-                        '.$featured.",
185
+                        ".$modal . ',
186
+                        '.$featured . ",
191 187
                         slideMap: false,
192 188
                         zoomLevel: 0,
193 189
                         distanceAlert: 120,
@@ -196,7 +192,7 @@  discard block
 block discarded – undo
196 192
                         inputID: 'Form_LocationSearch_Address',
197 193
                         categoryID: 'Form_LocationSearch_CategoryID',
198 194
                         distanceAlert: -1,
199
-                        ".$kilometer.'
195
+                        ".$kilometer . '
200 196
                     });
201 197
                 });
202 198
             ');
Please login to merge, or discard this patch.
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -2,189 +2,189 @@  discard block
 block discarded – undo
2 2
 
3 3
 class Locator extends Page
4 4
 {
5
-    private static $db = array(
6
-        'AutoGeocode' => 'Boolean',
7
-        'ModalWindow' => 'Boolean',
8
-        'Unit' => 'Enum("m,km","m")',
9
-    );
10
-
11
-    private static $many_many = array(
12
-        'Categories' => 'LocationCategory',
13
-    );
14
-
15
-    private static $defaults = array(
16
-        'AutoGeocode' => true,
17
-    );
18
-
19
-    private static $singular_name = 'Locator';
20
-    private static $plural_name = 'Locators';
21
-    private static $description = 'Find locations on a map';
22
-
23
-    /**
24
-     * @return FieldList
25
-     */
26
-    public function getCMSFields()
27
-    {
28
-        $fields = parent::getCMSFields();
29
-
30
-        // Settings
31
-        $fields->addFieldsToTab('Root.Settings', array(
32
-            HeaderField::create('DisplayOptions', 'Display Options', 3),
33
-            OptionsetField::create('Unit', 'Unit of measure', array('m' => 'Miles', 'km' => 'Kilometers')),
34
-            CheckboxField::create('AutoGeocode', 'Auto Geocode - Automatically filter map results based on user location')
35
-                ->setDescription('Note: if any locations are set as featured, the auto geocode is automatically disabled.'),
36
-            CheckboxField::create('ModalWindow', 'Modal Window - Show Map results in a modal window'),
37
-        ));
38
-
39
-        // Filter categories
40
-        $config = GridFieldConfig_RelationEditor::create();
41
-        if (class_exists('GridFieldAddExistingSearchButton')) {
42
-            $config->removeComponentsByType('GridFieldAddExistingAutocompleter');
43
-            $config->addComponent(new GridFieldAddExistingSearchButton());
44
-        }
45
-        $categories = $this->Categories();
46
-        $categoriesField = GridField::create('Categories', 'Categories', $categories, $config)
47
-            ->setDescription('only show locations from the selected category');
48
-
49
-            // Filter
50
-            $fields->addFieldsToTab('Root.Filter', array(
51
-                HeaderField::create('CategoryOptionsHeader', 'Location Filtering', 3),
52
-                $categoriesField,
53
-            ));
54
-
55
-        $this->extend('updateCMSFields', $fields);
56
-
57
-        return $fields;
58
-    }
59
-
60
-    /**
61
-     * @param array $filter
62
-     * @param array $filterAny
63
-     * @param array $exclude
64
-     * @param null $filterByCallback
65
-     * @return ArrayList
66
-     */
67
-    public static function locations(
68
-        $filter = array(),
69
-        $filterAny = array(),
70
-        $exclude = array(),
71
-        $filterByCallback = null
72
-    ) {
73
-        $locationsList = ArrayList::create();
74
-
75
-        $locations = Location::get()->filter($filter);
76
-
77
-        if (!empty($filterAny)) {
78
-            $locations = $locations->filterAny($filterAny);
79
-        }
80
-        if (!empty($exclude)) {
81
-            $locations = $locations->exclude($exclude);
82
-        }
83
-
84
-        if ($filterByCallback !== null && is_callable($filterByCallback)) {
85
-            $locations = $locations->filterByCallback($filterByCallback);
86
-        }
87
-
88
-        if ($locations->exists()) {
89
-            $locationsList->merge($locations);
90
-        }
91
-
92
-        return $locationsList;
93
-    }
94
-
95
-    /**
96
-     * @return DataList
97
-     */
98
-    public static function getAllCategories()
99
-    {
100
-        return LocationCategory::get();
101
-    }
102
-
103
-    /**
104
-     * @param null $id
105
-     * @return bool
106
-     */
107
-    public static function getPageCategories($id = null)
108
-    {
109
-        if ($id) {
110
-            if ($locator = self::get()->byID($id)) {
111
-                return $locator->Categories();
112
-            }
113
-
114
-            return false;
115
-        }
116
-
117
-        return false;
118
-    }
5
+	private static $db = array(
6
+		'AutoGeocode' => 'Boolean',
7
+		'ModalWindow' => 'Boolean',
8
+		'Unit' => 'Enum("m,km","m")',
9
+	);
10
+
11
+	private static $many_many = array(
12
+		'Categories' => 'LocationCategory',
13
+	);
14
+
15
+	private static $defaults = array(
16
+		'AutoGeocode' => true,
17
+	);
18
+
19
+	private static $singular_name = 'Locator';
20
+	private static $plural_name = 'Locators';
21
+	private static $description = 'Find locations on a map';
22
+
23
+	/**
24
+	 * @return FieldList
25
+	 */
26
+	public function getCMSFields()
27
+	{
28
+		$fields = parent::getCMSFields();
29
+
30
+		// Settings
31
+		$fields->addFieldsToTab('Root.Settings', array(
32
+			HeaderField::create('DisplayOptions', 'Display Options', 3),
33
+			OptionsetField::create('Unit', 'Unit of measure', array('m' => 'Miles', 'km' => 'Kilometers')),
34
+			CheckboxField::create('AutoGeocode', 'Auto Geocode - Automatically filter map results based on user location')
35
+				->setDescription('Note: if any locations are set as featured, the auto geocode is automatically disabled.'),
36
+			CheckboxField::create('ModalWindow', 'Modal Window - Show Map results in a modal window'),
37
+		));
38
+
39
+		// Filter categories
40
+		$config = GridFieldConfig_RelationEditor::create();
41
+		if (class_exists('GridFieldAddExistingSearchButton')) {
42
+			$config->removeComponentsByType('GridFieldAddExistingAutocompleter');
43
+			$config->addComponent(new GridFieldAddExistingSearchButton());
44
+		}
45
+		$categories = $this->Categories();
46
+		$categoriesField = GridField::create('Categories', 'Categories', $categories, $config)
47
+			->setDescription('only show locations from the selected category');
48
+
49
+			// Filter
50
+			$fields->addFieldsToTab('Root.Filter', array(
51
+				HeaderField::create('CategoryOptionsHeader', 'Location Filtering', 3),
52
+				$categoriesField,
53
+			));
54
+
55
+		$this->extend('updateCMSFields', $fields);
56
+
57
+		return $fields;
58
+	}
59
+
60
+	/**
61
+	 * @param array $filter
62
+	 * @param array $filterAny
63
+	 * @param array $exclude
64
+	 * @param null $filterByCallback
65
+	 * @return ArrayList
66
+	 */
67
+	public static function locations(
68
+		$filter = array(),
69
+		$filterAny = array(),
70
+		$exclude = array(),
71
+		$filterByCallback = null
72
+	) {
73
+		$locationsList = ArrayList::create();
74
+
75
+		$locations = Location::get()->filter($filter);
76
+
77
+		if (!empty($filterAny)) {
78
+			$locations = $locations->filterAny($filterAny);
79
+		}
80
+		if (!empty($exclude)) {
81
+			$locations = $locations->exclude($exclude);
82
+		}
83
+
84
+		if ($filterByCallback !== null && is_callable($filterByCallback)) {
85
+			$locations = $locations->filterByCallback($filterByCallback);
86
+		}
87
+
88
+		if ($locations->exists()) {
89
+			$locationsList->merge($locations);
90
+		}
91
+
92
+		return $locationsList;
93
+	}
94
+
95
+	/**
96
+	 * @return DataList
97
+	 */
98
+	public static function getAllCategories()
99
+	{
100
+		return LocationCategory::get();
101
+	}
102
+
103
+	/**
104
+	 * @param null $id
105
+	 * @return bool
106
+	 */
107
+	public static function getPageCategories($id = null)
108
+	{
109
+		if ($id) {
110
+			if ($locator = self::get()->byID($id)) {
111
+				return $locator->Categories();
112
+			}
113
+
114
+			return false;
115
+		}
116
+
117
+		return false;
118
+	}
119 119
 
120 120
 
121 121
 }
122 122
 
123 123
 class Locator_Controller extends Page_Controller
124 124
 {
125
-    // allowed actions
126
-    private static $allowed_actions = array(
127
-        'xml',
128
-    );
129
-
130
-    // Set Requirements based on input from CMS
131
-    public function init()
132
-    {
133
-        parent::init();
134
-
135
-        $themeDir = SSViewer::get_theme_folder();
136
-
137
-        // google maps api key
138
-        $key = Config::inst()->get('GoogleGeocoding', 'google_api_key');
139
-
140
-        $locations = $this->Items($this->request);
141
-
142
-        Requirements::javascript('framework/thirdparty/jquery/jquery.js');
143
-        if ($locations) {
144
-            Requirements::javascript('http://maps.google.com/maps/api/js?key='.$key);
145
-            Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
146
-            Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
147
-        }
148
-
149
-        Requirements::css('locator/css/map.css');
150
-
151
-        $featured = ($locations->filter(array('Featured' => 1))->count() > 0) ?
152
-            'featuredLocations: true' :
153
-            'featuredLocations: false';
154
-
155
-        // map config based on user input in Settings tab
156
-        // AutoGeocode or Full Map
157
-        $load = ($this->data()->AutoGeocode) ?
158
-            'autoGeocode: true, fullMapStart: false,' :
159
-            'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,';
160
-
161
-        $base = Director::baseFolder();
162
-        $themePath = $base.'/'.$themeDir;
163
-
164
-        $listTemplatePath = (file_exists($themePath.'/templates/location-list-description.html')) ?
165
-            $themeDir.'/templates/location-list-description.html' :
166
-            'locator/templates/location-list-description.html';
167
-        $infowindowTemplatePath = (file_exists($themePath.'/templates/infowindow-description.html')) ?
168
-            $themeDir.'/templates/infowindow-description.html' :
169
-            'locator/templates/infowindow-description.html';
170
-
171
-        // in page or modal
172
-        $modal = ($this->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false';
173
-
174
-        $kilometer = ($this->data()->Unit == 'km') ? 'lengthUnit: "km"' : 'lengthUnit: "m"';
175
-
176
-        // pass GET variables to xml action
177
-        $vars = $this->request->getVars();
178
-        unset($vars['url']);
179
-        $url = '';
180
-        if (count($vars)) {
181
-            $url .= '?'.http_build_query($vars);
182
-        }
183
-        $link = $this->Link().'xml.xml'.$url;
184
-
185
-        // init map
186
-        if ($locations) {
187
-            Requirements::customScript("
125
+	// allowed actions
126
+	private static $allowed_actions = array(
127
+		'xml',
128
+	);
129
+
130
+	// Set Requirements based on input from CMS
131
+	public function init()
132
+	{
133
+		parent::init();
134
+
135
+		$themeDir = SSViewer::get_theme_folder();
136
+
137
+		// google maps api key
138
+		$key = Config::inst()->get('GoogleGeocoding', 'google_api_key');
139
+
140
+		$locations = $this->Items($this->request);
141
+
142
+		Requirements::javascript('framework/thirdparty/jquery/jquery.js');
143
+		if ($locations) {
144
+			Requirements::javascript('http://maps.google.com/maps/api/js?key='.$key);
145
+			Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
146
+			Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
147
+		}
148
+
149
+		Requirements::css('locator/css/map.css');
150
+
151
+		$featured = ($locations->filter(array('Featured' => 1))->count() > 0) ?
152
+			'featuredLocations: true' :
153
+			'featuredLocations: false';
154
+
155
+		// map config based on user input in Settings tab
156
+		// AutoGeocode or Full Map
157
+		$load = ($this->data()->AutoGeocode) ?
158
+			'autoGeocode: true, fullMapStart: false,' :
159
+			'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,';
160
+
161
+		$base = Director::baseFolder();
162
+		$themePath = $base.'/'.$themeDir;
163
+
164
+		$listTemplatePath = (file_exists($themePath.'/templates/location-list-description.html')) ?
165
+			$themeDir.'/templates/location-list-description.html' :
166
+			'locator/templates/location-list-description.html';
167
+		$infowindowTemplatePath = (file_exists($themePath.'/templates/infowindow-description.html')) ?
168
+			$themeDir.'/templates/infowindow-description.html' :
169
+			'locator/templates/infowindow-description.html';
170
+
171
+		// in page or modal
172
+		$modal = ($this->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false';
173
+
174
+		$kilometer = ($this->data()->Unit == 'km') ? 'lengthUnit: "km"' : 'lengthUnit: "m"';
175
+
176
+		// pass GET variables to xml action
177
+		$vars = $this->request->getVars();
178
+		unset($vars['url']);
179
+		$url = '';
180
+		if (count($vars)) {
181
+			$url .= '?'.http_build_query($vars);
182
+		}
183
+		$link = $this->Link().'xml.xml'.$url;
184
+
185
+		// init map
186
+		if ($locations) {
187
+			Requirements::customScript("
188 188
                 $(function($) {
189 189
                     $('#map-container').storeLocator({
190 190
                         ".$load."
@@ -205,129 +205,129 @@  discard block
 block discarded – undo
205 205
                     });
206 206
                 });
207 207
             ');
208
-        }
209
-    }
210
-
211
-    /**
212
-     * @param SS_HTTPRequest $request
213
-     *
214
-     * @return ViewableData_Customised
215
-     */
216
-    public function index(SS_HTTPRequest $request)
217
-    {
218
-        $locations = $this->Items($request);
219
-
220
-        return $this->customise(array(
221
-            'Locations' => $locations,
222
-        ));
223
-    }
224
-
225
-    /**
226
-     * Return a XML feed of all locations marked "show in locator"
227
-     *
228
-     * @param SS_HTTPRequest $request
229
-     * @return HTMLText
230
-     */
231
-    public function xml(SS_HTTPRequest $request)
232
-    {
233
-        $locations = $this->Items($request);
234
-
235
-        return $this->customise(array(
236
-            'Locations' => $locations,
237
-        ))->renderWith('LocationXML');
238
-    }
239
-
240
-    /**
241
-     * @param array $searchCriteria
242
-     *
243
-     * @return mixed
244
-     */
245
-    public function Items($searchCriteria = array())
246
-    {
247
-        $request = ($this->request) ? $this->request : $this->parentController->getRequest();
248
-        if (empty($searchCriteria)) {
249
-            $searchCriteria = $request->requestVars();
250
-        }
251
-
252
-        $filter = array();
253
-        $filterAny = array();
254
-        $exclude = array();
255
-
256
-        // only show locations marked as ShowInLocator
257
-        $filter['ShowInLocator'] = 1;
258
-
259
-        // search across all address related fields
260
-        $address = ($request->getVar('Address')) ? $request->getVar('Address') : false;
261
-        if ($address) {
262
-            $filterAny['Address:PartialMatch'] = $address;
263
-            $filterAny['Suburb:PartialMatch'] = $address;
264
-            $filterAny['State:PartialMatch'] = $address;
265
-            $filterAny['Postcode:PartialMatch'] = $address;
266
-            $filterAny['Country:PartialMatch'] = $address;
267
-        }
268
-
269
-        $category = ($request->getVar('CategoryID')) ? $request->getVar('CategoryID') : false;
270
-        if ($category) {
271
-            $filter['CategoryID'] = $category;
272
-        }
273
-
274
-        $locations = Locator::locations($filter, $filterAny, $exclude);
275
-
276
-        return $locations;
277
-    }
278
-
279
-    /**
280
-     * LocationSearch form.
281
-     *
282
-     * Search form for locations, updates map and results list via AJAX
283
-     *
284
-     * @return Form
285
-     */
286
-    public function LocationSearch()
287
-    {
288
-        $fields = FieldList::create(
289
-            $address = TextField::create('Address', '')
290
-                ->setAttribute('placeholder', 'address or zip code')
291
-        );
292
-
293
-        $filterCategories = Locator::getPageCategories($this->ID);
294
-        $allCategories = Locator::getAllCategories();
295
-
296
-        if ($allCategories->Count() > 0) {
297
-            $categories = ArrayList::create();
298
-            if ($filterCategories->Count() > 0) {
299
-                if ($filterCategories->Count() != 1) {
300
-                    $categories = $filterCategories;
301
-                }
302
-            } else {
303
-                $categories = $allCategories;
304
-            }
305
-
306
-            if ($categories->count() > 0) {
307
-                $fields->push(
308
-                    DropdownField::create(
309
-                        'CategoryID',
310
-                        '',
311
-                        $categories->map()
312
-                    )->setEmptyString('All Categories'));
313
-            }
314
-        }
315
-
316
-        $actions = FieldList::create(
317
-            FormAction::create('index', 'Search')
318
-        );
319
-
320
-        if (class_exists('BootstrapForm')) {
321
-            $form = BootstrapForm::create($this, 'LocationSearch', $fields, $actions);
322
-        } else {
323
-            $form = Form::create($this, 'LocationSearch', $fields, $actions);
324
-        }
325
-
326
-        return $form
327
-            ->setFormMethod('GET')
328
-            ->setFormAction($this->Link())
329
-            ->disableSecurityToken()
330
-            ->loadDataFrom($this->request->getVars())
331
-        ;
332
-    }
208
+		}
209
+	}
210
+
211
+	/**
212
+	 * @param SS_HTTPRequest $request
213
+	 *
214
+	 * @return ViewableData_Customised
215
+	 */
216
+	public function index(SS_HTTPRequest $request)
217
+	{
218
+		$locations = $this->Items($request);
219
+
220
+		return $this->customise(array(
221
+			'Locations' => $locations,
222
+		));
223
+	}
224
+
225
+	/**
226
+	 * Return a XML feed of all locations marked "show in locator"
227
+	 *
228
+	 * @param SS_HTTPRequest $request
229
+	 * @return HTMLText
230
+	 */
231
+	public function xml(SS_HTTPRequest $request)
232
+	{
233
+		$locations = $this->Items($request);
234
+
235
+		return $this->customise(array(
236
+			'Locations' => $locations,
237
+		))->renderWith('LocationXML');
238
+	}
239
+
240
+	/**
241
+	 * @param array $searchCriteria
242
+	 *
243
+	 * @return mixed
244
+	 */
245
+	public function Items($searchCriteria = array())
246
+	{
247
+		$request = ($this->request) ? $this->request : $this->parentController->getRequest();
248
+		if (empty($searchCriteria)) {
249
+			$searchCriteria = $request->requestVars();
250
+		}
251
+
252
+		$filter = array();
253
+		$filterAny = array();
254
+		$exclude = array();
255
+
256
+		// only show locations marked as ShowInLocator
257
+		$filter['ShowInLocator'] = 1;
258
+
259
+		// search across all address related fields
260
+		$address = ($request->getVar('Address')) ? $request->getVar('Address') : false;
261
+		if ($address) {
262
+			$filterAny['Address:PartialMatch'] = $address;
263
+			$filterAny['Suburb:PartialMatch'] = $address;
264
+			$filterAny['State:PartialMatch'] = $address;
265
+			$filterAny['Postcode:PartialMatch'] = $address;
266
+			$filterAny['Country:PartialMatch'] = $address;
267
+		}
268
+
269
+		$category = ($request->getVar('CategoryID')) ? $request->getVar('CategoryID') : false;
270
+		if ($category) {
271
+			$filter['CategoryID'] = $category;
272
+		}
273
+
274
+		$locations = Locator::locations($filter, $filterAny, $exclude);
275
+
276
+		return $locations;
277
+	}
278
+
279
+	/**
280
+	 * LocationSearch form.
281
+	 *
282
+	 * Search form for locations, updates map and results list via AJAX
283
+	 *
284
+	 * @return Form
285
+	 */
286
+	public function LocationSearch()
287
+	{
288
+		$fields = FieldList::create(
289
+			$address = TextField::create('Address', '')
290
+				->setAttribute('placeholder', 'address or zip code')
291
+		);
292
+
293
+		$filterCategories = Locator::getPageCategories($this->ID);
294
+		$allCategories = Locator::getAllCategories();
295
+
296
+		if ($allCategories->Count() > 0) {
297
+			$categories = ArrayList::create();
298
+			if ($filterCategories->Count() > 0) {
299
+				if ($filterCategories->Count() != 1) {
300
+					$categories = $filterCategories;
301
+				}
302
+			} else {
303
+				$categories = $allCategories;
304
+			}
305
+
306
+			if ($categories->count() > 0) {
307
+				$fields->push(
308
+					DropdownField::create(
309
+						'CategoryID',
310
+						'',
311
+						$categories->map()
312
+					)->setEmptyString('All Categories'));
313
+			}
314
+		}
315
+
316
+		$actions = FieldList::create(
317
+			FormAction::create('index', 'Search')
318
+		);
319
+
320
+		if (class_exists('BootstrapForm')) {
321
+			$form = BootstrapForm::create($this, 'LocationSearch', $fields, $actions);
322
+		} else {
323
+			$form = Form::create($this, 'LocationSearch', $fields, $actions);
324
+		}
325
+
326
+		return $form
327
+			->setFormMethod('GET')
328
+			->setFormAction($this->Link())
329
+			->disableSecurityToken()
330
+			->loadDataFrom($this->request->getVars())
331
+		;
332
+	}
333 333
 }
Please login to merge, or discard this patch.
tests/LocationTest.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -2,118 +2,118 @@
 block discarded – undo
2 2
 
3 3
 class LocationTest extends Locator_Test
4 4
 {
5
-    public function testGetCoords()
6
-    {
7
-        $location = $this->objFromFixture('Location', 'dynamic');
8
-        $location->write();
5
+	public function testGetCoords()
6
+	{
7
+		$location = $this->objFromFixture('Location', 'dynamic');
8
+		$location->write();
9 9
 
10
-        $coords = ($location->Lat && $location->Lng) ? 'true' : 'false';
11
-        $geoCodable = Location::get()->byID($location->ID);
10
+		$coords = ($location->Lat && $location->Lng) ? 'true' : 'false';
11
+		$geoCodable = Location::get()->byID($location->ID);
12 12
 
13
-        $this->assertEquals($coords, $geoCodable->getCoords());
14
-    }
13
+		$this->assertEquals($coords, $geoCodable->getCoords());
14
+	}
15 15
 
16
-    public function testFieldLabels()
17
-    {
18
-        $location = $this->objFromFixture('Location', 'dynamic');
19
-        $labels = $location->FieldLabels();
20
-        $expected = array(
21
-            'Title' => 'Name',
22
-            'Featured' => 'Featured',
23
-            'Website' => 'Website',
24
-            'Phone' => 'Phone',
25
-            'Email' => 'Email',
26
-            'EmailAddress' => 'Email Address',
27
-            'ShowInLocator' => 'Show',
28
-            'Address' => 'Address',
29
-            'Suburb' => 'City',
30
-            'State' => 'State',
31
-            'Postcode' => 'Postal Code',
32
-            'Country' => 'Country',
33
-            'Lat' => 'Lat',
34
-            'Lng' => 'Lng',
35
-            'Category' => 'Category',
36
-            'ShowInLocator.NiceAsBoolean' => 'Show',
37
-            'Category.Name' => 'Category',
38
-            'Category.ID' => 'Category',
39
-            'Featured.NiceAsBoolean' => 'Featured',
40
-            'Coords' => 'Coords',
41
-        );
42
-        $this->assertEquals($expected, $labels);
43
-    }
16
+	public function testFieldLabels()
17
+	{
18
+		$location = $this->objFromFixture('Location', 'dynamic');
19
+		$labels = $location->FieldLabels();
20
+		$expected = array(
21
+			'Title' => 'Name',
22
+			'Featured' => 'Featured',
23
+			'Website' => 'Website',
24
+			'Phone' => 'Phone',
25
+			'Email' => 'Email',
26
+			'EmailAddress' => 'Email Address',
27
+			'ShowInLocator' => 'Show',
28
+			'Address' => 'Address',
29
+			'Suburb' => 'City',
30
+			'State' => 'State',
31
+			'Postcode' => 'Postal Code',
32
+			'Country' => 'Country',
33
+			'Lat' => 'Lat',
34
+			'Lng' => 'Lng',
35
+			'Category' => 'Category',
36
+			'ShowInLocator.NiceAsBoolean' => 'Show',
37
+			'Category.Name' => 'Category',
38
+			'Category.ID' => 'Category',
39
+			'Featured.NiceAsBoolean' => 'Featured',
40
+			'Coords' => 'Coords',
41
+		);
42
+		$this->assertEquals($expected, $labels);
43
+	}
44 44
 
45
-    public function testGetCMSFields()
46
-    {
47
-        $object = new Location();
48
-        $fieldset = $object->getCMSFields();
49
-        $this->assertTrue(is_a($fieldset, 'FieldList'));
50
-    }
45
+	public function testGetCMSFields()
46
+	{
47
+		$object = new Location();
48
+		$fieldset = $object->getCMSFields();
49
+		$this->assertTrue(is_a($fieldset, 'FieldList'));
50
+	}
51 51
 
52
-    public function testValidate()
53
-    {
54
-    }
52
+	public function testValidate()
53
+	{
54
+	}
55 55
 
56
-    public function testEmailAddress()
57
-    {
58
-    }
56
+	public function testEmailAddress()
57
+	{
58
+	}
59 59
 
60
-    public function testCanView()
61
-    {
62
-        $object = $this->objFromFixture('Location', 'dynamic');
63
-        $object->write();
64
-        $this->logInWithPermission('ADMIN');
65
-        $this->assertTrue($object->canView());
66
-        $this->logOut();
67
-        $nullMember = Member::create();
68
-        $nullMember->write();
69
-        $this->assertTrue($object->canView($nullMember));
70
-        $nullMember->delete();
71
-    }
60
+	public function testCanView()
61
+	{
62
+		$object = $this->objFromFixture('Location', 'dynamic');
63
+		$object->write();
64
+		$this->logInWithPermission('ADMIN');
65
+		$this->assertTrue($object->canView());
66
+		$this->logOut();
67
+		$nullMember = Member::create();
68
+		$nullMember->write();
69
+		$this->assertTrue($object->canView($nullMember));
70
+		$nullMember->delete();
71
+	}
72 72
 
73
-    public function testCanEdit()
74
-    {
75
-        $object = $this->objFromFixture('Location', 'dynamic');
76
-        $object->write();
77
-        $objectID = $object->ID;
78
-        $this->logInWithPermission('Location_EDIT');
79
-        $originalTitle = $object->Title;
80
-        $this->assertEquals($originalTitle, 'Dynamic, Inc.');
81
-        $this->assertTrue($object->canEdit());
82
-        $object->Title = 'Changed Title';
83
-        $object->write();
84
-        $testEdit = Location::get()->byID($objectID);
85
-        $this->assertEquals($testEdit->Title, 'Changed Title');
86
-        $this->logOut();
87
-    }
73
+	public function testCanEdit()
74
+	{
75
+		$object = $this->objFromFixture('Location', 'dynamic');
76
+		$object->write();
77
+		$objectID = $object->ID;
78
+		$this->logInWithPermission('Location_EDIT');
79
+		$originalTitle = $object->Title;
80
+		$this->assertEquals($originalTitle, 'Dynamic, Inc.');
81
+		$this->assertTrue($object->canEdit());
82
+		$object->Title = 'Changed Title';
83
+		$object->write();
84
+		$testEdit = Location::get()->byID($objectID);
85
+		$this->assertEquals($testEdit->Title, 'Changed Title');
86
+		$this->logOut();
87
+	}
88 88
 
89
-    public function testCanDelete()
90
-    {
91
-        $object = $this->objFromFixture('Location', 'dynamic');
92
-        $object->write();
93
-        $this->logInWithPermission('Location_DELETE');
94
-        $this->assertTrue($object->canDelete());
95
-        $checkObject = $object;
96
-        $object->delete();
97
-        $this->assertEquals($checkObject->ID, 0);
98
-    }
89
+	public function testCanDelete()
90
+	{
91
+		$object = $this->objFromFixture('Location', 'dynamic');
92
+		$object->write();
93
+		$this->logInWithPermission('Location_DELETE');
94
+		$this->assertTrue($object->canDelete());
95
+		$checkObject = $object;
96
+		$object->delete();
97
+		$this->assertEquals($checkObject->ID, 0);
98
+	}
99 99
 
100
-    public function testCanCreate()
101
-    {
102
-        $object = singleton('Location');
103
-        $this->logInWithPermission('Location_CREATE');
104
-        $this->assertTrue($object->canCreate());
105
-        $this->logOut();
106
-        $nullMember = Member::create();
107
-        $nullMember->write();
108
-        $this->assertFalse($object->canCreate($nullMember));
109
-        $nullMember->delete();
110
-    }
100
+	public function testCanCreate()
101
+	{
102
+		$object = singleton('Location');
103
+		$this->logInWithPermission('Location_CREATE');
104
+		$this->assertTrue($object->canCreate());
105
+		$this->logOut();
106
+		$nullMember = Member::create();
107
+		$nullMember->write();
108
+		$this->assertFalse($object->canCreate($nullMember));
109
+		$nullMember->delete();
110
+	}
111 111
 
112
-    public function testProvidePermissions()
113
-    {
114
-    }
112
+	public function testProvidePermissions()
113
+	{
114
+	}
115 115
 
116
-    public function testOnBeforeWrite()
117
-    {
118
-    }
116
+	public function testOnBeforeWrite()
117
+	{
118
+	}
119 119
 }
Please login to merge, or discard this patch.
code/Location.php 1 patch
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -2,200 +2,200 @@
 block discarded – undo
2 2
 
3 3
 class Location extends DataObject implements PermissionProvider
4 4
 {
5
-    private static $db = array(
6
-        'Title' => 'Varchar(255)',
7
-        'Featured' => 'Boolean',
8
-        'Website' => 'Varchar(255)',
9
-        'Phone' => 'Varchar(40)',
10
-        'Email' => 'Varchar(255)',
11
-        'EmailAddress' => 'Varchar(255)',
12
-        'ShowInLocator' => 'Boolean',
13
-    );
14
-
15
-    private static $has_one = array(
16
-        'Category' => 'LocationCategory',
17
-    );
18
-
19
-    private static $casting = array(
20
-        'distance' => 'Int',
21
-    );
22
-
23
-    private static $default_sort = 'Title';
24
-
25
-    private static $defaults = array(
26
-        'ShowInLocator' => true,
27
-    );
28
-
29
-    private static $singular_name = 'Location';
30
-    private static $plural_name = 'Locations';
31
-
32
-    // api access via Restful Server module
33
-    private static $api_access = true;
34
-
35
-    // search fields for Model Admin
36
-    private static $searchable_fields = array(
37
-        'Title',
38
-        'Address',
39
-        'Suburb',
40
-        'State',
41
-        'Postcode',
42
-        'Country',
43
-        'Website',
44
-        'Phone',
45
-        'Email',
46
-        'Category.ID',
47
-        'ShowInLocator',
48
-        'Featured',
49
-    );
50
-
51
-    // columns for grid field
52
-    private static $summary_fields = array(
53
-        'Title',
54
-        'Address',
55
-        'Suburb',
56
-        'State',
57
-        'Postcode',
58
-        'Country',
59
-        'Category.Name',
60
-        'ShowInLocator.NiceAsBoolean',
61
-        'Featured.NiceAsBoolean',
62
-        'Coords',
63
-    );
64
-
65
-    // Coords status for $summary_fields
66
-    public function getCoords()
67
-    {
68
-        return ($this->Lat != 0 && $this->Lng != 0) ? 'true' : 'false';
69
-    }
70
-
71
-    // custom labels for fields
72
-    public function fieldLabels($includerelations = true)
73
-    {
74
-        $labels = parent::fieldLabels();
75
-
76
-        $labels['Title'] = 'Name';
77
-        $labels['Suburb'] = 'City';
78
-        $labels['Postcode'] = 'Postal Code';
79
-        $labels['ShowInLocator'] = 'Show';
80
-        $labels['ShowInLocator.NiceAsBoolean'] = 'Show';
81
-        $labels['Category.Name'] = 'Category';
82
-        $labels['Category.ID'] = 'Category';
83
-        $labels['Email'] = 'Email';
84
-        $labels['Featured.NiceAsBoolean'] = 'Featured';
85
-        $labels['Coords'] = 'Coords';
86
-
87
-        return $labels;
88
-    }
89
-
90
-    public function getCMSFields()
91
-    {
92
-        $fields = FieldList::create(
93
-            new TabSet(
94
-                $name = 'Root',
95
-                new Tab(
96
-                    $title = 'Main',
97
-                    HeaderField::create('ContactHD', 'Contact Information'),
98
-                    TextField::create('Title', 'Name'),
99
-                    TextField::create('Phone'),
100
-                    EmailField::create('Email', 'Email'),
101
-                    TextField::create('Website')
102
-                        ->setAttribute('placeholder', 'http://'),
103
-                    DropDownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))
104
-                        ->setEmptyString('-- select --'),
105
-                    CheckboxField::create('ShowInLocator', 'Show in results')
106
-                        ->setDescription('Location will be included in results list'),
107
-                    CheckboxField::create('Featured')
108
-                        ->setDescription('Location will show at/near the top of the results list')
109
-                )
110
-            )
111
-        );
112
-
113
-        // allow to be extended via DataExtension
114
-        $this->extend('updateCMSFields', $fields);
115
-
116
-        // override Suburb field name
117
-        $fields->dataFieldByName('Suburb')->setTitle('City');
118
-
119
-        return $fields;
120
-    }
121
-
122
-    public function validate()
123
-    {
124
-        $result = parent::validate();
125
-
126
-        return $result;
127
-    }
128
-
129
-    public function EmailAddress()
130
-    {
131
-        Deprecation::notice('3.0', 'Use "$Email" instead.');
132
-        if ($this->Email) {
133
-            return $this->Email;
134
-        } elseif ($this->EmailAddress) {
135
-            return $this->EmailAddress;
136
-        }
137
-
138
-        return false;
139
-    }
140
-
141
-    public function getCustomSearchContext()
142
-    {
143
-        $fields = $this->scaffoldSearchFields(array(
144
-            'restrictFields' => array('Address', 'Category.ID'),
145
-        ));
146
-
147
-        $filters = array(
148
-            'Address' => new PartialMatchFilter('Address'),
149
-            'Suburb' => new PartialMatchFilter('Suburb'),
150
-            'State' => new PartialMatchFilter('State'),
151
-            'Postcode' => new PartialMatchFilter('Postcode'),
152
-            'Country' => new PartialMatchFilter('Postcode'),
153
-            'CategoryID' => new ExactMatchFilter('CategoryID'),
154
-        );
155
-
156
-        return new SearchContext(
157
-            $this->class,
158
-            $fields,
159
-            $filters
160
-        );
161
-    }
162
-
163
-    /**
164
-     * @param Member $member
165
-     *
166
-     * @return bool
167
-     */
168
-    public function canView($member = false)
169
-    {
170
-        return true;
171
-    }
172
-
173
-    public function canEdit($member = false)
174
-    {
175
-        return Permission::check('Location_EDIT');
176
-    }
177
-
178
-    public function canDelete($member = false)
179
-    {
180
-        return Permission::check('Location_DELETE');
181
-    }
182
-
183
-    public function canCreate($member = false)
184
-    {
185
-        return Permission::check('Location_CREATE');
186
-    }
187
-
188
-    public function providePermissions()
189
-    {
190
-        return array(
191
-            'Location_EDIT' => 'Edit a Location',
192
-            'Location_DELETE' => 'Delete a Location',
193
-            'Location_CREATE' => 'Create a Location',
194
-        );
195
-    }
196
-
197
-    public function onBeforeWrite()
198
-    {
199
-        parent::onBeforeWrite();
200
-    }
5
+	private static $db = array(
6
+		'Title' => 'Varchar(255)',
7
+		'Featured' => 'Boolean',
8
+		'Website' => 'Varchar(255)',
9
+		'Phone' => 'Varchar(40)',
10
+		'Email' => 'Varchar(255)',
11
+		'EmailAddress' => 'Varchar(255)',
12
+		'ShowInLocator' => 'Boolean',
13
+	);
14
+
15
+	private static $has_one = array(
16
+		'Category' => 'LocationCategory',
17
+	);
18
+
19
+	private static $casting = array(
20
+		'distance' => 'Int',
21
+	);
22
+
23
+	private static $default_sort = 'Title';
24
+
25
+	private static $defaults = array(
26
+		'ShowInLocator' => true,
27
+	);
28
+
29
+	private static $singular_name = 'Location';
30
+	private static $plural_name = 'Locations';
31
+
32
+	// api access via Restful Server module
33
+	private static $api_access = true;
34
+
35
+	// search fields for Model Admin
36
+	private static $searchable_fields = array(
37
+		'Title',
38
+		'Address',
39
+		'Suburb',
40
+		'State',
41
+		'Postcode',
42
+		'Country',
43
+		'Website',
44
+		'Phone',
45
+		'Email',
46
+		'Category.ID',
47
+		'ShowInLocator',
48
+		'Featured',
49
+	);
50
+
51
+	// columns for grid field
52
+	private static $summary_fields = array(
53
+		'Title',
54
+		'Address',
55
+		'Suburb',
56
+		'State',
57
+		'Postcode',
58
+		'Country',
59
+		'Category.Name',
60
+		'ShowInLocator.NiceAsBoolean',
61
+		'Featured.NiceAsBoolean',
62
+		'Coords',
63
+	);
64
+
65
+	// Coords status for $summary_fields
66
+	public function getCoords()
67
+	{
68
+		return ($this->Lat != 0 && $this->Lng != 0) ? 'true' : 'false';
69
+	}
70
+
71
+	// custom labels for fields
72
+	public function fieldLabels($includerelations = true)
73
+	{
74
+		$labels = parent::fieldLabels();
75
+
76
+		$labels['Title'] = 'Name';
77
+		$labels['Suburb'] = 'City';
78
+		$labels['Postcode'] = 'Postal Code';
79
+		$labels['ShowInLocator'] = 'Show';
80
+		$labels['ShowInLocator.NiceAsBoolean'] = 'Show';
81
+		$labels['Category.Name'] = 'Category';
82
+		$labels['Category.ID'] = 'Category';
83
+		$labels['Email'] = 'Email';
84
+		$labels['Featured.NiceAsBoolean'] = 'Featured';
85
+		$labels['Coords'] = 'Coords';
86
+
87
+		return $labels;
88
+	}
89
+
90
+	public function getCMSFields()
91
+	{
92
+		$fields = FieldList::create(
93
+			new TabSet(
94
+				$name = 'Root',
95
+				new Tab(
96
+					$title = 'Main',
97
+					HeaderField::create('ContactHD', 'Contact Information'),
98
+					TextField::create('Title', 'Name'),
99
+					TextField::create('Phone'),
100
+					EmailField::create('Email', 'Email'),
101
+					TextField::create('Website')
102
+						->setAttribute('placeholder', 'http://'),
103
+					DropDownField::create('CategoryID', 'Category', LocationCategory::get()->map('ID', 'Title'))
104
+						->setEmptyString('-- select --'),
105
+					CheckboxField::create('ShowInLocator', 'Show in results')
106
+						->setDescription('Location will be included in results list'),
107
+					CheckboxField::create('Featured')
108
+						->setDescription('Location will show at/near the top of the results list')
109
+				)
110
+			)
111
+		);
112
+
113
+		// allow to be extended via DataExtension
114
+		$this->extend('updateCMSFields', $fields);
115
+
116
+		// override Suburb field name
117
+		$fields->dataFieldByName('Suburb')->setTitle('City');
118
+
119
+		return $fields;
120
+	}
121
+
122
+	public function validate()
123
+	{
124
+		$result = parent::validate();
125
+
126
+		return $result;
127
+	}
128
+
129
+	public function EmailAddress()
130
+	{
131
+		Deprecation::notice('3.0', 'Use "$Email" instead.');
132
+		if ($this->Email) {
133
+			return $this->Email;
134
+		} elseif ($this->EmailAddress) {
135
+			return $this->EmailAddress;
136
+		}
137
+
138
+		return false;
139
+	}
140
+
141
+	public function getCustomSearchContext()
142
+	{
143
+		$fields = $this->scaffoldSearchFields(array(
144
+			'restrictFields' => array('Address', 'Category.ID'),
145
+		));
146
+
147
+		$filters = array(
148
+			'Address' => new PartialMatchFilter('Address'),
149
+			'Suburb' => new PartialMatchFilter('Suburb'),
150
+			'State' => new PartialMatchFilter('State'),
151
+			'Postcode' => new PartialMatchFilter('Postcode'),
152
+			'Country' => new PartialMatchFilter('Postcode'),
153
+			'CategoryID' => new ExactMatchFilter('CategoryID'),
154
+		);
155
+
156
+		return new SearchContext(
157
+			$this->class,
158
+			$fields,
159
+			$filters
160
+		);
161
+	}
162
+
163
+	/**
164
+	 * @param Member $member
165
+	 *
166
+	 * @return bool
167
+	 */
168
+	public function canView($member = false)
169
+	{
170
+		return true;
171
+	}
172
+
173
+	public function canEdit($member = false)
174
+	{
175
+		return Permission::check('Location_EDIT');
176
+	}
177
+
178
+	public function canDelete($member = false)
179
+	{
180
+		return Permission::check('Location_DELETE');
181
+	}
182
+
183
+	public function canCreate($member = false)
184
+	{
185
+		return Permission::check('Location_CREATE');
186
+	}
187
+
188
+	public function providePermissions()
189
+	{
190
+		return array(
191
+			'Location_EDIT' => 'Edit a Location',
192
+			'Location_DELETE' => 'Delete a Location',
193
+			'Location_CREATE' => 'Create a Location',
194
+		);
195
+	}
196
+
197
+	public function onBeforeWrite()
198
+	{
199
+		parent::onBeforeWrite();
200
+	}
201 201
 }
Please login to merge, or discard this patch.
tests/LocatorTest.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -2,72 +2,72 @@
 block discarded – undo
2 2
 
3 3
 class LocatorTest extends Locator_Test
4 4
 {
5
-    public function testGetCMSFields()
6
-    {
7
-        $object = new Locator();
8
-        $fieldset = $object->getCMSFields();
9
-        $this->assertTrue(is_a($fieldset, 'FieldList'));
10
-    }
5
+	public function testGetCMSFields()
6
+	{
7
+		$object = new Locator();
8
+		$fieldset = $object->getCMSFields();
9
+		$this->assertTrue(is_a($fieldset, 'FieldList'));
10
+	}
11 11
 
12
-    public function testLocations()
13
-    {
14
-        $locator = singleton('Locator');
15
-        $count = Location::get()->filter('ShowInLocator', 1)->exclude('Lat', 0)->Count();
16
-        $this->assertEquals($locator->getLocations()->Count(), $count);
17
-    }
12
+	public function testLocations()
13
+	{
14
+		$locator = singleton('Locator');
15
+		$count = Location::get()->filter('ShowInLocator', 1)->exclude('Lat', 0)->Count();
16
+		$this->assertEquals($locator->getLocations()->Count(), $count);
17
+	}
18 18
 
19
-    public function testGetAllCategories()
20
-    {
21
-        $locator = singleton('Locator');
22
-        $count = LocationCategory::get();
23
-        $this->assertEquals($locator->getAllCategories(), $count);
24
-    }
19
+	public function testGetAllCategories()
20
+	{
21
+		$locator = singleton('Locator');
22
+		$count = LocationCategory::get();
23
+		$this->assertEquals($locator->getAllCategories(), $count);
24
+	}
25 25
 
26
-    public function testGetPageCategories()
27
-    {
28
-        $locator = Locator::create();
29
-        $this->assertFalse($locator->getPageCategories());
26
+	public function testGetPageCategories()
27
+	{
28
+		$locator = Locator::create();
29
+		$this->assertFalse($locator->getPageCategories());
30 30
 
31
-        $this->assertFalse($locator->getPageCategories(500));
31
+		$this->assertFalse($locator->getPageCategories(500));
32 32
 
33
-        $locator->write();
34
-        $category = $this->objFromFixture('LocationCategory', 'service');
35
-        $locator->Categories()->add($category);
36
-        $this->assertEquals($locator->getPageCategories($locator->ID), $locator->Categories());
37
-    }
33
+		$locator->write();
34
+		$category = $this->objFromFixture('LocationCategory', 'service');
35
+		$locator->Categories()->add($category);
36
+		$this->assertEquals($locator->getPageCategories($locator->ID), $locator->Categories());
37
+	}
38 38
 
39
-    public function testInit()
40
-    {
41
-    }
39
+	public function testInit()
40
+	{
41
+	}
42 42
 
43
-    public function testIndex()
44
-    {
43
+	public function testIndex()
44
+	{
45 45
 
46
-    }
46
+	}
47 47
 
48
-    public function testXml()
49
-    {
50
-    }
48
+	public function testXml()
49
+	{
50
+	}
51 51
 
52
-    public function testItems()
53
-    {
52
+	public function testItems()
53
+	{
54 54
         
55
-    }
55
+	}
56 56
 
57
-    public function testLocationSearch()
58
-    {
59
-        $locator = $this->objFromFixture('Locator', 'locator1');
60
-        $object = Locator_Controller::create($locator);
61
-        $form = $object->LocationSearch();
62
-        $this->assertTrue(is_a($form, 'Form'));
57
+	public function testLocationSearch()
58
+	{
59
+		$locator = $this->objFromFixture('Locator', 'locator1');
60
+		$object = Locator_Controller::create($locator);
61
+		$form = $object->LocationSearch();
62
+		$this->assertTrue(is_a($form, 'Form'));
63 63
 
64
-        $category = $this->objFromFixture('LocationCategory', 'service');
65
-        $category2 = $this->objFromFixture('LocationCategory', 'manufacturing');
66
-        $locator->Categories()->add($category);
67
-        $locator->Categories()->add($category2);
64
+		$category = $this->objFromFixture('LocationCategory', 'service');
65
+		$category2 = $this->objFromFixture('LocationCategory', 'manufacturing');
66
+		$locator->Categories()->add($category);
67
+		$locator->Categories()->add($category2);
68 68
 
69
-        $form = $object->LocationSearch();
70
-        $fields = $form->Fields();
71
-        $this->assertNotNull($fields->fieldByName('CategoryID'));
72
-    }
69
+		$form = $object->LocationSearch();
70
+		$fields = $form->Fields();
71
+		$this->assertNotNull($fields->fieldByName('CategoryID'));
72
+	}
73 73
 }
Please login to merge, or discard this patch.