|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class BrowseContinentsPage extends BrowseAbstractPage |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Standard SS static |
|
8
|
|
|
**/ |
|
9
|
|
|
public static $icon = "geobrowser/images/treeicons/BrowseContinentsPage"; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Standard SS static |
|
14
|
|
|
**/ |
|
15
|
|
|
public static $allowed_children = array("BrowseCountriesPage"); |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Standard SS static |
|
19
|
|
|
**/ |
|
20
|
|
|
public static $default_child = "BrowseCountriesPage"; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Standard SS static |
|
24
|
|
|
**/ |
|
25
|
|
|
public static $default_parent = "BrowseWorldPage"; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Standard SS Static |
|
29
|
|
|
**/ |
|
30
|
|
|
public static $can_be_root = false; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Standard SS Static |
|
34
|
|
|
**/ |
|
35
|
|
|
public static $defaults = array( |
|
36
|
|
|
"ShowInMenus" => true |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* name of the level |
|
41
|
|
|
**/ |
|
42
|
|
|
public function GeoLevelName() |
|
43
|
|
|
{ |
|
44
|
|
|
return "Continents"; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* number of the level |
|
49
|
|
|
**/ |
|
50
|
|
|
public function GeoLevelNumber() |
|
51
|
|
|
{ |
|
52
|
|
|
return 0; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Standard SS Method |
|
57
|
|
|
* setup records |
|
58
|
|
|
**/ |
|
59
|
|
|
public function requireDefaultRecords() |
|
|
|
|
|
|
60
|
|
|
{ |
|
61
|
|
|
$bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
|
62
|
|
|
parent::requireDefaultRecords(); |
|
63
|
|
|
$parents = DataObject::get("BrowseContinentsPage"); |
|
64
|
|
|
if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) { |
|
65
|
|
View Code Duplication |
foreach ($parents as $parent) { |
|
|
|
|
|
|
66
|
|
|
if ($parent->CreateChildren && $parent->HiddenDataID) { |
|
67
|
|
|
echo "<li>creating countries for ".$parent->Title."<ul>"; |
|
68
|
|
|
$countries = $this->getDataFromTable("countries", "ContinentID = ".$parent->HiddenDataID, "Country"); |
|
69
|
|
|
foreach ($countries as $country) { |
|
70
|
|
|
if (!DataObject::get_one("BrowseCountriesPage", "{$bt}HiddenDataID{$bt} = ".$country["CountryID"])) { |
|
71
|
|
|
$page = new BrowseCountriesPage(); |
|
72
|
|
|
$page->CreateCountry($country, $parent); |
|
73
|
|
|
$page->destroy(); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
echo "</ul></li>"; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* create a continent |
|
84
|
|
|
* @param array - $contentint, continent data |
|
85
|
|
|
* @param Object - $parent, a BrowseWorldPage object that will be the parent page of the Continent. |
|
86
|
|
|
**/ |
|
87
|
|
|
public function CreateContinent(array $continent, BrowseWorldPage $parent) |
|
|
|
|
|
|
88
|
|
|
{ |
|
89
|
|
|
$bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
|
|
|
|
|
|
90
|
|
|
if ($parent && isset($continent["Continent"])) { |
|
91
|
|
|
$name = htmlentities($continent["Continent"]); |
|
92
|
|
|
if ($name) { |
|
93
|
|
|
if (isset($_GET["geobuild"])) { |
|
94
|
|
|
echo "<li>creating ".$name."</li>"; |
|
95
|
|
|
} |
|
96
|
|
|
$this->ParentID = $parent->ID; |
|
97
|
|
|
$this->Title = $name; |
|
98
|
|
|
$this->MetaTitle = $name; |
|
99
|
|
|
$this->MenuTitle = $name; |
|
100
|
|
|
$this->HiddenDataID = $continent["ContinentID"]; |
|
101
|
|
|
$this->CreateChildren = $parent->CreateAllChildren; |
|
102
|
|
|
$this->CreateAllChildren = $parent->CreateAllChildren; |
|
103
|
|
|
$this->writeToStage('Stage'); |
|
104
|
|
|
$this->publish('Stage', 'Live'); |
|
105
|
|
|
$this->flushCache(); |
|
106
|
|
|
} else { |
|
107
|
|
|
if (isset($_GET["geobuild"])) { |
|
108
|
|
|
debug::show("name does not exist"); |
|
109
|
|
|
} |
|
110
|
|
|
} |
|
111
|
|
|
} else { |
|
112
|
|
|
if (isset($_GET["geobuild"])) { |
|
113
|
|
|
debug::show("Parent does not exist"); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
class BrowseContinentsPage_Controller extends BrowseAbstractPage_Controller |
|
|
|
|
|
|
120
|
|
|
{ |
|
121
|
|
|
} |
|
122
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.