1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Provides info about the node entity.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_entity_property_info() on top of node module.
|
10 |
|
|
*
|
11 |
|
|
* @see entity_entity_property_info()
|
12 |
|
|
*/
|
13 |
|
|
function entity_metadata_node_entity_property_info() {
|
14 |
|
|
$info = array();
|
15 |
|
|
// Add meta-data about the basic node properties.
|
16 |
|
|
$properties = &$info['node']['properties'];
|
17 |
|
|
|
18 |
|
|
$properties['nid'] = array(
|
19 |
|
|
'label' => t("Node ID"),
|
20 |
|
|
'type' => 'integer',
|
21 |
|
|
'description' => t("The unique ID of the node."),
|
22 |
|
|
'schema field' => 'nid',
|
23 |
|
|
);
|
24 |
|
|
$properties['vid'] = array(
|
25 |
|
|
'label' => t("Revision ID"),
|
26 |
|
|
'type' => 'integer',
|
27 |
|
|
'description' => t("The unique ID of the node's revision."),
|
28 |
|
|
'schema field' => 'vid',
|
29 |
|
|
);
|
30 |
|
|
$properties['is_new'] = array(
|
31 |
|
|
'label' => t("Is new"),
|
32 |
|
|
'type' => 'boolean',
|
33 |
|
|
'description' => t("Whether the node is new and not saved to the database yet."),
|
34 |
|
|
'getter callback' => 'entity_metadata_node_get_properties',
|
35 |
|
|
);
|
36 |
|
|
$properties['type'] = array(
|
37 |
|
|
'label' => t("Content type"),
|
38 |
|
|
'type' => 'token',
|
39 |
|
|
'description' => t("The type of the node."),
|
40 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
41 |
|
|
'setter permission' => 'administer nodes',
|
42 |
|
|
'options list' => 'node_type_get_names',
|
43 |
|
|
'required' => TRUE,
|
44 |
|
|
'schema field' => 'type',
|
45 |
|
|
);
|
46 |
|
|
$properties['title'] = array(
|
47 |
|
|
'label' => t("Title"),
|
48 |
|
|
'description' => t("The title of the node."),
|
49 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
50 |
|
|
'schema field' => 'title',
|
51 |
|
|
'required' => TRUE,
|
52 |
|
|
);
|
53 |
|
|
$properties['language'] = array(
|
54 |
|
|
'label' => t("Language"),
|
55 |
|
|
'type' => 'token',
|
56 |
|
|
'description' => t("The language the node is written in."),
|
57 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
58 |
|
|
'options list' => 'entity_metadata_language_list',
|
59 |
|
|
'schema field' => 'language',
|
60 |
|
|
'setter permission' => 'administer nodes',
|
61 |
|
|
);
|
62 |
|
|
$properties['url'] = array(
|
63 |
|
|
'label' => t("URL"),
|
64 |
|
|
'description' => t("The URL of the node."),
|
65 |
|
|
'getter callback' => 'entity_metadata_entity_get_properties',
|
66 |
|
|
'type' => 'uri',
|
67 |
|
|
'computed' => TRUE,
|
68 |
|
|
);
|
69 |
|
|
$properties['edit_url'] = array(
|
70 |
|
|
'label' => t("Edit URL"),
|
71 |
|
|
'description' => t("The URL of the node's edit page."),
|
72 |
|
|
'getter callback' => 'entity_metadata_node_get_properties',
|
73 |
|
|
'type' => 'uri',
|
74 |
|
|
'computed' => TRUE,
|
75 |
|
|
);
|
76 |
|
|
$properties['status'] = array(
|
77 |
|
|
'label' => t("Status"),
|
78 |
|
|
'description' => t("Whether the node is published or unpublished."),
|
79 |
|
|
// Although the status is expected to be boolean, its schema suggests
|
80 |
|
|
// it is an integer, so we follow the schema definition.
|
81 |
|
|
'type' => 'integer',
|
82 |
|
|
'options list' => 'entity_metadata_status_options_list',
|
83 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
84 |
|
|
'setter permission' => 'administer nodes',
|
85 |
|
|
'schema field' => 'status',
|
86 |
|
|
);
|
87 |
|
|
$properties['promote'] = array(
|
88 |
|
|
'label' => t("Promoted to frontpage"),
|
89 |
|
|
'description' => t("Whether the node is promoted to the frontpage."),
|
90 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
91 |
|
|
'setter permission' => 'administer nodes',
|
92 |
|
|
'schema field' => 'promote',
|
93 |
|
|
'type' => 'boolean',
|
94 |
|
|
);
|
95 |
|
|
$properties['sticky'] = array(
|
96 |
|
|
'label' => t("Sticky in lists"),
|
97 |
|
|
'description' => t("Whether the node is displayed at the top of lists in which it appears."),
|
98 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
99 |
|
|
'setter permission' => 'administer nodes',
|
100 |
|
|
'schema field' => 'sticky',
|
101 |
|
|
'type' => 'boolean',
|
102 |
|
|
);
|
103 |
|
|
$properties['created'] = array(
|
104 |
|
|
'label' => t("Date created"),
|
105 |
|
|
'type' => 'date',
|
106 |
|
|
'description' => t("The date the node was posted."),
|
107 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
108 |
|
|
'setter permission' => 'administer nodes',
|
109 |
|
|
'schema field' => 'created',
|
110 |
|
|
);
|
111 |
|
|
$properties['changed'] = array(
|
112 |
|
|
'label' => t("Date changed"),
|
113 |
|
|
'type' => 'date',
|
114 |
|
|
'schema field' => 'changed',
|
115 |
|
|
'description' => t("The date the node was most recently updated."),
|
116 |
|
|
);
|
117 |
|
|
$properties['author'] = array(
|
118 |
|
|
'label' => t("Author"),
|
119 |
|
|
'type' => 'user',
|
120 |
|
|
'description' => t("The author of the node."),
|
121 |
dd54aff9
|
Assos Assos
|
'getter callback' => 'entity_metadata_node_get_properties',
|
122 |
85ad3d82
|
Assos Assos
|
'setter callback' => 'entity_property_verbatim_set',
|
123 |
|
|
'setter permission' => 'administer nodes',
|
124 |
|
|
'required' => TRUE,
|
125 |
|
|
'schema field' => 'uid',
|
126 |
|
|
);
|
127 |
|
|
$properties['source'] = array(
|
128 |
|
|
'label' => t("Translation source node"),
|
129 |
|
|
'type' => 'node',
|
130 |
|
|
'description' => t("The original-language version of this node, if one exists."),
|
131 |
|
|
'getter callback' => 'entity_metadata_node_get_properties',
|
132 |
|
|
);
|
133 |
|
|
$properties['log'] = array(
|
134 |
|
|
'label' => t("Revision log message"),
|
135 |
|
|
'type' => 'text',
|
136 |
|
|
'description' => t("In case a new revision is to be saved, the log entry explaining the changes for this version."),
|
137 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
138 |
|
|
'access callback' => 'entity_metadata_node_revision_access',
|
139 |
|
|
);
|
140 |
|
|
$properties['revision'] = array(
|
141 |
|
|
'label' => t("Creates revision"),
|
142 |
|
|
'type' => 'boolean',
|
143 |
|
|
'description' => t("Whether saving this node creates a new revision."),
|
144 |
|
|
'setter callback' => 'entity_property_verbatim_set',
|
145 |
|
|
'access callback' => 'entity_metadata_node_revision_access',
|
146 |
|
|
);
|
147 |
|
|
return $info;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
/**
|
151 |
|
|
* Implements hook_entity_property_info_alter() on top of node module.
|
152 |
|
|
* @see entity_metadata_entity_property_info_alter()
|
153 |
|
|
*/
|
154 |
|
|
function entity_metadata_node_entity_property_info_alter(&$info) {
|
155 |
|
|
// Move the body property to the node by default, as its usually there this
|
156 |
|
|
// makes dealing with it more convenient.
|
157 |
|
|
$info['node']['properties']['body'] = array(
|
158 |
|
|
'type' => 'text_formatted',
|
159 |
|
|
'label' => t('The main body text'),
|
160 |
|
|
'getter callback' => 'entity_metadata_field_verbatim_get',
|
161 |
|
|
'setter callback' => 'entity_metadata_field_verbatim_set',
|
162 |
|
|
'property info' => entity_property_text_formatted_info(),
|
163 |
|
|
'auto creation' => 'entity_property_create_array',
|
164 |
|
|
'field' => TRUE,
|
165 |
|
|
);
|
166 |
|
|
} |