本文整理汇总了PHP中SiteTree::requireDefaultRecords方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteTree::requireDefaultRecords方法的具体用法?PHP SiteTree::requireDefaultRecords怎么用?PHP SiteTree::requireDefaultRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteTree
的用法示例。
在下文中一共展示了SiteTree::requireDefaultRecords方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: requireDefaultRecords
function requireDefaultRecords()
{
parent::requireDefaultRecords();
if ($this->class == 'NewsletterHolder') {
if (!DataObject::get($this->class)) {
$n = new NewsletterHolder();
$n->Title = "Newsletter";
$n->URLSegment = "newsletter";
$n->SendFrom = self::$newsletterEmail;
$n->write();
Database::alteration_message("newsletter holder created", "created");
}
}
}
示例2: requireDefaultRecords
function requireDefaultRecords()
{
parent::requireDefaultRecords();
// default checkoutpage
if ($this->class == 'ShopCheckoutPage') {
//create usergroup for shop client
if (!DataObject::get_one("Group", "Title LIKE 'ShopClients'")) {
$group = new Group();
$group->Title = "ShopClients";
$group->Code = "shop-clients";
$group->Sort = DataObject::get_one("Group", "1", null, "Sort DESC")->Sort + 1;
$group->write();
DB::alteration_message('ShopClients usergroup created', 'created');
}
if (!DataObject::get('ShopCheckoutPage')) {
$p = new ShopCheckoutPage();
$p->Title = _t('Shop.CheckoutPageTitleDefault', 'Checkout');
$p->Content = _t('SiteTree.CheckoutPageContentDefault', '
<h2>Welcome to the checkout Page</h2>
<p>Please feel free to replace this text with your own shopinformations...</p>
');
$p->URLSegment = 'checkout';
$p->writeToStage('Stage');
$p->publish('Stage', 'Live');
$p->ContentInvoiceAddress = "<h2>Billing Address</h2>\n\t\t\t\t<p>Please fill out the billing address.</p>";
$p->ContentDeliveryAddress = "<h2>Shipping Address</h2>\n\t\t\t\t<p>Please fill out the shipping address.</p>";
$p->ContentShipping = "<h2>Shipping Method</h2>\n\t\t\t\t<p>Please select your preferred shipping method.</p>";
$p->ContentPayment = "<h2>Payment Method</h2>\n\t\t\t\t<p>Please choose your preffered payment methos.</p>";
$p->ContentSummary = "<h2>Order summary</h2>\n\t\t\t\t<p>Take a look of your order and click on „Place order” to finish your shopping session.</p>";
$p->ContentComplete = "<h2>Thanks for your order!</h2>\n\t\t\t\t<p>Your order has been submitted.</p>\n\t\t\t\t<p>You'll recieve an eMail with your order details soon.</p>";
$p->ContentError = "<h2>Order could not be placed</h2>\n\t\t\t\t<p>Sorry, but your order couldn't proceed complety. Please contact us for further information. Thanks!</p>";
$p->writeToStage('Stage');
$p->publish('Stage', 'Live');
$p->flushCache();
DB::alteration_message('ShopCheckoutPage created', 'created');
}
}
}
示例3: requireDefaultRecords
function requireDefaultRecords()
{
parent::requireDefaultRecords();
// create a 400 ErrorPage
if ($this->class == 'ErrorPage') {
// Ensure that an assets path exists before we do any error page creation
if (!file_exists(ASSETS_PATH)) {
mkdir(ASSETS_PATH);
}
$ErrorPage400 = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '400'");
$ErrorPage400Exists = $ErrorPage400 && $ErrorPage400->exists() ? true : false;
$ErrorPage400Path = ErrorPage::get_filepath_for_errorcode(400);
if (!($ErrorPage400Exists && file_exists($ErrorPage400Path))) {
if (!$ErrorPage400Exists) {
$ErrorPage400 = new ErrorPage();
$ErrorPage400->ErrorCode = 400;
$ErrorPage400->Title = _t('ErrorPage.ERRORPAGE400TITLE', '400 Error');
$ErrorPage400->Content = _t('ErrorPage.ERRORPAGE400CONTENT', '<p>An error occurred while processing your request.</p>');
$ErrorPage400->Status = 'New page';
$ErrorPage400->write();
$ErrorPage400->publish('Stage', 'Live');
}
// Ensure a static error page is created from latest error page content
$response = Director::test(Director::makeRelative($ErrorPage400->Link()));
if ($fh = fopen($ErrorPage400Path, 'w')) {
$written = fwrite($fh, $response->getBody());
fclose($fh);
}
if ($written) {
DB::alteration_message('400 error page created', 'created');
} else {
DB::alteration_message(sprintf('400 error page could not be created at %s. Please check permissions', $ErrorPage400Path), 'error');
}
}
$ErrorPage412 = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '412'");
$ErrorPage412Exists = $ErrorPage412 && $ErrorPage412->exists() ? true : false;
$ErrorPage412Path = ErrorPage::get_filepath_for_errorcode(412);
if (!($ErrorPage412Exists && file_exists($ErrorPage412Path))) {
if (!$ErrorPage412Exists) {
$ErrorPage412 = new ErrorPage();
$ErrorPage412->ErrorCode = 412;
$ErrorPage412->Title = _t('ErrorPage.ERRORPAGE412TITLE', '412 Error');
$ErrorPage412->Content = _t('ErrorPage.ERRORPAGE412CONTENT', '<p>Your Session has expired!.</p>');
$ErrorPage412->Status = 'New page';
$ErrorPage412->write();
$ErrorPage412->publish('Stage', 'Live');
}
// Ensure a static error page is created from latest error page content
$response = Director::test(Director::makeRelative($ErrorPage412->Link()));
if ($fh = fopen($ErrorPage412Path, 'w')) {
$written = fwrite($fh, $response->getBody());
fclose($fh);
}
if ($written) {
DB::alteration_message('412 error page created', 'created');
} else {
DB::alteration_message(sprintf('412 error page could not be created at %s. Please check permissions', $ErrorPage412Path), 'error');
}
}
}
}
示例4: requireDefaultRecords
/**
* 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();
}