You are here

protected function SocialContent::instanceSettingsForm in Social Content 7.2

Instance settings form.

Return value

array Any instance settings that will be included on all instance forms for the current global.

13 calls to SocialContent::instanceSettingsForm()
SocialContent::getForm in ./social_content.class.inc
Get an internal form of the gievn type.
SocialContent::globalSettingsForm in ./social_content.class.inc
Global settings form.
SocialContentFacebook::instanceSettingsForm in modules/facebook/social_content_facebook.class.inc
Instance settings form.
SocialContentFlickr::instanceSettingsForm in modules/flickr/social_content_flickr.class.inc
Instance settings form.
SocialContentInstagram::instanceSettingsForm in modules/instagram/social_content_instagram.class.inc
Instance settings form.

... See full list

11 methods override SocialContent::instanceSettingsForm()
SocialContentFacebook::instanceSettingsForm in modules/facebook/social_content_facebook.class.inc
Instance settings form.
SocialContentFlickr::instanceSettingsForm in modules/flickr/social_content_flickr.class.inc
Instance settings form.
SocialContentInstagram::instanceSettingsForm in modules/instagram/social_content_instagram.class.inc
Instance settings form.
SocialContentLinkedin::instanceSettingsForm in modules/linkedin/social_content_linkedin.class.inc
Instance settings form.
SocialContentPicasa::instanceSettingsForm in modules/picasa/social_content_picasa.class.inc
Instance settings form.

... See full list

File

./social_content.class.inc, line 233
Social Content class.

Class

SocialContent
TODO: Table names should be a property for ease of change Separate this class into smaller classes.

Code

protected function instanceSettingsForm() {
  $settings = array_merge($this->settings['global'], $this->settings['instance']);
  $form = array();
  if (!isset($settings['id'])) {
    $settings = $this
      ->instanceSettingsFields();
  }
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#description' => t('Friendly name, only seen by administrators.'),
    '#default_value' => isset($settings['title']) ? $settings['title'] : NULL,
    '#required' => TRUE,
  );

  // Content type selection.
  $types = node_type_get_types();
  $content_type_options = array();
  foreach ($types as $type) {
    $content_type_options[$type->type] = $type->name;
  }
  $form['content_type'] = array(
    '#type' => 'select',
    '#title' => t('Content type'),
    '#options' => $content_type_options,
    '#default_value' => isset($settings['content_type']) ? $settings['content_type'] : NULL,
    '#required' => TRUE,
  );

  // Fields mapping.
  $fields = field_info_fields();
  $fields_options = array(
    '_NO_MAP_' => t('Do not map'),
    '_REMOVE_' => t('Remove'),
  );
  foreach ($fields as $field_name => $field_info) {
    $fields_options[$field_name] = $field_name;
  }
  asort($fields_options);
  $form['fields'] = array(
    '#type' => 'fieldset',
    '#description' => t("Please make sure that the local field can accept the remote fields value i.e. don't map a text field to a file field."),
    '#title' => t('Fields'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  foreach ($this
    ->getFieldMappings() as $key => $value) {
    if (empty($key) || in_array($value, array(
      'created',
    ))) {
      continue;
    }
    elseif (isset($settings['fields'][$key])) {
      $default = $settings['fields'][$key];
    }
    else {
      $default = $value;
    }
    $form['fields'][$key] = array(
      '#type' => 'select',
      '#title' => $key,
      '#options' => $fields_options,
      '#default_value' => $default,
    );
  }
  $form['fields']['extra'] = array(
    '#type' => 'textarea',
    '#title' => t('Extra field mappings'),
    '#description' => t('Map extra fields from the record. For example if the response returns an object for each record and the record has object->user->geo, you could could map the geo attribute to a field_user_geo by entering .user.geo|field_user_geo, separate fields by a new line.'),
    '#weight' => 999,
  );
  $form['author'] = array(
    '#type' => 'textfield',
    '#title' => t('Authored by'),
    '#maxlength' => 60,
    '#autocomplete_path' => 'user/autocomplete',
    '#element_validate' => array(
      'social_content_element_validate_user_name',
    ),
    '#description' => t('Leave blank for %anonymous.', array(
      '%anonymous' => variable_get('anonymous', t('Anonymous')),
    )),
  );
  if (isset($settings['author'])) {
    $author = user_load($settings['author']);
    $form['author']['#default_value'] = $author->name;
  }
  else {
    $admin_user = user_load(1);
    $form['author']['#default_value'] = $admin_user->name;
  }
  $form['limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Import limit'),
    '#size' => 10,
    '#description' => t('Set the maximum number of posts to import each time. Leave blank for no limit. Some type of instances may not support this.'),
    '#default_value' => isset($settings['limit']) ? $settings['limit'] : NULL,
    '#required' => FALSE,
    '#element_validate' => array(
      'element_validate_number',
    ),
  );
  $language_options = array(
    LANGUAGE_NONE => t('Language neutral'),
    $this->currentLanguageKey => t('Site language'),
  );
  $languages = language_list();
  foreach ($languages as $langcode => $language) {
    $language_options[$langcode] = $language->language;
  }
  $form['language'] = array(
    '#type' => 'select',
    '#title' => t('Language'),
    '#options' => $language_options,
    '#description' => t('The language to import the content into.'),
    '#default_value' => isset($settings['language']) ? $settings['language'] : NULL,
    '#required' => FALSE,
  );
  if (module_exists('entity_translation')) {
    $form['translate'] = array(
      '#type' => 'select',
      '#title' => t('Translate'),
      '#options' => $language_options,
      '#multiple' => TRUE,
      '#description' => t('Translate imported content to these languages.'),
      '#default_value' => isset($settings['translate']) ? $settings['translate'] : NULL,
      '#required' => FALSE,
    );
    unset($form['translate']['#options'][LANGUAGE_NONE]);
    unset($form['translate']['#options'][$this->currentLanguageKey]);
  }
  $form['auto_publish'] = array(
    '#type' => 'checkbox',
    '#title' => t('Auto publish'),
    '#default_value' => isset($settings['auto_publish']) ? $settings['auto_publish'] : NULL,
    '#required' => FALSE,
  );
  $form['enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enabled on cron'),
    '#default_value' => isset($settings['enabled']) ? $settings['enabled'] : NULL,
    '#required' => FALSE,
  );
  $form['auto_delete'] = array(
    '#type' => 'textfield',
    '#title' => t('Auto delete'),
    '#size' => 10,
    '#description' => t('Automatically delete imported content posted after X days. Leave blank to keep it forever.'),
    '#default_value' => isset($settings['auto_delete']) ? $settings['auto_delete'] : NULL,
    '#required' => FALSE,
    '#field_suffix' => 'days',
    '#element_validate' => array(
      'element_validate_number',
    ),
  );
  $form['global'] = array(
    '#type' => 'hidden',
    '#value' => isset($settings['global']) ? $settings['global'] : NULL,
  );
  $form['id'] = array(
    '#type' => 'hidden',
    '#value' => isset($settings['id']) ? $settings['id'] : NULL,
  );
  return $form;
}