You are here

function node_gallery_relationship_settings_form in Node Gallery 6.3

Returns a FAPI form array that renders the settings form when adding/editing a Gallery-to-Image relationship

@parm $form_state

Parameters

$gallery_config: The existing gallery config relationship

Return value

A FAPI form array

1 string reference to 'node_gallery_relationship_settings_form'
node_gallery_menu in ./node_gallery.module
Implements hook_menu().

File

./node_gallery.admin.inc, line 240

Code

function node_gallery_relationship_settings_form($form_state, $relationship) {
  static $node_types, $image_types, $imagecaches;
  $image_type = content_types($relationship['image_type']);
  if (module_exists('taxonomy') && taxonomy_get_vocabularies($image_type['type'])) {
    $image_type['extra']['taxonomy'] = array(
      'label' => t('Taxonomy'),
      'description' => t('Taxonomy module form.'),
      'weight' => -3,
    );
  }

  //non-cck fields
  foreach ($image_type['extra'] as $name => $field) {
    if ($name != 'menu' && $name != 'attachments' && $name != 'workflow') {
      $image_type_fields[$name] = check_plain($field['label']);
    }
  }

  //cck fields
  foreach ($image_type['fields'] as $name => $field) {
    $image_type_fields[$name] = check_plain($field['widget']['label']);
  }
  if (empty($imagecaches)) {
    foreach (imagecache_presets() as $id => $imagecache) {
      $imagecaches[$imagecache['presetname']] = $imagecache['presetname'];
    }
  }
  if (empty($imagecaches)) {
    form_set_error('Node gallery config', t('There are no imagecache presets. <a href="@imagecache">You must create at least one preset</a>.', array(
      '@imagecache' => url('admin/build/imagecache/add'),
    )));
  }
  module_load_include('inc', 'content', 'includes/content.crud');
  $imagefield_instances = content_field_instance_read(array(
    'type_name' => $relationship['image_type'],
  ));
  $options_imagefields = array();
  foreach ($imagefield_instances as $imagefield_instance) {
    $options_imagefields[$imagefield_instance['field_name']] = $imagefield_instance['field_name'];
  }
  if (!array_key_exists('field_node_gallery_image', $options_imagefields)) {
    $options_imagefields['field_node_gallery_image'] = t('Create new imagefield');
  }
  $form['#relationship'] = $relationship;
  $form['node_gallery_relationship_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Relationship settings'),
    '#description' => t('This area defines the settings used to define the relationship between the Gallery and Image content types.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['node_gallery_relationship_settings']['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Relationship Name'),
    '#description' => t('Enter a name for this relationship which will only be viewed by the admin user.'),
    '#default_value' => $relationship['settings']['name'],
    '#required' => TRUE,
  );
  $form['node_gallery_relationship_settings']['imagefield'] = array(
    '#type' => 'select',
    '#title' => t('Image storage field'),
    '#description' => t("Select the CCK imagefield that will be used for storing the gallery images.  In most cases, you shouldn't need to change this setting."),
    '#options' => $options_imagefields,
    '#default_value' => isset($relationship['imagefield_name']) && !empty($relationship['imagefield_name']) ? $relationship['imagefield_name'] : 'field_node_gallery_image',
  );
  $viewdisplays = node_gallery_build_views_select('node_gallery_images');
  $form['node_gallery_gallery_view'] = array(
    '#type' => 'fieldset',
    '#title' => t('Gallery settings'),
    '#description' => t('This area defines the settings used to display an individual gallery node.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['node_gallery_gallery_view']['full'] = array(
    '#type' => 'fieldset',
    '#title' => t('Gallery full(page) view settings'),
    '#description' => t('Settings applied to a gallery node when being viewed in full(page) mode.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['node_gallery_gallery_view']['full']['view_gallery_full_image_display'] = array(
    '#type' => 'select',
    '#title' => t('Gallery full(page) view definition'),
    '#description' => t("Select the display of the images which will be attached to the page view of a gallery. Only Views tagged with 'node_gallery_images' are displayed here."),
    '#options' => $viewdisplays,
    '#default_value' => $relationship['settings']['view_gallery_full_image_display'],
  );
  $form['node_gallery_gallery_view']['full']['view_navigator_image_display'] = array(
    '#type' => 'select',
    '#title' => t('Gallery image sort view definition'),
    '#description' => t("Select the display that defines the desired sort order to be used when displaying images. You must include the 'Node: Nid' field in this view. Only Views tagged with 'node_gallery_images' are displayed here."),
    '#options' => $viewdisplays,
    '#default_value' => $relationship['settings']['view_navigator_image_display'],
  );
  $form['node_gallery_gallery_view']['teaser'] = array(
    '#type' => 'fieldset',
    '#title' => t('Gallery teaser(list) view settings'),
    '#description' => t('Settings applied to a gallery node when being viewed in teaser(list) mode.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['node_gallery_gallery_view']['teaser']['view_gallery_teaser_view_image_display'] = array(
    '#type' => 'select',
    '#title' => t('Gallery teaser(list) view definition'),
    '#description' => t("Select the display of the images which will be attached to the teaser view of a gallery. Only Views tagged with 'node_gallery_images' are displayed here."),
    '#options' => $viewdisplays,
    '#default_value' => $relationship['settings']['view_gallery_teaser_view_image_display'],
  );

  // image view options
  $form['node_gallery_image_view'] = array(
    '#type' => 'fieldset',
    '#title' => t('Image view settings'),
    '#description' => t('This area defines the settings used when displaying an individual image node.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['node_gallery_image_view']['display_navigator'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display image navigator on image pages?'),
    '#default_value' => $relationship['settings']['display_navigator'],
    '#description' => t('When checked, the navigator (bar providing "Previous", "Next", etc. links) will be displayed at the top of the image page.'),
  );
  $form['node_gallery_image_view']['node_images_page_fragment'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use Named Anchors on Image "Previous" and "Next" links?'),
    '#default_value' => $relationship['settings']['node_images_page_fragment'],
    '#description' => t('When checked, the "Previous" and "Next" links will jump to the top of the image. You might want to leave this unchecked if you have ads at the top of your image pages.'),
  );

  // Manage images tab settings
  $form['node_gallery_manage_images_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Manage Images tab settings'),
    '#description' => t('This area defines the settings used by the Manage Images tab.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['node_gallery_manage_images_settings']['manage_images_fields'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Manage Images Fields'),
    '#options' => $image_type_fields,
    '#description' => t('Specify which fields should be displayed on the Manage Images tab of a gallery node.'),
    '#default_value' => $relationship['settings']['manage_images_fields'],
  );
  $form['node_gallery_manage_images_settings']['manage_images_per_page'] = array(
    '#type' => 'textfield',
    '#maxlength' => 5,
    '#size' => 5,
    '#title' => t('Enter the number of images displayed on each Manage Images page'),
    '#default_value' => $relationship['settings']['manage_images_per_page'],
    '#description' => t('If this number is exceeded, a pager will be displayed below each corresponding Manage Images page.'),
  );
  $form['node_gallery_manage_images_settings']['manage_images_show_gallery_list'] = array(
    '#type' => 'checkbox',
    '#title' => t("Enable changing an image's gallery on the Manage Images page"),
    '#default_value' => $relationship['settings']['manage_images_show_gallery_list'],
    '#description' => t('If checked, a gallery dropdown list will be displayed on each image on the Manage Images tab allowing you to move images between galleries.'),
  );
  if (imageapi_default_toolkit() != 'imageapi_gd' || function_exists("imagerotate")) {
    $form['node_gallery_manage_images_settings']['manage_images_enable_rotation'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable the rotation of images on the manage images page'),
      '#default_value' => $relationship['settings']['manage_images_enable_rotation'],
      '#description' => t('If checked, image rotation operations will be displayed on each image on the Manage Images tab.'),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 8,
  );
  $form['#submit'] = array(
    'node_gallery_relationship_settings_form_submit',
  );
  return $form;
}