name.inc 706 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * @file
  4. * Plugin definition for duplicate suggestion based on names.
  5. */
  6. $plugin = array(
  7. 'title' => t('Terms names are the same'),
  8. 'description' => t('Mark terms as duplicates if they have the same name.'),
  9. 'hash callback' => 'term_merge_duplicate_suggestion_name_hash',
  10. 'weight' => -10,
  11. );
  12. /**
  13. * Hash term based on its name.
  14. */
  15. function term_merge_duplicate_suggestion_name_hash($term) {
  16. // Making upper case.
  17. $name = drupal_strtoupper($term->name);
  18. // Trying transliteration, if available.
  19. if (module_exists('transliteration')) {
  20. $name = transliteration_get($name);
  21. // Keeping only ASCII chars.
  22. $name = preg_replace('#\W#', '', $name);
  23. }
  24. return $name;
  25. }