You are here

function emimport_settings in Embedded Media Field 5

callback page for /admin/content/emfield/import.

this is the settings form for global & provider import settings.

1 string reference to 'emimport_settings'
emimport_menu in contrib/emimport/emimport.module
Implement hook_menu

File

contrib/emimport/emimport.module, line 59

Code

function emimport_settings() {
  $form = array();
  $form['emimport'] = array(
    '#type' => 'fieldset',
    '#title' => t('Embedded Media Import settings'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );

  // global settings...
  $form['emimport']['global'] = array(
    '#type' => 'fieldset',
    '#title' => t('Global settings'),
    '#description' => t('These settings apply to all importing of third party sets, but may be overridden in the individual Provider settings.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['emimport']['global']['emimport_global_display'] = array(
    '#type' => 'textfield',
    '#title' => t('Import display limit'),
    '#description' => t('This will limit how many titles/thumbnails will be displayed on the actual import page, when checking the individual set items to import. Leave at to 0 for unlimited, or to allow individual provider/types to override. If this value is greater than 0, then it may not be overridden below.'),
    '#default_value' => variable_get('emimport_global_display', 0),
  );
  $tags_select = array(
    0 => '(None)',
  );
  foreach (taxonomy_get_vocabularies() as $vocabulary) {
    if ($vocabulary->tags) {
      $tags_select[$vocabulary->vid] = $vocabulary->name;
    }
  }
  $form['emimport']['global']['emimport_global_tags'] = array(
    '#type' => 'select',
    '#title' => t('Tags vocabulary'),
    '#description' => t('When importing an individual set, any tags imported (or overridden) for an item will be saved into this vocabulary, if allowed for that node type. This value may always be overridden below.'),
    '#options' => $tags_select,
    '#default_value' => variable_get('emimport_global_tags', 0),
  );
  $system_types = _content_type_info();
  $content_types = $system_types['content types'];
  $field_types = $system_types['field types'];

  // the array that will store type/field information for provider import
  $types = emfield_implement_types(FALSE);

  // settings per module
  foreach (module_implements('emfield_info', TRUE) as $module) {
    $module_info = module_invoke($module, 'emfield_info');
    $form['emimport'][$module] = array(
      '#type' => 'fieldset',
      '#title' => $module_info['#name'],
      '#description' => $module_info['#settings_description'],
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['emimport'][$module]['emimport_' . $module . '_allow'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow import'),
      '#description' => t('When checked, this will allow importing into certain node types that include at least one %module.', array(
        '%module' => $module_info['#name'],
      )),
      '#default_value' => variable_get('emimport_' . $module . '_allow', TRUE),
    );
    $form['emimport'][$module]['emimport_' . $module . '_display'] = array(
      '#type' => 'textfield',
      '#title' => t('Import display limit'),
      '#description' => t('This will limit how many titles/thumbnails will be displayed on the actual import page for %module types, when checking the individual set items to import. Keep at 0 to allow individual providers to override, assuming the global value is also 0.', array(
        '%module' => $module_info['#name'],
      )),
      '#default_value' => variable_get('emimport_' . $module . '_display', 0),
    );
    $tags_select = array(
      0 => '(None)',
    );
    foreach (taxonomy_get_vocabularies() as $vocabulary) {
      if ($vocabulary->tags) {
        $tags_select[$vocabulary->vid] = $vocabulary->name;
      }
    }
    $form['emimport'][$module]['emimport_' . $module . '_tags'] = array(
      '#type' => 'select',
      '#title' => t('Tags vocabulary'),
      '#description' => t('When importing an individual set, any tags imported (or overridden) for an item will be saved into this vocabulary, if allowed for that node type. If selected, this will override the global value.'),
      '#options' => $tags_select,
      '#default_value' => variable_get('emimport_' . $module . '_tags', 0),
    );

    // settings per content type for the module
    $form['emimport'][$module]['types'] = array(
      '#type' => 'fieldset',
      '#title' => t('Content types'),
      '#description' => t('Settings affecting sets imported into types defining %module fields.', array(
        '%module' => $module_info['#name'],
      )),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    if (is_array($types[$module])) {
      foreach ($types[$module] as $content_type => $fields) {

        // settings per content type per module
        $form['emimport'][$module]['types'][$content_type] = array(
          '#type' => 'fieldset',
          '#title' => $content_types[$content_type]['name'],
          '#description' => t('Settings affecting %module sets imported into !type nodes.', array(
            '%module' => $module_info['#name'],
            '!type' => l($content_types[$content_type]['name'], 'admin/content/types/' . $content_types[$type]['url_str']),
          )),
          '#collapsible' => TRUE,
          '#collapsed' => TRUE,
        );
        $form['emimport'][$module]['types'][$content_type]['emimport_' . $module . '_type_allow_' . $content_type] = array(
          '#type' => 'checkbox',
          '#title' => t('Allow import'),
          '#description' => t('When checked, this will allow importing %module sets into this node type.', array(
            '%module' => $module_info['#name'],
          )),
          '#default_value' => variable_get('emimport_' . $module . '_type_allow_' . $content_type, TRUE),
        );
        $form['emimport'][$module]['types'][$content_type]['emimport_' . $module . '_type_display_' . $content_type] = array(
          '#type' => 'textfield',
          '#title' => t('Import display limit'),
          '#description' => t('This will limit how many titles/thumbnails will be displayed on the actual import page for %module types, when checking the individual set items to import. Keep at 0 to allow individual providers to override, assuming the global value is also 0.', array(
            '%module' => $module_info['#name'],
          )),
          '#default_value' => variable_get('emimport_' . $module . '_type_display_' . $content_type, 0),
        );
        $tags_select = array(
          0 => '(None)',
        );
        foreach (taxonomy_get_vocabularies() as $vocabulary) {
          if ($vocabulary->tags && in_array($content_type, $vocabulary->nodes)) {
            $tags_select[$vocabulary->vid] = $vocabulary->name;
          }
        }
        $form['emimport'][$module]['types'][$content_type]['emimport_' . $module . '_type_tags_' . $content_type] = array(
          '#type' => 'select',
          '#title' => t('Tags vocabulary'),
          '#description' => t('When importing an individual set, any tags imported (or overridden) for an item will be saved into this vocabulary, if allowed for that node type. If selected, this will override the %module value.', array(
            '%module' => $module_info['#name'],
          )),
          '#options' => $tags_select,
          '#default_value' => variable_get('emimport_' . $module . '_type_tags_' . $content_type, 0),
        );
      }
    }
    $emfield_info = module_invoke($module, 'emfield_info');
    $form['emimport'][$module]['providers'] = array(
      '#type' => 'fieldset',
      '#title' => t('Provider settings'),
      '#description' => t('If a provider allowed on the !media also allows importing content from sets, such as photosets or playlists, then it will be listed below. You may change specific settings for those providers here. If you don\'t see an expected provider here, first make sure that it is enabled on the !media page, and also make sure there that the provider allows that feature.', array(
        '!media' => l(t('media settings page'), 'admin/content/emfield/media'),
      )),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $providers = emfield_system_list($module);

    // individual provider settings
    foreach ($providers as $provider) {

      // only include a provider if we may actually make nodes embedding that provider
      if (variable_get('emfield_' . $module . '_allow_' . $provider->name, TRUE)) {
        if (emfield_include_hook($module, $provider->name, 'import')) {
          $info = emfield_include_invoke($module, $provider->name, 'info');
          $form['emimport'][$module]['providers'][$provider->name] = array(
            '#type' => 'fieldset',
            '#title' => $info['name'],
            '#description' => $info['settings_description'],
            '#collapsible' => TRUE,
            '#collapsed' => TRUE,
          );
          $form['emimport'][$module]['providers'][$provider->name]['emimport_' . $module . '_allow_' . $provider->name] = array(
            '#type' => 'checkbox',
            '#title' => t('Allow importing @sets from %provider.', array(
              '@sets' => $info['import_sets_word'] ? $info['import_sets_word'] : t('sets'),
              '%provider' => $info['name'],
            )),
            '#default_value' => variable_get('emimport_' . $module . '_allow_' . $provider->name, TRUE),
          );
          $form['emimport'][$module]['providers'][$provider->name]['emimport_' . $module . '_display_' . $provider->name] = array(
            '#type' => 'textfield',
            '#title' => t('Import display limit'),
            '#description' => t('This will limit how many titles/thumbnails will be displayed on the actual import page, when checking the individual set items to import.'),
            '#default_value' => variable_get('emimport_' . $module . '_display_' . $provider->name, 0),
          );
          $tags_select = array(
            0 => '(None)',
          );
          foreach (taxonomy_get_vocabularies() as $vocabulary) {
            if ($vocabulary->tags) {
              $tags_select[$vocabulary->vid] = $vocabulary->name;
            }
          }
          $form['emimport'][$module]['providers'][$provider->name]['emimport_' . $module . '_tags_' . $provider->name] = array(
            '#type' => 'select',
            '#title' => t('Tags vocabulary'),
            '#description' => t('When importing an individual set, any tags imported (or overridden) from %provider for an item will be saved into this vocabulary, if allowed for that node type. If selected, this will override the global, %module, and node type values.', array(
              '%module' => $module_info['#name'],
              '%provider' => $info['name'],
            )),
            '#options' => $tags_select,
            '#default_value' => variable_get('emimport_' . $module . '_tags_' . $provider->name, 0),
          );
        }
      }
    }
  }
  return system_settings_form($form);
}