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


PHP Page::doPublish方法代码示例

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


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

示例1: requireDefaultRecords

 function requireDefaultRecords()
 {
     if ($this->class == 'TestPage') {
         return;
     }
     $class = $this->class;
     if (!DataObject::get_one($class)) {
         // Try to create common parent
         $parent = SiteTree::get()->filter('URLSegment', 'feature-test-pages')->First();
         if (!$parent) {
             $parent = new Page(array('Title' => 'Feature Test Pages', 'Content' => 'A collection of pages for testing various features in the SilverStripe CMS', 'ShowInMenus' => 0));
             $parent->write();
             $parent->doPublish();
         }
         // Create actual page
         $page = new $class();
         $page->Title = str_replace("TestPage", "", $class);
         $page->ShowInMenus = 0;
         if ($parent) {
             $page->ParentID = $parent->ID;
         }
         $page->write();
         $page->publish('Stage', 'Live');
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-frameworktest,代码行数:25,代码来源:TestPage.php

示例2: doPublish

 /**
  * When an error page is published, create a static HTML page with its
  * content, so the page can be shown even when SilverStripe is not
  * functioning correctly before publishing this page normally.
  * @param string|int $fromStage Place to copy from. Can be either a stage name or a version number.
  * @param string $toStage Place to copy to. Must be a stage name.
  * @param boolean $createNewVersion Set this to true to create a new version number.  By default, the existing version number will be copied over.
  */
 function doPublish()
 {
     parent::doPublish();
     // Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
     $oldTheme = SSViewer::current_theme();
     SSViewer::set_theme(SSViewer::current_custom_theme());
     $response = Director::test(Director::makeRelative($this->Link()));
     SSViewer::set_theme($oldTheme);
     $errorContent = $response->getBody();
     // Make the base tag dynamic.
     // $errorContent = preg_replace('/<base[^>]+href="' . str_replace('/','\\/', Director::absoluteBaseURL()) . '"[^>]*>/i', '<base href="$BaseURL" />', $errorContent);
     // Check we have an assets base directory, creating if it we don't
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH, 02775);
     }
     // if the page is published in a language other than default language,
     // write a specific language version of the HTML page
     $filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Locale);
     if ($fh = fopen($filePath, "w")) {
         fwrite($fh, $errorContent);
         fclose($fh);
     } else {
         $fileErrorText = sprintf(_t("ErrorPage.ERRORFILEPROBLEM", "Error opening file \"%s\" for writing. Please check file permissions."), $errorFile);
         FormResponse::status_message($fileErrorText, 'bad');
         FormResponse::respond();
         return;
     }
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:36,代码来源:ErrorPage.php

示例3: doPublish

 /**
  * Publishing Versioning support.
  *
  * When publishing copy the editable form fields to the live database
  * Not going to version emails and submissions as they are likely to 
  * persist over multiple versions
  *
  * @return void
  */
 public function doPublish()
 {
     // remove fields on the live table which could have been orphaned.
     $live = Versioned::get_by_stage("EditableFormField", "Live", "\"EditableFormField\".\"ParentID\" = {$this->ID}");
     if ($live) {
         foreach ($live as $field) {
             $field->doDeleteFromStage('Live');
         }
     }
     // publish the draft pages
     if ($this->Fields()) {
         foreach ($this->Fields() as $field) {
             $field->doPublish('Stage', 'Live');
         }
     }
     parent::doPublish();
 }
开发者ID:nzjoel,项目名称:silverstripe-userforms,代码行数:26,代码来源:UserDefinedForm.php

