Exemplo n.º 1
0
 /**
  * Add default records to database.
  *
  * This function is called whenever the database is built, after the
  * database tables have all been created. Overload this to add default
  * records when the database is built, but make sure you call
  * parent::requireDefaultRecords().
  */
 public function requireDefaultRecords()
 {
     if (!SiteTree::get_by_link(Config::inst()->get('RootURLController', 'default_homepage_link'))) {
         $homepage = new HomePage();
         $homepage->Title = 'Home';
         $homepage->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link');
         $homepage->Sort = 1;
         $homepage->write();
         $homepage->publish('Stage', 'Live');
         $homepage->flushCache();
         DB::alteration_message('Home page created', 'created');
     }
     if (DB::query("SELECT COUNT(*) FROM \"SiteTree\"")->value() == 1) {
         $aboutus = new RootPage();
         $aboutus->Title = 'About Us';
         $aboutus->Sort = 2;
         $aboutus->write();
         $aboutus->publish('Stage', 'Live');
         $aboutus->flushCache();
         DB::alteration_message('Book 1 created', 'created');
         $contactus = new RootPage();
         $contactus->Title = 'Contact Us';
         $contactus->Sort = 3;
         $contactus->write();
         $contactus->publish('Stage', 'Live');
         $contactus->flushCache();
         DB::alteration_message('Book 2 created', 'created');
     }
     // call it on the parent
     parent::requireDefaultRecords();
 }
 /**
  * Change the contact-us page to ContactUsPage type
  */
 function requireDefaultRecords()
 {
     if (!SiteTree::get_by_link("contact-us")) {
         $contactpage = new HomePage();
         $contactpage->Title = "Contact Us";
         $contactpage->URLSegment = "contact-us";
         $contactpage->Sort = 3;
         $contactpage->write();
         $contactpage->publish('Stage', 'Live');
         $contactpage->flushCache();
         DB::alteration_message('Contact Us created', 'created');
     } else {
         $contactpage = SiteTree::get_by_link("contact-us");
         if ($contactpage->ClassName != "ContactUsPage") {
             $contactpage = $contactpage->newClassInstance("ContactUsPage");
             $contactpage->write();
             $contactpage->publish('Stage', 'Live');
             $contactpage->flushCache();
             DB::alteration_message('Contact Us changed to ContactUsPage', 'changed');
         }
     }
     parent::requireDefaultRecords();
 }
Exemplo n.º 3
0
 /**
  * Change the home page to HomePage type
  */
 public function requireDefaultRecords()
 {
     if (!SiteTree::get_by_link("home")) {
         $homepage = new HomePage();
         ${$homepage}->Title = "Home";
         $homepage->URLSegment = "home";
         $homepage->Sort = 1;
         $homepage->write();
         $homepage->publish('Stage', 'Live');
         $homepage->flushCache();
         DB::alteration_message('Home Page created', 'created');
     } else {
         $homepage = SiteTree::get_by_link("home");
         if ($homepage->ClassName != "HomePage") {
             $homepage = $homepage->newClassInstance("HomePage");
             $homepage->write();
             $homepage->publish('Stage', 'Live');
             $homepage->flushCache();
             DB::alteration_message('Home changed to HomePage', 'changed');
         }
     }
     parent::requireDefaultRecords();
 }