1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* Plugins are described by creating a $plugin array which will be used
|
5 |
|
|
* by the system that includes this file.
|
6 |
|
|
*/
|
7 |
|
|
$plugin = array(
|
8 |
|
|
'single' => TRUE,
|
9 |
|
|
'title' => t('Node author'),
|
10 |
|
|
'icon' => 'icon_node.png',
|
11 |
|
|
'description' => t('The author of the referenced node.'),
|
12 |
|
|
'required context' => new ctools_context_required(t('Node'), 'node'),
|
13 |
|
|
'category' => t('Node'),
|
14 |
|
|
'defaults' => array(
|
15 |
|
|
'link' => TRUE,
|
16 |
|
|
),
|
17 |
|
|
);
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* Render the custom content type.
|
21 |
|
|
*/
|
22 |
|
|
function ctools_node_author_content_type_render($subtype, $conf, $panel_args, $context) {
|
23 |
|
|
if (empty($context) || empty($context->data)) {
|
24 |
|
|
return;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
// Get a shortcut to the node.
|
28 |
|
|
$node = $context->data;
|
29 |
|
|
$user = user_load($node->uid);
|
30 |
|
|
|
31 |
|
|
// Build the content type block.
|
32 |
|
|
$block = new stdClass();
|
33 |
|
|
$block->module = 'node_author';
|
34 |
|
|
$block->title = t('Author');
|
35 |
|
|
$block->content = !empty($conf['link']) ? theme('username', array('account' => $user, 'link_path' => 'user/' . $node->uid)) : check_plain(format_username($node));
|
36 |
|
|
$block->delta = $node->nid;
|
37 |
|
|
|
38 |
|
|
return $block;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* Returns an edit form for custom type settings.
|
43 |
|
|
*/
|
44 |
|
|
function ctools_node_author_content_type_edit_form($form, &$form_state) {
|
45 |
|
|
$conf = $form_state['conf'];
|
46 |
|
|
|
47 |
|
|
$form['link'] = array(
|
48 |
|
|
'#title' => t('Link to author profile'),
|
49 |
|
|
'#type' => 'checkbox',
|
50 |
|
|
'#default_value' => $conf['link'],
|
51 |
|
|
'#description' => t('Check here to link to the node author profile.'),
|
52 |
|
|
);
|
53 |
|
|
return $form;
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
/**
|
57 |
|
|
* Submit handler for the custom type settings form.
|
58 |
|
|
*/
|
59 |
|
|
function ctools_node_author_content_type_edit_form_submit($form, &$form_state) {
|
60 |
|
|
// Copy everything from our defaults.
|
61 |
|
|
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
62 |
|
|
$form_state['conf'][$key] = $form_state['values'][$key];
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* Returns the administrative title for a type.
|
68 |
|
|
*/
|
69 |
|
|
function ctools_node_author_content_type_admin_title($subtype, $conf, $context) {
|
70 |
|
|
return t('"@s" author', array('@s' => $context->identifier));
|
71 |
|
|
} |