|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
class BrowseWorldPage extends BrowseAbstractPage |
|
|
|
|
|
|
6
|
|
|
{ |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Standard SS Static |
|
10
|
|
|
**/ |
|
11
|
|
|
public static $icon = "geobrowser/images/treeicons/BrowseWorldPage"; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Standard SS static |
|
15
|
|
|
**/ |
|
16
|
|
|
public static $allowed_children = array("BrowseContinentsPage"); |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Standard SS Static |
|
20
|
|
|
**/ |
|
21
|
|
|
public static $default_child = "BrowseContinentsPage"; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Standard SS Static |
|
25
|
|
|
**/ |
|
26
|
|
|
public static $db = array( |
|
27
|
|
|
"LevelOfDetail" => "Int", |
|
28
|
|
|
); |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Standard SS Static |
|
32
|
|
|
**/ |
|
33
|
|
|
public static $defaults = array( |
|
34
|
|
|
"CreateChildren" => true, |
|
35
|
|
|
"LevelOfDetail" => 2, |
|
36
|
|
|
"ShowInMenus" => true |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var Array |
|
41
|
|
|
* Sets the level of detail in terms of the pages that are automatically created. |
|
42
|
|
|
**/ |
|
43
|
|
|
protected static $LevelOfDetailArray = array( |
|
44
|
|
|
"0" => "Continents", |
|
45
|
|
|
"1" => "Countries", |
|
46
|
|
|
"2" => "Regions", |
|
47
|
|
|
"3" => "Cities", |
|
48
|
|
|
"4" => "Suburbs" |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function getCMSFields() |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
$fields = parent::getCMSFields(); |
|
55
|
|
|
$fields->addFieldToTab("Root.Content.AddSubRegion", new DropdownField("LevelOfDetail", "Greatest Level of Detail in pages shown ...", self::$LevelOfDetailArray)); |
|
56
|
|
|
return $fields; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Standard SS function |
|
61
|
|
|
* Creating level of detail |
|
62
|
|
|
* Note that the _GET variable "geobuild" needs to be turned on. |
|
63
|
|
|
**/ |
|
64
|
|
|
public function requireDefaultRecords() |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
parent::requireDefaultRecords(); |
|
67
|
|
|
$bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; |
|
68
|
|
|
$parents = DataObject::get("BrowseWorldPage"); |
|
69
|
|
|
if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"]) { |
|
70
|
|
View Code Duplication |
foreach ($parents as $parent) { |
|
|
|
|
|
|
71
|
|
|
if ($parent->CreateChildren) { |
|
72
|
|
|
echo "<li>creating continents for ".$parent->Title."<ul>"; |
|
73
|
|
|
$continents = $this->getDataFromTable("continents", null, "Continent"); |
|
74
|
|
|
foreach ($continents as $continent) { |
|
75
|
|
|
if (!DataObject::get("BrowseContinentsPage", "{$bt}BrowseAbstractPage{$bt}.{$bt}HiddenDataID{$bt} = ".$continent["ContinentID"])) { |
|
76
|
|
|
$page = new BrowseContinentsPage(); |
|
77
|
|
|
$page->CreateContinent($continent, $parent); |
|
78
|
|
|
$page->destroy(); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
echo "</ul></li>"; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
class BrowseWorldPage_Controller extends BrowseAbstractPage_Controller |
|
|
|
|
|
|
89
|
|
|
{ |
|
90
|
|
|
} |
|
91
|
|
|
|
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.