function date_handler_field_multiple::render in Date 7
Same name and namespace in other branches
- 6.2 date/date_handler_field_multiple.inc \date_handler_field_multiple::render()
Render the field.
Parameters
array $values: The values retrieved from the database.
Overrides views_handler_field::render
File
- date_views/
includes/ date_handler_field_multiple.inc, line 115 - An extended subclass for field handling that adds multiple field grouping.
Class
- date_handler_field_multiple
- @file An extended subclass for field handling that adds multiple field grouping.
Code
function render($values) {
// By this time $values is a pseudo node that will be passed
// to the theme. Add view information to it.
$values->date_info = !empty($this->view->date_info) ? $this->view->date_info : new stdClass();
$values->date_info->date_handler_fields = date_handler_fields($this->view);
// Add the formatter settings to the pseudo node.
$values->date_info->formatter_settings = $this->options;
$values->date_info->aliases = $this->aliases;
// If this is not a grouped field, use content_handler_field::render().
if (!$this->defer_query) {
return parent::render($values);
}
$field_name = $this->content_field_name;
$field = field_info_field($field_name);
$options = $this->options;
$vid = $values->{$this->field_alias};
if (isset($this->field_values[$vid])) {
// Build a pseudo-node from the retrieved values.
$node = clone $values;
// content_format and formatters will need a 'type' .
$node->type = $values->{$this->aliases['type']};
$node->nid = $values->{$this->aliases['nid']};
$node->vid = $values->{$this->aliases['vid']};
$items = $this->field_values[$vid];
$node->{$field_name} = $items;
// Some formatters need to behave differently depending on the build_mode
// (for instance: preview), so we provide one.
// TODO This has changed in D7.
$node->build_mode = NODE_BUILD_NORMAL;
// Render items.
$formatter_name = $options['format'];
if ($items && ($formatter = _content_get_formatter($formatter_name, $field['type']))) {
$rendered = array();
// Multiple values formatter.
$output = content_format($field, $items, $formatter_name, $values);
if (!empty($output)) {
$rendered[] = $this
->render_link($output, (object) array(
'nid' => $this->aliases['nid'],
));
}
}
if (count($rendered) > 1) {
// TODO: could we use generic field display ?
return theme('field_view_multiple_field', $rendered, $field, $values);
}
elseif ($rendered) {
return $rendered[0];
}
}
return '';
}