mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Use Controller::join_links() for all TableListField and ComplexTableField link building, to support form URLs with querystrings.
BUGFIX: If ComplexTableField::getParentRecord() can't find a record, just return null rather than erroring. (from r96555) (from r96649) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96775 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
252fbf0ba7
commit
9f9c572306
@ -354,7 +354,7 @@ JS;
|
||||
|
||||
|
||||
function AddLink() {
|
||||
return $this->Link() . '/add';
|
||||
return Controller::join_links($this->Link(), 'add');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -390,16 +390,18 @@ JS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the record in which the CTF resides
|
||||
* Return the record in which the CTF resides, if it exists.
|
||||
*/
|
||||
function getParentRecord() {
|
||||
if($this->form && $record = $this->form->getRecord()) {
|
||||
return $record;
|
||||
} else {
|
||||
if($this->sourceID()) {
|
||||
$parentClass = DataObject::get_by_id($this->getParentClass(), $this->sourceID());
|
||||
} else {
|
||||
$parentClass = singleton($this->getParentClass());
|
||||
$parentID = (int)$this->sourceID();
|
||||
$parentClass = $this->getParentClass();
|
||||
|
||||
if($parentClass) {
|
||||
if($parentID) return DataObject::get_by_id($parentClass, $parentID);
|
||||
else return singleton($parentClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -660,10 +662,12 @@ JS;
|
||||
_t('ComplexTableField.CLOSEPOPUP', 'Close Popup')
|
||||
);
|
||||
|
||||
$editLink = Controller::join_links($this->Link(), 'item/' . $childData->ID . '/edit');
|
||||
|
||||
$message = sprintf(
|
||||
_t('ComplexTableField.SUCCESSADD', 'Added %s %s %s'),
|
||||
$childData->singular_name(),
|
||||
'<a href="' . $this->Link() . '/item/' . $childData->ID . '/edit">' . $childData->Title . '</a>',
|
||||
'<a href="' . $editLink . '">' . $childData->Title . '</a>',
|
||||
$closeLink
|
||||
);
|
||||
|
||||
@ -1007,15 +1011,15 @@ class ComplexTableField_Item extends TableListField_Item {
|
||||
}
|
||||
|
||||
function EditLink() {
|
||||
return $this->Link() . "/edit";
|
||||
return Controller::join_links($this->Link(), "edit");
|
||||
}
|
||||
|
||||
function ShowLink() {
|
||||
return $this->Link() . "/show";
|
||||
return Controller::join_links($this->Link(), "show");
|
||||
}
|
||||
|
||||
function DeleteLink() {
|
||||
return $this->Link() . "/delete";
|
||||
return Controller::join_links($this->Link(), "delete");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1124,7 +1124,7 @@ JS
|
||||
|
||||
if(isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) {
|
||||
$start = ($_REQUEST['ctf'][$this->Name()]['start'] < 0) ? 0 : $_REQUEST['ctf'][$this->Name()]['start'];
|
||||
$link .= "/?ctf[{$this->Name()}][start]={$start}";
|
||||
$link = Controller::join_links($link, "?ctf[{$this->Name()}][start]={$start}");
|
||||
}
|
||||
|
||||
if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams);
|
||||
@ -1417,7 +1417,7 @@ class TableListField_ItemRequest extends RequestHandler {
|
||||
);
|
||||
|
||||
function Link() {
|
||||
return $this->ctf->Link() . '/item/' . $this->itemID;
|
||||
return Controller::join_links($this->ctf->Link(), 'item/' . $this->itemID);
|
||||
}
|
||||
|
||||
function __construct($ctf, $itemID) {
|
||||
|
@ -95,7 +95,7 @@ ComplexTableField.prototype = {
|
||||
var table = Event.findElement(e,"table");
|
||||
if(Event.element(e).nodeName == "IMG") {
|
||||
link = Event.findElement(e,"a");
|
||||
popupLink = link.href+"?ajax=1";
|
||||
popupLink = link.href + (link.href.match(/\?/) ? "&ajax=1" : "?ajax=1");
|
||||
} else {
|
||||
el = Event.findElement(e,"tr");
|
||||
var link = $$("a",el)[0];
|
||||
|
Loading…
Reference in New Issue
Block a user