Esempio n. 1
0
  public function settingsForm(array $form, FormStateInterface $form_state) {
    $elements = parent::settingsForm($form, $form_state);

    $elements['keep_pdfjs'] = array(
      '#type' => 'checkbox',
      '#title' => t('Always use pdf.js'),
      '#default_value' => $this->getSetting('keep_pdfjs'),
      '#description' => t("Use pdf.js even the browser has Adobe Reader Plugin, WebKit PDF Reader for Safari or the PDF Reader for Chrome (Chrome's default alternative to the Adobe Reader Plugin) installed."),
    );

    $elements['width'] = array(
      '#type' => 'textfield',
      '#title' => 'Width',
      '#default_value' => $this->getSetting('width'),
      '#description' => t('Width of the viewer. Ex: 250px or 100%'),
    );

    $elements['height'] = array(
      '#type' => 'textfield',
      '#title' => 'Height',
      '#default_value' => $this->getSetting('height'),
      '#description' => t('Height of the viewer. Ex: 250px or 100%'),
    );
    return $elements;
  }
 /**
  * {@inheritdoc}
  *
  * @see ::prepareView()
  * @see ::getEntitiestoView()
  */
 public function view(FieldItemListInterface $items, $langcode = NULL)
 {
     $elements = parent::view($items, $langcode);
     $field_level_access_cacheability = new CacheableMetadata();
     // Try to map the cacheability of the access result that was set at
     // _accessCacheability in getEntitiesToView() to the corresponding render
     // subtree. If no such subtree is found, then merge it with the field-level
     // access cacheability.
     foreach ($items as $delta => $item) {
         // Ignore items for which access cacheability could not be determined in
         // prepareView().
         if (!empty($item->_accessCacheability)) {
             if (isset($elements[$delta])) {
                 CacheableMetadata::createFromRenderArray($elements[$delta])->merge($item->_accessCacheability)->applyTo($elements[$delta]);
             } else {
                 $field_level_access_cacheability = $field_level_access_cacheability->merge($item->_accessCacheability);
             }
         }
     }
     // Apply the cacheability metadata for the inaccessible entities and the
     // entities for which the corresponding render subtree could not be found.
     // This causes the field to be rendered (and cached) according to the cache
     // contexts by which the access results vary, to ensure only users with
     // access to this field can view it. It also tags this field with the cache
     // tags on which the access results depend, to ensure users that cannot view
     // this field at the moment will gain access once any of those cache tags
     // are invalidated.
     $field_level_access_cacheability->applyTo($elements);
     return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $form['check_in_date_format'] = array('#type' => 'textfield', '#title' => $this->t('Check-in date/time format'), '#description' => $this->t('See <a href=":url" target="_blank">the documentation for PHP date formats</a>.', [':url' => 'http://php.net/manual/function.date.php']), '#default_value' => $this->getSetting('check_in_date_format'));
     $form['check_out_date_format'] = array('#type' => 'textfield', '#title' => $this->t('Check-out date/time format'), '#description' => $this->t('See <a href=":url" target="_blank">the documentation for PHP date formats</a>.', [':url' => 'http://php.net/manual/function.date.php']), '#default_value' => $this->getSetting('check_out_date_format'));
     return $form;
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $entity_type = $this->entityManager->getDefinition($this->fieldDefinition->getTargetEntityTypeId());
     $form['link_to_entity'] = ['#type' => 'checkbox', '#title' => $this->t('Link to the @entity_label', ['@entity_label' => $entity_type->getLabel()]), '#default_value' => $this->getSetting('link_to_entity')];
     return $form;
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $settings = $this->getSettings();
     $formatters = $settings['formatters'];
     $this->prepareFormatters($this->fieldDefinition->getType(), $formatters, FALSE);
     $elements['#attached']['library'][] = 'fallback_formatter/admin';
     $parents = array('fields', $this->fieldDefinition->getName(), 'settings_edit_form', 'settings', 'formatters');
     // Filter status.
     $elements['formatters']['status'] = array('#type' => 'item', '#title' => t('Enabled formatters'), '#prefix' => '<div class="fallback-formatter-status-wrapper">', '#suffix' => '</div>');
     foreach ($formatters as $name => $options) {
         $elements['formatters']['status'][$name] = array('#type' => 'checkbox', '#title' => $options['label'], '#default_value' => !empty($options['status']), '#parents' => array_merge($parents, array($name, 'status')), '#weight' => $options['weight']);
     }
     // Filter order (tabledrag).
     $elements['formatters']['order'] = array('#type' => 'item', '#title' => t('Formatter processing order'), '#theme' => 'fallback_formatter_settings_order');
     foreach ($formatters as $name => $options) {
         $elements['formatters']['order'][$name]['label'] = array('#markup' => $options['label']);
         $elements['formatters']['order'][$name]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $options['label'])), '#title_display' => 'invisible', '#delta' => 50, '#default_value' => $options['weight'], '#parents' => array_merge($parents, array($name, 'weight')));
         $elements['formatters']['order'][$name]['#weight'] = $options['weight'];
     }
     // Filter settings.
     foreach ($formatters as $name => $options) {
         $formatter_instance = $this->getFormatter($options);
         $settings_form = $formatter_instance->settingsForm($form, $form_state);
         if (!empty($settings_form)) {
             $elements['formatters']['settings'][$name] = array('#type' => 'fieldset', '#title' => $options['label'], '#parents' => array_merge($parents, array($name, 'settings')), '#weight' => $options['weight'], '#group' => 'formatter_settings');
             $elements['formatters']['settings'][$name] += $settings_form;
         }
         $elements['formatters']['settings'][$name]['formatter'] = array('#type' => 'value', '#value' => $name, '#parents' => array_merge($parents, array($name, 'formatter')));
     }
     return $elements;
 }
 /**
  * Constructs an AddressDefaultFormatter object.
  *
  * @param string $plugin_id
  *   The plugin_id for the formatter.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The definition of the field to which the formatter is associated.
  * @param array $settings
  *   The formatter settings.
  * @param string $label
  *   The formatter label display setting.
  * @param string $view_mode
  *   The view mode.
  * @param array $third_party_settings
  *   Any third party settings.
  * @param \CommerceGuys\Addressing\Repository\AddressFormatRepositoryInterface $address_format_repository
  *   The address format repository.
  * @param \CommerceGuys\Addressing\Repository\CountryRepositoryInterface $country_repository
  *   The country repository.
  * @param \CommerceGuys\Addressing\Repository\SubdivisionRepositoryInterface $subdivision_repository
  *   The subdivision repository.
  */
 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AddressFormatRepositoryInterface $address_format_repository, CountryRepositoryInterface $country_repository, SubdivisionRepositoryInterface $subdivision_repository)
 {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->addressFormatRepository = $address_format_repository;
     $this->countryRepository = $country_repository;
     $this->subdivisionRepository = $subdivision_repository;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $enabled_plugins = array();
     $i = 0;
     foreach ($this->getSetting('provider_plugins') as $plugin_id => $plugin) {
         if ($plugin['checked']) {
             $plugin['weight'] = intval($i++);
             $enabled_plugins[$plugin_id] = $plugin;
         }
     }
     $elements['geocoder_plugins_title'] = array('#type' => 'item', '#weight' => 15, '#title' => t('Geocoder plugin(s)'), '#description' => t('Select the Geocoder plugins to use, you can reorder them. The first one to return a valid value will be used.'));
     $elements['provider_plugins'] = array('#type' => 'table', '#weight' => 20, '#header' => array(array('data' => $this->t('Enabled')), array('data' => $this->t('Weight')), array('data' => $this->t('Name'))), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'provider_plugins-order-weight')));
     $rows = array();
     $count = count($enabled_plugins);
     foreach (Geocoder::getPlugins('Provider') as $plugin_id => $plugin_name) {
         if (isset($enabled_plugins[$plugin_id])) {
             $weight = $enabled_plugins[$plugin_id]['weight'];
         } else {
             $weight = $count++;
         }
         $rows[$plugin_id] = array('#attributes' => array('class' => array('draggable')), '#weight' => $weight, 'checked' => array('#type' => 'checkbox', '#default_value' => isset($enabled_plugins[$plugin_id]) ? 1 : 0), 'weight' => array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $plugin_id)), '#title_display' => 'invisible', '#default_value' => $weight, '#attributes' => array('class' => array('provider_plugins-order-weight'))), 'name' => array('#plain_text' => $plugin_name));
     }
     uasort($rows, function ($a, $b) {
         return strcmp($a['#weight'], $b['#weight']);
     });
     foreach ($rows as $plugin_id => $row) {
         $elements['provider_plugins'][$plugin_id] = $row;
     }
     $elements['dumper_plugin'] = array('#type' => 'select', '#weight' => 25, '#title' => 'Output format', '#default_value' => $this->getSetting('dumper_plugin'), '#options' => Geocoder::getPlugins('dumper'), '#description' => t('Set the output format of the value. Ex, for a geofield, the format must be set to WKT.'));
     return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $elements['image_style'] = array('#type' => 'select', '#title' => t('Image style'), '#options' => image_style_options(FALSE), '#default_value' => $this->getSetting('image_style'), '#empty_option' => t('None (original image)'));
     $link_types = array('content' => t('Content'), 'youtube' => t('YouTube'));
     $elements['image_link'] = array('#title' => t('Link image to'), '#type' => 'select', '#default_value' => $this->getSetting('image_link'), '#empty_option' => t('Nothing'), '#options' => $link_types);
     return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $options = \Drupal::service('geophp.geophp')->getAdapterMap();
     unset($options['google_geocode']);
     $elements['output_format'] = array('#title' => t('Output Format'), '#type' => 'select', '#default_value' => $this->getSetting('output_format'), '#options' => $options, '#required' => TRUE);
     return $elements;
 }
