Reverted r66440 - this was causing too many bugs

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2@66769 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2008-11-26 21:25:49 +00:00 committed by Sam Minnee
parent 407604eb1b
commit d2130a44f3

View File

@ -182,6 +182,45 @@ JS;
return $this->renderWith($this->template); return $this->renderWith($this->template);
} }
/**
* Returns non-paginated items.
* Please use Items() for pagination.
* This function is called whenever a complete result-set is needed,
* so even if a single record is displayed in a popup, we need the results
* to make pagination work.
*
* @todo Merge with more efficient querying of TableListField
*/
function sourceItems() {
if($this->sourceItems) {
return $this->sourceItems;
}
$limitClause = "";
if($this->pageSize) {
$limitClause = "{$this->pageSize}";
} else {
$limitClause = "0";
}
if(isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) {
$SQL_start = intval($_REQUEST['ctf'][$this->Name()]['start']);
$limitClause .= " OFFSET {$SQL_start}";
}
$sort = $this->sourceSort;
if(isset($_REQUEST['ctf'][$this->Name()]['sort'])) {
$sort = Convert::raw2sql($_REQUEST['ctf'][$this->Name()]['sort']);
}
$this->sourceItems = DataObject::get($this->sourceClass, $this->sourceFilter, $sort, $this->sourceJoin, $limitClause);
$this->unpagedSourceItems = DataObject::get($this->sourceClass, $this->sourceFilter, $sort, $this->sourceJoin);
$this->totalCount = ($this->unpagedSourceItems) ? $this->unpagedSourceItems->TotalItems() : null;
return $this->sourceItems;
}
/** /**
* @return DataObjectSet * @return DataObjectSet
*/ */