本文整理汇总了PHP中RootURLController::get_homepage_urlsegment方法的典型用法代码示例。如果您正苦于以下问题:PHP RootURLController::get_homepage_urlsegment方法的具体用法?PHP RootURLController::get_homepage_urlsegment怎么用?PHP RootURLController::get_homepage_urlsegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RootURLController
的用法示例。
在下文中一共展示了RootURLController::get_homepage_urlsegment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testHomepageForDomain
function testHomepageForDomain()
{
$originalHost = $_SERVER['HTTP_HOST'];
// Tests matching an HTTP_HOST value to URLSegment homepage values
$tests = array('page.co.nz' => 'page1', 'www.page.co.nz' => 'page1', 'help.com' => 'page1', 'www.help.com' => 'page1', 'something.com' => 'page1', 'www.something.com' => 'page1', 'other.co.nz' => 'page2', 'www.other.co.nz' => 'page2', 'right' => 'page2', 'www. right' => 'page2', 'only.com' => 'page3', 'www.only.com' => 'page3', 'www.somethingelse.com' => 'home', 'somethingelse.com' => 'home', 'alternate.only.com' => 'home', 'www.alternate.only.com' => 'home', 'alternate.something.com' => 'home');
foreach ($tests as $domain => $urlSegment) {
$_SERVER['HTTP_HOST'] = $domain;
$this->assertEquals($urlSegment, RootURLController::get_homepage_urlsegment(Translatable::default_locale()), "Testing {$domain} matches {$urlSegment}");
}
$_SERVER['HTTP_HOST'] = $originalHost;
}
示例2: testHomepageForDomain
function testHomepageForDomain() {
$originalHost = $_SERVER['HTTP_HOST'];
// Tests matching an HTTP_HOST value to URLSegment homepage values
$tests = array(
'page.co.nz' => 'page1',
'www.page.co.nz' => 'page1',
'help.com' => 'page1',
'www.help.com' => 'page1',
'something.com' => 'page1',
'www.something.com' => 'page1',
'other.co.nz' => 'page2',
'www.other.co.nz' => 'page2',
'right' => 'page2',
'www. right' => 'page2',
'only.com' => 'page3',
'www.only.com' => 'page3',
'www.somethingelse.com' => 'home',
'somethingelse.com' => 'home',
// Test some potential false matches to page2 and page3
'alternate.only.com' => 'home',
'www.alternate.only.com' => 'home',
'alternate.something.com' => 'home',
);
foreach($tests as $domain => $urlSegment) {
$_SERVER['HTTP_HOST'] = $domain;
$this->assertEquals($urlSegment, RootURLController::get_homepage_urlsegment(), "Testing $domain matches $urlSegment");
}
$_SERVER['HTTP_HOST'] = $originalHost;
}
示例3: testRootUrlDefaultsToTranslatedUrlSegment
function testRootUrlDefaultsToTranslatedUrlSegment()
{
$origPage = $this->objFromFixture('Page', 'homepage_en');
$origPage->publish('Stage', 'Live');
$translationDe = $origPage->createTranslation('de_DE');
$translationDe->URLSegment = 'heim';
$translationDe->write();
$translationDe->publish('Stage', 'Live');
// test with translatable
Translatable::set_current_locale('de_DE');
$this->assertEquals(RootURLController::get_homepage_urlsegment(), 'heim', 'Homepage with different URLSegment in non-default language is found');
// @todo Fix add/remove extension
// test with translatable disabled
// Object::remove_extension('Page', 'Translatable');
// $_SERVER['HTTP_HOST'] = '/';
// $this->assertEquals(
// RootURLController::get_homepage_urlsegment(),
// 'home',
// 'Homepage is showing in default language if ?lang GET variable is left out'
// );
// Object::add_extension('Page', 'Translatable');
// setting back to default
Translatable::set_current_locale('en_US');
}