function classified_classified_expires_content_type_render in Classified Ads 7.3
Same name and namespace in other branches
- 6.3 plugins/content_types/classified_expires.inc \classified_classified_expires_content_type_render()
Implements hook_PLUGIN_content_type_render().
Render the custom content type.
File
- plugins/
content_types/ classified_expires.inc, line 54 - CTools content_type plugin, displaying a Classified Ad expiration info.
Code
function classified_classified_expires_content_type_render($subtype, $conf, $panel_args, $context) {
if (empty($context) || empty($context->data)) {
return;
}
// Get a shortcut to the node.
$node = $context->data;
if ($node->type != 'classified') {
return;
}
// Build the content type block.
$block = new stdClass();
$block->module = 'classified';
$block->delta = $node->nid;
$variables = array(
'node' => $node,
);
if (empty($conf['format'])) {
$conf['format'] = 'formatted';
}
switch ($conf['format']) {
case 'date':
$block->title = t('Ad Expiration date');
classified_preprocess_classified_expires($variables);
$block->content = t('@date', array(
'@date' => $variables['expires'],
));
break;
case 'percent':
$block->title = t('Ad Lifetime, remaining');
classified_preprocess_classified_expires($variables);
$block->content = t('@percent%', array(
'@percent' => $variables['remaining_ratio'],
));
break;
case 'duration':
$block->title = t('Ad Lifetime, remaining');
classified_preprocess_classified_expires($variables);
$block->content = t('@remaining', array(
'@remaining' => $variables['remaining'],
));
break;
case 'formatted':
default:
$block->title = NULL;
$block->content = theme('classified_expires', array(
'node' => $node,
));
break;
}
if (!empty($conf['link'])) {
$block->content = l($block->content, 'node/' . $node->nid, array(
'html' => TRUE,
));
}
return $block;
}