本文整理汇总了PHP中Director::baseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::baseUrl方法的具体用法?PHP Director::baseUrl怎么用?PHP Director::baseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::baseUrl方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTagWithoutTitleContainingDots
function testGetTagWithoutTitleContainingDots() {
$image = $this->objFromFixture('Image', 'imageWithoutTitleContainingDots');
$expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test.image.with.dots.png" alt="test.image.with.dots" />';
$actual = $image->getTag();
$this->assertEquals($expected, $actual);
}
示例2: testChangePasswordFromLostPassword
public function testChangePasswordFromLostPassword()
{
$admin = $this->objFromFixture('Member', 'test');
$admin->FailedLoginCount = 99;
$admin->LockedOutUntil = SS_Datetime::now()->Format('Y-m-d H:i:s');
$admin->write();
$this->assertNull($admin->AutoLoginHash, 'Hash is empty before lost password');
// Request new password by email
$response = $this->get('Security/lostpassword');
$response = $this->post('Security/LostPasswordForm', array('Email' => 'sam@silverstripe.com'));
$this->assertEmailSent('sam@silverstripe.com');
// Load password link from email
$admin = DataObject::get_by_id('Member', $admin->ID);
$this->assertNotNull($admin->AutoLoginHash, 'Hash has been written after lost password');
// We don't have access to the token - generate a new token and hash pair.
$token = $admin->generateAutologinTokenAndStoreHash();
// Check.
$response = $this->get('Security/changepassword/?m=' . $admin->ID . '&t=' . $token);
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals(Director::baseUrl() . 'Security/changepassword', $response->getHeader('Location'));
// Follow redirection to form without hash in GET parameter
$response = $this->get('Security/changepassword');
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
$this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs'));
// Check if we can login with the new password
$goodResponse = $this->doTestLoginForm('sam@silverstripe.com', 'changedPassword');
$this->assertEquals(302, $goodResponse->getStatusCode());
$this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs'));
$admin = DataObject::get_by_id('Member', $admin->ID, false);
$this->assertNull($admin->LockedOutUntil);
$this->assertEquals(0, $admin->FailedLoginCount);
}
示例3: testChangePasswordFromLostPassword
function testChangePasswordFromLostPassword()
{
$admin = $this->objFromFixture('Member', 'test');
$this->assertNull($admin->AutoLoginHash, 'Hash is empty before lost password');
// Request new password by email
$response = $this->get('Security/lostpassword');
$response = $this->submitForm('MemberLoginForm_LostPasswordForm', null, array('Email' => 'sam@silverstripe.com'));
$this->assertEmailSent('sam@silverstripe.com');
// Load password link from email
$admin = DataObject::get_by_id('Member', $admin->ID);
$this->assertNotNull($admin->AutoLoginHash, 'Hash has been written after lost password');
$response = $this->get('Security/changepassword/?h=' . $admin->AutoLoginHash);
$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals(Director::baseUrl() . 'Security/changepassword', $response->getHeader('Location'));
// Follow redirection to form without hash in GET parameter
$response = $this->get('Security/changepassword');
$changedResponse = $this->doTestChangepasswordForm('1nitialPassword', 'changedPassword');
$this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs'));
// Check if we can login with the new password
$goodResponse = $this->doTestLoginForm('sam@silverstripe.com', 'changedPassword');
$this->assertEquals(302, $goodResponse->getStatusCode());
$this->assertEquals($this->idFromFixture('Member', 'test'), $this->session()->inst_get('loggedInAs'));
}
示例4: testGetTagWithoutTitleContainingDots
public function testGetTagWithoutTitleContainingDots()
{
Config::inst()->update('Image', 'force_resample', false);
$image = $this->objFromFixture('Image', 'imageWithoutTitleContainingDots');
$expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test.image.with.dots.png" alt="test.image.with.dots" />';
$actual = $image->getTag();
$this->assertEquals($expected, $actual);
}
示例5: buildFormAction
/**
* Builds and returns the form action to use.
*
* @return string
*
* @author Sebastian Diel <sdiel@pixeltricks.de>,
* Sascha Koehler <skoehler@pixeltricks.de>
* @since 04.07.2013
*/
protected function buildFormAction()
{
if (is_null($this->customHtmlFormAction)) {
$formAction = Controller::join_links($this->getFormController($this->controller, $this->basePreferences)->Link(), $this->getSubmitAction());
} else {
$formAction = Director::baseUrl() . 'customhtmlformaction/' . $this->customHtmlFormAction;
}
return $formAction;
}
示例6: BaseUrl
/**
* Returns the base url.
*
* @return string
*
* @author Sascha Koehler <skoehler@pixeltricks.de>
* @since 16.05.2012
*/
public function BaseUrl()
{
return Director::baseUrl();
}
示例7: Link
public function Link($action = null)
{
return Controller::join_links(Director::baseUrl(), 'dev/testsession', $action);
}
示例8: getBaseURLSegment
/**
* Returns the base URL segment that's used for inclusion of css and
* javascript files via Requirements.
*
* @return string
*
* @author Sascha Koehler <skoehler@pixeltricks.de>
* @since 16.02.2012
*/
public static function getBaseURLSegment()
{
if (is_null(self::$baseURLSegment)) {
$baseUrl = Director::baseUrl();
if ($baseUrl === '/') {
$baseUrl = '';
}
if (!empty($baseUrl) && substr($baseUrl, -1) != '/') {
$baseUrl .= '/';
}
self::$baseURLSegment = $baseUrl;
}
return self::$baseURLSegment;
}