Contributions API

i18nsync_node_available_fields

Definition

i18nsync_node_available_fields($type)
contributions/i18n/i18nsync/i18nsync.module, line 275

Description

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

Code

<?php
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)'),
      'taxonomy' => t('Taxonomy terms'),
  );
  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_node_$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
  /* Disabled until there's a stable version of CCK + views
  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;
}
?>