Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed broken script #197

Merged
merged 1 commit into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/pages/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -196,7 +196,7 @@ public function getRadiiArrayList()
*/
public function getLimit()
{
return Config::inst()->get(Locator::class, 'limit');
return $this->config()->get('limit');
}

/**
Expand All @@ -205,7 +205,7 @@ public function getLimit()
*/
public function getShowRadius()
{
return Config::inst()->get(Locator::class, 'show_radius');
return $this->config()->get('show_radius');
}

/**
Expand Down
126 changes: 63 additions & 63 deletions src/pages/LocatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class LocatorController extends \PageController
/**
* @var array
*/
private static $allowed_actions = array(
private static $allowed_actions = [
'xml',
'json',
);
];

/**
* @var array
Expand Down Expand Up @@ -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
Expand All @@ -150,7 +150,7 @@ public function init()
dataLocation: '{$link}',
listTemplatePath: '{$listTemplatePath}',
infowindowTemplatePath: '{$infowindowTemplatePath}',
{$markerImage},
{$markerImage}
originMarker: true,
{$featured},
slideMap: false,
Expand All @@ -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
}
});
});
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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
*/
Expand All @@ -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.
*
Expand Down