node_export.tokens.inc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @file
  4. * The Node export tokens file.
  5. *
  6. * Token group file.
  7. */
  8. /**
  9. * Implements hook_tokens().
  10. */
  11. function node_export_tokens($type, $tokens, $data = array(), $options = array()) {
  12. $replacements = array();
  13. if ($type == 'node_export_filename' && !empty($data['node_export_filename'])) {
  14. $object = (array)$data['node_export_filename'];
  15. foreach ($tokens as $name => $original) {
  16. switch ($name) {
  17. // Simple key values on the node.
  18. case 'nid-list':
  19. $replacements[$original] = $object['nid-list'];
  20. break;
  21. case 'node-count':
  22. $replacements[$original] = $object['node-count'];
  23. break;
  24. case 'timestamp':
  25. $replacements[$original] = $object['timestamp'];
  26. break;
  27. case 'format':
  28. $replacements[$original] = $object['format'];
  29. break;
  30. }
  31. }
  32. }
  33. return $replacements;
  34. }
  35. /**
  36. * Implements hook_token_info().
  37. */
  38. function node_export_token_info() {
  39. return array(
  40. 'types' => array(
  41. 'node_export_filename' => array(
  42. 'name' => t('Node export filename'),
  43. 'description' => t('Tokens related to the Node export filename.'),
  44. 'needs-data' => 'node_export_filename',
  45. ),
  46. ),
  47. 'tokens' => array(
  48. 'node_export_filename' => array(
  49. 'nid-list' => array(
  50. 'name' => t("Node ID list"),
  51. 'description' => t("Comma seperated list of Node IDs in square brackets (if available)."),
  52. ),
  53. 'node-count' => array(
  54. 'name' => t("Node count"),
  55. 'description' => t("The number of nodes exported."),
  56. ),
  57. 'timestamp' => array(
  58. 'name' => t("Timestamp"),
  59. 'description' => t("The timestamp when the file was generated."),
  60. ),
  61. 'format' => array(
  62. 'name' => t("Format"),
  63. 'description' => t("The format used to export."),
  64. ),
  65. ),
  66. ),
  67. );
  68. }