Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function defineOptions()
 {
     $options = parent::defineOptions();
     $options['fields'] = array('default' => array());
     $options['destination'] = array('default' => 1);
     return $options;
 }
Пример #2
0
  /**
   * Provide the options form.
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    // Link options.
    $form['link_photo'] = array(
      '#title' => t("Link image"),
      '#description' => t("Link the image to the album page or image page."),
      '#type' => 'radios',
      '#options' => array(
        '' => $this->t('None'),
        'album' => $this->t('Album page'),
        'image' => $this->t('Image page')
      ),
      '#default_value' => $this->options['link_photo']
    );

    // Get image styles.
    $style_options = image_style_options();
    $form['image_style'] = array(
      '#title' => $this->t('Image style'),
      '#type' => 'select',
      '#default_value' => $this->options['image_style'],
      '#options' => $style_options,
    );

    parent::buildOptionsForm($form, $form_state);
  }
Пример #3
0
 /**
  * Constructs a 'Disqus Comment Count' view field plugin.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Session\AccountInterface $current_user
  *   The current user.
  * @param \Drupal\disqus\DisqusCommentManager $disqus_manager
  *   The disqus comment manager object.
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
  *   The config factory.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountInterface $current_user, DisqusCommentManager $disqus_manager, ConfigFactoryInterface $config_factory)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->currentUser = $current_user;
     $this->disqusManager = $disqus_manager;
     $this->config = $config_factory->get('disqus.settings');
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $options = array('' => t('- All -'));
     $options += JobItem::getStates();
     $form['state'] = array('#title' => t('Job item state'), '#description' => t('Count only job items of a certain state.'), '#type' => 'select', '#options' => $options, '#default_value' => $this->options['state']);
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['range'] = array('#type' => 'textfield', '#title' => t('Range'), '#description' => t('The range of weights available to select. For
     example, a range of 20 will allow you to select a weight between -20
     and 20.'), '#default_value' => $this->options['range'], '#size' => 5);
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     // Only show fields that precede this one.
     $field_options = $this->getPreviousFieldLabels();
     $form['fields'] = array('#type' => 'checkboxes', '#title' => $this->t('Fields'), '#description' => $this->t('Fields to be included as links.'), '#options' => $field_options, '#default_value' => $this->options['fields']);
     $form['destination'] = array('#type' => 'checkbox', '#title' => $this->t('Include destination'), '#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the link action.'), '#default_value' => $this->options['destination']);
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['text'] = array('#type' => 'textfield', '#title' => $this->t('Text to display'), '#default_value' => $this->options['text']);
     parent::buildOptionsForm($form, $form_state);
     // The path is set by renderLink function so don't allow to set it.
     $form['alter']['path'] = array('#access' => FALSE);
     $form['alter']['external'] = array('#access' => FALSE);
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $this->format = $this->definition['format'];
     $this->additional_fields = array();
     if (is_array($this->format)) {
         $this->additional_fields['format'] = $this->format;
     }
 }
Пример #9
0
 /**
  * @inheritdoc
  */
 public function submitOptionsForm(&$form, FormStateInterface $form_state)
 {
     // Merge plural format options into one string and drop the individual
     // option values.
     $options =& $form_state->getValue('options');
     $options['format_plural_string'] = implode(LOCALE_PLURAL_DELIMITER, $options['format_plural_values']);
     unset($options['format_plural_values']);
     parent::submitOptionsForm($form, $form_state);
 }
Пример #10
0
 /**
  * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions().
  */
 protected function defineOptions()
 {
     $options = parent::defineOptions();
     $options['label'] = array('default' => $this->definition['title'], 'translatable' => TRUE);
     $options['gcal'] = array('default' => '');
     $options['class'] = array('default' => 'fc-event-default fc-event-gcal');
     $options['timezone'] = array('default' => date_default_timezone_get());
     return $options;
 }
Пример #11
0
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     // Remove the checkbox
     unset($form['alter']['alter_text']);
     unset($form['alter']['text']['#states']);
     unset($form['alter']['help']['#states']);
     $form['#pre_render'][] = array($this, 'preRenderCustomForm');
 }
Пример #12
0
 /**
  * @inheritDoc
  */
 public function getValue(ResultRow $values, $field = NULL)
 {
     $value = NULL;
     $cat_id = parent::getValue($values, $field);
     if ($cat_id) {
         $value = $this->entityStorage->load($cat_id)->getName();
     }
     return $value;
 }
