taxonomy.info.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * @file
  4. * Provides info about the taxonomy entity.
  5. */
  6. /**
  7. * Implements hook_entity_property_info() on top of taxonomy module.
  8. *
  9. * @see entity_entity_property_info()
  10. */
  11. function entity_metadata_taxonomy_entity_property_info() {
  12. $info = array();
  13. // Add meta-data about the basic taxonomy properties.
  14. $properties = &$info['taxonomy_term']['properties'];
  15. $properties['tid'] = array(
  16. 'label' => t("Term ID"),
  17. 'description' => t("The unique ID of the taxonomy term."),
  18. 'type' => 'integer',
  19. 'schema field' => 'tid',
  20. );
  21. $properties['name'] = array(
  22. 'label' => t("Name"),
  23. 'description' => t("The name of the taxonomy term."),
  24. 'setter callback' => 'entity_property_verbatim_set',
  25. 'required' => TRUE,
  26. 'schema field' => 'name',
  27. );
  28. $properties['description'] = array(
  29. 'label' => t("Description"),
  30. 'description' => t("The optional description of the taxonomy term."),
  31. 'sanitized' => TRUE,
  32. 'raw getter callback' => 'entity_property_verbatim_get',
  33. 'getter callback' => 'entity_metadata_taxonomy_term_get_properties',
  34. 'setter callback' => 'entity_property_verbatim_set',
  35. 'schema field' => 'description',
  36. );
  37. $properties['weight'] = array(
  38. 'label' => t("Weight"),
  39. 'type' => 'integer',
  40. 'description' => t('The weight of the term, which is used for ordering terms during display.'),
  41. 'setter callback' => 'entity_property_verbatim_set',
  42. 'schema field' => 'weight',
  43. );
  44. $properties['node_count'] = array(
  45. 'label' => t("Node count"),
  46. 'type' => 'integer',
  47. 'description' => t("The number of nodes tagged with the taxonomy term."),
  48. 'getter callback' => 'entity_metadata_taxonomy_term_get_properties',
  49. 'computed' => TRUE,
  50. );
  51. $properties['url'] = array(
  52. 'label' => t("URL"),
  53. 'description' => t("The URL of the taxonomy term."),
  54. 'getter callback' => 'entity_metadata_entity_get_properties',
  55. 'type' => 'uri',
  56. 'computed' => TRUE,
  57. );
  58. $properties['vocabulary'] = array(
  59. 'label' => t("Vocabulary"),
  60. 'description' => t("The vocabulary the taxonomy term belongs to."),
  61. 'setter callback' => 'entity_metadata_taxonomy_term_setter',
  62. 'type' => 'taxonomy_vocabulary',
  63. 'required' => TRUE,
  64. 'schema field' => 'vid',
  65. );
  66. $properties['parent'] = array(
  67. 'label' => t("Parent terms"),
  68. 'description' => t("The parent terms of the taxonomy term."),
  69. 'getter callback' => 'entity_metadata_taxonomy_term_get_properties',
  70. 'setter callback' => 'entity_metadata_taxonomy_term_setter',
  71. 'type' => 'list<taxonomy_term>',
  72. );
  73. $properties['parents_all'] = array(
  74. 'label' => t("All parent terms"),
  75. 'description' => t("Ancestors of the term, i.e. parent of all above hierarchy levels."),
  76. 'getter callback' => 'entity_metadata_taxonomy_term_get_properties',
  77. 'type' => 'list<taxonomy_term>',
  78. 'computed' => TRUE,
  79. );
  80. // Add meta-data about the basic vocabulary properties.
  81. $properties = &$info['taxonomy_vocabulary']['properties'];
  82. // Taxonomy vocabulary related variables.
  83. $properties['vid'] = array(
  84. 'label' => t("Vocabulary ID"),
  85. 'description' => t("The unique ID of the taxonomy vocabulary."),
  86. 'type' => 'integer',
  87. 'schema field' => 'vid',
  88. );
  89. $properties['name'] = array(
  90. 'label' => t("Name"),
  91. 'description' => t("The name of the taxonomy vocabulary."),
  92. 'setter callback' => 'entity_property_verbatim_set',
  93. 'required' => TRUE,
  94. 'schema field' => 'name',
  95. );
  96. $properties['machine_name'] = array(
  97. 'label' => t("Machine name"),
  98. 'type' => 'token',
  99. 'description' => t("The machine name of the taxonomy vocabulary."),
  100. 'setter callback' => 'entity_property_verbatim_set',
  101. 'required' => TRUE,
  102. 'schema field' => 'machine_name',
  103. );
  104. $properties['description'] = array(
  105. 'label' => t("Description"),
  106. 'description' => t("The optional description of the taxonomy vocabulary."),
  107. 'setter callback' => 'entity_property_verbatim_set',
  108. 'sanitize' => 'filter_xss',
  109. 'schema field' => 'description',
  110. );
  111. $properties['term_count'] = array(
  112. 'label' => t("Term count"),
  113. 'type' => 'integer',
  114. 'description' => t("The number of terms belonging to the taxonomy vocabulary."),
  115. 'getter callback' => 'entity_metadata_taxonomy_vocabulary_get_properties',
  116. 'computed' => TRUE,
  117. );
  118. return $info;
  119. }