search.inc 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * Plugin definition for synonyms search behavior.
  5. */
  6. $plugin = array(
  7. 'title' => t('Search'),
  8. 'description' => t('Integrate synonyms with Search module'),
  9. 'interface' => 'SearchSynonymsBehavior',
  10. 'enabled callback' => 'synonyms_search_behavior_search_enabled',
  11. 'disabled callback' => 'synonyms_search_behavior_search_disabled',
  12. );
  13. /**
  14. * Callback for when the behavior is enabled.
  15. *
  16. * Trigger re-indexing of all the nodes that reference terms from the vocabulary
  17. * where the change has taken place.
  18. */
  19. function synonyms_search_behavior_search_enabled($behavior_definition, $behavior_implementation) {
  20. if ($behavior_implementation['entity_type'] == 'taxonomy_term') {
  21. module_load_include('inc', 'synonyms_search', 'synonyms_search.pages');
  22. synonyms_search_reindex_nodes_by_vocabulary(taxonomy_vocabulary_machine_name_load($behavior_implementation['bundle']));
  23. }
  24. }
  25. /**
  26. * Callback for when the behavior is disabled.
  27. *
  28. * Trigger re-indexing of all the nodes that reference terms from the vocabulary
  29. * where the change has taken place.
  30. */
  31. function synonyms_search_behavior_search_disabled($behavior_definition, $behavior_implementation) {
  32. if ($behavior_implementation['entity_type'] == 'taxonomy_term') {
  33. module_load_include('inc', 'synonyms_search', 'synonyms_search.pages');
  34. synonyms_search_reindex_nodes_by_vocabulary(taxonomy_vocabulary_machine_name_load($behavior_implementation['bundle']));
  35. }
  36. }