materio_search_api.admin.inc 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. $form['mainsearchindex'] = array(
  10. '#type'=>'select',
  11. '#options'=>$index_options,
  12. '#default_value' => variable_get('mainsearchindex', -1),
  13. '#title' => t('Main search api index'),
  14. );
  15. $form['autocompletesearchindex'] = array(
  16. '#type'=>'select',
  17. '#options'=>$index_options,
  18. '#default_value' => variable_get('autocompletesearchindex', -1),
  19. '#title' => t('Autocomplete search api index'),
  20. );
  21. // TODO: select the activated viewmodes for change view mode and selected view mode
  22. $entity_infos = entity_get_info();
  23. // dsm($entity_infos, 'entity_infos');
  24. foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
  25. $viewmode_options[$viewmode] = $value['label'];
  26. }
  27. $form['availableviewmodes'] = array(
  28. '#type'=>'select',
  29. '#options'=>$viewmode_options,
  30. '#default_value' => variable_get('availableviewmodes', array()),
  31. '#title' => t('Availble View modes'),
  32. '#multiple' => true,
  33. );
  34. $form['defaultviewmode'] = array(
  35. '#type'=>'select',
  36. '#options'=>$viewmode_options,
  37. '#default_value' => variable_get('defaultviewmode', 'full'),
  38. '#title' => t('Defalut View mode'),
  39. );
  40. foreach (variable_get('availableviewmodes', array()) as $viewmode => $value) {
  41. $form[$viewmode.'_limite'] = array(
  42. '#type'=>'textfield',
  43. '#size'=>5,
  44. '#default_value' => variable_get($viewmode.'_limite', '10'),
  45. '#title' => t('@vm limite', array('@vm'=>$viewmode)),
  46. );
  47. }
  48. return system_settings_form($form);
  49. }