Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     // Get all image and text fields.
     $image_options = [];
     $caption_options = [];
     $transitions_options = ['Move' => ['L' => 'L', 'R' => 'R', 'T' => 'T', 'B' => 'B', 'TL' => 'TL', 'TR' => 'TR', 'BL' => 'BL', 'BR' => 'BR'], 'Move|IB' => ['L|IB' => 'L|IB', 'R|IB' => 'R|IB', 'T|IB' => 'T|IB', 'B|IB' => 'B|IB', 'TL|IB' => 'TL|IB', 'TR|IB' => 'TR|IB', 'BL|IB' => 'BL|IB', 'BR|IB' => 'BR|IB'], 'Move|IE' => ['L|IE' => 'L|IE', 'R|IE' => 'R|IE', 'T|IE' => 'T|IE', 'B|IE' => 'B|IE', 'TL|IE' => 'TL|IE', 'TR|IE' => 'TR|IE', 'BL|IE' => 'BL|IE', 'BR|IE' => 'BR|IE'], 'Move|EP' => ['L|EP' => 'L|EP', 'R|EP' => 'R|EP', 'T|EP' => 'T|EP', 'B|EP' => 'B|EP', 'TL|EP' => 'TL|EP', 'TR|EP' => 'TR|EP', 'BL|EP' => 'BL|EP', 'BR|EP' => 'BR|EP'], 'Move with Rotate' => ['L*' => 'L*', 'R*' => 'R*', 'T*' => 'T*', 'B*' => 'B*', 'TL*' => 'TL*', 'TR*' => 'TR*', 'BL*' => 'BL*', 'BR*' => 'BR*'], 'Move with Rotate IE' => ['L*IE' => 'L*IE', 'R*IE' => 'R*IE', 'T*IE' => 'T*IE', 'B*IE' => 'B*IE', 'TL*IE' => 'TL*IE', 'TR*IE' => 'TR*IE', 'BL*IE' => 'BL*IE', 'BR*IE' => 'BR*IE'], 'Move with Rotate IB' => ['L*IB' => 'L*IB', 'R*IB' => 'R*IB', 'T*IB' => 'T*IB', 'B*IB' => 'B*IB', 'TL*IB' => 'TL*IB', 'TR*IB' => 'TR*IB', 'BL*IB' => 'BL*IB', 'BR*IB' => 'BR*IB'], 'Move with Rotate IW' => ['L*IW' => 'L*IW', 'R*IW' => 'R*IW', 'T*IW' => 'T*IW', 'B*IW' => 'B*IW', 'TL*IW' => 'TL*IW', 'TR*IW' => 'TR*IW', 'BL*IW' => 'BL*IW', 'BR*IW' => 'BR*IW'], 'Move IE with Rotate IE' => ['L*IE*IE' => 'L*IE*IE', 'R*IE*IE' => 'R*IE*IE', 'T*IE*IE' => 'T*IE*IE', 'B*IE*IE' => 'B*IE*IE', 'TL*IE*IE' => 'TL*IE*IE', 'TR*IE*IE' => 'TR*IE*IE', 'BL*IE*IE' => 'BL*IE*IE', 'BR*IE*IE' => 'BR*IE*IE'], 'Clip' => ['CLIP' => 'CLIP', 'CLIP|LR' => 'CLIP|LR', 'CLIP|TB' => 'CLIP|TB', 'CLIP|L' => 'CLIP|L', 'CLIP|R' => 'CLIP|R', 'CLIP|T' => 'CLIP|T', 'CLIP|B' => 'CLIP|B'], 'MClip' => ['MCLIP|L' => 'MCLIP|L', 'MCLIP|R' => 'MCLIP|R', 'MCLIP|T' => 'MCLIP|T', 'MCLIP|B' => 'MCLIP|B'], 'Zoom' => ['ZM' => 'ZM', 'ZM|P30' => 'ZM|P30', 'ZM|P50' => 'ZM|P50', 'ZM|P70' => 'ZM|P70', 'ZM|P80' => 'ZM|P80', 'ZMF|2' => 'ZMF|2', 'ZMF|3' => 'ZMF|3', 'ZMF|4' => 'ZMF|4', 'ZMF|5' => 'ZMF|5', 'ZMF|10' => 'ZMF|10', 'ZML|L' => 'ZML|L', 'ZML|R' => 'ZML|R', 'ZML|T' => 'ZML|T', 'ZML|B' => 'ZML|B', 'ZML|TL' => 'ZML|TL', 'ZML|TR' => 'ZML|TR', 'ZML|BL' => 'ZML|BL', 'ZML|BR' => 'ZML|BR', 'ZML|IE|L' => 'ZML|IE|L', 'ZML|IE|R' => 'ZML|IE|R', 'ZML|IE|T' => 'ZML|IE|T', 'ZML|IE|B' => 'ZML|IE|B', 'ZML|IE|TL' => 'ZML|IE|TL', 'ZML|IE|TR' => 'ZML|IE|TR', 'ZML|IE|BL' => 'ZML|IE|BL', 'ZML|IE|BR' => 'ZML|IE|BR', 'ZMS|L' => 'ZMS|L', 'ZMS|R' => 'ZMS|R', 'ZMS|T' => 'ZMS|T', 'ZMS|B' => 'ZMS|B', 'ZMS|TL' => 'ZMS|TL', 'ZMS|TR' => 'ZMS|TR', 'ZMS|BL' => 'ZMS|BL', 'ZMS|BR' => 'ZMS|BR']];
     if ($fields = $this->view->display_handler->getOption('fields')) {
         foreach ($fields as $id => $field) {
             switch ($field['type']) {
                 case 'image':
                     $image_options[$id] = $field['id'];
                     break;
                 case 'string':
                     $caption_options[$id] = $field['id'];
                     break;
             }
         }
     }
     $form['image_options'] = array('#type' => 'select', '#title' => $this->t('Image field'), '#description' => $this->t('Select image field.'), '#options' => $image_options, '#default_value' => $this->options['image_options']);
     $form['caption_options'] = array('#type' => 'select', '#title' => $this->t('Caption field'), '#description' => $this->t('Select caption field.'), '#options' => $caption_options, '#default_value' => $this->options['caption_options']);
     $form['play_in_mode'] = ['#type' => 'select', '#title' => $this->t('Play in mode'), '#description' => $this->t('Specifies how captions will play in.'), '#options' => [0 => $this->t('No play'), 1 => $this->t('Goes after main slide played in, play captions in one by one'), 3 => $this->t('Goes after main slide played in, play all captions in parallelly')], '#default_value' => $this->options['play_in_mode']];
     $form['play_in_transition'] = ['#type' => 'select', '#title' => $this->t('Transition'), '#description' => $this->t('Transition.'), '#options' => $transitions_options, '#default_value' => $this->options['play_in_transition']];
     $form['play_out_mode'] = ['#type' => 'select', '#title' => $this->t('Play in mode'), '#description' => $this->t('Specifies how captions will play in.'), '#options' => [0 => $this->t('No play'), 1 => $this->t('Goes after main slide played in, play captions in one by one'), 3 => $this->t('Goes after main slide played in, play all captions in parallelly')], '#default_value' => $this->options['play_out_mode']];
     $form['play_out_transition'] = ['#type' => 'select', '#title' => $this->t('Transition'), '#description' => $this->t('Transition.'), '#options' => $transitions_options, '#default_value' => $this->options['play_out_transition']];
 }
