BUGFIX Fixed HasManyComplexTableField/ManyManyComplexTableField issue with source items which broke from changes in r66080. Thanks hamish!

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68628 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2008-12-12 09:58:05 +00:00 committed by Sam Minnee
parent e37fa6b790
commit f93b782e94

View File

@ -68,33 +68,24 @@ class HasManyComplexTableField extends ComplexTableField {
}
function sourceItems() {
if($this->sourceItems)
return $this->sourceItems;
if($this->sourceItems) return $this->sourceItems;
$limitClause = '';
if(isset($_REQUEST[ 'ctf' ][ $this->Name() ][ 'start' ]) && is_numeric($_REQUEST[ 'ctf' ][ $this->Name() ][ 'start' ]))
if(isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) {
$limitClause = $_REQUEST[ 'ctf' ][ $this->Name() ][ 'start' ] . ", $this->pageSize";
else
} else {
$limitClause = "0, $this->pageSize";
}
$dataQuery = $this->getQuery($limitClause);
$records = $dataQuery->execute();
$items = new DataObjectSet();
foreach($records as $record) {
if(! get_class($record))
$record = new DataObject($record);
$items->push($record);
}
$dataQuery = $this->getQuery();
$records = $dataQuery->execute();
$unpagedItems = new DataObjectSet();
foreach($records as $record) {
if(! get_class($record))
$record = new DataObject($record);
$unpagedItems->push($record);
}
$this->unpagedSourceItems = $unpagedItems;
$sourceClass = $this->sourceClass;
$dataobject = new $sourceClass();
$items = $dataobject->buildDataObjectSet($records, 'DataObjectSet');
$this->unpagedSourceItems = $dataobject->buildDataObjectSet($records, 'DataObjectSet');
$this->totalCount = ($this->unpagedSourceItems) ? $this->unpagedSourceItems->TotalItems() : null;