Source of file BrowseWorldPage.php
Size: 2,595 Bytes - Last Modified: 2021-12-23T10:41:46+00:00
/var/www/docs.ssmods.com/process/src/code/BrowseWorldPage.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | <?php class BrowseWorldPage extends BrowseAbstractPage { /** * Standard SS Static **/ public static $icon = "geobrowser/images/treeicons/BrowseWorldPage"; /** * Standard SS static **/ public static $allowed_children = array("BrowseContinentsPage"); /** * Standard SS Static **/ public static $default_child = "BrowseContinentsPage"; /** * Standard SS Static **/ public static $db = array( "LevelOfDetail" => "Int", ); /** * Standard SS Static **/ public static $defaults = array( "CreateChildren" => true, "LevelOfDetail" => 2, "ShowInMenus" => true ); /** * @var Array * Sets the level of detail in terms of the pages that are automatically created. **/ protected static $LevelOfDetailArray = array( "0" => "Continents", "1" => "Countries", "2" => "Regions", "3" => "Cities", "4" => "Suburbs" ); public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldToTab("Root.Content.AddSubRegion", new DropdownField("LevelOfDetail", "Greatest Level of Detail in pages shown ...", self::$LevelOfDetailArray)); return $fields; } /** * 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>"; } } } } } class BrowseWorldPage_Controller extends BrowseAbstractPage_Controller { } |