mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE Don't partially URI encode strings in SiteTree->RelativeLink(), rely on XML casting in templates instead (fixes #6125, thanks paradigmincarnate)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@113694 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
7700b223a3
commit
854cbe79c8
@ -111,6 +111,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
"Breadcrumbs" => "HTMLText",
|
||||
"LastEdited" => "SS_Datetime",
|
||||
"Created" => "SS_Datetime",
|
||||
'Link' => 'Text',
|
||||
'RelativeLink' => 'Text',
|
||||
'AbsoluteLink' => 'Text',
|
||||
);
|
||||
|
||||
static $defaults = array(
|
||||
@ -365,7 +368,10 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
/**
|
||||
* Return the link for this {@link SiteTree} object, with the {@link Director::baseURL()} included.
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $action Optional controller action (method).
|
||||
* Note: URI encoding of this parameter is applied automatically through template casting,
|
||||
* don't encode the passed parameter.
|
||||
* Please use {@link Controller::join_links()} instead to append GET parameters.
|
||||
* @return string
|
||||
*/
|
||||
public function Link($action = null) {
|
||||
@ -375,7 +381,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
/**
|
||||
* Get the absolute URL for this page, including protocol and host.
|
||||
*
|
||||
* @param string $action
|
||||
* @param string $action See {@link Link()}
|
||||
* @return string
|
||||
*/
|
||||
public function AbsoluteLink($action = null) {
|
||||
@ -394,7 +400,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
* and returned in its full form.
|
||||
*
|
||||
* @uses RootURLController::get_homepage_link()
|
||||
* @param string $action
|
||||
*
|
||||
* @param string $action See {@link Link()}
|
||||
* @return string
|
||||
*/
|
||||
public function RelativeLink($action = null) {
|
||||
@ -415,12 +422,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
}
|
||||
}
|
||||
|
||||
if(is_string($action)) {
|
||||
$action = str_replace('&', '&', $action);
|
||||
} elseif($action === true) {
|
||||
$action = null;
|
||||
}
|
||||
|
||||
// Legacy support
|
||||
if($action === true) $action = null;
|
||||
|
||||
return Controller::join_links($base, '/', $action);
|
||||
}
|
||||
|
||||
|
@ -331,6 +331,16 @@ class SiteTreeTest extends SapphireTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testRelativeLink() {
|
||||
$about = $this->objFromFixture('Page', 'about');
|
||||
$staff = $this->objFromFixture('Page', 'staff');
|
||||
|
||||
$this->assertEquals('about-us/', $about->RelativeLink(), 'Matches URLSegment on top level without parameters');
|
||||
$this->assertEquals('about-us/my-staff/', $staff->RelativeLink(), 'Matches URLSegment plus parent on second level without parameters');
|
||||
$this->assertEquals('about-us/edit', $about->RelativeLink('edit'), 'Matches URLSegment plus parameter on top level');
|
||||
$this->assertEquals('about-us/tom&jerry', $about->RelativeLink('tom&jerry'), 'Doesnt url encode parameter');
|
||||
}
|
||||
|
||||
function testDeleteFromStageOperatesRecursively() {
|
||||
SiteTree::set_enforce_strict_hierarchy(false);
|
||||
$pageAbout = $this->objFromFixture('Page', 'about');
|
||||
|
Loading…
x
Reference in New Issue
Block a user