/** * {@inheritdoc} */ public function render(ResultRow $values) { // Only render if we exist. if (isset($this->tableAlias)) { return parent::render($values); } }
/** * {@inheritdoc} */ public function render(ResultRow $values) { $value = parent::render($values); switch ($value) { case LocalTaskItemInterface::STATUS_PENDING: $label = t('Untranslated'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/ready.svg'; break; case LocalTaskItemInterface::STATUS_COMPLETED: $label = t('Translated'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/gray-check.svg'; break; case LocalTaskItemInterface::STATUS_REJECTED: $label = t('Rejected'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/rejected.svg'; break; case LocalTaskItemInterface::STATUS_CLOSED: $label = t('Completed'); $icon = 'core/misc/icons/73b355/check.svg'; break; default: $label = t('Untranslated'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/ready.svg'; } $element = ['#type' => 'inline_template', '#template' => '<img src="{{ icon }}" title="{{ label }}"><span></span></img>', '#context' => array('icon' => file_create_url($icon), 'label' => $label)]; return \Drupal::service('renderer')->render($element); }
/** * {@inheritdoc} */ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { // In case we act as the fallback handler for an entity field, our // submitOptionsForm() method won't be called, which means the // "format_plural_string" option won't be saved correctly. Fix that here. if (isset($options['format_plural_values'])) { $options['format_plural_string'] = implode(PluralTranslatableMarkup::DELIMITER, $options['format_plural_values']); } parent::init($view, $display, $options); }
/** * {@inheritdoc} */ public function render(ResultRow $values) { if ($this->options['format'] == 'uc_length') { $value = $this->getValue($values); if (is_null($value) || $value == 0 && $this->options['empty_zero']) { return ''; } return uc_length_format($value, $values->{$this->aliases['length_units']}); } else { return parent::render($values); } }
/** * {@inheritdoc} */ public function render(ResultRow $values) { if ($this->options['format'] == 'uc_price') { $value = $this->getValue($values); if (is_null($value) || $value == 0 && $this->options['empty_zero']) { return ''; } return uc_currency_format($value); } else { return parent::render($values); } }
/** * {@inheritdoc} */ public function render(ResultRow $values) { $value = parent::render($values); switch ($value) { case JobItemInterface::STATE_ACTIVE: $label = t('In progress'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/hourglass.svg'; break; case JobItemInterface::STATE_REVIEW: $label = t('Needs review'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/ready.svg'; break; default: $icon = NULL; $label = NULL; } $element = ['#type' => 'inline_template', '#template' => '{% if label %}<img src="{{ icon }}" title="{{ label }}"><span></span></img>{% endif %}', '#context' => array('icon' => file_create_url($icon), 'label' => $label)]; return \Drupal::service('renderer')->render($element); }
/** * {@inheritdoc} */ public function render(ResultRow $values) { $value = parent::render($values); switch ($value) { case JobInterface::STATE_UNPROCESSED: $label = t('Unprocessed'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/rejected.svg'; break; case JobInterface::STATE_ACTIVE: $needs_review = FALSE; /** @var JobItemInterface $item */ foreach ($values->_entity->getItems() as $item) { if ($item->isNeedsReview()) { $needs_review = TRUE; break; } } if ($needs_review) { $label = t('Needs review'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/ready.svg'; break; } $label = t('In progress'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/hourglass.svg'; break; case JobInterface::STATE_CONTINUOUS: $label = t('Continuous'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/continuous.svg'; break; case JobInterface::STATE_CONTINUOUS_INACTIVE: $label = t('Continuous Inactive'); $icon = drupal_get_path('module', 'tmgmt') . '/icons/continuous_inactive.svg'; break; default: $icon = NULL; $label = NULL; } $element = ['#type' => 'inline_template', '#template' => '{% if label %}<img src="{{ icon }}" title="{{ label }}"><span></span></img>{% endif %}', '#context' => ['icon' => file_create_url($icon), 'label' => $label]]; return \Drupal::service('renderer')->render($element); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { // Add a start point selector. // Add the proximity field group. $form['proximity_group'] = ['#type' => 'fieldset', '#title' => $this->t('Proximity Settings')]; // Add the source selector. $form['proximity_source'] = ['#type' => 'select', '#title' => $this->t('Select the source type.'), '#description' => $this->t('To calculate proximity we need a starting point to compare the field value to. Select where to get the start location.'), '#default_value' => $this->options['proximity_source'], '#fieldset' => 'proximity_group', '#options' => ['direct_input' => $this->t('Direct Input'), 'filter' => $this->t('Filter Settings'), 'argument' => $this->t('Contextual Filter')]]; // Add the Latitude field for direct input. $form['proximity_lat'] = ['#type' => 'textfield', '#title' => $this->t('Latitude'), '#empty_value' => '', '#default_value' => $this->options['proximity_lat'], '#maxlength' => 255, '#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'direct_input']]]]; // Add the Latitude field for direct input. $form['proximity_lng'] = ['#type' => 'textfield', '#title' => $this->t('Longitude'), '#empty_value' => '', '#default_value' => $this->options['proximity_lng'], '#maxlength' => 255, '#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'direct_input']]]]; $form['units'] = ['#type' => 'select', '#title' => $this->t('Units'), '#default_value' => !empty($this->options['units']) ? $this->options['units'] : '', '#weight' => 40, '#fieldset' => 'proximity_group', '#options' => ['mile' => $this->t('Miles'), 'km' => $this->t('Kilometers')], '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'direct_input']]]]; // Buffer available filters. $valid_filters = []; // Check for valid filters. foreach ($this->view->getHandlers('filter', $this->view->current_display) as $delta => $filter) { if ($filter['plugin_id'] === 'geolocation_filter_proximity') { $valid_filters[$delta] = $filter['id']; } } // Add the Filter selector. $form['proximity_filter'] = empty($valid_filters) ? ['#markup' => $this->t('There are no proximity filters available in this display.')] : ['#type' => 'select', '#title' => $this->t('Select filter.'), '#description' => $this->t('Select the filter to use as the starting point for calculating proximity.'), '#options' => $valid_filters]; $form['proximity_filter'] += ['#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'filter']]]]; // Buffer available filters. $valid_arguments = []; // Check for valid filters. foreach ($this->view->getHandlers('argument', $this->view->current_display) as $delta => $filter) { if ($filter['plugin_id'] === 'geolocation_argument_proximity') { $valid_arguments[$delta] = $filter['id']; } } // Add the Filter selector. $form['proximity_argument'] = empty($valid_arguments) ? ['#markup' => $this->t('There are no proximity contextual filters (arguments) available in this display.')] : ['#type' => 'select', '#title' => $this->t('Select contextual filter (argument).'), '#description' => $this->t('Select the contextual filter (argument) to use as the starting point for calculating proximity.'), '#options' => $valid_arguments]; $form['proximity_argument'] += ['#fieldset' => 'proximity_group', '#states' => ['visible' => ['select[name="options[proximity_source]"]' => ['value' => 'argument']]]]; // Add the Drupal\views\Plugin\views\field\Numeric settings to the form. parent::buildOptionsForm($form, $form_state); }
/** * {@inheritdoc} */ public function render(ResultRow $values) { $value = $this->getValue($values); if (!empty($value)) { return $this->renderLink(parent::render($values), $values); } else { $this->options['alter']['make_link'] = FALSE; } }