File
-
plugins/content_types/comment/comment_created.inc
View source
<?php
$plugin = array(
'single' => TRUE,
'title' => t('Comment created date'),
'icon' => 'icon_comment.png',
'description' => t('The date the referenced comment was created.'),
'required context' => new ctools_context_required(t('Comment'), 'entity:comment'),
'category' => t('Comment'),
'defaults' => array(
'format' => 'small',
),
);
function ctools_comment_created_content_type_render($subtype, $conf, $panel_args, $context) {
if (empty($context) || empty($context->data)) {
return;
}
$comment = $context->data;
$block = new stdClass();
$block->module = 'comment_created';
$block->title = t('Created date');
$block->content = format_date($comment->created, $conf['format']);
$block->delta = $comment->cid;
return $block;
}
function ctools_comment_created_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
$date_types = array();
foreach (system_get_date_types() as $date_type => $definition) {
$date_types[$date_type] = format_date(REQUEST_TIME, $date_type);
}
$form['format'] = array(
'#title' => t('Date format'),
'#type' => 'select',
'#options' => $date_types,
'#default_value' => $conf['format'],
);
return $form;
}
function ctools_comment_created_content_type_edit_form_submit($form, &$form_state) {
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}
function ctools_comment_created_content_type_admin_title($subtype, $conf, $context) {
return t('"@s" created date', array(
'@s' => $context->identifier,
));
}
Functions