class ClientLocationOriginFilter in Geofield 8
Defines 'Geofield Client Location Origin' plugin.
@package Drupal\geofield\Plugin
Plugin annotation
@GeofieldProximitySource(
id = "geofield_client_location_origin",
label = @Translation("Client Location Origin"),
description = @Translation("Gets the Client Location through the browser HTML5 Geolocation API."),
context = {
"filter",
},
exposedOnly = true
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\geofield\Plugin\GeofieldProximitySourceBase implements GeofieldProximitySourceInterface uses StringTranslationTrait
- class \Drupal\geofield\Plugin\GeofieldProximitySource\ManualOriginDefault
- class \Drupal\geofield\Plugin\GeofieldProximitySource\ClientLocationOriginFilter
- class \Drupal\geofield\Plugin\GeofieldProximitySource\ManualOriginDefault
- class \Drupal\geofield\Plugin\GeofieldProximitySourceBase implements GeofieldProximitySourceInterface uses StringTranslationTrait
Expanded class hierarchy of ClientLocationOriginFilter
File
- src/
Plugin/ GeofieldProximitySource/ ClientLocationOriginFilter.php, line 23
Namespace
Drupal\geofield\Plugin\GeofieldProximitySourceView source
class ClientLocationOriginFilter extends ManualOriginDefault {
/**
* {@inheritdoc}
*/
public function buildOptionsForm(array &$form, FormStateInterface $form_state, array $options_parents, $is_exposed = FALSE) {
$form['#attributes'] = [
'class' => [
'proximity-origin-client',
],
];
$form["origin"] = [
'#title' => $this
->t('Client Coordinates'),
'#type' => 'geofield_latlon',
'#description' => $this
->t('Value in decimal degrees. Use dot (.) as decimal separator.'),
'#default_value' => [
'lat' => '',
'lon' => '',
],
'#attributes' => [
'class' => [
'visually-hidden',
],
],
];
// If it is a proximity filter context and IS NOT exposed, render origin
// summary option.
if ($this->viewHandler->configuration['id'] == 'geofield_proximity_filter' && !$is_exposed) {
$form['origin_summary_flag'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show the Client Origin coordinates as summary in the Exposed Form'),
'#default_value' => isset($this->configuration['origin_summary_flag']) ? $this->configuration['origin_summary_flag'] : TRUE,
];
}
// If it IS exposed load the geolocation library.
if ($is_exposed) {
$form['origin']['#attached']['library'][] = 'geofield/geolocation';
// And eventually Render the Origin Summary.
if (isset($this->configuration['origin_summary_flag']) && $this->configuration['origin_summary_flag']) {
$form['origin_summary'] = [
"#type" => 'html_tag',
"#tag" => 'div',
'#value' => $this
->t('from Latitude: @lat and Longitude: @lon.', [
'@lat' => new FormattableMarkup('<span class="geofield-lat-summary">@lat</span>', [
'@lat' => $this
->t('undefined'),
]),
'@lon' => new FormattableMarkup('<span class="geofield-lon-summary">@lon</span>', [
'@lon' => $this
->t('undefined'),
]),
]),
];
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClientLocationOriginFilter:: |
public | function |
Builds the specific form elements for the geofield proximity plugin. Overrides ManualOriginDefault:: |
|
GeofieldProximitySourceBase:: |
protected | property | The origin point to measure proximity from. | |
GeofieldProximitySourceBase:: |
protected | property | The name of the constant defining the measurement unit. | |
GeofieldProximitySourceBase:: |
protected | property | The view handler which uses this proximity plugin. | |
GeofieldProximitySourceBase:: |
public | function |
Gets the haversine options. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function |
Gets the proximity distance origin. Overrides GeofieldProximitySourceInterface:: |
2 |
GeofieldProximitySourceBase:: |
public | function |
Get the calculated proximity. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function |
Get the current units. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function | Get the list of valid options for units. | |
GeofieldProximitySourceBase:: |
public | function |
Check if Location is empty. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function |
Check for a valid couple of latitude and longitude. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function |
Sets the proximity distance origin. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function |
Set the units to perform the calculation in. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function |
Sets view handler which uses this proximity plugin. Overrides GeofieldProximitySourceInterface:: |
|
GeofieldProximitySourceBase:: |
public | function |
Validates the options form for the geofield proximity plugin. Overrides GeofieldProximitySourceInterface:: |
1 |
ManualOriginDefault:: |
public | function |
Constructs a ManualOriginDefault object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |