FIX Ensure that redirection back to pages works for SS 3.6
This commit is contained in:
parent
d0c2558a1f
commit
9d5e028d10
|
@ -197,10 +197,26 @@ class DMSDocumentAddController extends LeftAndMain
|
|||
return $modelAdmin->Link();
|
||||
}
|
||||
|
||||
return $this->getPageEditLink($this->currentPageID(), $this->getRequest()->getVar('dsid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a link to a page. In SS <= 3.5 this is loaded from the session, whereas in SS >= 3.6 this is set
|
||||
* explicitly to a class property on CMSMain. This method checks whether the URL handler to detect this ID
|
||||
* exists on CMSMain, if so include it in the URL.
|
||||
*
|
||||
* @param int $pageId
|
||||
* @param int $documentSetId
|
||||
* @return string
|
||||
*/
|
||||
protected function getPageEditLink($pageId, $documentSetId)
|
||||
{
|
||||
// Only get configuration from CMSMain, not its descendants or extensions
|
||||
$urlHandlers = (array) Config::inst()->get('CMSMain', 'url_handlers', Config::UNINHERITED);
|
||||
$pageIdSegment = array_key_exists('EditForm/$ID', $urlHandlers) ? $pageId . '/' : '';
|
||||
return Controller::join_links(
|
||||
singleton('CMSPagesController')->Link(),
|
||||
'edit/EditForm/field/Document%20Sets/item',
|
||||
$this->getRequest()->getVar('dsid')
|
||||
sprintf('edit/EditForm/%sfield/Document Sets/item/%d', $pageIdSegment, $documentSetId)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,15 @@ class DMSDocumentAddControllerTest extends FunctionalTest
|
|||
$this->controller->setRequest($request);
|
||||
$this->assertContains('admin/pages', $this->controller->Backlink());
|
||||
$this->assertContains('123', $this->controller->Backlink());
|
||||
|
||||
$urlHandlers = (array) Config::inst()->get('CMSMain', 'url_handlers', Config::UNINHERITED);
|
||||
if (array_key_exists('EditForm/$ID', $urlHandlers)) {
|
||||
// SS 3.6 and above, ensure that the page ID is in the edit URL
|
||||
$this->assertContains('admin/pages/edit/EditForm/234', $this->controller->Backlink());
|
||||
} else {
|
||||
// SS 3.5 and below, the page ID is loaded from the session
|
||||
$this->assertNotContains('234', $this->controller->Backlink());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue