/** * Standard SS Method * Setup records * **/ public function requireDefaultRecords() { parent::requireDefaultRecords(); $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; $parents = DataObject::get("BrowseCountriesPage"); if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { foreach ($parents as $parent) { if ($parent->HiddenDataID) { echo "<li>creating regions for " . $parent->Title . "<ul>"; $regions = $this->getDataFromTable("regions", "CountryID = " . $parent->HiddenDataID, "Region"); foreach ($regions as $region) { if (!DataObject::get("BrowseRegionsPage", "{$bt}BrowseAbstractPage{$bt}.{$bt}HiddenDataID{$bt} = " . $region["RegionID"])) { $page = new BrowseRegionsPage(); $page->CreateRegion($region, $parent); $page->destroy(); } } echo "</ul></li>"; } else { if (isset($_GET["geobuild"])) { debug::show("Parent does not exist"); } } } } }
/** * 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>"; } } } }
/** * Standard SS function * Creating level of detail * Note that the _GET variable "geobuild" needs to be turned on. **/ public function requireDefaultRecords() { parent::requireDefaultRecords(); $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; $parents = DataObject::get("BrowseWorldPage"); if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"]) { foreach ($parents as $parent) { if ($parent->CreateChildren) { echo "<li>creating continents for " . $parent->Title . "<ul>"; $continents = $this->getDataFromTable("continents", null, "Continent"); foreach ($continents as $continent) { if (!DataObject::get("BrowseContinentsPage", "{$bt}BrowseAbstractPage{$bt}.{$bt}HiddenDataID{$bt} = " . $continent["ContinentID"])) { $page = new BrowseContinentsPage(); $page->CreateContinent($continent, $parent); $page->destroy(); } } echo "</ul></li>"; } } } }
/** * fix URLS * NOTE: you must set get variables: urls, from and to.... **/ public function requireDefaultRecords() { parent::requireDefaultRecords(); if (isset($_GET["urls"]) && isset($_GET["from"]) && isset($_GET["to"])) { $dos = DataObject::get("SiteTree", null, null, null, $_GET["from"] . ',' . $_GET["to"]); foreach ($dos as $page) { if (isset($page)) { echo "<li>fixing " . $page->Title . "</li>"; $page->URLSegment = $this->generateURLSegment($page->Title); $page->writeToStage('Stage'); $page->publish('Stage', 'Live'); $page->flushCache(); $page->detroy(); } } } }
/** * Standard SS method * CMS Fields **/ public function getCMSFields() { $fields = parent::getCMSFields(); return $fields; }