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


PHP ErrorPage::Link方法代码示例

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


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

示例1: requireDefaultRecords

 /**
  * Create an {@link ErrorPage} for status code 503
  * 
  * @see UnderConstruction_Extension::onBeforeInit()
  * @see DataObjectDecorator::requireDefaultRecords()
  * @return Void
  */
 function requireDefaultRecords()
 {
     // Ensure that an assets path exists before we do any error page creation
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH);
     }
     $pageUnderConstructionErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '503'");
     $pageUnderConstructionErrorPageExists = $pageUnderConstructionErrorPage && $pageUnderConstructionErrorPage->exists() ? true : false;
     $pageUnderConstructionErrorPagePath = ErrorPage::get_filepath_for_errorcode(503);
     if (!($pageUnderConstructionErrorPageExists && file_exists($pageUnderConstructionErrorPagePath))) {
         if (!$pageUnderConstructionErrorPageExists) {
             $pageUnderConstructionErrorPage = new ErrorPage();
             $pageUnderConstructionErrorPage->ErrorCode = 503;
             $pageUnderConstructionErrorPage->Title = _t('UnderConstruction.TITLE', 'Under Construction');
             $pageUnderConstructionErrorPage->Content = _t('UnderConstruction.CONTENT', '<p>Sorry, this site is currently under construction.</p>');
             $pageUnderConstructionErrorPage->Status = 'New page';
             $pageUnderConstructionErrorPage->write();
             $pageUnderConstructionErrorPage->publish('Stage', 'Live');
         }
         // Ensure a static error page is created from latest error page content
         $response = Director::test(Director::makeRelative($pageUnderConstructionErrorPage->Link()));
         if ($fh = fopen($pageUnderConstructionErrorPagePath, 'w')) {
             $written = fwrite($fh, $response->getBody());
             fclose($fh);
         }
         if ($written) {
             DB::alteration_message('503 error page created', 'created');
         } else {
             DB::alteration_message(sprintf('503 error page could not be created at %s. Please check permissions', $pageUnderConstructionErrorPagePath), 'error');
         }
     }
 }
开发者ID:helpfulrobot,项目名称:frankmullenger-underconstruction,代码行数:39,代码来源:UnderConstruction.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) {
         // Ensure that an assets path exists before we do any error page creation
         if (!file_exists(ASSETS_PATH)) {
             mkdir(ASSETS_PATH);
         }
         $defaultPages = $this->getDefaultRecords();
         foreach ($defaultPages as $defaultData) {
             $code = $defaultData['ErrorCode'];
             $page = DataObject::get_one('ErrorPage', sprintf("\"ErrorPage\".\"ErrorCode\" = '%s'", $code));
             $pageExists = $page && $page->exists();
             $pagePath = self::get_filepath_for_errorcode($code);
             if (!($pageExists && file_exists($pagePath))) {
                 if (!$pageExists) {
                     $page = new ErrorPage($defaultData);
                     $page->write();
                     $page->publish('Stage', 'Live');
                 }
                 // Ensure a static error page is created from latest error page content
                 $response = Director::test(Director::makeRelative($page->Link()));
                 $written = null;
                 if ($fh = fopen($pagePath, 'w')) {
                     $written = fwrite($fh, $response->getBody());
                     fclose($fh);
                 }
                 if ($written) {
                     DB::alteration_message(sprintf('%s error page created', $code), 'created');
                 } else {
                     DB::alteration_message(sprintf('%s error page could not be created at %s. Please check permissions', $code, $pagePath), 'error');
                 }
             }
         }
     }
 }
开发者ID:prostart,项目名称:erics-homes,代码行数:41,代码来源:ErrorPage.php

示例3: 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

示例4: 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');
             }
         }
     }
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:61,代码来源:Page.php


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