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

BUGFIX: Locator - remove autoGeocode references #156

Merged
merged 1 commit into from
Apr 18, 2017
Merged
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
27 changes: 1 addition & 26 deletions code/pages/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class Locator extends Page
* @var array
*/
private static $db = array(
'AutoGeocode' => 'Boolean',
'ModalWindow' => 'Boolean',
'Unit' => 'Enum("m,km","m")',
);

Expand All @@ -27,13 +25,6 @@ class Locator extends Page
'Categories' => 'LocationCategory',
);

/**
* @var array
*/
private static $defaults = array(
'AutoGeocode' => true,
);

/**
* @var string
*/
Expand Down Expand Up @@ -63,9 +54,6 @@ public function getCMSFields()
$fields->addFieldsToTab('Root.Settings', array(
HeaderField::create('DisplayOptions', 'Display Options', 3),
OptionsetField::create('Unit', 'Unit of measure', array('m' => 'Miles', 'km' => 'Kilometers')),
//CheckboxField::create('AutoGeocode', 'Auto Geocode - Automatically filter map results based on user location')
// ->setDescription('Note: if any locations are set as featured, the auto geocode is automatically disabled.'),
//CheckboxField::create('ModalWindow', 'Modal Window - Show Map results in a modal window'),
));

// Filter categories
Expand Down Expand Up @@ -253,30 +241,19 @@ public function init()

$featuredInList = ($locations->filter('Featured', true)->count() > 0);
$defaultCoords = $this->getAddressSearchCoords() ? $this->getAddressSearchCoords() : '';
$isChrome = (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== FALSE);

$featured = $featuredInList
? 'featuredLocations: true'
: 'featuredLocations: false';

// map config based on user input in Settings tab
// AutoGeocode or Full Map
$limit = Config::inst()->get('Locator_Controller', 'limit');
if ($limit < 1) $limit = -1;
if ($this->data()->AutoGeocode) {
$load = $featuredInList || $defaultCoords != '' || $isChrome
? 'autoGeocode: false, fullMapStart: true, storeLimit: ' . $limit . ', maxDistance: true,'
: 'autoGeocode: true, fullMapStart: false,';
} else {
$load = 'autoGeocode: false, fullMapStart: true, storeLimit: ' . $limit . ', maxDistance: true,';
}
$load = 'fullMapStart: true, storeLimit: ' . $limit . ', maxDistance: true,';

$listTemplatePath = Config::inst()->get('Locator_Controller', 'list_template_path');
$infowindowTemplatePath = Config::inst()->get('Locator_Controller', 'info_window_template_path');

// in page or modal
$modal = ($this->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false';

$kilometer = ($this->data()->Unit == 'km') ? "lengthUnit: 'km'" : "lengthUnit: 'm'";

// pass GET variables to xml action
Expand All @@ -286,7 +263,6 @@ public function init()
if (count($vars)) {
$url .= '?' . http_build_query($vars);
}
$link = Controller::join_links($this->AbsoluteLink(), 'xml.xml', $url);
$link = Controller::join_links($this->Link(), 'xml.xml', $url);

// containers
Expand All @@ -302,7 +278,6 @@ public function init()
listTemplatePath: '" . $listTemplatePath . "',
infowindowTemplatePath: '" . $infowindowTemplatePath . "',
originMarker: true,
//" . $modal . ",
" . $featured . ",
slideMap: false,
distanceAlert: -1,
Expand Down