示例4: Page

 function testSubsiteVirtualPagesArentInappropriatelyPublished()
 {
     // Fixture
     $p = new Page();
     $p->Content = "test content";
     $p->write();
     $vp = new SubsitesVirtualPage();
     $vp->CopyContentFromID = $p->ID;
     $vp->write();
     // VP is oragne
     $this->assertTrue($vp->IsAddedToStage);
     // VP is still orange after we publish
     $p->doPublish();
     $this->fixVersionNumberCache($vp);
     $this->assertTrue($vp->IsAddedToStage);
     // A new VP created after P's initial construction
     $vp2 = new SubsitesVirtualPage();
     $vp2->CopyContentFromID = $p->ID;
     $vp2->write();
     $this->assertTrue($vp2->IsAddedToStage);
     // Also remains orange after a republish
     $p->Content = "new content";
     $p->write();
     $p->doPublish();
     $this->fixVersionNumberCache($vp2);
     $this->assertTrue($vp2->IsAddedToStage);
     // VP is now published
     $vp->doPublish();
     $this->fixVersionNumberCache($vp);
     $this->assertTrue($vp->ExistsOnLive);
     $this->assertFalse($vp->IsModifiedOnStage);
     // P edited, VP and P both go green
     $p->Content = "third content";
     $p->write();
     $this->fixVersionNumberCache($vp, $p);
     $this->assertTrue($p->IsModifiedOnStage);
     $this->assertTrue($vp->IsModifiedOnStage);
     // Publish, VP goes black
     $p->doPublish();
     $this->fixVersionNumberCache($vp);
     $this->assertTrue($vp->ExistsOnLive);
     $this->assertFalse($vp->IsModifiedOnStage);
 }
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:43,代码来源:SubsitesVirtualPageTest.php

示例5: testStaticPublishing

 function testStaticPublishing()
 {
     $this->logInWithPermission('ADMIN');
     $p1 = new Page();
     $p1->URLSegment = strtolower(__CLASS__) . '-page-1';
     $p1->HomepageForDomain = '';
     $p1->write();
     $p1->doPublish();
     $p2 = new Page();
     $p2->URLSegment = strtolower(__CLASS__) . '-page-2';
     $p2->HomepageForDomain = 'domain1';
     $p2->write();
     $p2->doPublish();
     $p3 = new Page();
     $p3->URLSegment = strtolower(__CLASS__) . '-page-3';
     $p3->HomepageForDomain = 'domain2,domain3';
     $p3->write();
     $p3->doPublish();
     $map = HomepageForDomainExtension::generate_homepage_domain_map();
     $this->assertEquals($map, array('domain1' => strtolower(__CLASS__) . '-page-2', 'domain2' => strtolower(__CLASS__) . '-page-3', 'domain3' => strtolower(__CLASS__) . '-page-3'), 'Homepage/domain map is correct when static publishing is enabled');
 }
开发者ID:helpfulrobot,项目名称:silverstripe-homepagefordomain,代码行数:21,代码来源:HomepageForDomainTest.php

