From 728bcfe47087b5289f7cc5c32aeb5e0ccaa6273f Mon Sep 17 00:00:00 2001 From: Normann Lou Date: Tue, 24 Apr 2012 17:32:52 +1200 Subject: [PATCH] MINOR: add a test case which create a page with 100 sub-pages so as to develop features that need to based on a page with lots of children such as limit showing number of children to 20 while adding a "show all" node as the 21st node. --- code/BigFamilyPage.php | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 code/BigFamilyPage.php diff --git a/code/BigFamilyPage.php b/code/BigFamilyPage.php new file mode 100644 index 0000000..612173e --- /dev/null +++ b/code/BigFamilyPage.php @@ -0,0 +1,47 @@ +column(); + if(count($bigFmailyPages)){ + $ids = "(".implode(",", $bigFmailyPages).")"; + //Delete all children from all stages + DB::query("DELETE FROM \"SiteTree\" WHERE \"SiteTree\".\"ParentID\" IN $ids"); + DB::query("DELETE FROM \"SiteTree_versions\" WHERE \"SiteTree_versions\".\"ParentID\" IN $ids"); + DB::query("DELETE FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ParentID\" IN $ids"); + + //Delete themselves from all stages + DB::query("DELETE FROM \"SiteTree\" WHERE \"SiteTree\".\"ID\" IN $ids"); + DB::query("DELETE FROM \"SiteTree_versions\" WHERE \"SiteTree_versions\".\"RecordID\" IN $ids"); + DB::query("DELETE FROM \"SiteTree_Live\" WHERE \"SiteTree_Live\".\"ID\" IN $ids"); + } + + //create new records + $bigFamilyPages = DataObject::get('BigFamilyPage'); + foreach ($bigFamilyPages as $page) { + foreach($page->AllChildren() as $child){ + $child->delete(); + } + $page->delete(); + } + + $familyPage = new BigFamilyPage(); + $familyPage->Title = "Big Family"; + $familyPage->write(); + $familyPage->doPublish(); + + foreach(singleton('Employee')->data() as $name){ + $page = new Page(); + $page->Title = $name; + $page->MenuTitle = $name; + $page->ParentID = $familyPage->ID; + $page->write(); + $page->doPublish(); + } + + DB::alteration_message("Added default 'BigFamilyPage' and its children pages","created"); + } +} \ No newline at end of file