token.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @file
  4. * Token module integration.
  5. */
  6. /**
  7. * Implements hook_custom_formatters_form_ctools_export_ui_edit_item_form_alter_alter()
  8. * on behalf of token.module.
  9. */
  10. function token_custom_formatters_form_ctools_export_ui_edit_item_form_alter_alter(&$form, $form_state) {
  11. if (isset($form['#formatters']) && $form['#formatters'] && 'token' == $form['info']['mode']['#default_value']) {
  12. // Add token tree.
  13. $fieldable = array();
  14. $entity_types = entity_get_info();
  15. foreach ($entity_types as $entity_type => $entity) {
  16. if ($entity['fieldable']) {
  17. $fieldable[] = $entity['token type'];
  18. }
  19. }
  20. $token_types = $fieldable;
  21. $field_type = $form['engine']['field_types']['#default_value'];
  22. drupal_alter('custom_formatters_token_tree_types', $token_types, $field_type);
  23. $form['engine']['tokens'] = array(
  24. '#title' => t('Tokens'),
  25. '#type' => 'fieldset',
  26. '#description' => theme('token_tree', array('token_types' => $token_types)),
  27. '#weight' => 50,
  28. '#collapsible' => TRUE,
  29. '#collapsed' => TRUE,
  30. );
  31. }
  32. }
  33. /**
  34. * Implements hook_custom_formatters_form_builder_types_alter() on behalf of
  35. * token.module.
  36. */
  37. function token_custom_formatters_form_builder_types_alter(&$fields) {
  38. $fields['token_tree'] = array(
  39. 'title' => t('Token tree'),
  40. 'properties' => array(
  41. 'title',
  42. 'key'
  43. ),
  44. 'default' => array(
  45. '#title' => t('Tokens'),
  46. '#type' => 'fieldset',
  47. '#collapsible' => TRUE,
  48. '#collapsed' => TRUE,
  49. '#theme' => 'token_tree',
  50. '#token_types' => 'all',
  51. ),
  52. );
  53. }