/** * Create the page if needed */ public function requireDefaultRecords() { if (!self::inst() && Config::inst()->get('WishListPage', 'auto_create_page')) { $rec = new WishListPage(); $rec->Title = 'Wish List'; $rec->ShowInSearch = false; $rec->ShowInMenu = false; $rec->CanViewType = 'LoggedInUsers'; $rec->write(); $rec->publish('Stage', 'Live'); $rec->flushCache(); } }
/** * Add default records to database. * Make sure you call parent::requireDefaultRecords(). */ function requireDefaultRecords() { parent::requireDefaultRecords(); $update = array(); $page = DataObject::get_one("WishListPage"); if (!$page) { $page = new WishListPage(); $page->Title = "Wish List"; $page->MetaTitle = "Wish List"; $page->URLSegment = "wish-list"; $page->MenuTitle = "wish list"; } if ($page) { if (!$page->AddedToListText) { $page->AddedToListText = "added to wish list"; $update[] = "updated AddedToListText"; } if (!$page->AddedToListTextError) { $page->AddedToListTextError = "could not add to wish list"; $update[] = "updated AddedToListTextError"; } if (!$page->RemovedFromListConfirmation) { $page->RemovedFromListConfirmation = "are you sure you want to remove it from your wish list?"; $update[] = "updated RemovedFromListConfirmation"; } if (!$page->RetrieveListConfirmation) { $page->RetrieveListConfirmation = "Are you sure you would like to retrieve your saved list? It will replace your current list. Do you want to go ahead?"; $update[] = "updated RetrieveListConfirmation"; } if (!$page->ClearListConfirmation) { $page->ClearListConfirmation = "Are you sure you would like to clear your saved list? "; $update[] = "updated ClearListConfirmation"; } if (!$page->RemovedFromListText) { $page->RemovedFromListText = "removed from wish list"; $update[] = "updated RemovedFromListText"; } if (!$page->RemovedFromListTextError) { $page->RemovedFromListTextError = "could not be removed from wish list"; $update[] = "updated RemovedFromListTextError"; } if (!$page->ClearWishList) { $page->ClearWishList = "cleared wish list"; $update[] = "updated ClearWishList"; } if (!$page->SavedWishListText) { $page->SavedWishListText = "saved wish list"; $update[] = "updated SavedWishListText"; } if (!$page->SavedWishListTextError) { $page->SavedWishListTextError = "could not save wish list"; $update[] = "updated SavedWishListTextError"; } if (!$page->RetrievedWishListText) { $page->RetrievedWishListText = "retrieved wish list"; $update[] = "updated RetrievedWishListText"; } if (!$page->RetrievedWishListTextError) { $page->RetrievedWishListTextError = "could not retrieve wish list"; $update[] = "updated RetrievedWishListTextError"; } if (count($update)) { $page->writeToStage('Stage'); $page->publish('Stage', 'Live'); DB::alteration_message($page->ClassName . " created/updated: <ul><li>" . implode("</li><li>", $update) . "</li></ul>", 'created'); } } }