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