1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* This file provides a CTools content type containing the author pane.
|
6
|
*/
|
7
|
$plugin = array(
|
8
|
'title' => t('Author Pane (content pane)'),
|
9
|
'description' => t('Author related variables gathered from helper modules.'),
|
10
|
'single' => TRUE,
|
11
|
'required context' => new ctools_context_required(t('User'), 'user'),
|
12
|
'category' => t('User'),
|
13
|
'icon' => 'icon_user.png',
|
14
|
'edit form' => 'author_pane_content_type_edit_form',
|
15
|
'render callback' => 'author_pane_content_type_render',
|
16
|
'admin title' => 'author_pane_content_type_admin_title',
|
17
|
'defaults' => array(
|
18
|
'caller' => 'advanced_profile',
|
19
|
'picture_preset' => '',
|
20
|
'join_date_type' => 'short',
|
21
|
),
|
22
|
);
|
23
|
|
24
|
/**
|
25
|
* Output function for the 'author pane' content type.
|
26
|
*/
|
27
|
function author_pane_content_type_render($subtype, $conf, $panel_args, $context) {
|
28
|
$account = isset($context->data) ? clone $context->data : NULL;
|
29
|
$block = new stdClass();
|
30
|
|
31
|
if ($account) {
|
32
|
// Use the Real Name module if installed. Otherwise just the plain,
|
33
|
// unthemed user name for the title since we don't want it linked.
|
34
|
if (module_exists('realname')) {
|
35
|
$block->title = theme('realname', $account, array('plain' => TRUE));
|
36
|
}
|
37
|
else {
|
38
|
$block->title = check_plain($account->name);
|
39
|
}
|
40
|
$variables = array(
|
41
|
'account' => $account,
|
42
|
'caller' => $conf['caller'],
|
43
|
'picture_preset' => $conf['picture_preset'],
|
44
|
'join_date_type' => $conf['join_date_type'],
|
45
|
);
|
46
|
$block->content = theme('author_pane', $variables);
|
47
|
}
|
48
|
else {
|
49
|
$block->content = t('User information not available');
|
50
|
}
|
51
|
|
52
|
return $block;
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* Returns an edit form for the custom type.
|
57
|
*/
|
58
|
function author_pane_content_type_edit_form($form, &$form_state) {
|
59
|
$conf = $form_state['conf'];
|
60
|
|
61
|
$join_date_options = array();
|
62
|
foreach (system_get_date_types() as $date_type) {
|
63
|
$join_date_options[$date_type['type']] = $date_type['title'];
|
64
|
}
|
65
|
|
66
|
$form['join_date_type'] = array(
|
67
|
'#type' => 'select',
|
68
|
'#title' => t('Join date, date type'),
|
69
|
'#options' => $join_date_options,
|
70
|
'#default_value' => $conf['join_date_type'],
|
71
|
'#description' => t('Select which <a href="@date-type-url">date type</a> to use for displaying the join date.', array('@date-type-url' => url('admin/config/regional/date-time'))),
|
72
|
);
|
73
|
|
74
|
if (module_exists('image')) {
|
75
|
$options = array('' => '');
|
76
|
foreach (image_styles() as $style) {
|
77
|
$options[$style['name']] = $style['name'];
|
78
|
}
|
79
|
|
80
|
$form['picture_preset'] = array(
|
81
|
'#type' => 'select',
|
82
|
'#title' => t('User picture preset'),
|
83
|
'#options' => $options,
|
84
|
'#description' => t('Imagecache preset to use for user picture. Leave blank to not use this feature.'),
|
85
|
'#default_value' => $conf['picture_preset'],
|
86
|
);
|
87
|
}
|
88
|
|
89
|
$form['caller'] = array(
|
90
|
'#type' => 'textfield',
|
91
|
'#title' => t('Caller'),
|
92
|
'#size' => 50,
|
93
|
'#description' => t('Name of the calling program. This can be picked up during the preprocessing for specific changes. If using this in Advanced Profile Kit, it should be set to "advanced_profile"'),
|
94
|
'#default_value' => $conf['caller'],
|
95
|
);
|
96
|
|
97
|
return $form;
|
98
|
}
|
99
|
|
100
|
/**
|
101
|
* @todo Please document this function.
|
102
|
* @see http://drupal.org/node/1354
|
103
|
*/
|
104
|
function author_pane_content_type_edit_form_submit($form, &$form_state) {
|
105
|
// Copy everything from our defaults.
|
106
|
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
107
|
$form_state['conf'][$key] = $form_state['values'][$key];
|
108
|
}
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* @todo Please document this function.
|
113
|
* @see http://drupal.org/node/1354
|
114
|
*/
|
115
|
function author_pane_content_type_admin_title($subtype, $conf, $context) {
|
116
|
return t('"@s" author pane', array('@s' => $context->identifier));
|
117
|
}
|