/** * @see AllChildrenIncludingDeleted * * @param unknown_type $context * @return DataObjectSet */ public function doAllChildrenIncludingDeleted($context = null) { // Cache the allChildren data, so that future requests will return the references to the same // object. This allows the mark..() system to work appropriately. if (!$this->allChildrenIncludingDeleted) { $baseClass = ClassInfo::baseDataClass($this->owner->class); if ($baseClass) { $stageChildren = $this->owner->stageChildren(true); $this->allChildrenIncludingDeleted = $stageChildren; $this->owner->extend("augmentAllChildrenIncludingDeleted", $stageChildren, $context); // Add live site content, if required. if ($this->owner->hasExtension('Versioned')) { // Get all the requisite data, and index it $liveChildren = $this->owner->liveChildren(true); if (isset($stageChildren)) { foreach ($stageChildren as $child) { $idxStageChildren[$child->ID] = $child; } } if (isset($liveChildren)) { foreach ($liveChildren as $child) { $idxLiveChildren[$child->ID] = $child; } } DataObject::disable_subclass_access(); if (isset($idxStageChildren)) { $foundInLive = Versioned::get_by_stage($baseClass, 'Live', "`{$baseClass}`.`ID` IN (" . implode(",", array_keys($idxStageChildren)) . ")", ""); } if (isset($idxLiveChildren)) { $foundInStage = Versioned::get_by_stage($baseClass, 'Stage', "`{$baseClass}`.`ID` IN (" . implode(",", array_keys($idxLiveChildren)) . ")", ""); } DataObject::enable_subclass_access(); if (isset($foundInLive)) { foreach ($foundInLive as $child) { $idxFoundInLive[$child->ID] = $child; } } if (isset($foundInStage)) { foreach ($foundInStage as $child) { $idxFoundInStage[$child->ID] = $child; } } $this->allChildrenIncludingDeleted = new DataObjectSet(); // First, go through the stage children. They will all be listed but may be different colours if ($stageChildren) { foreach ($stageChildren as $child) { $this->allChildrenIncludingDeleted->push($child); } } // Next, go through the live children. Only some of these will be listed if ($liveChildren) { foreach ($liveChildren as $child) { // Not found on stage = deleted page. Anything else is ignored if (!isset($idxFoundInStage[$child->ID])) { $this->allChildrenIncludingDeleted->push($child); } } } } } else { user_error("Hierarchy::AllChildren() Couldn't determine base class for '{$this->owner->class}'", E_USER_ERROR); } } return $this->allChildrenIncludingDeleted; }