function node_gallery_api_relationship_type_content_types_form in Node Gallery 7
Form definition for relationship type content types.
1 string reference to 'node_gallery_api_relationship_type_content_types_form'
- node_gallery_api_menu in ./
node_gallery_api.module - Implements hook_menu().
File
- ./
node_gallery_api.admin.inc, line 104 - Node Gallery API admin interface.
Code
function node_gallery_api_relationship_type_content_types_form($form, $form_state, $relationship_type = NULL) {
static $node_types;
$form['relationship_type'] = array(
'#tree' => TRUE,
);
if (empty($node_types)) {
foreach (node_type_get_types() as $node_type) {
$node_types[$node_type->type] = check_plain($node_type->name);
}
}
$form['#relationship_type'] = $relationship_type;
$form['relationship_type']['gallery_types'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Gallery Types'),
'#options' => $node_types,
'#description' => t('Select which content type should be used as the gallery type.'),
'#default_value' => !empty($relationship_type->gallery_types) ? $relationship_type->gallery_types : NULL,
'#required' => TRUE,
);
$form['relationship_type']['item_types'] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => t('Item Types'),
'#options' => $node_types,
'#description' => t('Select which content type should be used as the item type.'),
'#default_value' => !empty($relationship_type->item_types) ? $relationship_type->item_types : NULL,
'#required' => TRUE,
);
$item_types = isset($relationship_type->item_types) ? $relationship_type->item_types : NULL;
if (empty($item_types)) {
$item_types = array_keys(node_type_get_types());
}
$item_fields = node_gallery_api_get_fields_from_content_types($item_types);
$file_fields = array(
'node_gallery_none' => 'None',
);
foreach ($item_fields as $name => $field) {
$item_field_options[$name] = check_plain($field['label']);
if (!empty($field['field_info']) && in_array($field['field_info']['type'], array(
'file',
'image',
))) {
$file_fields[$name] = $name;
}
}
if (!array_key_exists(NODE_GALLERY_MEDIA_FIELD, $file_fields)) {
$file_fields['node_gallery_create'] = t('Create new file field');
}
$form['relationship_type']['filefield_name'] = array(
'#type' => 'select',
'#title' => t('File storage field'),
'#description' => t("Select the file field that will be used for storing gallery item media. In most cases, you shouldn't need to change this setting."),
'#options' => $file_fields,
'#default_value' => !empty($relationship_type->filefield_name) ? $relationship_type->filefield_name : NODE_GALLERY_MEDIA_FIELD,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}