function i18nsync_node_available_fields in Internationalization 6
Same name and namespace in other branches
- 5.3 experimental/i18nsync.module \i18nsync_node_available_fields()
- 5 experimental/i18nsync.module \i18nsync_node_available_fields()
- 5.2 experimental/i18nsync.module \i18nsync_node_available_fields()
Returns list of available fields for given content type.
There are two hidden variables (without UI) that can be used to add fields with the form array('field' => 'Field name')
- i18nsync_fields_node
- i18nsync_fields_node_$type;
Fields can also be changed using hook_i18nsync_fields_alter($fields, $type)
Parameters
$type: Node type.
1 call to i18nsync_node_available_fields()
- i18nsync_form_alter in i18nsync/
i18nsync.module - Implementation of hook_form_alter().
File
- i18nsync/
i18nsync.module, line 460 - Internationalization (i18n) package. Synchronization of translations
Code
function i18nsync_node_available_fields($type) {
static $cache;
if (!isset($cache[$type])) {
// Default node fields.
$fields['node']['#title'] = t('Standard node fields.');
$options = variable_get('i18nsync_fields_node', array());
$options += array(
'name' => 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')) {
$options['files'] = t('File attachments');
}
// Location module
if (module_exists('location')) {
$options['locations'] = t('Location settings');
}
// 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 and image attach.
if (module_exists('image') && $type == 'image') {
$image['images'] = t('Image files');
}
if (module_exists('image_attach') && variable_get('image_attach_' . $type, 0)) {
$image['iid'] = t('Attached image nodes');
}
if (!empty($image)) {
$fields['image']['#title'] = t('Image module');
$fields['image']['#options'] = $image;
}
// 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 ($contentfields = _i18nsync_cck_fields($type)) {
// Get context information.
$info = module_invoke('content', 'fields', NULL, $type);
$fields['cck']['#title'] = t('CCK fields');
foreach ($contentfields as $name => $data) {
$fields['cck']['#options'][$data['field_name']] = $data['widget']['label'];
}
}
// Give a chance to modules to change/remove/add their own fields
drupal_alter('i18nsync_fields', $fields, $type);
$cache[$type] = $fields;
}
return $cache[$type];
}