getSummaryFields() will also get those summary fields defined in Member's decorator applied to the results and export

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@61509 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Normann Lou 2008-08-26 01:45:52 +00:00
parent 413b309d17
commit 6a897d7bfa
4 changed files with 23 additions and 14 deletions

View File

@ -2466,8 +2466,9 @@ class DataObject extends ViewableData implements DataObjectInterface {
if ($this->hasField('Name')) $fields['Name'] = 'Name'; if ($this->hasField('Name')) $fields['Name'] = 'Name';
if ($this->hasField('Title')) $fields['Title'] = 'Title'; if ($this->hasField('Title')) $fields['Title'] = 'Title';
if ($this->hasField('Description')) $fields['Description'] = 'Description'; if ($this->hasField('Description')) $fields['Description'] = 'Description';
if ($this->hasField('Firstname')) $fields['Firstname'] = 'Firstname'; if ($this->hasField('FirstName')) $fields['FirstName'] = 'First Name';
} }
$this->extend("updateSummaryFields", $fields);
// Final fail-over, just list all the fields :-S // Final fail-over, just list all the fields :-S
if(!$fields) { if(!$fields) {

View File

@ -138,7 +138,7 @@ class CheckboxSetField extends OptionsetField {
* Return the CheckboxSetField value, as an array of the selected item keys * Return the CheckboxSetField value, as an array of the selected item keys
*/ */
function dataValue() { function dataValue() {
if($this->value){ if($this->value&&is_array($this->value)){
// Filter items to those who aren't 0 // Filter items to those who aren't 0
$filtered = array(); $filtered = array();
foreach($this->value as $item) if($item) $filtered[] = str_replace(",", "{comma}", $item); foreach($this->value as $item) if($item) $filtered[] = str_replace(",", "{comma}", $item);

View File

@ -670,7 +670,7 @@ JS
/** /**
* @return array * @return array
*/ */
function getPermissions($arr) { function getPermissions() {
return $this->permissions; return $this->permissions;
} }
@ -707,8 +707,10 @@ JS
/** /**
* @param array * @param array
* @deprecated Put the query string onto your form's link instead :-)
*/ */
function setExtraLinkParams($params){ function setExtraLinkParams($params){
user_error("TableListField::setExtraLinkParams() deprecated - put the query string onto your form's FormAction instead; it will be handed down to all field with special handlers", E_USER_NOTICE);
$this->extraLinkParams = $params; $this->extraLinkParams = $params;
} }
@ -725,7 +727,7 @@ JS
if(!isset($_REQUEST['ctf'][$this->Name()]['start']) || !is_numeric($_REQUEST['ctf'][$this->Name()]['start']) || $_REQUEST['ctf'][$this->Name()]['start'] == 0) { if(!isset($_REQUEST['ctf'][$this->Name()]['start']) || !is_numeric($_REQUEST['ctf'][$this->Name()]['start']) || $_REQUEST['ctf'][$this->Name()]['start'] == 0) {
return null; return null;
} }
$link = $this->Link() . "/?ctf[{$this->Name()}][start]={$start}"; $link = Controller::join_links($this->Link(), "ajax_refresh?ctf[{$this->Name()}][start]={$start}");
if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams);
return $link; return $link;
} }
@ -739,18 +741,19 @@ JS
$start = ($_REQUEST['ctf'][$this->Name()]['start'] - $this->pageSize < 0) ? 0 : $_REQUEST['ctf'][$this->Name()]['start'] - $this->pageSize; $start = ($_REQUEST['ctf'][$this->Name()]['start'] - $this->pageSize < 0) ? 0 : $_REQUEST['ctf'][$this->Name()]['start'] - $this->pageSize;
$link = $this->Link() . "/?ctf[{$this->Name()}][start]={$start}"; $link = Controller::join_links($this->Link(), "ajax_refresh?ctf[{$this->Name()}][start]={$start}");
if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams);
return $link; return $link;
} }
function NextLink() { function NextLink() {
$currentStart = isset($_REQUEST['ctf'][$this->Name()]['start']) ? $_REQUEST['ctf'][$this->Name()]['start'] : 0; $currentStart = isset($_REQUEST['ctf'][$this->Name()]['start']) ? $_REQUEST['ctf'][$this->Name()]['start'] : 0;
$start = ($currentStart + $this->pageSize < $this->TotalCount()) ? $currentStart + $this->pageSize : $this->TotalCount() % $this->pageSize > 0; $start = ($currentStart + $this->pageSize < $this->TotalCount()) ? $currentStart + $this->pageSize : $this->TotalCount() % $this->pageSize > 0;
if($currentStart >= $start-1) { if($currentStart >= $start-1) {
return null; return null;
} }
$link = $this->Link() . "/?ctf[{$this->Name()}][start]={$start}"; $link = Controller::join_links($this->Link(), "ajax_refresh?ctf[{$this->Name()}][start]={$start}");
if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams);
return $link; return $link;
} }
@ -763,7 +766,7 @@ JS
return null; return null;
} }
$link = $this->Link() . "/?ctf[{$this->Name()}][start]={$start}"; $link = Controller::join_links($this->Link(), "ajax_refresh?ctf[{$this->Name()}][start]={$start}");
if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams); if($this->extraLinkParams) $link .= "&" . http_build_query($this->extraLinkParams);
return $link; return $link;
} }
@ -866,12 +869,10 @@ JS
* @todo Make relation-syntax available (at the moment you'll have to use custom sql) * @todo Make relation-syntax available (at the moment you'll have to use custom sql)
*/ */
function export() { function export() {
$now = Date("d-m-Y-H-i"); $now = Date("d-m-Y-H-i");
$fileName = "export-$now.csv"; $fileName = "export-$now.csv";
$separator = $this->csvSeparator; $separator = $this->csvSeparator;
$csvColumns = ($this->fieldListCsv) ? $this->fieldListCsv : $this->fieldList; $csvColumns = ($this->fieldListCsv) ? $this->fieldListCsv : $this->fieldList;
$fileData = ""; $fileData = "";
if($this->csvHasHeader) { if($this->csvHasHeader) {
@ -929,6 +930,7 @@ JS
*/ */
function ExportLink() { function ExportLink() {
$exportLink = Controller::join_links($this->Link(), 'export'); $exportLink = Controller::join_links($this->Link(), 'export');
if($this->extraLinkParams) $exportLink .= "?" . http_build_query($this->extraLinkParams); if($this->extraLinkParams) $exportLink .= "?" . http_build_query($this->extraLinkParams);
return $exportLink; return $exportLink;
} }
@ -985,8 +987,8 @@ JS
// pagination and filters are respected on template accessors // pagination and filters are respected on template accessors
//$this->sourceItems(); //$this->sourceItems();
$response = $this->renderWith($this->template); $response = $this->renderWith($this->template);echo($response);die('here');
FormResponse::update_dom_id($this->id(), $response); FormResponse::update_dom_id($this->id(), $response, 1);
FormResponse::set_non_ajax_content($response); FormResponse::set_non_ajax_content($response);
return FormResponse::respond(); return FormResponse::respond();
} }

View File

@ -66,6 +66,12 @@ class Member extends DataObject {
'Email', 'Email',
); );
static $summary_fields = array(
'FirstName',
'Surname',
'Email',
);
/** /**
* {@link PasswordValidator} object for validating user's password * {@link PasswordValidator} object for validating user's password