示例6: doPublish

 /**
  * When an error page is published, create a static HTML page with its
  * content, so the page can be shown even when SilverStripe is not
  * functioning correctly before publishing this page normally.
  * @param string|int $fromStage Place to copy from. Can be either a stage name or a version number.
  * @param string $toStage Place to copy to. Must be a stage name.
  * @param boolean $createNewVersion Set this to true to create a new version number.  By default, the existing version number will be copied over.
  */
 function doPublish()
 {
     parent::doPublish();
     // Run the page
     $response = Director::test(Director::makeRelative($this->Link()));
     $errorContent = $response->getBody();
     // Check we have an assets base directory, creating if it we don't
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH, 02775);
     }
     // if the page is published in a language other than default language,
     // write a specific language version of the HTML page
     $filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Locale);
     if ($fh = fopen($filePath, "w")) {
         fwrite($fh, $errorContent);
         fclose($fh);
     } else {
         $fileErrorText = sprintf(_t("ErrorPage.ERRORFILEPROBLEM", "Error opening file \"%s\" for writing. Please check file permissions."), $errorFile);
         FormResponse::status_message($fileErrorText, 'bad');
         FormResponse::respond();
         return;
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:31,代码来源:ErrorPage.php

示例7: testStaticPublisherTheme

 public function testStaticPublisherTheme()
 {
     // This will be the name of the default theme of this particular project
     $default_theme = Config::inst()->get('SSViewer', 'theme');
     $p1 = new Page();
     $p1->URLSegment = strtolower(__CLASS__) . '-page-1';
     $p1->HomepageForDomain = '';
     $p1->write();
     $p1->doPublish();
     $current_theme = Config::inst()->get('SSViewer', 'theme_enabled') ? Config::inst()->get('SSViewer', 'theme') : null;
     $this->assertEquals($current_theme, $default_theme, 'After a standard publication, the theme is correct');
     //We can set the static_publishing theme to something completely different:
     //Static publishing will use this one instead of the current_custom_theme if it is not false
     Config::inst()->update('StaticPublisher', 'static_publisher_theme', 'otherTheme');
     $current_theme = Config::inst()->get('StaticPublisher', 'static_publisher_theme');
     $this->assertNotEquals($current_theme, $default_theme, 'The static publisher theme overrides the custom theme');
 }
开发者ID:helpfulrobot,项目名称:silverstripe-staticpublisher,代码行数:17,代码来源:FilesystemPublisherTest.php

示例8: testActionsChangedOnStageRecord

	function testActionsChangedOnStageRecord() {
		if(class_exists('SiteTreeCMSWorkflow')) return true;
		
		$author = $this->objFromFixture('Member', 'cmseditor');
		$this->session()->inst_set('loggedInAs', $author->ID);
		
		$page = new Page();
		$page->CanEditType = 'LoggedInUsers';
		$page->write();
		$page->doPublish();
		$page->Content = 'Changed on Stage';
		$page->write();
		$page->flushCache();
		
		$actions = $page->getCMSActions();
		$this->assertNotNull($actions->dataFieldByName('action_save'));
		$this->assertNotNull($actions->dataFieldByName('action_publish'));
		$this->assertNotNull($actions->dataFieldByName('action_unpublish'));
		$this->assertNotNull($actions->dataFieldByName('action_delete'));
		$this->assertNull($actions->dataFieldByName('action_deletefromlive'));
		$this->assertNotNull($actions->dataFieldByName('action_rollback'));
		$this->assertNull($actions->dataFieldByName('action_revert'));
	}
开发者ID:redema,项目名称:silverstripe-cms,代码行数:23,代码来源:SiteTreeActionsTest.php

示例9: testDeletingFromLiveSourcePageOfAVirtualPageAlsoUnpublishesVirtualPage

 public function testDeletingFromLiveSourcePageOfAVirtualPageAlsoUnpublishesVirtualPage()
 {
     // Create page and virutal page
     $p = new Page();
     $p->Title = "source";
     $p->write();
     $this->assertTrue($p->doPublish());
     $vp = new VirtualPage();
     $vp->CopyContentFromID = $p->ID;
     $vp->write();
     $this->assertTrue($vp->doPublish());
     // All is fine, the virtual page doesn't have a broken link
     $this->assertFalse($vp->HasBrokenLink);
     // Delete the source page from draft, confirm that this creates a broken link
     $pID = $p->ID;
     $p->delete();
     $vp->flushCache();
     $vp = DataObject::get_by_id('SiteTree', $vp->ID);
     $this->assertEquals(1, $vp->HasBrokenLink);
     // Delete the source page form live, confirm that the virtual page has also been unpublished
     $pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
     $this->assertTrue($pLive->doDeleteFromLive());
     $vpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID);
     $this->assertNull($vpLive);
     // Delete from draft, confirm that the virtual page has a broken link on the draft site
     $pLive->delete();
     $vp->flushCache();
     $vp = DataObject::get_by_id('SiteTree', $vp->ID);
     $this->assertEquals(1, $vp->HasBrokenLink);
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:30,代码来源:VirtualPageTest.php

示例10: testRevertToLiveFixesBrokenLinks

 public function testRevertToLiveFixesBrokenLinks()
 {
     // Create page and virutal page
     $p = new Page();
     $p->Title = "source";
     $p->write();
     $pageID = $p->ID;
     $this->assertTrue($p->doPublish());
     // Content links are one kind of link to pages
     $p2 = new Page();
     $p2->Title = "regular link";
     $p2->Content = "<a href=\"[sitetree_link,id={$p->ID}]\">test</a>";
     $p2->write();
     $this->assertTrue($p2->doPublish());
     // Virtual pages are another
     $vp = new VirtualPage();
     $vp->CopyContentFromID = $p->ID;
     $vp->write();
     // Redirector links are a third
     $rp = new RedirectorPage();
     $rp->Title = "redirector";
     $rp->LinkType = 'Internal';
     $rp->LinkToID = $p->ID;
     $rp->write();
     $this->assertTrue($rp->doPublish());
     // Confirm that there are no broken links to begin with
     $this->assertFalse($p2->HasBrokenLink);
     $this->assertFalse($vp->HasBrokenLink);
     $this->assertFalse($rp->HasBrokenLink);
     // Delete from draft and confirm that broken links are marked
     $pID = $p->ID;
     $p->delete();
     $vp->flushCache();
     $vp = DataObject::get_by_id('SiteTree', $vp->ID);
     $p2->flushCache();
     $p2 = DataObject::get_by_id('SiteTree', $p2->ID);
     $rp->flushCache();
     $rp = DataObject::get_by_id('SiteTree', $rp->ID);
     $this->assertEquals(1, $p2->HasBrokenLink);
     $this->assertEquals(1, $vp->HasBrokenLink);
     $this->assertEquals(1, $rp->HasBrokenLink);
     // Call doRevertToLive and confirm that broken links are restored
     $pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID);
     $pLive->doRevertToLive();
     $p2->flushCache();
     $p2 = DataObject::get_by_id('SiteTree', $p2->ID);
     $vp->flushCache();
     $vp = DataObject::get_by_id('SiteTree', $vp->ID);
     $rp->flushCache();
     $rp = DataObject::get_by_id('SiteTree', $rp->ID);
     $this->assertFalse((bool) $p2->HasBrokenLink);
     $this->assertFalse((bool) $vp->HasBrokenLink);
     $this->assertFalse((bool) $rp->HasBrokenLink);
 }
