/**
  * Standard SS Method
  * setup records
  **/
 public function requireDefaultRecords()
 {
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     parent::requireDefaultRecords();
     $parents = DataObject::get("BrowseContinentsPage");
     if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) {
         foreach ($parents as $parent) {
             if ($parent->CreateChildren && $parent->HiddenDataID) {
                 echo "<li>creating countries for " . $parent->Title . "<ul>";
                 $countries = $this->getDataFromTable("countries", "ContinentID = " . $parent->HiddenDataID, "Country");
                 foreach ($countries as $country) {
                     if (!DataObject::get_one("BrowseCountriesPage", "{$bt}HiddenDataID{$bt} = " . $country["CountryID"])) {
                         $page = new BrowseCountriesPage();
                         $page->CreateCountry($country, $parent);
                         $page->destroy();
                     }
                 }
                 echo "</ul></li>";
             }
         }
     }
 }
    /**
     * This static method creates a city page and all the required parent pages...
     *@param Int - $CityID: the ID for the city to create
     **/
    public static function create_city_and_parents($CityID)
    {
        $cityPage = null;
        //check if the city exists at all
        $sql = '
			SELECT cities.RegionID, regions.CountryID, countries.ContinentID From cities, regions, countries, continents
			WHERE
				cities.RegionID = regions.RegionID AND
				regions.CountryID = countries.CountryID AND
				countries.ContinentID = continents.ContinentID AND
				cities.CityID = ' . $CityID . '
			LIMIT 1;';
        $result = DB::query($sql);
        foreach ($result as $row) {
            break;
        }
        $abstractHelpPage = new BrowseAbstractPage();
        if ($row) {
            //1 check if world exists
            if ($worldPage = DataObject::get_one("BrowseWorldPage")) {
                //do nothing
            } else {
                $worldPage = new BrowseWorldPage();
                $name = "Find";
                $worldPage->Title = $name;
                $worldPage->MetaTitle = $name;
                $worldPage->MenuTitle = $name;
                $worldPage->writeToStage('Stage');
                $worldPage->publish('Stage', 'Live');
                $worldPage->flushCache();
            }
            //2 check if continent exists
            $ContinentID = $row["ContinentID"];
            if ($continentPage = DataObject::get_one("BrowseContinentsPage", 'HiddenDataID = ' . $ContinentID)) {
                //debug::show("continent exists");
            } else {
                //create continent
                $continents = $abstractHelpPage->getDataFromTable("continents", "ContinentID = " . $ContinentID, null);
                foreach ($continents as $continentData) {
                    $continentPage = new BrowseContinentsPage();
                    $continentPage->CreateContinent($continentData, $worldPage);
                }
            }
            //3 check if country exists
            $CountryID = $row["CountryID"];
            if ($countryPage = DataObject::get_one("BrowseCountriesPage", 'HiddenDataID = ' . $CountryID)) {
                //debug::show("country exists");
            } else {
                //create Country
                $countries = $abstractHelpPage->getDataFromTable("countries", "CountryID = " . $CountryID, null);
                foreach ($countries as $countryData) {
                    $countryPage = new BrowseCountriesPage();
                    $countryPage->CreateCountry($countryData, $continentPage);
                }
            }
            //4 check if region exists
            $RegionID = $row["RegionID"];
            if ($regionPage = DataObject::get_one("BrowseRegionsPage", 'HiddenDataID = ' . $RegionID)) {
                //debug::show("region exists");
            } else {
                //create region
                $regions = $abstractHelpPage->getDataFromTable("regions", "RegionID = " . $RegionID, null);
                foreach ($regions as $regionData) {
                    $regionPage = new BrowseRegionsPage();
                    $regionPage->CreateRegion($regionData, $countryPage);
                }
            }
            if ($cityPage = DataObject::get_one("BrowseCitiesPage", 'HiddenDataID = ' . $CityID)) {
                //debug::show("city exists");
            } else {
                //create region
                $cities = $abstractHelpPage->getDataFromTable("cities", "CityID = " . $CityID, null);
                foreach ($cities as $city) {
                    $cityPage = new BrowseCitiesPage();
                    $cityPage->CreateCity($city, $regionPage);
                }
            }
        }
        return $cityPage;
    }