function updateCMSFields(FieldList $fields) { if ($this->classHasGoogleMap()) { $fields->addFieldToTab("Root", new Tab("Map")); $fields->addFieldToTab("Root.Map", new CheckboxField("HasGeoInfo", "Has Address(es)? - save and reload this page to start data-entry")); if ($this->owner->HasGeoInfo) { $dataObject = new GoogleMapLocationsObject(); $complexTableFields = $dataObject->complexTableFields(); $source = $this->owner->GeoPoints(); $GeoPointsField = new GridField("GeoPoints", "Locations", $source, GridFieldConfig_RelationEditor::create()); $fields->addFieldToTab("Root.Map", $GeoPointsField); } } return $fields; }
public static function create_new($searchedFor, $parentID = 0, $addGoogleMapLocationsObjectOrItsID = false) { $obj = new GoogleMapSearchRecord(); $obj->SearchedFor = $searchedFor; $obj->ParentID = $parentID; if (!$addGoogleMapLocationsObjectOrItsID) { //do nothing } elseif ($addGoogleMapLocationsObjectOrItsID === true || ($addGoogleMapLocationsObjectOrItsID = 1)) { //create object $location = new GoogleMapLocationsObject(); $location->Address = $searchedFor; $location->Manual = false; $location->write(); $obj->GoogleMapLocationsObjectID = $location->ID; } else { $obj->GoogleMapLocationsObjectID = $addGoogleMapLocationsObjectOrItsID; } $obj->write(); return $obj; }
function createnewbusinesslistingfrompoint($request) { if (!isset($_GET["address"])) { $addressArray = array(); $address = ''; } else { $addressArray = unserialize($_GET["address"]); $address = $addressArray["address"]; } if (!isset($_GET["name"])) { $name = ''; } else { $name = Convert::raw2xml($_GET["name"]); } if (!isset($_GET["parent"])) { $parent = 0; } else { $parent = intval($_GET["parent"]); } if ($member = Member::currentMember()) { if ($name) { if ($parent && ($parentPage = DataObject::get_by_id("SiteTree", $parent))) { if ($address && count($addressArray)) { $allowedParents = BusinessPage::get_can_be_child_off(); if (is_array($allowedParents) && in_array($parentPage->ClassName, $allowedParents)) { $extension = ''; if (Versioned::current_stage() == "Live") { $extension = "_Live"; } $page = DataObject::get_one("BusinessPage", "ParentID = " . $parentPage->ID . " AND SiteTree{$extension}.Title = '" . Convert::raw2sql($name) . "'"); if ($page) { //do nothing } else { $page = new BusinessPage(); $page->Title = $name; $page->MenuTitle = $name; $page->MetaTitle = $name; $page->Email = $member->Email; $page->ParentID = $parentPage->ID; $page->writeToStage('Stage'); $page->publish('Stage', 'Live'); $page->flushCache(); $page->Members()->add($member); $member->addToGroupByCode(BusinessPage::get_member_group_code()); } $point = new GoogleMapLocationsObject(); $point->addDataFromArray($addressArray); $point->ParentID = $page->ID; $point->write(); Director::redirect($page->Link()); return; } else { Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find correct parent page type "))); return; } } else { Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find address page."))); return; } } else { Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find parent page."))); return; } } Director::redirect($this->linkWithExtras(array("address" => $address, "name" => $name, "error" => "Could not find listing name."))); return; } else { Security::permissionFailure($this, "You must have an account and be logged in to create new a new listing."); } }
public function setPageDataObjectSet($PageDataObjectSet) { if (count($PageDataObjectSet)) { $where = "ParentID IN (-1 "; foreach ($PageDataObjectSet as $page) { if ($page->HasGeoInfo) { $where .= ", " . $page->ID; } } $where .= ') '; $this->GooglePointsDataObject = GoogleMapLocationsObject::get()->where($where); $PageDataObjectSet = null; } }
function completePoints() { $uncompletedPoints = GoogleMapLocationsObject::get()->where("\r\n\t\t\t(\r\n\t\t\t\t(\"GoogleMapLocationsObject\".\"Address\" <> \"GoogleMapLocationsObject\".\"FullAddress\")\r\n\t\t\t\tOR (\r\n\t\t\t\t\t\"GoogleMapLocationsObject\".\"Address\" = IsNull\r\n\t\t\t\t\tOR \"GoogleMapLocationsObject\".\"Address\" = ''\r\n\t\t\t\t)\r\n\t\t\t)\r\n\t\t\tAND\r\n\t\t\t\t\"GoogleMapLocationsObject\".\"Manual\" <> 1\r\n\t\t\t\tAND \"GoogleMapLocationsObject\".\"Address\" <> IsNull\r\n\t\t\t\tAND ((\"GoogleMapLocationsObject\".\"Address\") <> '' OR (\"GoogleMapLocationsObject\".\"Longitude\"<> 0\r\n\t\t\t\tAND \"GoogleMapLocationsObject\".\"Latitude\" <> 0\r\n\t\t\t\tAND (\r\n\t\t\t\t\t\"GoogleMapLocationsObject\".\"Address\" = ''\r\n\t\t\t\t\tOR \"GoogleMapLocationsObject\".\"Address\" = IsNull\r\n\t\t\t\t)\r\n\t\t\t)"); if ($uncompletedPoints->count()) { foreach ($uncompletedPoints as $point) { $point->findGooglePoints(false); } } }
public function updatemexml() { //we use request here, because the data comes from javascript! if ($this->owner->canEdit()) { if (isset($_REQUEST["x"]) && isset($_REQUEST["y"]) && isset($_REQUEST["i"]) && isset($_REQUEST["a"])) { $lng = floatval($_REQUEST["x"]); $lat = floatval($_REQUEST["y"]); $id = intval($_REQUEST["i"]); $action = $_REQUEST["a"]; if ($lng && $lat) { if (0 == $id && "add" == $action) { $point = new GoogleMapLocationsObject(); $point->ParentID = $this->owner->ID; $point->Latitude = $lat; $point->Longitude = $lng; $point->write(); return $point->ID; } elseif ($id > 0 && "move" == $action) { $point = GoogleMapLocationsObject::get()->byID($id); if ($point) { if ($point->ParentID == $this->owner->ID) { $point->Latitude = $lat; $point->Longitude = $lng; $point->Address = ""; $point->FullAddress = ""; $point->write(); return "location updated"; } else { return "you dont have permission to update that location"; } } else { return "could not find location"; } } elseif ($id && "remove" == $action) { $point = GoogleMapLocationsObject::get()->byID($id); if ($point) { if ($point->ParentID == $this->owner->ID) { $point->delete(); $point = null; return "location deleted"; } else { return "you dont have permission to delete that location"; } } else { return "could not find location."; } } } else { return "point not defined."; } } else { return "not enough information was provided."; } } return "point could NOT be updated."; }