linkit.api.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Implements hook_linkit_plugin_entities_alter().
  4. *
  5. * The default behavior for entities is that they will use the default entity
  6. * search plugin class, which will provide them with the basic methods they
  7. * need.
  8. *
  9. * Tho there can be some search plugins that will extend those basic method with
  10. * more advanced once, therefore the handlers for those plugins will have to be
  11. * changed.
  12. *
  13. * Make sure that your classes is included in the regisrty.
  14. * The easiest way to do this is by define them as
  15. *
  16. * <code> files[] = plugins/linkit_search/my_custom_plugin.class.php </code>
  17. *
  18. * @param $plugins
  19. * An array of all search plugins processed within Linkit entity plugin.
  20. */
  21. function hook_linkit_search_plugin_entities_alter(&$plugins) {
  22. $path = drupal_get_path('module', 'mymodule') . '/plugins/linkit_search';
  23. if (isset($plugins['my_custom_plugin'])) {
  24. $handler = array(
  25. 'class' => 'MyCustomPlugin',
  26. 'file' => 'my_custom_plugin.class.php',
  27. 'path' => $path,
  28. );
  29. $plugins['my_custom_plugin']['handler'] = $handler;
  30. }
  31. }
  32. /**
  33. * Implements hook_linkit_local_hosts_alter().
  34. *
  35. * The default behavior is that only the current host is considered "local",
  36. * when deciding how to classify a URL. For example, if the user is on
  37. * http://www.example.com, then all URLs to other hosts will not be considered
  38. * for local URLs. This means that if your users edit content on a different host
  39. * from the actual public-facing site, such as https://staging.example.com,
  40. * then if they paste in URLs from the public site (www), none of those
  41. * URLs will be considered local.
  42. *
  43. * Implementing this hook will allow you to alter the list (indexed array) of
  44. * hosts that will be considered for internal links. Include the protocol
  45. * (eg, http or https).
  46. */
  47. function hook_linkit_local_hosts_alter(&$local_hosts) {
  48. $local_hosts[] = 'http://www.example.com';
  49. }