You are here

function _collageformatter_settings_form in Collage Formatter 7

Settings form for Collage Formatter.

2 calls to _collageformatter_settings_form()
collageformatter_field_formatter_settings_form in ./collageformatter.module
Implements hook_field_formatter_settings_form().
collageformatter_plugin_style_collage::options_form in views/collageformatter_plugin_style_collage.inc
Provide the form for setting options.

File

./collageformatter.module, line 111
Main file for Collage Formatter module.

Code

function _collageformatter_settings_form($settings) {
  $options_0_50 = drupal_map_assoc(range(0, 50));
  $options_1_50 = drupal_map_assoc(range(1, 50));
  $element['collage_number'] = array(
    '#type' => 'select',
    '#title' => t('Number of collages'),
    '#title_display' => 'invisible',
    '#options' => $options_1_50,
    '#default_value' => $settings['collage_number'],
    '#field_prefix' => t('Generate'),
    '#field_suffix' => t('collage(s)'),
    '#prefix' => '<div class="container-inline">',
  );
  $element['images_per_collage'] = array(
    '#type' => 'select',
    '#title' => t('Images per collage'),
    '#title_display' => 'invisible',
    '#options' => $options_1_50,
    '#default_value' => $settings['images_per_collage'],
    '#empty_option' => t('all'),
    '#field_prefix' => t('with'),
    '#field_suffix' => t('image(s) per collage') . ';',
  );
  $element['images_to_skip'] = array(
    '#type' => 'select',
    '#title' => t('Images to skip'),
    '#title_display' => 'invisible',
    '#options' => $options_0_50,
    '#default_value' => $settings['images_to_skip'],
    '#field_prefix' => t('Skip'),
    '#field_suffix' => t('image(s) from the start'),
    '#suffix' => '</div>',
  );
  $element['collage_orientation'] = array(
    '#type' => 'select',
    '#title' => t('Collage orientation'),
    '#description' => t('Select if it should be a wide collage (landscape) or a tall one (portrait).'),
    '#options' => array(
      '0' => t('Landscape'),
      '1' => t('Portrait'),
    ),
    '#default_value' => $settings['collage_orientation'],
    '#prefix' => '<div class="container-inline">',
    '#field_suffix' => '</br>',
    '#suffix' => '</div>',
  );
  $element['collage_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Collage width'),
    '#title_display' => 'invisible',
    '#default_value' => $settings['collage_width'],
    '#element_validate' => array(
      'element_validate_integer_positive',
    ),
    '#size' => 4,
    '#maxlength' => 4,
    '#prefix' => '<div class="container-inline"><strong>' . t('Collage width & height') . '</strong>',
    // '#field_prefix' => '</br>',
    '#field_suffix' => 'x',
  );
  $element['collage_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Collage height'),
    '#title_display' => 'invisible',
    '#description' => t('Total collage width and height with all the borders and gaps. If you specify both then the images will be cropped.'),
    '#default_value' => $settings['collage_height'],
    '#element_validate' => array(
      'element_validate_integer_positive',
    ),
    '#size' => 4,
    '#maxlength' => 4,
    '#field_suffix' => 'px</br>',
    '#suffix' => '</div>',
  );
  $element['collage_border_size'] = array(
    '#type' => 'select',
    '#title' => t('Collage border'),
    '#options' => $options_0_50,
    '#default_value' => $settings['collage_border_size'],
    '#field_suffix' => 'px',
    '#prefix' => '<div class="container-inline">',
  );
  $element['collage_border_color'] = array(
    '#type' => 'textfield',
    '#title' => t('Collage border color'),
    '#default_value' => $settings['collage_border_color'],
    '#size' => 7,
    '#maxlength' => 7,
    '#suffix' => '<div class="collageformatter-color-picker"></div>' . '</div>',
    '#attached' => array(
      'library' => array(
        array(
          'system',
          'farbtastic',
        ),
      ),
      'js' => array(
        drupal_get_path('module', 'collageformatter') . '/js/collageformatter.admin.js' => array(
          'type' => 'file',
        ),
      ),
    ),
  );
  $element['gap_size'] = $element['collage_border_size'];
  $element['gap_size']['#title'] = t('Image gap');
  $element['gap_size']['#default_value'] = $settings['gap_size'];
  $element['gap_color'] = $element['collage_border_color'];
  $element['gap_color']['#title'] = t('Image gap color');
  $element['gap_color']['#default_value'] = $settings['gap_color'];
  $element['border_size'] = $element['collage_border_size'];
  $element['border_size']['#title'] = t('Image border');
  $element['border_size']['#default_value'] = $settings['border_size'];
  $element['border_color'] = $element['collage_border_color'];
  $element['border_color']['#title'] = t('Image border color');
  $element['border_color']['#default_value'] = $settings['border_color'];
  $link_types = array(
    'content' => t('Content'),
    'file' => t('File'),
  );
  $element['image_link'] = array(
    '#title' => t('Link image to'),
    '#type' => 'select',
    '#default_value' => $settings['image_link'],
    '#empty_option' => t('Nothing'),
    '#options' => $link_types,
    '#prefix' => '<div class="container-inline">',
  );
  $image_styles = image_style_options(FALSE);
  $element['image_link_image_style'] = array(
    '#title' => t('Target image style'),
    '#type' => 'select',
    '#default_value' => $settings['image_link_image_style'],
    '#empty_option' => t('None (original image)'),
    '#options' => $image_styles,
  );
  $modal_options = array();
  if (module_exists('colorbox')) {
    $modal_options['colorbox'] = t('Colorbox');
  }
  if (module_exists('shadowbox')) {
    $modal_options['shadowbox'] = t('Shadowbox');
  }
  if (module_exists('fancybox')) {
    $modal_options['fancybox'] = t('fancyBox');
  }
  if (module_exists('photobox')) {
    $modal_options['photobox'] = t('Photobox');
  }
  if (module_exists('photoswipe')) {
    $modal_options['photoswipe'] = t('PhotoSwipe');
  }
  if (module_exists('lightbox2')) {
    $modal_options['lightbox2'] = t('Lightbox2');
  }
  $element['image_link_modal'] = array(
    '#title' => t('Modal gallery'),
    '#type' => 'select',
    '#default_value' => $settings['image_link_modal'],
    '#empty_option' => t('None'),
    '#options' => $modal_options,
    '#suffix' => '</div>',
  );
  $element['image_link_class'] = array(
    '#type' => 'textfield',
    '#title' => t('Image link class'),
    // '#description' => t('Custom class to add to all image links.'),
    '#default_value' => $settings['image_link_class'],
    '#size' => 30,
    '#prefix' => '<div class="container-inline">',
  );
  $element['image_link_rel'] = array(
    '#type' => 'textfield',
    '#title' => t('Image link rel'),
    // '#description' => t('Custom rel attribute to add to all image links.'),
    '#default_value' => $settings['image_link_rel'],
    '#size' => 30,
    '#suffix' => '</div>',
  );
  $element['generate_image_derivatives'] = array(
    '#type' => 'checkbox',
    '#title' => t('Generate image derivatives'),
    '#description' => t('Generate image derivatives used in the collage while rendering it, before displaying.'),
    '#default_value' => $settings['generate_image_derivatives'],
  );
  $element['prevent_upscale'] = array(
    '#type' => 'checkbox',
    '#title' => t('Prevent images upscaling'),
    '#description' => t('Generated collage dimensions might be smaller.'),
    '#default_value' => $settings['prevent_upscale'],
  );
  $element['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $element['advanced']['original_image_reference'] = array(
    '#type' => 'radios',
    '#title' => t('Original image reference method'),
    '#description' => t('If you need to add additional image effects to collageformatter image style before the "Collage Formatter" effect then you need to use "Symlink" or "Copy" method.'),
    '#options' => array(
      'symlink' => t('Symlink'),
      'fake' => t('Fake image'),
      'copy' => t('Copy'),
    ),
    '#default_value' => $settings['advanced']['original_image_reference'],
  );
  return $element;
}