Esempio n. 10
0
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = parent::settingsSummary();
     $format = $this->getSetting('flag_display');
     $formats = $this->getOutputFormats();
     $summary[] = $formats[$format];
     return $summary;
 }
Esempio n. 11
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $form['show_quantity'] = ['#type' => 'checkbox', '#title' => t('Display a quantity input field on the add to cart form.'), '#default_value' => $this->getSetting('show_quantity')];
     $form['default_quantity'] = ['#type' => 'number', '#title' => t('Default quantity'), '#default_value' => $this->getSetting('default_quantity'), '#min' => 1, '#max' => 9999];
     $form['combine'] = ['#type' => 'checkbox', '#title' => t('Attempt to combine line items containing the same product variation.'), '#description' => t('The line item type, referenced product variation, and data from fields exposed on the Add to Cart form must all match to combine.'), '#default_value' => $this->getSetting('combine')];
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $field_settings = $this->getFieldSettings();
     $settings = $this->getSettings();
     $form['show_interest_groups'] = array('#title' => t('Show Interest Groups'), '#type' => 'checkbox', '#description' => $field_settings['show_interest_groups'] ? t('Check to display interest group membership details.') : t('To display Interest Groups, first enable them in the field instance settings.'), '#default_value' => $field_settings['show_interest_groups'] && $settings['show_interest_groups'], '#disabled' => !$field_settings['show_interest_groups']);
     return $form;
 }
 /**
  * Constructs a new instance.
  *
  * @param string $plugin_id
  *   The plugin_id for the formatter.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The definition of the field to which the formatter is associated.
  * @param array $settings
  *   The formatter settings.
  * @param string $label
  *   The formatter label display setting.
  * @param string $view_mode
  *   The view mode.
  * @param array $third_party_settings
  *   Any third party settings.
  */
 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, RequestStack $request_stack, EntityFormBuilderInterface $entity_form_builder, EntityStorageInterface $payment_storage, PaymentLineItemManagerInterface $payment_line_item_manager)
 {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->entityFormBuilder = $entity_form_builder;
     $this->paymentLineItemManager = $payment_line_item_manager;
     $this->paymentStorage = $payment_storage;
     $this->requestStack = $request_stack;
 }
