silverstripe-cms/code/controllers/CMSPagesController.php
Ingo Schommer f454f481f2 BUG Session namespace sharing for CMS controllers
Ideally we could do this without session, but pragmatically
we still need it, because of the inflexible routing system,
and because of performance considerations.

Example: The tree is lazy loaded via a generic  URL (admin/pages/treeview).
While we could add ?ID=<currentpage> to make the view (more or less) stateless,
it would trigger a full tree reload on every tree navigation action.
Instead, we assume that all "reachable" nodes are already cached,
and simply mark a different one as current. For this to work, we need
shared session state between CMS controllers.

See http://open.silverstripe.org/ticket/7815 for detail.
2012-08-29 15:09:15 +02:00

62 lines
1.5 KiB
PHP

<?php
/**
* @package cms
*/
class CMSPagesController extends CMSMain {
static $url_segment = 'pages';
static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 40;
static $menu_title = 'Pages';
static $required_permission_codes = 'CMS_ACCESS_CMSMain';
static $session_namespace = 'CMSMain';
function LinkPreview() {
return false;
}
/**
* @return String
*/
public function ViewState() {
return $this->request->getVar('view');
}
public function isCurrentPage(DataObject $record) {
return false;
}
public function Breadcrumbs($unlinked = false) {
$items = parent::Breadcrumbs($unlinked);
//special case for building the breadcrumbs when calling the listchildren Pages ListView action
if($parentID = $this->request->getVar('ParentID')) {
$page = DataObject::get_by_id('SiteTree', $parentID);
//build a reversed list of the parent tree
$pages = array();
while($page) {
array_unshift($pages, $page); //add to start of array so that array is in reverse order
$page = $page->Parent;
}
//turns the title and link of the breadcrumbs into template-friendly variables
$params = array_filter(array(
'view' => $this->request->getVar('view'),
'q' => $this->request->getVar('q')
));
foreach($pages as $page) {
$params['ParentID'] = $page->ID;
$item = new StdClass();
$item->Title = $page->Title;
$item->Link = Controller::join_links($this->Link(), '?' . http_build_query($params));
$items->push(new ArrayData($item));
}
}
return $items;
}
}