function ip_geoloc_plugin_style_render_fields in IP Geolocation Views & Maps 7
Same name and namespace in other branches
- 8 src/Plugin/views/style/ip_geoloc_plugin_style.inc \ip_geoloc_plugin_style_render_fields()
Perform token replacement, convert timestamps to date strings etc.
Store the rendered rows on the object passed in, which will typically be an instance of class views_plugin_style or subclass. Note that fields that have their Exclude box ticked, won't be rendered, Typical candidates for exclusion are the latitude and longitude fields.
Parameters
string $views_plugin_style: The views plugin style.
3 calls to ip_geoloc_plugin_style_render_fields()
- ip_geoloc_plugin_style_leaflet::render in views/
ip_geoloc_plugin_style_leaflet.inc - Transform the View result in a list of marker locations and render on map.
- ip_geoloc_plugin_style_map::render in views/
ip_geoloc_plugin_style_map.inc - Transform the View result in a list of markers and render these on a map.
- ip_geoloc_plugin_style_openlayers::render in views/
ip_geoloc_plugin_style_openlayers.inc - Transform the View result in a list of markers and render these on a map.
File
- views/
ip_geoloc_plugin_style.inc, line 1251 - ip_geoloc_plugin_style.inc
Code
function ip_geoloc_plugin_style_render_fields($views_plugin_style) {
if (!$views_plugin_style
->uses_fields() || isset($views_plugin_style->rendered_fields)) {
return;
}
$views_plugin_style->rendered_fields = array();
$differentiator = $views_plugin_style->options['differentiator']['differentiator_field'];
$aggregation_field = isset($views_plugin_style->options['cluster_aggregation']['aggregation_field']) ? $views_plugin_style->options['cluster_aggregation']['aggregation_field'] : NULL;
$latitudes = $views_plugin_style->options['ip_geoloc_views_plugin_latitude'];
if (!is_array($latitudes)) {
$latitudes = array(
$latitudes,
);
}
$longitude = trim($views_plugin_style->options['ip_geoloc_views_plugin_longitude']);
foreach ($views_plugin_style->view->result as $i => &$row) {
// God knows why we need this...
$views_plugin_style->view->row_index = $i;
foreach ($views_plugin_style->view->field as $field_id => $field) {
// theme() also renders the replacement tokens that may be used in the
// balloons of OTHER fields when "Rewrite the output of this field" is
// ticked on those fields. So even if Excluded is ticked for this field,
// we need to theme() it for the potential sake of those other fields.
$field_value = $field
->theme($row);
// Add the special 'views_' fields that normally aren't in the results
// set to the row, if required for the $differentiator or lat/lon that
// have math expressions applied through the Views UI.
// Examples:
// "User: Roles" used as differentiator becomes 'views_rid'
// "Global: View result counter" as differentiator becomes 'views_counter'
$special_field_id = 'views_' . $field_id;
if (($special_field_id == $differentiator || $special_field_id == $aggregation_field || in_array($special_field_id, $latitudes) || $special_field_id == $longitude) && empty($row->{$special_field_id})) {
$row->{$special_field_id}[] = $field_value;
}
// If Excluded is ticked, we don't style and don't add the field to the
// rendered_fields.
if (!$field->options['exclude'] && !($field_value == '' && $field->options['hide_empty'])) {
$styled_field_value = _ip_geoloc_plugin_style_add_label_and_styling($field, $field_value);
$views_plugin_style->rendered_fields[$i][$field_id] = $styled_field_value;
}
}
}
unset($views_plugin_style->view->row_index);
return $views_plugin_style->rendered_fields;
}