mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #1056 from stojg/issue/cms-1049
BUG: Delete parent page, child pages cannot be found anymore
This commit is contained in:
commit
4967d3dbf6
@ -36,6 +36,11 @@ abstract class CMSSiteTreeFilter extends Object {
|
|||||||
*/
|
*/
|
||||||
protected $childrenMethod = null;
|
protected $childrenMethod = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $numChildrenMethod = 'numChildren';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a sorted array of all implementators of CMSSiteTreeFilter, suitable for use in a dropdown.
|
* Returns a sorted array of all implementators of CMSSiteTreeFilter, suitable for use in a dropdown.
|
||||||
*
|
*
|
||||||
@ -71,13 +76,21 @@ abstract class CMSSiteTreeFilter extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String Method on {@link Hierarchy} objects
|
* Method on {@link Hierarchy} objects which is used to traverse into children relationships.
|
||||||
* which is used to traverse into children relationships.
|
*
|
||||||
|
* @return String
|
||||||
*/
|
*/
|
||||||
public function getChildrenMethod() {
|
public function getChildrenMethod() {
|
||||||
return $this->childrenMethod;
|
return $this->childrenMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method on {@link Hierarchy} objects which is used find the number of children for a parent page
|
||||||
|
*/
|
||||||
|
public function getNumChildrenMethod() {
|
||||||
|
return $this->numChildrenMethod;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Array Map of Page IDs to their respective ParentID values.
|
* @return Array Map of Page IDs to their respective ParentID values.
|
||||||
*/
|
*/
|
||||||
@ -101,17 +114,13 @@ abstract class CMSSiteTreeFilter extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(!empty($parents)) {
|
while(!empty($parents)) {
|
||||||
$q = new SQLQuery();
|
$q = Versioned::get_including_deleted('SiteTree', '"RecordID" in ('.implode(',',array_keys($parents)).')');
|
||||||
$q->setSelect(array('"ID"','"ParentID"'))
|
$list = $q->map('ID', 'ParentID');
|
||||||
->setFrom('"SiteTree"')
|
|
||||||
->setWhere('"ID" in ('.implode(',',array_keys($parents)).')');
|
|
||||||
|
|
||||||
$parents = array();
|
$parents = array();
|
||||||
|
foreach($list as $id => $parentID) {
|
||||||
foreach($q->execute() as $row) {
|
if ($parentID) $parents[$parentID] = true;
|
||||||
if ($row['ParentID']) $parents[$row['ParentID']] = true;
|
$this->_cache_ids[$id] = true;
|
||||||
$this->_cache_ids[$row['ID']] = true;
|
$this->_cache_expanded[$id] = true;
|
||||||
$this->_cache_expanded[$row['ID']] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,8 +212,16 @@ abstract class CMSSiteTreeFilter extends Object {
|
|||||||
*/
|
*/
|
||||||
class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter {
|
class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $childrenMethod = "AllHistoricalChildren";
|
protected $childrenMethod = "AllHistoricalChildren";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $numChildrenMethod = 'numHistoricalChildren';
|
||||||
|
|
||||||
static public function title() {
|
static public function title() {
|
||||||
return _t('CMSSiteTreeFilter_DeletedPages.Title', "All pages, including deleted");
|
return _t('CMSSiteTreeFilter_DeletedPages.Title', "All pages, including deleted");
|
||||||
}
|
}
|
||||||
@ -303,8 +320,16 @@ class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter {
|
|||||||
*/
|
*/
|
||||||
class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $childrenMethod = "AllHistoricalChildren";
|
protected $childrenMethod = "AllHistoricalChildren";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $numChildrenMethod = 'numHistoricalChildren';
|
||||||
|
|
||||||
static public function title() {
|
static public function title() {
|
||||||
return _t('CMSSiteTreeFilter_StatusDeletedPages.Title', 'Deleted pages');
|
return _t('CMSSiteTreeFilter_StatusDeletedPages.Title', 'Deleted pages');
|
||||||
}
|
}
|
||||||
@ -318,6 +343,7 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter {
|
|||||||
public function pagesIncluded() {
|
public function pagesIncluded() {
|
||||||
$pages = Versioned::get_including_deleted('SiteTree');
|
$pages = Versioned::get_including_deleted('SiteTree');
|
||||||
$pages = $this->applyDefaultFilters($pages);
|
$pages = $this->applyDefaultFilters($pages);
|
||||||
|
|
||||||
$pages = $pages->filterByCallback(function($page) {
|
$pages = $pages->filterByCallback(function($page) {
|
||||||
// Doesn't exist on either stage or live
|
// Doesn't exist on either stage or live
|
||||||
return $page->IsDeletedFromStage && !$page->ExistsOnLive;
|
return $page->IsDeletedFromStage && !$page->ExistsOnLive;
|
||||||
|
@ -2736,9 +2736,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
/**
|
/**
|
||||||
* Return the CSS classes to apply to this node in the CMS tree
|
* Return the CSS classes to apply to this node in the CMS tree
|
||||||
*
|
*
|
||||||
|
* @param string $numChildrenMethod
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function CMSTreeClasses() {
|
public function CMSTreeClasses($numChildrenMethod="numChildren") {
|
||||||
$classes = sprintf('class-%s', $this->class);
|
$classes = sprintf('class-%s', $this->class);
|
||||||
if($this->HasBrokenFile || $this->HasBrokenLink) {
|
if($this->HasBrokenFile || $this->HasBrokenLink) {
|
||||||
$classes .= " BrokenLink";
|
$classes .= " BrokenLink";
|
||||||
@ -2765,7 +2766,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
if($this->hasExtension('Translatable') && $controller->Locale != Translatable::default_locale() && !$this->isTranslation())
|
if($this->hasExtension('Translatable') && $controller->Locale != Translatable::default_locale() && !$this->isTranslation())
|
||||||
$classes .= " untranslated ";
|
$classes .= " untranslated ";
|
||||||
*/
|
*/
|
||||||
$classes .= $this->markingClasses();
|
$classes .= $this->markingClasses($numChildrenMethod);
|
||||||
|
|
||||||
return $classes;
|
return $classes;
|
||||||
}
|
}
|
||||||
|
@ -387,8 +387,12 @@ class VirtualPage extends Page {
|
|||||||
$this->ImageTracking()->setByIdList($this->CopyContentFrom()->ImageTracking()->column('ID'));
|
$this->ImageTracking()->setByIdList($this->CopyContentFrom()->ImageTracking()->column('ID'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CMSTreeClasses() {
|
/**
|
||||||
return parent::CMSTreeClasses() . ' VirtualPage-' . $this->CopyContentFrom()->ClassName;
|
* @param string $numChildrenMethod
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function CMSTreeClasses($numChildrenMethod="numChildren") {
|
||||||
|
return parent::CMSTreeClasses($numChildrenMethod) . ' VirtualPage-' . $this->CopyContentFrom()->ClassName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user