mirror of
https://github.com/colymba/GridFieldBulkEditingTools.git
synced 2024-10-22 11:05:57 +02:00
API: Added config vars to component
Switching all component settings to a config variable with getter and setter
This commit is contained in:
parent
86e2773663
commit
bdb3ce7c5e
@ -18,6 +18,18 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
||||
*/
|
||||
protected $recordEditableFields;
|
||||
|
||||
/**
|
||||
* component configuration
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $config = array(
|
||||
'imageFieldName' => null,
|
||||
'editableFields' => null,
|
||||
'fieldsClassBlacklist' => array( 'GridField', 'UploadField' ),
|
||||
'fieldsNameBlacklist' => array()
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $imageField
|
||||
@ -31,6 +43,82 @@ class GridFieldBulkImageUpload implements GridField_HTMLProvider, GridField_URLH
|
||||
$this->setRecordEditableFields($editableFields);
|
||||
}
|
||||
|
||||
function setConfig ( $reference, $value )
|
||||
{
|
||||
if ( isset( $this->config[$reference] ) )
|
||||
{
|
||||
if ( ($reference == 'fieldsClassBlacklist' || $reference == 'fieldsClassBlacklist') && !is_array($value) )
|
||||
{
|
||||
$value = array($value);
|
||||
}
|
||||
$this->$config[$reference] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns one $config parameter of the full $config
|
||||
*
|
||||
* @param string $reference $congif parameter to return
|
||||
* @return mixed
|
||||
*/
|
||||
function getConfig ( $reference = false )
|
||||
{
|
||||
if ( $reference ) return $this->config[$reference];
|
||||
else return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a field to the editable fields blacklist
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return boolean
|
||||
*/
|
||||
function addFieldNameToBlacklist ( $fieldName )
|
||||
{
|
||||
return array_push( $this->config['fieldsNameBlacklist'], $fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a class to the editable fields blacklist
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean
|
||||
*/
|
||||
function addClassToBlacklist ( $className )
|
||||
{
|
||||
return array_push( $this->config['fieldsClassBlacklist'], $className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a field to the editable fields blacklist
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return boolean
|
||||
*/
|
||||
function removeFieldNameFromBlacklist ( $fieldName )
|
||||
{
|
||||
if (key_exists($fieldName, $this->config['fieldsNameBlacklist'])) {
|
||||
return delete( $this->config['fieldsNameBlacklist'][$fieldName] );
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a class to the editable fields blacklist
|
||||
*
|
||||
* @param string $className
|
||||
* @return boolean
|
||||
*/
|
||||
function removeClassFromBlacklist ( $className )
|
||||
{
|
||||
if (key_exists($className, $this->config['fieldsNameBlacklist'])) {
|
||||
return delete( $this->config['fieldsNameBlacklist'][$className] );
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $field
|
||||
|
Loading…
Reference in New Issue
Block a user