Skip to content
This repository
Browse code

ENHANCEMENT: Part of fix to #7010. Change to some gridfield calls to …

…setDisplayFields and friends.
  • Loading branch information...
commit 7850499687662442359bb84a73139575f277541c 1 parent 0e071c9
Robert Curry authored April 19, 2012
5  code/controllers/AssetAdmin.php
@@ -139,14 +139,15 @@ public function getEditForm($id = null, $fields = null) {
139 139
 			new GridFieldDetailForm()
140 140
 		);
141 141
 		$gridField = new GridField('File','Files', $this->getList(), $gridFieldConfig);
142  
-		$gridField->setDisplayFields(array(
  142
+		$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
  143
+		$columns->setDisplayFields(array(
143 144
 			'StripThumbnail' => '',
144 145
 			// 'Parent.FileName' => 'Folder',
145 146
 			'Title' => _t('File.Name'),
146 147
 			'Created' => _t('AssetAdmin.CREATED', 'Date'),
147 148
 			'Size' => _t('AssetAdmin.SIZE', 'Size'),
148 149
 		));
149  
-		$gridField->setFieldCasting(array(
  150
+		$columns->setFieldCasting(array(
150 151
 			'Created' => 'Date->Nice'
151 152
 		));
152 153
 		$gridField->setAttribute(
9  code/controllers/CMSMain.php
@@ -676,7 +676,8 @@ public function ListViewForm(){
676 676
 			new GridFieldPaginator(15)
677 677
 		);
678 678
 		$gridField = new GridField('Page','Pages', $list, $gridFieldConfig);
679  
-		
  679
+		$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
  680
+
680 681
 		// Don't allow navigating into children nodes on filtered lists
681 682
 		if($params){
682 683
 			$gridField->setDisplayFields(array(
@@ -685,7 +686,7 @@ public function ListViewForm(){
685 686
 				'LastEdited' => _t('SiteTree.LASTUPDATED', 'Last Updated'),
686 687
 			));
687 688
 		}else{
688  
-			$gridField->setDisplayFields(array(
  689
+			$columns->setDisplayFields(array(
689 690
 				'listChildrenLink' => "",
690 691
 				'getTreeTitle' => _t('SiteTree.PAGETITLE', 'Page Title'),
691 692
 				'Created' => _t('SiteTree.CREATED', 'Date Created'),
@@ -693,13 +694,13 @@ public function ListViewForm(){
693 694
 			));
694 695
 		}
695 696
 		
696  
-		$gridField->setFieldCasting(array(
  697
+		$columns->setFieldCasting(array(
697 698
 			'Created' => 'Date->Ago',
698 699
 			'LastEdited' => 'Date->Ago',
699 700
 		));
700 701
 
701 702
 		$controller = $this;
702  
-		$gridField->setFieldFormatting(array(
  703
+		$columns->setFieldFormatting(array(
703 704
 			'listChildrenLink' => function(&$item) use($controller) {
704 705
 				$num = $item->numChildren();
705 706
 				if($num) {
12  code/controllers/ReportAdmin.php
@@ -162,6 +162,7 @@ public function getEditForm($id = null, $fields = null) {
162 162
 				new GridFieldExportButton()
163 163
 			);
164 164
 			$gridField = new GridField('Report',$report->title(), $report->sourceRecords(array(), null, null), $gridFieldConfig);
  165
+			$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
165 166
 			$displayFields = array();
166 167
 			$fieldCasting = array();
167 168
 			$fieldFormatting = array();
@@ -181,9 +182,9 @@ public function getEditForm($id = null, $fields = null) {
181 182
 
182 183
 				$displayFields[$source] = isset($info['title']) ? $info['title'] : $source;
183 184
 			}
184  
-			$gridField->setDisplayFields($displayFields);
185  
-			$gridField->setFieldCasting($fieldCasting);
186  
-			$gridField->setFieldFormatting($fieldFormatting);
  185
+			$columns->setDisplayFields($displayFields);
  186
+			$columns->setFieldCasting($fieldCasting);
  187
+			$columns->setFieldFormatting($fieldFormatting);
187 188
 
188 189
 			$fields->push($gridField);
189 190
 		} else {
@@ -195,10 +196,11 @@ public function getEditForm($id = null, $fields = null) {
195 196
 				new GridFieldFooter()
196 197
 			);
197 198
 			$gridField = new GridField('Reports','Reports', $this->Reports(), $gridFieldConfig);
198  
-			$gridField->setDisplayFields(array(
  199
+			$columns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
  200
+			$columns->setDisplayFields(array(
199 201
 				'title' => 'Title',
200 202
 			));
201  
-			$gridField->setFieldFormatting(array(
  203
+			$columns->setFieldFormatting(array(
202 204
 				'title' => '<a href=\"$Link\" class=\"cms-panel-link\">$value</a>'
203 205
 			));
204 206
 			$gridField->addExtraClass('all-reports-gridfield');

0 notes on commit 7850499

Please sign in to comment.
Something went wrong with that request. Please try again.