mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-09-30 05:09:11 +02:00
MINOR phpDoc for CMSMain->PageTypes()
MINOR Code syntax formatting for CMSMain->PageTypes() MINOR Removed commented out code in CMSMain->PageTypes() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@64395 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
86b81b81f5
commit
1acd10f35a
@ -262,8 +262,10 @@ JS;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates an array of classes in the CMS which allows the
|
* Populates an array of classes in the CMS
|
||||||
* user to change the page type.
|
* which allows the user to change the page type.
|
||||||
|
*
|
||||||
|
* @return DataObjectSet
|
||||||
*/
|
*/
|
||||||
public function PageTypes() {
|
public function PageTypes() {
|
||||||
$classes = ClassInfo::getValidSubClasses();
|
$classes = ClassInfo::getValidSubClasses();
|
||||||
@ -273,51 +275,42 @@ JS;
|
|||||||
|
|
||||||
// figure out if there are any classes we don't want to appear
|
// figure out if there are any classes we don't want to appear
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
$instance = singleton($class);
|
$instance = singleton($class);
|
||||||
|
|
||||||
// do any of the progeny want to hide an ancestor?
|
// do any of the progeny want to hide an ancestor?
|
||||||
if ($ancestor_to_hide = $instance->stat('hide_ancestor')){
|
if($ancestor_to_hide = $instance->stat('hide_ancestor')) {
|
||||||
// note for killing later
|
// note for killing later
|
||||||
$kill_ancestors[] = $ancestor_to_hide;
|
$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 any of the descendents don't want any of the elders to show up, cruelly render the elders surplus to requirements.
|
||||||
if ($kill_ancestors) {
|
if($kill_ancestors) {
|
||||||
foreach ($kill_ancestors as $mark) {
|
foreach ($kill_ancestors as $mark) {
|
||||||
// unset from $classes
|
// unset from $classes
|
||||||
$idx = array_search($mark, $classes);
|
$idx = array_search($mark, $classes);
|
||||||
unset($classes[$idx]);
|
unset($classes[$idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
$instance = singleton($class);
|
$instance = singleton($class);
|
||||||
if($instance instanceof HiddenClass) continue;
|
|
||||||
|
|
||||||
if( !$instance->canCreate() ) continue;
|
if($instance instanceof HiddenClass) continue;
|
||||||
|
|
||||||
|
if(!$instance->canCreate()) continue;
|
||||||
|
|
||||||
// skip this type if it is restricted
|
// skip this type if it is restricted
|
||||||
if($instance->stat('need_permission') && !$this->can( singleton($class)->stat('need_permission') ) ) continue;
|
if($instance->stat('need_permission') && !$this->can(singleton($class)->stat('need_permission'))) continue;
|
||||||
|
|
||||||
/*
|
|
||||||
* Since i18n_singular_name() this is not necessary
|
|
||||||
$addAction = $instance->uninherited('add_action', true);
|
|
||||||
if($addAction) {
|
|
||||||
// backwards compatibility for actions like "a page" (instead of "page")
|
|
||||||
$addAction = preg_replace('/^a /','',$addAction);
|
|
||||||
$addAction = ucfirst($addAction);
|
|
||||||
} else {
|
|
||||||
$addAction = $instance->i18n_singular_name();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$addAction = $instance->i18n_singular_name();
|
$addAction = $instance->i18n_singular_name();
|
||||||
|
|
||||||
$result->push(new ArrayData(array(
|
$result->push(new ArrayData(array(
|
||||||
"ClassName" => $class,
|
'ClassName' => $class,
|
||||||
"AddAction" => $addAction,
|
'AddAction' => $addAction,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$result->sort('AddAction');
|
$result->sort('AddAction');
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
Reference in New Issue
Block a user