Esempio n. 2
0
 /**
  * Provide a form for setting options.
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $options = $this->displayHandler->getFieldLabels();
     if (empty($this->options['inline'])) {
         $this->options['inline'] = array();
     }
     $form['default_field_elements'] = array('#type' => 'checkbox', '#title' => $this->t('Provide default field wrapper elements'), '#default_value' => $this->options['default_field_elements'], '#description' => $this->t('If not checked, fields that are not configured to customize their HTML elements will get no wrappers at all for their field, label and field + label wrappers. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.'));
     $form['inline'] = array('#type' => 'checkboxes', '#title' => $this->t('Inline fields'), '#options' => $options, '#default_value' => $this->options['inline'], '#description' => $this->t('Inline fields will be displayed next to each other rather than one after another. Note that some fields will ignore this if they are block elements, particularly body fields and other formatted HTML.'), '#states' => array('visible' => array(':input[name="row_options[default_field_elements]"]' => array('checked' => TRUE))));
     $form['separator'] = array('#title' => $this->t('Separator'), '#type' => 'textfield', '#size' => 10, '#default_value' => isset($this->options['separator']) ? $this->options['separator'] : '', '#description' => $this->t('The separator may be placed between inline fields to keep them from squishing up next to each other. You can use HTML in this field.'), '#states' => array('visible' => array(':input[name="row_options[default_field_elements]"]' => array('checked' => TRUE))));
     $form['hide_empty'] = array('#type' => 'checkbox', '#title' => $this->t('Hide empty fields'), '#default_value' => $this->options['hide_empty'], '#description' => $this->t('Do not display fields, labels or markup for fields that are empty.'));
 }
 /**
  * Overrides \Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['field_options'] = array('#type' => 'table', '#header' => array(t('Field'), $this->t('Alias'), $this->t('Raw output')), '#empty' => $this->t('You have no fields. Add some to your view.'), '#tree' => TRUE);
     $options = $this->options['field_options'];
     if ($fields = $this->view->display_handler->getOption('fields')) {
         foreach ($fields as $id => $field) {
             $form['field_options'][$id]['field'] = array('#markup' => $id);
             $form['field_options'][$id]['alias'] = array('#title' => $this->t('Alias for @id', array('@id' => $id)), '#title_display' => 'invisible', '#type' => 'textfield', '#default_value' => isset($options[$id]['alias']) ? $options[$id]['alias'] : '', '#element_validate' => array(array($this, 'validateAliasName')));
             $form['field_options'][$id]['raw_output'] = array('#title' => $this->t('Raw output for @id', array('@id' => $id)), '#title_display' => 'invisible', '#type' => 'checkbox', '#default_value' => isset($options[$id]['raw_output']) ? $options[$id]['raw_output'] : '');
         }
     }
 }
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $initial_labels = array('' => $this->t('- None -'));
     $view_fields_labels = $this->displayHandler->getFieldLabels();
     $view_fields_labels = array_merge($initial_labels, $view_fields_labels);
     $form['title_field'] = array('#type' => 'select', '#title' => $this->t('Title field'), '#description' => $this->t('The field that is going to be used as the RSS item title for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['title_field'], '#required' => TRUE);
     $form['link_field'] = array('#type' => 'select', '#title' => $this->t('Link field'), '#description' => $this->t('The field that is going to be used as the RSS item link for each row. This must be a drupal relative path.'), '#options' => $view_fields_labels, '#default_value' => $this->options['link_field'], '#required' => TRUE);
     $form['description_field'] = array('#type' => 'select', '#title' => $this->t('Description field'), '#description' => $this->t('The field that is going to be used as the RSS item description for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['description_field'], '#required' => TRUE);
     $form['creator_field'] = array('#type' => 'select', '#title' => $this->t('Creator field'), '#description' => $this->t('The field that is going to be used as the RSS item creator for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['creator_field'], '#required' => TRUE);
     $form['date_field'] = array('#type' => 'select', '#title' => $this->t('Publication date field'), '#description' => $this->t('The field that is going to be used as the RSS item pubDate for each row. It needs to be in RFC 2822 format.'), '#options' => $view_fields_labels, '#default_value' => $this->options['date_field'], '#required' => TRUE);
     $form['guid_field_options'] = array('#type' => 'details', '#title' => $this->t('GUID settings'), '#open' => TRUE);
     $form['guid_field_options']['guid_field'] = array('#type' => 'select', '#title' => $this->t('GUID field'), '#description' => $this->t('The globally unique identifier of the RSS item.'), '#options' => $view_fields_labels, '#default_value' => $this->options['guid_field_options']['guid_field'], '#required' => TRUE);
     $form['guid_field_options']['guid_field_is_permalink'] = array('#type' => 'checkbox', '#title' => $this->t('GUID is permalink'), '#description' => $this->t('The RSS item GUID is a permalink.'), '#default_value' => $this->options['guid_field_options']['guid_field_is_permalink']);
 }
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $initial_labels = array('' => $this->t('- None -'));
     $view_fields_labels = $this->displayHandler->getFieldLabels();
     $view_fields_labels = array_merge($initial_labels, $view_fields_labels);
     $form['loc_field'] = array('#type' => 'select', '#title' => $this->t('Location'), '#description' => $this->t('The URL to the news (<loc>).'), '#options' => $view_fields_labels, '#default_value' => $this->options['loc_field'], '#required' => TRUE);
     $form['news_publication_name_field'] = array('#type' => 'select', '#title' => $this->t('Name'), '#description' => $this->t('The name of the publication (<news:name>), defaults to the site name.'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_publication_name_field']);
     $form['news_publication_language_field'] = array('#type' => 'select', '#title' => $this->t('Language code'), '#description' => $this->t('The language code (<news:language>). Must be a language code, will use the default language if not provided.'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_publication_language_field']);
     $form['news_access_field'] = array('#type' => 'select', '#title' => $this->t('Access'), '#description' => $this->t('Access information (<news:access>), must be Subscription, Registration or an empty string if access is not restricted.'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_access_field']);
     $form['news_genres_field'] = array('#type' => 'select', '#title' => $this->t('Genres'), '#description' => $this->t('The field that is going to be used as the Google News <news:genres> attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_genres_field']);
     $form['news_publication_date_field'] = array('#type' => 'select', '#title' => $this->t('Publication date'), '#description' => $this->t('The publication date of the news (<news:publication_date>).'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_publication_date_field'], '#required' => TRUE);
     $form['news_title_field'] = array('#type' => 'select', '#title' => $this->t('Title'), '#description' => $this->t('The news title (<news:title>).'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_title_field'], '#required' => TRUE);
     $form['news_keywords_field'] = array('#type' => 'select', '#title' => $this->t('Keywords'), '#description' => $this->t('Keywords or tags for this news (Google News <news:keywords>).'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_keywords_field']);
     $form['news_stock_tickers_field'] = array('#type' => 'select', '#title' => $this->t('Stock tickers'), '#description' => $this->t('Stock ticker references (<news:stock_tickers>)'), '#options' => $view_fields_labels, '#default_value' => $this->options['news_stock_tickers_field']);
     $form['documentation'] = ['#type' => 'item', '#title' => $this->t('Documentation'), '#markup' => $this->t('See <a href="@url">the Google News Sitemap reference</a> for more information', ['@url' => 'https://support.google.com/news/publisher/answer/74288?hl=en#tagdefinitions'])];
 }
Esempio n. 6
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $initial_labels = array('' => $this->t('- None -'));
     $view_fields_labels = $this->displayHandler->getFieldLabels();
     $view_fields_labels = array_merge($initial_labels, $view_fields_labels);
     $types = array('rss' => $this->t('RSS'), 'link' => $this->t('Link'), 'include' => $this->t('Include'));
     $types = array_merge($initial_labels, $types);
     $form['type_field'] = array('#type' => 'select', '#title' => $this->t('Type attribute'), '#description' => $this->t('The type of this row.'), '#options' => $types, '#default_value' => $this->options['type_field']);
     $form['text_field'] = array('#type' => 'select', '#title' => $this->t('Text attribute'), '#description' => $this->t('The field that is going to be used as the OPML text attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['text_field'], '#required' => TRUE);
     $form['created_field'] = array('#type' => 'select', '#title' => $this->t('Created attribute'), '#description' => $this->t('The field that is going to be used as the OPML created attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['created_field']);
     $form['description_field'] = array('#type' => 'select', '#title' => $this->t('Description attribute'), '#description' => $this->t('The field that is going to be used as the OPML description attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['description_field'], '#states' => array('visible' => array(':input[name="row_options[type_field]"]' => array('value' => 'rss'))));
     $form['html_url_field'] = array('#type' => 'select', '#title' => $this->t('HTML URL attribute'), '#description' => $this->t('The field that is going to be used as the OPML htmlUrl attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['html_url_field'], '#states' => array('visible' => array(':input[name="row_options[type_field]"]' => array('value' => 'rss'))));
     $form['language_field'] = array('#type' => 'select', '#title' => $this->t('Language attribute'), '#description' => $this->t('The field that is going to be used as the OPML language attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['language_field'], '#states' => array('visible' => array(':input[name="row_options[type_field]"]' => array('value' => 'rss'))));
     $form['xml_url_field'] = array('#type' => 'select', '#title' => $this->t('XML URL attribute'), '#description' => $this->t('The field that is going to be used as the OPML text attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['xml_url_field'], '#states' => array('visible' => array(':input[name="row_options[type_field]"]' => array('value' => 'rss'))));
     $form['url_field'] = array('#type' => 'select', '#title' => $this->t('URL attribute'), '#description' => $this->t('The field that is going to be used as the OPML url attribute for each row.'), '#options' => $view_fields_labels, '#default_value' => $this->options['url_field'], '#states' => array('visible' => array(':input[name="row_options[type_field]"]' => array(array('value' => 'link'), array('value' => 'include')))));
 }
Esempio n. 7
0
 /**
  * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['test_option'] = array('#title' => t('Test option'), '#type' => 'textfield', '#description' => t('This is a textfield for test_option.'), '#default_value' => $this->options['test_option']);
 }
Esempio n. 8
0
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['view_mode'] = array('#type' => 'select', '#title' => t('Display type'), '#options' => $this->options_form_summary_options(), '#default_value' => $this->options['view_mode']);
     $form['links'] = array('#type' => 'checkbox', '#title' => t('Display links'), '#default_value' => $this->options['links']);
 }
Esempio n. 9
0
 /**
  * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['view_mode'] = array('#type' => 'select', '#options' => \Drupal::entityManager()->getViewModeOptions($this->entityTypeId), '#title' => $this->t('View mode'), '#default_value' => $this->options['view_mode']);
 }
Esempio n. 10
0
 /**
  * Overrides Drupal\views\Plugin\views\row\RowPluginBase::buildOptionsForm().
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['view_mode'] = array('#type' => 'select', '#options' => \Drupal::entityManager()->getViewModeOptions($this->entityTypeId), '#title' => $this->t('View mode'), '#default_value' => $this->options['view_mode']);
     $options = $this->buildRenderingLanguageOptions();
     $form['rendering_language'] = array('#type' => 'select', '#options' => $options, '#title' => $this->t('Rendering language'), '#default_value' => $this->options['rendering_language'], '#access' => $this->languageManager->isMultilingual());
 }
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     /** @var \Drupal\search_api\Datasource\DatasourceInterface $datasource */
     foreach ($this->index->getDatasources() as $datasource_id => $datasource) {
         $bundles = $datasource->getBundles();
         if (!$datasource->getViewModes()) {
             $form['view_modes'][$datasource_id] = array('#type' => 'item', '#title' => $this->t('Default View mode for datasource %name', array('%name' => $datasource->label())), '#description' => $this->t("This datasource doesn't have any view modes available. It is therefore not possible to display results of this datasource using this row plugin."));
             continue;
         }
         foreach ($bundles as $bundle_id => $bundle) {
             $view_modes = $datasource->getViewModes($bundle_id);
             if (!$view_modes) {
                 $form['view_modes'][$datasource_id][$bundle_id] = array('#type' => 'item', '#title' => $this->t('View mode for bundle %name', array('%name' => $bundle['label'])), '#description' => $this->t("This datasource doesn't have any view modes available. It is therefore not possible to display results of this bundle using this row plugin."));
                 continue;
             }
             $form['view_modes'][$datasource_id][$bundle_id] = array('#type' => 'select', '#options' => $view_modes, '#title' => $this->t('View mode for bundle %name', array('%name' => $bundle['label'])), '#default_value' => key($view_modes));
             if (isset($this->options['view_modes'][$datasource_id][$bundle_id])) {
                 $form['view_modes'][$datasource_id][$bundle_id]['#default_value'] = $this->options['view_modes'][$datasource_id][$bundle_id];
             }
         }
     }
 }
