本文整理汇总了PHP中SiteTree::generate_homepage_domain_map方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteTree::generate_homepage_domain_map方法的具体用法?PHP SiteTree::generate_homepage_domain_map怎么用?PHP SiteTree::generate_homepage_domain_map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteTree
的用法示例。
在下文中一共展示了SiteTree::generate_homepage_domain_map方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHomepageMapIsWithStaticPublishing
function testHomepageMapIsWithStaticPublishing()
{
$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 = SiteTree::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');
}
示例2: doPublish
/**
* Publish this page.
*
* @uses SiteTreeDecorator->onBeforePublish()
* @uses SiteTreeDecorator->onAfterPublish()
*/
function doPublish()
{
if (!$this->canPublish()) {
return false;
}
$original = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = {$this->ID}");
if (!$original) {
$original = new SiteTree();
}
// Handle activities undertaken by decorators
$this->invokeWithExtensions('onBeforePublish', $original);
$this->Status = "Published";
//$this->PublishedByID = Member::currentUser()->ID;
$this->write();
$this->publish("Stage", "Live");
DB::query("UPDATE \"SiteTree_Live\"\n\t\t\tSET \"Sort\" = (SELECT \"SiteTree\".\"Sort\" FROM \"SiteTree\" WHERE \"SiteTree_Live\".\"ID\" = \"SiteTree\".\"ID\")\n\t\t\tWHERE EXISTS (SELECT \"SiteTree\".\"Sort\" FROM \"SiteTree\" WHERE \"SiteTree_Live\".\"ID\" = \"SiteTree\".\"ID\") AND \"ParentID\" = " . sprintf('%d', $this->ParentID));
// Publish any virtual pages that might need publishing
$linkedPages = $this->VirtualPages();
if ($linkedPages) {
foreach ($linkedPages as $page) {
$page->copyFrom($page->CopyContentFrom());
$page->write();
if ($page->ExistsOnLive) {
$page->doPublish();
}
}
}
// Need to update pages linking to this one as no longer broken, on the live site
$origMode = Versioned::get_reading_mode();
Versioned::reading_stage('Live');
foreach ($this->DependentPages(false) as $page) {
// $page->write() calls syncLinkTracking, which does all the hard work for us.
$page->write();
}
Versioned::set_reading_mode($origMode);
// Check to write CMS homepage map.
$usingStaticPublishing = false;
foreach (ClassInfo::subclassesFor('StaticPublisher') as $class) {
if ($this->hasExtension($class)) {
$usingStaticPublishing = true;
}
}
// NOTE: if you change the path here, you must also change it in sapphire/static-main.php
if (self::$write_homepage_map) {
if ($usingStaticPublishing && ($map = SiteTree::generate_homepage_domain_map())) {
@file_put_contents(BASE_PATH . '/' . ASSETS_DIR . '/_homepage-map.php', "<?php\n\$homepageMap = " . var_export($map, true) . "; ?>");
} else {
if (file_exists(BASE_PATH . '/' . ASSETS_DIR . '/_homepage-map.php')) {
unlink(BASE_PATH . '/' . ASSETS_DIR . '/_homepage-map.php');
}
}
}
// Handle activities undertaken by decorators
$this->invokeWithExtensions('onAfterPublish', $original);
return true;
}