4 * Plugins are described by creating a $plugin array which will be used
5 * by the system that includes this file.
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'),
20 * Render the custom content type.
22 function ctools_node_updated_content_type_render($subtype, $conf, $panel_args, $context) {
23 if (empty($context) || empty($context->data) || empty($context->data->nid)) {
27 // Get a shortcut to the node.
28 $node = $context->data;
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;
41 * Returns an edit form for custom type settings.
43 function ctools_node_updated_content_type_edit_form($form, &$form_state) {
44 $conf = $form_state['conf'];
45 $date_types = array();
47 foreach (system_get_date_types() as $date_type => $definition) {
48 $date_types[$date_type] = format_date(REQUEST_TIME, $date_type);
51 $form['format'] = array(
52 '#title' => t('Date format'),
54 '#options' => $date_types,
55 '#default_value' => $conf['format'],
61 * Submit handler for the custom type settings form.
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];
71 * Returns the administrative title for a type.
73 function ctools_node_updated_content_type_admin_title($subtype, $conf, $context) {
74 return t('"@s" last updated date', array('@s' => $context->identifier));