You are here

function vkxp_admin_images_settings in VK CrossPoster 6

Same name and namespace in other branches
  1. 6.2 vkxp.admin.inc \vkxp_admin_images_settings()
  2. 7 vkxp.admin.inc \vkxp_admin_images_settings()

Return form width vkxp image settings

1 string reference to 'vkxp_admin_images_settings'
vkxp_menu in ./vkxp.module
Implementation of hook_menu()

File

./vkxp.admin.inc, line 211
Contains vkxp settings forms

Code

function vkxp_admin_images_settings() {
  $form = array();

  // Get node types that should be crossposted
  $selected_node_types = _vkxp_get_selected_node_types();
  if (!$selected_node_types) {
    $form['imagefield'] = array(
      '#value' => t('Please, select content types to see their image fiels'),
    );
    return $form;
  }
  if (module_exists('imagefield')) {
    $image_fields = array();
    $content_info = _content_type_info();
    foreach ($selected_node_types as $node_type) {

      // Build fieldset for every selected node type
      $node_types = node_get_types('names');
      $form['vkxp_node_type_' . $node_type] = array(
        '#type' => 'fieldset',
        '#title' => $node_types[$node_type],
      );

      // If node type has cck fields we should find imagefield
      if ($content_info['content types'][$node_type]['fields']) {
        $fields = $content_info['content types'][$node_type]['fields'];
        foreach ($fields as $field) {
          if ($field['widget']['module'] == 'imagefield') {
            $image_fields[$node_type][$field['field_name']] = $field['field_name'];
          }
        }
      }

      // If imagefield for this node type found - build settings form for that
      if ($image_fields[$node_type]) {
        $form['vkxp_node_type_' . $node_type][$node_type . '_image_amount'] = array(
          '#type' => 'select',
          '#title' => t('Select amount of images'),
          '#options' => drupal_map_assoc(array(
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
          )),
          '#default_value' => variable_get($node_type . '_image_amount', 0),
          '#description' => t('Amount of images which will be posted to vkontakte.ru'),
        );
        $form['vkxp_node_type_' . $node_type][$node_type . '_image_field'] = array(
          '#type' => 'select',
          '#title' => t('Select imagefield'),
          '#options' => $image_fields[$node_type],
          '#default_value' => variable_get($node_type . '_image_field', ''),
          '#description' => t('Selected field will be posted with message to vkontakte.ru'),
        );
      }
      else {
        $form['vkxp_node_type_' . $node_type]['empty_value'] = array(
          '#value' => t('This node types does not contain image fields'),
        );
      }
    }
  }
  else {
    $form['imagefield'] = array(
      '#value' => t("You can't post images until !imagefield module is installed.", array(
        '!imagefield' => '<a href = "http://drupal.org/project/imagefield">imagefield</a>',
      )),
    );
    return $form;
  }
  $form = system_settings_form($form);
  unset($form['buttons']['reset']);
  return $form;
}