You are here

function i18nsync_node_available_fields in Internationalization 5

Same name and namespace in other branches
  1. 5.3 experimental/i18nsync.module \i18nsync_node_available_fields()
  2. 5.2 experimental/i18nsync.module \i18nsync_node_available_fields()
  3. 6 i18nsync/i18nsync.module \i18nsync_node_available_fields()

Returns list of available fields for given content type

Parameters

$type: Node type

$tree: Whether to return in tree form or FALSE for flat list

1 call to i18nsync_node_available_fields()
i18nsync_form_alter in experimental/i18nsync.module
Implementation of hook_form_alter().

File

experimental/i18nsync.module, line 250
Internationalization (i18n) package. Synchronization of translations

Code

function i18nsync_node_available_fields($type) {

  // Default node fields
  $fields['node']['#title'] = t('Standard node fields.');
  $options = variable_get('i18nsync_fields_node', array());
  $options += array(
    'author' => t('Author'),
    'status' => t('Status'),
    'promote' => t('Promote'),
    'moderate' => t('Moderate'),
    'sticky' => t('Sticky'),
    'revision' => t('Revision (Create also new revision for translations)'),
    'parent' => t('Book outline (With the translated parent)'),
  );
  if (module_exists('comment')) {
    $options['comment'] = t('Comment settings');
  }
  if (module_exists('upload') || module_exists('image')) {
    $options['files'] = t('File attachments');
  }

  // If no type defined yet, that's it
  $fields['node']['#options'] = $options;
  if (!$type) {
    return $fields;
  }

  // Get variable for this node type
  $fields += variable_get("i18nsync_fields_{$type}", array());

  // Image attach
  if (variable_get('image_attach_' . $type, 0)) {
    $fields['image']['#title'] = t('Image Attach module');
    $fields['image']['#options']['iid'] = t('Attached image nodes');
  }

  // Event fields
  if (variable_get('event_nodeapi_' . $type, 'never') != 'never') {
    $fields['event']['#title'] = t('Event fields');
    $fields['event']['#options'] = array(
      'event_start' => t('Event start'),
      'event_end' => t('Event end'),
      'timezone' => t('Timezone'),
    );
  }

  // Get CCK fields
  if (($content = module_invoke('content', 'types', $type)) && isset($content['fields'])) {

    // Get context information
    $info = module_invoke('content', 'fields', NULL, $type);
    $fields['cck']['#title'] = t('CCK fields');
    foreach ($content['fields'] as $name => $data) {
      $fields['cck']['#options'][$data['field_name']] = $data['widget']['label'];
    }
  }
  return $fields;
}