mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
adding page id into cmsmain
This commit is contained in:
parent
af1002194d
commit
487235f991
@ -15,6 +15,10 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
|
|
||||||
private static $url_rule = '/$Action/$ID/$OtherID';
|
private static $url_rule = '/$Action/$ID/$OtherID';
|
||||||
|
|
||||||
|
private static $url_handlers = array(
|
||||||
|
'EditForm/$ID' => 'EditForm',
|
||||||
|
);
|
||||||
|
|
||||||
// Maintain a lower priority than other administration sections
|
// Maintain a lower priority than other administration sections
|
||||||
// so that Director does not think they are actions of CMSMain
|
// so that Director does not think they are actions of CMSMain
|
||||||
private static $url_priority = 39;
|
private static $url_priority = 39;
|
||||||
@ -66,6 +70,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
*/
|
*/
|
||||||
private static $enabled_legacy_actions = array();
|
private static $enabled_legacy_actions = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The page id for this request
|
||||||
|
*
|
||||||
|
* @var int|null
|
||||||
|
*/
|
||||||
|
protected $pageID = null;
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
// set reading lang
|
// set reading lang
|
||||||
if(SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
|
if(SiteTree::has_extension('Translatable') && !$this->getRequest()->isAjax()) {
|
||||||
@ -592,6 +603,29 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensuring we set the current page id from the $ID url parameter.
|
||||||
|
*
|
||||||
|
* @param SS_HTTPRequest $request
|
||||||
|
*
|
||||||
|
* @return Form
|
||||||
|
*/
|
||||||
|
public function EditForm($request = null) {
|
||||||
|
// set page ID from request
|
||||||
|
if ($request) {
|
||||||
|
// validate id is present
|
||||||
|
$id = $request->param('ID');
|
||||||
|
|
||||||
|
if (!isset($id)) {
|
||||||
|
return $this->httpError(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setCurrentPageID($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getEditForm();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* @param int $id
|
||||||
* @param FieldList $fields
|
* @param FieldList $fields
|
||||||
@ -690,6 +724,9 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
$form->setFields($readonlyFields);
|
$form->setFields($readonlyFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update form action to include $pageID
|
||||||
|
$form->setFormAction(Controller::join_links($form->FormAction(), $id));
|
||||||
|
|
||||||
$this->extend('updateEditForm', $form);
|
$this->extend('updateEditForm', $form);
|
||||||
return $form;
|
return $form;
|
||||||
} else if($id) {
|
} else if($id) {
|
||||||
@ -866,8 +903,25 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
return $listview;
|
return $listview;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the page id into $pageID rather than into {@link Session}.
|
||||||
|
*
|
||||||
|
* @param string|int $id
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setCurrentPageID($id) {
|
||||||
|
$id = (int)$id;
|
||||||
|
$this->pageID = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the page id from this request
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function currentPageID() {
|
public function currentPageID() {
|
||||||
$id = parent::currentPageID();
|
$id = $this->pageID;
|
||||||
|
|
||||||
$this->extend('updateCurrentPageID', $id);
|
$this->extend('updateCurrentPageID', $id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user