/**
  * Creates the default SiteTree if not exists
  * 
  * @return SilvercartFrontPage
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 02.05.2012
  */
 public function createDefaultSiteTree()
 {
     $rootPage = SilvercartPage::get()->filter('IdentifierCode', 'SilvercartCartPage')->first();
     if (!$rootPage) {
         //create a silvercart front page (parent of all other SilverCart pages
         $rootPage = new SilvercartFrontPage();
         $rootPage->IdentifierCode = "SilvercartFrontPage";
         $rootPage->Title = 'SilverCart';
         $rootPage->MenuTitle = "SilverCart";
         if (SiteTree::get_by_link('home')) {
             $rootPage->URLSegment = 'webshop';
         } else {
             $rootPage->URLSegment = 'home';
         }
         $rootPage->ShowInMenus = false;
         $rootPage->ShowInSearch = false;
         $rootPage->Status = "Published";
         $rootPage->CanViewType = "Anyone";
         $rootPage->Content = _t('SilvercartFrontPage.DEFAULT_CONTENT', '<h2>Welcome to <strong>SilverCart</strong> Webshop!</h2>');
         $rootPage->write();
         $rootPage->publish("Stage", "Live");
         //create a silvercart product group holder as a child af the silvercart root
         $productGroupHolder = new SilvercartProductGroupHolder();
         $productGroupHolder->Title = _t('SilvercartProductGroupHolder.DEFAULT_TITLE', 'product groups');
         $productGroupHolder->URLSegment = _t('SilvercartProductGroupHolder.DEFAULT_URLSEGMENT', 'productgroups');
         $productGroupHolder->Status = "Published";
         $productGroupHolder->ParentID = $rootPage->ID;
         $productGroupHolder->IdentifierCode = "SilvercartProductGroupHolder";
         $productGroupHolder->InheritFromParent = false;
         $productGroupHolder->UseAsRootForMainNavigation = true;
         $productGroupHolder->write();
         $productGroupHolder->publish("Stage", "Live");
         //create a cart page
         $cartPage = new SilvercartCartPage();
         $cartPage->Title = _t('SilvercartCartPage.DEFAULT_TITLE');
         $cartPage->URLSegment = _t('SilvercartCartPage.DEFAULT_URLSEGMENT', 'cart');
         $cartPage->Status = "Published";
         $cartPage->ShowInMenus = true;
         $cartPage->ShowInSearch = false;
         $cartPage->IdentifierCode = "SilvercartCartPage";
         $cartPage->ParentID = $rootPage->ID;
         $cartPage->InheritFromParent = false;
         $cartPage->write();
         $cartPage->publish("Stage", "Live");
         //create a silvercart checkout step (checkout) as achild of the silvercart root
         $checkoutStep = new SilvercartCheckoutStep();
         $checkoutStep->Title = _t('SilvercartCheckoutStep.DEFAULT_TITLE');
         $checkoutStep->URLSegment = _t('SilvercartCheckoutStep.DEFAULT_URLSEGMENT', 'checkout');
         $checkoutStep->Status = "Published";
         $checkoutStep->ShowInMenus = true;
         $checkoutStep->ShowInSearch = true;
         $checkoutStep->basename = 'SilvercartCheckoutFormStep';
         $checkoutStep->showCancelLink = true;
         $checkoutStep->cancelPageID = $cartPage->ID;
         $checkoutStep->ParentID = $rootPage->ID;
         $checkoutStep->IdentifierCode = "SilvercartCheckoutStep";
         $checkoutStep->InheritFromParent = false;
         $checkoutStep->write();
         $checkoutStep->publish("Stage", "Live");
         //create a silvercart order confirmation page as a child of the silvercart root
         $orderConfirmationPage = new SilvercartOrderConfirmationPage();
         $orderConfirmationPage->Title = _t('SilvercartOrderConfirmationPage.DEFAULT_TITLE', 'order conirmation page');
         $orderConfirmationPage->URLSegment = _t('SilvercartOrderConfirmationPage.DEFAULT_URLSEGMENT', 'order-conirmation');
         $orderConfirmationPage->Status = "Published";
         $orderConfirmationPage->ShowInMenus = false;
         $orderConfirmationPage->ShowInSearch = false;
         $orderConfirmationPage->CanViewType = "LoggedInUsers";
         $orderConfirmationPage->IdentifierCode = "SilvercartOrderConfirmationPage";
         $orderConfirmationPage->ParentID = $rootPage->ID;
         $orderConfirmationPage->InheritFromParent = false;
         $orderConfirmationPage->write();
         $orderConfirmationPage->publish("Stage", "Live");
         //create a payment notification page as a child of the silvercart root
         $paymentNotification = new SilvercartPaymentNotification();
         $paymentNotification->Title = _t('SilvercartPaymentNotification.DEFAULT_TITLE', 'payment notification');
         $paymentNotification->URLSegment = _t('SilvercartPaymentNotification.DEFAULT_URLSEGMENT', 'payment-notification');
         $paymentNotification->Status = 'Published';
         $paymentNotification->ShowInMenus = 0;
         $paymentNotification->ShowInSearch = 0;
         $paymentNotification->ParentID = $rootPage->ID;
         $paymentNotification->IdentifierCode = "SilvercartPaymentNotification";
         $paymentNotification->InheritFromParent = false;
         $paymentNotification->write();
         $paymentNotification->publish('Stage', 'Live');
         DB::alteration_message('SilvercartPaymentNotification Page created', 'created');
         //create a silvercart registration page as a child of silvercart root
         $registrationPage = new SilvercartRegistrationPage();
         $registrationPage->Title = _t('SilvercartRegistrationPage.DEFAULT_TITLE', 'registration page');
         $registrationPage->URLSegment = _t('SilvercartRegistrationPage.DEFAULT_URLSEGMENT', 'registration');
         $registrationPage->Status = "Published";
         $registrationPage->ShowInMenus = false;
         $registrationPage->ShowInSearch = true;
         $registrationPage->ParentID = $rootPage->ID;
         $registrationPage->IdentifierCode = "SilvercartRegistrationPage";
         $registrationPage->InheritFromParent = false;
         $registrationPage->write();
         $registrationPage->publish("Stage", "Live");
         //create a silvercart registration confirmation page as a child the silvercart registration page
         $registerConfirmationPage = new SilvercartRegisterConfirmationPage();
         $registerConfirmationPage->Title = _t('SilvercartRegisterConfirmationPage.DEFAULT_TITLE', 'register confirmation page');
         $registerConfirmationPage->URLSegment = _t('SilvercartRegisterConfirmationPage.DEFAULT_URLSEGMENT', 'register-confirmation');
         $registerConfirmationPage->Content = _t('SilvercartRegisterConfirmationPage.DEFAULT_CONTENT');
         $registerConfirmationPage->Status = "Published";
         $registerConfirmationPage->ParentID = $registrationPage->ID;
         $registerConfirmationPage->ShowInMenus = false;
         $registerConfirmationPage->ShowInSearch = false;
         $registerConfirmationPage->CanViewType = "LoggedInUsers";
         $registerConfirmationPage->IdentifierCode = "SilvercartRegisterConfirmationPage";
         $registerConfirmationPage->write();
         $registerConfirmationPage->publish("Stage", "Live");
         //create a silvercart search results page as a child of the silvercart root
         $searchResultsPage = new SilvercartSearchResultsPage();
         $searchResultsPage->Title = _t('SilvercartSearchResultsPage.DEFAULT_TITLE', 'search results');
         $searchResultsPage->URLSegment = _t('SilvercartSearchResultsPage.DEFAULT_URLSEGMENT', 'search-results');
         $searchResultsPage->Status = "Published";
         $searchResultsPage->ShowInMenus = false;
         $searchResultsPage->ShowInSearch = false;
         $searchResultsPage->ParentID = $rootPage->ID;
         $searchResultsPage->IdentifierCode = "SilvercartSearchResultsPage";
         $searchResultsPage->InheritFromParent = false;
         $searchResultsPage->write();
         $searchResultsPage->publish("Stage", "Live");
         $this->createDefaultSiteTreeCMSSection($rootPage);
     }
     return $rootPage;
 }
 /**
  * Constructor
  *
  * @param array|null $record      This will be null for a new database record.  Alternatively, you can pass an array of
  *                                field values.  Normally this contructor is only used by the internal systems that get objects from the database.
  * @param boolean    $isSingleton This this to true if this is a singleton() object, a stub for calling methods.  Singletons
  *                                don't have their defaults set.
  *
  * @author Roland Lehmann <*****@*****.**>
  * @since 2.2.2011
  */
 public function __construct($record = null, $isSingleton = false)
 {
     self::$defaults = array('ActivationMailSubject' => _t('SilvercartRegistrationPage.YOUR_REGISTRATION', 'your registration'), 'ActivationMailMessage' => _t('SilvercartRegistrationPage.CUSTOMER_SALUTATION', 'Dear customer\\,'));
     parent::__construct($record, $isSingleton);
 }