mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Creation of a new page type now uses a consistent source of classes that respect $hide_ancestor on SiteTree.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@70131 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
53c87fe7e0
commit
dd4228fc1d
@ -190,6 +190,41 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
*/
|
*/
|
||||||
private static $runCMSFieldsExtensions = true;
|
private static $runCMSFieldsExtensions = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a subclass map of SiteTree
|
||||||
|
* that shouldn't be hidden through
|
||||||
|
* {@link SiteTree::$hide_ancestor}
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function page_type_classes() {
|
||||||
|
$classes = ClassInfo::getValidSubClasses();
|
||||||
|
array_shift($classes);
|
||||||
|
$kill_ancestors = array();
|
||||||
|
|
||||||
|
// figure out if there are any classes we don't want to appear
|
||||||
|
foreach($classes as $class) {
|
||||||
|
$instance = singleton($class);
|
||||||
|
|
||||||
|
// do any of the progeny want to hide an ancestor?
|
||||||
|
if($ancestor_to_hide = $instance->stat('hide_ancestor')) {
|
||||||
|
// note for killing later
|
||||||
|
$kill_ancestors[] = $ancestor_to_hide;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If any of the descendents don't want any of the elders to show up, cruelly render the elders surplus to requirements.
|
||||||
|
if($kill_ancestors) {
|
||||||
|
foreach ($kill_ancestors as $mark) {
|
||||||
|
// unset from $classes
|
||||||
|
$idx = array_search($mark, $classes);
|
||||||
|
unset($classes[$idx]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $classes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the URL for this page.
|
* Get the URL for this page.
|
||||||
*
|
*
|
||||||
@ -1476,9 +1511,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getClassDropdown() {
|
protected function getClassDropdown() {
|
||||||
$classes = ClassInfo::getValidSubClasses('SiteTree');
|
$classes = self::page_type_classes();
|
||||||
array_shift($classes);
|
|
||||||
|
|
||||||
$currentClass = null;
|
$currentClass = null;
|
||||||
|
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
|
Loading…
Reference in New Issue
Block a user