Пример #13
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['text'] = ['#type' => 'textfield', '#title' => $this->t('Text to display'), '#default_value' => $this->options['text']];
     parent::buildOptionsForm($form, $form_state);
     // The path is set by ::renderLink() so we do not allow to set it.
     $form['alter'] += ['path' => [], 'query' => [], 'external' => []];
     $form['alter']['path'] += ['#access' => FALSE];
     $form['alter']['query'] += ['#access' => FALSE];
     $form['alter']['external'] += ['#access' => FALSE];
 }
Пример #14
0
 /**
  * Constructs a new instance.
  *
  * @param mixed[] $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin_id for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
  *   The string translator.
  * @param \Drupal\Core\Entity\EntityStorageInterface $currency_storage
  *   THe currency storage.
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(array $configuration, $plugin_id, array $plugin_definition, TranslationInterface $string_translation, EntityStorageInterface $currency_storage)
 {
     if (!isset($configuration['currency_method'])) {
         throw new \InvalidArgumentException('Missing currency_method definition.');
     } elseif (!method_exists(CurrencyInterface::class, $configuration['currency_method'])) {
         throw new \InvalidArgumentException(sprintf('Method %s does not exist on \\Drupal\\currency\\Entity\\CurrencyInterface.', $configuration['currency_method']));
     }
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->currencyStorage = $currency_storage;
     $this->stringTranslation = $string_translation;
 }
Пример #15
0
 /**
  * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions().
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $modules = system_get_info('module');
     $names = array();
     foreach ($modules as $name => $module) {
         $names[$name] = $module['name'];
     }
     $form['data_module'] = array('#title' => $this->t('Module name'), '#type' => 'select', '#description' => $this->t('The module which sets this user data.'), '#default_value' => $this->options['data_module'], '#options' => $names);
     $form['data_name'] = array('#title' => $this->t('Name'), '#type' => 'textfield', '#description' => $this->t('The name of the data key.'), '#default_value' => $this->options['data_name']);
 }
Пример #16
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     foreach ($this->formats as $key => $item) {
         $options[$key] = implode('/', $item);
     }
     $form['type'] = array('#type' => 'select', '#title' => $this->t('Output format'), '#options' => $options, '#default_value' => $this->options['type']);
     $form['type_custom_true'] = array('#type' => 'textfield', '#title' => $this->t('Custom output for TRUE'), '#default_value' => $this->options['type_custom_true'], '#states' => array('visible' => array('select[name="options[type]"]' => array('value' => 'custom'))));
     $form['type_custom_false'] = array('#type' => 'textfield', '#title' => $this->t('Custom output for FALSE'), '#default_value' => $this->options['type_custom_false'], '#states' => array('visible' => array('select[name="options[type]"]' => array('value' => 'custom'))));
     $form['not'] = array('#type' => 'checkbox', '#title' => $this->t('Reverse'), '#description' => $this->t('If checked, true will be displayed as false.'), '#default_value' => $this->options['not']);
     parent::buildOptionsForm($form, $form_state);
 }
Пример #17
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $modules = $this->moduleHandler->getModuleList();
     $names = array();
     foreach (array_keys($modules) as $name) {
         $names[$name] = $this->moduleHandler->getName($name);
     }
     $form['data_module'] = array('#title' => $this->t('Module name'), '#type' => 'select', '#description' => $this->t('The module which sets this user data.'), '#default_value' => $this->options['data_module'], '#options' => $names);
     $form['data_name'] = array('#title' => $this->t('Name'), '#type' => 'textfield', '#description' => $this->t('The name of the data key.'), '#default_value' => $this->options['data_name']);
 }
Пример #18
0
 /**
  * {@inheritdoc}
  */
 public function preRender(&$values)
 {
     parent::preRender($values);
     // If the view is using a table style, provide a placeholder for a
     // "select all" checkbox.
     if (!empty($this->view->style_plugin) && $this->view->style_plugin instanceof Table) {
         // Add the tableselect css classes.
         $this->options['element_label_class'] .= 'select-all';
         // Hide the actual label of the field on the table header.
         $this->options['label'] = '';
     }
 }
