Source of file BrowseCountriesPage.php
Size: 4,735 Bytes - Last Modified: 2021-12-23T10:41:46+00:00
/var/www/docs.ssmods.com/process/src/code/BrowseCountriesPage.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 | <?php class BrowseCountriesPage extends BrowseAbstractPage { /** * Standard SS static **/ public static $icon = "geobrowser/images/treeicons/BrowseCountriesPage"; /** * Standard SS static **/ public static $allowed_children = array("BrowseRegionsPage"); /** * Standard SS static **/ public static $default_child = "BrowseRegionsPage"; /** * Standard SS static **/ public static $default_parent = "BrowseContinentsPage"; /** * Standard SS static **/ public static $can_be_root = false; /** * Standard SS static **/ public static $db = array( "Country" => "Varchar(50)" , "ISO2" => "Varchar(2)" , "Internet" => "Varchar(2)" , "Capital" => "Varchar(25)" , "NationalitySingular" => "Varchar(35)" , "NationalityPlural" => "Varchar(35)" , "Currency" => "Varchar(30)" , "CurrencyCode" => "Varchar(3)" , "Population" => "Int" , "AdditionalTitle" => "Varchar(50)" ); /** * Standard SS Static **/ public static $defaults = array( "ShowInMenus" => false ); /** * Standard SS Method **/ public function getCMSFields() { $fields = parent::getCMSFields(); return $fields; } public function GeoLevelName() { return "Countries"; } public function GeoLevelNumber() { return 1; } /** * 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"); } } } } } /** * Create a country based on an array and a Continent Parent **/ public function CreateCountry(array $country, BrowseContinentsPage $parent) { if ($parent && isset($country["Country"])) { $name = htmlentities($country["Country"]); 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 = $country["CountryID"]; $this->ISO2 = $country["ISO2"]; $this->Internet = $country["Internet"]; $this->Capital = htmlentities($country["Capital"]); $this->NationalitySingular = htmlentities($country["NationalitySingular"]); $this->NationalityPlural = htmlentities($country["NationalityPlural"]); $this->Currency = $country["Currency"]; $this->CurrencyCode = $country["CurrencyCode"]; $this->Population = $country["Population"]; $this->AdditionalTitle = htmlentities($country["Title"]); $this->CreateChildren = $parent->CreateAllChildren; $this->CreateAllChildren = $parent->CreateAllChildren; $this->writeToStage('Stage'); $this->publish('Stage', 'Live'); $this->flushCache(); } else { if (isset($_GET["geobuild"])) { debug::show("name does not exist"); } } } else { if (isset($_GET["geobuild"])) { debug::show("Parent does not exist"); } } } } class BrowseCountriesPage_Controller extends BrowseAbstractPage_Controller { } |