开发者ID:helpfulrobot,项目名称:comperio-silverstripe-cms,代码行数:54,代码来源:SiteTreeBrokenLinksTest.php

示例11: doPublish

 /**
  * When an error page is published, create a static HTML page with its
  * content, so the page can be shown even when SilverStripe is not
  * functioning correctly before publishing this page normally.
  *
  * @return bool
  */
 public function doPublish()
 {
     if (!parent::doPublish()) {
         return false;
     }
     return $this->writeStaticPage();
 }
开发者ID:tcaiger,项目名称:mSupplyNZ,代码行数:14,代码来源:ErrorPage.php

示例12: onBeforeWrite

 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if ($new_pages = $this->owner->PageStructure) {
         $new_pages = explode("\n", $new_pages);
         $curr_level_page = array();
         $level_sequence = array(1 => 0, 2 => 0, 3 => 0, 4 => 0);
         foreach ($new_pages as $page) {
             $page_class = false;
             if (strpos($page, "|") !== false) {
                 list($page_name, $page_class) = explode("|", trim($page));
             } else {
                 $page_name = trim($page);
             }
             $level = 1;
             while (preg_match("/^\\~/", $page_name)) {
                 $page_name = substr($page_name, 1);
                 $level++;
             }
             $level_sequence[$level] += 10;
             $parentID = 0;
             if ($level > 1 && $curr_level_page[$level - 1]) {
                 $parent = $curr_level_page[$level - 1];
                 $parentID = $parent->ID;
             }
             // see if the page exists
             if (!($new_page = DataObject::get_one('SiteTree', "Title = '" . Convert::raw2sql($page_name) . "' AND ParentID = " . $parentID))) {
                 if ($page_class && $page_class != "Page" && class_exists($page_class)) {
                     $new_page = new $page_class();
                 } else {
                     $new_page = new Page();
                 }
                 $new_page->Title = $page_name;
                 $new_page->Content = '<p>Donec tristique sagittis volutpat. Donec vitae fringilla enim. Vivamus ut velit consectetur, suscipit enim eu, vestibulum ipsum. Morbi tincidunt arcu et nunc consequat dictum. Donec venenatis dolor ac dolor malesuada, non fringilla diam tristique. Duis sit amet semper velit. Vivamus porttitor lectus sed erat interdum, at facilisis urna accumsan. Nunc sit amet sapien et nibh pharetra suscipit at ac urna. Praesent semper eros a mi adipiscing vehicula. Donec pharetra aliquet porta.</p>';
                 $new_page->Status = 'Published';
                 $new_page->Sort = $level_sequence[$level];
                 if ($parentID) {
                     $new_page->ParentID = $parentID;
                 }
                 $new_page->write();
                 $new_page->writeToStage('Stage');
                 $new_page->doPublish();
                 $new_page->flushCache();
             } else {
                 // update the position if the page already exists
                 if (class_exists($page_class) && $new_page->ClassName != $page_class) {
                     $new_page->ClassName = $page_class;
                 }
                 $new_page->Sort = $level_sequence[$level];
                 $new_page->write();
                 $new_page->writeToStage('Stage');
                 $new_page->doPublish();
                 $new_page->flushCache();
             }
             $curr_level_page[$level] = $new_page;
         }
         // update sequence on error pages
         foreach (DataObject::get('ErrorPage') as $error_page) {
             $error_page->Sort = 9999;
             $error_page->write();
             $error_page->writeToStage('Stage');
             $error_page->doPublish();
             $error_page->flushCache();
         }
     }
     $this->owner->PageStructure = "";
 }
