diff --git a/src/pages/Locator.php b/src/pages/Locator.php index 173b615..e68f70a 100644 --- a/src/pages/Locator.php +++ b/src/pages/Locator.php @@ -169,7 +169,7 @@ public function getRadii() '2' => '75', '3' => '100', ]; - $config_radii = Config::inst()->get(Locator::class, 'radii'); + $config_radii = $this->config()->get('radii'); if ($config_radii) { $radii = $config_radii; } @@ -196,7 +196,7 @@ public function getRadiiArrayList() */ public function getLimit() { - return Config::inst()->get(Locator::class, 'limit'); + return $this->config()->get('limit'); } /** @@ -205,7 +205,7 @@ public function getLimit() */ public function getShowRadius() { - return Config::inst()->get(Locator::class, 'show_radius'); + return $this->config()->get('show_radius'); } /** diff --git a/src/pages/LocatorController.php b/src/pages/LocatorController.php index 8a1cd2c..fd91c6c 100644 --- a/src/pages/LocatorController.php +++ b/src/pages/LocatorController.php @@ -21,10 +21,10 @@ class LocatorController extends \PageController /** * @var array */ - private static $allowed_actions = array( + private static $allowed_actions = [ 'xml', 'json', - ); + ]; /** * @var array @@ -133,13 +133,13 @@ public function init() $mapStyle = ''; if ($stylePath = $this->getMapStyleJSONPath()) { if ($style = file_get_contents($stylePath)) { - $mapStyle = "styles: {$style}"; + $mapStyle = "styles: {$style},"; } }; $markerImage = ''; if ($imagePath = $this->getMarkerIcon()) { - $markerImage = "markerImg: '{$imagePath},'"; + $markerImage = "markerImg: '{$imagePath}',"; } // init map @@ -150,7 +150,7 @@ public function init() dataLocation: '{$link}', listTemplatePath: '{$listTemplatePath}', infowindowTemplatePath: '{$infowindowTemplatePath}', - {$markerImage}, + {$markerImage} originMarker: true, {$featured}, slideMap: false, @@ -161,13 +161,13 @@ public function init() mapID: '{$map_id}', locationList: '{$list_class}', mapSettings: { + {$mapStyle} zoom: 12, mapTypeId: google.maps.MapTypeId.ROADMAP, disableDoubleClickZoom: true, scrollwheel: false, navigationControl: false, - draggable: false, - {$mapStyle} + draggable: false } }); }); @@ -179,51 +179,16 @@ public function init() /** * @param HTTPRequest $request * - * @return \SilverStripe\View\ViewableData_Customised + * @return bool */ - public function index(HTTPRequest $request) + public function getTrigger(HTTPRequest $request = null) { - if ($this->getTrigger($request)) { - $locations = $this->getLocations(); - } else { - $locations = ArrayList::create(); + if ($request === null) { + $request = $this->getRequest(); } + $trigger = $request->getVar(Config::inst()->get(LocatorController::class, 'query_trigger')); - return $this->customise(array( - 'Locations' => $locations, - )); - } - - /** - * Renders locations in xml format - * - * @return \SilverStripe\ORM\FieldType\DBHTMLText - */ - public function xml() - { - $this->getResponse()->addHeader("Content-Type", "application/xml"); - $data = new ArrayData(array( - "Locations" => $this->getLocations(), - "AddressCoords" => $this->getAddressSearchCoords(), - )); - - return $data->renderWith('Dynamic/Locator/Data/XML'); - } - - /** - * Renders locations in json format - * - * @return \SilverStripe\ORM\FieldType\DBHTMLText - */ - public function json() - { - $this->getResponse()->addHeader("Content-Type", "application/json"); - $data = new ArrayData(array( - "Locations" => $this->getLocations(), - "AddressCoords" => $this->getAddressSearchCoords(), - )); - - return $data->renderWith('Dynamic/Locator/Data/JSON'); + return isset($trigger); } /** @@ -304,21 +269,6 @@ public function setLocations(HTTPRequest $request = null) } - /** - * @param HTTPRequest $request - * - * @return bool - */ - public function getTrigger(HTTPRequest $request = null) - { - if ($request === null) { - $request = $this->getRequest(); - } - $trigger = $request->getVar(Config::inst()->get(LocatorController::class, 'query_trigger')); - - return isset($trigger); - } - /** * @return ArrayData|boolean */ @@ -342,6 +292,56 @@ public function getAddressSearchCoords() } + /** + * @param HTTPRequest $request + * + * @return \SilverStripe\View\ViewableData_Customised + */ + public function index(HTTPRequest $request) + { + if ($this->getTrigger($request)) { + $locations = $this->getLocations(); + } else { + $locations = ArrayList::create(); + } + + return $this->customise(array( + 'Locations' => $locations, + )); + } + + /** + * Renders locations in xml format + * + * @return \SilverStripe\ORM\FieldType\DBHTMLText + */ + public function xml() + { + $this->getResponse()->addHeader("Content-Type", "application/xml"); + $data = new ArrayData(array( + "Locations" => $this->getLocations(), + "AddressCoords" => $this->getAddressSearchCoords(), + )); + + return $data->renderWith('Dynamic/Locator/Data/XML'); + } + + /** + * Renders locations in json format + * + * @return \SilverStripe\ORM\FieldType\DBHTMLText + */ + public function json() + { + $this->getResponse()->addHeader("Content-Type", "application/json"); + $data = new ArrayData(array( + "Locations" => $this->getLocations(), + "AddressCoords" => $this->getAddressSearchCoords(), + )); + + return $data->renderWith('Dynamic/Locator/Data/JSON'); + } + /** * LocationSearch form. *