MINOR Simplified TableField->sortData() code structure (no logic changes) (merged from branches/2.3-nzct)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@82079 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-07-17 00:17:43 +00:00
parent bc07a4644e
commit 99d6f2241f

View File

@ -471,28 +471,26 @@ class TableField extends TableListField {
* @return array Collection of maps suitable to construct DataObjects * @return array Collection of maps suitable to construct DataObjects
*/ */
function sortData($data, $recordID = null) { function sortData($data, $recordID = null) {
$dataObjects = array(); if(!$data) return false;
if($data) {
$dataObjects = array(); $sortedData = array();
foreach($data as $field => $rowData) { foreach($data as $field => $rowData) {
$i = 0; $i = 0;
$blank = 0;
if(!is_array($rowData)) continue; if(!is_array($rowData)) continue;
foreach($rowData as $id => $value) {
if($value == '$RecordID') $value = $recordID;
if($value){ foreach($rowData as $id => $value) {
$dataObjects[$id][$field] = $value; if($value == '$recordID') $value = $recordID;
}else{
$blank++; if($value) $sortedData[$id][$field] = $value;
}
$i++; $i++;
} }
// TODO ADD stuff for removing rows with incomplete data // TODO ADD stuff for removing rows with incomplete data
} }
return $dataObjects;
} return $sortedData;
} }
/** /**