materio_search_api.admin.inc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. function materio_search_api_settings(){
  3. $indexes = search_api_index_load_multiple(false);
  4. // dsm($indexes, '$indexes');
  5. foreach ($indexes as $machine_name => $index) {
  6. if($index->status == 1)
  7. $index_options[$index->machine_name] = $index->name;
  8. }
  9. $languages = locale_language_list();
  10. // dsm($languages, 'languages');
  11. foreach ($languages as $lcode => $name) {
  12. $form['mainsearchindex_'.$lcode] = array(
  13. '#type'=>'select',
  14. '#options'=>$index_options,
  15. '#default_value' => variable_get('mainsearchindex_'.$lcode, -1),
  16. '#title' => t('Main search api index for %lang contents.', array('%lang'=>$name)),
  17. );
  18. $form['brevessearchindex_'.$lcode] = array(
  19. '#type'=>'select',
  20. '#options'=>$index_options,
  21. '#default_value' => variable_get('brevessearchindex_'.$lcode, -1),
  22. '#title' => t('Breves search api index for %lang contents.', array('%lang'=>$name)),
  23. );
  24. $form['autocompletesearchindex_'.$lcode] = array(
  25. '#type'=>'select',
  26. '#options'=>$index_options,
  27. '#default_value' => variable_get('autocompletesearchindex_'.$lcode, -1),
  28. '#title' => t('Autocomplete search api index for %lang contents.', array('%lang'=>$name)),
  29. );
  30. }
  31. // TODO: select the activated viewmodes for change view mode and selected view mode
  32. $entity_infos = entity_get_info();
  33. // dsm($entity_infos, 'entity_infos');
  34. foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
  35. $viewmode_options[$viewmode] = $value['label'];
  36. }
  37. $form['availableviewmodes'] = array(
  38. '#type'=>'select',
  39. '#options'=>$viewmode_options,
  40. '#default_value' => variable_get('availableviewmodes', array()),
  41. '#title' => t('Availble View modes'),
  42. '#multiple' => true,
  43. );
  44. $form['defaultviewmode'] = array(
  45. '#type'=>'select',
  46. '#options'=>$viewmode_options,
  47. '#default_value' => variable_get('defaultviewmode', 'full'),
  48. '#title' => t('Defalut View mode'),
  49. );
  50. foreach (variable_get('availableviewmodes', array()) as $viewmode => $value) {
  51. $form[$viewmode.'_limite'] = array(
  52. '#type'=>'textfield',
  53. '#size'=>5,
  54. '#default_value' => variable_get($viewmode.'_limite', '10'),
  55. '#title' => t('@vm limite', array('@vm'=>$viewmode)),
  56. );
  57. }
  58. return system_settings_form($form);
  59. }