@@ -5,47 +5,47 @@ discard block |
||
| 5 | 5 | private static $db = array( |
| 6 | 6 | 'AutoGeocode' => 'Boolean', |
| 7 | 7 | 'ModalWindow' => 'Boolean', |
| 8 | - 'Unit' => 'Enum("km,m","m")' |
|
| 8 | + 'Unit' => 'Enum("km,m","m")' |
|
| 9 | 9 | ); |
| 10 | 10 | |
| 11 | - private static $has_many = array( |
|
| 12 | - 'Locations' => 'Location' |
|
| 13 | - ); |
|
| 11 | + private static $has_many = array( |
|
| 12 | + 'Locations' => 'Location' |
|
| 13 | + ); |
|
| 14 | 14 | |
| 15 | 15 | private static $defaults = array( |
| 16 | 16 | 'AutoGeocode' => true |
| 17 | 17 | ); |
| 18 | 18 | |
| 19 | 19 | private static $singular_name = "Locator"; |
| 20 | - private static $plural_name = "Locators"; |
|
| 21 | - private static $description = 'Find locations on a map'; |
|
| 20 | + private static $plural_name = "Locators"; |
|
| 21 | + private static $description = 'Find locations on a map'; |
|
| 22 | 22 | |
| 23 | - public function getCMSFields() { |
|
| 24 | - $fields = parent::getCMSFields(); |
|
| 23 | + public function getCMSFields() { |
|
| 24 | + $fields = parent::getCMSFields(); |
|
| 25 | 25 | |
| 26 | - // Locations Grid Field |
|
| 26 | + // Locations Grid Field |
|
| 27 | 27 | $config = (self::getMultipleLocators()) |
| 28 | - ? GridFieldConfig_RelationEditor::create() : GridFieldConfig_RecordEditor::create(); |
|
| 29 | - $locations = (self::getMultipleLocators()) ? $this->Locations() : Location::get(); |
|
| 30 | - $fields->addFieldToTab("Root.Locations", GridField::create("Locations", "Locations", $locations, $config)); |
|
| 31 | - |
|
| 32 | - // Location categories |
|
| 33 | - $config = GridFieldConfig_RecordEditor::create(); |
|
| 34 | - $fields->addFieldToTab("Root.Categories", GridField::create("Categories", "Categories", LocationCategory::get(), $config)); |
|
| 35 | - |
|
| 36 | - // Settings |
|
| 37 | - $fields->addFieldsToTab('Root.Settings', array( |
|
| 38 | - HeaderField::create('DisplayOptions', 'Display Options', 3), |
|
| 39 | - OptionsetField::create('Unit', 'Unit of measure', array('km' => 'Kilometers', 'm' => 'Miles')), |
|
| 40 | - CheckboxField::create('AutoGeocode', 'Auto Geocode - Automatically filter map results based on user location') |
|
| 28 | + ? GridFieldConfig_RelationEditor::create() : GridFieldConfig_RecordEditor::create(); |
|
| 29 | + $locations = (self::getMultipleLocators()) ? $this->Locations() : Location::get(); |
|
| 30 | + $fields->addFieldToTab("Root.Locations", GridField::create("Locations", "Locations", $locations, $config)); |
|
| 31 | + |
|
| 32 | + // Location categories |
|
| 33 | + $config = GridFieldConfig_RecordEditor::create(); |
|
| 34 | + $fields->addFieldToTab("Root.Categories", GridField::create("Categories", "Categories", LocationCategory::get(), $config)); |
|
| 35 | + |
|
| 36 | + // Settings |
|
| 37 | + $fields->addFieldsToTab('Root.Settings', array( |
|
| 38 | + HeaderField::create('DisplayOptions', 'Display Options', 3), |
|
| 39 | + OptionsetField::create('Unit', 'Unit of measure', array('km' => 'Kilometers', 'm' => 'Miles')), |
|
| 40 | + CheckboxField::create('AutoGeocode', 'Auto Geocode - Automatically filter map results based on user location') |
|
| 41 | 41 | ->setDescription('Note: if any locations are set as featured, the auto geocode is automatically disabled.'), |
| 42 | - CheckboxField::create('ModalWindow', 'Modal Window - Show Map results in a modal window') |
|
| 43 | - )); |
|
| 42 | + CheckboxField::create('ModalWindow', 'Modal Window - Show Map results in a modal window') |
|
| 43 | + )); |
|
| 44 | 44 | |
| 45 | 45 | $this->extend('updateCMSFields', $fields); |
| 46 | 46 | |
| 47 | - return $fields; |
|
| 48 | - } |
|
| 47 | + return $fields; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public static function getLocations($filter = array(), $exclude = array()){ |
| 51 | 51 | $filter['ShowInLocator'] = true; |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | return self::getLocations(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public static function getMultipleLocators(){ |
|
| 63 | - return (Locator::get()->count() > 1) ? true : false; |
|
| 64 | - } |
|
| 62 | + public static function getMultipleLocators(){ |
|
| 63 | + return (Locator::get()->count() > 1) ? true : false; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
@@ -108,14 +108,14 @@ discard block |
||
| 108 | 108 | // in page or modal |
| 109 | 109 | $modal = ($this->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false'; |
| 110 | 110 | |
| 111 | - $kilometer = ($this->data()->Unit == 'km') ? 'lengthUnit: "km"' : 'lengthUnit: "m"'; |
|
| 111 | + $kilometer = ($this->data()->Unit == 'km') ? 'lengthUnit: "km"' : 'lengthUnit: "m"'; |
|
| 112 | 112 | |
| 113 | - $link = $this->Link() . "xml.xml"; |
|
| 114 | - $link .= (Locator::getMultipleLocators()) ? "?locatorID=" . $this->data()->ID : "" ; |
|
| 113 | + $link = $this->Link() . "xml.xml"; |
|
| 114 | + $link .= (Locator::getMultipleLocators()) ? "?locatorID=" . $this->data()->ID : "" ; |
|
| 115 | 115 | |
| 116 | 116 | // init map |
| 117 | - if(Locator::getLocations()) { |
|
| 118 | - Requirements::customScript(" |
|
| 117 | + if(Locator::getLocations()) { |
|
| 118 | + Requirements::customScript(" |
|
| 119 | 119 | $(function($) { |
| 120 | 120 | $('#map-container').storeLocator({ |
| 121 | 121 | " . $load . " |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | }); |
| 137 | 137 | }); |
| 138 | 138 | "); |
| 139 | - } |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @access public |
| 149 | 149 | * @return XML file |
| 150 | - * @todo rename/refactor to allow for json/xml |
|
| 150 | + * @todo rename/refactor to allow for json/xml |
|
| 151 | 151 | */ |
| 152 | 152 | public function xml(SS_HTTPRequest $request) { |
| 153 | - $filter = array(); |
|
| 154 | - if(Locator::getMultipleLocators()){//only checks published locators |
|
| 155 | - if($request->getVar('locatorID')){ |
|
| 156 | - $filter['LocatorID'] = $request->getVar('locatorID'); |
|
| 157 | - } |
|
| 158 | - } |
|
| 153 | + $filter = array(); |
|
| 154 | + if(Locator::getMultipleLocators()){//only checks published locators |
|
| 155 | + if($request->getVar('locatorID')){ |
|
| 156 | + $filter['LocatorID'] = $request->getVar('locatorID'); |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | 159 | $Locations = Locator::getLocations($filter); |
| 160 | 160 | |
| 161 | 161 | return $this->customise(array( |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | |
| 182 | 182 | if (LocationCategory::get()->Count() > 0) { |
| 183 | 183 | |
| 184 | - $filter = ($this->data()->getMultipleLocators()) ? array('LocatorID' => $this->data()->ID) : array(); |
|
| 184 | + $filter = ($this->data()->getMultipleLocators()) ? array('LocatorID' => $this->data()->ID) : array(); |
|
| 185 | 185 | $locals = Locator::getLocations($filter, $exclude = array('CategoryID' => 0)); |
| 186 | 186 | //debug::show($locals); |
| 187 | 187 | $categories = ArrayList::create(); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | return $fields; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public static function getLocations($filter = array(), $exclude = array()){ |
|
| 50 | + public static function getLocations($filter = array(), $exclude = array()) { |
|
| 51 | 51 | $filter['ShowInLocator'] = true; |
| 52 | 52 | return Location::get() |
| 53 | 53 | ->exclude($exclude) |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | ->filter($filter); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - public function getAreLocations(){ |
|
| 58 | + public function getAreLocations() { |
|
| 59 | 59 | return self::getLocations(); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public static function getMultipleLocators(){ |
|
| 62 | + public static function getMultipleLocators() { |
|
| 63 | 63 | return (Locator::get()->count() > 1) ? true : false; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $themeDir = SSViewer::get_theme_folder(); |
| 78 | 78 | |
| 79 | 79 | Requirements::javascript('framework/thirdparty/jquery/jquery.js'); |
| 80 | - if(Locator::getLocations()){ |
|
| 80 | + if (Locator::getLocations()) { |
|
| 81 | 81 | Requirements::javascript('http://maps.google.com/maps/api/js?sensor=false'); |
| 82 | 82 | Requirements::javascript('locator/thirdparty/handlebars/handlebars-v1.3.0.js'); |
| 83 | 83 | Requirements::javascript('locator/thirdparty/jquery-store-locator/js/jquery.storelocator.js'); |
@@ -86,24 +86,20 @@ discard block |
||
| 86 | 86 | Requirements::css('locator/css/map.css'); |
| 87 | 87 | |
| 88 | 88 | $featured = (Locator::getLocations(array('Featured' => 1))->count() > 0) ? |
| 89 | - 'featuredLocations: true' : |
|
| 90 | - 'featuredLocations: false'; |
|
| 89 | + 'featuredLocations: true' : 'featuredLocations: false'; |
|
| 91 | 90 | |
| 92 | 91 | // map config based on user input in Settings tab |
| 93 | 92 | // AutoGeocode or Full Map |
| 94 | 93 | $load = ($this->data()->AutoGeocode) ? |
| 95 | - 'autoGeocode: true, fullMapStart: false,' : |
|
| 96 | - 'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,'; |
|
| 94 | + 'autoGeocode: true, fullMapStart: false,' : 'autoGeocode: false, fullMapStart: true, storeLimit: 1000, maxDistance: true,'; |
|
| 97 | 95 | |
| 98 | 96 | $base = Director::baseFolder(); |
| 99 | - $themePath = $base."/".$themeDir; |
|
| 97 | + $themePath = $base . "/" . $themeDir; |
|
| 100 | 98 | |
| 101 | 99 | $listTemplatePath = (file_exists($themePath . '/templates/location-list-description.html')) ? |
| 102 | - $themeDir . '/templates/location-list-description.html' : |
|
| 103 | - 'locator/templates/location-list-description.html'; |
|
| 100 | + $themeDir . '/templates/location-list-description.html' : 'locator/templates/location-list-description.html'; |
|
| 104 | 101 | $infowindowTemplatePath = (file_exists($themePath . '/templates/infowindow-description.html')) ? |
| 105 | - $themeDir . '/templates/infowindow-description.html' : |
|
| 106 | - 'locator/templates/infowindow-description.html'; |
|
| 102 | + $themeDir . '/templates/infowindow-description.html' : 'locator/templates/infowindow-description.html'; |
|
| 107 | 103 | |
| 108 | 104 | // in page or modal |
| 109 | 105 | $modal = ($this->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false'; |
@@ -111,10 +107,10 @@ discard block |
||
| 111 | 107 | $kilometer = ($this->data()->Unit == 'km') ? 'lengthUnit: "km"' : 'lengthUnit: "m"'; |
| 112 | 108 | |
| 113 | 109 | $link = $this->Link() . "xml.xml"; |
| 114 | - $link .= (Locator::getMultipleLocators()) ? "?locatorID=" . $this->data()->ID : "" ; |
|
| 110 | + $link .= (Locator::getMultipleLocators()) ? "?locatorID=" . $this->data()->ID : ""; |
|
| 115 | 111 | |
| 116 | 112 | // init map |
| 117 | - if(Locator::getLocations()) { |
|
| 113 | + if (Locator::getLocations()) { |
|
| 118 | 114 | Requirements::customScript(" |
| 119 | 115 | $(function($) { |
| 120 | 116 | $('#map-container').storeLocator({ |
@@ -151,8 +147,8 @@ discard block |
||
| 151 | 147 | */ |
| 152 | 148 | public function xml(SS_HTTPRequest $request) { |
| 153 | 149 | $filter = array(); |
| 154 | - if(Locator::getMultipleLocators()){//only checks published locators |
|
| 155 | - if($request->getVar('locatorID')){ |
|
| 150 | + if (Locator::getMultipleLocators()) {//only checks published locators |
|
| 151 | + if ($request->getVar('locatorID')) { |
|
| 156 | 152 | $filter['LocatorID'] = $request->getVar('locatorID'); |
| 157 | 153 | } |
| 158 | 154 | } |
@@ -186,11 +182,11 @@ discard block |
||
| 186 | 182 | //debug::show($locals); |
| 187 | 183 | $categories = ArrayList::create(); |
| 188 | 184 | |
| 189 | - foreach($locals as $local){ |
|
| 185 | + foreach ($locals as $local) { |
|
| 190 | 186 | $categories->add($local->Category()); |
| 191 | 187 | } |
| 192 | 188 | |
| 193 | - if($categories->count()>0){ |
|
| 189 | + if ($categories->count() > 0) { |
|
| 194 | 190 | $fields->push( |
| 195 | 191 | DropdownField::create( |
| 196 | 192 | 'category', |
@@ -1,30 +1,30 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class LocationCsvBulkLoader extends CsvBulkLoader { |
| 3 | 3 | public $columnMap = array( |
| 4 | - 'Name' => 'Title', |
|
| 5 | - //'Address' => 'Address', |
|
| 6 | - 'City' => 'Suburb', |
|
| 7 | - //'State' => 'State', |
|
| 8 | - 'Zip' => 'Postcode', |
|
| 9 | - 'Category' => 'Category.Name', |
|
| 4 | + 'Name' => 'Title', |
|
| 5 | + //'Address' => 'Address', |
|
| 6 | + 'City' => 'Suburb', |
|
| 7 | + //'State' => 'State', |
|
| 8 | + 'Zip' => 'Postcode', |
|
| 9 | + 'Category' => 'Category.Name', |
|
| 10 | 10 | 'Email' => 'EmailAddress' |
| 11 | 11 | ); |
| 12 | 12 | |
| 13 | 13 | public $duplicateChecks = array( |
| 14 | - 'Address' => 'Address', |
|
| 15 | - //'Website' => 'Website' |
|
| 14 | + 'Address' => 'Address', |
|
| 15 | + //'Website' => 'Website' |
|
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | 18 | public $relationCallbacks = array( |
| 19 | - 'Category.Name' => array( |
|
| 20 | - 'relationname' => 'Category', |
|
| 21 | - 'callback' => 'getCatByName' |
|
| 22 | - ) |
|
| 19 | + 'Category.Name' => array( |
|
| 20 | + 'relationname' => 'Category', |
|
| 21 | + 'callback' => 'getCatByName' |
|
| 22 | + ) |
|
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | 25 | public static function getCatByName(&$obj, $val, $record) { |
| 26 | 26 | $val = Convert::raw2sql($val); |
| 27 | - return LocationCategory::get()->filter('Name', $val)->First(); |
|
| 28 | - //); |
|
| 27 | + return LocationCategory::get()->filter('Name', $val)->First(); |
|
| 28 | + //); |
|
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | \ No newline at end of file |
@@ -7,19 +7,19 @@ discard block |
||
| 7 | 7 | ); |
| 8 | 8 | |
| 9 | 9 | static $model_importers = array( |
| 10 | - 'Location' => 'LocationCsvBulkLoader', |
|
| 11 | - 'LocationCategory' => 'CsvBulkLoader' |
|
| 12 | - ); |
|
| 10 | + 'Location' => 'LocationCsvBulkLoader', |
|
| 11 | + 'LocationCategory' => 'CsvBulkLoader' |
|
| 12 | + ); |
|
| 13 | 13 | |
| 14 | 14 | static $menu_title = 'Locator'; |
| 15 | - static $url_segment = 'locator'; |
|
| 15 | + static $url_segment = 'locator'; |
|
| 16 | 16 | |
| 17 | - public function getExportFields() { |
|
| 18 | - return array( |
|
| 19 | - 'Title' => 'Name', |
|
| 20 | - 'Address' => 'Address', |
|
| 21 | - 'Suburb' => 'City', |
|
| 22 | - 'State' => 'State', |
|
| 17 | + public function getExportFields() { |
|
| 18 | + return array( |
|
| 19 | + 'Title' => 'Name', |
|
| 20 | + 'Address' => 'Address', |
|
| 21 | + 'Suburb' => 'City', |
|
| 22 | + 'State' => 'State', |
|
| 23 | 23 | 'Postcode' => 'Postal Code', |
| 24 | 24 | 'Country' => 'Country', |
| 25 | 25 | 'Website' => 'Website', |
@@ -29,6 +29,6 @@ discard block |
||
| 29 | 29 | 'ShowInLocator' => 'Show', |
| 30 | 30 | 'Lat' => 'Lat', |
| 31 | 31 | 'Lng' => 'Lng' |
| 32 | - ); |
|
| 33 | - } |
|
| 32 | + ); |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | static $has_one = array( |
| 15 | 15 | 'Category' => 'LocationCategory', |
| 16 | - 'Locator' => 'Locator' |
|
| 16 | + 'Locator' => 'Locator' |
|
| 17 | 17 | ); |
| 18 | 18 | |
| 19 | 19 | static $casting = array( |
@@ -32,21 +32,21 @@ discard block |
||
| 32 | 32 | // api access via Restful Server module |
| 33 | 33 | static $api_access = true; |
| 34 | 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 | - 'Category.ID', |
|
| 44 | - 'ShowInLocator', |
|
| 45 | - 'Featured', |
|
| 46 | - 'Website', |
|
| 47 | - 'Phone', |
|
| 48 | - 'EmailAddress' |
|
| 49 | - ); |
|
| 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 | + 'Category.ID', |
|
| 44 | + 'ShowInLocator', |
|
| 45 | + 'Featured', |
|
| 46 | + 'Website', |
|
| 47 | + 'Phone', |
|
| 48 | + 'EmailAddress' |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | 51 | // columns for grid field |
| 52 | 52 | static $summary_fields = array( |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | 'Category.Name', |
| 60 | 60 | 'ShowInLocator.NiceAsBoolean', |
| 61 | 61 | 'Featured.NiceAsBoolean', |
| 62 | - 'Coords' |
|
| 62 | + 'Coords' |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | 65 | // Coords status for $summary_fields |
@@ -67,21 +67,21 @@ discard block |
||
| 67 | 67 | return ($this->Lat != 0 && $this->Lng != 0) ? 'true' : 'false'; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - // custom labels for fields |
|
| 70 | + // custom labels for fields |
|
| 71 | 71 | function fieldLabels($includerelations = true) { |
| 72 | - $labels = parent::fieldLabels(); |
|
| 73 | - |
|
| 74 | - $labels['Title'] = 'Name'; |
|
| 75 | - $labels['Suburb'] = "City"; |
|
| 76 | - $labels['Postcode'] = 'Postal Code'; |
|
| 77 | - $labels['ShowInLocator'] = 'Show'; |
|
| 78 | - $labels['ShowInLocator.NiceAsBoolean'] = 'Show'; |
|
| 79 | - $labels['Category.Name'] = 'Category'; |
|
| 80 | - $labels['EmailAddress'] = 'Email'; |
|
| 72 | + $labels = parent::fieldLabels(); |
|
| 73 | + |
|
| 74 | + $labels['Title'] = 'Name'; |
|
| 75 | + $labels['Suburb'] = "City"; |
|
| 76 | + $labels['Postcode'] = 'Postal Code'; |
|
| 77 | + $labels['ShowInLocator'] = 'Show'; |
|
| 78 | + $labels['ShowInLocator.NiceAsBoolean'] = 'Show'; |
|
| 79 | + $labels['Category.Name'] = 'Category'; |
|
| 80 | + $labels['EmailAddress'] = 'Email'; |
|
| 81 | 81 | $labels['Featured.NiceAsBoolean'] = 'Featured'; |
| 82 | - $labels['Coords'] = 'Coords'; |
|
| 82 | + $labels['Coords'] = 'Coords'; |
|
| 83 | 83 | |
| 84 | - return $labels; |
|
| 84 | + return $labels; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function getCMSFields() { |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $fields = parent::getCMSFields(); |
| 90 | 90 | |
| 91 | 91 | // remove Main tab |
| 92 | - $fields->removeByName('Main'); |
|
| 92 | + $fields->removeByName('Main'); |
|
| 93 | 93 | |
| 94 | 94 | // create and populate Info tab |
| 95 | 95 | $fields->addFieldsToTab('Root.Info', array( |
@@ -113,19 +113,19 @@ discard block |
||
| 113 | 113 | $fields->insertAfter(CheckboxField::create('Featured', 'Featured'), 'Title'); |
| 114 | 114 | $fields->insertAfter(CheckboxField::create('ShowInLocator', 'Show on Map'), 'Country'); |
| 115 | 115 | |
| 116 | - // allow to be extended via DataExtension |
|
| 116 | + // allow to be extended via DataExtension |
|
| 117 | 117 | $this->extend('updateCMSFields', $fields); |
| 118 | 118 | |
| 119 | 119 | return $fields; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function validate() { |
|
| 123 | - $result = parent::validate(); |
|
| 124 | - if(Locator::getMultipleLocators() && $this->LocatorID == 0) { |
|
| 125 | - $result->error('You must associate this location with a locator page. Add the location from the desired locator page.'); |
|
| 126 | - } |
|
| 127 | - return $result; |
|
| 128 | - } |
|
| 122 | + public function validate() { |
|
| 123 | + $result = parent::validate(); |
|
| 124 | + if(Locator::getMultipleLocators() && $this->LocatorID == 0) { |
|
| 125 | + $result->error('You must associate this location with a locator page. Add the location from the desired locator page.'); |
|
| 126 | + } |
|
| 127 | + return $result; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * @param Member $member |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | ); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function onBeforeWrite(){ |
|
| 160 | + public function onBeforeWrite(){ |
|
| 161 | 161 | |
| 162 | - if(Locator::get()->count() == 1){ |
|
| 163 | - $this->LocatorID = Locator::get()->first()->ID; |
|
| 164 | - } |
|
| 162 | + if(Locator::get()->count() == 1){ |
|
| 163 | + $this->LocatorID = Locator::get()->first()->ID; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - parent::onBeforeWrite(); |
|
| 167 | - } |
|
| 166 | + parent::onBeforeWrite(); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | 169 | } |
| 170 | 170 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Location extends DataObject implements PermissionProvider{ |
|
| 3 | +class Location extends DataObject implements PermissionProvider { |
|
| 4 | 4 | |
| 5 | 5 | static $db = array( |
| 6 | 6 | 'Title' => 'Varchar(255)', |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function validate() { |
| 123 | 123 | $result = parent::validate(); |
| 124 | - if(Locator::getMultipleLocators() && $this->LocatorID == 0) { |
|
| 124 | + if (Locator::getMultipleLocators() && $this->LocatorID == 0) { |
|
| 125 | 125 | $result->error('You must associate this location with a locator page. Add the location from the desired locator page.'); |
| 126 | 126 | } |
| 127 | 127 | return $result; |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | ); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function onBeforeWrite(){ |
|
| 160 | + public function onBeforeWrite() { |
|
| 161 | 161 | |
| 162 | - if(Locator::get()->count() == 1){ |
|
| 162 | + if (Locator::get()->count() == 1) { |
|
| 163 | 163 | $this->LocatorID = Locator::get()->first()->ID; |
| 164 | 164 | } |
| 165 | 165 | |