mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
API: Request Handler use $config + EditingTools
This commit is contained in:
parent
bed1372a45
commit
1e260d2b48
@ -75,7 +75,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
*/
|
*/
|
||||||
function getRecordImageField()
|
function getRecordImageField()
|
||||||
{
|
{
|
||||||
$fieldName = $this->component->getRecordImageField();
|
$fieldName = $this->component->getConfig('imageFieldName');
|
||||||
if ( $fieldName == null ) $fieldName = $this->getDefaultRecordImageField();
|
if ( $fieldName == null ) $fieldName = $this->getDefaultRecordImageField();
|
||||||
|
|
||||||
return $fieldName;
|
return $fieldName;
|
||||||
@ -89,7 +89,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
*/
|
*/
|
||||||
function getRecordEditableFields()
|
function getRecordEditableFields()
|
||||||
{
|
{
|
||||||
$fields = $this->component->getRecordEditableFields();
|
$fields = $this->component->getConfig('editableFields');
|
||||||
if ( $fields == null ) $fields = $this->getDefaultRecordEditableFields();
|
if ( $fields == null ) $fields = $this->getDefaultRecordEditableFields();
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
@ -122,6 +122,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
function getDefaultRecordEditableFields()
|
function getDefaultRecordEditableFields()
|
||||||
{
|
{
|
||||||
$recordClass = $this->gridField->list->dataClass;
|
$recordClass = $this->gridField->list->dataClass;
|
||||||
@ -137,6 +138,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
|
|
||||||
return $editableFields;
|
return $editableFields;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the CMS edit field for a given name. As set in the GridField managed DataObject getCMSFields method
|
* Return the CMS edit field for a given name. As set in the GridField managed DataObject getCMSFields method
|
||||||
@ -144,6 +146,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
* @param string $fieldName
|
* @param string $fieldName
|
||||||
* @return FormField
|
* @return FormField
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
function getFieldEditForm($fieldName)
|
function getFieldEditForm($fieldName)
|
||||||
{
|
{
|
||||||
if ( !$this->recordCMSFieldList ) {
|
if ( !$this->recordCMSFieldList ) {
|
||||||
@ -160,6 +163,27 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getRecordHTMLFormFields( $recordID = 0 )
|
||||||
|
{
|
||||||
|
$config = $this->component->getConfig();
|
||||||
|
$recordCMSDataFields = GridFieldBulkEditingTools::getModelCMSDataFields( $config, $this->gridField->list->dataClass );
|
||||||
|
|
||||||
|
//@TODO: if editableFields given use them with filterNonEditableRecordsFields()
|
||||||
|
// otherwise go through getModelFilteredDataFields
|
||||||
|
|
||||||
|
|
||||||
|
$recordCMSDataFields = GridFieldBulkEditingTools::filterNonEditableRecordsFields($config, $recordCMSDataFields);
|
||||||
|
|
||||||
|
if ( $config['imageFieldName'] == null ) $config['imageFieldName'] = $this->getDefaultRecordImageField();
|
||||||
|
|
||||||
|
$recordCMSDataFields = GridFieldBulkEditingTools::getModelFilteredDataFields($config, $recordCMSDataFields);
|
||||||
|
$formFieldsHTML = GridFieldBulkEditingTools::dataFieldsToHTML($recordCMSDataFields);
|
||||||
|
$formFieldsHTML = GridFieldBulkEditingTools::escapeFormFieldsHTML($formFieldsHTML, $recordID);
|
||||||
|
|
||||||
|
return $formFieldsHTML;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default and main action that returns the upload form etc...
|
* Default and main action that returns the upload form etc...
|
||||||
@ -306,8 +330,12 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
$record->setField($this->getRecordImageField(), $file->ID);
|
$record->setField($this->getRecordImageField(), $file->ID);
|
||||||
$record->write();
|
$record->write();
|
||||||
|
|
||||||
|
//get record's CMS Fields
|
||||||
|
$recordEditableFormFields = $this->getRecordHTMLFormFields( $record->ID );
|
||||||
|
|
||||||
|
|
||||||
// collect all editable fields forms
|
// collect all editable fields forms
|
||||||
|
/*
|
||||||
$recordEditableFieldsForms = array();
|
$recordEditableFieldsForms = array();
|
||||||
foreach ( $this->getRecordEditableFields() as $editableFieldName )
|
foreach ( $this->getRecordEditableFields() as $editableFieldName )
|
||||||
{
|
{
|
||||||
@ -316,6 +344,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
array_push($recordEditableFieldsForms, $this->parseFieldHTMLWithRecordID($formField->FieldHolder(), $record->ID) );
|
array_push($recordEditableFieldsForms, $this->parseFieldHTMLWithRecordID($formField->FieldHolder(), $record->ID) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Collect all output data.
|
// Collect all output data.
|
||||||
$return = array_merge($return, array(
|
$return = array_merge($return, array(
|
||||||
@ -328,7 +357,7 @@ class GridFieldBulkImageUpload_Request extends RequestHandler {
|
|||||||
//'buttons' => $file->UploadFieldFileButtons,
|
//'buttons' => $file->UploadFieldFileButtons,
|
||||||
'record' => array(
|
'record' => array(
|
||||||
'ID' => $record->ID,
|
'ID' => $record->ID,
|
||||||
'fields' => $recordEditableFieldsForms
|
'fields' => $recordEditableFormFields
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user