Esempio n. 12
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['markup'] = ['#markup' => $this->t("The calendar row plugin will format view results as calendar items. Make sure this display has a 'Calendar' format and uses a 'Date' contextual filter, or this plugin will not work correctly.")];
     $form['colors'] = ['#type' => 'fieldset', '#title' => $this->t('Legend Colors'), '#description' => $this->t('Set a hex color value (like #ffffff) to use in the calendar legend for each content type. Items with empty values will have no stripe in the calendar and will not be added to the legend.')];
     $options = [];
     // @todo Allow strip options for any bundes of any entity type
     if ($this->view->getBaseTables()['node_field_data']) {
         $options['type'] = $this->t('Based on Content Type');
     }
     if (\Drupal::moduleHandler()->moduleExists('taxonomy')) {
         $options['taxonomy'] = $this->t('Based on Taxonomy');
     }
     // If no option is available, stop here.
     if (empty($options)) {
         return;
     }
     $form['colors']['legend'] = ['#title' => $this->t('Stripes'), '#description' => $this->t('Add stripes to calendar items.'), '#type' => 'select', '#options' => $options, '#empty_value' => (string) $this->t('None'), '#default_value' => $this->options['colors']['legend']];
     if ($this->view->getBaseTables()['node_field_data']) {
         $colors = $this->options['colors']['calendar_colors_type'];
         $type_names = node_type_get_names();
         foreach ($type_names as $key => $name) {
             $form['colors']['calendar_colors_type'][$key] = ['#title' => $name, '#default_value' => isset($colors[$key]) ? $colors[$key] : CALENDAR_EMPTY_STRIPE, '#dependency' => ['edit-row-options-colors-legend' => ['type']], '#type' => 'textfield', '#size' => 7, '#maxlength' => 7, '#element_validate' => [[$this, 'validateHexColor']], '#prefix' => '<div class="calendar-colorpicker-wrapper">', '#suffix' => '<div class="calendar-colorpicker"></div></div>', '#attributes' => ['class' => ['edit-calendar-colorpicker']], '#attached' => ['library' => ['calendar/calendar.colorpicker']]] + $this->visibleOnLegendState('type');
         }
     }
     if (\Drupal::moduleHandler()->moduleExists('taxonomy')) {
         // Get the display's field names of taxonomy fields.
         $vocabulary_field_options = [];
         $fields = $this->displayHandler->getOption('fields');
         foreach ($fields as $name => $field_info) {
             // Select the proper field type.
             if ($this->isTermReferenceField($field_info, $this->fieldManager)) {
                 $vocabulary_field_options[$name] = $field_info['label'] ?: $name;
             }
         }
         if (empty($vocabulary_field_options)) {
             return;
         }
         $form['colors']['taxonomy_field'] = ['#title' => t('Term field'), '#type' => !empty($vocabulary_field_options) ? 'select' : 'hidden', '#default_value' => $this->options['colors']['taxonomy_field'], '#empty_value' => (string) $this->t('None'), '#description' => $this->t("Select the taxonomy term field to use when setting stripe colors. This works best for vocabularies with only a limited number of possible terms."), '#options' => $vocabulary_field_options, '#dependency' => ['edit-row-options-colors-legend' => ['taxonomy']]] + $this->visibleOnLegendState('taxonomy');
         if (empty($vocabulary_field_options)) {
             $form['colors']['taxonomy_field']['#options'] = ['' => ''];
             $form['colors']['taxonomy_field']['#suffix'] = $this->t('You must add a term field to this view to use taxonomy stripe values. This works best for vocabularies with only a limited number of possible terms.');
         }
         // Get the Vocabulary names.
         $vocab_vids = [];
         foreach ($vocabulary_field_options as $field_name => $label) {
             // @todo Provide storage manager via Dependency Injection
             $field_config = \Drupal::entityManager()->getStorage('field_config')->loadByProperties(['field_name' => $field_name]);
             // @TODO refactor
             reset($field_config);
             $key = key($field_config);
             $data = \Drupal::config('field.field.' . $field_config[$key]->getOriginalId())->getRawData();
             if ($target_bundles = $data['settings']['handler_settings']['target_bundles']) {
                 // Fields must target bundles set.
                 reset($target_bundles);
                 $vocab_vids[$field_name] = key($target_bundles);
             }
         }
         if (empty($vocab_vids)) {
             return;
         }
         $this->options['colors']['calendar_colors_vocabulary'] = $vocab_vids;
         $form['colors']['calendar_colors_vocabulary'] = ['#title' => t('Vocabulary Legend Types'), '#type' => 'value', '#value' => $vocab_vids] + $this->visibleOnLegendState('taxonomy');
         // Get the Vocabulary term id's and map to colors.
         // @todo Add labels for each Vocabulary.
         $term_colors = $this->options['colors']['calendar_colors_taxonomy'];
         foreach ($vocab_vids as $field_name => $vid) {
             $vocab = \Drupal::entityManager()->getStorage("taxonomy_term")->loadTree($vid);
             foreach ($vocab as $key => $term) {
                 $form['colors']['calendar_colors_taxonomy'][$term->tid] = ['#title' => $this->t($term->name), '#default_value' => isset($term_colors[$term->tid]) ? $term_colors[$term->tid] : CALENDAR_EMPTY_STRIPE, '#access' => !empty($vocabulary_field_options), '#dependency_count' => 2, '#dependency' => ['edit-row-options-colors-legend' => ['taxonomy'], 'edit-row-options-colors-taxonomy-field' => [$field_name]], '#type' => 'textfield', '#size' => 7, '#maxlength' => 7, '#element_validate' => [[$this, 'validateHexColor']], '#prefix' => '<div class="calendar-colorpicker-wrapper">', '#suffix' => '<div class="calendar-colorpicker"></div></div>', '#attributes' => ['class' => ['edit-calendar-colorpicker']], '#attached' => ['library' => ['calendar/calendar.colorpicker']]] + $this->visibleOnLegendState('taxonomy');
             }
         }
     }
 }
Esempio n. 13
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $form['view_mode'] = array('#type' => 'select', '#title' => $this->t('Display type'), '#options' => $this->buildOptionsForm_summary_options(), '#default_value' => $this->options['view_mode']);
 }