/** * Render the given style. */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['type'] = array('#type' => 'radios', '#title' => $this->t('List type'), '#options' => array('ul' => $this->t('Unordered list'), 'ol' => $this->t('Ordered list')), '#default_value' => $this->options['type']); $form['wrapper_class'] = array('#title' => $this->t('Wrapper class'), '#description' => $this->t('The class to provide on the wrapper, outside the list.'), '#type' => 'textfield', '#size' => '30', '#default_value' => $this->options['wrapper_class']); $form['class'] = array('#title' => $this->t('List class'), '#description' => $this->t('The class to provide on the list element itself.'), '#type' => 'textfield', '#size' => '30', '#default_value' => $this->options['class']); }
/** * Validates the view configuration. * Fails if there is a non-image field, or there are more * than one image fields that are not excluded from display. */ function validate() { $errors = parent::validate(); if ($this->view->storage->isNew()) { // Skip validation when the view is being created. // (the default field is a title field, which would fail.) return $errors; } // Get a list of fields that have been added to the display. $fields = $this->displayHandler->handlers['field']; // Check if there is exactly one image field to display. $fields_valid = TRUE; $field_count = 0; foreach ($fields as $key => $field) { // Ignore fields excluded from display. if (!empty($field->options['exclude'])) { continue; } // Determine the field's type. $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($field->definition['entity_type']); $field_type = $field_storage_definitions[$field->field]->getType(); if ($field_type != 'image') { // Cannot display non-image fields. That would break the image grid. $fields_valid = FALSE; break; } $field_count++; } if (!$fields_valid || $field_count > 1) { $errors[] = $this->t('This format can display only one image field and no other fields.'); } return $errors; }
/** * Overrides \Drupal\views\Plugin\views\style\StylePluginBase\StylePluginBase::render(). */ public function render() { if (!empty($this->view->live_preview)) { return parent::render(); } // Group the rows according to the grouping field, if specified. $sets = $this->renderGrouping($this->view->result, $this->options['grouping']); // Grab the alias of the 'id' field added by // entity_reference_plugin_display. $id_field_alias = $this->view->storage->get('base_field'); // @todo We don't display grouping info for now. Could be useful for select // widget, though. $results = array(); $this->view->row_index = 0; foreach ($sets as $records) { foreach ($records as $values) { // Sanitize HTML, remove line breaks and extra whitespace. $output = $this->view->rowPlugin->render($values); $output = drupal_render($output); $results[$values->{$id_field_alias}] = Xss::filterAdmin(preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', $output))); $this->view->row_index++; } } unset($this->view->row_index); return $results; }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['grid_style'] = array('#prefix' => '<h4>Grid Settings</h4>', '#type' => 'select', '#title' => t('Mode'), '#description' => t('Choose grid style:'), '#options' => array('classic' => t('Classic Grid'), 'masonry' => t('Masonry Simple'), 'masonry_resize' => t('Masonry Resize')), '#default_value' => $this->options['grid_style'], '#attributes' => array('class' => array('grid-style'))); $field_options = array(); $fields = \Drupal::entityManager()->getFieldMapByFieldType('image'); foreach ($fields as $field) { foreach ($field as $key => $value) { $field_options[$key] = $key; } } $form['masonry_background'] = array('#type' => 'select', '#title' => t('Image'), '#options' => $field_options, '#default_value' => $this->options['masonry_background'], '#states' => array('visible' => array('.grid-style' => array('value' => 'masonry_resize')))); $form['grid_ratio'] = array('#type' => 'textfield', '#title' => t('Ratio'), '#description' => t('The ratio image'), '#default_value' => $this->options['grid_ratio'], '#states' => array('visible' => array('.grid-style' => array('value' => 'masonry_resize')))); $form['grid_cols_lg'] = array('#type' => 'select', '#title' => t('Large Desktop Items'), '#description' => t('Number of items on large desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_lg']); $form['grid_cols_md'] = array('#type' => 'select', '#title' => t('Desktop Items'), '#description' => t('Number of items on desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_md']); $form['grid_cols_sm'] = array('#type' => 'select', '#title' => t('Tablet Items'), '#description' => t('Number of items on tablet'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_sm']); $form['grid_cols_xs'] = array('#type' => 'select', '#title' => t('Phone Items'), '#description' => t('Number of items on phone'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['grid_cols_xs']); $form['grid_margin'] = array('#type' => 'textfield', '#title' => t('Margin'), '#description' => t('The spacing beetween items'), '#default_value' => $this->options['grid_margin'], '#field_suffix' => 'px'); $form['grid_filter'] = array('#type' => 'select', '#title' => t('Use Filter'), '#options' => array(0 => t('No'), 1 => t('Yes')), '#description' => t('Filter items by taxonomy term'), '#default_value' => $this->options['grid_filter'], '#attributes' => array('class' => array('grid-filter-option'))); $categories = array(); $categories['select'] = t('Select'); foreach (Vocabulary::loadMultiple() as $vocabulary) { $categories[$vocabulary->id()] = $vocabulary->get('name'); } $form['grid_filter_vocabulary'] = array('#type' => 'select', '#title' => t('Filter Vocabulary'), '#options' => $categories, '#description' => t('Which taxonomy vocabulary do you want to use for the filter'), '#default_value' => $this->options['grid_filter_vocabulary'], '#states' => array('visible' => array('.grid-filter-option' => array('value' => 1)))); }
protected function defineOptions() { $options = parent::defineOptions(); $options['base_path'] = array('default' => ''); $options['count'] = array('default' => TRUE, 'bool' => TRUE); $options['override'] = array('default' => FALSE, 'bool' => TRUE); $options['items_per_page'] = array('default' => 25); return $options; }
/** * Builds the configuration form. */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $options = array('' => $this->t('- None -')); $field_labels = $this->displayHandler->getFieldLabels(TRUE); $options += $field_labels; $form['date_field'] = array('#type' => 'select', '#title' => $this->t('Date'), '#options' => $options, '#default_value' => $this->options['date_field'], '#description' => $this->t('The field name of the date field that will be used as the date on the timeline.')); $form['group_heading'] = array('#type' => 'select', '#title' => $this->t('Group heading'), '#options' => array('' => $this->t('No Heading'), 'century' => $this->t('Century'), 'date' => $this->t('Full Date'), 'format' => $this->t('Custom Format')), '#description' => $this->t('The type of date heading to add to the timeline. This heading will be inserted at the first spot where the value of the heading changes.'), '#default_value' => $this->options['group_heading']); $form['group_heading_format'] = array('#type' => 'textfield', '#title' => $this->t('Group heading format'), '#description' => $this->t("If 'Custom Format' was selected above, input the format string to use for the date heading, using the formats from http://php.net/manual/en/function.date.php. For instance, 'M Y' will display a heading over all items with the same month and year, formatted as 'Jan 2016'."), '#default_value' => $this->options['group_heading_format']); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $options = array('' => $this->t('- None -')); $field_labels = $this->displayHandler->getFieldLabels(TRUE); $options += $field_labels; $grouping = $this->options['grouping']; $form['grouping'] = array('#type' => 'select', '#title' => $this->t('Grouping field Nr.@number'), '#options' => $options, '#default_value' => $grouping, '#description' => $this->t('You may optionally specify a field by which to group the records. Leave blank to not group.')); $a = ''; }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['title_field'] = array('#type' => 'select', '#title' => $this->t('Title field'), '#options' => $this->displayHandler->getFieldLabels(TRUE), '#required' => TRUE, '#default_value' => $this->options['title_field'], '#description' => $this->t('Select the field that will be used as the title.')); $form['accordion_filter'] = array('#type' => 'select', '#title' => t('Use Filter'), '#options' => array(0 => t('No'), 1 => t('Yes')), '#description' => t('Filter items by taxonomy term'), '#default_value' => $this->options['accordion_filter'], '#attributes' => array('class' => array('accordion-filter-option'))); $categories = array(); $categories['select'] = t('Select'); foreach (Vocabulary::loadMultiple() as $vocabulary) { $categories[$vocabulary->id()] = $vocabulary->get('name'); } $form['accordion_filter_vocabulary'] = array('#type' => 'select', '#title' => t('Filter Vocabulary'), '#options' => $categories, '#description' => t('Which taxonomy vocabulary do you want to use for the filter'), '#default_value' => $this->options['accordion_filter_vocabulary'], '#states' => array('visible' => array('.accordion-filter-option' => array('value' => 1)))); }
/** * @covers ::render * @covers ::defineOptions * @covers ::init * * @dataProvider providerTestTokens */ public function testRenderWithIdAndToken($token, $id) { $this->setupEntityManager(); $options = ['target' => $token, 'tokenize' => TRUE]; $entity = $this->getMock('Drupal\\Core\\Entity\\EntityInterface'); $entity->expects($this->once())->method('access')->willReturn(TRUE); $this->stylePlugin->expects($this->once())->method('tokenizeValue')->with($token, 0)->willReturn($id); $this->entityStorage->expects($this->never())->method('loadByProperties'); $this->entityStorage->expects($this->once())->method('load')->with($id)->willReturn($entity); $this->entityViewBuilder->expects($this->once())->method('view')->with($entity, 'default')->willReturn(['#markup' => 'hallo']); $this->entityHandler->init($this->executable, $this->display, $options); $result = $this->entityHandler->render(); $this->assertEquals(['#markup' => 'hallo'], $result); }
/** * Render the given style. */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['items'] = array('#type' => 'number', '#title' => $this->t('Items'), '#description' => $this->t('Maximum amount of items displayed at a time with the widest browser width.'), '#default_value' => $this->options['items']); $form['itemsDesktop'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop'), '#description' => $this->t('This allows you to preset the number of slides visible with a particular browser width. The format is [x,y] whereby x=browser width and y=number of slides displayed. For example [1199,4] means that if(window<=1199){ show 4 slides per page}'), '#default_value' => $this->options['itemsDesktop']); $form['itemsDesktopSmall'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop Small'), '#description' => $this->t('Example: [979,3]'), '#default_value' => $this->options['itemsDesktopSmall']); $form['itemsTablet'] = array('#type' => 'textfield', '#title' => $this->t('Items Tablet'), '#description' => $this->t('Example: [768,2]'), '#default_value' => $this->options['itemsTablet']); $form['itemsMobile'] = array('#type' => 'textfield', '#title' => $this->t('Items Mobile'), '#description' => $this->t('Example: [479,1]'), '#default_value' => $this->options['itemsMobile']); $form['singleItem'] = array('#type' => 'checkbox', '#title' => $this->t('Single Item'), '#default_value' => $this->options['singleItem'], '#description' => $this->t('Display only one item.')); //itemsScaleUp $form['itemsScaleUp'] = array('#type' => 'checkbox', '#title' => $this->t('Items ScaleUp'), '#default_value' => $this->options['itemsScaleUp'], '#description' => $this->t('Option to not stretch items when it is less than the supplied items.')); //slideSpeed $form['slideSpeed'] = array('#type' => 'number', '#title' => $this->t('Slide Speed'), '#default_value' => $this->options['slideSpeed'], '#description' => $this->t('Slide speed in milliseconds.')); //paginationSpeed $form['paginationSpeed'] = array('#type' => 'number', '#title' => $this->t('Pagination Speed'), '#default_value' => $this->options['paginationSpeed'], '#description' => $this->t('Pagination speed in milliseconds.')); //rewindSpeed $form['rewindSpeed'] = array('#type' => 'number', '#title' => $this->t('Rewind Speed'), '#default_value' => $this->options['rewindSpeed'], '#description' => $this->t('Rewind speed in milliseconds.')); //autoPlay $form['autoPlay'] = array('#type' => 'checkbox', '#title' => $this->t('AutoPlay'), '#default_value' => $this->options['autoPlay']); //stopOnHover $form['stopOnHover'] = array('#type' => 'checkbox', '#title' => $this->t('Stop On Hover'), '#default_value' => $this->options['stopOnHover'], '#description' => $this->t('Stop autoplay on mouse hover.')); //navigation $form['navigation'] = array('#type' => 'checkbox', '#title' => $this->t('Navigation'), '#default_value' => $this->options['navigation'], '#description' => $this->t('Display "next" and "prev" buttons.')); //prevText $form['prevText'] = array('#type' => 'textfield', '#title' => $this->t('Prev Text'), '#default_value' => $this->options['prevText'], '#description' => $this->t('Text for navigation prev button')); //nextText $form['nextText'] = array('#type' => 'textfield', '#title' => $this->t('Next Text'), '#default_value' => $this->options['nextText'], '#description' => $this->t('Text for navigation next button')); //rewindNav $form['rewindNav'] = array('#type' => 'checkbox', '#title' => $this->t('Rewind Nav'), '#default_value' => $this->options['rewindNav'], '#description' => $this->t('Slide to first item.')); //scrollPerPage $form['scrollPerPage'] = array('#type' => 'checkbox', '#title' => $this->t('Scroll Per Page'), '#default_value' => $this->options['scrollPerPage'], '#description' => $this->t('Scroll per page not per item. This affect next/prev buttons and mouse/touch dragging.')); //pagination $form['pagination'] = array('#type' => 'checkbox', '#title' => $this->t('pagination'), '#default_value' => $this->options['pagination'], '#description' => $this->t('Show pagination.')); //paginationNumbers $form['paginationNumbers'] = array('#type' => 'checkbox', '#title' => $this->t('Pagination Numbers'), '#default_value' => $this->options['paginationNumbers'], '#description' => $this->t('Show numbers inside pagination buttons.')); //responsive $form['responsive'] = array('#type' => 'checkbox', '#title' => $this->t('Responsive'), '#default_value' => $this->options['responsive'], '#description' => $this->t('Uncheck to use Owl Carousel on desktop-only.')); //responsiveRefreshRate $form['responsiveRefreshRate'] = array('#type' => 'number', '#title' => $this->t('Responsive Refresh Rate'), '#default_value' => $this->options['responsiveRefreshRate'], '#description' => $this->t('Check window width changes every 200ms for responsive actions.')); //mouseDrag $form['mouseDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Mouse Drag'), '#default_value' => $this->options['mouseDrag'], '#description' => $this->t('Turn off/on mouse events.')); //touchDrag $form['touchDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Touch Drag'), '#default_value' => $this->options['touchDrag'], '#description' => $this->t('Turn off/on touch events.')); //transitionStyle $form['transitionStyle'] = array('#type' => 'select', '#options' => array('fade' => $this->t('Fade'), 'backSlide' => $this->t('Back Slide'), 'goDown' => $this->t('Go Down'), 'scaleUp' => $this->t('ScaleUp')), '#title' => $this->t('Transition Style'), '#default_value' => $this->options['transitionStyle'], '#description' => $this->t('Add CSS3 transition style. Works only with one item on screen.')); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['columns'] = array('#type' => 'number', '#title' => $this->t('Number of columns'), '#default_value' => $this->options['columns'], '#required' => TRUE, '#min' => 1); $form['automatic_width'] = array('#type' => 'checkbox', '#title' => $this->t('Automatic width'), '#description' => $this->t('The width of each column will be calculated automatically based on the number of columns provided. If additional classes are entered or a theme injects classes based on a grid system, disabling this option may prove beneficial.'), '#default_value' => $this->options['automatic_width']); $form['alignment'] = array('#type' => 'radios', '#title' => $this->t('Alignment'), '#options' => array('horizontal' => $this->t('Horizontal'), 'vertical' => $this->t('Vertical')), '#default_value' => $this->options['alignment'], '#description' => $this->t('Horizontal alignment will place items starting in the upper left and moving right. Vertical alignment will place items starting in the upper left and moving down.')); $form['col_class_default'] = array('#title' => $this->t('Default column classes'), '#description' => $this->t('Add the default views column classes like views-col, col-1 and clearfix to the output. 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.'), '#type' => 'checkbox', '#default_value' => $this->options['col_class_default']); $form['col_class_custom'] = array('#title' => $this->t('Custom column class'), '#description' => $this->t('Additional classes to provide on each column. Separated by a space.'), '#type' => 'textfield', '#default_value' => $this->options['col_class_custom']); if ($this->usesFields()) { $form['col_class_custom']['#description'] .= ' ' . $this->t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.'); } $form['row_class_default'] = array('#title' => $this->t('Default row classes'), '#description' => $this->t('Adds the default views row classes like views-row, row-1 and clearfix to the output. 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.'), '#type' => 'checkbox', '#default_value' => $this->options['row_class_default']); $form['row_class_custom'] = array('#title' => $this->t('Custom row class'), '#description' => $this->t('Additional classes to provide on each row. Separated by a space.'), '#type' => 'textfield', '#default_value' => $this->options['row_class_custom']); if ($this->usesFields()) { $form['row_class_custom']['#description'] .= ' ' . $this->t('You may use field tokens from as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.'); } }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['global'] = array('#type' => 'fieldset', '#title' => 'Global'); $form['global']['autoplay'] = array('#type' => 'checkbox', '#title' => $this->t('Autoplay'), '#default_value' => isset($this->options['global']['autoplay']) ? $this->options['global']['autoplay'] : $this->options['autoplay'], '#description' => t('Enable to auto play.')); $form['global']['autoplayinterval'] = array('#type' => 'number', '#title' => $this->t('Autoplay interval'), '#attributes' => array('min' => 0, 'step' => 1, 'value' => isset($this->options['global']['autoplayinterval']) ? $this->options['global']['autoplayinterval'] : $this->options['autoplayinterval']), '#description' => t('Interval (in milliseconds) to go for next slide since the previous stopped.'), '#states' => array('visible' => array(':input[name="style_options[global][autoplay]"]' => array('checked' => TRUE)))); $form['global']['autoplaysteps'] = array('#type' => 'number', '#title' => $this->t('Autoplay step'), '#attributes' => array('min' => 1, 'step' => 1, 'value' => isset($this->options['global']['autoplaysteps']) ? $this->options['global']['autoplaysteps'] : $this->options['autoplaysteps']), '#description' => t('Steps to go for each navigation request.'), '#states' => array('visible' => array(':input[name="style_options[global][autoplay]"]' => array('checked' => TRUE)))); $form['global']['pauseonhover'] = array('#type' => 'select', '#title' => $this->t('Pause on hover'), '#description' => t('Whether to pause when mouse over if a slider is auto playing.'), '#default_value' => isset($this->options['global']['pauseonhover']) ? $this->options['global']['pauseonhover'] : $this->options['pauseonhover'], '#options' => array(0 => $this->t('No pause'), 1 => $this->t('Pause for desktop'), 2 => $this->t('Pause for touch device'), 3 => $this->t('Pause for desktop and touch device'), 4 => $this->t('Freeze for desktop'), 8 => $this->t('Freeze for touch device'), 12 => $this->t('Freeze for desktop and touch device')), '#states' => array('visible' => array(':input[name="style_options[global][autoplay]"]' => array('checked' => TRUE)))); $form['global']['transition'] = array('#type' => 'select', '#title' => $this->t('Transition'), '#description' => t('Whether to pause when mouse over if a slider is auto playing.'), '#default_value' => isset($this->options['global']['transition']) ? $this->options['global']['transition'] : $this->options['transition'], '#options' => array(t('Twins Effects') => array('transition0001' => $this->t('Fade Twins'), 'transition0002' => $this->t('Rotate Overlap'), 'transition0003' => $this->t('Switch'), 'transition0004' => $this->t('Rotate Relay'), 'transition0005' => $this->t('Doors'), 'transition0006' => $this->t('Rotate in+ out-'), 'transition0007' => $this->t('Fly Twins'), 'transition0008' => $this->t('Rotate in- out+'), 'transition0009' => $this->t('Rotate Axis up overlap'), 'transition0010' => $this->t('Chess Replace TB'), 'transition0011' => $this->t('Chess Replace LR'), 'transition0012' => $this->t('Shift TB'), 'transition0013' => $this->t('Shift LR'), 'transition0014' => $this->t('Return TB'), 'transition0015' => $this->t('Return LR'), 'transition0016' => $this->t('Rotate Axis down'), 'transition0017' => $this->t('Extrude Replace')), t('Fade Effects') => array('transition0101' => $this->t('Fade'), 'transition0102' => $this->t('Fade in L'), 'transition0103' => $this->t('Fade in R')), t('Swing Outside Effects') => array('transition0201' => $this->t('Swing Outside in Stairs'), 'transition0202' => $this->t('Swing Outside in ZigZag'), 'transition0203' => $this->t('Swing Outside in Swirl'), 'transition0204' => $this->t('Swing Outside in Random'), 'transition0205' => $this->t('Swing Outside in Random Chess')), t('Swing Inside Effects') => array('transition0301' => $this->t('Swing Inside in Stairs'), 'transition0302' => $this->t('Swing Inside in ZigZag'), 'transition0303' => $this->t('Swing Inside in Swirl'), 'transition0304' => $this->t('Swing Inside in Random'), 'transition0305' => $this->t('Swing Inside in Random Chess')), t('Dodge Dance Outside Effects') => array('transition0401' => $this->t('Dodge Dance Outside in Stairs'), 'transition0402' => $this->t('Dodge Dance Outside in Swirl'), 'transition0403' => $this->t('Dodge Dance Outside in ZigZag'), 'transition0404' => $this->t('Dodge Dance Outside in Random'), 'transition0405' => $this->t('Dodge Dance Outside in Random Chess')), t('Dodge Dance Inside Effects') => array('transition0501' => $this->t('Dodge Dance Inside in Stairs'), 'transition0502' => $this->t('Dodge Dance Inside in Swirl'), 'transition0503' => $this->t('Dodge Dance Inside in ZigZag'), 'transition0504' => $this->t('Dodge Dance Inside in Random'), 'transition0505' => $this->t('Dodge Dance Inside in Random Chess')), t('Dodge Pet Outside Effects') => array('transition0601' => $this->t('Dodge Pet Outside in Stairs'), 'transition0602' => $this->t('Dodge Pet Outside in Swirl'), 'transition0603' => $this->t('Dodge Pet Outside in ZigZag'), 'transition0604' => $this->t('Dodge Pet Outside in Random'), 'transition0605' => $this->t('Dodge Pet Outside in Random Chess')), t('Dodge Pet Inside Effects') => array('transition0701' => $this->t('Dodge Pet Inside in Stairs'), 'transition0702' => $this->t('Dodge Pet Inside in Swirl'), 'transition0703' => $this->t('Dodge Pet Inside in ZigZag'), 'transition0704' => $this->t('Dodge Pet Inside in Random'), 'transition0705' => $this->t('Dodge Pet Inside in Random Chess')), t('Dodge Outside Effects') => array('transition0801' => $this->t('Dodge Outside out Stairs'), 'transition0802' => $this->t('Dodge Outside out Swirl'), 'transition0803' => $this->t('Dodge Outside out ZigZag'), 'transition0804' => $this->t('Dodge Outside out Random'), 'transition0805' => $this->t('Dodge Outside out Random Chess'), 'transition0806' => $this->t('Dodge Outside out Square'), 'transition0807' => $this->t('Dodge Outside in Stairs'), 'transition0808' => $this->t('Dodge Outside in Swirl'), 'transition0809' => $this->t('Dodge Outside in ZigZag'), 'transition0810' => $this->t('Dodge Outside in Random'), 'transition0811' => $this->t('Dodge Outside in Random Chess'), 'transition0812' => $this->t('Dodge Outside in Square')), t('Dodge Inside Effects') => array('transition0901' => $this->t('Dodge Inside out Stairs'), 'transition0902' => $this->t('Dodge Inside out Swirl'), 'transition0903' => $this->t('Dodge Inside out ZigZag'), 'transition0904' => $this->t('Dodge Inside out Random'), 'transition0905' => $this->t('Dodge Inside out Random Chess'), 'transition0906' => $this->t('Dodge Inside out Square'), 'transition0907' => $this->t('Dodge Inside in Stairs'), 'transition0908' => $this->t('Dodge Inside in Swirl'), 'transition0909' => $this->t('Dodge Inside in ZigZag'), 'transition0910' => $this->t('Dodge Inside in Random'), 'transition0911' => $this->t('Dodge Inside in Random Chess'), 'transition0912' => $this->t('Dodge Inside in Square')), t('Flutter Outside Effects') => array('transition1001' => $this->t('Flutter Outside in'), 'transition1002' => $this->t('Flutter Outside in Wind'), 'transition1003' => $this->t('Flutter Outside in Swirl'), 'transition1004' => $this->t('Flutter Outside in Column'), 'transition1005' => $this->t('Flutter Outside out'), 'transition1006' => $this->t('Flutter Outside out Wind'), 'transition1007' => $this->t('Flutter Outside out Swirl'), 'transition1008' => $this->t('Flutter Outside out Column')), t('Flutter Inside Effects') => array('transition1101' => $this->t('Flutter Inside in'), 'transition1102' => $this->t('Flutter Inside in Wind'), 'transition1103' => $this->t('Flutter Inside in Swirl'), 'transition1104' => $this->t('Flutter Inside in Column'), 'transition1105' => $this->t('Flutter Inside out'), 'transition1106' => $this->t('Flutter Inside out Wind'), 'transition1107' => $this->t('Flutter Inside out Swirl'), 'transition1108' => $this->t('Flutter Inside out Column')), t('Rotate Effects') => array('transition1201' => $this->t('Rotate VDouble+ in'), 'transition1202' => $this->t('Rotate HDouble+ in'), 'transition1203' => $this->t('Rotate VDouble- in'), 'transition1204' => $this->t('Rotate HDouble- in'), 'transition1205' => $this->t('Rotate VDouble+ out'), 'transition1206' => $this->t('Rotate HDouble+ out'), 'transition1207' => $this->t('Rotate VDouble- out'), 'transition1208' => $this->t('Rotate HDouble- out'), 'transition1209' => $this->t('Rotate VFork+ in'), 'transition1210' => $this->t('Rotate HFork+ in'), 'transition1211' => $this->t('Rotate VFork+ out'), 'transition1212' => $this->t('Rotate HFork+ out'), 'transition1213' => $this->t('Rotate Zoom+ in'), 'transition1214' => $this->t('Rotate Zoom+ in L'), 'transition1215' => $this->t('Rotate Zoom+ in R'), 'transition1216' => $this->t('Rotate Zoom+ in T'), 'transition1217' => $this->t('Rotate Zoom+ in B'), 'transition1218' => $this->t('Rotate Zoom+ in TL'), 'transition1219' => $this->t('Rotate Zoom+ in TR'), 'transition1220' => $this->t('Rotate Zoom+ in BL'), 'transition1221' => $this->t('Rotate Zoom+ in BR'), 'transition1222' => $this->t('Rotate Zoom+ out'), 'transition1223' => $this->t('Rotate Zoom+ out L'), 'transition1224' => $this->t('Rotate Zoom+ out R')), t('Zoom Effects') => array('transition1301' => $this->t('Zoom VDouble+ in'), 'transition1302' => $this->t('Zoom HDouble+ in'), 'transition1303' => $this->t('Zoom VDouble- in'), 'transition1304' => $this->t('Zoom HDouble- in'), 'transition1305' => $this->t('Zoom VDouble+ out'), 'transition1306' => $this->t('Zoom HDouble+ out'), 'transition1307' => $this->t('Zoom VDouble- out'), 'transition1308' => $this->t('Zoom HDouble- out'), 'transition1309' => $this->t('Zoom+ in'), 'transition1310' => $this->t('Zoom+ in L'), 'transition1311' => $this->t('Zoom+ in R'), 'transition1312' => $this->t('Zoom+ in T'), 'transition1313' => $this->t('Zoom+ in B'), 'transition1314' => $this->t('Zoom+ in TL'), 'transition1315' => $this->t('Zoom+ in TR'), 'transition1316' => $this->t('Zoom+ in BL'), 'transition1317' => $this->t('Zoom+ in BR'), 'transition1318' => $this->t('Zoom+ out'), 'transition1319' => $this->t('Zoom+ out L'), 'transition1320' => $this->t('Zoom+ out R')), t('Collapse Effects') => array('transition1401' => $this->t('Collapse Stairs')), t('Compound Effects') => array('transition1501' => $this->t('Clip & Chess in')), t('Expand Effects') => array('transition1601' => $this->t('Expand Stairs')), t('Stripe Effects') => array('transition1701' => $this->t('Dominoes Stripe')), t('Wave out Effects') => array('transition1801' => $this->t('Wave out')), t('Wave in Effects') => array('transition1901' => $this->t('Wave in')), t('Jump out Effects') => array('transition2001' => $this->t('Jump out Straight'), 'transition2002' => $this->t('Jump out Swirl'), 'transition2003' => $this->t('Jump out ZigZag'), 'transition2004' => $this->t('Jump out Square'), 'transition2005' => $this->t('Jump out Square with Chess'), 'transition2006' => $this->t('Jump out Rectangle'), 'transition2007' => $this->t('Jump out Circle'), 'transition2008' => $this->t('Jump out Rectangle Cross')), t('Jump in Effects') => array('transition2101' => $this->t('Jump in Straight'), 'transition2101' => $this->t('Jump in Straight'), 'transition2102' => $this->t('Jump in Swirl'), 'transition2103' => $this->t('Jump in ZigZag'), 'transition2104' => $this->t('Jump in Square'), 'transition2105' => $this->t('Jump in Square with Chess'), 'transition2106' => $this->t('Jump in Rectangle'), 'transition2107' => $this->t('Jump in Circle'), 'transition2108' => $this->t('Jump in Rectangle Cross')), t('Parabola Effects') => array('transition2201' => $this->t('Parabola Swirl in'), 'transition2202' => $this->t('Parabola Swirl out'), 'transition2203' => $this->t('Parabola ZigZag in'), 'transition2204' => $this->t('Parabola ZigZag out'), 'transition2205' => $this->t('Parabola Stairs in'), 'transition2206' => $this->t('Parabola Stairs out')), t('Float Effects') => array('transition2301' => $this->t('Float Right Random'), 'transition2302' => $this->t('Float up Random'), 'transition2303' => $this->t('Float up Random with Chess'), 'transition2304' => $this->t('Float Right ZigZag'), 'transition2305' => $this->t('Float up ZigZag'), 'transition2306' => $this->t('Float up ZigZag with Chess'), 'transition2307' => $this->t('Float Right Swirl'), 'transition2308' => $this->t('Float up Swirl'), 'transition2309' => $this->t('Float up Swirl with Chess')), t('Fly Effects') => array('transition2401' => $this->t('Fly Right Random'), 'transition2402' => $this->t('Fly up Random'), 'transition2403' => $this->t('Fly up Random with Chess'), 'transition2404' => $this->t('Fly Right ZigZag'), 'transition2405' => $this->t('Fly up ZigZag'), 'transition2406' => $this->t('Fly up ZigZag with Chess'), 'transition2407' => $this->t('Fly Right Swirl'), 'transition2408' => $this->t('Fly up Swirl'), 'transition2409' => $this->t('Fly up Swirl with Chess')), t('Stone Effects') => array('transition2501' => $this->t('Slide Down'), 'transition2502' => $this->t('Slide Right'), 'transition2503' => $this->t('Bounce Down'), 'transition2504' => $this->t('Bounce Right'))), '#states' => array('visible' => array(':input[name="style_options[global][autoplay]"]' => array('checked' => TRUE)))); $form['global']['arrownavigator'] = array('#type' => 'checkbox', '#title' => $this->t('Enable arrow navigator'), '#default_value' => isset($this->options['global']['arrownavigator']) ? $this->options['global']['arrownavigator'] : $this->options['arrownavigator']); $form['global']['bulletnavigator'] = array('#type' => 'checkbox', '#title' => $this->t('Enable bullet navigator'), '#default_value' => isset($this->options['global']['bulletnavigator']) ? $this->options['global']['bulletnavigator'] : $this->options['bulletnavigator']); // Arrow navigator. $form['arrownavigator'] = array('#type' => 'fieldset', '#title' => $this->t('Arrow navigator'), '#states' => array('visible' => array(':input[name="style_options[global][arrownavigator]"]' => array('checked' => TRUE)))); $arrowskin = array(); for ($i = 1; $i < 22; $i++) { $i = $i < 10 ? '0' . $i : $i; $arrowskin[$i] = $this->t('Arrow ') . $i; } $form['arrownavigator']['arrowskin'] = array('#type' => 'select', '#title' => $this->t('Skin'), '#default_value' => isset($this->options['arrownavigator']['arrowskin']) ? $this->options['arrownavigator']['arrowskin'] : $this->options['arrowskin'], '#options' => $arrowskin); $form['arrownavigator']['autocenter'] = array('#type' => 'select', '#title' => $this->t('Auto center'), '#description' => $this->t('Auto center arrows in parent container'), '#default_value' => isset($this->options['arrownavigator']['autocenter']) ? $this->options['arrownavigator']['autocenter'] : $this->options['autocenter'], '#options' => array(0 => $this->t('No'), 1 => $this->t('Horizontal'), 2 => $this->t('Vertical'), 3 => $this->t('Both'))); $form['arrownavigator']['chancetoshow'] = array('#type' => 'select', '#title' => $this->t('Chance to show'), '#default_value' => isset($this->options['arrownavigator']['chancetoshow']) ? $this->options['arrownavigator']['chancetoshow'] : $this->options['chancetoshow'], '#options' => array(0 => $this->t('Never'), 1 => $this->t('Mouse Over'), 2 => $this->t('Always'))); // Bullet navigator. $form['bulletnavigator'] = array('#type' => 'fieldset', '#title' => $this->t('Bullet navigator'), '#states' => array('visible' => array(':input[name="style_options[global][bulletnavigator]"]' => array('checked' => TRUE)))); $bulletskin = array(); for ($i = 1; $i < 22; $i++) { $i = $i < 10 ? '0' . $i : $i; $bulletskin[$i] = $this->t('Bullet ') . $i; } $form['bulletnavigator']['bulletskin'] = array('#type' => 'select', '#title' => $this->t('Skin'), '#default_value' => isset($this->options['bulletnavigator']['bulletskin']) ? $this->options['bulletnavigator']['bulletskin'] : $this->options['bulletskin'], '#options' => $bulletskin); $form['bulletnavigator']['autocenter'] = array('#type' => 'select', '#title' => $this->t('Auto center'), '#description' => $this->t('Auto center arrows in parent container'), '#default_value' => isset($this->options['bulletnavigator']['autocenter']) ? $this->options['bulletnavigator']['autocenter'] : $this->options['autocenter'], '#options' => array(0 => $this->t('No'), 1 => $this->t('Horizontal'), 2 => $this->t('Vertical'), 3 => $this->t('Both'))); $form['bulletnavigator']['chancetoshow'] = array('#type' => 'select', '#title' => $this->t('Chance to show'), '#default_value' => isset($this->options['bulletnavigator']['chancetoshow']) ? $this->options['bulletnavigator']['chancetoshow'] : $this->options['chancetoshow'], '#options' => array(0 => $this->t('Never'), 1 => $this->t('Mouse Over'), 2 => $this->t('Always'))); $form['bulletnavigator']['spacingx'] = array('#type' => 'number', '#title' => $this->t('Horizontal space'), '#attributes' => array('min' => 0, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['spacingx']) ? $this->options['bulletnavigator']['spacingx'] : $this->options['spacingx']), '#description' => t('Horizontal space between each item in pixel.')); $form['bulletnavigator']['spacingy'] = array('#type' => 'number', '#title' => $this->t('Vertical space'), '#attributes' => array('min' => 0, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['spacingy']) ? $this->options['bulletnavigator']['spacingy'] : $this->options['spacingy']), '#description' => t('Vertical space between each item in pixel.')); $form['bulletnavigator']['orientation'] = array('#type' => 'select', '#title' => $this->t('The orientation of the navigator'), '#default_value' => isset($this->options['bulletnavigator']['orientation']) ? $this->options['bulletnavigator']['orientation'] : $this->options['orientation'], '#options' => array(1 => $this->t('Horizontal'), 2 => $this->t('Vertical'))); $form['bulletnavigator']['steps'] = array('#type' => 'number', '#title' => $this->t('Steps'), '#attributes' => array('min' => 1, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['steps']) ? $this->options['bulletnavigator']['steps'] : $this->options['steps']), '#description' => t('Steps to go for each navigation request.')); $form['bulletnavigator']['lanes'] = array('#type' => 'number', '#title' => $this->t('Lanes'), '#attributes' => array('min' => 1, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['lanes']) ? $this->options['bulletnavigator']['lanes'] : $this->options['lanes']), '#description' => t('Specify lanes to arrange items.')); }
/** * Overrides Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm(). */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Get the mapping. $mapping = $this->defineMapping(); // Restrict the list of defaults to the mapping, in case they have changed. $options = array_intersect_key($this->options['mapping'], $mapping); // Get the labels of the fields added to this display. $field_labels = $this->displayHandler->getFieldLabels(); // Provide some default values. $defaults = array('#type' => 'select', '#required' => FALSE, '#multiple' => FALSE); // For each mapping, add a select element to the form. foreach ($options as $key => $value) { // If the field is optional, add a 'None' value to the top of the options. $field_options = array(); $required = !empty($mapping[$key]['#required']); if (!$required && empty($mapping[$key]['#multiple'])) { $field_options = array('' => $this->t('- None -')); } $field_options += $field_labels; // Optionally filter the available fields. if (isset($mapping[$key]['#filter'])) { $this->view->initHandlers(); $filter = $mapping[$key]['#filter']; $this::$filter($field_options); unset($mapping[$key]['#filter']); } // These values must always be set. $overrides = array('#options' => $field_options, '#default_value' => $options[$key]); // Optionally allow the select to be toggleable. if (!empty($mapping[$key]['#toggle'])) { $form['mapping']["toggle_{$key}"] = array('#type' => 'checkbox', '#title' => $this->t('Use a custom %field_name', array('%field_name' => strtolower($mapping[$key]['#title']))), '#default_value' => $this->options['mapping']["toggle_{$key}"]); $overrides['#states']['visible'][':input[name="style_options[mapping][' . "toggle_{$key}" . ']"]'] = array('checked' => TRUE); } $form['mapping'][$key] = $overrides + $mapping[$key] + $defaults; } }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['mode'] = array('#prefix' => '<h4>bxSlider Settings</h4>', '#type' => 'select', '#title' => t('Mode'), '#description' => t('Type of transition between slides'), '#options' => array('horizontal' => t('Horizontal'), 'vertical' => t('Vertical'), 'fade' => t('Fade')), '#default_value' => $this->options['mode']); $form['ticker'] = array('#type' => 'select', '#title' => t('Ticker Enabled'), '#description' => t('If yes, use slider in ticker mode (similar to a news ticker)'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['ticker']); $form['tickerHover'] = array('#type' => 'select', '#title' => t('Ticker Hover'), '#description' => t('Ticker will pause when mouse hovers over slider. Note: this functionality does NOT work if using CSS transitions!'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['tickerHover']); $form['speed'] = array('#type' => 'textfield', '#title' => t('Speed'), '#description' => t('Slide transition duration (in ms)'), '#default_value' => $this->options['speed']); $form['touchEnabled'] = array('#type' => 'select', '#title' => t('Touch Enabled'), '#description' => t('If yes, slider will allow touch swipe transitions'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['touchEnabled']); $form['auto'] = array('#type' => 'select', '#title' => t('Auto'), '#description' => t('Slides will automatically transition.'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['auto']); $form['pause'] = array('#type' => 'textfield', '#title' => t('Pause'), '#description' => t('The amount of time (in ms) between each auto transition.'), '#default_value' => $this->options['pause']); $form['infiniteloop'] = array('#type' => 'select', '#title' => t('Infinite'), '#description' => t('If true, clicking "Next" while on the last slide will transition to the first slide and vice-versa'), '#options' => array(true => t('Yes'), false => t('No')), '#default_value' => $this->options['infiniteloop']); $form['slidemargin'] = array('#type' => 'textfield', '#title' => t('Slide Margin'), '#description' => t('Margin between each slide'), '#default_value' => $this->options['slidemargin']); $form['startslide'] = array('#type' => 'textfield', '#title' => t('Start Slide'), '#description' => t('Starting slide index (zero-based)'), '#default_value' => $this->options['startslide']); $form['randomstart'] = array('#type' => 'select', '#title' => t('Random Start'), '#options' => array(true => t('Yes'), false => t('No')), '#description' => t('Start slider on a random slide'), '#default_value' => $this->options['randomstart']); $form['pager'] = array('#type' => 'select', '#title' => t('Show Pager'), '#description' => t('If yes, a pager will be added.'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['pager']); $form['controls'] = array('#type' => 'select', '#title' => t('Show Controls'), '#description' => t('If yes, next/prev controls will be added.'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['controls']); $form['nexttext'] = array('#type' => 'textfield', '#title' => t('Custom nextText'), '#description' => t('Custom text to be used for the "Next" control'), '#default_value' => $this->options['nexttext']); $form['prevtext'] = array('#type' => 'textfield', '#title' => t('Custom prevText'), '#description' => t('Custom text to be used for the "Prev" control'), '#default_value' => $this->options['prevtext']); $form['autoControls'] = array('#type' => 'select', '#title' => t('Show Auto Controls'), '#description' => t('If Yes, "Start" / "Stop" controls will be added. Note: this functionality work if auto is true!'), '#options' => array(true => 'Yes', false => 'No'), '#default_value' => $this->options['autoControls']); $form['moveslides'] = array('#type' => 'textfield', '#title' => t('Move Slides'), '#description' => t('The number of slides to move on transition. This value must be >= minSlides, and <= maxSlides. If zero (default), the number of fully-visible slides will be used.'), '#default_value' => $this->options['moveslides']); $form['lg_items'] = array('#type' => 'select', '#title' => t('Large Desktop Items'), '#description' => t('Number of items on large desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['lg_items']); $form['md_items'] = array('#type' => 'select', '#title' => t('Desktop Items'), '#description' => t('Number of items on desktop'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['md_items']); $form['sm_items'] = array('#type' => 'select', '#title' => t('Tablet Items'), '#description' => t('Number of items on tablet'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['sm_items']); $form['xs_items'] = array('#type' => 'select', '#title' => t('Phone Items'), '#description' => t('Number of items on phone'), '#options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12), '#default_value' => $this->options['xs_items']); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Wrap all the form elements to help style the form. $form['views_slideshow_wrapper'] = array('#markup' => '<div id="views-slideshow-form-wrapper">'); /** * Style. */ $form['slideshow_skin_header'] = array('#markup' => '<h2>' . t('Style') . '</h2>'); // Get a list of all available skins. $skin_info = $this->getSkins(); foreach ($skin_info as $skin => $info) { $skins[$skin] = $info['name']; } asort($skins); // Create the drop down box so users can choose an available skin. $form['slideshow_skin'] = array('#type' => 'select', '#title' => t('Skin'), '#options' => $skins, '#default_value' => $this->options['slideshow_skin'], '#description' => t('Select the skin to use for this display. Skins allow for easily swappable layouts of things like next/prev links and thumbnails. Note that not all skins support all widgets, so a combination of skins and widgets may lead to unpredictable results in layout.')); /** * Slides */ $form['slides_header'] = array('#markup' => '<h2>' . t('Slides') . '</h2>'); // Get all slideshow types. $slideshows = \Drupal::moduleHandler()->invokeAll('views_slideshow_slideshow_info'); if ($slideshows) { // Build our slideshow options for the form. $slideshow_options = array(); foreach ($slideshows as $slideshow_id => $slideshow_info) { $slideshow_options[$slideshow_id] = $slideshow_info['name']; } $form['slideshow_type'] = array('#type' => 'select', '#title' => t('Slideshow Type'), '#options' => $slideshow_options, '#default_value' => $this->options['slideshow_type']); $arguments = array(&$form, &$form_state, &$this); foreach (\Drupal::moduleHandler()->getImplementations('views_slideshow_slideshow_type_form') as $module) { $form[$module] = array('#type' => 'fieldset', '#title' => t('!module options', array('!module' => $slideshows[$module]['name'])), '#collapsible' => TRUE, '#attributes' => array('class' => array($module)), '#states' => array('visible' => array(':input[name="style_options[slideshow_type]"]' => array('value' => $module)))); $function = $module . '_views_slideshow_slideshow_type_form'; call_user_func_array($function, $arguments); } } else { $form['enable_module'] = array('#markup' => t('There is no Views Slideshow plugin enabled. Go to the !modules and enable a Views Slideshow plugin module. For example Views Slideshow Singleframe.', array('!modules' => \Drupal::l(t('Modules Page'), Url::fromRoute('system.modules_list'))))); } /** * Widgets */ $form['widgets_header'] = array('#markup' => '<h2>' . t('Widgets') . '</h2>'); // Loop through all locations so we can add header for each location. $location = array('top' => t('Top'), 'bottom' => t('Bottom')); foreach ($location as $location_id => $location_name) { // Widget Header $form['widgets'][$location_id]['header'] = array('#markup' => '<h3>' . t('!location Widgets', array('!location' => $location_name)) . '</h3>'); } // Get all widgets that are registered. // If we have widgets then build it's form fields. $widgets = \Drupal::moduleHandler()->invokeAll('views_slideshow_widget_info'); if (!empty($widgets)) { // Build our weight values by number of widgets $weights = array(); for ($i = 1; $i <= count($widgets); $i++) { $weights[$i] = $i; } // Loop through our widgets and locations to build our form values for // each widget. foreach ($widgets as $widget_id => $widget_info) { foreach ($location as $location_id => $location_name) { $widget_dependency = 'style_options[widgets][' . $location_id . '][' . $widget_id . ']'; // Determine if a widget is compatible with a slideshow. $compatible_slideshows = array(); foreach ($slideshows as $slideshow_id => $slideshow_info) { $is_compatible = 1; // Check if every required accept value in the widget has a // corresponding calls value in the slideshow. foreach ($widget_info['accepts'] as $accept_key => $accept_value) { if (is_array($accept_value) && !empty($accept_value['required']) && !in_array($accept_key, $slideshow_info['calls'])) { $is_compatible = 0; break; } } // No need to go through this if it's not compatible. if ($is_compatible) { // Check if every required calls value in the widget has a // corresponding accepts call. foreach ($widget_info['calls'] as $calls_key => $calls_value) { if (is_array($calls_value) && !empty($calls_value['required']) && !in_array($calls_key, $slideshow_info['accepts'])) { $is_compatible = 0; break; } } } // If it passed all those tests then they are compatible. if ($is_compatible) { $compatible_slideshows[] = $slideshow_id; } } // Use Widget Checkbox $form['widgets'][$location_id][$widget_id]['enable'] = array('#type' => 'checkbox', '#title' => t($widget_info['name']), '#default_value' => $this->options['widgets'][$location_id][$widget_id]['enable'], '#description' => t('Should !name be rendered at the !location of the slides.', array('!name' => $widget_info['name'], '!location' => $location_name))); $form['widgets'][$location_id][$widget_id]['enable']['#dependency']['edit-style-options-slideshow-type'] = !empty($compatible_slideshows) ? $compatible_slideshows : array('none'); // Need to wrap this so it indents correctly. $form['widgets'][$location_id][$widget_id]['wrapper'] = array('#markup' => '<div class="vs-dependent">'); // Widget weight // We check to see if the default value is greater than the number of // widgets just in case a widget has been removed and the form hasn't // been saved again. $weight = isset($this->options['widgets'][$location_id][$widget_id]['weight']) ? $this->options['widgets'][$location_id][$widget_id]['weight'] : 0; if ($weight > count($widgets)) { $weight = count($widgets); } $form['widgets'][$location_id][$widget_id]['weight'] = array('#type' => 'select', '#title' => t('Weight of the !name', array('!name' => $widget_info['name'])), '#default_value' => $weight, '#options' => $weights, '#description' => t('Determines in what order the !name appears. A lower weight will cause the !name to be above higher weight items.', array('!name' => $widget_info['name'])), '#prefix' => '<div class="vs-dependent">', '#suffix' => '</div>', '#states' => array('visible' => array(':input[name="style_options[widgets][' . $location_id . '][' . $widget_id . '][enable]"]' => array('checked' => TRUE)))); // Add all the widget settings. if (function_exists($widget_id . '_views_slideshow_widget_form_options')) { $arguments = array(&$form['widgets'][$location_id][$widget_id], &$form_state, &$this, $this->options['widgets'][$location_id][$widget_id], $widget_dependency); call_user_func_array($widget_id . '_views_slideshow_widget_form_options', $arguments); } $form['widgets'][$location_id][$widget_id]['wrapper_close'] = array('#markup' => '</div>'); } } } $form['views_slideshow_wrapper_close'] = array('#markup' => '</div>'); $form['#attached']['library'] = array('views_slideshow/form'); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $labels = $this->displayHandler->getFieldLabels(); $fieldMap = \Drupal::entityManager()->getFieldMap(); $geo_options = []; $title_options = []; $filters = $this->displayHandler->getOption('filters'); $fields = $this->displayHandler->getOption('fields'); foreach ($fields as $field_name => $field) { if ($field['plugin_id'] == 'geolocation_field') { $geo_options[$field_name] = $labels[$field_name]; } if ($field['plugin_id'] == 'field' && !empty($field['entity_type']) && !empty($field['entity_field'])) { if (!empty($fieldMap[$field['entity_type']][$field['entity_field']]['type']) && $fieldMap[$field['entity_type']][$field['entity_field']]['type'] == 'geolocation') { $geo_options[$field_name] = $labels[$field_name]; } } if ($field['type'] == 'string') { $title_options[$field_name] = $labels[$field_name]; } } $form['geolocation_field'] = ['#title' => $this->t('Geolocation source field'), '#type' => 'select', '#default_value' => $this->options['geolocation_field'], '#description' => $this->t("The source of geodata for each entity."), '#options' => $geo_options]; $form['title_field'] = ['#title' => $this->t('Title source field'), '#type' => 'select', '#default_value' => $this->options['title_field'], '#description' => $this->t("The source of the title for each entity. Must be string"), '#options' => $title_options]; $options = ['first_row' => $this->t('Use first row as centre.'), 'fixed_value' => $this->t('Provide fixed latitude and longitude.')]; foreach ($filters as $filter_name => $filter) { if (empty($filter['plugin_id']) || $filter['plugin_id'] != 'geolocation_filter_proximity') { continue; } $options['proximity_filter_' . $filter_name] = $this->displayHandler->getHandler('filter', $filter_name)->adminLabel(); } $form['centre'] = ['#type' => 'table', '#header' => [t('Enable'), t('Option'), t('settings'), array('data' => t('Settings'), 'colspan' => '1')], '#attributes' => ['id' => 'geolocation-centre-options'], '#tabledrag' => [['action' => 'order', 'relationship' => 'sibling', 'group' => 'geolocation-centre-option-weight']]]; foreach ($options as $id => $label) { $weight = $this->options['centre'][$id]['weight'] ?: 0; $form['centre'][$id]['#weight'] = $weight; $form['centre'][$id]['enable'] = ['#type' => 'checkbox', '#default_value' => isset($this->options['centre'][$id]['enable']) ? $this->options['centre'][$id]['enable'] : TRUE]; $form['centre'][$id]['option'] = ['#markup' => $label]; // Optionally, to add tableDrag support: $form['centre'][$id]['#attributes']['class'][] = 'draggable'; $form['centre'][$id]['weight'] = ['#type' => 'weight', '#title' => t('Weight for @option', ['@option' => $label]), '#title_display' => 'invisible', '#size' => 4, '#default_value' => $weight, '#attributes' => ['class' => ['geolocation-centre-option-weight']]]; } $form['centre']['fixed_value']['settings'] = ['#title' => $this->t('Fixed values for centre'), '#type' => 'container', 'latitude' => ['#type' => 'textfield', '#title' => t('Latitude'), '#default_value' => $this->options['centre']['fixed_value']['settings']['latitude'], '#size' => 60, '#maxlength' => 128], 'longitude' => ['#type' => 'textfield', '#title' => t('Longitude'), '#default_value' => $this->options['centre']['fixed_value']['settings']['longitude'], '#size' => 60, '#maxlength' => 128], '#description' => $this->t("The source of geodata for each entity. Must be string"), '#states' => ['visible' => [':input[name="style_options[centre][fixed_value][enable]"]' => ['checked' => TRUE]]]]; uasort($form['centre'], 'Drupal\\Component\\Utility\\SortArray::sortByWeightProperty'); }
/** * {@inheritdoc} */ public function calculateDependencies() { $dependencies = parent::calculateDependencies(); $formats = $this->getFormats(); $providers = array_intersect_key($this->formatProviders, array_flip($formats)); // The plugin always uses services from the serialization module. $providers[] = 'serialization'; $dependencies += ['module' => []]; $dependencies['module'] = array_merge($dependencies['module'], $providers); return $dependencies; }
/** * {@inheritdoc} */ public function validate() { $errors = parent::validate(); $display_id = $this->displayHandler->display['id']; if ($display_id == 'default') { // @todo Update default display in templates to validate. return $errors; } // @todo Validate row plugin $argument = CalendarHelper::getDateArgumentHandler($this->view, $display_id); if (empty($argument)) { $errors[] = $this->t('\\Drupal\\calendar\\Plugin\\views\\style\\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.'); } return $errors; }
/** * {@inheritdoc} */ public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); $formats = $form_state->getValue(array('style_options', 'formats')); $form_state->setValue(array('style_options', 'formats'), array_filter($formats)); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['global'] = array('#type' => 'fieldset', '#title' => 'Global'); $form['global']['autoplay'] = array('#type' => 'checkbox', '#title' => $this->t('Autoplay'), '#default_value' => isset($this->options['global']['autoplay']) ? $this->options['global']['autoplay'] : $this->options['autoplay'], '#description' => t('Enable to auto play.')); $form['global']['arrownavigator'] = array('#type' => 'checkbox', '#title' => $this->t('Arrow navigator'), '#default_value' => isset($this->options['global']['arrownavigator']) ? $this->options['global']['arrownavigator'] : $this->options['arrownavigator'], '#description' => t('Enable arrow navigator.')); $form['global']['bulletnavigator'] = array('#type' => 'checkbox', '#title' => $this->t('Bullet navigator'), '#default_value' => isset($this->options['global']['bulletnavigator']) ? $this->options['global']['bulletnavigator'] : $this->options['bulletnavigator'], '#description' => t('Enable bullet navigator.')); // Slider. $form['general'] = array('#type' => 'fieldset', '#title' => $this->t('General')); $form['general']['slide_duration'] = array('#type' => 'number', '#title' => $this->t('Slide duration'), '#attributes' => array('min' => 0, 'step' => 1, 'value' => isset($this->options['general']['slide_duration']) ? $this->options['general']['slide_duration'] : $this->options['slide_duration']), '#description' => t('Specifies default duration (swipe) for slide in milliseconds.')); /*$form['general']['slide_spacing'] = array( '#type' => 'number', '#title' => $this->t('Slide spacing'), '#attributes' => array( 'min' => 0, 'step' => 1, 'value' => (isset($this->options['general']['slide_spacing'])) ? $this->options['general']['slide_spacing'] : $this->options['slide_spacing'], ), '#description' => t('Space between each slide in pixels.'), );*/ $form['general']['drag_orientation'] = array('#type' => 'select', '#title' => $this->t('Drag orientation'), '#description' => t('Orientation to drag slide.'), '#default_value' => isset($this->options['general']['drag_orientation']) ? $this->options['general']['drag_orientation'] : $this->options['drag_orientation'], '#options' => array(0 => $this->t('No drag'), 1 => $this->t('Horizontal'), 2 => $this->t('Vertical'), 3 => $this->t('Horizontal and vertical'))); $form['general']['key_navigation'] = array('#type' => 'checkbox', '#title' => t('Key navigation'), '#default_value' => isset($this->options['general']['key_navigation']) ? $this->options['general']['key_navigation'] : $this->options['key_navigation'], '#description' => t('Allows keyboard (arrow key) navigation or not.')); // Autoplay. $form['autoplay'] = array('#type' => 'fieldset', '#title' => $this->t('Autoplay'), '#states' => array('visible' => array(':input[name="style_options[global][autoplay]"]' => array('checked' => TRUE)))); $form['autoplay']['autoplayinterval'] = array('#type' => 'number', '#title' => $this->t('Autoplay interval'), '#attributes' => array('min' => 0, 'step' => 1, 'value' => isset($this->options['autoplay']['autoplayinterval']) ? $this->options['autoplay']['autoplayinterval'] : $this->options['autoplayinterval']), '#description' => t('Interval (in milliseconds) to go for next slide since the previous stopped.')); $form['autoplay']['autoplaysteps'] = array('#type' => 'number', '#title' => $this->t('Autoplay step'), '#attributes' => array('min' => 1, 'step' => 1, 'value' => isset($this->options['autoplay']['autoplaysteps']) ? $this->options['autoplay']['autoplaysteps'] : $this->options['autoplaysteps']), '#description' => t('Steps to go for each navigation request.')); $form['autoplay']['pauseonhover'] = array('#type' => 'select', '#title' => $this->t('Pause on hover'), '#description' => t('Whether to pause when mouse over if a slider is auto playing.'), '#default_value' => isset($this->options['autoplay']['pauseonhover']) ? $this->options['autoplay']['pauseonhover'] : $this->options['pauseonhover'], '#options' => array(0 => $this->t('No pause'), 1 => $this->t('Pause for desktop'), 2 => $this->t('Pause for touch device'), 3 => $this->t('Pause for desktop and touch device'), 4 => $this->t('Freeze for desktop'), 8 => $this->t('Freeze for touch device'), 12 => $this->t('Freeze for desktop and touch device'))); $form['autoplay']['transition'] = ['#type' => 'select', '#title' => $this->t('Transition'), '#description' => t('Whether to pause when mouse over if a slider is auto playing.'), '#default_value' => isset($this->options['autoplay']['transition']) ? $this->options['autoplay']['transition'] : $this->options['transition'], '#options' => ['Twins Effects' => ['transition0000' => $this->t('Basic'), 'transition0001' => $this->t('Fade Twins'), 'transition0002' => $this->t('Rotate Overlap'), 'transition0003' => $this->t('Switch'), 'transition0004' => $this->t('Rotate Relay'), 'transition0005' => $this->t('Doors'), 'transition0006' => $this->t('Rotate in+ out-'), 'transition0007' => $this->t('Fly Twins'), 'transition0008' => $this->t('Rotate in- out+'), 'transition0009' => $this->t('Rotate Axis up overlap'), 'transition0010' => $this->t('Chess Replace TB'), 'transition0011' => $this->t('Chess Replace LR'), 'transition0012' => $this->t('Shift TB'), 'transition0013' => $this->t('Shift LR'), 'transition0014' => $this->t('Return TB'), 'transition0015' => $this->t('Return LR'), 'transition0016' => $this->t('Rotate Axis down'), 'transition0017' => $this->t('Extrude Replace')], 'Fade Effects' => ['transition0101' => $this->t('Fade'), 'transition0102' => $this->t('Fade in L'), 'transition0103' => $this->t('Fade in R'), 'transition0104' => $this->t('Fade in T'), 'transition0105' => $this->t('Fade in B'), 'transition0106' => $this->t('Fade in LR'), 'transition0107' => $this->t('Fade in LR Chess'), 'transition0108' => $this->t('Fade in TB'), 'transition0109' => $this->t('Fade in TB Chess'), 'transition0110' => $this->t('Fade in Corners'), 'transition0111' => $this->t('Fade out L'), 'transition0112' => $this->t('Fade out R'), 'transition0113' => $this->t('Fade out T'), 'transition0114' => $this->t('Fade out B'), 'transition0115' => $this->t('Fade out LR'), 'transition0116' => $this->t('Fade out LR Chess'), 'transition0117' => $this->t('Fade out TB'), 'transition0118' => $this->t('Fade out TB Chess'), 'transition0119' => $this->t('Fade out Corners'), 'transition0120' => $this->t('Fade Fly in L'), 'transition0121' => $this->t('Fade Fly in R'), 'transition0122' => $this->t('Fade Fly in T'), 'transition0123' => $this->t('Fade Fly in B'), 'transition0124' => $this->t('Fade Fly in LR'), 'transition0125' => $this->t('Fade Fly in LR Chess'), 'transition0126' => $this->t('Fade Fly in TB'), 'transition0127' => $this->t('Fade Fly in TB Chess'), 'transition0128' => $this->t('Fade Fly in Corners'), 'transition0129' => $this->t('Fade Fly out L'), 'transition0130' => $this->t('Fade Fly out R'), 'transition0131' => $this->t('Fade Fly out T'), 'transition0132' => $this->t('Fade Fly out B'), 'transition0133' => $this->t('Fade Fly out LR'), 'transition0134' => $this->t('Fade Fly out LR Chess'), 'transition0135' => $this->t('Fade Fly out TB'), 'transition0136' => $this->t('Fade Fly out TB Chess'), 'transition0137' => $this->t('Fade Fly out Corners'), 'transition0138' => $this->t('Fade Clip in H'), 'transition0139' => $this->t('Fade Clip in V'), 'transition0140' => $this->t('Fade Clip out H'), 'transition0141' => $this->t('Fade Clip out V'), 'transition0142' => $this->t('Fade Stairs'), 'transition0143' => $this->t('Fade Random'), 'transition0144' => $this->t('Fade Swirl'), 'transition0145' => $this->t('Fade ZigZag')], 'Swing Outside Effects' => ['transition0201' => $this->t('Swing Outside in Stairs'), 'transition0202' => $this->t('Swing Outside in ZigZag'), 'transition0203' => $this->t('Swing Outside in Swirl'), 'transition0204' => $this->t('Swing Outside in Random'), 'transition0205' => $this->t('Swing Outside in Random Chess'), 'transition0206' => $this->t('Swing Outside in Square'), 'transition0207' => $this->t('Swing Outside out Stairs'), 'transition0208' => $this->t('Swing Outside out ZigZag'), 'transition0209' => $this->t('Swing Outside out Swirl'), 'transition0210' => $this->t('Swing Outside out Random'), 'transition0211' => $this->t('Swing Outside out Random Chess'), 'transition0212' => $this->t('Swing Outside out Square')], 'Swing Inside Effects' => ['transition0301' => $this->t('Swing Inside in Stairs'), 'transition0302' => $this->t('Swing Inside in ZigZag'), 'transition0303' => $this->t('Swing Inside in Swirl'), 'transition0304' => $this->t('Swing Inside in Random'), 'transition0305' => $this->t('Swing Inside in Random Chess'), 'transition0306' => $this->t('Swing Inside in Square'), 'transition0307' => $this->t('Swing Inside out ZigZag'), 'transition0308' => $this->t('Swing Inside out Swirl')], 'Dodge Dance Outside Effects' => ['transition0401' => $this->t('Dodge Dance Outside in Stairs'), 'transition0402' => $this->t('Dodge Dance Outside in Swirl'), 'transition0403' => $this->t('Dodge Dance Outside in ZigZag'), 'transition0404' => $this->t('Dodge Dance Outside in Random'), 'transition0405' => $this->t('Dodge Dance Outside in Random Chess'), 'transition0406' => $this->t('Dodge Dance Outside in Square'), 'transition0407' => $this->t('Dodge Dance Outside out Stairs'), 'transition0408' => $this->t('Dodge Dance Outside out Swirl'), 'transition0409' => $this->t('Dodge Dance Outside out ZigZag'), 'transition0410' => $this->t('Dodge Dance Outside out Random'), 'transition0411' => $this->t('Dodge Dance Outside out Random Chess'), 'transition0412' => $this->t('Dodge Dance Outside out Square')], 'Dodge Dance Inside Effects' => ['transition0501' => $this->t('Dodge Dance Inside in Stairs'), 'transition0502' => $this->t('Dodge Dance Inside in Swirl'), 'transition0503' => $this->t('Dodge Dance Inside in ZigZag'), 'transition0504' => $this->t('Dodge Dance Inside in Random'), 'transition0505' => $this->t('Dodge Dance Inside in Random Chess'), 'transition0506' => $this->t('Dodge Dance Inside in Square'), 'transition0507' => $this->t('Dodge Dance Inside out Stairs'), 'transition0508' => $this->t('Dodge Dance Inside out Swirl'), 'transition0509' => $this->t('Dodge Dance Inside out ZigZag'), 'transition0510' => $this->t('Dodge Dance Inside out Random'), 'transition0511' => $this->t('Dodge Dance Inside out Random Chess'), 'transition0512' => $this->t('Dodge Dance Inside out Square')], 'Dodge Pet Outside Effects' => ['transition0601' => $this->t('Dodge Pet Outside in Stairs'), 'transition0602' => $this->t('Dodge Pet Outside in Swirl'), 'transition0603' => $this->t('Dodge Pet Outside in ZigZag'), 'transition0604' => $this->t('Dodge Pet Outside in Random'), 'transition0605' => $this->t('Dodge Pet Outside in Random Chess'), 'transition0606' => $this->t('Dodge Pet Outside in Square'), 'transition0607' => $this->t('Dodge Pet Outside out Stairs'), 'transition0608' => $this->t('Dodge Pet Outside out Swirl'), 'transition0609' => $this->t('Dodge Pet Outside out ZigZag'), 'transition0610' => $this->t('Dodge Pet Outside out Random'), 'transition0611' => $this->t('Dodge Pet Outside out Random Chess'), 'transition0612' => $this->t('Dodge Pet Outside out Square')], 'Dodge Pet Inside Effects' => ['transition0701' => $this->t('Dodge Pet Inside in Stairs'), 'transition0702' => $this->t('Dodge Pet Inside in Swirl'), 'transition0703' => $this->t('Dodge Pet Inside in ZigZag'), 'transition0704' => $this->t('Dodge Pet Inside in Random'), 'transition0705' => $this->t('Dodge Pet Inside in Random Chess'), 'transition0706' => $this->t('Dodge Pet Inside in Square'), 'transition0707' => $this->t('Dodge Pet Inside out Stairs'), 'transition0708' => $this->t('Dodge Pet Inside out Swirl'), 'transition0709' => $this->t('Dodge Pet Inside out ZigZag'), 'transition0710' => $this->t('Dodge Pet Inside out Random'), 'transition0711' => $this->t('Dodge Pet Inside out Random Chess'), 'transition0712' => $this->t('Dodge Pet Inside out Square')], 'Dodge Outside Effects' => ['transition0801' => $this->t('Dodge Outside out Stairs'), 'transition0802' => $this->t('Dodge Outside out Swirl'), 'transition0803' => $this->t('Dodge Outside out ZigZag'), 'transition0804' => $this->t('Dodge Outside out Random'), 'transition0805' => $this->t('Dodge Outside out Random Chess'), 'transition0806' => $this->t('Dodge Outside out Square'), 'transition0807' => $this->t('Dodge Outside in Stairs'), 'transition0808' => $this->t('Dodge Outside in Swirl'), 'transition0809' => $this->t('Dodge Outside in ZigZag'), 'transition0810' => $this->t('Dodge Outside in Random'), 'transition0811' => $this->t('Dodge Outside in Random Chess'), 'transition0812' => $this->t('Dodge Outside in Square')], $this->t('Dodge Inside Effects') => ['transition0901' => $this->t('Dodge Inside out Stairs'), 'transition0902' => $this->t('Dodge Inside out Swirl'), 'transition0903' => $this->t('Dodge Inside out ZigZag'), 'transition0904' => $this->t('Dodge Inside out Random'), 'transition0905' => $this->t('Dodge Inside out Random Chess'), 'transition0906' => $this->t('Dodge Inside out Square'), 'transition0907' => $this->t('Dodge Inside in Stairs'), 'transition0908' => $this->t('Dodge Inside in Swirl'), 'transition0909' => $this->t('Dodge Inside in ZigZag'), 'transition0910' => $this->t('Dodge Inside in Random'), 'transition0911' => $this->t('Dodge Inside in Random Chess'), 'transition0912' => $this->t('Dodge Inside in Square'), 'transition0913' => $this->t('Dodge Inside in TL'), 'transition0914' => $this->t('Dodge Inside in TR'), 'transition0915' => $this->t('Dodge Inside in BL'), 'transition0916' => $this->t('Dodge Inside in BR'), 'transition0917' => $this->t('Dodge Inside out TL'), 'transition0918' => $this->t('Dodge Inside out TR'), 'transition0919' => $this->t('Dodge Inside out BL'), 'transition0920' => $this->t('Dodge Inside out BR')], 'Flutter Outside Effects' => ['transition1001' => $this->t('Flutter Outside in'), 'transition1002' => $this->t('Flutter Outside in Wind'), 'transition1003' => $this->t('Flutter Outside in Swirl'), 'transition1004' => $this->t('Flutter Outside in Column'), 'transition1005' => $this->t('Flutter Outside out'), 'transition1006' => $this->t('Flutter Outside out Wind'), 'transition1007' => $this->t('Flutter Outside out Swirl'), 'transition1008' => $this->t('Flutter Outside out Column')], 'Flutter Inside Effects' => ['transition1101' => $this->t('Flutter Inside in'), 'transition1102' => $this->t('Flutter Inside in Wind'), 'transition1103' => $this->t('Flutter Inside in Swirl'), 'transition1104' => $this->t('Flutter Inside in Column'), 'transition1105' => $this->t('Flutter Inside out'), 'transition1106' => $this->t('Flutter Inside out Wind'), 'transition1107' => $this->t('Flutter Inside out Swirl'), 'transition1108' => $this->t('Flutter Inside out Column')], 'Rotate Effects' => ['transition1201' => $this->t('Rotate VDouble+ in'), 'transition1202' => $this->t('Rotate HDouble+ in'), 'transition1203' => $this->t('Rotate VDouble- in'), 'transition1204' => $this->t('Rotate HDouble- in'), 'transition1205' => $this->t('Rotate VDouble+ out'), 'transition1206' => $this->t('Rotate HDouble+ out'), 'transition1207' => $this->t('Rotate VDouble- out'), 'transition1208' => $this->t('Rotate HDouble- out'), 'transition1209' => $this->t('Rotate VFork+ in'), 'transition1210' => $this->t('Rotate HFork+ in'), 'transition1211' => $this->t('Rotate VFork+ out'), 'transition1212' => $this->t('Rotate HFork+ out'), 'transition1213' => $this->t('Rotate Zoom+ in'), 'transition1214' => $this->t('Rotate Zoom+ in L'), 'transition1215' => $this->t('Rotate Zoom+ in R'), 'transition1216' => $this->t('Rotate Zoom+ in T'), 'transition1217' => $this->t('Rotate Zoom+ in B'), 'transition1218' => $this->t('Rotate Zoom+ in TL'), 'transition1219' => $this->t('Rotate Zoom+ in TR'), 'transition1220' => $this->t('Rotate Zoom+ in BL'), 'transition1221' => $this->t('Rotate Zoom+ in BR'), 'transition1222' => $this->t('Rotate Zoom+ out'), 'transition1223' => $this->t('Rotate Zoom+ out L'), 'transition1224' => $this->t('Rotate Zoom+ out R'), 'transition1225' => $this->t('Rotate Zoom+ out T'), 'transition1226' => $this->t('Rotate Zoom+ out B'), 'transition1227' => $this->t('Rotate Zoom+ out TL'), 'transition1228' => $this->t('Rotate Zoom+ out TR'), 'transition1229' => $this->t('Rotate Zoom+ out BL'), 'transition1230' => $this->t('Rotate Zoom+ out BR'), 'transition1231' => $this->t('Rotate Zoom+ in'), 'transition1232' => $this->t('Rotate Zoom+ in L'), 'transition1233' => $this->t('Rotate Zoom+ in R'), 'transition1234' => $this->t('Rotate Zoom+ in T'), 'transition1235' => $this->t('Rotate Zoom+ in B'), 'transition1236' => $this->t('Rotate Zoom+ in TL'), 'transition1237' => $this->t('Rotate Zoom+ in TR'), 'transition1238' => $this->t('Rotate Zoom+ in BL'), 'transition1239' => $this->t('Rotate Zoom+ in BR'), 'transition1240' => $this->t('Rotate Zoom- out'), 'transition1241' => $this->t('Rotate Zoom- out L'), 'transition1242' => $this->t('Rotate Zoom- out R'), 'transition1243' => $this->t('Rotate Zoom- out T'), 'transition1244' => $this->t('Rotate Zoom- out B'), 'transition1245' => $this->t('Rotate Zoom- out TL'), 'transition1246' => $this->t('Rotate Zoom- out TR'), 'transition1247' => $this->t('Rotate Zoom- out BL'), 'transition1248' => $this->t('Rotate Zoom- out BR')], 'Zoom Effects' => ['transition1301' => $this->t('Zoom VDouble+ in'), 'transition1302' => $this->t('Zoom HDouble+ in'), 'transition1303' => $this->t('Zoom VDouble- in'), 'transition1304' => $this->t('Zoom HDouble- in'), 'transition1305' => $this->t('Zoom VDouble+ out'), 'transition1306' => $this->t('Zoom HDouble+ out'), 'transition1307' => $this->t('Zoom VDouble- out'), 'transition1308' => $this->t('Zoom HDouble- out'), 'transition1309' => $this->t('Zoom+ in'), 'transition1310' => $this->t('Zoom+ in L'), 'transition1311' => $this->t('Zoom+ in R'), 'transition1312' => $this->t('Zoom+ in T'), 'transition1313' => $this->t('Zoom+ in B'), 'transition1314' => $this->t('Zoom+ in TL'), 'transition1315' => $this->t('Zoom+ in TR'), 'transition1316' => $this->t('Zoom+ in BL'), 'transition1317' => $this->t('Zoom+ in BR'), 'transition1318' => $this->t('Zoom+ out'), 'transition1319' => $this->t('Zoom+ out L'), 'transition1320' => $this->t('Zoom+ out R'), 'transition1321' => $this->t('Zoom+ out T'), 'transition1322' => $this->t('Zoom+ out B'), 'transition1323' => $this->t('Zoom+ out TL'), 'transition1324' => $this->t('Zoom+ out TR'), 'transition1325' => $this->t('Zoom+ out BL'), 'transition1326' => $this->t('Zoom+ out BR'), 'transition1327' => $this->t('Zoom- in'), 'transition1328' => $this->t('Zoom- in L'), 'transition1329' => $this->t('Zoom- in R'), 'transition1330' => $this->t('Zoom- in T'), 'transition1331' => $this->t('Zoom- in B'), 'transition1332' => $this->t('Zoom- in TL'), 'transition1333' => $this->t('Zoom- in TR'), 'transition1334' => $this->t('Zoom- in BL'), 'transition1335' => $this->t('Zoom- in BR'), 'transition1336' => $this->t('Zoom- out'), 'transition1337' => $this->t('Zoom- out L'), 'transition1338' => $this->t('Zoom- out R'), 'transition1339' => $this->t('Zoom- out T'), 'transition1340' => $this->t('Zoom- out B'), 'transition1341' => $this->t('Zoom- out TL'), 'transition1342' => $this->t('Zoom- out TR'), 'transition1343' => $this->t('Zoom- out BL'), 'transition1344' => $this->t('Zoom- out BR')], 'Collapse Effects' => ['transition1401' => $this->t('Collapse Stairs'), 'transition1402' => $this->t('Collapse Swirl'), 'transition1403' => $this->t('Collapse Square'), 'transition1404' => $this->t('Collapse Rectangle Cross'), 'transition1405' => $this->t('Collapse Rectangle'), 'transition1406' => $this->t('Collapse Cross'), 'transition1407' => $this->t('Collapse Circle'), 'transition1408' => $this->t('Collapse ZigZag'), 'transition1409' => $this->t('Collapse Random')], 'Compound Effects' => ['transition1501' => $this->t('Clip & Chess in'), 'transition1502' => $this->t('Clip & Chess out'), 'transition1503' => $this->t('Clip & Oblique Chess in'), 'transition1504' => $this->t('Clip & Oblique Chess out'), 'transition1505' => $this->t('Clip & Wave in'), 'transition1506' => $this->t('Clip & Wave out'), 'transition1507' => $this->t('Clip & Jump in'), 'transition1508' => $this->t('Clip & Jump out')], 'Expand Effects' => ['transition1601' => $this->t('Expand Stairs'), 'transition1602' => $this->t('Expand Straight'), 'transition1603' => $this->t('Expand Swirl'), 'transition1604' => $this->t('Expand Square'), 'transition1605' => $this->t('Expand Rectangle Cross'), 'transition1606' => $this->t('Expand Rectangle'), 'transition1607' => $this->t('Expand Cross'), 'transition1608' => $this->t('Expand ZigZag'), 'transition1609' => $this->t('Expand Random')], 'Stripe Effects' => ['transition1701' => $this->t('Dominoes Stripe'), 'transition1702' => $this->t('Extrude out Stripe'), 'transition1703' => $this->t('Extrude in Stripe'), 'transition1704' => $this->t('Horizontal Blind Stripe'), 'transition1705' => $this->t('Vertical Blind Stripe'), 'transition1706' => $this->t('Horizontal Stripe'), 'transition1707' => $this->t('Vertical Stripe'), 'transition1708' => $this->t('Horizontal Moving Stripe'), 'transition1709' => $this->t('Vertical Moving Stripe'), 'transition1710' => $this->t('Horizontal Fade Stripe'), 'transition1711' => $this->t('Vertical Fade Stripe'), 'transition1712' => $this->t('Horizontal Fly Stripe'), 'transition1713' => $this->t('Vertical Fly Stripe'), 'transition1714' => $this->t('Horizontal Chess Stripe'), 'transition1715' => $this->t('Vertical Chess Stripe'), 'transition1716' => $this->t('Horizontal Random Fade Stripe'), 'transition1717' => $this->t('Vertical Random Fade Stripe'), 'transition1718' => $this->t('Horizontal Bounce Stripe'), 'transition1719' => $this->t('Vertical Bounce Stripe')], 'Wave out Effects' => ['transition1801' => $this->t('Wave out'), 'transition1802' => $this->t('Wave out Eagle'), 'transition1803' => $this->t('Wave out Swirl'), 'transition1804' => $this->t('Wave out ZigZag'), 'transition1805' => $this->t('Wave out Square'), 'transition1806' => $this->t('Wave out Rectangle'), 'transition1807' => $this->t('Wave out Circle'), 'transition1808' => $this->t('Wave out Cross'), 'transition1809' => $this->t('Wave out Rectangle Cross')], 'Wave in Effects' => ['transition1901' => $this->t('Wave in'), 'transition1902' => $this->t('Wave in Eagle'), 'transition1903' => $this->t('Wave in Swirl'), 'transition1904' => $this->t('Wave in ZigZag'), 'transition1905' => $this->t('Wave in Square'), 'transition1906' => $this->t('Wave in Rectangle'), 'transition1907' => $this->t('Wave in Circle'), 'transition1908' => $this->t('Wave in Cross'), 'transition1909' => $this->t('Wave in Rectangle Cross')], 'Jump out Effects' => ['transition2001' => $this->t('Jump out Straight'), 'transition2002' => $this->t('Jump out Swirl'), 'transition2003' => $this->t('Jump out ZigZag'), 'transition2004' => $this->t('Jump out Square'), 'transition2005' => $this->t('Jump out Square with Chess'), 'transition2006' => $this->t('Jump out Rectangle'), 'transition2007' => $this->t('Jump out Circle'), 'transition2008' => $this->t('Jump out Rectangle Cross')], 'Jump in Effects' => ['transition2101' => $this->t('Jump in Straight'), 'transition2101' => $this->t('Jump in Straight'), 'transition2102' => $this->t('Jump in Swirl'), 'transition2103' => $this->t('Jump in ZigZag'), 'transition2104' => $this->t('Jump in Square'), 'transition2105' => $this->t('Jump in Square with Chess'), 'transition2106' => $this->t('Jump in Rectangle'), 'transition2107' => $this->t('Jump in Circle'), 'transition2108' => $this->t('Jump in Rectangle Cross')], 'Parabola Effects' => ['transition2201' => $this->t('Parabola Swirl in'), 'transition2202' => $this->t('Parabola Swirl out'), 'transition2203' => $this->t('Parabola ZigZag in'), 'transition2204' => $this->t('Parabola ZigZag out'), 'transition2205' => $this->t('Parabola Stairs in'), 'transition2206' => $this->t('Parabola Stairs out')], 'Float Effects' => ['transition2301' => $this->t('Float Right Random'), 'transition2302' => $this->t('Float up Random'), 'transition2303' => $this->t('Float up Random with Chess'), 'transition2304' => $this->t('Float Right ZigZag'), 'transition2305' => $this->t('Float up ZigZag'), 'transition2306' => $this->t('Float up ZigZag with Chess'), 'transition2307' => $this->t('Float Right Swirl'), 'transition2308' => $this->t('Float up Swirl'), 'transition2309' => $this->t('Float up Swirl with Chess')], 'Fly Effects' => ['transition2401' => $this->t('Fly Right Random'), 'transition2402' => $this->t('Fly up Random'), 'transition2403' => $this->t('Fly up Random with Chess'), 'transition2404' => $this->t('Fly Right ZigZag'), 'transition2405' => $this->t('Fly up ZigZag'), 'transition2406' => $this->t('Fly up ZigZag with Chess'), 'transition2407' => $this->t('Fly Right Swirl'), 'transition2408' => $this->t('Fly up Swirl'), 'transition2409' => $this->t('Fly up Swirl with Chess')], 'Stone Effects' => ['transition2501' => $this->t('Slide Down'), 'transition2502' => $this->t('Slide Right'), 'transition2503' => $this->t('Bounce Down'), 'transition2504' => $this->t('Bounce Right')]]]; // Arrow navigator. $form['arrownavigator'] = array('#type' => 'fieldset', '#title' => $this->t('Arrow navigator'), '#states' => array('visible' => array(':input[name="style_options[global][arrownavigator]"]' => array('checked' => TRUE)))); $arrowskin = []; for ($i = 1; $i < 22; $i++) { $i = $i < 10 ? '0' . $i : $i; $arrowskin[$i] = $this->t('Arrow ') . $i; } $form['arrownavigator']['arrowskin'] = array('#type' => 'select', '#title' => $this->t('Skin'), '#default_value' => isset($this->options['arrownavigator']['arrowskin']) ? $this->options['arrownavigator']['arrowskin'] : $this->options['arrowskin'], '#options' => $arrowskin); $form['arrownavigator']['autocenter'] = array('#type' => 'select', '#title' => $this->t('Auto center'), '#description' => $this->t('Auto center arrows in parent container.'), '#default_value' => isset($this->options['arrownavigator']['autocenter']) ? $this->options['arrownavigator']['autocenter'] : $this->options['autocenter'], '#options' => array(0 => $this->t('No'), 1 => $this->t('Horizontal'), 2 => $this->t('Vertical'), 3 => $this->t('Both'))); $form['arrownavigator']['chancetoshow'] = array('#type' => 'select', '#title' => $this->t('Chance to show'), '#description' => $this->t('How to react on the bullet navigator.'), '#default_value' => isset($this->options['arrownavigator']['chancetoshow']) ? $this->options['arrownavigator']['chancetoshow'] : $this->options['chancetoshow'], '#options' => array(0 => $this->t('Never'), 1 => $this->t('Mouse Over'), 2 => $this->t('Always'))); $form['arrownavigator']['steps'] = array('#type' => 'number', '#title' => $this->t('Steps'), '#description' => t('Steps to go for each navigation request.'), '#attributes' => array('min' => 1, 'step' => 1, 'value' => isset($this->options['arrownavigator']['steps']) ? $this->options['arrownavigator']['steps'] : $this->options['steps'])); $form['arrownavigator']['scale'] = array('#type' => 'checkbox', '#title' => $this->t('Scales bullet navigator'), '#description' => t('Scales bullet navigator or not while slider scale.'), '#default_value' => isset($this->options['arrownavigator']['scale']) ? $this->options['arrownavigator']['scale'] : $this->options['scale']); // Bullet navigators. $form['bulletnavigator'] = array('#type' => 'fieldset', '#title' => $this->t('Bullet navigator'), '#states' => array('visible' => array(':input[name="style_options[global][bulletnavigator]"]' => array('checked' => TRUE)))); $bulletskin = []; for ($i = 1; $i < 22; $i++) { $i = $i < 10 ? '0' . $i : $i; $bulletskin[$i] = $this->t('Bullet ') . $i; } $form['bulletnavigator']['bulletskin'] = array('#type' => 'select', '#title' => $this->t('Skin'), '#default_value' => isset($this->options['bulletnavigator']['bulletskin']) ? $this->options['bulletnavigator']['bulletskin'] : $this->options['bulletskin'], '#options' => $bulletskin); $form['bulletnavigator']['chancetoshow'] = array('#type' => 'select', '#title' => $this->t('Chance to show'), '#description' => $this->t('When to display the bullet navigator.'), '#default_value' => isset($this->options['bulletnavigator']['chancetoshow']) ? $this->options['bulletnavigator']['chancetoshow'] : $this->options['chancetoshow'], '#options' => array(0 => $this->t('Never'), 1 => $this->t('Mouse Over'), 2 => $this->t('Always'))); $form['bulletnavigator']['action_mode'] = array('#type' => 'select', '#title' => $this->t('Action mode'), '#description' => $this->t('How to react on the bullet navigator.'), '#default_value' => isset($this->options['bulletnavigator']['action_mode']) ? $this->options['bulletnavigator']['action_mode'] : $this->options['action_mode'], '#options' => array(0 => $this->t('None'), 1 => $this->t('Act by click'), 2 => $this->t('Act by mouse hover'), 3 => $this->t('Act by click or mouse hover'))); $form['bulletnavigator']['autocenter'] = array('#type' => 'select', '#title' => $this->t('Auto center'), '#description' => $this->t('Auto center arrows in parent container.'), '#default_value' => isset($this->options['bulletnavigator']['autocenter']) ? $this->options['bulletnavigator']['autocenter'] : $this->options['autocenter'], '#options' => array(0 => $this->t('No'), 1 => $this->t('Horizontal'), 2 => $this->t('Vertical'), 3 => $this->t('Both'))); $form['bulletnavigator']['rows'] = array('#type' => 'number', '#title' => $this->t('Rows'), '#description' => t('Rows to arrange bullets.'), '#attributes' => array('min' => 1, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['rows']) ? $this->options['bulletnavigator']['rows'] : $this->options['rows'])); $form['bulletnavigator']['steps'] = array('#type' => 'number', '#title' => $this->t('Steps'), '#description' => t('Steps to go for each navigation request.'), '#attributes' => array('min' => 1, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['steps']) ? $this->options['bulletnavigator']['steps'] : $this->options['steps'])); $form['bulletnavigator']['spacingx'] = array('#type' => 'number', '#title' => $this->t('Horizontal space'), '#description' => t('Horizontal space between each item in pixel.'), '#attributes' => array('min' => 0, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['spacingx']) ? $this->options['bulletnavigator']['spacingx'] : $this->options['spacingx'])); $form['bulletnavigator']['spacingy'] = array('#type' => 'number', '#title' => $this->t('Vertical space'), '#description' => t('Vertical space between each item in pixel.'), '#attributes' => array('min' => 0, 'step' => 1, 'value' => isset($this->options['bulletnavigator']['spacingy']) ? $this->options['bulletnavigator']['spacingy'] : $this->options['spacingy'])); $form['bulletnavigator']['orientation'] = array('#type' => 'select', '#title' => $this->t('Orientation'), '#description' => t('The orientation of the navigator.'), '#default_value' => isset($this->options['bulletnavigator']['orientation']) ? $this->options['bulletnavigator']['orientation'] : $this->options['orientation'], '#options' => array(1 => $this->t('Horizontal'), 2 => $this->t('Vertical'))); $form['bulletnavigator']['scale'] = array('#type' => 'checkbox', '#title' => $this->t('Scales bullet navigator'), '#description' => t('Scales bullet navigator or not while slider scale.'), '#default_value' => isset($this->options['bulletnavigator']['scale']) ? $this->options['bulletnavigator']['scale'] : $this->options['scale']); }
public function evenEmpty() { return parent::evenEmpty() || !empty($this->options['empty_table']); }
public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['description'] = array('#type' => 'textfield', '#title' => $this->t('RSS description'), '#default_value' => $this->options['description'], '#description' => $this->t('This will appear in the RSS feed itself.'), '#maxlength' => 1024); }
/** * Overrides Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm(). */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['test_option'] = array('#title' => $this->t('Test option'), '#type' => 'textfield', '#description' => $this->t('This is a textfield for test_option.'), '#default_value' => $this->options['test_option']); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $options = $this->displayHandler->getFieldLabels(TRUE); $form['tab_nav_field'] = array('#title' => $this->t('The tab navigation field'), '#description' => $this->t('Select the field that will be used as the tab navigation. The rest of the fields will show up in the tab content.'), '#type' => 'select', '#default_value' => $this->options['tab_nav_field'], '#options' => $options); }
/** * Unset references so that a $view object may be properly garbage * collected. */ public function destroy() { foreach ($this::getHandlerTypes() as $type => $info) { if (isset($this->{$type})) { foreach ($this->{$type} as $handler) { $handler->destroy(); } } } if (isset($this->style_plugin)) { $this->style_plugin->destroy(); } $reflection = new \ReflectionClass($this); $defaults = $reflection->getDefaultProperties(); // The external dependencies should not be reset. This is not generated by // the execution of a view. unset($defaults['storage'], $defaults['user'], $defaults['request'], $defaults['routeProvider']); foreach ($defaults as $property => $default) { $this->{$property} = $default; } }
/** * {@inheritdoc} */ public function validate() { $errors = parent::validate(); $pager_options = $this->displayHandler->getOption('pager'); if (isset($pager_options['type']) && !($pager_options['type'] == 'none' || $pager_options['type'] == 'some')) { // @todo: Re-enable this error once issue #2579931 is resolved. // $errors[] = $this->stringTranslation->translate('The Juicebox style cannot be used with a pager. Please disable the "Use a pager" option for this display.'); } $style = $this->displayHandler->getOption('style'); // We want to somewhat "nag" the user if they have not yet configured the // Juicebox-specific plugin settings (because things won't work until they // do). However, we do NOT want to formally set an error. This is because // this validate method can run on pages where the user can't actaully touch // the Juicebox-specific plugin settings (such as // admin/structure/views/add). if (empty($style['options']['image_field']) || empty($style['options']['thumb_field'])) { drupal_set_message($this->stringTranslation->translate("To ensure a fully functional Juicebox gallery please remember to add at least one field of type Image, File or File ID to your Juicebox view display, and to configure all Juicebox Gallery format settings. Once you have completed these steps, re-save your view to remove this warning."), 'warning', FALSE); } return $errors; }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); // Wrap all the form elements to help style the form. $form['views_slideshow_wrapper'] = array('#markup' => '<div id="views-slideshow-form-wrapper">'); // Skins. $form['slideshow_skin_header'] = array('#markup' => '<h2>' . t('Style') . '</h2>'); /** @var \Drupal\Component\Plugin\PluginManagerInterface */ $skinManager = \Drupal::service('plugin.manager.views_slideshow.slideshow_skin'); // Get all skins to create the option list. $skins = []; foreach ($skinManager->getDefinitions() as $id => $definition) { $skins[$id] = $definition['label']; } asort($skins); // Create the drop down box so users can choose an available skin. $form['slideshow_skin'] = array('#type' => 'select', '#title' => t('Skin'), '#options' => $skins, '#default_value' => $this->options['slideshow_skin'], '#description' => t('Select the skin to use for this display. Skins allow for easily swappable layouts of things like next/prev links and thumbnails. Note that not all skins support all widgets, so a combination of skins and widgets may lead to unpredictable results in layout.')); // Slides. $form['slides_header'] = array('#markup' => '<h2>' . t('Slides') . '</h2>'); // Get all slideshow types. $typeManager = \Drupal::service('plugin.manager.views_slideshow.slideshow_type'); $types = $typeManager->getDefinitions(); if ($types) { // Build our slideshow options for the form. $slideshow_options = array(); foreach ($types as $id => $definition) { $slideshow_options[$id] = $definition['label']; } $form['slideshow_type'] = array('#type' => 'select', '#title' => t('Slideshow Type'), '#options' => $slideshow_options, '#default_value' => $this->options['slideshow_type']); // @todo: check if default values are properly passed to the buildConfigurationForm(). foreach ($types as $id => $definition) { $configuration = []; if (!empty($this->options[$id])) { $configuration = $this->options[$id]; } $instance = $typeManager->createInstance($id, $configuration); $form[$id] = array('#type' => 'fieldset', '#title' => t('@module options', array('@module' => $definition['label'])), '#collapsible' => TRUE, '#attributes' => array('class' => array($id)), '#states' => array('visible' => array(':input[name="style_options[slideshow_type]"]' => array('value' => $id)))); $form = $instance->buildConfigurationForm($form, $form_state); } } else { $form['enable_module'] = array('#markup' => t('There is no Views Slideshow plugin enabled. Go to the @modules and enable a Views Slideshow plugin module. For example Views Slideshow Singleframe.', array('@modules' => \Drupal::l(t('Modules Page'), Url::fromRoute('system.modules_list'))))); } // Widgets. // @todo: Improve the UX by using Ajax. $form['widgets_header'] = array('#markup' => '<h2>' . t('Widgets') . '</h2>'); // Define the available locations. $location = array('top' => t('Top'), 'bottom' => t('Bottom')); // Loop through all locations so we can add header for each location. foreach ($location as $location_id => $location_name) { $form['widgets'][$location_id]['header'] = array('#markup' => '<h3>' . t('@location Widgets', array('@location' => $location_name)) . '</h3>'); } /** @var \Drupal\Component\Plugin\PluginManagerInterface */ $widgetTypeManager = \Drupal::service('plugin.manager.views_slideshow.widget_type'); // Get all widgets types that are registered. $widgets = $widgetTypeManager->getDefinitions(); if (!empty($widgets)) { // Build our weight values by number of widgets $weights = []; for ($i = 1; $i <= count($widgets); $i++) { $weights[$i] = $i; } // Loop through our widgets and locations to build our form values for // each widget. foreach ($widgets as $widget_id => $widget_info) { // Determine if this widget type is compatible with any slideshow type. $compatible_slideshows = []; foreach ($types as $slideshow_id => $slideshow_info) { if ($widgetTypeManager->createInstance($widget_id, [])->checkCompatiblity($slideshow_info)) { $compatible_slideshows[] = $slideshow_id; } } // Display the widget config form only if the widget type is compatible // with at least one slideshow type. if (!empty($compatible_slideshows)) { foreach ($location as $location_id => $location_name) { // Use Widget Checkbox. $form['widgets'][$location_id][$widget_id]['enable'] = array('#type' => 'checkbox', '#title' => $widget_info['label'], '#default_value' => $this->options['widgets'][$location_id][$widget_id]['enable'], '#description' => t('Should @name be rendered at the @location of the slides.', array('@name' => $widget_info['label'], '@location' => $location_name)), '#dependency' => array('edit-style-options-slideshow-type' => $compatible_slideshows)); // Need to wrap this so it indents correctly. $form['widgets'][$location_id][$widget_id]['wrapper'] = ['#markup' => '<div class="vs-dependent">']; // Widget weight. // We check to see if the default value is greater than the number // of widgets just in case a widget has been removed and the form // hasn't been saved again. $weight = isset($this->options['widgets'][$location_id][$widget_id]['weight']) ? $this->options['widgets'][$location_id][$widget_id]['weight'] : 0; if ($weight > count($widgets)) { $weight = count($widgets); } $form['widgets'][$location_id][$widget_id]['weight'] = ['#type' => 'select', '#title' => t('Weight of the @name', ['@name' => $widget_info['label']]), '#default_value' => $weight, '#options' => $weights, '#description' => t('Determines in what order the @name appears. A lower weight will cause the @name to be above higher weight items.', ['@name' => $widget_info['label']]), '#prefix' => '<div class="vs-dependent">', '#suffix' => '</div>', '#states' => ['visible' => [':input[name="style_options[widgets][' . $location_id . '][' . $widget_id . '][enable]"]' => ['checked' => TRUE]]]]; // Build the appropriate array for the states API. $widget_dependency = 'style_options[widgets][' . $location_id . '][' . $widget_id . ']'; // Get the current configuration of this widget type. $configuration = []; if (!empty($this->options['widgets'][$location_id][$widget_id])) { $configuration = $this->options['widgets'][$location_id][$widget_id]; } $configuration['dependency'] = $widget_dependency; $instance = $widgetTypeManager->createInstance($widget_id, $configuration); // Get the configuration form of this widget type. $form['widgets'][$location_id][$widget_id] = $instance->buildConfigurationForm($form['widgets'][$location_id][$widget_id], $form_state); // Close the vs-dependent wrapper. $form['widgets'][$location_id][$widget_id]['wrapper_close'] = ['#markup' => '</div>']; } } } } // Browse locations and remove the header if no widget is available. foreach ($location as $location_id => $location_name) { // If no widget is available, the only key is "header". if (count(array_keys($form['widgets'][$location_id])) == 1) { unset($form['widgets'][$location_id]); } } // Remove the widget section header if there is no widget available. if (empty($form['widgets'])) { unset($form['widgets']); unset($form['widgets_header']); } $form['views_slideshow_wrapper_close'] = ['#markup' => '</div>']; // Add a library to style the form. $form['#attached']['library'] = ['views_slideshow/form']; }
/** * {@inheritdoc} */ public function submitOptionsForm(&$form, FormStateInterface $form_state) { parent::submitOptionsForm($form, $form_state); /* Move flexslider options to the parent array so that * values are saved properly. * Original: values['style_options']['flexslider'] = ['options', 'caption', 'id']. */ $flexslider_options = $form_state->getValue(array('style_options', 'flexslider')); // Edit: values['style_options'] += ['options', 'caption', 'id']. foreach ($flexslider_options as $key => $value) { $form_state->setValue(array('style_options', $key), $value); } // Edit: values['style_options']['flexslider'] = NULL. $form_state->setValue(array('style_options', 'flexslider'), NULL); }
/** * {@inheritdoc} */ public function submitOptionsForm(&$form, &$form_state) { parent::submitOptionsForm($form, $form_state); $form_state['values']['style_options']['formats'] = array_filter($form_state['values']['style_options']['formats']); }
/** * {@inheritdoc} */ public function validateOptionsForm(&$form, FormStateInterface $form_state) { $errors = parent::validateOptionsForm($form, $form_state); if ($this->view->usePager()) { $errors[] = t('The jCarousel style cannot be used with a pager. Disable the "Use pager" option for this display.'); } return $errors; }