function blockreference_field_settings in Block reference 6
Implementation of hook_field_settings().
File
- ./
blockreference.module, line 111 - Defines a field type for referencing a block from a node.
Code
function blockreference_field_settings($op, $field) {
switch ($op) {
case 'form':
$form = array();
$form['referenceable_regions'] = array(
'#type' => 'checkboxes',
'#title' => t('Regions containing blocks that can be referenced'),
'#multiple' => TRUE,
'#default_value' => !empty($field['referenceable_regions']) ? $field['referenceable_regions'] : array(),
'#options' => array(
'' => '(Disabled)',
) + system_region_list(variable_get('theme_default', 'garland')),
'#description' => t('If no regions are selected, blocks from all regions will be available.'),
);
$form['referenceable_modules'] = array(
'#type' => 'checkboxes',
'#title' => t('Modules defining blocks that can be referenced'),
'#multiple' => TRUE,
'#default_value' => !empty($field['referenceable_modules']) ? $field['referenceable_modules'] : array(),
'#options' => blockreference_get_block_modules(),
'#description' => t('If no modules are selected, blocks from all modules will be available.'),
);
$form['referenceable_operator'] = array(
'#type' => 'radios',
'#title' => t('Operator to use if referenceable regions and referenceable modules are selected.'),
'#default_value' => !empty($field['referenceable_operator']) ? $field['referenceable_operator'] : 'AND',
'#options' => array(
'AND' => '<strong>AND</strong> - ' . t('Block must be both contained in a referenceable region and defined by a referenceable module.'),
'OR' => '<strong>OR</strong> - ' . t('Block must be either contained in a referenceable region or defined by a referenceable module.'),
),
'#description' => t('If regions and modules are selected, choose operator to use when retrieving blocks list.'),
);
return $form;
case 'save':
$settings = array(
'referenceable_regions',
'referenceable_modules',
'referenceable_operator',
);
return $settings;
case 'database columns':
$columns = array(
'bid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
);
return $columns;
case 'views data':
$data = content_views_field_views_data($field);
$db_info = content_database_info($field);
$table_alias = content_views_tablename($field);
// Filter: swap the handler to the 'in' operator.
$data[$table_alias][$field['field_name'] . '_bid']['filter']['handler'] = 'content_handler_filter_many_to_one';
$data["node_{$table_alias}"]['table']['join']['node'] = array(
'table' => 'node',
'field' => 'vid',
'left_table' => $table_alias,
'left_field' => 'vid',
);
$data[$table_alias][$field['field_name'] . '_bid']['argument']['handler'] = 'content_handler_argument_reference';
$data[$table_alias][$field['field_name'] . '_bid']['argument']['name table'] = "node_{$table_alias}";
$data[$table_alias][$field['field_name'] . '_bid']['argument']['name field'] = 'title';
// Relationship: add a relationship for related block.
$data[$table_alias][$field['field_name'] . '_bid']['relationship'] = array(
'base' => 'blocks',
'field' => $db_info['columns']['bid']['column'],
'handler' => 'content_handler_relationship',
'label' => t($field['widget']['label']),
'content_field_name' => $field['field_name'],
);
return $data;
}
}