开发者ID:helpfulrobot,项目名称:iqnection-modules-pagebuilder,代码行数:67,代码来源:PageBuilder.php

示例13: testDuplicateSubsite

 function testDuplicateSubsite()
 {
     // get subsite1 & create page
     $subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
     $subsite1->activate();
     $page1 = new Page();
     $page1->Title = 'MyAwesomePage';
     $page1->write();
     $page1->doPublish();
     $this->assertEquals($page1->SubsiteID, $subsite1->ID);
     // duplicate
     $subsite2 = $subsite1->duplicate();
     $subsite2->activate();
     // change content on dupe
     $page2 = DataObject::get_one('Page', "\"Title\" = 'MyAwesomePage'");
     $page2->Title = 'MyNewAwesomePage';
     $page2->write();
     $page2->doPublish();
     // check change & check change has not affected subiste1
     $subsite1->activate();
     $this->assertEquals('MyAwesomePage', DataObject::get_by_id('Page', $page1->ID)->Title);
     $subsite2->activate();
     $this->assertEquals('MyNewAwesomePage', DataObject::get_by_id('Page', $page2->ID)->Title);
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:24,代码来源:SubsiteTest.php

示例14: doPublish

 /**
  * When an error page is published, create a static HTML page with its
  * content, so the page can be shown even when SilverStripe is not
  * functioning correctly before publishing this page normally.
  *
  * @param string|int $fromStage Place to copy from. Can be either a stage name or a version number.
  * @param string $toStage Place to copy to. Must be a stage name.
  * @param boolean $createNewVersion Set this to true to create a new version number.  By default, the existing version number will be copied over.
  */
 public function doPublish()
 {
     parent::doPublish();
     // Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
     $oldEnabled = Config::inst()->get('SSViewer', 'theme_enabled');
     Config::inst()->update('SSViewer', 'theme_enabled', true);
     $response = Director::test(Director::makeRelative($this->Link()));
     Config::inst()->update('SSViewer', 'theme_enabled', $oldEnabled);
     $errorContent = $response->getBody();
     // Make the base tag dynamic.
     // $errorContent = preg_replace('/<base[^>]+href="' . str_replace('/','\\/', Director::absoluteBaseURL()) . '"[^>]*>/i', '<base href="$BaseURL" />', $errorContent);
     // Check we have an assets base directory, creating if it we don't
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH, 02775);
     }
     // if the page is published in a language other than default language,
     // write a specific language version of the HTML page
     $filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Locale);
     if ($fh = fopen($filePath, "w")) {
         fwrite($fh, $errorContent);
         fclose($fh);
     } else {
         $fileErrorText = _t("ErrorPage.ERRORFILEPROBLEM", "Error opening file \"{filename}\" for writing. Please check file permissions.", array('filename' => $errorFile));
         $this->response->addHeader('X-Status', rawurlencode($fileErrorText));
         return $this->httpError(405);
     }
 }
开发者ID:prostart,项目名称:erics-homes,代码行数:36,代码来源:ErrorPage.php

示例15: testEmbargoExpiryWithVirtualPages

 function testEmbargoExpiryWithVirtualPages()
 {
     $custompublisher = $this->objFromFixture('Member', 'custompublisher');
     $custompublisher->login();
     $sourcePage = new Page();
     $sourcePage->Content = '<p>Pre-embargo</p>';
     $sourcePage->write();
     $sourcePage->doPublish();
     $sourcePage->Content = '<p>Post-embargo</p>';
     $sourcePage->write();
     $request = $sourcePage->openOrNewWorkflowRequest('WorkflowPublicationRequest');
     $sourcePage->setEmbargo('01/06/2050', '3:00pm');
     $sourcePage->write();
     $request->approve('all good');
     $virtualPage = new VirtualPage();
     $virtualPage->CopyContentFromID = $sourcePage->ID;
     $virtualPage->write();
     $virtualPage->doPublish();
     $liveVirtualPage = Versioned::get_one_by_stage('VirtualPage', 'Live', '"SiteTree"."ID" = ' . $virtualPage->ID);
     $this->assertEquals($liveVirtualPage->Content, '<p>Pre-embargo</p>');
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:21,代码来源:ThreeStepWorkflowTest.php


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