public function SearchApiAlterLanguageControl::configurationForm in Search API 7
Implements SearchApiAlterCallbackInterface::configurationForm().
Overrides SearchApiAbstractAlterCallback::configurationForm
File
- includes/
callback_language_control.inc, line 39 - Contains SearchApiAlterLanguageControl.
Class
- SearchApiAlterLanguageControl
- Search API data alteration callback that filters out items based on their bundle.
Code
public function configurationForm() {
$form = array();
$wrapper = $this->index
->entityWrapper();
$fields[''] = t('- Use default -');
foreach ($wrapper as $key => $property) {
if ($key == 'search_api_language') {
continue;
}
$type = $property
->type();
// Only single-valued string properties make sense here. Also, nested
// properties probably don't make sense.
if ($type == 'text' || $type == 'token') {
$info = $property
->info();
$fields[$key] = $info['label'];
}
}
if (count($fields) > 1) {
$form['lang_field'] = array(
'#type' => 'select',
'#title' => t('Language field'),
'#description' => t("Select the field which should be used to determine an item's language."),
'#options' => $fields,
'#default_value' => $this->options['lang_field'],
);
}
$languages[LANGUAGE_NONE] = t('Language neutral');
$list = language_list('enabled') + array(
array(),
array(),
);
foreach (array(
$list[1],
$list[0],
) as $list) {
foreach ($list as $lang) {
$name = t($lang->name);
$native = $lang->native;
$languages[$lang->language] = check_plain($name == $native ? $name : "{$name} ({$native})");
if (!$lang->enabled) {
$languages[$lang->language] .= ' [' . t('disabled') . ']';
}
}
}
$form['languages'] = array(
'#type' => 'checkboxes',
'#title' => t('Indexed languages'),
'#description' => t('Index only items in the selected languages. ' . 'When no language is selected, there will be no language-related restrictions.'),
'#options' => $languages,
'#default_value' => $this->options['languages'],
);
return $form;
}