Source of file BrowseRegionsPage.php
Size: 3,952 Bytes - Last Modified: 2021-12-23T10:41:46+00:00
/var/www/docs.ssmods.com/process/src/code/BrowseRegionsPage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | <?php class BrowseRegionsPage extends BrowseAbstractPage { /** * Standard SS Static **/ public static $icon = "geobrowser/images/treeicons/BrowseRegionsPage"; /** * Standard SS Static **/ public static $allowed_children = array("BrowseCitiesPage"); /** * Standard SS Static **/ public static $default_child = "BrowseCitiesPage"; /** * Standard SS Static **/ public static $default_parent = "BrowseCountriesPage"; /** * Standard SS Static **/ public static $can_be_root = false; /** * Standard SS Static **/ public static $db = array( "Code" => "Varchar(8)", ); /** * Standard SS Static **/ public static $defaults = array( "ShowInMenus" => false ); /** * Standard SS Static **/ public function getCMSFields() { $fields = parent::getCMSFields(); return $fields; } /** * Name of the level **/ public function GeoLevelName() { return "Regions"; } /** * Number of the level **/ public function GeoLevelNumber() { return 2; } /** * Setup pages... **/ public function requireDefaultRecords() { parent::requireDefaultRecords(); $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; $parents = DataObject::get("BrowseRegionsPage"); if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { foreach ($parents as $parent) { if ($parent->CreateChildren && $parent->HiddenDataID) { echo "<li>creating cities for ".$parent->Title."<ul>"; $cities = $this->getDataFromTable("cities", "RegionID = ".$parent->HiddenDataID, "City"); foreach ($cities as $city) { if (!DataObject::get_one("BrowseCitiesPage", "{$bt}BrowseAbstractPage{$bt}.{$bt}HiddenDataID{$bt} = ".$city["CityID"])) { $page = new BrowseCitiesPage(); $page->CreateCity($city, $parent); $page->destroy(); } } echo "</ul></li>"; } } $parents->destroy(); } } /** * Creates a region... called from BrowseCountriesPage * *@param Array $region - array of region details *@param Object $parent - a BrowseCountriesPage object * **/ public function CreateRegion(array $region, BrowseCountriesPage $parent) { if ($parent && isset($region["Region"])) { $name = htmlentities($region["Region"]); if ($name) { if (isset($_GET["geobuild"])) { echo "<li>creating ".$name."</li>"; } $this->ParentID = $parent->ID; $this->Title = $name; $this->MetaTitle = $name; $this->MenuTitle = $name; $this->HiddenDataID = $region["RegionID"]; $this->Code = $region["Code"]; $this->CreateChildren = $parent->CreateAllChildren; $this->CreateAllChildren = $parent->CreateAllChildren; $this->URLSegment = $this->generateURLSegment($this->Title); $this->writeToStage('Stage'); $this->publish('Stage', 'Live'); $this->flushCache(); } else { if (isset($_GET["geobuild"])) { debug::show("region does not exist"); } } } else { if (isset($_GET["geobuild"])) { debug::show("Parent does not exist"); } } } } class BrowseRegionsPage_Controller extends BrowseAbstractPage_Controller { } |