Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ENHANCEMENT SSF-124 customise displayed fields of page list view, add…

… children list view links
  • Loading branch information...
commit 7d9873472b51c362910f6d5610b9b855f3ae48b2 1 parent ea377b6
@normann normann authored
Showing with 46 additions and 5 deletions.
  1. +39 −5 code/controllers/CMSMain.php
  2. +7 −0 code/model/SiteTree.php
View
44 code/controllers/CMSMain.php
@@ -524,7 +524,7 @@ public function getEditForm($id = null, $fields = null) {
*
* @return SS_List
*/
- public function getList() {
+ public function getList(&$filterOnOff) {
$list = new DataList($this->stat('tree_class'));
$request = $this->request;
@@ -535,26 +535,51 @@ public function getList() {
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 @@ public function getListView(){
);
$this->extend('updateListView', $listview);
+
$listview->disableSecurityToken();
return $listview;
}
@@ -587,6 +613,14 @@ public function currentPageID() {
return $id;
}
+
+ public function listchildren(){
+ if(Director::is_ajax()){
+ return $this;
+ }else{
+
+ }
+ }
//------------------------------------------------------------------------------------------//
// Data saving handlers
View
7 code/model/SiteTree.php
@@ -2448,6 +2448,13 @@ function TreeTitle() {
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
Please sign in to comment.
Something went wrong with that request. Please try again.