API: added forbidden filed classes

Some fields classes break the component. These have been added to a
forbidden list and cannot be removed from the blacklist.
This commit is contained in:
colymba 2012-08-09 20:24:33 +03:00
parent c916d6ac12
commit b8a0a1e14f

View File

@ -20,11 +20,17 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
protected $config = array(
'imageFieldName' => null,
'editableFields' => null,
'fieldsClassBlacklist' => array( 'GridField', 'UploadField' ),
'fieldsClassBlacklist' => array(),
'fieldsNameBlacklist' => array(),
'folderName' => 'bulkUpload'
);
/**
* Holds any class that should not be used as they break the component
* These cannot be removed from the blacklist
*/
protected $forbiddenFieldsClasses = array( 'GridField', 'UploadField' );
/**
*
* @param string $imageField
@ -34,6 +40,9 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
{
if ( $imageField != null ) $this->setConfig ( 'imageFieldName', $imageField );
if ( $editableFields != null ) $this->setConfig ( 'editableFields', $editableFields );
//init classes blacklist with forbidden classes
$this->config['fieldsClassBlacklist'] = $this->forbiddenFieldsClasses;
}
/**
@ -50,6 +59,13 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
{
$value = array($value);
}
//makes sure $forbiddenFieldsClasses are in no matter what
if ( $reference == 'fieldsClassBlacklist' )
{
$value = array_unique( array_merge($value, $this->forbiddenFieldsClasses) );
}
$this->config[$reference] = $value;
}
}
@ -111,7 +127,7 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
*/
function removeClassFromBlacklist ( $className )
{
if (key_exists($className, $this->config['fieldsNameBlacklist'])) {
if (key_exists($className, $this->config['fieldsNameBlacklist']) && !in_array($className, $this->forbiddenFieldsClasses)) {
return delete( $this->config['fieldsNameBlacklist'][$className] );
}else{
return false;