You are here

function node_gallery_lightbox2_form_alter in Node Gallery 6.2

Implementation of hook_form_alter()

File

contrib/node_gallery_lightbox2/node_gallery_lightbox2.module, line 20
node_gallery_lightbox2.module

Code

function node_gallery_lightbox2_form_alter(&$form, $form_state, $form_id) {
  static $imagecaches;
  if ($form_id == 'node_gallery_config_form') {
    $step = empty($form_state['values']['step']) ? 1 : 2;
    if ($step == 2) {
      $gallery_config = $form['#gallery_config'];
      if (empty($imagecaches)) {
        foreach (imagecache_presets() as $id => $imagecache) {
          $imagecaches[$imagecache['presetname']] = $imagecache['presetname'];
        }
      }
      drupal_add_js(drupal_get_path('module', 'node_gallery_lightbox2') . '/node_gallery_lightbox2.admin.js', 'module');
      $form['config']['original']['view_original']['#options']['lightbox2'] = t('Enable as Lightbox2 Popup');
      $form['config']['original']['lightbox2'] = array(
        '#type' => 'select',
        '#title' => t('Imagecache Preset for Lightbox2'),
        '#options' => $imagecaches,
        '#description' => t('Select an Imagecache preset that will be used with the Lightbox2 popup.  Please note that this preset should be larger than your Display preset.'),
        '#default_value' => $gallery_config['original']['lightbox2'],
        '#prefix' => '<div class="lightbox2-preset">',
        '#suffix' => '</div>',
        '#weight' => 6,
      );
      $form['config']['teaser']['gallery_display_type']['#options']['lightbox2_gallery'] = t('Thumbnails that open a Lightbox2 Gallery');
      $form['config']['teaser']['lightbox2_gallery'] = array(
        '#type' => 'select',
        '#title' => t('Image Size for Lightbox2 Gallery'),
        '#options' => $imagecaches,
        '#description' => t('Select an Imagecache preset that will be used with the Lightbox2 popup.'),
        '#default_value' => $gallery_config['teaser']['lightbox2_gallery'],
        '#prefix' => '<div class="lightbox2-gallery-preset">',
        '#suffix' => '</div>',
        '#weight' => 10,
      );
      $form['config']['gallery']['gallery_display_type']['#options']['lightbox2_gallery'] = t('Thumbnails that open a Lightbox2 Gallery');
      $form['config']['gallery']['lightbox2_gallery_preset'] = array(
        '#type' => 'select',
        '#title' => t('Image Size for Lightbox2 Gallery'),
        '#options' => $imagecaches,
        '#description' => t('Select an Imagecache preset that will be used with the Lightbox2 popup.'),
        '#default_value' => $gallery_config['gallery']['lightbox2_gallery_preset'],
        '#prefix' => '<div class="gallery-lightbox2-gallery-preset">',
        '#suffix' => '</div>',
        '#weight' => 10,
      );
    }
  }
}