mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 09:05:53 +00:00
ENHANCEMENT SSF-124 customise displayed fields of page list view, add children list view links
This commit is contained in:
parent
ea377b6012
commit
7d9873472b
@ -524,7 +524,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
*
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getList() {
|
||||
public function getList(&$filterOnOff) {
|
||||
$list = new DataList($this->stat('tree_class'));
|
||||
|
||||
$request = $this->request;
|
||||
@ -535,26 +535,51 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
throw new Exception(sprintf('Invalid filter class passed: %s', $filterClass));
|
||||
}
|
||||
$filter = new $filterClass($request->requestVars());
|
||||
$filterOn = true;
|
||||
foreach($pages=$filter->pagesIncluded() as $pageMap){
|
||||
$ids[] = $pageMap['ID'];
|
||||
}
|
||||
if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')');
|
||||
}else{
|
||||
$list->filter("ParentID", 0);
|
||||
}
|
||||
|
||||
if(count($ids)) $list->where('"'.$this->stat('tree_class').'"."ID" IN ('.implode(",", $ids).')');
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getListView(){
|
||||
$list = $this->getList();
|
||||
$filterOn = false;
|
||||
$list = $this->getList($filterOn);
|
||||
$gridFieldConfig = GridFieldConfig::create()->addComponents(
|
||||
new GridFieldSortableHeader(),
|
||||
new GridFieldDataColumns(),
|
||||
new GridFieldPaginator(15),
|
||||
new GridFieldEditButton(),
|
||||
new GridFieldDeleteAction(),
|
||||
new GridFieldDetailForm()
|
||||
);
|
||||
$gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
|
||||
|
||||
if($filterOn){
|
||||
$gridField->setDisplayFields(array(
|
||||
'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
|
||||
'Created' => _t('SiteTree.CREATED', 'Date Created'),
|
||||
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
|
||||
));
|
||||
}else{
|
||||
$gridField->setDisplayFields(array(
|
||||
'listChildrenLink' => "",
|
||||
'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
|
||||
'Created' => _t('SiteTree.CREATED', 'Date Created'),
|
||||
'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
|
||||
));
|
||||
}
|
||||
|
||||
$gridField->setFieldCasting(array(
|
||||
'Created' => 'Date->Ago',
|
||||
'LastEdited' => 'Date->Ago',
|
||||
|
||||
));
|
||||
|
||||
$listview = new Form(
|
||||
$this,
|
||||
'ListView',
|
||||
@ -563,6 +588,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
);
|
||||
|
||||
$this->extend('updateListView', $listview);
|
||||
|
||||
$listview->disableSecurityToken();
|
||||
return $listview;
|
||||
}
|
||||
@ -587,6 +613,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
public function listchildren(){
|
||||
if(Director::is_ajax()){
|
||||
return $this;
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------//
|
||||
// Data saving handlers
|
||||
|
@ -2448,6 +2448,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
Deprecation::notice('3.0', 'Use getTreeTitle() instead.');
|
||||
return $this->getTreeTitle();
|
||||
}
|
||||
|
||||
function listChildrenLink(){
|
||||
if($num = $this->numChildren()){
|
||||
$link = singleton('CMSPagesController')->Link('listchildren')."/".$this->ID;
|
||||
return '<a href="'.$link.'" class="list-children-link">'.$num.'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TitleWithStatus will return the title in an <ins>, <del> or
|
||||
|
Loading…
x
Reference in New Issue
Block a user