/**
  * Test responsive image administration functionality.
  */
 public function testResponsiveImageAdmin()
 {
     // We start without any default styles.
     $this->drupalGet('admin/config/media/responsive-image-style');
     $this->assertText('There is no Responsive image style yet.');
     // Add a new responsive image style, our breakpoint set should be selected.
     $this->drupalGet('admin/config/media/responsive-image-style/add');
     $this->assertFieldByName('breakpoint_group', 'responsive_image_test_module');
     // Create a new group.
     $edit = array('label' => 'Style One', 'id' => 'style_one', 'breakpoint_group' => 'responsive_image_test_module', 'fallback_image_style' => 'thumbnail');
     $this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
     // Check if the new group is created.
     $this->assertResponse(200);
     $this->drupalGet('admin/config/media/responsive-image-style');
     $this->assertNoText('There is no Responsive image style yet.');
     $this->assertText('Style One');
     $this->assertText('style_one');
     // Edit the group.
     $this->drupalGet('admin/config/media/responsive-image-style/style_one');
     $this->assertFieldByName('label', 'Style One');
     $this->assertFieldByName('breakpoint_group', 'responsive_image_test_module');
     $this->assertFieldByName('fallback_image_style', 'thumbnail');
     $cases = array(array('mobile', '1x'), array('mobile', '2x'), array('narrow', '1x'), array('narrow', '2x'), array('wide', '1x'), array('wide', '2x'));
     foreach ($cases as $case) {
         // Check if the radio buttons are present.
         $this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][image_mapping_type]', '');
         // Check if the image style dropdowns are present.
         $this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][image_style]', '');
         // Check if the sizes textfields are present.
         $this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][sizes]', '');
         // Check if the image styles checkboxes are present.
         foreach (array_keys(image_style_options(FALSE)) as $image_style_name) {
             $this->assertFieldByName('keyed_styles[responsive_image_test_module.' . $case[0] . '][' . $case[1] . '][sizes_image_styles][' . $image_style_name . ']');
         }
     }
     // Save styles for 1x variant only.
     $edit = array('label' => 'Style One', 'breakpoint_group' => 'responsive_image_test_module', 'fallback_image_style' => 'thumbnail', 'keyed_styles[responsive_image_test_module.mobile][1x][image_mapping_type]' => 'image_style', 'keyed_styles[responsive_image_test_module.mobile][1x][image_style]' => 'thumbnail', 'keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]' => 'sizes', 'keyed_styles[responsive_image_test_module.narrow][1x][sizes]' => '(min-width: 700px) 700px, 100vw', 'keyed_styles[responsive_image_test_module.narrow][1x][sizes_image_styles][large]' => 'large', 'keyed_styles[responsive_image_test_module.narrow][1x][sizes_image_styles][medium]' => 'medium', 'keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]' => 'image_style', 'keyed_styles[responsive_image_test_module.wide][1x][image_style]' => 'large');
     $this->drupalPostForm('admin/config/media/responsive-image-style/style_one', $edit, t('Save'));
     $this->drupalGet('admin/config/media/responsive-image-style/style_one');
     // Check the mapping for multipliers 1x and 2x for the mobile breakpoint.
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][1x][image_style]', 'thumbnail');
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][1x][image_mapping_type]', 'image_style');
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.mobile][2x][image_mapping_type]', '_none');
     // Check the mapping for multipliers 1x and 2x for the narrow breakpoint.
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]', 'sizes');
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][1x][sizes]', '(min-width: 700px) 700px, 100vw');
     $this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-large');
     $this->assertFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-medium');
     $this->assertNoFieldChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-thumbnail');
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.narrow][2x][image_mapping_type]', '_none');
     // Check the mapping for multipliers 1x and 2x for the wide breakpoint.
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][1x][image_style]', 'large');
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]', 'image_style');
     $this->assertFieldByName('keyed_styles[responsive_image_test_module.wide][2x][image_mapping_type]', '_none');
     // Delete the style.
     $this->drupalGet('admin/config/media/responsive-image-style/style_one/delete');
     $this->drupalPostForm(NULL, array(), t('Delete'));
     $this->drupalGet('admin/config/media/responsive-image-style');
     $this->assertText('There is no Responsive image style yet.');
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->configFactory->get('youtube.settings');
     $form['text'] = array('#type' => 'markup', '#markup' => '<p>' . t('The following settings will be used as default
     values on all YouTube video fields.  Many of these settings can be
     overridden on a per-field basis.') . '</p>');
     $form['youtube_global'] = array('#type' => 'fieldset', '#title' => t('Video parameters'));
     $form['youtube_global']['youtube_suggest'] = array('#type' => 'checkbox', '#title' => t('Show suggested videos when the video finishes'), '#default_value' => $config->get('youtube_suggest'));
     $form['youtube_global']['youtube_modestbranding'] = array('#type' => 'checkbox', '#title' => t('Do not show YouTube logo on video player control bar
     (modestbranding).'), '#default_value' => $config->get('youtube_modestbranding'));
     $form['youtube_global']['youtube_theme'] = array('#type' => 'checkbox', '#title' => t('Use a light colored control bar for video player controls
     (theme).'), '#default_value' => $config->get('youtube_theme'));
     $form['youtube_global']['youtube_color'] = array('#type' => 'checkbox', '#title' => t('Use a white colored video progress bar (color).'), '#default_value' => $config->get('youtube_color'), '#description' => t('Note: the modestbranding parameter will be ignored
     when this is in use.'));
     $form['youtube_global']['youtube_enablejsapi'] = array('#type' => 'checkbox', '#title' => t('Enable use of the IFrame API (enablejsapi, origin).'), '#default_value' => $config->get('youtube_enablejsapi'), '#description' => t('For more information on the IFrame API and how to use
     it, see the <a href="@api_reference">IFrame API documentation</a>.', array('@api_reference' => 'https://developers.google.com/youtube/iframe_api_reference')));
     $form['youtube_global']['youtube_wmode'] = array('#type' => 'checkbox', '#title' => t('Fix overlay problem on IE8 and lower'), '#default_value' => $config->get('youtube_wmode'), '#description' => t('Checking this will fix the issue of a YouTube video
     showing above a modal window (including Drupal\'s Overlay). This is
     needed if you have Overlay users in IE or have modal windows throughout
     your site.'));
     $form['youtube_thumbs'] = array('#type' => 'fieldset', '#title' => t('Thumbnails'));
     $form['youtube_thumbs']['youtube_thumb_dir'] = array('#type' => 'textfield', '#title' => t('YouTube thumbnail directory'), '#field_prefix' => Settings::get('file_public_path', \Drupal::service('kernel')->getSitePath() . '/files') . '/', '#field_suffix' => '/thumbnail.jpg', '#description' => t('Location, within the files directory, where you would
     like the YouTube thumbnails stored.'), '#default_value' => $config->get('youtube_thumb_dir'));
     $form['youtube_thumbs']['youtube_thumb_hires'] = array('#type' => 'checkbox', '#title' => t('Save higher resolution thumbnail images'), '#description' => t('This will save thumbnails larger than the default
     size, 480x360, to the thumbnails directory specified above.'), '#default_value' => $config->get('youtube_thumb_hires'));
     $form['youtube_thumbs']['youtube_thumb_token_image_style'] = array('#type' => 'select', '#options' => image_style_options(TRUE), '#title' => t('Default token image style'), '#description' => t('Default image style for the output of a
     youtube_image_url token.'), '#default_value' => $config->get('youtube_thumb_token_image_style'));
     $form['youtube_thumbs']['youtube_thumb_delete_all'] = array('#type' => 'submit', '#value' => t('Refresh existing thumbnail image files'), '#submit' => array('youtube_thumb_delete_all'));
     $form['youtube_privacy'] = array('#type' => 'checkbox', '#title' => t('Enable privacy-enhanced mode'), '#default_value' => $config->get('youtube_privacy'), '#description' => t('Checking this box will prevent YouTube from setting
     cookies in your site visitors browser.'));
     $form['youtube_player_class'] = array('#type' => 'textfield', '#title' => t('YouTube player class'), '#default_value' => $config->get('youtube_player_class'), '#description' => t('The iframe of every player will be given this class.
     They will also be given IDs based off of this value.'));
     return parent::buildForm($form, $form_state);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $entity = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => 'Label', '#default_value' => $entity->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $entity->id(), '#required' => TRUE, '#machine_name' => array('exists' => [$this, 'exists'], 'replace_pattern' => '[^a-z0-9_.]+'));
     $form['weight'] = array('#type' => 'weight', '#title' => 'Weight', '#default_value' => $entity->get('weight'));
     $form['style'] = array('#type' => 'select', '#title' => 'Image style', '#options' => array(), '#default_value' => $entity->get('style'), '#access' => FALSE);
     if ($this->moduleHandler->moduleExists('image')) {
         $form['style']['#access'] = TRUE;
         $form['style']['#options'] = image_style_options();
     }
     // The main premise of entity forms is that we get to work with an entity
     // object at all times instead of checking submitted values from the form
     // state.
     $size = $entity->get('size');
     $form['size_wrapper'] = array('#type' => 'container', '#attributes' => array('id' => 'size-wrapper'));
     $form['size_wrapper']['size'] = array('#type' => 'select', '#title' => 'Size', '#options' => array('custom' => 'Custom'), '#empty_option' => '- None -', '#default_value' => $size, '#ajax' => array('callback' => '::updateSize', 'wrapper' => 'size-wrapper'));
     $form['size_wrapper']['size_submit'] = array('#type' => 'submit', '#value' => t('Change size'), '#attributes' => array('class' => array('js-hide')), '#submit' => array(array(get_class($this), 'changeSize')));
     $form['size_wrapper']['size_value'] = array('#type' => 'select', '#title' => 'Custom size value', '#options' => array('small' => 'Small', 'medium' => 'Medium', 'large' => 'Large'), '#default_value' => $entity->get('size_value'), '#access' => !empty($size));
     $form['langcode'] = array('#type' => 'language_select', '#title' => t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $entity->language()->getId());
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Save');
     $form['actions']['delete'] = array('#type' => 'submit', '#value' => 'Delete');
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = array();
     $image_styles = image_style_options(FALSE);
     // Unset possible 'No defined styles' option.
     unset($image_styles['']);
     // Styles could be lost because of enabled/disabled modules that defines
     // their styles in code.
     if (isset($image_styles[$this->getSetting('colorbox_node_style')])) {
         $summary[] = t('Content image style: @style', array('@style' => $image_styles[$this->getSetting('colorbox_node_style')]));
     } elseif ($this->getSetting('colorbox_node_style') == 'hide') {
         $summary[] = t('Content image style: Hide');
     } else {
         $summary[] = t('Content image style: Original image');
     }
     if (isset($image_styles[$this->getSetting('colorbox_node_style_first')])) {
         $summary[] = t('Content image style of first image: @style', array('@style' => $image_styles[$this->getSetting('colorbox_node_style_first')]));
     }
     if (isset($image_styles[$this->getSetting('colorbox_image_style')])) {
         $summary[] = t('Colorbox image style: @style', array('@style' => $image_styles[$this->getSetting('colorbox_image_style')]));
     } else {
         $summary[] = t('Colorbox image style: Original image');
     }
     $gallery = array('post' => t('Per post gallery'), 'page' => t('Per page gallery'), 'field_post' => t('Per field in post gallery'), 'field_page' => t('Per field in page gallery'), 'custom' => t('Custom (with tokens)'), 'none' => t('No gallery'));
     if ($this->getSetting('colorbox_gallery')) {
         $summary[] = t('Colorbox gallery type: @type', array('@type' => $gallery[$this->getSetting('colorbox_gallery')])) . ($this->getSetting('colorbox_gallery') == 'custom' ? ' (' . $this->getSetting('colorbox_gallery_custom') . ')' : '');
     }
     $caption = array('auto' => t('Automatic'), 'title' => t('Title text'), 'alt' => t('Alt text'), 'entity_title' => t('Content title'), 'custom' => t('Custom (with tokens)'), 'none' => t('None'));
     if ($this->getSetting('colorbox_caption')) {
         $summary[] = t('Colorbox caption: @type', array('@type' => $caption[$this->getSetting('colorbox_caption')]));
     }
     return $summary;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = [];
     $image_styles = image_style_options(FALSE);
     // Unset possible 'No defined styles' option.
     unset($image_styles['']);
     // Styles could be lost because of enabled/disabled modules that defines
     // their styles in code.
     $image_style_setting = $this->getSetting('first_image_style');
     if (!isset($image_styles[$image_style_setting])) {
         $image_styles[$image_style_setting] = t('Original image');
     }
     $summary[] = t('First image style: @style', ['@style' => $image_styles[$image_style_setting]]);
     $image_style_setting = $this->getSetting('other_image_style');
     if (!isset($image_styles[$image_style_setting])) {
         $image_styles[$image_style_setting] = t('Original image');
     }
     $summary[] = t('Subsequent image style: @style', ['@style' => $image_styles[$image_style_setting]]);
     $link_types = array('content' => t('Linked to content'), 'file' => t('Linked to file'));
     // Display this setting only if image is linked.
     $image_link_setting = $this->getSetting('image_link');
     if (isset($link_types[$image_link_setting])) {
         $summary[] = $link_types[$image_link_setting];
     }
     return $summary;
 }
Example #6
0
  /**
   * Provide the options form.
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    // Link options.
    $form['link_photo'] = array(
      '#title' => t("Link image"),
      '#description' => t("Link the image to the album page or image page."),
      '#type' => 'radios',
      '#options' => array(
        '' => $this->t('None'),
        'album' => $this->t('Album page'),
        'image' => $this->t('Image page')
      ),
      '#default_value' => $this->options['link_photo']
    );

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

    parent::buildOptionsForm($form, $form_state);
  }
 /**
  * Overrides Drupal\Core\Entity\EntityForm::form().
  *
  * @param array $form
  *   A nested array form elements comprising the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  * @param \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping
  *   The entity being edited.
  *
  * @return array
  *   The array containing the complete form.
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     if ($this->operation == 'duplicate') {
         $form['#title'] = $this->t('<em>Duplicate responsive image mapping</em> @label', array('@label' => $this->entity->label()));
         $this->entity = $this->entity->createDuplicate();
     }
     if ($this->operation == 'edit') {
         $form['#title'] = $this->t('<em>Edit responsive image mapping</em> @label', array('@label' => $this->entity->label()));
     }
     /** @var \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping */
     $responsive_image_mapping = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $responsive_image_mapping->label(), '#description' => $this->t("Example: 'Hero image' or 'Author image'."), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $responsive_image_mapping->id(), '#machine_name' => array('exists' => '\\Drupal\\responsive_image\\Entity\\ResponsiveImageMapping::load', 'source' => array('label')), '#disabled' => (bool) $responsive_image_mapping->id() && $this->operation != 'duplicate');
     if ((bool) $responsive_image_mapping->id() && $this->operation != 'duplicate') {
         $description = $this->t('Select a breakpoint group from the enabled themes.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your selected mappings.");
     } else {
         $description = $this->t('Select a breakpoint group from the enabled themes.');
     }
     $form['breakpointGroup'] = array('#type' => 'select', '#title' => $this->t('Breakpoint group'), '#default_value' => $responsive_image_mapping->getBreakpointGroup() != '' ? $responsive_image_mapping->getBreakpointGroup()->id() : '', '#options' => breakpoint_group_select_options(), '#required' => TRUE, '#description' => $description);
     $image_styles = image_style_options(TRUE);
     $image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('- empty image -');
     foreach ($responsive_image_mapping->getMappings() as $breakpoint_id => $mapping) {
         foreach ($mapping as $multiplier => $image_style) {
             $breakpoint = $responsive_image_mapping->getBreakpointGroup()->getBreakpointById($breakpoint_id);
             $label = $multiplier . ' ' . $breakpoint->name . ' [' . $breakpoint->mediaQuery . ']';
             $form['mappings'][$breakpoint_id][$multiplier] = array('#type' => 'select', '#title' => String::checkPlain($label), '#options' => $image_styles, '#default_value' => $image_style, '#description' => $this->t('Select an image style for this breakpoint.'));
         }
     }
     $form['#tree'] = TRUE;
     return parent::form($form, $form_state, $responsive_image_mapping);
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $element = parent::settingsForm($form, $form_state);
     $element['image_style'] = ['#title' => $this->t('Image Style'), '#type' => 'select', '#default_value' => $this->getSetting('image_style'), '#required' => FALSE, '#options' => image_style_options()];
     $element['link_image_to'] = ['#title' => $this->t('Link image to'), '#type' => 'select', '#empty_option' => $this->t('- None -'), '#default_value' => $this->getSetting('link_image_to'), '#options' => [static::LINK_CONTENT => $this->t('Content'), static::LINK_PROVIDER => $this->t('Provider URL')]];
     return $element;
 }
 /**
  * Returns a list of image style replacement options.
  *
  * @return array
  *   An option list suitable for the form select '#options'.
  */
 protected function getReplacementOptions()
 {
     if (!isset($this->replacementOptions)) {
         $this->replacementOptions = array_diff_key(image_style_options(), [$this->getEntity()->id() => '']);
     }
     return $this->replacementOptions;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $elements['image_style'] = array('#type' => 'select', '#title' => t('Image style'), '#options' => image_style_options(FALSE), '#default_value' => $this->getSetting('image_style'), '#empty_option' => t('None (original image)'));
     $link_types = array('content' => t('Content'), 'youtube' => t('YouTube'));
     $elements['image_link'] = array('#title' => t('Link image to'), '#type' => 'select', '#default_value' => $this->getSetting('image_link'), '#empty_option' => t('Nothing'), '#options' => $link_types);
     return $elements;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $image_styles = image_style_options(FALSE);
     $thumb_image_style = $this->getSetting('thumbnail_image_style');
     $popup_image_style = $this->getSetting('popup_image_style');
     // Check image styles exist or display 'Original Image'.
     $summary[] = t('Thumbnail image style: @thumb_style. Popup image style: @popup_style', ['@thumb_style' => isset($image_styles[$thumb_image_style]) ? $thumb_image_style : 'Original Image', '@popup_style' => isset($image_styles[$popup_image_style]) ? $popup_image_style : 'Original Image']);
     return $summary;
 }
 /**
  * Test creating an image style with a numeric name and ensuring it can be
  * applied to an image.
  */
 function testNumericStyleName()
 {
     $style_name = rand();
     $style_label = $this->randomString();
     $edit = array('name' => $style_name, 'label' => $style_label);
     $this->drupalPostForm('admin/config/media/image-styles/add', $edit, t('Create new style'));
     $this->assertRaw(t('Style %name was created.', array('%name' => $style_label)));
     $options = image_style_options();
     $this->assertTrue(array_key_exists($style_name, $options), format_string('Array key %key exists.', array('%key' => $style_name)));
 }
 /**
  * {inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['#form_horizontal'] = true;
     $form['interface'] = ['#type' => 'fieldset', '#title' => $this->t("User interface")];
     $form['interface'][APB_VAR_USER_PAGER_LIMIT] = ['#type' => 'select', '#title' => $this->t("User notification page limit"), '#options' => drupal_map_assoc([5, 10, 20, 30, 50, 100]), '#description' => $this->t("Number of notifications being displayed per page in user notification page."), '#default_value' => variable_get(APB_VAR_USER_PAGER_LIMIT, APB_DEF_USER_PAGER_LIMIT)];
     $form['interface'][APB_VAR_USER_BLOCK_LIMIT] = ['#type' => 'select', '#title' => $this->t("User notification block limit"), '#options' => drupal_map_assoc([3, 5, 8, 10, 13, 15, 20]), '#description' => $this->t("Number of notifications being displayed per in the user notification block."), '#default_value' => variable_get(APB_VAR_USER_BLOCK_LIMIT, APB_DEF_USER_BLOCK_LIMIT)];
     $form['interface'][APB_VAR_IMG_STYLE] = ['#type' => 'select', '#title' => $this->t("Notification image style"), '#empty_option' => $this->t("Do not display image"), '#options' => image_style_options(true), '#description' => $this->t("Number of notifications being displayed per page in user notification page."), '#default_value' => variable_get(APB_VAR_IMG_STYLE, APB_DEF_IMG_STYLE)];
     $form['advanced'] = ['#type' => 'fieldset', '#title' => $this->t("Advanced / Performance")];
     $form['advanced'][APB_VAR_ENABLE_PROD] = ['#type' => 'checkbox', '#title' => $this->t("Enable production mode"), '#description' => $this->t("Will suppress some warnings, errors and exceptions. Always check this option on a production site."), '#default_value' => variable_get(APB_VAR_ENABLE_PROD, APB_DEF_ENABLE_PROD)];
     $form['advanced'][APB_VAR_ENABLE_FORMATTED_CONTENT] = ['#type' => 'checkbox', '#title' => $this->t("Store content inside messages"), '#description' => $this->t("If checked, formatted messages will be sent in the message contents instead of being formatted at view time. This will bypass translation but allows you to display those notifications outside of the originating website. If checked generated links inside formatted notifications will all be absolute. Note that if you change this setting and data has already been sent some notifications might not be displayed correctly."), '#default_value' => variable_get(APB_VAR_ENABLE_FORMATTED_CONTENT, APB_DEF_ENABLE_FORMATTED_CONTENT)];
     return system_settings_form($form);
 }
 /**
  * Overrides Drupal\Core\Entity\EntityForm::form().
  *
  * @param array $form
  *   A nested array form elements comprising the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return array
  *   The array containing the complete form.
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     if ($this->operation == 'duplicate') {
         $form['#title'] = $this->t('<em>Duplicate responsive image style</em> @label', array('@label' => $this->entity->label()));
         $this->entity = $this->entity->createDuplicate();
     }
     if ($this->operation == 'edit') {
         $form['#title'] = $this->t('<em>Edit responsive image style</em> @label', array('@label' => $this->entity->label()));
     }
     /** @var \Drupal\responsive_image\ResponsiveImageStyleInterface $responsive_image_style */
     $responsive_image_style = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $responsive_image_style->label(), '#description' => $this->t("Example: 'Hero image' or 'Author image'."), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $responsive_image_style->id(), '#machine_name' => array('exists' => '\\Drupal\\responsive_image\\Entity\\ResponsiveImageStyle::load', 'source' => array('label')), '#disabled' => (bool) $responsive_image_style->id() && $this->operation != 'duplicate');
     $image_styles = image_style_options(TRUE);
     $image_styles[RESPONSIVE_IMAGE_ORIGINAL_IMAGE] = $this->t('- None (original image) -');
     $image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('- empty image -');
     if ((bool) $responsive_image_style->id() && $this->operation != 'duplicate') {
         $description = $this->t('Select a breakpoint group from the installed themes and modules. Below you can select which breakpoints to use from this group. You can also select which image style or styles to use for each breakpoint you use.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your image style selections for each breakpoint.");
     } else {
         $description = $this->t('Select a breakpoint group from the installed themes and modules.');
     }
     $form['breakpoint_group'] = array('#type' => 'select', '#title' => $this->t('Breakpoint group'), '#default_value' => $responsive_image_style->getBreakpointGroup() ?: 'responsive_image', '#options' => $this->breakpointManager->getGroups(), '#required' => TRUE, '#description' => $description, '#ajax' => array('callback' => '::breakpointMappingFormAjax', 'wrapper' => 'responsive-image-style-breakpoints-wrapper'));
     $form['keyed_styles'] = array('#type' => 'container', '#attributes' => array('id' => 'responsive-image-style-breakpoints-wrapper'));
     // By default, breakpoints are ordered from smallest weight to largest:
     // the smallest weight is expected to have the smallest breakpoint width,
     // while the largest weight is expected to have the largest breakpoint
     // width. For responsive images, we need largest breakpoint widths first, so
     // we need to reverse the order of these breakpoints.
     $breakpoints = array_reverse($this->breakpointManager->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()));
     foreach ($breakpoints as $breakpoint_id => $breakpoint) {
         foreach ($breakpoint->getMultipliers() as $multiplier) {
             $label = $multiplier . ' ' . $breakpoint->getLabel() . ' [' . $breakpoint->getMediaQuery() . ']';
             $form['keyed_styles'][$breakpoint_id][$multiplier] = array('#type' => 'details', '#title' => $label);
             $image_style_mapping = $responsive_image_style->getImageStyleMapping($breakpoint_id, $multiplier);
             if (\Drupal::moduleHandler()->moduleExists('help')) {
                 $description = $this->t('See the <a href=":responsive_image_help">Responsive Image help page</a> for information on the sizes attribute.', array(':responsive_image_help' => \Drupal::url('help.page', array('name' => 'responsive_image'))));
             } else {
                 $description = $this->t('Enable the Help module for more information on the sizes attribute.');
             }
             $form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type'] = array('#title' => $this->t('Type'), '#type' => 'radios', '#options' => array('sizes' => $this->t('Select multiple image styles and use the sizes attribute.'), 'image_style' => $this->t('Select a single image style.'), '_none' => $this->t('Do not use this breakpoint.')), '#default_value' => isset($image_style_mapping['image_mapping_type']) ? $image_style_mapping['image_mapping_type'] : '_none', '#description' => $description);
             $form['keyed_styles'][$breakpoint_id][$multiplier]['image_style'] = array('#type' => 'select', '#title' => $this->t('Image style'), '#options' => $image_styles, '#default_value' => isset($image_style_mapping['image_mapping']) && is_string($image_style_mapping['image_mapping']) ? $image_style_mapping['image_mapping'] : '', '#description' => $this->t('Select an image style for this breakpoint.'), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'image_style'))));
             $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes'] = array('#type' => 'textfield', '#title' => $this->t('Sizes'), '#default_value' => isset($image_style_mapping['image_mapping']['sizes']) ? $image_style_mapping['image_mapping']['sizes'] : '100vw', '#description' => $this->t('Enter the value for the sizes attribute, for example: %example_sizes.', ['%example_sizes' => '(min-width:700px) 700px, 100vw']), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes')), 'required' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'))));
             $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes_image_styles'] = array('#title' => $this->t('Image styles'), '#type' => 'checkboxes', '#options' => array_diff_key($image_styles, array('' => '')), '#description' => $this->t('Select image styles with widths that range from the smallest amount of space this image will take up in the layout to the largest, bearing in mind that high resolution screens will need images 1.5x to 2x larger.'), '#default_value' => isset($image_style_mapping['image_mapping']['sizes_image_styles']) ? $image_style_mapping['image_mapping']['sizes_image_styles'] : array(), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes')), 'required' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'))));
             // Expand the details if "do not use this breakpoint" was not selected.
             if ($form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type']['#default_value'] != '_none') {
                 $form['keyed_styles'][$breakpoint_id][$multiplier]['#open'] = TRUE;
             }
         }
     }
     $form['fallback_image_style'] = array('#title' => $this->t('Fallback image style'), '#type' => 'select', '#default_value' => $responsive_image_style->getFallbackImageStyle(), '#options' => $image_styles, '#required' => TRUE, '#description' => t('Select the smallest image style you expect to appear in this space. The fallback image style should only appear on the site if an error occurs.'));
     $form['#tree'] = TRUE;
     return parent::form($form, $form_state, $responsive_image_style);
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $image_styles = image_style_options(FALSE);
     $description_link = Link::fromTextAndUrl($this->t('Configure Image Styles'), Url::fromRoute('entity.image_style.collection'));
     $element['image_style'] = ['#title' => t('Image style'), '#type' => 'select', '#default_value' => $this->getSetting('image_style'), '#empty_option' => t('None (original image)'), '#options' => $image_styles, '#description' => $description_link->toRenderable() + ['#access' => $this->currentUser->hasPermission('administer image styles')]];
     $link_types = array('content' => t('Content'), 'file' => t('File'));
     $element['image_link'] = array('#title' => t('Link image to'), '#type' => 'select', '#default_value' => $this->getSetting('image_link'), '#empty_option' => t('Nothing'), '#options' => $link_types);
     $element['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->getSetting('items'));
     $element['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->getSetting('itemsDesktop'));
     $element['itemsDesktopSmall'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop Small'), '#description' => $this->t('Example: [979,3]'), '#default_value' => $this->getSetting('itemsDesktopSmall'));
     $element['itemsTablet'] = array('#type' => 'textfield', '#title' => $this->t('Items Tablet'), '#description' => $this->t('Example: [768,2]'), '#default_value' => $this->getSetting('itemsTablet'));
     $element['itemsMobile'] = array('#type' => 'textfield', '#title' => $this->t('Items Mobile'), '#description' => $this->t('Example: [479,1]'), '#default_value' => $this->getSetting('itemsMobile'));
     $element['singleItem'] = array('#type' => 'checkbox', '#title' => $this->t('Single Item'), '#default_value' => $this->getSetting('singleItem'), '#description' => $this->t('Display only one item.'));
     //itemsScaleUp
     $element['itemsScaleUp'] = array('#type' => 'checkbox', '#title' => $this->t('Items ScaleUp'), '#default_value' => $this->getSetting('itemsScaleUp'), '#description' => $this->t('Option to not stretch items when it is less than the supplied items.'));
     //slideSpeed
     $element['slideSpeed'] = array('#type' => 'number', '#title' => $this->t('Slide Speed'), '#default_value' => $this->getSetting('slideSpeed'), '#description' => $this->t('Slide speed in milliseconds.'));
     //paginationSpeed
     $element['paginationSpeed'] = array('#type' => 'number', '#title' => $this->t('Pagination Speed'), '#default_value' => $this->getSetting('paginationSpeed'), '#description' => $this->t('Pagination speed in milliseconds.'));
     //rewindSpeed
     $element['rewindSpeed'] = array('#type' => 'number', '#title' => $this->t('Rewind Speed'), '#default_value' => $this->getSetting('rewindSpeed'), '#description' => $this->t('Rewind speed in milliseconds.'));
     //autoPlay
     $element['autoPlay'] = array('#type' => 'checkbox', '#title' => $this->t('AutoPlay'), '#default_value' => $this->getSetting('autoPlay'));
     //stopOnHover
     $element['stopOnHover'] = array('#type' => 'checkbox', '#title' => $this->t('Stop On Hover'), '#default_value' => $this->getSetting('stopOnHover'), '#description' => $this->t('Stop autoplay on mouse hover.'));
     //navigation
     $element['navigation'] = array('#type' => 'checkbox', '#title' => $this->t('Navigation'), '#default_value' => $this->getSetting('navigation'), '#description' => $this->t('Display "next" and "prev" buttons.'));
     //prevText
     $element['prevText'] = array('#type' => 'textfield', '#title' => $this->t('Prev Text'), '#default_value' => $this->getSetting('prevText'), '#description' => $this->t('Text for navigation prev button'));
     //nextText
     $element['nextText'] = array('#type' => 'textfield', '#title' => $this->t('Next Text'), '#default_value' => $this->getSetting('nextText'), '#description' => $this->t('Text for navigation next button'));
     //rewindNav
     $element['rewindNav'] = array('#type' => 'checkbox', '#title' => $this->t('Rewind Nav'), '#default_value' => $this->getSetting('rewindNav'), '#description' => $this->t('Slide to first item.'));
     //scrollPerPage
     $element['scrollPerPage'] = array('#type' => 'checkbox', '#title' => $this->t('Scroll Per Page'), '#default_value' => $this->getSetting('scrollPerPage'), '#description' => $this->t('Scroll per page not per item. This affect next/prev buttons and mouse/touch dragging.'));
     //pagination
     $element['pagination'] = array('#type' => 'checkbox', '#title' => $this->t('pagination'), '#default_value' => $this->getSetting('pagination'), '#description' => $this->t('Show pagination.'));
     //paginationNumbers
     $element['paginationNumbers'] = array('#type' => 'checkbox', '#title' => $this->t('Pagination Numbers'), '#default_value' => $this->getSetting('paginationNumbers'), '#description' => $this->t('Show numbers inside pagination buttons.'));
     //responsive
     $element['responsive'] = array('#type' => 'checkbox', '#title' => $this->t('Responsive'), '#default_value' => $this->getSetting('responsive'), '#description' => $this->t('Uncheck to use Owl Carousel on desktop-only.'));
     //responsiveRefreshRate
     $element['responsiveRefreshRate'] = array('#type' => 'number', '#title' => $this->t('Responsive Refresh Rate'), '#default_value' => $this->getSetting('responsiveRefreshRate'), '#description' => $this->t('Check window width changes every 200ms for responsive actions.'));
     //mouseDrag
     $element['mouseDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Mouse Drag'), '#default_value' => $this->getSetting('mouseDrag'), '#description' => $this->t('Turn off/on mouse events.'));
     //touchDrag
     $element['touchDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Touch Drag'), '#default_value' => $this->getSetting('touchDrag'), '#description' => $this->t('Turn off/on touch events.'));
     //transitionStyle
     $element['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->getSetting('transitionStyle'), '#description' => $this->t('Add CSS3 transition style. Works only with one item on screen.'));
     return $element + parent::settingsForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = array();
     $image_styles = image_style_options(FALSE);
     // Unset possible 'No defined styles' option.
     unset($image_styles['']);
     // Styles could be lost because of enabled/disabled modules that defines
     // their styles in code.
     $image_style_setting = $this->getSetting('image_style');
     if (isset($image_styles[$image_style_setting])) {
         $summary[] = t('Image style: @style', array('@style' => $image_styles[$image_style_setting]));
     } else {
         $summary[] = t('Original image');
     }
     return $summary;
 }
Example #17
0
 /**
  * Overrides Drupal\Core\Entity\EntityForm::form().
  */
 public function form(array $form, array &$form_state)
 {
     $form = parent::form($form, $form_state);
     $entity = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => 'Label', '#default_value' => $entity->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $entity->id(), '#required' => TRUE, '#machine_name' => array('exists' => 'config_test_load', 'replace_pattern' => '[^a-z0-9_.]+'));
     $form['weight'] = array('#type' => 'weight', '#title' => 'Weight', '#default_value' => $entity->get('weight'));
     $form['style'] = array('#type' => 'select', '#title' => 'Image style', '#options' => array(), '#default_value' => $entity->get('style'), '#access' => FALSE);
     if ($this->moduleHandler->moduleExists('image')) {
         $form['style']['#access'] = TRUE;
         $form['style']['#options'] = image_style_options();
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => 'Save');
     $form['actions']['delete'] = array('#type' => 'submit', '#value' => 'Delete');
     return $form;
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = parent::settingsSummary();
     $image_styles = image_style_options(FALSE);
     // Unset possible 'No defined styles' option.
     unset($image_styles['']);
     // Styles could be lost because of enabled/disabled modules that defines
     // their styles in code.
     $image_style_setting = $this->getSetting('preview_image_style');
     if (isset($image_styles[$image_style_setting])) {
         $preview_image_style = t('Preview image style: @style', array('@style' => $image_styles[$image_style_setting]));
     } else {
         $preview_image_style = t('No preview');
     }
     array_unshift($summary, $preview_image_style);
     return $summary;
 }
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = array();
     $summary[] = $this->t('Sizes: @sizes', array('@sizes' => $this->getSetting('sizes')));
     $image_styles = image_style_options(FALSE);
     unset($image_styles['']);
     $image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('Empty image');
     $selected_styles = array_filter($this->getSetting('image_styles'));
     $summary[] = t('Image styles: @styles', array('@styles' => implode(', ', array_intersect_key($image_styles, $selected_styles))));
     $summary[] = t('Fallback image style: @style', array('@style' => $image_styles[$this->getSetting('fallback_image_style')]));
     $link_types = array('content' => t('Linked to content'), 'file' => t('Linked to file'));
     // Display this setting only if image is linked.
     if (isset($link_types[$this->getSetting('image_link')])) {
         $summary[] = $link_types[$this->getSetting('image_link')];
     }
     return $summary;
 }
Example #20
0
 /**
  * Overrides Drupal\responsive_image\ResponsiveImageForm::form().
  *
  * @param array $form
  *   A nested array form elements comprising the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return array
  *   The array containing the complete form.
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $image_styles = image_style_options(TRUE);
     $image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('- empty image -');
     $breakpoints = $this->breakpointManager->getBreakpointsByGroup($this->entity->getBreakpointGroup());
     foreach ($breakpoints as $breakpoint_id => $breakpoint) {
         foreach ($breakpoint->getMultipliers() as $multiplier) {
             $label = $multiplier . ' ' . $breakpoint->getLabel() . ' [' . $breakpoint->getMediaQuery() . ']';
             $form['keyed_styles'][$breakpoint_id][$multiplier] = array('#type' => 'details', '#title' => $label);
             $mapping_definition = $this->entity->getImageStyleMapping($breakpoint_id, $multiplier);
             $form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type'] = array('#title' => $this->t('Image mapping type'), '#type' => 'radios', '#options' => array('_none' => $this->t('Do not use this breakpoint'), 'image_style' => $this->t('Use image styles'), 'sizes' => $this->t('Use the sizes attribute')), '#default_value' => isset($mapping_definition['image_mapping_type']) ? $mapping_definition['image_mapping_type'] : '_none');
             $form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping'] = array('#type' => 'select', '#title' => $this->t('Image style'), '#options' => $image_styles, '#default_value' => isset($mapping_definition['image_mapping']) && is_string($mapping_definition['image_mapping']) ? $mapping_definition['image_mapping'] : '', '#description' => $this->t('Select an image style for this breakpoint.'), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'image_style'))));
             $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes'] = array('#type' => 'textfield', '#title' => $this->t('Sizes'), '#default_value' => isset($mapping_definition['image_mapping']['sizes']) ? $mapping_definition['image_mapping']['sizes'] : '', '#description' => $this->t('Enter the value for the sizes attribute (e.g. "(min-width:700px) 700px, 100vw").'), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'))));
             $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes_image_styles'] = array('#title' => $this->t('Image styles'), '#type' => 'checkboxes', '#options' => array_diff_key($image_styles, array('' => '')), '#default_value' => isset($mapping_definition['image_mapping']['sizes_image_styles']) && is_array($mapping_definition['image_mapping']['sizes_image_styles']) ? $mapping_definition['image_mapping']['sizes_image_styles'] : array(), '#states' => array('visible' => array(':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => array('value' => 'sizes'))));
         }
     }
     return $form;
 }
 /**
  * Overrides Drupal\Core\Entity\EntityForm::form().
  *
  * @param array $form
  *   A nested array form elements comprising the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return array
  *   The array containing the complete form.
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     if ($this->operation == 'duplicate') {
         $form['#title'] = $this->t('<em>Duplicate responsive image style</em> @label', array('@label' => $this->entity->label()));
         $this->entity = $this->entity->createDuplicate();
     }
     if ($this->operation == 'edit') {
         $form['#title'] = $this->t('<em>Edit responsive image style</em> @label', array('@label' => $this->entity->label()));
     }
     /** @var \Drupal\responsive_image\ResponsiveImageStyleInterface $responsive_image_style */
     $responsive_image_style = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $responsive_image_style->label(), '#description' => $this->t("Example: 'Hero image' or 'Author image'."), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $responsive_image_style->id(), '#machine_name' => array('exists' => '\\Drupal\\responsive_image\\Entity\\ResponsiveImageStyle::load', 'source' => array('label')), '#disabled' => (bool) $responsive_image_style->id() && $this->operation != 'duplicate');
     if ((bool) $responsive_image_style->id() && $this->operation != 'duplicate') {
         $description = $this->t('Select a breakpoint group from the installed themes.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your selected image style mappings.");
     } else {
         $description = $this->t('Select a breakpoint group from the installed themes.');
     }
     $form['breakpoint_group'] = array('#type' => 'select', '#title' => $this->t('Breakpoint group'), '#default_value' => $responsive_image_style->getBreakpointGroup(), '#options' => $this->breakpointManager->getGroups(), '#required' => TRUE, '#description' => $description);
     $image_styles = image_style_options(TRUE);
     $image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('- empty image -');
     $form['fallback_image_style'] = array('#title' => $this->t('Fallback image style'), '#type' => 'select', '#default_value' => $responsive_image_style->getFallbackImageStyle(), '#options' => $image_styles, '#required' => TRUE);
     // By default, breakpoints are ordered from smallest weight to largest:
     // the smallest weight is expected to have the smallest breakpoint width,
     // while the largest weight is expected to have the largest breakpoint
     // width. For responsive images, we need largest breakpoint widths first, so
     // we need to reverse the order of these breakpoints.
     $breakpoints = array_reverse($this->breakpointManager->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()));
     foreach ($breakpoints as $breakpoint_id => $breakpoint) {
         foreach ($breakpoint->getMultipliers() as $multiplier) {
             $label = $multiplier . ' ' . $breakpoint->getLabel() . ' [' . $breakpoint->getMediaQuery() . ']';
             $form['keyed_styles'][$breakpoint_id][$multiplier] = array('#type' => 'container');
             $image_style_mapping = $responsive_image_style->getImageStyleMapping($breakpoint_id, $multiplier);
             // @todo The image_mapping_type is only temporarily hardcoded, until
             // support for the other responsive image mapping type ('sizes') is
             // added in https://www.drupal.org/node/2334387.
             $form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping_type'] = array('#type' => 'value', '#value' => 'image_style');
             $form['keyed_styles'][$breakpoint_id][$multiplier]['image_mapping'] = array('#type' => 'select', '#title' => $label, '#options' => $image_styles, '#default_value' => isset($image_style_mapping['image_mapping']) ? $image_style_mapping['image_mapping'] : array(), '#description' => $this->t('Select an image style for this breakpoint.'));
         }
     }
     $form['#tree'] = TRUE;
     return parent::form($form, $form_state, $responsive_image_style);
 }
Example #22
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $library = \Drupal::service('juicebox.formatter')->getLibrary(TRUE, TRUE);
     $version = !empty($library['version']) ? $library['version'] : t('Unknown');
     // Get all settings
     $settings = $this->config('juicebox.settings')->get();
     // If the base language list is not officially saved yet, we can get the
     // default value from the library settings.
     if (empty($settings['base_languagelist'])) {
         $settings['base_languagelist'] = $library['base_languagelist'];
     }
     $form['juicebox_admin_intro'] = array('#markup' => t("The options below apply to all Juicebox galleries. Note that most Juicebox configuration options are set within each gallery's unique configuration form and not applied on a global scope like the values here."));
     $form['apply_markup_filter'] = array('#type' => 'checkbox', '#title' => t('Filter all title and caption output for compatibility with Juicebox javascript (recommended)'), '#default_value' => $settings['apply_markup_filter'], '#description' => t('This option helps ensure title/caption output is syntactically compatible with the Juicebox javascript library by removing block-level tags.'));
     $form['enable_cors'] = array('#type' => 'checkbox', '#title' => t('Allow galleries to be embedded remotely (CORS support)'), '#default_value' => $settings['enable_cors'], '#description' => t('Enable cross-origin resource sharing (CORS) for all generated Juicebox XML. This will allow all origins/domains to use any Juicebox XML requested from this site for embedding purposes (adds a <em>Access-Control-Allow-Origin: *</em> header to all Juicebox XML responses).'));
     $form['multilingual'] = array('#type' => 'details', '#title' => t('Multilingual options'), '#open' => TRUE);
     $form['multilingual']['translate_interface'] = array('#type' => 'checkbox', '#title' => t('Translate the Juicebox javascript interface'), '#default_value' => $settings['translate_interface'], '#description' => t('Send interface strings to the Juicebox javascript after passing them through the Drupal translation system.'));
     $form['multilingual']['base_languagelist'] = array('#type' => 'textarea', '#title' => t('Base string for interface translation'), '#default_value' => $settings['base_languagelist'], '#description' => t('The base <strong>English</strong> interface text that Drupal should attempt to translate and pass to the Juicebox javascript for display (using the "languageList" configuration option). This text will be treated as a <strong>single string</strong> by Drupal and must be translated with a tool such as the Locale module. Note that this base string value will rarely change, and any changes made to it will break existing translations.'), '#wysiwyg' => FALSE, '#states' => array('invisible' => array(':input[name="translate_interface"]' => array('checked' => FALSE))));
     $form['multilingual']['base_languagelist_suggestion'] = array('#type' => 'item', '#title' => t('Suggested base string for currently detected Juicebox version (@version)', array('@version' => $version)), '#description' => SafeMarkup::format('<pre>' . $library['base_languagelist'] . '</pre>', array()), '#states' => array('invisible' => array(':input[name="translate_interface"]' => array('checked' => FALSE))));
     $multisize_disallowed = in_array('juicebox_multisize_image_style', $library['disallowed_conf']);
     $multisize_description = '<p>' . t('Some versions of the Juicebox javascript library support "multi-size" (adaptive) image delivery. Individual galleries configured to use the <strong>Juicebox PRO multi-size (adaptive)</strong> image style allow for three different source derivatives to be defined per image, each of which can be configured below. The Juicebox javascript library will then choose between these depending on the active screen mode (i.e. viewport size) of each user. See the Juicebox javascript library documentation for more information.') . '</p>';
     if ($multisize_disallowed) {
         $multisize_description .= '<p><strong>' . t('Your currently detected Juicebox version (@version) is not compatible with multi-size features, so the options below have been disabled.', array('@version' => $version)) . '</strong></p>';
     }
     // Mark our description, and its markup, as safe for unescaped display.
     $multisize_description = SafeMarkup::format($multisize_description, array());
     $form['juicebox_multisize'] = array('#type' => 'details', '#title' => t('Juicebox PRO multi-size style configuration'), '#description' => $multisize_description, '#open' => !$multisize_disallowed);
     // Get available image style presets
     $presets = image_style_options(FALSE);
     $form['juicebox_multisize']['juicebox_multisize_small'] = array('#title' => t('Small mode image style'), '#default_value' => $settings['juicebox_multisize_small'], '#description' => t('The style formatter to use in small screen mode (e.g., non-retina mobile devices).'));
     $form['juicebox_multisize']['juicebox_multisize_medium'] = array('#title' => t('Medium mode image style'), '#default_value' => $settings['juicebox_multisize_medium'], '#description' => t('The style formatter to use in medium screen mode (e.g., desktops and retina mobile devices).'));
     $form['juicebox_multisize']['juicebox_multisize_large'] = array('#title' => t('Large mode image style'), '#default_value' => $settings['juicebox_multisize_large'], '#description' => t('The style formatter to use in large screen mode (e.g., expanded view and retina laptops).'));
     foreach ($form['juicebox_multisize'] as &$options) {
         if (is_array($options)) {
             $options += array('#type' => 'select', '#options' => $presets, '#empty_option' => t('None (original image)'), '#disabled' => $multisize_disallowed);
         }
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = array();
     $responsive_image_mapping = entity_load('responsive_image_mapping', $this->getSetting('responsive_image_mapping'));
     if ($responsive_image_mapping) {
         $summary[] = t('Responsive image mapping: @responsive_image_mapping', array('@responsive_image_mapping' => $responsive_image_mapping->label()));
         $image_styles = image_style_options(FALSE);
         unset($image_styles['']);
         if (isset($image_styles[$this->getSetting('fallback_image_style')])) {
             $summary[] = t('Fallback Image style: @style', array('@style' => $image_styles[$this->getSetting('fallback_image_style')]));
         } else {
             $summary[] = t('Automatic fallback');
         }
         $link_types = array('content' => t('Linked to content'), 'file' => t('Linked to file'));
         // Display this setting only if image is linked.
         if (isset($link_types[$this->getSetting('image_link')])) {
             $summary[] = $link_types[$this->getSetting('image_link')];
         }
     } else {
         $summary[] = t('Select a responsive image mapping.');
     }
     return $summary;
 }
        print isset($parameters["img_path"]) ? $parameters["img_path"] : '';
        ?>
" />
            </div>
            <div class="form-item">
              <?php 
        $img_style = isset($parameters["img_style"]) ? $parameters["img_style"] : '';
        ?>
              <label for="img_style">Image style</label>
              <select name="img_style">
                <option value=""<?php 
        print $img_style == '' ? ' selected="selected"' : "";
        ?>
>None (Original image)</option>
                <?php 
        foreach (image_style_options(FALSE) as $key => $val) {
            ?>
                  <option value="<?php 
            print $key;
            ?>
"<?php 
            print $img_style == $key ? ' selected="selected"' : "";
            ?>
><?php 
            print $val;
            ?>
</option>
                <?php 
        }
        ?>
              </select>
 function edit_form(&$form, &$form_state)
 {
     parent::edit_form($form, $form_state);
     $module_path = drupal_get_path('module', 'slick');
     $optionset = $form_state['item'];
     $options = $optionset->options;
     $form['#attached']['css'][] = $module_path . '/css/admin/slick.admin--ui.css';
     $form['#attached']['css'][] = $module_path . '/css/admin/slick.admin--vertical-tabs.css';
     $form['#attached']['js'][] = $module_path . '/js/slick.admin.ui.js';
     $form['#attributes']['class'][] = 'no-js';
     $form['#attributes']['class'][] = 'form--slick';
     $form['#attributes']['class'][] = 'form--compact';
     $form['#attributes']['class'][] = 'form--optionset';
     $form['#attributes']['class'][] = 'clearfix';
     $form['info']['label']['#attributes']['class'][] = 'is-tooltip';
     $form['info']['name']['#attributes']['class'][] = 'is-tooltip';
     $form['info']['label']['#prefix'] = '<div class="form--slick__header has-tooltip clearfix">';
     // Skins.
     $skins = slick_skins(TRUE);
     $form['skin'] = array('#type' => 'select', '#title' => t('Skin'), '#options' => $skins, '#default_value' => $optionset->skin, '#description' => t('Skins allow swappable layouts like next/prev links, split image and caption, etc. Make sure to provide a dedicated slide layout per field. However a combination of skins and options may lead to unpredictable layouts, get dirty yourself. See main <a href="@skin">README.txt</a> for details on Skins.', array('@skin' => url($module_path . '/README.txt'))), '#attributes' => array('class' => array('is-tooltip')));
     $form['breakpoints'] = array('#title' => t('Breakpoints'), '#type' => 'textfield', '#description' => t('The number of breakpoints added to Responsive display.'), '#default_value' => isset($form_state['values']['breakpoints']) ? $form_state['values']['breakpoints'] : $optionset->breakpoints, '#suffix' => '</div>', '#ajax' => array('callback' => 'slick_add_breakpoints_ajax_callback', 'wrapper' => 'breakpoints-ajax-wrapper', 'event' => 'change'), '#attributes' => array('class' => array('is-tooltip')));
     // Options.
     $form['options'] = array('#type' => 'vertical_tabs', '#tree' => TRUE);
     // Image styles.
     $image_styles = image_style_options(FALSE);
     $form['options']['general'] = array('#type' => 'fieldset', '#title' => t('General'), '#attributes' => array('class' => array('has-tooltip', 'fieldset--no-checkboxes-label')));
     $form['options']['general']['normal'] = array('#type' => 'select', '#title' => t('Image style'), '#description' => t('Image style for the main/background image, overriden by field. Thumbnails are defined per field basis.'), '#empty_option' => t('None (original image)'), '#options' => $image_styles, '#default_value' => isset($options['general']['normal']) ? $options['general']['normal'] : '', '#attributes' => array('class' => array('is-tooltip')));
     /*
     @todo drop it or test elementTransition.js
     $form['options']['general']['transition'] = array(
       '#type' => 'select',
       '#title' => t('Transition effect'),
       '#description' => t('Custom CSS3 transition effect.'),
       '#empty_option' => t('- None -'),
       '#options' => _slick_transition_options(),
       '#default_value' => isset($options['general']['transition']) ? $options['general']['transition'] : '',
     );
     */
     $form['options']['general']['template_class'] = array('#type' => 'textfield', '#title' => t('Wrapper class'), '#description' => t('Additional template wrapper classes separated by spaces to gain more control per optionset.'), '#default_value' => isset($options['general']['template_class']) ? $options['general']['template_class'] : '', '#attributes' => array('class' => array('is-tooltip')));
     $form['options']['general']['goodies'] = array('#type' => 'checkboxes', '#title' => t('Goodies'), '#default_value' => !empty($options['general']['goodies']) ? array_values((array) $options['general']['goodies']) : array(), '#options' => array('pattern' => t('Use pattern overlay'), 'arrow-down' => t('Use arrow down')), '#description' => t('<ol><li>Pattern overlay is background image with pattern placed over the main stage.</li><li>Arrow down to scroll down into a certain page section, make sure to provide target selector.</li></ol>'), '#attributes' => array('class' => array('is-tooltip')));
     $form['options']['general']['arrow_down_target'] = array('#type' => 'textfield', '#title' => t('Arrow down target'), '#description' => t('Valid CSS selector to scroll to, e.g.: #main, or #content.'), '#default_value' => isset($options['general']['arrow_down_target']) ? $options['general']['arrow_down_target'] : '', '#states' => array('visible' => array(':input[name*=arrow-down]' => array('checked' => TRUE))), '#attributes' => array('class' => array('is-tooltip')));
     $form['options']['general']['arrow_down_offset'] = array('#type' => 'textfield', '#title' => t('Arrow down offset'), '#description' => t('Offset when scrolled down from the top.'), '#default_value' => isset($options['general']['arrow_down_offset']) ? $options['general']['arrow_down_offset'] : '', '#states' => array('visible' => array(':input[name*=arrow-down]' => array('checked' => TRUE))), '#attributes' => array('class' => array('is-tooltip')));
     // Add empty suffix to style checkboxes like iOS.
     foreach ($form['options']['general']['goodies']['#options'] as $key => $value) {
         $form['options']['general']['goodies'][$key]['#field_suffix'] = '';
         $form['options']['general']['goodies'][$key]['#title_display'] = 'before';
     }
     // Main options.
     $slick_options = slick_get_options();
     $form['options']['settings'] = array('#title' => t('Settings'), '#type' => 'fieldset', '#collapsible' => FALSE, '#tree' => TRUE, '#attributes' => array('class' => array('fieldset--settings', 'has-tooltip')));
     foreach ($slick_options as $name => $values) {
         $form['options']['settings'][$name] = array('#title' => $values['title'], '#description' => $values['description'], '#type' => $values['type'], '#default_value' => isset($options['settings'][$name]) ? $options['settings'][$name] : $values['default'], '#attributes' => array('class' => array('is-tooltip')));
         if (isset($values['field_suffix'])) {
             $form['options']['settings'][$name]['#field_suffix'] = $values['field_suffix'];
         }
         if ($values['type'] == 'textfield') {
             $form['options']['settings'][$name]['#size'] = 20;
             $form['options']['settings'][$name]['#maxlength'] = 255;
         }
         if (!isset($values['field_suffix']) && $values['cast'] == 'bool') {
             $form['options']['settings'][$name]['#field_suffix'] = '';
             $form['options']['settings'][$name]['#title_display'] = 'before';
         }
         if ($values['cast'] == 'int') {
             $form['options']['settings'][$name]['#maxlength'] = 60;
             $form['options']['settings'][$name]['#attributes']['class'][] = 'form-text--int';
         }
         if (isset($values['states'])) {
             $form['options']['settings'][$name]['#states'] = $values['states'];
         }
         if (isset($values['options'])) {
             $form['options']['settings'][$name]['#options'] = $values['options'];
         }
         if (isset($values['empty_option'])) {
             $form['options']['settings'][$name]['#empty_option'] = $values['empty_option'];
         }
         // Expand textfield for easy edit.
         if (in_array($name, array('prevArrow', 'nextArrow'))) {
             $form['options']['settings'][$name]['#attributes']['class'][] = 'js-expandable';
         }
     }
     // Responsive options.
     $form['options']['responsives'] = array('#title' => t('Responsive display'), '#type' => 'fieldset', '#description' => t('Containing breakpoints and settings objects. Settings set at a given breakpoint/screen width is self-contained and does not inherit the main settings, but defaults. Currently only supports Desktop first: starts breakpoint from the largest to smallest.'), '#collapsible' => FALSE, '#tree' => TRUE);
     $form['options']['responsives']['responsive'] = array('#title' => t('Responsive'), '#type' => 'fieldset', '#collapsible' => FALSE, '#attributes' => array('class' => array('has-tooltip', 'fieldset--responsive--ajax')), '#prefix' => '<div id="breakpoints-ajax-wrapper">', '#suffix' => '</div>');
     $breakpoints_count = isset($form_state['values']['breakpoints']) ? $form_state['values']['breakpoints'] : $optionset->breakpoints;
     $form_state['breakpoints_count'] = $breakpoints_count;
     if ($form_state['breakpoints_count'] > 0) {
         $slick_options = slick_get_responsive_options($form_state['breakpoints_count']);
         foreach ($slick_options as $i => $values) {
             if ($values['type'] == 'fieldset') {
                 $fieldset_class = drupal_clean_css_identifier(drupal_strtolower($values['title']));
                 $form['options']['responsives']['responsive'][$i] = array('#title' => $values['title'], '#type' => $values['type'], '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => array('class' => array('fieldset--responsive', 'fieldset--' . $fieldset_class, 'has-tooltip')));
                 foreach ($values as $key => $vals) {
                     if (is_array($vals)) {
                         if ($vals['type'] == 'fieldset') {
                             if (!isset($vals['default']) && $vals['type'] == 'fieldset') {
                                 $form['options']['responsives']['responsive'][$i][$key] = array('#title' => $vals['title'], '#type' => $vals['type'], '#collapsible' => FALSE, '#collapsed' => FALSE, '#attributes' => array('class' => array('fieldset--settings', 'fieldset--' . $fieldset_class, 'has-tooltip')));
                             }
                             foreach ($vals as $k => $value) {
                                 if ($value && is_array($value)) {
                                     $form['options']['responsives']['responsive'][$i][$key][$k] = array('#title' => $value['title'], '#description' => $value['description'], '#type' => $value['type'], '#attributes' => array('class' => array('is-tooltip')));
                                     if ($value['type'] != 'fieldset') {
                                         $form['options']['responsives']['responsive'][$i][$key][$k]['#default_value'] = isset($options['responsives']['responsive'][$i][$key][$k]) ? $options['responsives']['responsive'][$i][$key][$k] : $value['default'];
                                     }
                                     if (isset($value['states'])) {
                                         // Specify proper states for the breakpoint form elements.
                                         $states = '';
                                         switch ($k) {
                                             case 'pauseOnHover':
                                             case 'pauseOnDotsHover':
                                             case 'autoplaySpeed':
                                                 $states = array('visible' => array(':input[name*="options[responsives][responsive][' . $i . '][settings][autoplay]"]' => array('checked' => TRUE)));
                                                 break;
                                             case 'appendArrows':
                                                 $states = array('visible' => array(':input[name*="options[responsives][responsive][' . $i . '][settings][arrows]"]' => array('checked' => TRUE)));
                                                 break;
                                             case 'centerPadding':
                                                 $states = array('visible' => array(':input[name*="options[responsives][responsive][' . $i . '][settings][centerMode]"]' => array('checked' => TRUE)));
                                                 break;
                                             case 'touchThreshold':
                                                 $states = array('visible' => array(':input[name*="options[responsives][responsive][' . $i . '][settings][touchMove]"]' => array('checked' => TRUE)));
                                                 break;
                                         }
                                         if ($states) {
                                             $form['options']['responsives']['responsive'][$i][$key][$k]['#states'] = $states;
                                         }
                                     }
                                     if (isset($value['options'])) {
                                         $form['options']['responsives']['responsive'][$i][$key][$k]['#options'] = $value['options'];
                                     }
                                     if (isset($value['empty_option'])) {
                                         $form['options']['responsives']['responsive'][$i][$key][$k]['#empty_option'] = $value['empty_option'];
                                     }
                                     if (isset($value['field_suffix'])) {
                                         $form['options']['responsives']['responsive'][$i][$key][$k]['#field_suffix'] = $value['field_suffix'];
                                     }
                                     if (!isset($value['field_suffix']) && $value['cast'] == 'bool') {
                                         $form['options']['responsives']['responsive'][$i][$key][$k]['#field_suffix'] = '';
                                         $form['options']['responsives']['responsive'][$i][$key][$k]['#title_display'] = 'before';
                                     }
                                 }
                             }
                         } else {
                             $form['options']['responsives']['responsive'][$i][$key] = array('#title' => $vals['title'], '#description' => $vals['description'], '#type' => $vals['type'], '#default_value' => isset($options['responsives']['responsive'][$i][$key]) ? $options['responsives']['responsive'][$i][$key] : $vals['default'], '#attributes' => array('class' => array('is-tooltip')));
                             if ($vals['type'] == 'textfield') {
                                 $form['options']['responsives']['responsive'][$i][$key]['#size'] = 20;
                                 $form['options']['responsives']['responsive'][$i][$key]['#maxlength'] = 255;
                             }
                             if ($vals['cast'] == 'int') {
                                 $form['options']['responsives']['responsive'][$i][$key]['#maxlength'] = 60;
                             }
                             if (isset($vals['states'])) {
                                 $form['options']['responsives']['responsive'][$i][$key]['#states'] = $vals['states'];
                             }
                             if (isset($vals['options'])) {
                                 $form['options']['responsives']['responsive'][$i][$key]['#options'] = $vals['options'];
                             }
                             if (isset($vals['field_suffix'])) {
                                 $form['options']['responsives']['responsive'][$i][$key]['#field_suffix'] = $vals['field_suffix'];
                             }
                             if (!isset($vals['field_suffix']) && $vals['cast'] == 'bool') {
                                 $form['options']['responsives']['responsive'][$i][$key]['#field_suffix'] = '';
                                 $form['options']['responsives']['responsive'][$i][$key]['#title_display'] = 'before';
                             }
                         }
                     }
                 }
             }
         }
     }
 }
  /**
   * {@inheritdoc}
   */
  public function settingsSummary() {
    $summary = array();
    $image_styles = image_style_options(FALSE);

    // Unset possible 'No defined styles' option.
    unset($image_styles['']);

    // Styles could be lost because of enabled/disabled modules that defines
    // their styles in code.
    if (!empty($image_styles[$this->getSetting('image_style')])) {
      $summary[] = t('Image style: @style', array('@style' => $image_styles[$this->getSetting('image_style')]));
    }
    else {
      $summary[] = t('Image style: @style', array('@style' => t('Original image')));
    }
    if (!empty($image_styles[$this->getSetting('image_link_style')])) {
      $summary[] = t('Link to image style: @style', array('@style' => $image_styles[$this->getSetting('image_link_style')]));
    }
    else {
      $summary[] = t('Link to image style: @style', array('@style' => t('Original image')));
    }
    if (!empty($this->getSetting('image_link_class'))) {
      $summary[] = t('Link class(es): @classes', array('@classes' => $this->getSetting('image_link_class')));
    }
    if (!empty($this->getSetting('image_link_rel'))) {
      $summary[] = t('Link rel(s): @rels', array('@rels' => $this->getSetting('image_link_rel')));
    }
    if (!empty($this->getSetting('image_link_image_class'))) {
      $summary[] = t('Image class(es): @classes', array('@classes' => $this->getSetting('image_link_image_class')));
    }

    return $summary;
  }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $replacement_styles = array_diff_key(image_style_options(), array($this->entity->id() => ''));
     $form['replacement'] = array('#title' => $this->t('Replacement style'), '#type' => 'select', '#options' => $replacement_styles, '#empty_option' => $this->t('No replacement, just delete'));
     return parent::form($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $image_styles = image_style_options(FALSE);
     $form['landscape'] = array('#type' => 'select', '#title' => t('Landscape image style'), '#options' => $image_styles, '#default_value' => $this->configuration['landscape'], '#description' => t('Select the image style for landscape images'), '#required' => TRUE);
     $form['portrait'] = array('#type' => 'select', '#title' => t('Portrait'), '#options' => $image_styles, '#default_value' => $this->configuration['portrait'], '#description' => t('Select the image style for portrait images'), '#required' => TRUE);
     return $form;
 }
Example #29
0
 /**
  * Overrides the actual editing form.
  */
 public function edit_form(&$form, &$form_state)
 {
     parent::edit_form($form, $form_state);
     ctools_form_include($form_state, 'slick.admin', 'slick');
     $module_path = drupal_get_path('module', 'slick');
     $optionset = $form_state['item'];
     $options = $optionset->options;
     $slick_options = slick_get_options();
     $form['#attached']['library'][] = array('slick_ui', 'slick.ui');
     $form['#attached']['css'][] = $module_path . '/css/admin/slick.admin--vertical-tabs.css';
     $form['#attributes']['class'][] = 'no-js';
     $form['#attributes']['class'][] = 'form--slick';
     $form['#attributes']['class'][] = 'form--compact';
     $form['#attributes']['class'][] = 'form--optionset';
     $form['#attributes']['class'][] = 'clearfix';
     $form['info']['name']['#attributes']['class'][] = 'is-tooltip';
     $form['info']['label']['#attributes']['class'][] = 'is-tooltip';
     $form['info']['label']['#prefix'] = '<div class="form--slick__header has-tooltip clearfix">';
     // Skins. We don't provide skin_thumbnail as each optionset may be deployed
     // as main display, or thumbnail navigation.
     $skins = slick_skins_options();
     $form['skin'] = array('#type' => 'select', '#title' => t('Skin'), '#options' => $skins, '#default_value' => $optionset->skin, '#empty_option' => t('- None -'), '#description' => t('Skins allow swappable layouts like next/prev links, split image and caption, etc. Be sure to provide a dedicated slide layout per field. However a combination of skins and options may lead to unpredictable layouts, get dirty yourself. See main <a href="@skin">README</a> for details on Skins. Keep it simple for thumbnail navigation skin.', array('@skin' => url($module_path . '/README.txt'))), '#attributes' => array('class' => array('is-tooltip')));
     $form['breakpoints'] = array('#title' => t('Breakpoints'), '#type' => 'textfield', '#description' => t('The number of breakpoints added to Responsive display, max 9. This is not Breakpoint Width (480px, etc).'), '#default_value' => isset($form_state['values']['breakpoints']) ? $form_state['values']['breakpoints'] : $optionset->breakpoints, '#suffix' => '</div>', '#ajax' => array('callback' => 'slick_ui_add_breakpoints', 'wrapper' => 'breakpoints-ajax-wrapper', 'event' => 'blur'), '#attributes' => array('class' => array('is-tooltip')), '#maxlength' => 1);
     // Options.
     $form['options'] = array('#type' => 'vertical_tabs', '#tree' => TRUE);
     // Image styles.
     $image_styles = function_exists('image_style_options') ? image_style_options(FALSE) : array();
     $form['options']['general'] = array('#type' => 'fieldset', '#title' => t('General'), '#attributes' => array('class' => array('has-tooltip', 'fieldset--no-checkboxes-label')));
     $form['options']['general']['normal'] = array('#type' => 'select', '#title' => t('Image style'), '#description' => t('Image style for the main/background image, overriden by field formatter. Useful for custom work.'), '#empty_option' => t('None (original image)'), '#options' => $image_styles, '#default_value' => isset($options['general']['normal']) ? $options['general']['normal'] : '', '#attributes' => array('class' => array('is-tooltip')));
     // More useful for custom work, overriden by sub-modules.
     $form['options']['general']['thumbnail'] = array('#type' => 'select', '#title' => t('Thumbnail style'), '#description' => t('Image style for the thumbnail image if using asNavFor, overriden by field formatter. Useful for custom work.'), '#empty_option' => t('None (original image)'), '#options' => $image_styles, '#default_value' => isset($options['general']['thumbnail']) ? $options['general']['thumbnail'] : '', '#attributes' => array('class' => array('is-tooltip')));
     $form['options']['general']['template_class'] = array('#type' => 'textfield', '#title' => t('Wrapper class'), '#description' => t('Additional template wrapper classes separated by spaces. No need to prefix it with a dot (.).'), '#default_value' => isset($options['general']['template_class']) ? $options['general']['template_class'] : '', '#attributes' => array('class' => array('is-tooltip')));
     $form['options']['general']['goodies'] = array('#type' => 'checkboxes', '#title' => t('Goodies'), '#default_value' => !empty($options['general']['goodies']) ? array_values((array) $options['general']['goodies']) : array(), '#options' => array('pattern' => t('Use pattern overlay'), 'arrow-down' => t('Use arrow down'), 'random' => t('Randomize')), '#description' => t('Applies to main display, not thumbnail pager. <ol><li>Pattern overlay is background image with pattern placed over the main stage.</li><li>Arrow down to scroll down into a certain page section, make sure to provide target selector.</li><li>Randomize the slide display, useful to manipulate cached blocks.</li></ol>'), '#attributes' => array('class' => array('is-tooltip')));
     $form['options']['general']['arrow_down_target'] = array('#type' => 'textfield', '#title' => t('Arrow down target'), '#description' => t('Valid CSS selector to scroll to, e.g.: #main, or #content.'), '#default_value' => isset($options['general']['arrow_down_target']) ? $options['general']['arrow_down_target'] : '', '#states' => array('visible' => array(':input[name*=arrow-down]' => array('checked' => TRUE))), '#attributes' => array('class' => array('is-tooltip')));
     $form['options']['general']['arrow_down_offset'] = array('#type' => 'textfield', '#title' => t('Arrow down offset'), '#description' => t('Offset when scrolled down from the top.'), '#default_value' => isset($options['general']['arrow_down_offset']) ? $options['general']['arrow_down_offset'] : '', '#states' => array('visible' => array(':input[name*=arrow-down]' => array('checked' => TRUE))), '#attributes' => array('class' => array('is-tooltip')));
     // Add empty suffix to style checkboxes like iOS.
     foreach ($form['options']['general']['goodies']['#options'] as $key => $value) {
         $form['options']['general']['goodies'][$key]['#field_suffix'] = '';
         $form['options']['general']['goodies'][$key]['#title_display'] = 'before';
     }
     // Main options.
     $slick_elements = $this->getSlickElements();
     $form['options']['settings'] = array('#title' => t('Settings'), '#type' => 'fieldset', '#collapsible' => FALSE, '#tree' => TRUE, '#attributes' => array('class' => array('fieldset--settings', 'has-tooltip')));
     foreach ($slick_elements as $name => $element) {
         $default_value = isset($options['settings'][$name]) ? $options['settings'][$name] : $element['default'];
         // Allows to reset string values by emptying it, such as changing arrows.
         if (is_string($default_value) && empty($default_value)) {
             $default_value = $element['default'];
         }
         $form['options']['settings'][$name] = array('#title' => isset($element['title']) ? $element['title'] : '', '#description' => isset($element['description']) ? $element['description'] : '', '#type' => $element['type'], '#default_value' => $default_value, '#attributes' => array('class' => array('is-tooltip')));
         if (isset($element['field_suffix'])) {
             $form['options']['settings'][$name]['#field_suffix'] = $element['field_suffix'];
         }
         if ($element['type'] == 'textfield') {
             $form['options']['settings'][$name]['#size'] = 20;
             $form['options']['settings'][$name]['#maxlength'] = 255;
         }
         if (!isset($element['field_suffix']) && is_bool($element['default'])) {
             $form['options']['settings'][$name]['#field_suffix'] = '';
             $form['options']['settings'][$name]['#title_display'] = 'before';
         }
         if (is_int($element['default'])) {
             $form['options']['settings'][$name]['#maxlength'] = 60;
             $form['options']['settings'][$name]['#attributes']['class'][] = 'form-text--int';
         }
         if (isset($element['states'])) {
             $form['options']['settings'][$name]['#states'] = $element['states'];
         }
         if (isset($element['options'])) {
             $form['options']['settings'][$name]['#options'] = $element['options'];
         }
         if (isset($element['empty_option'])) {
             $form['options']['settings'][$name]['#empty_option'] = $element['empty_option'];
         }
         // Expand textfield for easy edit.
         if (in_array($name, array('prevArrow', 'nextArrow'))) {
             $form['options']['settings'][$name]['#attributes']['class'][] = 'js-expandable';
         }
     }
     // Responsive options.
     $form['options']['responsives'] = array('#title' => t('Responsive display'), '#type' => 'fieldset', '#description' => t('Containing breakpoints and settings objects. Settings set at a given breakpoint/screen width is self-contained and does not inherit the main settings, but defaults.'), '#collapsible' => FALSE, '#tree' => TRUE);
     $form['options']['responsives']['responsive'] = array('#title' => t('Responsive'), '#type' => 'fieldset', '#collapsible' => FALSE, '#attributes' => array('class' => array('has-tooltip', 'fieldset--responsive--ajax')), '#prefix' => '<div id="breakpoints-ajax-wrapper">', '#suffix' => '</div>');
     $breakpoints_count = isset($form_state['values']['breakpoints']) ? $form_state['values']['breakpoints'] : $optionset->breakpoints;
     $form_state['breakpoints_count'] = $breakpoints_count;
     if ($form_state['breakpoints_count'] > 0) {
         $slick_responsive_elements = $this->getSlickResponsiveElements($form_state['breakpoints_count']);
         foreach ($slick_responsive_elements as $i => $responsives) {
             // Individual breakpoint fieldset.
             $fieldset_class = drupal_clean_css_identifier(drupal_strtolower($responsives['title']));
             $form['options']['responsives']['responsive'][$i] = array('#title' => $responsives['title'], '#type' => $responsives['type'], '#description' => isset($responsives['description']) ? $responsives['description'] : '', '#collapsible' => TRUE, '#collapsed' => TRUE, '#attributes' => array('class' => array('fieldset--responsive', 'fieldset--' . $fieldset_class, 'has-tooltip')));
             foreach ($responsives as $key => $responsive) {
                 switch ($key) {
                     case 'breakpoint':
                     case 'unslick':
                         $form['options']['responsives']['responsive'][$i][$key] = array('#title' => $responsive['title'], '#description' => $responsive['description'], '#type' => $responsive['type'], '#default_value' => isset($options['responsives']['responsive'][$i][$key]) ? $options['responsives']['responsive'][$i][$key] : $responsive['default'], '#attributes' => array('class' => array('is-tooltip')));
                         if ($responsive['type'] == 'textfield') {
                             $form['options']['responsives']['responsive'][$i][$key]['#size'] = 20;
                             $form['options']['responsives']['responsive'][$i][$key]['#maxlength'] = 255;
                         }
                         if (is_int($responsive['default'])) {
                             $form['options']['responsives']['responsive'][$i][$key]['#maxlength'] = 60;
                         }
                         if (isset($responsive['states'])) {
                             $form['options']['responsives']['responsive'][$i][$key]['#states'] = $responsive['states'];
                         }
                         if (isset($responsive['options'])) {
                             $form['options']['responsives']['responsive'][$i][$key]['#options'] = $responsive['options'];
                         }
                         if (isset($responsive['field_suffix'])) {
                             $form['options']['responsives']['responsive'][$i][$key]['#field_suffix'] = $responsive['field_suffix'];
                         }
                         if (!isset($responsive['field_suffix']) && is_bool($responsive['default'])) {
                             $form['options']['responsives']['responsive'][$i][$key]['#field_suffix'] = '';
                             $form['options']['responsives']['responsive'][$i][$key]['#title_display'] = 'before';
                         }
                         break;
                     case 'settings':
                         $form['options']['responsives']['responsive'][$i][$key] = array('#title' => t('Settings'), '#title_display' => 'invisible', '#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, '#attributes' => array('class' => array('fieldset--settings', 'fieldset--' . $fieldset_class, 'has-tooltip')), '#states' => array('visible' => array(':input[name*="[responsive][' . $i . '][unslick]"]' => array('checked' => FALSE))));
                         unset($responsive['title'], $responsive['type']);
                         if (!is_array($responsive)) {
                             continue;
                         }
                         foreach ($responsive as $k => $item) {
                             if ($item && !is_array($item)) {
                                 continue;
                             }
                             $form['options']['responsives']['responsive'][$i][$key][$k] = array('#title' => isset($item['title']) ? $item['title'] : '', '#description' => isset($item['description']) ? $item['description'] : '', '#type' => $item['type'], '#attributes' => array('class' => array('is-tooltip')), '#default_value' => isset($options['responsives']['responsive'][$i][$key][$k]) ? $options['responsives']['responsive'][$i][$key][$k] : $item['default']);
                             // Specify proper states for the breakpoint elements.
                             if (isset($item['states'])) {
                                 $states = '';
                                 switch ($k) {
                                     case 'pauseOnHover':
                                     case 'pauseOnDotsHover':
                                     case 'autoplaySpeed':
                                         $states = array('visible' => array(':input[name*="[' . $i . '][settings][autoplay]"]' => array('checked' => TRUE)));
                                         break;
                                     case 'centerPadding':
                                         $states = array('visible' => array(':input[name*="[' . $i . '][settings][centerMode]"]' => array('checked' => TRUE)));
                                         break;
                                     case 'touchThreshold':
                                         $states = array('visible' => array(':input[name*="[' . $i . '][settings][touchMove]"]' => array('checked' => TRUE)));
                                         break;
                                     case 'swipeToSlide':
                                         $states = array('visible' => array(':input[name*="[' . $i . '][settings][swipe]"]' => array('checked' => TRUE)));
                                         break;
                                     case 'cssEase':
                                     case 'cssEaseOverride':
                                         $states = array('visible' => array(':input[name*="[' . $i . '][settings][useCSS]"]' => array('checked' => TRUE)));
                                         break;
                                     case 'verticalSwiping':
                                         $states = array('visible' => array(':input[name*="[' . $i . '][settings][vertical]"]' => array('checked' => TRUE)));
                                         break;
                                 }
                                 if ($states) {
                                     $form['options']['responsives']['responsive'][$i][$key][$k]['#states'] = $states;
                                 }
                             }
                             if (isset($item['options'])) {
                                 $form['options']['responsives']['responsive'][$i][$key][$k]['#options'] = $item['options'];
                             }
                             if (isset($item['empty_option'])) {
                                 $form['options']['responsives']['responsive'][$i][$key][$k]['#empty_option'] = $item['empty_option'];
                             }
                             if (isset($item['field_suffix'])) {
                                 $form['options']['responsives']['responsive'][$i][$key][$k]['#field_suffix'] = $item['field_suffix'];
                             }
                             if (!isset($item['field_suffix']) && is_bool($item['default'])) {
                                 $form['options']['responsives']['responsive'][$i][$key][$k]['#field_suffix'] = '';
                                 $form['options']['responsives']['responsive'][$i][$key][$k]['#title_display'] = 'before';
                             }
                         }
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     // Allows form elements information to be altered without a class.
     // @see ctools_export_ui_edit_item_form
     drupal_alter('slick_ui_optionset_form', $form, $form_state);
 }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    // Get variables for default values.
    $config = $this->config('photos.settings');

    // Load custom admin css and js library.
    $form['#attached']['library'] = array(
      'photos/photos.admin'
    );

    $form['basic'] = array(
      '#title' => t('Basic settings'),
      '#weight' => -5,
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
    );

    // Search integration settings.
    $module_search_exists = \Drupal::moduleHandler()->moduleExists('search');
    if ($module_search_exists) {
      $url = \Drupal\Core\Url::fromRoute('entity.search_page.collection');
      $search_admin_link = \Drupal::l(t('enable photo searching'), $url);
      $form['basic']['search'] = array(
         '#markup' => t('Configure and @link', array('@link' => $search_admin_link))
       );
    }

    // Photos access integration settings.
    $module_photos_access_exists = \Drupal::moduleHandler()->moduleExists('photos_access');
    $url = \Drupal\Core\Url::fromRoute('system.modules_list', array(), array('fragment' => 'module-photos-access'));
    $link = \Drupal::l('photos_access', $url);
    $warning_msg = '';
    // Set warning if private file path is not set.
    if (!PrivateStream::basePath() && $config->get('photos_access_photos')) {
      $warning_msg = t('Warning: image files can still be accessed by visiting the direct URL.
        For better security, ask your website admin to setup a private file path.');
    }
    $form['basic']['photos_access_photos'] = array(
      '#type' => 'radios',
      '#title' => t('Privacy settings'),
      '#default_value' => $config->get('photos_access_photos') ?: 0,
      '#description' => $module_photos_access_exists ? $warning_msg : t('Enable the @link module.', array('@link' => $link)),
      '#options' => array(t('Disabled'), t('Enabled')),
      '#required' => TRUE,
      '#disabled' => ($module_photos_access_exists ? FALSE : TRUE)
    );

    // Classic upload form settings.
    $num_options = array(
      1 => 1,
      2 => 2,
      3 => 3,
      4 => 4,
      5 => 5,
      6 => 6,
      7 => 7,
      8 => 8,
      9 => 9,
      10 => 10
    );
    $form['basic']['photos_num'] = array(
      '#type' => 'select',
      '#title' => t('Classic form'),
      '#default_value' => $config->get('photos_num'),
      '#required' => TRUE,
      '#options' => $num_options,
      '#description' => t('Maximum number of upload fields on the classic upload form.'),
    );

    // Plupload integration settings.
    $module_plupload_exists = \Drupal::moduleHandler()->moduleExists('plupload');
    if ($module_plupload_exists) {
      $form['basic']['photos_plupload_status'] = array(
        '#type' => 'checkbox',
        '#title' => t('Use Plupoad for file uploads'),
        '#default_value' => $config->get('photos_plupload_status'),
      );
    }
    else {
      \Drupal::configFactory()->getEditable('photos.settings')->set('photos_plupload_status', 0)->save();
      $form['basic']['photos_plupload_status'] = array(
        '#type' => 'checkbox',
        '#title' => t('Use Plupoad for file uploads'),
        '#disabled' => TRUE,
        '#description' => t('To enable multiuploads and drag&drop upload features, download and install @link module', array(
          '@link' => \Drupal::l(t('Plupload integration'), \Drupal\Core\Url::fromUri('http://drupal.org/project/plupload'))
        )),
      );
    }

    // Photos module settings.
    // @todo token integration.
    $form['basic']['photos_path'] = array(
      '#type' => 'textfield',
      '#title' => t('Path'),
      '#default_value' => $config->get('photos_path'),
      '#description' => t('The path where the files will be saved relative to the files folder.
        Available variables: %uid, %username, %Y, %m, %d.'),
      '#size' => '40',
      '#required' => TRUE,
    );
    $form['basic']['photos_size_max'] = array(
      '#type' => 'textfield',
      '#title' => t('Maximum image resolution'),
      '#default_value' => $config->get('photos_size_max'),
      '#description' => t('The maximum image resolution example: 800x600. If an image toolkit is available the image will be scaled
        to fit within the desired maximum dimensions. Make sure this size is larger than any image styles used.
        Leave blank for no restrictions.'),
      '#size' => '40',
    );
    $form['basic']['photos_print_sizes'] = array(
      '#type' => 'radios',
      '#title' => t('How to display original image and all sizes?'),
      '#default_value' => $config->get('photos_print_sizes'),
      '#required' => TRUE,
      '#options' => array(
        t('Full page'),
        t('I am using colorbox (with Enable Colorbox load)'),
        t('Hide link')
      ),
    );
    $form['basic']['photos_comment'] = array(
      '#type' => 'radios',
      '#title' => t('Comment setting'),
      '#default_value' => $config->get('photos_comment') ?: 0,
      '#description' => t('Enable to comment on single photo. You must also open comments for content type / node.'),
      '#required' => TRUE,
      '#options' => array(t('Disabled'), t('Enabled')),
    );

    // Voting API module integration settings.
    $module_votingapi_exists = \Drupal::moduleHandler()->moduleExists('votingapi');
    $form['basic']['photos_vote'] = array(
      '#type' => 'radios',
      '#title' => t('Images vote'),
      '#default_value' => $config->get('photos_vote') ?: 0,
      '#description' => t('For the image to increase the voting feature, you must first install the votingapi.module.'),
      '#required' => TRUE,
      '#options' => array(t('Disabled'), t('Enabled')),
      '#disabled' => ($module_votingapi_exists ? FALSE : TRUE)
    );
    $form['basic']['photos_upzip'] = array(
      '#type' => 'radios',
      '#title' => t('Allow zip upload'),
      '#default_value' => $config->get('photos_upzip') ?: 0,
      '#description' => t('Will be allowed to upload images compressed into a zip folder.'),
      '#options' => array(t('Disabled'), t('Enabled'))
    );
    // @todo look into transliteration integration D8 core.
    $form['basic']['photos_rname'] = array(
      '#type' => 'radios',
      '#title' => t('Rename image'),
      '#default_value' => $config->get('photos_rname') ?: 0,
      '#description' => t('Rename uploaded image by random numbers, to solve problems with non-ASCII filenames such as Chinese.'),
      '#required' => TRUE,
      '#options' => array(t('Disabled'), t('Enabled')),
    );
    $form['basic']['num'] = array(
      '#title' => t('Number of albums'),
      '#weight' => 10,
      '#type' => 'fieldset',
      '#description' => t('The number of albums a user allowed to create. Administrater is not limited.'),
      '#collapsible' => TRUE,
      '#tree' => TRUE
    );

    $roles = user_roles(TRUE);
    foreach ($roles as $key => $role) {
      $form['basic']['num']['photos_pnum_' . $key] = array(
         '#type' => 'number',
         '#title' => $role->label(),
         '#required' => TRUE,
         '#default_value' => $config->get('photos_pnum_' . $key) ? $config->get('photos_pnum_' . $key) : 20,
         '#min' => 1,
         '#step' => 1,
         '#prefix' => '<div class="photos-admin-inline">',
         '#suffix' => '</div>',
         '#size' => 10
       );
    }
    // Thumb settings.
    if ($size = photos_upload_info(0)) {
      $num = ($size['count'] + 3);
      $sizes = array();
      foreach ($size['size'] as $style => $label) {
        $sizes[] = array(
          'style' => $style,
          'label' => $label
        );
      }
      $size['size'] = $sizes;
    }
    else {
      // @todo remove else or use $size_options?
      $num = 3;
      $size['size'] = array(
        array(
          'style' => 'medium',
          'label' => 'Medium'
        ),
        array(
          'style' => 'large',
          'label' => 'Large'
        ),
        array(
          'style' => 'thumbnail',
          'label' => 'Thumbnail'
        )
      );
    }
    $form['photos_thumb_count'] = array(
      '#type' => 'hidden',
      '#default_value' => $num,
    );
    $form['thumb'] = array(
      '#title' => t('Image sizes'),
      '#weight' => -4,
      '#type' => 'fieldset',
      '#description' => t('Default image sizes. Note: if an image style is deleted after it has been in use for some time that may result in broken external image links (i.e. from the share code and shared galleries).'),
      '#collapsible' => TRUE,
    );
    $thumb_options = image_style_options();
    if (empty($thumb_options)) {
      $form['thumb']['image_style'] = array(
        '#markup' => '<p>One or more image styles required: ' . \Drupal::l(t('add image styles'), \Drupal\Core\Url::fromRoute('entity.image_style.collection')) . '.</p>'
      );
    }
    else {
      $form['thumb']['photos_pager_imagesize'] = array(
        '#type' => 'select',
        '#title' => 'Pager size',
        '#default_value' => $config->get('photos_pager_imagesize'),
        '#description' => '(Default pager block image style.)',
        '#options' => $thumb_options,
        '#required' => TRUE,
      );
      $form['thumb']['photos_cover_imagesize'] = array(
        '#type' => 'select',
        '#title' => 'Cover size',
        '#default_value' => $config->get('photos_cover_imagesize'),
        '#description' => '(Default album cover image style.)',
        '#options' => $thumb_options,
        '#required' => TRUE,
      );
      $form['thumb']['photos_name_0'] = array(
        '#type' => 'textfield',
        '#title' => t('Name'),
        '#default_value' => isset($size['size'][0]['label']) ? $size['size'][0]['label'] : NULL,
        '#size' => '10',
        '#required' => TRUE,
        '#prefix' => '<div class="photos-admin-inline">'
      );

      $form['thumb']['photos_size_0'] = array(
        '#type' => 'select',
        '#title' => 'Thumb size',
        '#default_value' => isset($size['size'][0]['style']) ? $size['size'][0]['style'] : NULL,
        '#options' => $thumb_options,
        '#required' => TRUE,
        '#suffix' => '</div>'
      );
      $empty_option = array('' => '');
      $thumb_options = $empty_option+$thumb_options;
      $form['thumb']['additional_sizes'] = array(
        '#markup' => '<p>Additional image sizes ' . \Drupal::l(t('add more image styles'), \Drupal\Core\Url::fromRoute('entity.image_style.collection')) . '.</p>'
      );

      $additional_sizes = 0;
      for ($i = 1; $i < $num; $i++) {
        $form['thumb']['photos_name_' . $i] = array(
          '#type' => 'textfield',
          '#title' => t('Name'),
          '#default_value' => isset($size['size'][$i]['label']) ? $size['size'][$i]['label'] : NULL,
          '#size' => '10',
          '#prefix' => '<div class="photos-admin-inline">',
        );
        $form['thumb']['photos_size_' . $i] = array(
          '#type' => 'select',
          '#title' => t('Size'),
          '#default_value' => isset($size['size'][$i]['style']) ? $size['size'][$i]['style'] : NULL,
          '#options' => $thumb_options,
          '#suffix' => '</div>',
        );
        $additional_sizes = $i;
      }

      $form['thumb']['photos_additional_sizes'] = array(
        '#type' => 'hidden',
        '#value' => $additional_sizes
      );
    }
    // End thumb settings.
    // Display settings.
    $form['display'] = array(
      '#title' => t('Display Settings'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
    );

    $form['display']['global'] = array(
      '#type' => 'fieldset',
      '#title' => t('Global Settings'),
      '#collapsible' => TRUE,
      '#description' => t('Albums basic display settings')
    );
    $form['display']['page'] = array(
      '#type' => 'fieldset',
      '#title' => t('Page Settings'),
      '#collapsible' => TRUE,
      '#description' => t('Page (e.g: node/[nid]) display settings'),
      '#prefix' => '<div id="photos-form-page">',
      '#suffix' => '</div>'
    );
    $form['display']['teaser'] = array(
      '#type' => 'fieldset',
      '#title' => t('Teaser Settings'),
      '#collapsible' => TRUE,
      '#description' => t('Teaser display settings'),
      '#prefix' => '<div id="photos-form-teaser">',
      '#suffix' => '</div>'
    );
    $form['display']['global']['photos_display_viewpager'] = array(
      '#type' => 'number',
      '#default_value' => $config->get('photos_display_viewpager'),
      '#title' => t('How many images show in each page?'),
      '#required' => TRUE,
      '#min' => 1,
      '#step' => 1,
    );
    $form['display']['global']['photos_display_imageorder'] = array(
      '#type' => 'select',
      '#title' => t('Image display order'),
      '#required' => TRUE,
      '#default_value' => $config->get('photos_display_imageorder'),
      '#options' => _photos_order_label()
    );
    $list_imagesize = $config->get('photos_display_list_imagesize');
    $view_imagesize = $config->get('photos_display_view_imagesize');
    $size_options = _photos_select_size();
    $form['display']['global']['photos_display_list_imagesize'] = array(
      '#type' => 'select',
      '#title' => t('Image display size (list)'),
      '#required' => TRUE,
      '#default_value' => $list_imagesize,
      '#description' => t('Displayed in the list (e.g: photos/album/[nid]) of image size.'),
      '#options' => $size_options
    );
    $form['display']['global']['photos_display_view_imagesize'] = array(
      '#type' => 'select',
      '#title' => t('Image display size (page)'),
      '#required' => TRUE,
      '#default_value' => $view_imagesize,
      '#description' => t('Displayed in the page (e.g: photos/image/[fid]) of image size.'),
      '#options' => $size_options
    );
    $form['display']['global']['photos_display_user'] = array(
      '#type' => 'radios',
      '#title' => t('Allow users to modify this setting when they create a new album.'),
      '#default_value' => $config->get('photos_display_user') ?: 0,
      '#options' => array(t('Disabled'), t('Enabled'))
    );
    $form['display']['page']['photos_display_page_display'] = array(
      '#type' => 'radios',
      '#default_value' => $config->get('photos_display_page_display'),
      '#title' => t('Display setting'),
      '#required' => TRUE,
      '#options' => array(t('Do not display'), t('Display cover'), t('Display thumbnails'))
    );
    $form['display']['page']['photos_display_full_viewnum'] = array(
      '#type' => 'number',
      '#default_value' => $config->get('photos_display_full_viewnum'),
      '#title' => t('Display quantity'),
      '#required' => TRUE,
      '#min' => 1,
      '#step' => 1,
      '#prefix' => '<div class="photos-form-count">'
    );
    $form['display']['page']['photos_display_full_imagesize'] = array(
      '#type' => 'select',
      '#title' => t('Image display size'),
      '#required' => TRUE,
      '#default_value' => $config->get('photos_display_full_imagesize'),
      '#options' => $size_options,
      '#suffix' => '</div>'
    );
    $form['display']['page']['photos_display_page_user'] = array(
      '#type' => 'radios',
      '#title' => t('Allow users to modify this setting when they create a new album.'),
      '#default_value' => $config->get('photos_display_page_user') ?: 0,
      '#options' => array(t('Disabled'), t('Enabled'))
    );
    $form['display']['teaser']['photos_display_teaser_display'] = array(
      '#type' => 'radios',
      '#default_value' => $config->get('photos_display_teaser_display'),
      '#title' => t('Display setting'),
      '#required' => TRUE,
      '#options' => array(t('Do not display'), t('Display cover'), t('Display thumbnails'))
    );
    $form['display']['teaser']['photos_display_teaser_viewnum'] = array(
      '#type' => 'number',
      '#default_value' => $config->get('photos_display_teaser_viewnum'),
      '#title' => t('Display quantity'),
      '#required' => TRUE,
      '#min' => 1,
      '#step' => 1,
      '#prefix' => '<div class="photos-form-count">'
    );
    $form['display']['teaser']['photos_display_teaser_imagesize'] = array(
      '#type' => 'select',
      '#title' => t('Image display size'),
      '#required' => TRUE,
      '#default_value' => $config->get('photos_display_teaser_imagesize'),
      '#options' => $size_options,
      '#suffix' => '</div>'
    );
    $form['display']['teaser']['photos_display_teaser_user'] = array(
      '#type' => 'radios',
      '#title' => t('Allow users to modify this setting when they create a new album.'),
      '#default_value' => $config->get('photos_display_teaser_user') ?: 0,
      '#options' => array(t('Disabled'), t('Enabled'))
    );
    // Count settings.
    $form['count'] = array(
      '#title' => t('Statistics'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
    );
    $form['count']['photos_image_count'] = array(
      '#type' => 'radios',
      '#title' => t('Count image views'),
      '#default_value' => $config->get('photos_image_count') ?: 0,
      '#description' => t('Increment a counter each time image is viewed.'),
      '#options' => array( t('Enabled'), t('Disabled'))
    );
    $form['count']['photos_user_count_cron'] = array(
      '#type' => 'radios',
      '#title' => t('Image quantity statistics'),
      '#default_value' => $config->get('photos_user_count_cron') ?: 0,
      '#description' => t('Users/Site images and albums quantity statistics.'),
      '#options' => array( t('Update count when cron runs (affect the count update).'), t('Update count when image is uploaded (affect the upload speed)'))
    );
    // End count settings.
    // Exif settings.
    $form['exif'] = array(
      '#title' => t('Exif Settings'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#description' => t('These options require the php exif extension to be loaded.')
    );
    $form['exif']['photos_exif'] = array(
      '#type' => 'radios',
      '#title' => t('Show exif information'),
      '#default_value' => $config->get('photos_exif') ?: 0,
      '#description' => t('When the image is available automatically read and display exif information.'),
      '#options' => array(t('Disabled'), t('Enabled')),
      '#disabled' => (extension_loaded('exif') ? FALSE : TRUE)
    );
    $form['exif']['photos_exif_cache'] = array(
      '#type' => 'radios',
      '#title' => t('Cache exif information'),
      '#default_value' => $config->get('photos_exif_cache') ?: 0,
      '#description' => t('Exif information cache can improve access speed.'),
      '#options' => array(t('Do not cache'), t('To database')),
      '#disabled' => (extension_loaded('exif') ? FALSE : TRUE)
    );
    // $form['exif']['photos_exif_help']['#markup'] = '<p>' . t('For custom exif please modify function _photos_exif_tag,
    //  in: .../photos/inc/photos.down.inc') . '</p>';
    // End exif settings.

    return parent::buildForm($form, $form_state);
  }