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 last updated date'),
|
10 |
|
|
'icon' => 'icon_node.png',
|
11 |
|
|
'description' => t('The date the referenced node was last updated.'),
|
12 |
|
|
'required context' => new ctools_context_required(t('Node'), 'node'),
|
13 |
|
|
'category' => t('Node'),
|
14 |
|
|
'defaults' => array(
|
15 |
|
|
'format' => 'small',
|
16 |
|
|
),
|
17 |
|
|
);
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* Render the custom content type.
|
21 |
|
|
*/
|
22 |
|
|
function ctools_node_updated_content_type_render($subtype, $conf, $panel_args, $context) {
|
23 |
e4c061ad
|
Assos Assos
|
if (empty($context) || empty($context->data) || empty($context->data->nid)) {
|
24 |
85ad3d82
|
Assos Assos
|
return;
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
// Get a shortcut to the node.
|
28 |
|
|
$node = $context->data;
|
29 |
|
|
|
30 |
|
|
// Build the content type block.
|
31 |
|
|
$block = new stdClass();
|
32 |
|
|
$block->module = 'node_updated';
|
33 |
|
|
$block->title = t('Last updated date');
|
34 |
|
|
$block->content = format_date(!empty($node->changed) ? $node->changed : $node->created, $conf['format']);
|
35 |
|
|
$block->delta = $node->nid;
|
36 |
|
|
|
37 |
|
|
return $block;
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
/**
|
41 |
|
|
* Returns an edit form for custom type settings.
|
42 |
|
|
*/
|
43 |
|
|
function ctools_node_updated_content_type_edit_form($form, &$form_state) {
|
44 |
|
|
$conf = $form_state['conf'];
|
45 |
|
|
$date_types = array();
|
46 |
|
|
|
47 |
|
|
foreach (system_get_date_types() as $date_type => $definition) {
|
48 |
|
|
$date_types[$date_type] = format_date(REQUEST_TIME, $date_type);
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
$form['format'] = array(
|
52 |
|
|
'#title' => t('Date format'),
|
53 |
|
|
'#type' => 'select',
|
54 |
|
|
'#options' => $date_types,
|
55 |
|
|
'#default_value' => $conf['format'],
|
56 |
|
|
);
|
57 |
|
|
return $form;
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
/**
|
61 |
|
|
* Submit handler for the custom type settings form.
|
62 |
|
|
*/
|
63 |
|
|
function ctools_node_updated_content_type_edit_form_submit($form, &$form_state) {
|
64 |
|
|
// Copy everything from our defaults.
|
65 |
|
|
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
66 |
|
|
$form_state['conf'][$key] = $form_state['values'][$key];
|
67 |
|
|
}
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
/**
|
71 |
|
|
* Returns the administrative title for a type.
|
72 |
|
|
*/
|
73 |
|
|
function ctools_node_updated_content_type_admin_title($subtype, $conf, $context) {
|
74 |
|
|
return t('"@s" last updated date', array('@s' => $context->identifier));
|
75 |
|
|
} |