Пример #19
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     if (!empty($this->definition['float'])) {
         $form['set_precision'] = array('#type' => 'checkbox', '#title' => $this->t('Round'), '#description' => $this->t('If checked, the number will be rounded.'), '#default_value' => $this->options['set_precision']);
         $form['precision'] = array('#type' => 'textfield', '#title' => $this->t('Precision'), '#default_value' => $this->options['precision'], '#description' => $this->t('Specify how many digits to print after the decimal point.'), '#states' => array('visible' => array(':input[name="options[set_precision]"]' => array('checked' => TRUE))), '#size' => 2);
         $form['decimal'] = array('#type' => 'textfield', '#title' => $this->t('Decimal point'), '#default_value' => $this->options['decimal'], '#description' => $this->t('What single character to use as a decimal point.'), '#size' => 2);
     }
     $form['separator'] = array('#type' => 'select', '#title' => $this->t('Thousands marker'), '#options' => array('' => $this->t('- None -'), ',' => $this->t('Comma'), ' ' => $this->t('Space'), '.' => $this->t('Decimal'), '\'' => $this->t('Apostrophe')), '#default_value' => $this->options['separator'], '#description' => $this->t('What single character to use as the thousands separator.'), '#size' => 2);
     $form['format_plural'] = array('#type' => 'checkbox', '#title' => $this->t('Format plural'), '#description' => $this->t('If checked, special handling will be used for plurality.'), '#default_value' => $this->options['format_plural']);
     $form['format_plural_singular'] = array('#type' => 'textfield', '#title' => $this->t('Singular form'), '#default_value' => $this->options['format_plural_singular'], '#description' => $this->t('Text to use for the singular form.'), '#states' => array('visible' => array(':input[name="options[format_plural]"]' => array('checked' => TRUE))));
     $form['format_plural_plural'] = array('#type' => 'textfield', '#title' => $this->t('Plural form'), '#default_value' => $this->options['format_plural_plural'], '#description' => $this->t('Text to use for the plural form, @count will be replaced with the value.'), '#states' => array('visible' => array(':input[name="options[format_plural]"]' => array('checked' => TRUE))));
     $form['prefix'] = array('#type' => 'textfield', '#title' => $this->t('Prefix'), '#default_value' => $this->options['prefix'], '#description' => $this->t('Text to put before the number, such as currency symbol.'));
     $form['suffix'] = array('#type' => 'textfield', '#title' => $this->t('Suffix'), '#default_value' => $this->options['suffix'], '#description' => $this->t('Text to put after the number, such as currency symbol.'));
     parent::buildOptionsForm($form, $form_state);
 }
