Skip to content

Commit

Permalink
Locator - file path fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Jul 21, 2015
1 parent 20a5652 commit 594daf5
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions code/Locator.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

class Locator extends Page {

private static $db = array(
'AutoGeocode' => 'Boolean',
'ModalWindow' => 'Boolean',
Expand All @@ -11,24 +11,24 @@ class Locator extends Page {
private static $has_many = array(
'Locations' => 'Location'
);

private static $defaults = array(
'AutoGeocode' => true
);

private static $singular_name = "Locator";
private static $plural_name = "Locators";
private static $description = 'Find locations on a map';

public function getCMSFields() {
$fields = parent::getCMSFields();

// Locations Grid Field
$config = (self::getMultipleLocators())
? GridFieldConfig_RelationEditor::create() : GridFieldConfig_RecordEditor::create();
$locations = (self::getMultipleLocators()) ? $this->Locations() : Location::get();
$fields->addFieldToTab("Root.Locations", GridField::create("Locations", "Locations", $locations, $config));

// Location categories
$config = GridFieldConfig_RecordEditor::create();
$fields->addFieldToTab("Root.Categories", GridField::create("Categories", "Categories", LocationCategory::get(), $config));
Expand All @@ -43,7 +43,7 @@ public function getCMSFields() {
));

$this->extend('updateCMSFields', $fields);

return $fields;
}

Expand All @@ -69,7 +69,7 @@ class Locator_Controller extends Page_Controller {

// allowed actions
private static $allowed_actions = array('xml');

// Set Requirements based on input from CMS
public function init() {
parent::init();
Expand All @@ -82,7 +82,7 @@ public function init() {
Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js');
Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js');
}

Requirements::css('locator/css/map.css');

$featured = (Locator::getLocations(array('Featured' => 1))->count() > 0) ?
Expand All @@ -95,8 +95,7 @@ public function init() {
'autoGeocode: true, fullMapStart: false,' :
'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,';

$absoluteBase = getcwd();//get current working dir
$base = str_replace('/framework','',$absoluteBase);//remove framework if .htaccess is working
$base = Director::baseFolder();
$themePath = $base."/".$themeDir;

$listTemplatePath = (file_exists($themePath . '/templates/location-list-description.html')) ?
Expand Down Expand Up @@ -139,13 +138,13 @@ public function init() {
");
}

}
}

/**
* Find all locations for map
*
*
* Will return a XML feed of all locations marked "show in locator".
*
*
* @access public
* @return XML file
* @todo rename/refactor to allow for json/xml
Expand All @@ -158,19 +157,19 @@ public function xml(SS_HTTPRequest $request) {
}
}
$Locations = Locator::getLocations($filter);

return $this->customise(array(
'Locations' => $Locations
))->renderWith('LocationXML');
}

}


/**
* LocationSearch form.
*
* Search form for locations, updates map and results list via AJAX
*
*
* @access public
* @return Form
*/
Expand All @@ -179,7 +178,7 @@ public function LocationSearch() {
$address = TextField::create('address', '')
);
$address->setAttribute('placeholder', 'address or zip code');

if (LocationCategory::get()->Count() > 0) {

$filter = ($this->data()->getMultipleLocators()) ? array('LocatorID' => $this->data()->ID) : array();
Expand All @@ -200,13 +199,13 @@ public function LocationSearch() {
)->setEmptyString('Select Category'));
}
}

$actions = FieldList::create(
FormAction::create('', 'Search')
);

return Form::create($this, 'LocationSearch', $fields, $actions);

}

}

0 comments on commit 594daf5

Please sign in to comment.