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
*/
function sortData($data, $recordID = null) {
$dataObjects = array();
if($data) {
$dataObjects = array();
foreach($data as $field => $rowData) {
$i = 0;
$blank = 0;
if(!is_array($rowData)) continue;
foreach($rowData as $id => $value) {
if($value == '$RecordID') $value = $recordID;
if($value){
$dataObjects[$id][$field] = $value;
}else{
$blank++;
}
$i++;
}
if(!$data) return false;
$sortedData = array();
foreach($data as $field => $rowData) {
$i = 0;
if(!is_array($rowData)) continue;
foreach($rowData as $id => $value) {
if($value == '$recordID') $value = $recordID;
// TODO ADD stuff for removing rows with incomplete data
if($value) $sortedData[$id][$field] = $value;
$i++;
}
return $dataObjects;
// TODO ADD stuff for removing rows with incomplete data
}
return $sortedData;
}
/**