1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Provides info about system-wide entities.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Implements hook_entity_property_info() on top of system module.
|
10
|
*
|
11
|
* @see entity_entity_property_info()
|
12
|
* @see entity_metadata_site_wrapper()
|
13
|
*/
|
14
|
function entity_metadata_system_entity_property_info() {
|
15
|
$info = array();
|
16
|
|
17
|
// There is no site entity, but still add metadata for global site properties
|
18
|
// here. That way modules can alter and add further properties at this place.
|
19
|
// In order to make use of this metadata modules may use the wrapper returned
|
20
|
// by entity_metadata_site_wrapper().
|
21
|
$properties = &$info['site']['properties'];
|
22
|
$properties['name'] = array(
|
23
|
'label' => t("Name"),
|
24
|
'description' => t("The name of the site."),
|
25
|
'getter callback' => 'entity_metadata_system_get_properties',
|
26
|
'sanitize' => 'check_plain',
|
27
|
);
|
28
|
$properties['slogan'] = array(
|
29
|
'label' => t("Slogan"),
|
30
|
'description' => t("The slogan of the site."),
|
31
|
'getter callback' => 'entity_metadata_system_get_properties',
|
32
|
'sanitize' => 'check_plain',
|
33
|
);
|
34
|
$properties['mail'] = array(
|
35
|
'label' => t("Email"),
|
36
|
'description' => t("The administrative email address for the site."),
|
37
|
'getter callback' => 'entity_metadata_system_get_properties',
|
38
|
);
|
39
|
$properties['url'] = array(
|
40
|
'label' => t("URL"),
|
41
|
'description' => t("The URL of the site's front page."),
|
42
|
'getter callback' => 'entity_metadata_system_get_properties',
|
43
|
'type' => 'uri',
|
44
|
);
|
45
|
$properties['login_url'] = array(
|
46
|
'label' => t("Login page"),
|
47
|
'description' => t("The URL of the site's login page."),
|
48
|
'getter callback' => 'entity_metadata_system_get_properties',
|
49
|
'type' => 'uri',
|
50
|
);
|
51
|
$properties['current_user'] = array(
|
52
|
'label' => t("Logged in user"),
|
53
|
'description' => t("The currently logged in user."),
|
54
|
'getter callback' => 'entity_metadata_system_get_properties',
|
55
|
'type' => 'user',
|
56
|
);
|
57
|
$properties['current_date'] = array(
|
58
|
'label' => t("Current date"),
|
59
|
'description' => t("The current date and time."),
|
60
|
'getter callback' => 'entity_metadata_system_get_properties',
|
61
|
'type' => 'date',
|
62
|
);
|
63
|
$properties['current_page'] = array(
|
64
|
'label' => t("Current page"),
|
65
|
'description' => t("Information related to the current page request."),
|
66
|
'getter callback' => 'entity_metadata_system_get_properties',
|
67
|
'type' => 'struct',
|
68
|
'property info' => array(
|
69
|
'path' => array(
|
70
|
'label' => t("Path"),
|
71
|
'description' => t("The internal Drupal path of the current page request."),
|
72
|
'getter callback' => 'current_path',
|
73
|
'type' => 'text',
|
74
|
),
|
75
|
'url' => array(
|
76
|
'label' => t("URL"),
|
77
|
'description' => t("The full URL of the current page request."),
|
78
|
'getter callback' => 'entity_metadata_system_get_page_properties',
|
79
|
'type' => 'uri',
|
80
|
),
|
81
|
),
|
82
|
);
|
83
|
|
84
|
// Files.
|
85
|
$properties = &$info['file']['properties'];
|
86
|
$properties['fid'] = array(
|
87
|
'label' => t("File ID"),
|
88
|
'description' => t("The unique ID of the uploaded file."),
|
89
|
'type' => 'integer',
|
90
|
'validation callback' => 'entity_metadata_validate_integer_positive',
|
91
|
'schema field' => 'fid',
|
92
|
);
|
93
|
$properties['name'] = array(
|
94
|
'label' => t("File name"),
|
95
|
'description' => t("The name of the file on disk."),
|
96
|
'getter callback' => 'entity_metadata_system_get_file_properties',
|
97
|
'schema field' => 'filename',
|
98
|
);
|
99
|
$properties['mime'] = array(
|
100
|
'label' => t("MIME type"),
|
101
|
'description' => t("The MIME type of the file."),
|
102
|
'getter callback' => 'entity_metadata_system_get_file_properties',
|
103
|
'sanitize' => 'filter_xss',
|
104
|
'schema field' => 'filemime',
|
105
|
);
|
106
|
$properties['size'] = array(
|
107
|
'label' => t("File size"),
|
108
|
'description' => t("The size of the file, in kilobytes."),
|
109
|
'getter callback' => 'entity_metadata_system_get_file_properties',
|
110
|
'type' => 'integer',
|
111
|
'schema field' => 'filesize',
|
112
|
);
|
113
|
$properties['url'] = array(
|
114
|
'label' => t("URL"),
|
115
|
'description' => t("The web-accessible URL for the file."),
|
116
|
'getter callback' => 'entity_metadata_system_get_file_properties',
|
117
|
);
|
118
|
$properties['timestamp'] = array(
|
119
|
'label' => t("Timestamp"),
|
120
|
'description' => t("The date the file was most recently changed."),
|
121
|
'type' => 'date',
|
122
|
'schema field' => 'timestamp',
|
123
|
);
|
124
|
$properties['owner'] = array(
|
125
|
'label' => t("Owner"),
|
126
|
'description' => t("The user who originally uploaded the file."),
|
127
|
'type' => 'user',
|
128
|
'getter callback' => 'entity_metadata_system_get_file_properties',
|
129
|
'schema field' => 'uid',
|
130
|
);
|
131
|
return $info;
|
132
|
}
|