Пример #20
0
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $date_formats = array();
     foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) {
         $date_formats[$machine_name] = $this->t('@name format: @date', array('@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)));
     }
     $form['date_format'] = array('#type' => 'select', '#title' => $this->t('Date format'), '#options' => $date_formats + array('custom' => $this->t('Custom'), 'raw time ago' => $this->t('Time ago'), 'time ago' => $this->t('Time ago (with "ago" appended)'), 'raw time hence' => $this->t('Time hence'), 'time hence' => $this->t('Time hence (with "hence" appended)'), 'raw time span' => $this->t('Time span (future dates have "-" prepended)'), 'inverse time span' => $this->t('Time span (past dates have "-" prepended)'), 'time span' => $this->t('Time span (with "ago/hence" appended)')), '#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small');
     $form['custom_date_format'] = array('#type' => 'textfield', '#title' => $this->t('Custom date format'), '#description' => $this->t('If "Custom", see <a href="http://us.php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.'), '#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '');
     // Setup #states for all possible date_formats on the custom_date_format form element.
     foreach (array('custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span') as $custom_date_possible) {
         $form['custom_date_format']['#states']['visible'][] = array(':input[name="options[date_format]"]' => array('value' => $custom_date_possible));
     }
     $form['timezone'] = array('#type' => 'select', '#title' => $this->t('Timezone'), '#description' => $this->t('Timezone to be used for date output.'), '#options' => array('' => $this->t('- Default site/user timezone -')) + system_time_zones(FALSE), '#default_value' => $this->options['timezone']);
     foreach (array_merge(array('custom'), array_keys($date_formats)) as $timezone_date_formats) {
         $form['timezone']['#states']['visible'][] = array(':input[name="options[date_format]"]' => array('value' => $timezone_date_formats));
     }
     parent::buildOptionsForm($form, $form_state);
 }
Пример #21
0
 /**
  * Prefetch statistics for all jobs.
  */
 public function preRender(&$values)
 {
     parent::preRender($values);
     // In case of jobs or tasks, pre-fetch the statistics in a single query and
     // add them to the static cache.
     if ($this->getEntityType() == 'tmgmt_job') {
         $tjids = array();
         foreach ($values as $value) {
             // Skip loading data for continuous jobs.
             if ($this->getEntity($value)->isContinuous()) {
                 continue;
             }
             $tjids[] = $this->getValue($value);
         }
         tmgmt_job_statistics_load($tjids);
     } elseif ($this->getEntityType() == 'tmgmt_task') {
         $tltids = array();
         foreach ($values as $value) {
             $tltids[] = $value->tjid;
         }
         tmgmt_local_task_statistics_load($tltids);
     }
 }
Пример #22
0
 /**
  * Provide link to file option
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['link_to_file'] = array('#title' => $this->t('Link this field to download the file'), '#description' => $this->t("Enable to override this field's links."), '#type' => 'checkbox', '#default_value' => !empty($this->options['link_to_file']));
     parent::buildOptionsForm($form, $form_state);
 }
Пример #23
0
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['text'] = array('#type' => 'textfield', '#title' => $this->t('Text to display'), '#default_value' => $this->options['text']);
     parent::buildOptionsForm($form, $form_state);
 }
Пример #24
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['extension_detect_tar'] = array('#type' => 'checkbox', '#title' => t('Detect if tar is part of the extension'), '#description' => t("See if the previous extension is '.tar' and if so, add that, so we see 'tar.gz' or 'tar.bz2' instead of just 'gz'."), '#default_value' => $this->options['extension_detect_tar']);
 }
Пример #25
0
 /**
  * {@inheritdoc}
  */
 protected function defineOptions()
 {
     $options = parent::defineOptions();
     $options['link_to_user'] = array('default' => TRUE);
     return $options;
 }
Пример #26
0
  /**
   * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::init().
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);

    $this->additional_fields['profile_id'] = 'profile_id';
  }
Пример #27
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['native_language'] = array('#title' => $this->t('Display in native language'), '#type' => 'checkbox', '#default_value' => $this->options['native_language']);
 }
Пример #28
0
 /**
  * Tests the trimText method.
  */
 public function testTrimText()
 {
     // Test unicode. See https://www.drupal.org/node/513396#comment-2839416.
     $text = array('Tuy nhiên, những hi vọng', 'Giả sử chúng tôi có 3 Apple', 'siêu nhỏ này là bộ xử lý', 'Di động của nhà sản xuất Phần Lan', 'khoảng cách từ đại lí đến', 'của hãng bao gồm ba dòng', 'сд асд асд ас', 'асд асд асд ас');
     // Just test maxlength without word boundary.
     $alter = array('max_length' => 10);
     $expect = array('Tuy nhiên,', 'Giả sử chú', 'siêu nhỏ n', 'Di động củ', 'khoảng các', 'của hãng b', 'сд асд асд', 'асд асд ас');
     foreach ($text as $key => $line) {
         $result_text = FieldPluginBase::trimText($alter, $line);
         $this->assertEqual($result_text, $expect[$key]);
     }
     // Test also word_boundary
     $alter['word_boundary'] = TRUE;
     $expect = array('Tuy nhiên', 'Giả sử', 'siêu nhỏ', 'Di động', 'khoảng', 'của hãng', 'сд асд', 'асд асд');
     foreach ($text as $key => $line) {
         $result_text = FieldPluginBase::trimText($alter, $line);
         $this->assertEqual($result_text, $expect[$key]);
     }
 }
Пример #29
0
 /**
  * {@inheritdoc}
  */
 public function preRender(&$values)
 {
     parent::preRender($values);
     $entity_ids_per_type = array();
     foreach ($values as $value) {
         if ($type = $this->getValue($value, 'type')) {
             $entity_ids_per_type[$type][] = $this->getValue($value);
         }
     }
     foreach ($entity_ids_per_type as $type => $ids) {
         $this->loadedReferencers[$type] = $this->entityManager->getStorage($type)->loadMultiple($ids);
     }
 }
Пример #30
0
 /**
  * Provide link to taxonomy option
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['link_to_taxonomy'] = array('#title' => t('Link this field to its taxonomy term page'), '#description' => t("Enable to override this field's links."), '#type' => 'checkbox', '#default_value' => !empty($this->options['link_to_taxonomy']));
     $form['convert_spaces'] = array('#title' => t('Convert spaces in term names to hyphens'), '#description' => t('This allows links to work with Views taxonomy term arguments.'), '#type' => 'checkbox', '#default_value' => !empty($this->options['convert_spaces']));
     parent::buildOptionsForm($form, $form_state);
 }