Issue #1556192 by fago, chx: fixed compatibility with drupal 7.14 by adapting the...
[project/entity.git] / modules / node.info.inc
1 <?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 'setter callback' => 'entity_property_verbatim_set',
122 'setter permission' => 'administer nodes',
123 'required' => TRUE,
124 'schema field' => 'uid',
125 );
126 $properties['source'] = array(
127 'label' => t("Translation source node"),
128 'type' => 'node',
129 'description' => t("The original-language version of this node, if one exists."),
130 'getter callback' => 'entity_metadata_node_get_properties',
131 );
132 $properties['log'] = array(
133 'label' => t("Revision log message"),
134 'type' => 'text',
135 'description' => t("In case a new revision is to be saved, the log entry explaining the changes for this version."),
136 'setter callback' => 'entity_property_verbatim_set',
137 'access callback' => 'entity_metadata_node_revision_access',
138 );
139 $properties['revision'] = array(
140 'label' => t("Creates revision"),
141 'type' => 'boolean',
142 'description' => t("Whether saving this node creates a new revision."),
143 'setter callback' => 'entity_property_verbatim_set',
144 'access callback' => 'entity_metadata_node_revision_access',
145 );
146 return $info;
147 }
148
149 /**
150 * Implements hook_entity_property_info_alter() on top of node module.
151 * @see entity_metadata_entity_property_info_alter()
152 */
153 function entity_metadata_node_entity_property_info_alter(&$info) {
154 // Move the body property to the node by default, as its usually there this
155 // makes dealing with it more convenient.
156 $info['node']['properties']['body'] = array(
157 'type' => 'text_formatted',
158 'label' => t('The main body text'),
159 'getter callback' => 'entity_metadata_field_verbatim_get',
160 'setter callback' => 'entity_metadata_field_verbatim_set',
161 'property info' => entity_property_text_formatted_info(),
162 'auto creation' => 'entity_property_create_array',
163 'field' => TRUE,
164 );
165 }