ENHANCEMENT: encapsulated getResultsTable from ResultsForm in ModelAdmin_CollectionController

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@77158 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Rainer Spittel 2009-05-19 03:25:47 +00:00
parent 80d79e63b8
commit fa69772112

View File

@ -639,12 +639,16 @@ class ModelAdmin_CollectionController extends Controller {
}
/**
* Shows results from the "search" action in a TableListField.
* Creates and returns the result table field for resultsForm.
* Uses {@link resultsTableClassName()} to initialise the formfield.
* Method is called from {@link ResultsForm}.
*
* @return Form
* @param array $searchCriteria passed through from ResultsForm
*
* @return TableListField
*/
function ResultsForm($searchCriteria) {
if($searchCriteria instanceof HTTPRequest) $searchCriteria = $searchCriteria->getVars();
function getResultsTable($searchCriteria) {
$summaryFields = $this->getResultColumns($searchCriteria);
$className = $this->parentController->resultsTableClassName();
@ -667,6 +671,22 @@ class ModelAdmin_CollectionController extends Controller {
$url = '<a href=\"' . $this->Link() . '/$ID/edit\">$value</a>';
$tf->setFieldFormatting(array_combine(array_keys($summaryFields), array_fill(0,count($summaryFields), $url)));
return $tf;
}
/**
* Shows results from the "search" action in a TableListField.
*
* @uses getResultsTable()
*
* @return Form
*/
function ResultsForm($searchCriteria) {
if($searchCriteria instanceof HTTPRequest) $searchCriteria = $searchCriteria->getVars();
$tf = $this->getResultsTable($searchCriteria);
// implemented as a form to enable further actions on the resultset
// (serverside sorting, export as CSV, etc)
$form = new Form(