Esempio n. 14
0
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = parent::settingsSummary();
     if ($override = $this->getSetting('timezone_override')) {
         $summary[] = $this->t('Time zone: @timezone', array('@timezone' => $override));
     }
     return $summary;
 }
Esempio n. 15
0
 /**
  * {@inheritdoc}
  */
 public static function defaultSettings()
 {
     $settings = [];
     foreach (['first', 'second'] as $subfield) {
         $settings[$subfield] = ['hidden' => FALSE, 'prefix' => '', 'suffix' => ''];
     }
     return $settings + parent::defaultSettings();
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $elements['trim_length'] = array('#type' => 'number', '#title' => t('Trim link text length'), '#field_suffix' => t('characters'), '#default_value' => $this->getSetting('trim_length'), '#min' => 1, '#description' => t('Leave blank to allow unlimited link text lengths.'));
     $elements['url_only'] = array('#type' => 'checkbox', '#title' => t('URL only'), '#default_value' => $this->getSetting('url_only'), '#access' => $this->getPluginId() == 'link');
     $elements['url_plain'] = array('#type' => 'checkbox', '#title' => t('Show URL as plain text'), '#default_value' => $this->getSetting('url_plain'), '#access' => $this->getPluginId() == 'link', '#states' => array('visible' => array(':input[name*="url_only"]' => array('checked' => TRUE))));
     $elements['rel'] = array('#type' => 'checkbox', '#title' => t('Add rel="nofollow" to links'), '#return_value' => 'nofollow', '#default_value' => $this->getSetting('rel'));
     $elements['target'] = array('#type' => 'checkbox', '#title' => t('Open link in new window'), '#return_value' => '_blank', '#default_value' => $this->getSetting('target'));
     return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $elements['range_separator'] = array('#type' => 'textfield', '#title' => t('Range separator.'), '#default_value' => $this->getSetting('range_separator'), '#weight' => 0);
     $options = array('' => t('- None -'), '.' => t('Decimal point'), ',' => t('Comma'), ' ' => t('Space'), chr(8201) => t('Thin space'), "'" => t('Apostrophe'));
     $elements['thousand_separator'] = array('#type' => 'select', '#title' => t('Thousand marker'), '#options' => $options, '#default_value' => $this->getSetting('thousand_separator'), '#weight' => 1);
     $elements['range_combine'] = array('#type' => 'checkbox', '#title' => t('Combine equivalent values'), '#description' => t('If the FROM and TO values are equal, combine the display into a single value.'), '#default_value' => $this->getSetting('range_combine'), '#weight' => 10);
     $elements['from_prefix_suffix'] = array('#type' => 'checkbox', '#title' => t('Display <em>FROM value</em> prefix and suffix'), '#default_value' => $this->getSetting('from_prefix_suffix'), '#weight' => 11);
     $elements['to_prefix_suffix'] = array('#type' => 'checkbox', '#title' => t('Display <em>TO value</em> prefix and suffix'), '#default_value' => $this->getSetting('to_prefix_suffix'), '#weight' => 12);
     return $elements;
 }
  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {
    $form = parent::settingsForm($form, $form_state);
    // We may decide on alternatives to rendering the view so get settings established
    $form['render_view'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Render View'),
      '#default_value' => $this->getSetting('render_view'),
    ];

    return $form;
  }
