function node_gallery_api_field_information in Node Gallery 7
Field information.
2 calls to node_gallery_api_field_information()
- node_gallery_api_create_field in ./
node_gallery_api.module - Create a node gallery field in a bundle.
- node_gallery_api_entity_update in ./
node_gallery_api.module - Implements hook_entity_update().
File
- ./
node_gallery_api.module, line 794 - Node Gallery module.
Code
function node_gallery_api_field_information($field_name = NULL) {
// We can't use node_gallery_api_get_relationship_type() here because it
// creates PHP notices from this core issue: http://drupal.org/node/1001060.
$relationship_types = db_select('node_gallery_relationship_type', 'ngrt')
->fields('ngrt')
->execute();
if (!empty($relationship_types)) {
foreach ($relationship_types as $relationship_type) {
$relationship_type->settings = unserialize($relationship_type->settings);
$relationship_type->item_types = $relationship_type->settings['relationship_type']['item_types'];
$relationship_type->gallery_types = $relationship_type->settings['relationship_type']['gallery_types'];
$name = node_gallery_api_get_item_field_name(NULL, NULL, $relationship_type->id);
$items[$name] = array(
'no ui' => TRUE,
'type' => array(
'gallery item',
),
'description' => t('Determine to which galleries this gallery item is assigned to.'),
'field' => array(
'field_name' => $name,
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'handler' => 'node_gallery',
'handler_submit' => 'Change handler',
'handler_settings' => array(
'node_gallery_relationship_type' => $relationship_type->id,
'behaviors' => array(
'node_gallery_behavior' => array(
'status' => TRUE,
),
),
'target_bundles' => $relationship_type->gallery_types,
'sort' => array(
'type' => 'property',
'property' => 'title',
'field' => 'body:value',
'direction' => 'ASC',
),
),
'target_type' => 'node',
),
),
'instance' => array(
'label' => t('Galleries'),
'widget' => array(
'module' => 'options',
'settings' => array(),
'type' => 'options_select',
),
'display' => array(
'default' => array(
'module' => 'options',
'label' => 'inline',
'type' => 'hidden',
'settings' => array(),
),
),
),
);
}
}
$items[NODE_GALLERY_MEDIA_FIELD] = array(
'description' => t('Default field for storing node gallery media.'),
'field' => array(
'field_name' => NODE_GALLERY_MEDIA_FIELD,
'type' => 'file',
'cardinality' => 1,
),
'instance' => array(
'label' => t('Gallery Media '),
'description' => t('File to store Node Gallery media.'),
'display_label' => 1,
'settings' => array(
'file_directory' => 'node_gallery',
'file_extensions' => 'jpg jpeg gif png',
'description_field' => 0,
),
'widget' => array(
'module' => 'file',
'type' => 'file_generic',
'weight' => 2,
),
),
);
if (empty($field_name)) {
return $items;
}
if (empty($items[$field_name])) {
return NULL;
}
return $items[$field_name];
}