materio_search_api.admin.inc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. $vocabularies = taxonomy_get_vocabularies();
  59. // dsm($vocabularies, 'vocabularies');
  60. foreach ($vocabularies as $vid => $voc){
  61. $vocs_options[$vid] = $voc->name;
  62. }
  63. $form['advancedsearchvocs'] = array(
  64. '#type'=>'select',
  65. '#options'=>$vocs_options,
  66. '#default_value' => variable_get('advancedsearchvocs', array()),
  67. '#title' => t('Advanced Search Vocabularies'),
  68. '#multiple' => true,
  69. );
  70. return system_settings_form($form);
  71. }