Esempio n. 19
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $elements['youtube_size'] = array('#type' => 'select', '#title' => t('YouTube video size'), '#options' => youtube_size_options(), '#default_value' => $this->getSetting('youtube_size'));
     $elements['youtube_width'] = array('#type' => 'textfield', '#title' => t('Width'), '#size' => 10, '#default_value' => $this->getSetting('youtube_width'), '#states' => array('visible' => array(':input[name*="youtube_size"]' => array('value' => 'custom'))));
     $elements['youtube_height'] = array('#type' => 'textfield', '#title' => t('Height'), '#size' => 10, '#default_value' => $this->getSetting('youtube_height'), '#states' => array('visible' => array(':input[name*="youtube_size"]' => array('value' => 'custom'))));
     $elements['youtube_autoplay'] = array('#type' => 'checkbox', '#title' => t('Play video automatically when loaded (autoplay).'), '#default_value' => $this->getSetting('youtube_autoplay'));
     $elements['youtube_loop'] = array('#type' => 'checkbox', '#title' => t('Loop the playback of the video (loop).'), '#default_value' => $this->getSetting('youtube_loop'));
     $elements['youtube_showinfo'] = array('#type' => 'checkbox', '#title' => t('Hide video title and uploader info (showinfo).'), '#default_value' => $this->getSetting('youtube_showinfo'));
     $elements['youtube_controls'] = array('#type' => 'checkbox', '#title' => t('Always hide video controls (controls).'), '#default_value' => $this->getSetting('youtube_controls'));
     $elements['youtube_autohide'] = array('#type' => 'checkbox', '#title' => t('Hide video controls after play begins (autohide).'), '#default_value' => $this->getSetting('youtube_autohide'));
     $elements['youtube_iv_load_policy'] = array('#type' => 'checkbox', '#title' => t('Hide video annotations by default (iv_load_policy).'), '#default_value' => $this->getSetting('youtube_iv_load_policy'));
     return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $entity_text_fields = array();
     foreach ($form['#fields'] as $field) {
         $config = \Drupal::config('field.field.' . $form['#entity_type'] . '.' . $form['#bundle'] . '.' . $field);
         if ($config->get('field_type') == 'string') {
             $entity_text_fields[$field] = $config->get('label');
         }
     }
     $elements['stripe_checkout_description'] = array('#type' => 'select', '#title' => t('Description'), '#options' => array('' => 'none', 'title' => 'Entity title') + $entity_text_fields, '#default_value' => $this->getSetting('stripe_checkout_description'), '#description' => t('Select the source for the description text.'));
     $currency = \Drupal::config('stripe_checkout.settings')->get('stripe_checkout_currency');
     $elements['stripe_checkout_currency'] = array('#type' => 'textfield', '#title' => t('Currency'), '#size' => 3, '#default_value' => $this->getSetting('stripe_checkout_currency'), '#description' => t('Override the default currency for this field only, if you wish. Current default is <strong>@currency</strong>', array('@currency' => $currency)));
     return $elements;
 }
