当前位置: 首页>>代码示例>>PHP>>正文


PHP Page::requireDefaultRecords方法代码示例

本文整理汇总了PHP中Page::requireDefaultRecords方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::requireDefaultRecords方法的具体用法?PHP Page::requireDefaultRecords怎么用?PHP Page::requireDefaultRecords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Page的用法示例。


在下文中一共展示了Page::requireDefaultRecords方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: requireDefaultRecords

 /**
  *	Instantiate a search page, should one not exist.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $mode = Versioned::get_reading_mode();
     Versioned::reading_stage('Stage');
     // Determine whether pages should be created.
     if (self::config()->create_default_pages) {
         // Determine whether an extensible search page already exists.
         if (!ExtensibleSearchPage::get()->first()) {
             // Instantiate an extensible search page.
             $page = ExtensibleSearchPage::create();
             $page->Title = 'Search Page';
             $page->write();
             DB::alteration_message('"Default" Extensible Search Page', 'created');
         }
     } else {
         if (ClassInfo::exists('Multisites')) {
             foreach (Site::get() as $site) {
                 // Determine whether an extensible search page already exists.
                 if (!ExtensibleSearchPage::get()->filter('SiteID', $site->ID)->first()) {
                     // Instantiate an extensible search page.
                     $page = ExtensibleSearchPage::create();
                     $page->ParentID = $site->ID;
                     $page->Title = 'Search Page';
                     $page->write();
                     DB::alteration_message("\"{$site->Title}\" Extensible Search Page", 'created');
                 }
             }
         }
     }
     Versioned::set_reading_mode($mode);
 }
开发者ID:nglasl,项目名称:silverstripe-extensible-search,代码行数:35,代码来源:ExtensibleSearchPage.php

示例2: requireDefaultRecords

 /**
  * Ensures that there is always a 404 page by checking if there's an
  * instance of ErrorPage with a 404 and 500 error code. If there is not,
  * one is created when the DB is built.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if ($this->class === 'ErrorPage' && SiteTree::config()->create_default_pages) {
         $defaultPages = $this->getDefaultRecords();
         foreach ($defaultPages as $defaultData) {
             $code = $defaultData['ErrorCode'];
             $page = ErrorPage::get()->filter('ErrorCode', $code)->first();
             $pageExists = !empty($page);
             if (!$pageExists) {
                 $page = new ErrorPage($defaultData);
                 $page->write();
                 $page->publish('Stage', 'Live');
             }
             // Check if static files are enabled
             if (!self::config()->enable_static_file) {
                 continue;
             }
             // Ensure this page has cached error content
             $success = true;
             if (!$page->hasStaticPage()) {
                 // Update static content
                 $success = $page->writeStaticPage();
             } elseif ($pageExists) {
                 // If page exists and already has content, no alteration_message is displayed
                 continue;
             }
             if ($success) {
                 DB::alteration_message(sprintf('%s error page created', $code), 'created');
             } else {
                 DB::alteration_message(sprintf('%s error page could not be created. Please check permissions', $code), 'error');
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:40,代码来源:ErrorPage.php

示例3: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if ($this->config()->get("auto_include")) {
         $check = TemplateOverviewPage::get()->First();
         if (!$check) {
             $page = new TemplateOverviewPage();
             $page->ShowInMenus = 0;
             $page->ShowInSearch = 0;
             $page->Title = "Templates overview";
             $page->PageTitle = "Templates overview";
             $page->Sort = 99998;
             $page->URLSegment = "templates";
             $parent = Page::get()->filter(array("URLSegment" => $this->config()->get("parent_url_segment")))->First();
             if ($parent) {
                 $page->ParentID = $parent->ID;
             }
             $page->writeToStage('Stage');
             $page->publish('Stage', 'Live');
             $page->URLSegment = "templates";
             $page->writeToStage('Stage');
             $page->publish('Stage', 'Live');
             DB::alteration_message("TemplateOverviewPage", "created");
         }
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-templateoverview,代码行数:26,代码来源:TemplateOverviewPage.php

示例4: requireDefaultRecords

 /**
  * Ensures that there is always a 404 page
  * by checking if there's an instance of
  * ErrorPage with a 404 and 500 error code. If there
  * is not, one is created when the DB is built.
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $pageNotFoundErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '404'");
     if (!($pageNotFoundErrorPage && $pageNotFoundErrorPage->exists())) {
         $pageNotFoundErrorPage = new ErrorPage();
         $pageNotFoundErrorPage->ErrorCode = 404;
         $pageNotFoundErrorPage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
         $pageNotFoundErrorPage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
         $pageNotFoundErrorPage->Status = 'New page';
         $pageNotFoundErrorPage->write();
         $pageNotFoundErrorPage->publish('Stage', 'Live');
         DB::alteration_message('404 page created', 'created');
     }
     $serverErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '500'");
     if (!($serverErrorPage && $serverErrorPage->exists())) {
         $serverErrorPage = new ErrorPage();
         $serverErrorPage->ErrorCode = 500;
         $serverErrorPage->Title = _t('ErrorPage.DEFAULTSERVERERRORPAGETITLE', 'Server error');
         $serverErrorPage->Content = _t('ErrorPage.DEFAULTSERVERERRORPAGECONTENT', '<p>Sorry, there was a problem with handling your request.</p>');
         $serverErrorPage->Status = 'New page';
         $serverErrorPage->write();
         $serverErrorPage->publish('Stage', 'Live');
         DB::alteration_message('500 page created', 'created');
     }
 }
开发者ID:NARKOZ,项目名称:silverstripe-doc-restructuring,代码行数:32,代码来源:ErrorPage.php

示例5: requireDefaultRecords

 /**
  * Create default blog setup
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one('UserAgreementPage')) {
         if (class_exists('Site') && ($sites = Site::get())) {
             if ($sites->first()) {
                 foreach ($sites as $site) {
                     $page = new UserAgreementPage();
                     $page->Title = "User Agreement";
                     $page->URLSegment = "user-agreement";
                     $page->Status = "Published";
                     $page->ShowInMenus = 0;
                     $page->ParentID = $site->ID;
                     $page->write();
                     $page->publish("Stage", "Live");
                     DB::alteration_message("User Agreement Page Created", "created");
                 }
             }
         } else {
             $page = new UserAgreementPage();
             $page->Title = "User Agreement";
             $page->URLSegment = "user-agreement";
             $page->Status = "Published";
             $page->ShowInMenus = 0;
             $page->write();
             $page->publish("Stage", "Live");
             DB::alteration_message("User Agreement Page Created", "created");
         }
     }
 }
开发者ID:rodneyway,项目名称:silverstripe-useragreement,代码行数:33,代码来源:UserAgreementPage.php

示例6: requireDefaultRecords

 /**
  * Ensures that there is always a 404 page
  * by checking if there's an instance of
  * ErrorPage with a 404 and 500 error code. If there
  * is not, one is created when the DB is built.
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if ($this->class == 'ErrorPage' && SiteTree::get_create_default_pages()) {
         // Ensure that an assets path exists before we do any error page creation
         if (!file_exists(ASSETS_PATH)) {
             mkdir(ASSETS_PATH);
         }
         $pageNotFoundErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '404'");
         $pageNotFoundErrorPageExists = $pageNotFoundErrorPage && $pageNotFoundErrorPage->exists() ? true : false;
         $pageNotFoundErrorPagePath = self::get_filepath_for_errorcode(404);
         if (!($pageNotFoundErrorPageExists && file_exists($pageNotFoundErrorPagePath))) {
             if (!$pageNotFoundErrorPageExists) {
                 $pageNotFoundErrorPage = new ErrorPage();
                 $pageNotFoundErrorPage->ErrorCode = 404;
                 $pageNotFoundErrorPage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
                 $pageNotFoundErrorPage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
                 $pageNotFoundErrorPage->write();
                 $pageNotFoundErrorPage->publish('Stage', 'Live');
             }
             // Ensure a static error page is created from latest error page content
             $response = Director::test(Director::makeRelative($pageNotFoundErrorPage->Link()));
             $written = null;
             if ($fh = fopen($pageNotFoundErrorPagePath, 'w')) {
                 $written = fwrite($fh, $response->getBody());
                 fclose($fh);
             }
             if ($written) {
                 DB::alteration_message('404 error page created', 'created');
             } else {
                 DB::alteration_message(sprintf('404 error page could not be created at %s. Please check permissions', $pageNotFoundErrorPagePath), 'error');
             }
         }
         $serverErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '500'");
         $serverErrorPageExists = $serverErrorPage && $serverErrorPage->exists() ? true : false;
         $serverErrorPagePath = self::get_filepath_for_errorcode(500);
         if (!($serverErrorPageExists && file_exists($serverErrorPagePath))) {
             if (!$serverErrorPageExists) {
                 $serverErrorPage = new ErrorPage();
                 $serverErrorPage->ErrorCode = 500;
                 $serverErrorPage->Title = _t('ErrorPage.DEFAULTSERVERERRORPAGETITLE', 'Server error');
                 $serverErrorPage->Content = _t('ErrorPage.DEFAULTSERVERERRORPAGECONTENT', '<p>Sorry, there was a problem with handling your request.</p>');
                 $serverErrorPage->write();
                 $serverErrorPage->publish('Stage', 'Live');
             }
             // Ensure a static error page is created from latest error page content
             $response = Director::test(Director::makeRelative($serverErrorPage->Link()));
             $written = null;
             if ($fh = fopen($serverErrorPagePath, 'w')) {
                 $written = fwrite($fh, $response->getBody());
                 fclose($fh);
             }
             if ($written) {
                 DB::alteration_message('500 error page created', 'created');
             } else {
                 DB::alteration_message(sprintf('500 error page could not be created at %s. Please check permissions', $serverErrorPagePath), 'error');
             }
         }
     }
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:66,代码来源:ErrorPage.php

示例7: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $accountPages = DataObject::get('MembersAccountPage');
     foreach ($accountPages as $page) {
         $this->addMemberAccountFields($page);
     }
 }
开发者ID:helpfulrobot,项目名称:zucchi-membermanagement,代码行数:8,代码来源:MembersAccountPage.php

示例8: requireDefaultRecords

 /**
  * This module always requires a page model.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!self::get()->exists() && $this->config()->create_default_pages) {
         $page = self::create(array('Title' => 'Account', 'URLSegment' => AccountPage_Controller::config()->url_segment, 'ShowInMenus' => 0));
         $page->write();
         $page->publish('Stage', 'Live');
         $page->flushCache();
         DB::alteration_message('Account page created', 'created');
     }
 }
开发者ID:renskorswagen,项目名称:silverstripe-shop,代码行数:14,代码来源:AccountPage.php

示例9: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $page = DataObject::get_one('GridFieldTestPage');
     if (!$page) {
         $page = new GridFieldTestPage();
     }
     $page->URLSegment = 'gridfieldtest';
     $page->Title = 'GridField Test';
     $page->ParentID = 0;
     $page->write();
     $page->doPublish();
 }
开发者ID:normann,项目名称:silverstripe-frameworktest,代码行数:13,代码来源:GridFieldTestPage.php

示例10: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!SubscriptionPage::get()->Count()) {
         $page = new SubscriptionPage();
         $page->Title = 'Newsletter Subscription';
         $page->URLSegment = 'newsletter-subscription';
         $page->SendNotification = 1;
         $page->ShowInMenus = false;
         $page->write();
         $page->publish('Stage', 'Live');
     }
 }
开发者ID:Zauberfisch,项目名称:silverstripe-newsletter,代码行数:13,代码来源:SubscriptionPage.php

示例11: requireDefaultRecords

 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one('DPSHostedPaymentPage')) {
         $page = new DPSHostedPaymentPage();
         $page->Title = "Payment Status";
         $page->URLSegment = "paymentstatus";
         $page->ShowInMenus = 0;
         $page->ShowInSearch = 0;
         $page->write();
         SS_Database::alterationMessage("DPSHostedPaymentPage page created", "created");
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-payment-dpshosted,代码行数:13,代码来源:DPSHostedPaymentPage.php

示例12: requireDefaultRecords

 /**
  * Automatically create an AccountPage if one is not found
  * on the site at the time the database is built (dev/build).
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one('AccountPage')) {
         $page = new AccountPage();
         $page->Title = 'Account';
         $page->Content = '<p>This is the account page. It is used for shop users to login and change their member details if they have an account.</p>';
         $page->URLSegment = 'account';
         $page->ShowInMenus = 0;
         $page->writeToStage('Stage');
         $page->publish('Stage', 'Live');
         DB::alteration_message('Account page \'Account\' created', 'created');
     }
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:18,代码来源:AccountPage.php

示例13: requireDefaultRecords

 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!Catalog::get()->first()) {
         $catalog = new Catalog();
         $catalog->Title = "Product Catalog";
         $catalog->URLSegment = "catalog";
         $catalog->Sort = 4;
         $catalog->write();
         $catalog->publish('Stage', 'Live');
         $catalog->flushCache();
         DB::alteration_message('Product Catalog created', 'created');
     }
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:14,代码来源:Catalog.php

示例14: requireDefaultRecords

 /**
  * Ensures that there is always a 404 page
  * by checking if there's an instance of
  * ErrorPage with a 404 error code. If there
  * is not, one is created when the DB is built.
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $errorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '404'");
     if (!($errorPage && $errorPage->exists())) {
         $errorpage = new ErrorPage();
         $errorpage->ErrorCode = 404;
         $errorpage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
         $errorpage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
         $errorpage->Status = 'New page';
         $errorpage->write();
         DB::alteration_message('404 page created', 'created');
     }
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:20,代码来源:ErrorPage.php

示例15: requireDefaultRecords

 /**
  * Ensure that any categories that exist with no forum holder are updated to be owned by the first forum holder
  * if there is one. This is required now that multiple forum holds are allowed, and categories belong to holders.
  *
  * @see sapphire/core/model/DataObject#requireDefaultRecords()
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!($cats = DataObject::get("ForumCategory", '"ForumCategory"."ForumHolderID" = 0'))) {
         return;
     }
     if (!($holder = DataObject::get_one("ForumHolder"))) {
         return;
     }
     foreach ($cats as $c) {
         $c->ForumHolderID = $holder->ID;
         $c->write();
     }
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:20,代码来源:ForumHolder.php


注:本文中的Page::requireDefaultRecords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。