function _views_pivot_add_field_to_row in Pivot Tables for Views 7
Helper function to add a field to a table row, called by template_preprocess_views_view_pivot_table
Parameters
$vars:
$options:
$renders:
$fields:
$num:
$row_key:
$field:
$column_key:
$column:
bool $append:
See also
template_preprocess_views_view_pivot_table
1 call to _views_pivot_add_field_to_row()
- template_preprocess_views_view_pivot_table in ./
views_pivot.theme.inc - Callback to prepare row data for later rendering.
File
- ./
views_pivot.theme.inc, line 465
Code
function _views_pivot_add_field_to_row(&$vars, $options, $renders, $fields, $num, $row_key, $field, $column_key, $column, $append = TRUE) {
if (!isset($fields[$field])) {
// Maybe no fields defined yet.
return;
}
/* @var $field_handler views_handler_field_field */
$field_handler = $fields[$field];
_views_pivot_add_field_classes($vars, $fields, $num, $row_key, $field);
if (!empty($field_handler) && empty($field_handler->options['exclude'])) {
$field_output = $renders[$num][$field];
$element_type = $field_handler
->element_type(TRUE, TRUE);
if ($element_type) {
$field_output = '<' . $element_type . '>' . $field_output . '</' . $element_type . '>';
}
// Don't bother with separators and stuff if the field does not show up.
if (empty($field_output) && !empty($vars['rows'][$row_key][$column_key])) {
return;
}
// Let's see if we have an aggregated field
$pivot_agg_mode = strpos($column_key, 'agg:') === 0 || strpos($row_key, 'agg:') === 0;
if (!$pivot_agg_mode && $append && !empty($field_handler->options['group_type']) && $field_handler->options['group_type'] == 'count') {
if (empty($vars['rows'][$row_key][$column_key])) {
$vars['rows'][$row_key][$column_key] = 0;
}
$vars['rows'][$row_key][$column_key]++;
return;
}
// Place the field into the column, along with an optional separator.
if ($append && !empty($vars['rows'][$row_key][$column_key])) {
if (strrpos($vars['rows'][$row_key][$column_key], $field_output) !== FALSE) {
// Ignore it as we seem to have added that already
return;
}
if (!empty($options['info'][$column]['separator'])) {
$vars['rows'][$row_key][$column_key] .= filter_xss_admin($options['info'][$column]['separator']);
}
}
else {
$vars['rows'][$row_key][$column_key] = '';
}
$vars['rows'][$row_key][$column_key] .= $field_output;
}
}