Esempio n. 21
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $elements['embedded_label'] = array('#type' => 'markup', '#markup' => '<h3>' . $this->t('Embedded map') . '</h3>');
     $elements['include_map'] = array('#type' => 'checkbox', '#title' => $this->t('Include embedded dynamic map'), '#default_value' => $this->getSetting('include_map'));
     $elements['include_static_map'] = array('#type' => 'checkbox', '#title' => $this->t('Include embedded static map'), '#default_value' => $this->getSetting('include_static_map'));
     $elements['iframe_width'] = array('#type' => 'number', '#title' => $this->t('Width of embedded map'), '#default_value' => $this->getSetting('iframe_width'), '#description' => $this->t('Note that static maps only accept sizes in pixels'), '#min' => 1, '#step' => 1);
     $elements['iframe_height'] = array('#type' => 'number', '#title' => $this->t('Height of embedded map'), '#default_value' => $this->getSetting('iframe_height'), '#description' => $this->t('Note that static maps only accept sizes in pixels'), '#min' => 1, '#step' => 1);
     $elements['link_label'] = array('#type' => 'markup', '#markup' => '<h3>' . $this->t('Link to map') . '</h3>');
     $elements['include_link'] = array('#type' => 'checkbox', '#title' => $this->t('Include link to map'), '#default_value' => $this->getSetting('include_link'));
     $elements['link_text'] = array('#type' => 'textfield', '#title' => $this->t('Link text'), '#default_value' => $this->getSetting('link_text'), '#description' => $this->t("Enter the text to use for the link to the map, or enter 'use_address' (without the quotes) to use the entered address text as the link text"));
     $elements['generic_label'] = array('#type' => 'markup', '#markup' => '<h3>' . $this->t('General settings') . '</h3>');
     $elements['zoom_level'] = array('#type' => 'select', '#options' => array(1 => $this->t('1 - Minimum'), 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => $this->t('14 - Default'), 15 => 15, 16 => 16, 17 => 17, 18 => 18, 19 => 19, 20 => $this->t('20 - Maximum')), '#title' => $this->t('Zoom level'), '#default_value' => $this->getSetting('zoom_level'));
     $elements['information_bubble'] = array('#type' => 'checkbox', '#title' => $this->t('Show information bubble'), '#default_value' => $this->getSetting('information_bubble'), '#description' => $this->t('If checked, the information bubble for the marker will be displayed when the embedded or linked map loads.'));
     $elements['include_text'] = array('#type' => 'checkbox', '#title' => $this->t('Include original address text'), '#default_value' => $this->getSetting('include_text'));
     $elements['map_type'] = array('#type' => 'select', '#title' => $this->t('Map type'), '#description' => $this->t('Choose a default map type for embedded and linked maps'), '#options' => array('m' => $this->t('Map'), 'k' => $this->t('Satellite'), 'h' => $this->t('Hybrid'), 'p' => $this->t('Terrain')), '#default_value' => $this->getSetting('map_type'));
     $elements['langcode'] = array('#type' => 'textfield', '#title' => $this->t('Language'), '#default_value' => $this->getSetting('langcode'), '#description' => $this->t("Enter a two-letter language code that Google Maps can recognize, or enter 'page' (without the quotes) to use the current page's language code"));
     return $elements;
 }
