materio-base-legacy/materio_search_api.admin.inc
2014-08-27 15:27:15 +02:00

93 lines
2.8 KiB
PHP
Executable File

<?php
function materio_search_api_settings(){
$indexes = search_api_index_load_multiple(false);
// dsm($indexes, '$indexes');
foreach ($indexes as $machine_name => $index) {
if($index->status == 1)
$index_options[$index->machine_name] = $index->name;
}
$languages = locale_language_list();
// dsm($languages, 'languages');
foreach ($languages as $lcode => $name) {
$form['mainsearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('mainsearchindex_'.$lcode, -1),
'#title' => t('Main search api index for %lang contents.', array('%lang'=>$name)),
);
$form['brevessearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('brevessearchindex_'.$lcode, -1),
'#title' => t('Breves search api index for %lang contents.', array('%lang'=>$name)),
);
$form['autocompletesearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('autocompletesearchindex_'.$lcode, -1),
'#title' => t('Autocomplete search api index for %lang contents.', array('%lang'=>$name)),
);
$form['advancedsearchindex_'.$lcode] = array(
'#type'=>'select',
'#options'=>$index_options,
'#default_value' => variable_get('advancedsearchindex_'.$lcode, -1),
'#title' => t('Advanced search api index for %lang contents.', array('%lang'=>$name)),
);
}
// TODO: select the activated viewmodes for change view mode and selected view mode
$entity_infos = entity_get_info();
// dsm($entity_infos, 'entity_infos');
foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
$viewmode_options[$viewmode] = $value['label'];
}
$form['availableviewmodes'] = array(
'#type'=>'select',
'#options'=>$viewmode_options,
'#default_value' => variable_get('availableviewmodes', array()),
'#title' => t('Availble View modes'),
'#multiple' => true,
);
$form['defaultviewmode'] = array(
'#type'=>'select',
'#options'=>$viewmode_options,
'#default_value' => variable_get('defaultviewmode', 'full'),
'#title' => t('Defalut View mode'),
);
foreach (variable_get('availableviewmodes', array()) as $viewmode => $value) {
$form[$viewmode.'_limite'] = array(
'#type'=>'textfield',
'#size'=>5,
'#default_value' => variable_get($viewmode.'_limite', '10'),
'#title' => t('@vm limite', array('@vm'=>$viewmode)),
);
}
$vocabularies = taxonomy_get_vocabularies();
// dsm($vocabularies, 'vocabularies');
foreach ($vocabularies as $vid => $voc){
$vocs_options[$vid] = $voc->name;
}
$form['advancedsearchvocs'] = array(
'#type'=>'select',
'#options'=>$vocs_options,
'#default_value' => variable_get('advancedsearchvocs', array()),
'#title' => t('Advanced Search Vocabularies'),
'#multiple' => true,
);
return system_settings_form($form);
}