1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Display Suite fields.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_ds_fields_info().
|
10 |
|
|
*/
|
11 |
|
|
function ds_ds_fields_info($entity_type) {
|
12 |
|
|
|
13 |
|
|
/* --------------------------------------------------------------
|
14 |
|
|
Custom fields.
|
15 |
|
|
-------------------------------------------------------------- */
|
16 |
|
|
|
17 |
|
|
ctools_include('export');
|
18 |
|
|
$custom_fields = ctools_export_crud_load_all('ds_fields');
|
19 |
|
|
foreach ($custom_fields as $key => $field) {
|
20 |
|
|
if (isset($field->entities[$entity_type])) {
|
21 |
|
|
$fields[$entity_type][$key] = array(
|
22 |
|
|
'title' => $field->label,
|
23 |
|
|
'field_type' => $field->field_type,
|
24 |
|
|
'properties' => $field->properties,
|
25 |
|
|
);
|
26 |
|
|
if (!empty($field->ui_limit)) {
|
27 |
|
|
$fields[$entity_type][$key]['ui_limit'] = explode("\n", $field->ui_limit);
|
28 |
|
|
// Ensure that all strings are trimmed, eg. don't have
|
29 |
|
|
// extra spaces, \r chars etc.
|
30 |
|
|
foreach ($fields[$entity_type][$key]['ui_limit'] as $k => $v) {
|
31 |
|
|
$fields[$entity_type][$key]['ui_limit'][$k] = trim($v);
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
}
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
/* --------------------------------------------------------------
|
38 |
|
|
General node fields.
|
39 |
|
|
-------------------------------------------------------------- */
|
40 |
|
|
|
41 |
|
|
// Node title.
|
42 |
|
|
$fields['node']['title'] = array(
|
43 |
|
|
'title' => t('Title'),
|
44 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
45 |
|
|
'function' => 'ds_render_field',
|
46 |
|
|
'properties' => array(
|
47 |
|
|
'entity_render_key' => 'title',
|
48 |
|
|
'settings' => array(
|
49 |
|
|
'link' => array('type' => 'select', 'options' => array('no', 'yes')),
|
50 |
|
|
'wrapper' => array('type' => 'textfield', 'description' => t('Eg: h1, h2, p')),
|
51 |
|
|
'class' => array('type' => 'textfield', 'description' => t('Put a class on the wrapper. Eg: block-title')),
|
52 |
|
|
),
|
53 |
|
|
'default' => array('wrapper' => 'h2', 'link' => 0, 'class' => ''),
|
54 |
|
|
)
|
55 |
|
|
);
|
56 |
|
|
|
57 |
|
|
// Links.
|
58 |
|
|
$fields['node']['links'] = array(
|
59 |
|
|
'title' => t('Links'),
|
60 |
|
|
'field_type' => DS_FIELD_TYPE_IGNORE,
|
61 |
|
|
);
|
62 |
|
|
|
63 |
|
|
// Comments.
|
64 |
|
|
if (module_exists('comment')) {
|
65 |
|
|
$fields['node']['comments'] = array(
|
66 |
|
|
'title' => t('Comments'),
|
67 |
|
|
'field_type' => DS_FIELD_TYPE_IGNORE,
|
68 |
|
|
'ui_limit' => array(
|
69 |
|
|
'*|full', '*|default',
|
70 |
|
|
),
|
71 |
|
|
);
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
// Node link.
|
75 |
|
|
$fields['node']['node_link'] = array(
|
76 |
|
|
'title' => t('Read more'),
|
77 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
78 |
|
|
'function' => 'ds_render_field',
|
79 |
|
|
'properties' => array(
|
80 |
|
|
'settings' => array(
|
81 |
|
|
'link text' => array('type' => 'textfield'),
|
82 |
|
|
'wrapper' => array('type' => 'textfield', 'description' => t('Eg: h1, h2, p')),
|
83 |
|
|
'class' => array('type' => 'textfield', 'description' => t('Put a class on the wrapper. Eg: block-title')),
|
84 |
|
|
),
|
85 |
|
|
'default' => array('link text' => 'Read more', 'wrapper' => '', 'class' => '', 'link' => 1),
|
86 |
|
|
)
|
87 |
|
|
);
|
88 |
|
|
|
89 |
|
|
// Author.
|
90 |
|
|
$fields['node']['author'] = array(
|
91 |
|
|
'title' => t('Author'),
|
92 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
93 |
|
|
'function' => 'ds_render_author_field',
|
94 |
|
|
'properties' => array(
|
95 |
|
|
'formatters' => array(
|
96 |
|
|
'author' => t('Author'),
|
97 |
|
|
'author_linked' => t('Author linked to profile')
|
98 |
|
|
),
|
99 |
|
|
),
|
100 |
|
|
);
|
101 |
|
|
|
102 |
|
|
// Created time.
|
103 |
|
|
$format_types = system_get_date_types();
|
104 |
|
|
$date_formatters = array();
|
105 |
|
|
foreach ($format_types as $formatter) {
|
106 |
|
|
$date_formatters['ds_post_date_' . $formatter['type']] = t($formatter['title']);
|
107 |
|
|
}
|
108 |
|
|
$fields['node']['post_date'] = array(
|
109 |
|
|
'title' => t('Post date'),
|
110 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
111 |
|
|
'function' => 'ds_render_date_field',
|
112 |
|
|
'properties' => array(
|
113 |
|
|
'formatters' => $date_formatters,
|
114 |
|
|
'entity_render_key' => 'created',
|
115 |
|
|
),
|
116 |
|
|
);
|
117 |
|
|
|
118 |
|
|
// Updated time.
|
119 |
|
|
$fields['node']['changed_date'] = array(
|
120 |
|
|
'title' => t('Last modified'),
|
121 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
122 |
|
|
'function' => 'ds_render_date_field',
|
123 |
|
|
'properties' => array(
|
124 |
|
|
'formatters' => $date_formatters,
|
125 |
|
|
'entity_render_key' => 'changed',
|
126 |
|
|
),
|
127 |
|
|
);
|
128 |
|
|
|
129 |
|
|
// "Submitted by"-line. Skip this if the "Submitted By" module is used.
|
130 |
|
|
if (!module_exists('submitted_by')) {
|
131 |
|
|
$date_formatters = array('ds_time_ago' => t('Time ago')) + $date_formatters;
|
132 |
|
|
$fields['node']['submitted_by'] = array(
|
133 |
|
|
'title' => t('Submitted by'),
|
134 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
135 |
|
|
'function' => 'ds_render_submitted_by',
|
136 |
|
|
'properties' => array(
|
137 |
|
|
'formatters' => $date_formatters,
|
138 |
|
|
),
|
139 |
|
|
);
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
// User picture
|
143 |
|
|
if (variable_get('user_pictures', 0)) {
|
144 |
|
|
$key = 'user_picture';
|
145 |
|
|
$type = DS_FIELD_TYPE_IGNORE;
|
146 |
|
|
$picture_formatters = array();
|
147 |
|
|
if (module_exists('image')) {
|
148 |
|
|
$key = 'ds_user_picture';
|
149 |
|
|
$type = DS_FIELD_TYPE_FUNCTION;
|
150 |
|
|
$styles = image_styles();
|
151 |
|
|
foreach ($styles as $formatter) {
|
152 |
|
|
$picture_formatters['ds_picture_' . $formatter['name']] = drupal_ucfirst(str_replace('_', ' ', $formatter['name']));
|
153 |
|
|
}
|
154 |
|
|
}
|
155 |
|
|
else {
|
156 |
|
|
$picture_formatters['default'] = t('Default');
|
157 |
|
|
}
|
158 |
|
|
$fields['node'][$key] = array(
|
159 |
|
|
'title' => t('User picture'),
|
160 |
|
|
'field_type' => $type,
|
161 |
|
|
'properties' => array(
|
162 |
|
|
'formatters' => $picture_formatters,
|
163 |
|
|
),
|
164 |
|
|
);
|
165 |
|
|
if ($type == DS_FIELD_TYPE_FUNCTION) {
|
166 |
|
|
$fields['node'][$key]['function'] = 'ds_render_user_picture';
|
167 |
|
|
}
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
/* --------------------------------------------------------------
|
171 |
|
|
Book support.
|
172 |
|
|
-------------------------------------------------------------- */
|
173 |
|
|
|
174 |
|
|
if (module_exists('book')) {
|
175 |
|
|
|
176 |
|
|
$ui_limit = array();
|
177 |
|
|
$types = variable_get('book_allowed_types', array('book'));
|
178 |
|
|
foreach ($types as $type) {
|
179 |
|
|
$ui_limit[] = $type . '|full';
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
if (!empty($ui_limit)) {
|
183 |
|
|
$fields['node']['book_navigation'] = array(
|
184 |
|
|
'title' => t('Book navigation'),
|
185 |
|
|
'field_type' => DS_FIELD_TYPE_IGNORE,
|
186 |
|
|
'ui_limit' => $ui_limit,
|
187 |
|
|
);
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
/* --------------------------------------------------------------
|
192 |
|
|
Comment support.
|
193 |
|
|
-------------------------------------------------------------- */
|
194 |
|
|
|
195 |
|
|
if (module_exists('comment')) {
|
196 |
|
|
|
197 |
|
|
// Comment Links.
|
198 |
|
|
$fields['comment']['links'] = array(
|
199 |
|
|
'title' => t('Links'),
|
200 |
|
|
'field_type' => DS_FIELD_TYPE_IGNORE,
|
201 |
|
|
);
|
202 |
|
|
|
203 |
|
|
// Created time.
|
204 |
|
|
$format_types = system_get_date_types();
|
205 |
|
|
$date_formatters = array();
|
206 |
|
|
foreach ($format_types as $formatter) {
|
207 |
|
|
$date_formatters['ds_post_date_' . $formatter['type']] = t($formatter['title']);
|
208 |
|
|
}
|
209 |
|
|
$fields['comment']['post_date'] = array(
|
210 |
|
|
'title' => t('Post date'),
|
211 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
212 |
|
|
'function' => 'ds_render_date_field',
|
213 |
|
|
'properties' => array(
|
214 |
|
|
'formatters' => $date_formatters,
|
215 |
|
|
'entity_render_key' => 'created',
|
216 |
|
|
),
|
217 |
|
|
);
|
218 |
|
|
|
219 |
|
|
// Permalink.
|
220 |
|
|
$fields['comment']['permalink'] = array(
|
221 |
|
|
'title' => t('Permalink'),
|
222 |
|
|
'field_type' => DS_FIELD_TYPE_PREPROCESS,
|
223 |
|
|
);
|
224 |
|
|
|
225 |
|
|
// Submitted.
|
226 |
|
|
$fields['comment']['submitted'] = array(
|
227 |
|
|
'title' => t('Submitted'),
|
228 |
|
|
'field_type' => DS_FIELD_TYPE_PREPROCESS,
|
229 |
|
|
);
|
230 |
|
|
|
231 |
|
|
// Title.
|
232 |
|
|
$fields['comment']['title'] = array(
|
233 |
|
|
'title' => t('Title'),
|
234 |
|
|
'field_type' => DS_FIELD_TYPE_PREPROCESS,
|
235 |
|
|
);
|
236 |
|
|
|
237 |
|
|
// Author.
|
238 |
|
|
$fields['comment']['author'] = array(
|
239 |
|
|
'title' => t('Author'),
|
240 |
|
|
'field_type' => DS_FIELD_TYPE_PREPROCESS,
|
241 |
|
|
);
|
242 |
|
|
|
243 |
|
|
// User signature.
|
244 |
|
|
if (variable_get('user_signatures', 0)) {
|
245 |
|
|
$fields['comment']['signature'] = array(
|
246 |
|
|
'title' => t('User signature'),
|
247 |
|
|
'field_type' => DS_FIELD_TYPE_PREPROCESS,
|
248 |
|
|
);
|
249 |
|
|
}
|
250 |
|
|
|
251 |
|
|
// User picture
|
252 |
|
|
if (variable_get('user_pictures', 0)) {
|
253 |
|
|
$key = 'picture';
|
254 |
|
|
$type = DS_FIELD_TYPE_PREPROCESS;
|
255 |
|
|
$picture_formatters = array();
|
256 |
|
|
if (module_exists('image')) {
|
257 |
|
|
$key = 'ds_user_picture';
|
258 |
|
|
$type = DS_FIELD_TYPE_FUNCTION;
|
259 |
|
|
$styles = image_styles();
|
260 |
|
|
foreach ($styles as $formatter) {
|
261 |
|
|
$picture_formatters['ds_picture_' . $formatter['name']] = drupal_ucfirst(str_replace('_', ' ', $formatter['name']));
|
262 |
|
|
}
|
263 |
|
|
}
|
264 |
|
|
else {
|
265 |
|
|
$picture_formatters['default'] = t('Default');
|
266 |
|
|
}
|
267 |
|
|
$fields['comment'][$key] = array(
|
268 |
|
|
'title' => t('User picture'),
|
269 |
|
|
'field_type' => $type,
|
270 |
|
|
'properties' => array(
|
271 |
|
|
'formatters' => $picture_formatters,
|
272 |
|
|
),
|
273 |
|
|
);
|
274 |
|
|
if ($type == DS_FIELD_TYPE_FUNCTION) {
|
275 |
|
|
$fields['comment'][$key]['function'] = 'ds_render_user_picture';
|
276 |
|
|
}
|
277 |
|
|
}
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
/* --------------------------------------------------------------
|
281 |
|
|
User support.
|
282 |
|
|
-------------------------------------------------------------- */
|
283 |
|
|
|
284 |
|
|
// Username
|
285 |
|
|
$fields['user']['name'] = array(
|
286 |
|
|
'title' => t('Username'),
|
287 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
288 |
|
|
'function' => 'ds_render_field',
|
289 |
|
|
'properties' => array(
|
290 |
|
|
'entity_render_key' => 'name',
|
291 |
|
|
'settings' => array(
|
292 |
|
|
'link' => array('type' => 'select', 'options' => array('no', 'yes')),
|
293 |
|
|
'wrapper' => array('type' => 'textfield', 'description' => t('Eg: h1, h2, p')),
|
294 |
|
|
'class' => array('type' => 'textfield', 'description' => t('Put a class on the wrapper. Eg: block-title')),
|
295 |
|
|
),
|
296 |
|
|
'default' => array('wrapper' => 'h2', 'link' => 0, 'class' => ''),
|
297 |
|
|
)
|
298 |
|
|
);
|
299 |
|
|
|
300 |
|
|
// User signature
|
301 |
|
|
if (variable_get('user_signatures', 0)) {
|
302 |
|
|
$fields['user']['user_signature'] = array(
|
303 |
|
|
'title' => t('User signature'),
|
304 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
305 |
|
|
'function' => 'ds_render_markup',
|
306 |
|
|
'properties' => array(
|
307 |
|
|
'key' => 'signature',
|
308 |
|
|
'format' => 'signature_format',
|
309 |
|
|
),
|
310 |
|
|
);
|
311 |
|
|
}
|
312 |
|
|
|
313 |
|
|
// User picture
|
314 |
|
|
if (variable_get('user_pictures', 0)) {
|
315 |
|
|
$key = 'user_picture';
|
316 |
|
|
$type = DS_FIELD_TYPE_IGNORE;
|
317 |
|
|
$picture_formatters = array();
|
318 |
|
|
if (module_exists('image')) {
|
319 |
|
|
$key = 'ds_user_picture';
|
320 |
|
|
$type = DS_FIELD_TYPE_FUNCTION;
|
321 |
|
|
$styles = image_styles();
|
322 |
|
|
foreach ($styles as $formatter) {
|
323 |
|
|
$picture_formatters['ds_picture_' . $formatter['name']] = drupal_ucfirst(str_replace('_', ' ', $formatter['name']));
|
324 |
|
|
}
|
325 |
|
|
}
|
326 |
|
|
else {
|
327 |
|
|
$picture_formatters['default'] = t('Default');
|
328 |
|
|
}
|
329 |
|
|
$fields['user'][$key] = array(
|
330 |
|
|
'title' => t('User picture'),
|
331 |
|
|
'field_type' => $type,
|
332 |
|
|
'properties' => array(
|
333 |
|
|
'formatters' => $picture_formatters,
|
334 |
|
|
),
|
335 |
|
|
);
|
336 |
|
|
if ($type == DS_FIELD_TYPE_FUNCTION) {
|
337 |
|
|
$fields['user'][$key]['function'] = 'ds_render_user_picture';
|
338 |
|
|
}
|
339 |
|
|
}
|
340 |
|
|
|
341 |
|
|
/* --------------------------------------------------------------
|
342 |
|
|
Taxonomy support.
|
343 |
|
|
-------------------------------------------------------------- */
|
344 |
|
|
|
345 |
|
|
if (module_exists('taxonomy')) {
|
346 |
|
|
// Taxonomy term title.
|
347 |
|
|
$fields['taxonomy_term']['title'] = array(
|
348 |
|
|
'title' => t('Title'),
|
349 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
350 |
|
|
'function' => 'ds_render_field',
|
351 |
|
|
'properties' => array(
|
352 |
|
|
'entity_render_key' => 'name',
|
353 |
|
|
'settings' => array(
|
354 |
|
|
'link' => array('type' => 'select', 'options' => array('no', 'yes')),
|
355 |
|
|
'wrapper' => array('type' => 'textfield', 'description' => t('Eg: h1, h2, p')),
|
356 |
|
|
'class' => array('type' => 'textfield', 'description' => t('Put a class on the wrapper. Eg: block-title')),
|
357 |
|
|
),
|
358 |
|
|
'default' => array('wrapper' => 'h2', 'link' => 0, 'class' => ''),
|
359 |
|
|
)
|
360 |
|
|
);
|
361 |
|
|
|
362 |
|
|
// Taxonomy term link.
|
363 |
|
|
$fields['taxonomy_term']['more_link'] = array(
|
364 |
|
|
'title' => t('Read more'),
|
365 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
366 |
|
|
'function' => 'ds_render_field',
|
367 |
|
|
'properties' => array(
|
368 |
|
|
'settings' => array(
|
369 |
|
|
'link text' => array('type' => 'textfield'),
|
370 |
|
|
'wrapper' => array('type' => 'textfield', 'description' => t('Eg: h1, h2, p')),
|
371 |
|
|
'class' => array('type' => 'textfield', 'description' => t('Put a class on the wrapper. Eg: block-title')),
|
372 |
|
|
),
|
373 |
|
|
'default' => array('link text' => 'Read more', 'wrapper' => '', 'class' => '', 'link' => 1),
|
374 |
|
|
)
|
375 |
|
|
);
|
376 |
|
|
}
|
377 |
|
|
|
378 |
|
|
// Support for ECK Entity title
|
379 |
|
|
if (module_exists('eck')) {
|
380 |
|
|
$entity_info = entity_get_info($entity_type);
|
381 |
|
|
if (isset($entity_info['module']) && $entity_info['module'] == 'eck') {
|
382 |
|
|
$fields[$entity_type]['title'] = array(
|
383 |
|
|
'title' => t('Title'),
|
384 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
385 |
|
|
'function' => 'ds_render_field',
|
386 |
|
|
'properties' => array(
|
387 |
|
|
'entity_render_key' => 'title',
|
388 |
|
|
'settings' => array(
|
389 |
|
|
'link' => array('type' => 'select', 'options' => array('no', 'yes')),
|
390 |
|
|
'wrapper' => array('type' => 'textfield', 'description' => t('Eg: h1, h2, p')),
|
391 |
|
|
'class' => array('type' => 'textfield', 'description' => t('Put a class on the wrapper. Eg: block-title')),
|
392 |
|
|
),
|
393 |
|
|
'default' => array('wrapper' => 'h2', 'link' => 0, 'class' => ''),
|
394 |
|
|
)
|
395 |
|
|
);
|
396 |
|
|
}
|
397 |
|
|
}
|
398 |
|
|
|
399 |
|
|
// Support for fieldable panels panes.
|
400 |
|
|
if (module_exists('fieldable_panels_panes')) {
|
401 |
|
|
$fields['fieldable_panels_pane']['title_ds'] = array(
|
402 |
|
|
'title' => t('Display Suite Title'),
|
403 |
|
|
'field_type' => DS_FIELD_TYPE_FUNCTION,
|
404 |
|
|
'function' => 'ds_render_field',
|
405 |
|
|
'properties' => array(
|
406 |
|
|
'entity_render_key' => 'title',
|
407 |
|
|
'settings' => array(
|
408 |
|
|
'link' => array('type' => 'select', 'options' => array('no', 'yes')),
|
409 |
|
|
'wrapper' => array('type' => 'textfield', 'description' => t('Eg: h1, h2, p')),
|
410 |
|
|
'class' => array('type' => 'textfield', 'description' => t('Put a class on the wrapper. Eg: block-title')),
|
411 |
|
|
),
|
412 |
|
|
'default' => array('wrapper' => 'h2', 'link' => 0, 'class' => ''),
|
413 |
|
|
)
|
414 |
|
|
);
|
415 |
|
|
}
|
416 |
|
|
|
417 |
|
|
if (isset($fields[$entity_type])) {
|
418 |
|
|
return array($entity_type => $fields[$entity_type]);
|
419 |
|
|
}
|
420 |
|
|
return;
|
421 |
|
|
} |