Esempio n. 22
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $formats = [];
     foreach ($this->getOutputFormats() as $format_name => $format) {
         if (is_array($format)) {
             if ($format_name == 'default') {
                 $formats[$format_name] = $this->t('Field settings (@on_label / @off_label)', array('@on_label' => $format[0], '@off_label' => $format[1]));
             } else {
                 $formats[$format_name] = $this->t('@on_label / @off_label', array('@on_label' => $format[0], '@off_label' => $format[1]));
             }
         } else {
             $formats[$format_name] = $format;
         }
     }
     $form['format'] = ['#type' => 'select', '#title' => $this->t('Output format'), '#default_value' => $this->getSetting('format'), '#options' => $formats];
     $form['format_custom_true'] = ['#type' => 'textfield', '#title' => $this->t('Custom output for TRUE'), '#default_value' => $this->getSetting('format_custom_true'), '#states' => ['visible' => ['select[name="fields[field_boolean][settings_edit_form][settings][format]"]' => ['value' => 'custom']]]];
     $form['format_custom_false'] = ['#type' => 'textfield', '#title' => $this->t('Custom output for FALSE'), '#default_value' => $this->getSetting('format_custom_false'), '#states' => ['visible' => ['select[name="fields[field_boolean][settings_edit_form][settings][format]"]' => ['value' => 'custom']]]];
     return $form;
 }
Esempio n. 23
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $field_name = $this->fieldDefinition->getName();
     $elements['format'] = array('#type' => 'select', '#title' => t('Name format'), '#default_value' => $this->getSetting('format'), '#options' => name_get_custom_format_options(), '#required' => TRUE);
     $elements['markup'] = array('#type' => 'checkbox', '#title' => t('Markup'), '#default_value' => $this->getSetting('markup'), '#description' => t('This option wraps the individual components of the name in SPAN elements with corresponding classes to the component.'));
     $elements['output'] = array('#type' => 'radios', '#title' => t('Output'), '#default_value' => $this->getSetting('output'), '#options' => _name_formatter_output_options(), '#description' => t('This option provides additional options for rendering the field. <strong>Normally, using the "Raw value" option would be a security risk.</strong>'), '#required' => TRUE);
     $elements['multiple'] = array('#type' => 'radios', '#title' => t('Multiple format options'), '#default_value' => $this->getSetting('multiple'), '#options' => _name_formatter_multiple_options(), '#required' => TRUE);
     $base = array('#states' => array('visible' => array(':input[name="fields[' . $field_name . '][settings_edit_form][settings][multiple]"]' => array('value' => 'inline_list'))), '#prefix' => '<div style="padding: 0 2em;">', '#suffix' => '</div>');
     // We can not nest this field, so use a prefix / suffix with padding to help
     // to provide context.
     $elements['multiple_delimiter'] = $base + array('#type' => 'textfield', '#title' => t('Delimiter'), '#default_value' => $this->getSetting('multiple_delimiter'), '#description' => t('This specifies the delimiter between the second to last and the last name.'));
     $elements['multiple_and'] = $base + array('#type' => 'radios', '#title' => t('Last delimiter type'), '#options' => array('text' => t('Textual (and)'), 'symbol' => t('Ampersand (&amp;)')), '#default_value' => $this->getSetting('multiple_and'), '#description' => t('This specifies the delimiter between the second to last and the last name.'));
     $elements['multiple_delimiter_precedes_last'] = $base + array('#type' => 'radios', '#title' => t('Standard delimiter precedes last delimiter'), '#options' => array('never' => t('Never (i.e. "J. Doe and T. Williams")'), 'always' => t('Always (i.e. "J. Doe<strong>,</strong> and T. Williams")'), 'contextual' => t('Contextual (i.e. "J. Doe and T. Williams" <em>or</em> "J. Doe, S. Smith<strong>,</strong> and T. Williams")')), '#default_value' => $this->getSetting('multiple_delimiter_precedes_last'), '#description' => t('This specifies the delimiter between the second to last and the last name. Contextual means that the delimiter is only included for lists with three or more names.'));
     $options = range(1, 20);
     $options = array_combine($options, $options);
     $elements['multiple_el_al_min'] = $base + array('#type' => 'select', '#title' => t('Reduce list and append <em>el al</em>'), '#options' => array(0 => t('Never reduce')) + $options, '#default_value' => $this->getSetting('multiple_el_al_min'), '#description' => t('This specifies a limit on the number of names to display. After this limit, names are removed and the abbrivation <em>et al</em> is appended. This Latin abbrivation of <em>et alii</em> means "and others".'));
     $elements['multiple_el_al_first'] = $base + array('#type' => 'select', '#title' => t('Number of names to display when using <em>el al</em>'), '#options' => $options, '#default_value' => $this->getSetting('multiple_el_al_first'));
     return $elements;
 }
