public function SearchApiAttachmentsAlterSettings::configurationForm in Search API attachments 7
Adds configuration form.
Return value
array The configuration form.
Overrides SearchApiAbstractAlterCallback::configurationForm
File
- includes/
callback_attachments_settings.inc, line 135 - Search API data alteration callback.
Class
- SearchApiAttachmentsAlterSettings
- Indexes files content.
Code
public function configurationForm() {
$default = implode(' ', search_api_attachments_default_excluded());
$form['excluded_extensions'] = array(
'#type' => 'textfield',
'#title' => t('Excluded file extensions'),
'#default_value' => isset($this->options['excluded_extensions']) ? $this->options['excluded_extensions'] : $default,
'#size' => 80,
'#maxlength' => 255,
'#description' => t('File extensions that are excluded from indexing. Separate extensions with a space and do not include the leading dot. Extensions are internally mapped to a MIME type, so it is not necessary to put variations that map to the same type (e.g. tif is sufficient for tif and tiff)'),
);
$form['number_indexed'] = array(
'#type' => 'textfield',
'#title' => t('Number of file indexed per file field'),
'#default_value' => isset($this->options['number_indexed']) ? $this->options['number_indexed'] : '0',
'#size' => 5,
'#description' => t('The number of files to index per file field. The order of indexation is the weight in the widget. 0 for no restriction.'),
);
$form['max_file_size'] = array(
'#type' => 'textfield',
'#title' => t('Maximum file size'),
'#default_value' => isset($this->options['max_file_size']) ? $this->options['max_file_size'] : '0',
'#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the max file size of files that should be indexed.'),
'#size' => 80,
'#maxlength' => 255,
'#element_validate' => array(
'_file_generic_settings_max_filesize',
),
);
$form['excluded_private'] = array(
'#type' => 'checkbox',
'#title' => t('Exclude private files'),
'#default_value' => isset($this->options['excluded_private']) ? $this->options['excluded_private'] : TRUE,
'#description' => t('Check this box if you want to exclude private files to be indexed.'),
);
// Add setting specific for the file entity.
if (module_exists('file_entity')) {
// Build the select options.
$bundle_options = array();
foreach (field_info_bundles('file') as $bundle => $info) {
$bundle_options[$bundle] = $info['label'];
}
if ($bundle_options) {
$form['excluded_file_entity_bundles'] = array(
'#type' => 'select',
'#title' => t('Exclude file entity bundles'),
'#options' => $bundle_options,
'#multiple' => TRUE,
'#default_value' => isset($this->options['excluded_file_entity_bundles']) ? $this->options['excluded_file_entity_bundles'] : array(),
'#description' => t('File entity bundles that are excluded from indexing.'),
);
}
}
return $form;
}