public function IpGeoLocViewsPluginStyle::pluginStyleRenderFields in IP Geolocation Views & Maps 8
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.
File
- src/
Services/ IpGeoLocViewsPluginStyle.php, line 1087
Class
- IpGeoLocViewsPluginStyle
- Class IpGeoLocViewsPluginStyle.
Namespace
Drupal\ip_geoloc\ServicesCode
public function pluginStyleRenderFields($views_plugin_style) {
if (!$views_plugin_style
->usesFields() || isset($views_plugin_style->rendered_fields)) {
return;
}
$rendered_fields = [];
$field_ids = array_keys($views_plugin_style->view->field);
$differentiator = $views_plugin_style->options['differentiator']['differentiator_field'];
$latitude = trim($views_plugin_style->options['ip_geoloc_views_plugin_latitude']);
$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 ($field_ids as $field_id) {
$field = $views_plugin_style->view->field[$field_id];
// theme() also renders the tokens that may be used in the balloon 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.
$special_field_id = 'views_' . $field_id;
if (($special_field_id == $differentiator || $special_field_id == $latitude || $special_field_id == $longitude) && empty($row->{$special_field_id})) {
$row->{$special_field_id}[] = $field_value;
}
// If Excluded is ticked, we don't style and add the field to the
// rendered_fields.
if (!$field->options['exclude']) {
$styled_field_value = $this
->pluginStyleAddLabelAndStyling($field, $field_value);
$rendered_fields[$i][$field_id] = $styled_field_value;
}
}
}
$views_plugin_style
->setRenderedFields($rendered_fields);
// unset($views_plugin_style->view->row_index);.
return $rendered_fields;
}