materio_search_api.admin.inc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. $form['advancedsearchindex_'.$lcode] = array(
  31. '#type'=>'select',
  32. '#options'=>$index_options,
  33. '#default_value' => variable_get('advancedsearchindex_'.$lcode, -1),
  34. '#title' => t('Advanced search api index for %lang contents.', array('%lang'=>$name)),
  35. );
  36. }
  37. // TODO: select the activated viewmodes for change view mode and selected view mode
  38. $entity_infos = entity_get_info();
  39. // dsm($entity_infos, 'entity_infos');
  40. foreach ($entity_infos['node']['view modes'] as $viewmode => $value) {
  41. $viewmode_options[$viewmode] = $value['label'];
  42. }
  43. $form['availableviewmodes'] = array(
  44. '#type'=>'select',
  45. '#options'=>$viewmode_options,
  46. '#default_value' => variable_get('availableviewmodes', array()),
  47. '#title' => t('Availble View modes'),
  48. '#multiple' => true,
  49. );
  50. $form['defaultviewmode'] = array(
  51. '#type'=>'select',
  52. '#options'=>$viewmode_options,
  53. '#default_value' => variable_get('defaultviewmode', 'full'),
  54. '#title' => t('Defalut View mode'),
  55. );
  56. foreach (variable_get('availableviewmodes', array()) as $viewmode => $value) {
  57. $form[$viewmode.'_limite'] = array(
  58. '#type'=>'textfield',
  59. '#size'=>5,
  60. '#default_value' => variable_get($viewmode.'_limite', '10'),
  61. '#title' => t('@vm limite', array('@vm'=>$viewmode)),
  62. );
  63. }
  64. $vocabularies = taxonomy_get_vocabularies();
  65. // dsm($vocabularies, 'vocabularies');
  66. foreach ($vocabularies as $vid => $voc){
  67. $vocs_options[$vid] = $voc->name;
  68. }
  69. $form['advancedsearchvocs'] = array(
  70. '#type'=>'select',
  71. '#options'=>$vocs_options,
  72. '#default_value' => variable_get('advancedsearchvocs', array()),
  73. '#title' => t('Advanced Search Vocabularies'),
  74. '#multiple' => true,
  75. );
  76. return system_settings_form($form);
  77. }