Esempio n. 24
0
 public function settingsForm(array $form, FormStateInterface $form_state) {
   $elements = parent::settingsForm($form, $form_state);
   $elements['scale'] = array(
     '#type' => 'textfield',
     '#title' => t('Set the scale of PDF pages'),
     '#default_value' => $this->getSetting('scale'),
   );
   $elements['width'] = array(
     '#type' => 'textfield',
     '#title' => 'Width',
     '#default_value' => $this->getSetting('width'),
     '#description' => t('Width of the viewer. Ex: 250px or 100%'),
   );
   $elements['height'] = array(
     '#type' => 'textfield',
     '#title' => 'Height',
     '#default_value' => $this->getSetting('height'),
     '#description' => t('Height of the viewer. Ex: 250px or 100%'),
   );
   return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public static function defaultSettings()
 {
     return array('field_empty_setting' => '') + parent::defaultSettings();
 }
 /**
  * Constructs a new CommentDefaultFormatter.
  *
  * @param string $plugin_id
  *   The plugin_id for the formatter.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The definition of the field to which the formatter is associated.
  * @param array $settings
  *   The formatter settings.
  * @param string $label
  *   The formatter label display setting.
  * @param string $view_mode
  *   The view mode.
  * @param array $third_party_settings
  *   Third party settings.
  * @param \Drupal\Core\Session\AccountInterface $current_user
  *   The current user.
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager
  * @param \Drupal\Core\Entity\EntityFormBuilderInterface $entity_form_builder
  *   The entity form builder.
  */
 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AccountInterface $current_user, EntityManagerInterface $entity_manager, EntityFormBuilderInterface $entity_form_builder)
 {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->viewBuilder = $entity_manager->getViewBuilder('comment');
     $this->storage = $entity_manager->getStorage('comment');
     $this->currentUser = $current_user;
     $this->entityManager = $entity_manager;
     $this->entityFormBuilder = $entity_form_builder;
 }
 /**
  * {@inheritdoc}
  */
 public static function defaultSettings()
 {
     return array('test_formatter_setting' => 'dummy test string') + parent::defaultSettings();
 }
 /**
  * Constructs a new PricePlainFormatter object.
  *
  * @param string $plugin_id
  *   The plugin_id for the formatter.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The definition of the field to which the formatter is associated.
  * @param array $settings
  *   The formatter settings.
  * @param string $label
  *   The formatter label display setting.
  * @param string $view_mode
  *   The view mode.
  * @param array $third_party_settings
  *   Any third party settings settings.
  * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
  *   The entity type manager.
  */
 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager)
 {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->currencyStorage = $entity_type_manager->getStorage('commerce_currency');
 }
Esempio n. 29
0
 /**
  * Constructs a new DateTimeDefaultFormatter.
  *
  * @param string $plugin_id
  *   The plugin_id for the formatter.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The definition of the field to which the formatter is associated.
  * @param array $settings
  *   The formatter settings.
  * @param string $label
  *   The formatter label display setting.
  * @param string $view_mode
  *   The view mode.
  * @param array $third_party_settings
  *   Third party settings.
  * @param \Drupal\Core\Datetime\Date $date_formatter
  *   The date formatter service.
  * @param \Drupal\Core\Entity\EntityStorageInterface $date_storage
  *   The date storage.
  */
 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, DateFormatter $date_formatter, EntityStorageInterface $date_storage)
 {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->dateFormatter = $date_formatter;
     $this->dateStorage = $date_storage;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = parent::settingsSummary();
     $future_date = strtotime('1 year 1 month 1 week 1 day 1 hour 1 minute');
     $past_date = strtotime('-1 year -1 month -1 week -1 day -1 hour -1 minute');
     $summary[] = $this->t('Future date: %display', array('%display' => $this->formatTimestamp($future_date)));
     $summary[] = $this->t('Past date: %display', array('%display' => $this->formatTimestamp($past_date)));
     return $summary;
 }