You are here

function node_gallery_api_relationship_type_settings_form in Node Gallery 7

Form definition for Relationship Type settings form.

1 string reference to 'node_gallery_api_relationship_type_settings_form'
node_gallery_api_menu in ./node_gallery_api.module
Implements hook_menu().

File

./node_gallery_api.admin.inc, line 246
Node Gallery API admin interface.

Code

function node_gallery_api_relationship_type_settings_form($form, $form_state, $relationship_type) {
  $view_modes = node_gallery_api_get_view_modes();
  $item_fields = node_gallery_api_get_fields_from_content_types($relationship_type->item_types);
  $item_field_options = array();
  foreach ($item_fields as $key => $info) {
    $item_field_options[$key] = $info['label'];
  }
  $form['#tree'] = TRUE;
  $form['#relationship_type'] = $relationship_type;
  $form['relationship'] = array(
    '#type' => 'fieldset',
    '#title' => t('Relationship settings'),
    '#description' => t('This area defines the settings used to define the relationship between the Gallery and Item content types.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['relationship']['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_type->settings['relationship']['name'],
    '#required' => TRUE,
  );
  $viewdisplays = node_gallery_api_build_views_select('node_gallery_items');
  $form['view_modes'] = array(
    '#type' => 'fieldset',
    '#title' => t('Gallery View Modes'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#description' => t('This area defines the settings used to display an individual gallery node.'),
  );
  foreach ($view_modes as $name => $label) {
    $form['view_modes'][$name] = array(
      '#type' => 'fieldset',
      '#title' => check_plain($label),
      '#collapsible' => TRUE,
      '#collapsed' => !($name == 'full' || $name == 'teaser'),
    );
    $form['view_modes'][$name]['view'] = array(
      '#type' => 'select',
      '#title' => 'View',
      '#description' => t("Select the display of the gallery items which will be shown in this view mode. Only Views tagged with 'node_gallery_items' are displayed here."),
      '#options' => $viewdisplays,
      '#default_value' => isset($relationship_type->settings['view_modes'][$name]['view']) ? $relationship_type->settings['view_modes'][$name]['view'] : '',
    );
  }

  // Image view options.
  $form['item_view'] = array(
    '#type' => 'fieldset',
    '#title' => t('Item view settings'),
    '#description' => t('This area defines the settings used when displaying an individual item node.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['item_view']['display_navigator'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display item navigator on item pages?'),
    '#default_value' => $relationship_type->settings['item_view']['display_navigator'],
    '#description' => t('When checked, the navigator (bar providing "Previous", "Next", etc. links) will be displayed at the top of the item page.'),
  );
  $form['item_view']['view_navigator_item_display'] = array(
    '#type' => 'select',
    '#title' => t('Item navigator sort view'),
    '#description' => t("Select the display that defines the desired sort order to be used when displaying items. You must include the 'Node: Nid' field in this view. Only Views tagged with 'node_gallery_items' are displayed here."),
    '#options' => $viewdisplays,
    '#default_value' => isset($relationship_type->settings['item_view']['view_navigator_item_display']) ? $relationship_type->settings['item_view']['view_navigator_item_display'] : '',
  );
  $form['item_view']['page_fragment'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use Named Anchors on Image "Previous" and "Next" links?'),
    '#default_value' => $relationship_type->settings['item_view']['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['manage_items'] = array(
    '#type' => 'fieldset',
    '#title' => t('Manage Items tab settings'),
    '#description' => t('This area defines the settings used by the Manage Items tab.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['manage_items']['items_fields'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Manage Items Fields'),
    '#options' => $item_field_options,
    '#description' => t('Specify which fields should be displayed on the Manage Items tab of a gallery node.'),
    '#default_value' => $relationship_type->settings['manage_items']['items_fields'],
  );
  $form['manage_items']['items_per_page'] = array(
    '#type' => 'textfield',
    '#maxlength' => 5,
    '#size' => 5,
    '#title' => t('Enter the number of images displayed on each Manage Items page'),
    '#default_value' => $relationship_type->settings['manage_items']['items_per_page'],
    '#description' => t('If this number is exceeded, a pager will be displayed below each corresponding Manage Items page.'),
  );
  if (image_get_toolkit() != 'gd' || function_exists("imagerotate")) {
    $form['manage_items']['enable_rotation'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable the rotation of images on the Manage Items page'),
      '#default_value' => $relationship_type->settings['manage_items']['enable_rotation'],
      '#description' => t('If checked, image rotation operations will be displayed on each image on the Manage Items tab.'),
    );
    $form['manage_items']['rotation_radios'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show radio buttons for rotation.'),
      '#default_value' => isset($relationship_type->settings['manage_items']['rotation_radios']) ? $relationship_type->settings['manage_items']['rotation_radios'] : 1,
      '#description' => t('If checked, image rotation can be done by selecting radio buttons for the rotation degree.'),
      '#states' => array(
        'disabled' => array(
          ':input[name="manage_items[enable_rotation]"]' => array(
            'checked' => FALSE,
          ),
        ),
      ),
    );
    $form['manage_items']['rotation_modal'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show link for rotation popup.'),
      '#default_value' => isset($relationship_type->settings['manage_items']['rotation_modal']) ? $relationship_type->settings['manage_items']['rotation_modal'] : 1,
      '#description' => t('If checked, image rotation can be done with a popup box that display all options.'),
      '#states' => array(
        'disabled' => array(
          ':input[name="manage_items[enable_rotation]"]' => array(
            'checked' => FALSE,
          ),
        ),
      ),
    );
  }
  $has_og = module_exists('og');
  $form['og'] = array(
    '#type' => 'fieldset',
    '#title' => t('Organic Groups'),
    '#collapsible' => TRUE,
    '#collapsed' => !$has_og,
  );
  $form['og']['sync_items'] = array(
    '#type' => 'checkbox',
    '#title' => t("Keep gallery item Group Audience in sync with gallery Group Audience"),
    '#default_value' => isset($relationship_type->settings['og']['sync_items']) ? $relationship_type->settings['og']['sync_items'] : 1,
    '#description' => t('If checked, changes to the Group Audience of a gallery will be copied to all items in that gallery.'),
  );
  if (!$has_og) {
    $form['og']['sync_items']['#attributes']['disabled'] = 'disabled';
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 8,
  );
  $form['#submit'] = array(
    'node_gallery_api_relationship_settings_form_submit',
  );
  return $form;
}